Package com.couchbase.lite
Class Result
java.lang.Object
com.couchbase.lite.internal.BaseJFleeceCollection
com.couchbase.lite.Result
- All Implemented Interfaces:
ArrayInterface,DictionaryInterface,com.couchbase.lite.internal.fleece.JSONEncodable,JFleeceCollectionInterface,Iterable<String>
public final class Result
extends com.couchbase.lite.internal.BaseJFleeceCollection
implements ArrayInterface, DictionaryInterface, com.couchbase.lite.internal.fleece.JSONEncodable, Iterable<String>
Result represents a row of result set returned by a Query.
A Result may be referenced only while the ResultSet that contains it is open. An attempt to reference a Result after calling ResultSet.close on the ResultSet that contains it will throw an CouchbaseLiteError
-
Method Summary
Modifier and TypeMethodDescriptionbooleanTests whether key exists or not.intcount()getArray(int index) The result at the given index interpreted as an Array.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 ArraygetBlob(int index) The result at the given index interpreted as a Blob.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(String key) The result value for the given key as a boolean Returns false if the key doesn't exist or if the value is not a booleangetDate(int index) Gets value at the given index as a Date.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 DategetDictionary(int index) The result at the given index interpreted as a Dictionary.getDictionary(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.doubleThe 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.floatThe 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.intThe result value for the given key as an int Returns 0 if the key doesn't exist or if the value is not a intgetKeys()longgetLong(int index) The result at the given index interpreted as a long.longThe result value for the given key as a long Returns 0L if the key doesn't exist or if the value is not a longgetNumber(int index) The result at the given index interpreted as a Number.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 NumbergetString(int index) The result at the given index converted to a StringThe result value for the given key as a String Returns null if the key doesn't exist.getValue(int index) The result value at the given index.<T> TThe result value at the given index.<T> TGets a property's value as an object.The result value for the given key as an Object Returns null if the key doesn't exist.booleanisEmpty()iterator()Gets an iterator over the result's keys.toJSON()Encode a Result as a JSON stringtoList()Gets all the values as a List.toMap()Gets all values as a Map.Methods inherited from class com.couchbase.lite.internal.BaseJFleeceCollection
asArray, asBlob, asBoolean, asDictionary, asNumber, asString, asValue, toBoolean, toDouble, toDouble, toFloat, toFloat, toInteger, toInteger, toJFleece, toJFleeceCollection, toLong, toLongMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
count
public int count()- Specified by:
countin interfaceJFleeceCollectionInterface- Returns:
- the number of the values in the result.
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceJFleeceCollectionInterface
-
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.
-
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.
-
getNumber
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.
-
getString
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.
-
getDate
Gets value at the given index as a Date. JSON does not directly support dates, so the actual property value must be a string, which is then parsed according to the ISO-8601 date format (the default used in JSON.) Returns null if the value doesn't exist, is not a string, or is not parsable as a date. NOTE: This is not a generic date parser! It only recognizes the ISO-8601 format, with or without milliseconds.- Specified by:
getDatein interfaceArrayInterface- Parameters:
index- the index. This value must not exceed the bounds of the array.- Returns:
- the Date value or null.
-
getBlob
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.
-
getArray
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
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.
-
getValue
The result value at the given index.- Specified by:
getValuein interfaceArrayInterface- Parameters:
index- the index of the required value.- Returns:
- the value.
-
getValue
The result value at the given index.- Specified by:
getValuein interfaceArrayInterface- Parameters:
index- the index. This value must be 0 <= index < count().klass- the class of the object.- Returns:
- the array value at the index.
-
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.
-
contains
Tests whether key exists or not.- Specified by:
containsin interfaceDictionaryInterface- Parameters:
key- The select result key.- Returns:
- True if exists, otherwise false.
-
getKeys
- Specified by:
getKeysin interfaceDictionaryInterface- Returns:
- a list of keys
-
getBoolean
The result value for the given key as a boolean Returns false 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.
-
getInt
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
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
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
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.
-
getNumber
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.
-
getString
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.
-
getDate
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.
-
getBlob
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.
-
getArray
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
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.
-
getValue
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.
-
getValue
Gets a property's value as an object. The object types are Blob, Array, Dictionary, Number, or String based on the underlying data type; or nil if the property value is null or the property doesn't exist.- Specified by:
getValuein interfaceDictionaryInterface- Parameters:
key- the key.- Returns:
- The value in the dictionary at the key (or null).
- Throws:
ClassCastException- if the value is not of the passed class.
-
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
Encode a Result as a JSON string- Specified by:
toJSONin interfacecom.couchbase.lite.internal.fleece.JSONEncodable- Returns:
- JSON encoded representation of the Result
- Throws:
CouchbaseLiteException- on encoder failure.
-
iterator
Gets an iterator over the result's keys.
-