Class LookupInResult

java.lang.Object
com.couchbase.client.java.kv.LookupInResult
Direct Known Subclasses:
LookupInReplicaResult

public class LookupInResult extends Object
This result is returned from successful KeyValue subdocument lookup responses.
Since:
3.0.0
  • Constructor Details

  • Method Details

    • cas

      public long cas()
      Returns the CAS value of document at the time of loading.

      The CAS value is an opaque identifier which is associated with a specific state of the document on the server. It can be used during a subsequent mutation to make sure that the document has not been modified in the meantime.

      If document on the server has been modified in the meantime the SDK will raise a CasMismatchException. In this case the caller is expected to re-do the whole "fetch-modify-update" cycle again. Please refer to the SDK documentation for more information on CAS mismatches and subsequent retries.

    • contentAs

      public <T> T contentAs(int index, Class<T> target)
      Decodes the content at the given index into an instance of the target class.
      Parameters:
      index - the index of the subdoc value to decode.
      target - the target type to decode into.
      Returns:
      the decoded content into the generic type requested.
    • contentAs

      public <T> T contentAs(int index, TypeRef<T> target)
      Decodes the content at the given index into an instance of the target type.
      Parameters:
      index - the index of the subdoc value to decode.
      target - the target type to decode into.
      Returns:
      the decoded content into the generic type requested.
    • contentAsBytes

      @Uncommitted public byte[] contentAsBytes(int index)
      Returns the raw JSON bytes of the content at the given index.

      Note that if the field is a string then it will be surrounded by quotation marks, as this is the raw response from the server. E.g. "foo" will return a 5-byte array.

      Parameters:
      index - the index of the subdoc value to retrieve.
      Returns:
      the JSON content as a byte array
    • contentAsObject

      public JsonObject contentAsObject(int index)
      Decodes the encoded content at the given index into a JsonObject.
      Parameters:
      index - the index at which to decode.
    • contentAsArray

      public JsonArray contentAsArray(int index)
      Decodes the encoded content at the given index into a JsonArray.
      Parameters:
      index - the index at which to decode.
    • exists

      public boolean exists(int index)
      Allows to check if a value at the given index exists.
      Parameters:
      index - the index at which to check.
      Returns:
      true if a value is present at the index, false otherwise.
    • isDeleted

      @Internal public boolean isDeleted()
      Returns whether this document was deleted (a tombstone).

      Will always be false unless LookupInOptions.accessDeleted(boolean) has been set.

      For internal use only: applications should not require it.

      Returns:
      whether this document was a tombstone
    • toString

      public String toString()
      Overrides:
      toString in class Object