Class Result

java.lang.Object
com.couchbase.lite.Result
All Implemented Interfaces:
ArrayInterface, DictionaryInterface, Iterable<String>

public final class Result extends Object implements ArrayInterface, DictionaryInterface, 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 and IllegalStateException

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Tests whether key exists or not.
    int
     
    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 Array
    getBlob(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 Blob
    boolean
    getBoolean(int index)
    The result at the given index interpreted as a boolean.
    boolean
    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
    getDate(int index)
    The result at the given index interpreted 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 Date
    getDictionary(int index)
    The result at the given index interpreted as a Dictionary.
    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
    double
    getDouble(int index)
    The result at the given index interpreted as a double.
    double
    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
    float
    getFloat(int index)
    The result at the given index interpreted as a float.
    float
    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
    int
    getInt(int index)
    The result at the given index interpreted as and an int.
    int
    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
     
    long
    getLong(int index)
    The result at the given index interpreted as a long.
    long
    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
    getNumber(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 Number
    getString(int index)
    The result at the given index converted to a String
    The 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.
    The result value for the given key as an Object Returns null if the key doesn't exist.
    Gets an iterator over the result's keys.
     
    Gets all the values as a List.
    Gets all values as a Map.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Method Details

    • count

      public int count()
      Specified by:
      count in interface ArrayInterface
      Specified by:
      count in interface DictionaryInterface
      Returns:
      the number of the values in the result.
    • getValue

      @Nullable public Object getValue(int index)
      The result value at the given index.
      Specified by:
      getValue in interface ArrayInterface
      Parameters:
      index - the index of the required value.
      Returns:
      the value.
    • getString

      @Nullable public String getString(int index)
      The result at the given index converted to a String
      Specified by:
      getString in interface ArrayInterface
      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 interpreted as a Number. Returns null if the value cannot be so interpreted.
      Specified by:
      getNumber in interface ArrayInterface
      Parameters:
      index - the index of the required value.
      Returns:
      a Number 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:
      getInt in interface ArrayInterface
      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:
      getLong in interface ArrayInterface
      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:
      getFloat in interface ArrayInterface
      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:
      getDouble in interface ArrayInterface
      Parameters:
      index - the index of the required value.
      Returns:
      a double value.
    • 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:
      getBoolean in interface ArrayInterface
      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 interpreted as a Blob. Returns null if the value cannot be so interpreted.
      Specified by:
      getBlob in interface ArrayInterface
      Parameters:
      index - the index of the required value.
      Returns:
      a Blob.
    • getDate

      @Nullable public Date getDate(int index)
      The result at the given index interpreted as a Date. Returns null if the value cannot be so interpreted.
      Specified by:
      getDate in interface ArrayInterface
      Parameters:
      index - the index of the required value.
      Returns:
      a Date.
    • getArray

      @Nullable public Array getArray(int index)
      The result at the given index interpreted as an Array. Returns null if the value cannot be so interpreted.
      Specified by:
      getArray in interface ArrayInterface
      Parameters:
      index - the index of the required value.
      Returns:
      an Array.
    • getDictionary

      @Nullable public Dictionary getDictionary(int index)
      The result at the given index interpreted as a Dictionary. Returns null if the value cannot be so interpreted.
      Specified by:
      getDictionary in interface ArrayInterface
      Parameters:
      index - the index of the required value.
      Returns:
      a Dictionary.
    • toList

      @NonNull public List<Object> 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:
      toList in interface ArrayInterface
      Returns:
      a List containing all values.
    • getKeys

      @NonNull public List<String> getKeys()
      Specified by:
      getKeys in interface DictionaryInterface
      Returns:
      a list of keys
    • getValue

      @Nullable public Object getValue(@NonNull String key)
      The result value for the given key as an Object Returns null if the key doesn't exist.
      Specified by:
      getValue in interface DictionaryInterface
      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 Returns null if the key doesn't exist.
      Specified by:
      getString in interface DictionaryInterface
      Parameters:
      key - The select result key.
      Returns:
      The String object.
    • getNumber

      @Nullable public Number getNumber(@NonNull String key)
      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:
      getNumber in interface DictionaryInterface
      Parameters:
      key - The select result key.
      Returns:
      The Number object.
    • getInt

      public int getInt(@NonNull String key)
      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:
      getInt in interface DictionaryInterface
      Parameters:
      key - The select result key.
      Returns:
      The integer value.
    • getLong

      public long getLong(@NonNull String key)
      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:
      getLong in interface DictionaryInterface
      Parameters:
      key - The select result key.
      Returns:
      The long value.
    • getFloat

      public float getFloat(@NonNull String key)
      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:
      getFloat in interface DictionaryInterface
      Parameters:
      key - The select result key.
      Returns:
      The float value.
    • getDouble

      public double getDouble(@NonNull String key)
      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:
      getDouble in interface DictionaryInterface
      Parameters:
      key - The select result key.
      Returns:
      The double value.
    • getBoolean

      public boolean getBoolean(@NonNull 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 boolean
      Specified by:
      getBoolean in interface DictionaryInterface
      Parameters:
      key - The select result key.
      Returns:
      The boolean value.
    • getBlob

      @Nullable public Blob getBlob(@NonNull String key)
      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:
      getBlob in interface DictionaryInterface
      Parameters:
      key - The select result key.
      Returns:
      The Blob object.
    • getDate

      @Nullable public Date getDate(@NonNull String key)
      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:
      getDate in interface DictionaryInterface
      Parameters:
      key - The select result key.
      Returns:
      The Date object.
    • getArray

      @Nullable public Array getArray(@NonNull String key)
      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:
      getArray in interface DictionaryInterface
      Parameters:
      key - The select result key.
      Returns:
      The Array object.
    • getDictionary

      @Nullable public Dictionary getDictionary(@NonNull 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 Dictionary
      Specified by:
      getDictionary in interface DictionaryInterface
      Parameters:
      key - The select result key.
      Returns:
      The Dictionary object.
    • toMap

      @NonNull public Map<String,Object> 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:
      toMap in interface DictionaryInterface
      Returns:
      The Map representing all values.
    • toJSON

      @NonNull public String toJSON()
      Specified by:
      toJSON in interface ArrayInterface
      Specified by:
      toJSON in interface DictionaryInterface
    • contains

      public boolean contains(@NonNull String key)
      Tests whether key exists or not.
      Specified by:
      contains in interface DictionaryInterface
      Parameters:
      key - The select result key.
      Returns:
      True if exists, otherwise false.
    • iterator

      @NonNull public Iterator<String> iterator()
      Gets an iterator over the result's keys.
      Specified by:
      iterator in interface Iterable<String>
      Returns:
      The Iterator object of all result keys.