Package com.couchbase.lite
Class Result
- java.lang.Object
-
- com.couchbase.lite.Result
-
- All Implemented Interfaces:
DictionaryInterface,Iterable<String>
public final class Result extends Object implements DictionaryInterface, Iterable<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(String key)Tests whether a projecting result key exists or not.intcount()ArraygetArray(int index)The result at the given index as an ArrayArraygetArray(String key)The projecting result value for the given key as a readonly Array object.BlobgetBlob(int index)The result at the given index as a BlobBlobgetBlob(String key)The projecting result value for the given key as a Blob object.booleangetBoolean(int index)The result at the given index as a booleanbooleangetBoolean(String key)The projecting result value for the given key as a boolean value.DategetDate(int index)The result at the given index as a DateDategetDate(String key)The projecting result value for the given key as a Date object.DictionarygetDictionary(int index)The result at the given index as a DictionaryDictionarygetDictionary(String key)The projecting result value for the given key as a readonly Dictionary object.doublegetDouble(int index)The result at the given index as a doubledoublegetDouble(String key)The projecting result value for the given key as a double value.floatgetFloat(int index)The result at the given index as a floatfloatgetFloat(String key)The projecting result value for the given key as a float value.intgetInt(int index)The result at the given index as an intintgetInt(String key)The projecting result value for the given key as a integer value Returns 0 if the key doesn't exist.List<String>getKeys()longgetLong(int index)The result at the given index as a longlonggetLong(String key)The projecting result value for the given key as a long value Returns 0L if the key doesn't exist.NumbergetNumber(int index)The result at the given index as a NumberNumbergetNumber(String key)The projecting result value for the given key as a Number object Returns null if the key doesn't exist.StringgetString(int index)The result at the given index as a StringStringgetString(String key)The result value for the given key as a String object Returns null if the key doesn't exist.ObjectgetValue(int index)The result value at the given index.ObjectgetValue(String key)The result value for the given key as a Object Returns null if the key doesn't exist.Iterator<String>iterator()Gets an iterator over the projecting result keys.StringtoJSON()List<Object>toList()Gets all values as a List.Map<String,Object>toMap()Gets all values as a Dictionary.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
count
public int count()
- Specified by:
countin interfaceDictionaryInterface- Returns:
- the number of the values in the result.
-
getValue
@Nullable public Object getValue(int index)
The result value at the given index.- Parameters:
index- the index of the required value.- Returns:
- the value.
-
getString
@Nullable public String getString(int index)
The result at the given index as a String- Parameters:
index- the index of the required value.- Returns:
- a String value.
-
getNumber
@Nullable public Number getNumber(int index)
The result at the given index as a Number- Parameters:
index- the index of the required value.- Returns:
- a Number value.
-
getInt
public int getInt(int index)
The result at the given index as an int- Parameters:
index- the index of the required value.- Returns:
- an int value.
-
getLong
public long getLong(int index)
The result at the given index as a long- Parameters:
index- the index of the required value.- Returns:
- a long value.
-
getFloat
public float getFloat(int index)
The result at the given index as a float- Parameters:
index- the index of the required value.- Returns:
- a float value.
-
getDouble
public double getDouble(int index)
The result at the given index as a double- Parameters:
index- the index of the required value.- Returns:
- a double value.
-
getBoolean
public boolean getBoolean(int index)
The result at the given index as a boolean- 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 as a Blob- Parameters:
index- the index of the required value.- Returns:
- a Blob.
-
getDate
@Nullable public Date getDate(int index)
The result at the given index as a Date- Parameters:
index- the index of the required value.- Returns:
- a Date.
-
getArray
@Nullable public Array getArray(int index)
The result at the given index as an Array- Parameters:
index- the index of the required value.- Returns:
- an Array.
-
getDictionary
@Nullable public Dictionary getDictionary(int index)
The result at the given index as a Dictionary- Parameters:
index- the index of the required value.- Returns:
- a Dictionary.
-
toList
@NonNull public List<Object> toList()
Gets all values as a List. The types of the values contained in the returned List are Array, Blob, Dictionary, Number types, String, and null.- Returns:
- a List containing all values.
-
getKeys
@NonNull public List<String> getKeys()
- Specified by:
getKeysin interfaceDictionaryInterface- Returns:
- a list of keys
-
getValue
@Nullable public Object getValue(@NonNull String key)
The result value for the given key as a 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 String getString(@NonNull String key)
The result value for the given key as a String object 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 Number getNumber(@NonNull String key)
The projecting result value for the given key as a Number object Returns null if the key doesn't exist.- Specified by:
getNumberin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The Number object.
-
getInt
public int getInt(@NonNull String key)The projecting result value for the given key as a integer value Returns 0 if the key doesn't exist.- Specified by:
getIntin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The integer value.
-
getLong
public long getLong(@NonNull String key)The projecting result value for the given key as a long value Returns 0L if the key doesn't exist.- Specified by:
getLongin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The long value.
-
getFloat
public float getFloat(@NonNull String key)The projecting result value for the given key as a float value. Returns 0.0f if the key doesn't exist.- Specified by:
getFloatin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The float value.
-
getDouble
public double getDouble(@NonNull String key)The projecting result value for the given key as a double value. Returns 0.0 if the key doesn't exist.- Specified by:
getDoublein interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The double value.
-
getBoolean
public boolean getBoolean(@NonNull String key)The projecting result value for the given key as a boolean value. Returns false if the key doesn't exist.- Specified by:
getBooleanin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The boolean value.
-
getBlob
@Nullable public Blob getBlob(@NonNull String key)
The projecting result value for the given key as a Blob object. Returns null if the key doesn't exist.- Specified by:
getBlobin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The Blob object.
-
getDate
@Nullable public Date getDate(@NonNull String key)
The projecting result value for the given key as a Date object. Returns null if the key doesn't exist.- Specified by:
getDatein interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The Date object.
-
getArray
@Nullable public Array getArray(@NonNull String key)
The projecting result value for the given key as a readonly Array object. Returns null if the key doesn't exist.- Specified by:
getArrayin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The Array object.
-
getDictionary
@Nullable public Dictionary getDictionary(@NonNull String key)
The projecting result value for the given key as a readonly Dictionary object. Returns null if the key doesn't exist.- Specified by:
getDictionaryin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- The Dictionary object.
-
toMap
@NonNull public Map<String,Object> toMap()
Gets all values as a Dictionary. The value types of the values contained in the returned Dictionary object are Array, Blob, Dictionary, Number types, String, and null.- Specified by:
toMapin interfaceDictionaryInterface- Returns:
- The Map representing all values.
-
toJSON
@NonNull public String toJSON()
- Specified by:
toJSONin interfaceDictionaryInterface
-
contains
public boolean contains(@NonNull String key)Tests whether a projecting result key exists or not.- Specified by:
containsin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- True if exists, otherwise false.
-
-