Package com.couchbase.lite
Class Result
- java.lang.Object
-
- com.couchbase.lite.Result
-
- All Implemented Interfaces:
DictionaryInterface,java.lang.Iterable<java.lang.String>
public final class Result extends java.lang.Object implements 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 a projecting result key exists or not.intcount()ArraygetArray(int index)The result at the given index as an ArrayArraygetArray(java.lang.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(java.lang.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(java.lang.String key)The projecting result value for the given key as a boolean value.java.util.DategetDate(int index)The result at the given index as a Datejava.util.DategetDate(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.String key)The projecting result value for the given key as a integer value Returns 0 if the key doesn't exist.java.util.List<java.lang.String>getKeys()longgetLong(int index)The result at the given index as a longlonggetLong(java.lang.String key)The projecting result value for the given key as a long value Returns 0L if the key doesn't exist.java.lang.NumbergetNumber(int index)The result at the given index as a Numberjava.lang.NumbergetNumber(java.lang.String key)The projecting result value for the given key as a Number object Returns null if the key doesn't exist.java.lang.StringgetString(int index)The result at the given index as a Stringjava.lang.StringgetString(java.lang.String key)The result value for the given key as a String object 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 a Object Returns null if the key doesn't exist.java.util.Iterator<java.lang.String>iterator()Gets an iterator over the projecting result keys.java.lang.StringtoJSON()java.util.List<java.lang.Object>toList()Gets all values as a List.java.util.Map<java.lang.String,java.lang.Object>toMap()Gets all values as a Dictionary.
-
-
-
Method Detail
-
count
public int count()
- 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.- 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 as a String- 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 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 java.util.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 java.util.List<java.lang.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 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 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 java.lang.String getString(@NonNull java.lang.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 java.lang.Number getNumber(@NonNull java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.util.Date getDate(@NonNull java.lang.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 java.lang.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 java.lang.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 java.util.Map<java.lang.String,java.lang.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 java.lang.String toJSON()
- Specified by:
toJSONin interfaceDictionaryInterface
-
contains
public boolean contains(@NonNull java.lang.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.
-
iterator
@NonNull public java.util.Iterator<java.lang.String> iterator()
Gets an iterator over the projecting result keys.- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.String>- Returns:
- The Iterator object of all result keys.
-
-