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 boolean
contains(String key)
Tests whether a projecting result key exists or not.int
count()
Array
getArray(int index)
The result at the given index as an ArrayArray
getArray(String key)
The projecting result value for the given key as a readonly Array object.Blob
getBlob(int index)
The result at the given index as a BlobBlob
getBlob(String key)
The projecting result value for the given key as a Blob object.boolean
getBoolean(int index)
The result at the given index as a booleanboolean
getBoolean(String key)
The projecting result value for the given key as a boolean value.Date
getDate(int index)
The result at the given index as a DateDate
getDate(String key)
The projecting result value for the given key as a Date object.Dictionary
getDictionary(int index)
The result at the given index as a DictionaryDictionary
getDictionary(String key)
The projecting result value for the given key as a readonly Dictionary object.double
getDouble(int index)
The result at the given index as a doubledouble
getDouble(String key)
The projecting result value for the given key as a double value.float
getFloat(int index)
The result at the given index as a floatfloat
getFloat(String key)
The projecting result value for the given key as a float value.int
getInt(int index)
The result at the given index as an intint
getInt(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()
long
getLong(int index)
The result at the given index as a longlong
getLong(String key)
The projecting result value for the given key as a long value Returns 0L if the key doesn't exist.Number
getNumber(int index)
The result at the given index as a NumberNumber
getNumber(String key)
The projecting result value for the given key as a Number object Returns null if the key doesn't exist.String
getString(int index)
The result at the given index as a StringString
getString(String key)
The result value for the given key as a String object Returns null if the key doesn't exist.Object
getValue(int index)
The result value at the given index.Object
getValue(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.String
toJSON()
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:
count
in 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:
getKeys
in 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:
getValue
in 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:
getString
in 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:
getNumber
in 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:
getInt
in 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:
getLong
in 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:
getFloat
in 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:
getDouble
in 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:
getBoolean
in 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:
getBlob
in 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:
getDate
in 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:
getArray
in 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:
getDictionary
in 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:
toMap
in interfaceDictionaryInterface
- Returns:
- The Map representing all values.
-
toJSON
@NonNull public String toJSON()
- Specified by:
toJSON
in interfaceDictionaryInterface
-
contains
public boolean contains(@NonNull String key)
Tests whether a projecting result key exists or not.- Specified by:
contains
in interfaceDictionaryInterface
- Parameters:
key
- The select result key.- Returns:
- True if exists, otherwise false.
-
-