Package com.couchbase.client.java.subdoc
Class SubdocOperationResult<OPERATION>
- java.lang.Object
-
- com.couchbase.client.java.subdoc.SubdocOperationResult<OPERATION>
-
@Uncommitted @Private public class SubdocOperationResult<OPERATION> extends Object
Internally represent result corresponding to a singleLookupSpecorMutationSpec, as part of aDocumentFragment.- Since:
- 2.2
- Author:
- Simon Baslé
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <OPERATION>
SubdocOperationResult<OPERATION>createError(String path, OPERATION operation, ResponseStatus status, CouchbaseException exception)Create aSubdocOperationResultthat correspond to a subdoc-level error, to be thrown by the enclosingDocumentFragment when calling content methods.static <OPERATION>
SubdocOperationResult<OPERATION>createFatal(String path, OPERATION operation, RuntimeException fatal)Create aSubdocOperationResultthat denotes that a fatal Exception occurred when parsing server-side result.static <OPERATION>
SubdocOperationResult<OPERATION>createResult(String path, OPERATION operation, ResponseStatus status, Object value)Create aSubdocOperationResultthat corresponds to an operation that should return a content (including null) instead of throwing when callingDocumentFragment.content(String).static <OPERATION>
SubdocOperationResult<OPERATION>createResult(String path, OPERATION operation, ResponseStatus status, Object value, byte[] rawValue)Create aSubdocOperationResultthat corresponds to an operation that should return a content (including null) instead of throwing when callingDocumentFragment.content(String).booleanexists()booleanisFatal()OPERATIONoperation()Stringpath()byte[]rawValue()Returns the serialized form of the value of a successful GET, as an array of bytes, or null for any other case, including when the raw value isn't relevant.ResponseStatusstatus()StringtoString()Objectvalue()Returns: - the value retrieved by a successful GET.
-
-
-
Method Detail
-
createFatal
public static <OPERATION> SubdocOperationResult<OPERATION> createFatal(String path, OPERATION operation, RuntimeException fatal)
Create aSubdocOperationResultthat denotes that a fatal Exception occurred when parsing server-side result. The exception can be found as the value, and the status isResponseStatus.FAILURE.- Parameters:
path- the path looked up.operation- the type of the operation which result couldn't be parsed.fatal- the Exception that occurred during response parsing.- Returns:
- the fatal LookupResult.
-
createResult
public static <OPERATION> SubdocOperationResult<OPERATION> createResult(String path, OPERATION operation, ResponseStatus status, Object value)
Create aSubdocOperationResultthat corresponds to an operation that should return a content (including null) instead of throwing when callingDocumentFragment.content(String).- Parameters:
path- the path looked up.operation- the type of operation.status- the status of the operation.value- the value of the operation if applicable, null otherwise.- Returns:
- the operation result.
-
createResult
public static <OPERATION> SubdocOperationResult<OPERATION> createResult(String path, OPERATION operation, ResponseStatus status, Object value, byte[] rawValue)
Create aSubdocOperationResultthat corresponds to an operation that should return a content (including null) instead of throwing when callingDocumentFragment.content(String). Additionally, the result can also contain a raw byte representation of the same content in serialized form.- Parameters:
path- the path looked up.operation- the type of operation.status- the status of the operation.value- the value of the operation if applicable, null otherwise.rawValue- the raw byte value of the operation if applicable, null otherwise.- Returns:
- the operation result.
-
createError
public static <OPERATION> SubdocOperationResult<OPERATION> createError(String path, OPERATION operation, ResponseStatus status, CouchbaseException exception)
Create aSubdocOperationResultthat correspond to a subdoc-level error, to be thrown by the enclosingDocumentFragment when calling content methods.- Parameters:
path- the path looked up.operation- the type of operation.status- the status of the operation.exception- the exception to throw when trying to access the operation content.- Returns:
- the operation result.
-
path
public String path()
- Returns:
- the path that was looked up.
-
operation
public OPERATION operation()
- Returns:
- the exact kind of lookup that was performed.
-
status
public ResponseStatus status()
- Returns:
- the status of the lookup.
-
exists
public boolean exists()
- Returns:
- true if the value existed (and might have associated value), false otherwise.
-
value
public Object value()
Returns: - the value retrieved by a successful GET. - null for an unsuccessful GET (see thestatus()for details). - true/false for an EXIST (equivalent toexists()). - aRuntimeExceptionif the client side parsing of the result failed (isFatal()).- Returns:
- the value
-
rawValue
public byte[] rawValue()
Returns the serialized form of the value of a successful GET, as an array of bytes, or null for any other case, including when the raw value isn't relevant.- Returns:
- the serialized raw value, if available.
-
isFatal
public boolean isFatal()
- Returns:
- true if there was a fatal error while processing the result on the client side, in which case
value()returns anRuntimeException.
-
-