@Stability.Volatile public class ScanResult extends Object
| Constructor and Description |
|---|
ScanResult(boolean idOnly,
String id,
byte[] content,
int flags,
long cas,
Optional<Instant> expiry,
Transcoder transcoder)
Creates a new
GetResult. |
| Modifier and Type | Method and Description |
|---|---|
long |
cas()
Returns the CAS value of document at the time of loading.
|
<T> T |
contentAs(Class<T> target)
Decodes the content of the document into an instance of the target class.
|
<T> T |
contentAs(TypeRef<T> target)
Decodes the content of the document into an instance of the target type.
|
JsonArray |
contentAsArray()
Decodes the content of the document into a
JsonArray. |
byte[] |
contentAsBytes()
Returns the raw bytes of the document content.
|
JsonObject |
contentAsObject()
Decodes the content of the document into a
JsonObject. |
boolean |
equals(Object o) |
Optional<Instant> |
expiryTime()
If the document has an expiry, returns the point in time when the loaded
document expires.
|
int |
hashCode() |
String |
id()
Returns the ID of the document.
|
boolean |
idOnly()
Returns true if this result came from a scan where
ScanOptions.idsOnly(boolean)
was set to true. |
String |
toString() |
@Stability.Internal
public ScanResult(boolean idOnly,
String id,
byte[] content,
int flags,
long cas,
Optional<Instant> expiry,
Transcoder transcoder)
GetResult.cas - the cas from the doc.expiry - the expiry if fetched from the doc.public String id()
public boolean idOnly()
ScanOptions.idsOnly(boolean)
was set to true.
If true, attempting to access the document content or metadata will throw
UnsupportedOperationException.
public long cas()
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.
NoSuchElementException - if this result came from a scan
where ScanOptions.idsOnly(boolean) was set to true. See idOnly().public Optional<Instant> expiryTime()
NoSuchElementException - if this result came from a scan
where ScanOptions.idsOnly(boolean) was set to true. See idOnly().public JsonObject contentAsObject()
JsonObject.NoSuchElementException - if this result came from a scan
where ScanOptions.idsOnly(boolean) was set to true. See idOnly().public JsonArray contentAsArray()
JsonArray.NoSuchElementException - if this result came from a scan
where ScanOptions.idsOnly(boolean) was set to true. See idOnly().public <T> T contentAs(Class<T> target)
target - the target class to decode the encoded content into.NoSuchElementException - if this result came from a scan
where ScanOptions.idsOnly(boolean) was set to true. See idOnly().public <T> T contentAs(TypeRef<T> target)
List<String> strings = result.contentAs(new TypeRef<List<String>>(){});
target - the type to decode the encoded content into.NoSuchElementException - if this result came from a scan
where ScanOptions.idsOnly(boolean) was set to true. See idOnly().public byte[] contentAsBytes()
NoSuchElementException - if this result came from a scan
where ScanOptions.idsOnly(boolean) was set to true. See idOnly().Copyright © 2024 Couchbase, Inc.. All rights reserved.