@InterfaceStability.Committed @InterfaceAudience.Public public class LookupInBuilder extends Object
execute()
method. Operations are performed synchronously (see AsyncLookupInBuilder
for an asynchronous
version).
Instances of this builder should be obtained through Bucket.lookupIn(String)
rather than directly
constructed.Constructor and Description |
---|
LookupInBuilder(AsyncLookupInBuilder async,
long defaultTimeout,
TimeUnit defaultTimeUnit)
Instances of this builder should be obtained through
Bucket.lookupIn(String) rather than directly
constructed. |
Modifier and Type | Method and Description |
---|---|
LookupInBuilder |
accessDeleted(boolean accessDeleted)
Set accessDeleted to true, if the document has been deleted to access xattrs
|
DocumentFragment<Lookup> |
execute()
Perform several
lookup operations inside a single existing JSON document ,
using the default key/value timeout. |
DocumentFragment<Lookup> |
execute(long timeout,
TimeUnit timeUnit)
Perform several
lookup operations inside a single existing JSON document ,
using a specific timeout. |
LookupInBuilder |
exists(Iterable<String> paths,
SubdocOptionsBuilder optionsBuilder)
Check if a value exists inside the document (if it does not, attempting to get the
DocumentFragment.content(int) will raise an error). |
LookupInBuilder |
exists(String... paths)
Check if a value exists inside the document (if it does not, attempting to get the
DocumentFragment.content(int) will raise an error). |
LookupInBuilder |
exists(String path,
SubdocOptionsBuilder optionsBuilder)
Check if a value exists inside the document (if it does not, attempting to get the
DocumentFragment.content(int) will raise an error). |
LookupInBuilder |
get()
Get full JSON document
|
LookupInBuilder |
get(Iterable<String> paths,
SubdocOptionsBuilder optionsBuilder)
Get a value inside the JSON document.
|
LookupInBuilder |
get(String... paths)
Get a value inside the JSON document.
|
LookupInBuilder |
get(String path,
SubdocOptionsBuilder optionsBuilder)
Get a value inside the JSON document.
|
LookupInBuilder |
getCount(Iterable<String> paths,
SubdocOptionsBuilder optionsBuilder)
Get a count of values inside the JSON document.
|
LookupInBuilder |
getCount(String... paths)
Get a count of values inside the JSON document.
|
LookupInBuilder |
getCount(String path,
SubdocOptionsBuilder optionsBuilder)
Get a count of values inside the JSON document.
|
LookupInBuilder |
includeRaw(boolean includeRaw)
Set to true, includes the raw byte value for each GET in the results, in addition to the deserialized content.
|
boolean |
isIncludeRaw() |
String |
toString() |
@InterfaceAudience.Private public LookupInBuilder(AsyncLookupInBuilder async, long defaultTimeout, TimeUnit defaultTimeUnit)
Bucket.lookupIn(String)
rather than directly
constructed.@InterfaceStability.Committed public LookupInBuilder accessDeleted(boolean accessDeleted)
accessDeleted
- true to access deleted document xattrspublic DocumentFragment<Lookup> execute()
lookup
operations inside a single existing JSON document
,
using the default key/value timeout.
The list of path to look for inside the JSON is constructed through builder methods get(String...)
and
exists(String...)
.
The subdocument API has the benefit of only transmitting the fragment of the document you work with
on the wire, instead of the whole document.
If multiple operations are specified, each spec will receive an answer, overall contained in a
DocumentFragment
, meaning that if sub-document level error conditions happen (like the path is malformed
or doesn't exist), the whole operation still succeeds.
If a single operation is specified, then any error other that a path not found will throw the corresponding
SubDocumentException
. Otherwise a DocumentFragment
is returned.
Calling DocumentFragment.content(String)
or one of its variants on a failed spec/path will throw the
corresponding SubDocumentException
. For successful gets, it will return the value (or null in the case
of a path not found, and only in this case). For exists, it will return true (or false for a path not found).
To check for any error without throwing an exception, use DocumentFragment.status(String)
(or its index-based variant).
To check that a given path (or index) is valid for calling content()
on
it without raising an Exception, use DocumentFragment.exists(String)
.
One special fatal error can also happen, when the value couldn't be decoded from JSON. In that case,
the ResponseStatus for the path is ResponseStatus.FAILURE
and the content(path) will throw a
TranscodingException
.
This operation throws under the following notable error conditions:
- The enclosing document does not exist: DocumentDoesNotExistException
- The enclosing document is not JSON: DocumentNotJsonException
- No lookup was defined through the builder API: IllegalArgumentException
Other document-level error conditions are similar to those encountered during a document-level AsyncBucket.get(String)
.DocumentFragment
representing the whole list of results (1 for each spec), unless a
document-level error happened (in which case an exception is thrown).public DocumentFragment<Lookup> execute(long timeout, TimeUnit timeUnit)
lookup
operations inside a single existing JSON document
,
using a specific timeout.
The list of path to look for inside the JSON is constructed through builder methods get(String...)
and
exists(String...)
.
The subdocument API has the benefit of only transmitting the fragment of the document you work with
on the wire, instead of the whole document.
If multiple operations are specified, each spec will receive an answer, overall contained in a
DocumentFragment
, meaning that if sub-document level error conditions happen (like the path is malformed
or doesn't exist), the whole operation still succeeds.
If a single operation is specified, then any error other that a path not found will throw the corresponding
SubDocumentException
. Otherwise a DocumentFragment
is returned.
Calling DocumentFragment.content(String)
or one of its variants on a failed spec/path will throw the
corresponding SubDocumentException
. For successful gets, it will return the value (or null in the case
of a path not found, and only in this case). For exists, it will return true (or false for a path not found).
To check for any error without throwing an exception, use DocumentFragment.status(String)
(or its index-based variant).
To check that a given path (or index) is valid for calling content()
on
it without raising an Exception, use DocumentFragment.exists(String)
.
One special fatal error can also happen, when the value couldn't be decoded from JSON. In that case,
the ResponseStatus for the path is ResponseStatus.FAILURE
and the content(path) will throw a
TranscodingException
.
This operation throws under the following notable error conditions:
- The enclosing document does not exist: DocumentDoesNotExistException
- The enclosing document is not JSON: DocumentNotJsonException
- No lookup was defined through the builder API: IllegalArgumentException
Other document-level error conditions are similar to those encountered during a document-level AsyncBucket.get(String)
.timeout
- the specific timeout to apply for the operation.timeUnit
- the time unit for the timeout.DocumentFragment
representing the whole list of results (1 for each spec), unless a
document-level error happened (in which case an exception is thrown).public LookupInBuilder get(String... paths)
paths
- the paths inside the document where to get the value from.@InterfaceStability.Experimental public LookupInBuilder get()
public LookupInBuilder get(String path, SubdocOptionsBuilder optionsBuilder)
path
- the paths inside the document where to get the value from.optionsBuilder
- SubdocOptionsBuilder
public LookupInBuilder get(Iterable<String> paths, SubdocOptionsBuilder optionsBuilder)
paths
- the paths inside the document where to get the value from.optionsBuilder
- SubdocOptionsBuilder
public LookupInBuilder exists(String... paths)
DocumentFragment.content(int)
will raise an error).
This doesn't transmit the value on the wire if it exists, saving the corresponding byte overhead.paths
- the paths inside the document to check for existence.public LookupInBuilder exists(String path, SubdocOptionsBuilder optionsBuilder)
DocumentFragment.content(int)
will raise an error).
This doesn't transmit the value on the wire if it exists, saving the corresponding byte overhead.path
- the path inside the document to check for existence.optionsBuilder
- SubdocOptionsBuilder
public LookupInBuilder exists(Iterable<String> paths, SubdocOptionsBuilder optionsBuilder)
DocumentFragment.content(int)
will raise an error).
This doesn't transmit the value on the wire if it exists, saving the corresponding byte overhead.paths
- the paths inside the document to check for existence.optionsBuilder
- SubdocOptionsBuilder
public LookupInBuilder getCount(String... paths)
paths
- the paths inside the document where to get the count from.public LookupInBuilder getCount(String path, SubdocOptionsBuilder optionsBuilder)
path
- the paths inside the document where to get the count from.optionsBuilder
- SubdocOptionsBuilder
public LookupInBuilder getCount(Iterable<String> paths, SubdocOptionsBuilder optionsBuilder)
paths
- the paths inside the document where to get the count from.optionsBuilder
- SubdocOptionsBuilder
public LookupInBuilder includeRaw(boolean includeRaw)
public boolean isIncludeRaw()
Copyright © 2015 Couchbase, Inc.