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 boolean
contains(java.lang.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(java.lang.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(java.lang.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(java.lang.String key)
The projecting result value for the given key as a boolean value.java.util.Date
getDate(int index)
The result at the given index as a Datejava.util.Date
getDate(java.lang.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(java.lang.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(java.lang.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(java.lang.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(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()
long
getLong(int index)
The result at the given index as a longlong
getLong(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.Number
getNumber(int index)
The result at the given index as a Numberjava.lang.Number
getNumber(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.String
getString(int index)
The result at the given index as a Stringjava.lang.String
getString(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.Object
getValue(int index)
The result value at the given index.java.lang.Object
getValue(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.String
toJSON()
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:
count
in 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:
getKeys
in 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:
getValue
in 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:
getString
in 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:
getNumber
in 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:
getInt
in 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:
getLong
in 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:
getFloat
in 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:
getDouble
in 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:
getBoolean
in 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:
getBlob
in 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:
getDate
in 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:
getArray
in 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:
getDictionary
in 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:
toMap
in interfaceDictionaryInterface
- Returns:
- The Map representing all values.
-
toJSON
@NonNull public java.lang.String toJSON()
- Specified by:
toJSON
in interfaceDictionaryInterface
-
contains
public boolean contains(@NonNull java.lang.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.
-
iterator
@NonNull public java.util.Iterator<java.lang.String> iterator()
Gets an iterator over the projecting result keys.- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.String>
- Returns:
- The Iterator object of all result keys.
-
-