Package com.couchbase.client.java.kv
Class ScanResult
java.lang.Object
com.couchbase.client.java.kv.ScanResult
Returned for each found item in a KV Range Scan operation.
-
Constructor Summary
ConstructorDescriptionScanResult
(boolean idOnly, String id, byte[] content, int flags, long cas, Optional<Instant> expiry, Transcoder transcoder) Creates a newGetResult
. -
Method Summary
Modifier and TypeMethodDescriptionlong
cas()
Returns the CAS value of document at the time of loading.<T> T
Decodes the content of the document into an instance of the target type.<T> T
Decodes the content of the document into an instance of the target class.Decodes the content of the document into aJsonArray
.byte[]
Returns the raw bytes of the document content.Decodes the content of the document into aJsonObject
.boolean
If the document has an expiry, returns the point in time when the loaded document expires.int
hashCode()
id()
Returns the ID of the document.boolean
idOnly()
Returns true if this result came from a scan whereScanOptions.idsOnly(boolean)
was set to true.toString()
-
Constructor Details
-
Method Details
-
id
Returns the ID of the document.- Returns:
- the ID of the document.
-
idOnly
public boolean idOnly()Returns true if this result came from a scan whereScanOptions.idsOnly(boolean)
was set to true.If true, attempting to access the document content or metadata will throw
UnsupportedOperationException
. -
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.- Throws:
NoSuchElementException
- if this result came from a scan whereScanOptions.idsOnly(boolean)
was set to true. SeeidOnly()
.
-
expiryTime
If the document has an expiry, returns the point in time when the loaded document expires.- Throws:
NoSuchElementException
- if this result came from a scan whereScanOptions.idsOnly(boolean)
was set to true. SeeidOnly()
.
-
contentAsObject
Decodes the content of the document into aJsonObject
.- Throws:
NoSuchElementException
- if this result came from a scan whereScanOptions.idsOnly(boolean)
was set to true. SeeidOnly()
.
-
contentAsArray
Decodes the content of the document into aJsonArray
.- Throws:
NoSuchElementException
- if this result came from a scan whereScanOptions.idsOnly(boolean)
was set to true. SeeidOnly()
.
-
contentAs
Decodes the content of the document into an instance of the target class.- Parameters:
target
- the target class to decode the encoded content into.- Throws:
NoSuchElementException
- if this result came from a scan whereScanOptions.idsOnly(boolean)
was set to true. SeeidOnly()
.
-
contentAs
Decodes the content of the document into an instance of the target type. Example usage:List<String> strings = result.contentAs(new TypeRef<List<String>>(){});
- Parameters:
target
- the type to decode the encoded content into.- Throws:
NoSuchElementException
- if this result came from a scan whereScanOptions.idsOnly(boolean)
was set to true. SeeidOnly()
.
-
contentAsBytes
public byte[] contentAsBytes()Returns the raw bytes of the document content.- Returns:
- the document content as a byte array
- Throws:
NoSuchElementException
- if this result came from a scan whereScanOptions.idsOnly(boolean)
was set to true. SeeidOnly()
.
-
toString
-
equals
-
hashCode
public int hashCode()
-