Package com.couchbase.lite
Class Result
- java.lang.Object
-
- com.couchbase.lite.Result
-
- All Implemented Interfaces:
ArrayInterface,DictionaryInterface,java.lang.Iterable<java.lang.String>
public final class Result extends java.lang.Object implements ArrayInterface, DictionaryInterface, java.lang.Iterable<java.lang.String>
Result represents a row of result set returned by a Query.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(java.lang.String key)Tests whether key exists or not.intcount()ArraygetArray(int index)The result at the given index interpreted as an Array.ArraygetArray(java.lang.String key)The result value for the given key as a Array Returns null if the key doesn't exist or if the value is not an ArrayBlobgetBlob(int index)The result at the given index interpreted as a Blob.BlobgetBlob(java.lang.String key)The result value for the given key as a Blob Returns null if the key doesn't exist or if the value is not a BlobbooleangetBoolean(int index)The result at the given index interpreted as a boolean.booleangetBoolean(java.lang.String key)The result value for the given key as a boolean Returns null if the key doesn't exist or if the value is not a booleanjava.util.DategetDate(int index)The result at the given index interpreted as a Date.java.util.DategetDate(java.lang.String key)The result value for the given key as a Date Returns null if the key doesn't exist or if the value is not a DateDictionarygetDictionary(int index)The result at the given index interpreted as a Dictionary.DictionarygetDictionary(java.lang.String key)The result value for the given key as a Dictionary Returns null if the key doesn't exist or if the value is not a DictionarydoublegetDouble(int index)The result at the given index interpreted as a double.doublegetDouble(java.lang.String key)The result value for the given key as a double Returns 0.0 if the key doesn't exist or if the value is not a doublefloatgetFloat(int index)The result at the given index interpreted as a float.floatgetFloat(java.lang.String key)The result value for the given key as a float Returns 0.0F if the key doesn't exist or if the value is not a floatintgetInt(int index)The result at the given index interpreted as and an int.intgetInt(java.lang.String key)The result value for the given key as an int Returns 0 if the key doesn't exist or if the value is not a intjava.util.List<java.lang.String>getKeys()longgetLong(int index)The result at the given index interpreted as a long.longgetLong(java.lang.String key)The result value for the given key as a long Returns 0L if the key doesn't exist or if the value is not a longjava.lang.NumbergetNumber(int index)The result at the given index interpreted as a Number.java.lang.NumbergetNumber(java.lang.String key)The result value for the given key as a Number Returns null if the key doesn't exist or if the value is not a Numberjava.lang.StringgetString(int index)The result at the given index converted to a Stringjava.lang.StringgetString(java.lang.String key)The result value for the given key as a String Returns null if the key doesn't exist.java.lang.ObjectgetValue(int index)The result value at the given index.java.lang.ObjectgetValue(java.lang.String key)The result value for the given key as an Object Returns null if the key doesn't exist.java.util.Iterator<java.lang.String>iterator()Gets an iterator over the result's keys.java.lang.StringtoJSON()java.util.List<java.lang.Object>toList()Gets all the values as a List.java.util.Map<java.lang.String,java.lang.Object>toMap()Gets all values as a Map.
-
-
-
Method Detail
-
count
public int count()
- Specified by:
countin interfaceArrayInterface- Specified by:
countin interfaceDictionaryInterface- Returns:
- the number of the values in the result.
-
getValue
@Nullable public java.lang.Object getValue(int index)
The result value at the given index.- Specified by:
getValuein interfaceArrayInterface- Parameters:
index- the index of the required value.- Returns:
- the value.
-
getString
@Nullable public java.lang.String getString(int index)
The result at the given index converted to a String- Specified by:
getStringin interfaceArrayInterface- Parameters:
index- the index of the required value.- Returns:
- a String value.
-
getNumber
@Nullable public java.lang.Number getNumber(int index)
The result at the given index interpreted as a Number. Returns null if the value cannot be so interpreted.- Specified by:
getNumberin interfaceArrayInterface- Parameters:
index- the index of the required value.- Returns:
- a Number value.
-
getInt
public int getInt(int index)
The result at the given index interpreted as and an int. Returns 0 if the value cannot be so interpreted.- Specified by:
getIntin interfaceArrayInterface- Parameters:
index- the index of the required value.- Returns:
- an int value.
-
getLong
public long getLong(int index)
The result at the given index interpreted as a long. Returns 0 if the value cannot be so interpreted.- Specified by:
getLongin interfaceArrayInterface- Parameters:
index- the index of the required value.- Returns:
- a long value.
-
getFloat
public float getFloat(int index)
The result at the given index interpreted as a float. Returns 0.0F if the value cannot be so interpreted.- Specified by:
getFloatin interfaceArrayInterface- Parameters:
index- the index of the required value.- Returns:
- a float value.
-
getDouble
public double getDouble(int index)
The result at the given index interpreted as a double. Returns 0.0 if the value cannot be so interpreted.- Specified by:
getDoublein interfaceArrayInterface- Parameters:
index- the index of the required value.- Returns:
- a double value.
-
getBoolean
public boolean getBoolean(int index)
The result at the given index interpreted as a boolean. Returns false if the value cannot be so interpreted.- Specified by:
getBooleanin interfaceArrayInterface- Parameters:
index- the index of the required value.- Returns:
- a boolean value.
-
getBlob
@Nullable public Blob getBlob(int index)
The result at the given index interpreted as a Blob. Returns null if the value cannot be so interpreted.- Specified by:
getBlobin interfaceArrayInterface- Parameters:
index- the index of the required value.- Returns:
- a Blob.
-
getDate
@Nullable public java.util.Date getDate(int index)
The result at the given index interpreted as a Date. Returns null if the value cannot be so interpreted.- Specified by:
getDatein interfaceArrayInterface- Parameters:
index- the index of the required value.- Returns:
- a Date.
-
getArray
@Nullable public Array getArray(int index)
The result at the given index interpreted as an Array. Returns null if the value cannot be so interpreted.- Specified by:
getArrayin interfaceArrayInterface- Parameters:
index- the index of the required value.- Returns:
- an Array.
-
getDictionary
@Nullable public Dictionary getDictionary(int index)
The result at the given index interpreted as a Dictionary. Returns null if the value cannot be so interpreted.- Specified by:
getDictionaryin interfaceArrayInterface- Parameters:
index- the index of the required value.- Returns:
- a Dictionary.
-
toList
@NonNull public java.util.List<java.lang.Object> toList()
Gets all the values as a List. The types of the values contained in the returned List are Array, Blob, Dictionary, Number types, String, and null.- Specified by:
toListin interfaceArrayInterface- Returns:
- a List containing all values.
-
getKeys
@NonNull public java.util.List<java.lang.String> getKeys()
- Specified by:
getKeysin interfaceDictionaryInterface- Returns:
- a list of keys
-
getValue
@Nullable public java.lang.Object getValue(@NonNull java.lang.String key)The result value for the given key as an Object Returns null if the key doesn't exist.- Specified by:
getValuein interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The Object.
-
getString
@Nullable public java.lang.String getString(@NonNull java.lang.String key)The result value for the given key as a String Returns null if the key doesn't exist.- Specified by:
getStringin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The String object.
-
getNumber
@Nullable public java.lang.Number getNumber(@NonNull java.lang.String key)The result value for the given key as a Number Returns null if the key doesn't exist or if the value is not a Number- Specified by:
getNumberin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The Number object.
-
getInt
public int getInt(@NonNull java.lang.String key)The result value for the given key as an int Returns 0 if the key doesn't exist or if the value is not a int- Specified by:
getIntin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The integer value.
-
getLong
public long getLong(@NonNull java.lang.String key)The result value for the given key as a long Returns 0L if the key doesn't exist or if the value is not a long- Specified by:
getLongin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The long value.
-
getFloat
public float getFloat(@NonNull java.lang.String key)The result value for the given key as a float Returns 0.0F if the key doesn't exist or if the value is not a float- Specified by:
getFloatin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The float value.
-
getDouble
public double getDouble(@NonNull java.lang.String key)The result value for the given key as a double Returns 0.0 if the key doesn't exist or if the value is not a double- Specified by:
getDoublein interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The double value.
-
getBoolean
public boolean getBoolean(@NonNull java.lang.String key)The result value for the given key as a boolean Returns null if the key doesn't exist or if the value is not a boolean- Specified by:
getBooleanin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The boolean value.
-
getBlob
@Nullable public Blob getBlob(@NonNull java.lang.String key)
The result value for the given key as a Blob Returns null if the key doesn't exist or if the value is not a Blob- Specified by:
getBlobin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The Blob object.
-
getDate
@Nullable public java.util.Date getDate(@NonNull java.lang.String key)The result value for the given key as a Date Returns null if the key doesn't exist or if the value is not a Date- Specified by:
getDatein interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The Date object.
-
getArray
@Nullable public Array getArray(@NonNull java.lang.String key)
The result value for the given key as a Array Returns null if the key doesn't exist or if the value is not an Array- Specified by:
getArrayin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The Array object.
-
getDictionary
@Nullable public Dictionary getDictionary(@NonNull java.lang.String key)
The result value for the given key as a Dictionary Returns null if the key doesn't exist or if the value is not a Dictionary- Specified by:
getDictionaryin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The Dictionary object.
-
toMap
@NonNull public java.util.Map<java.lang.String,java.lang.Object> toMap()
Gets all values as a Map. The keys in the returned map are the names of columns that have values. The types of the values are Array, Blob, Dictionary, Number types, String, and null.- Specified by:
toMapin interfaceDictionaryInterface- Returns:
- The Map representing all values.
-
toJSON
@NonNull public java.lang.String toJSON()
- Specified by:
toJSONin interfaceArrayInterface- Specified by:
toJSONin interfaceDictionaryInterface
-
contains
public boolean contains(@NonNull java.lang.String key)Tests whether key exists or not.- Specified by:
containsin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- True if exists, otherwise false.
-
iterator
@NonNull public java.util.Iterator<java.lang.String> iterator()
Gets an iterator over the result's keys.- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.String>- Returns:
- The Iterator object of all result keys.
-
-