Class AbstractSubdocRequest
- java.lang.Object
-
- com.couchbase.client.core.message.AbstractCouchbaseRequest
-
- com.couchbase.client.core.message.kv.AbstractKeyValueRequest
-
- com.couchbase.client.core.message.kv.subdoc.simple.AbstractSubdocRequest
-
- All Implemented Interfaces:
CouchbaseMessage
,CouchbaseRequest
,BinaryRequest
,BinarySubdocRequest
- Direct Known Subclasses:
AbstractSubdocMutationRequest
,SubExistRequest
,SubGetCountRequest
,SubGetRequest
@Committed @Public public abstract class AbstractSubdocRequest extends AbstractKeyValueRequest implements BinarySubdocRequest
Base class for allBinarySubdocRequest
.- Since:
- 1.2
- Author:
- Simon Baslé
-
-
Field Summary
Fields Modifier and Type Field Description static IllegalArgumentException
EXCEPTION_EMPTY_PATH
AnIllegalArgumentException
that is thrown by constructors when a empty path is provided on an operation that doesn't allow them.static NullPointerException
EXCEPTION_NULL_PATH
ANullPointerException
that is thrown by constructors when a null path is provided.-
Fields inherited from class com.couchbase.client.core.message.kv.AbstractKeyValueRequest
DEFAULT_PARTITION
-
-
Constructor Summary
Constructors Constructor Description AbstractSubdocRequest(String key, String path, String bucket, ByteBuf... restOfContent)
Creates a newAbstractSubdocRequest
.AbstractSubdocRequest(String key, String path, String bucket, rx.subjects.Subject<CouchbaseResponse,CouchbaseResponse> observable, ByteBuf... restOfContent)
Creates a newAbstractSubdocRequest
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
cleanUpAndThrow(RuntimeException e)
Utility method to ensure good cleanup when throwing an exception from a constructor.ByteBuf
content()
TheByteBuf
bearing the full content for this request.protected ByteBuf
createContent(ByteBuf pathByteBuf, ByteBuf... restOfContent)
String
path()
Returns the **path** inside a JSON document where values will be obtained/mutated.int
pathLength()
-
Methods inherited from class com.couchbase.client.core.message.kv.AbstractKeyValueRequest
afterSpanSet, key, keyBytes, opaque, operationId, partition, partition
-
Methods inherited from class com.couchbase.client.core.message.AbstractCouchbaseRequest
bucket, complete, creationTime, dispatchHostname, dispatchHostname, emit, fail, incrementRetryCount, isActive, lastLocalId, lastLocalId, lastLocalSocket, lastLocalSocket, lastRemoteSocket, lastRemoteSocket, maxRetryDuration, maxRetryDuration, observable, password, retryAfter, retryAfter, retryCount, retryDelay, retryDelay, span, span, subscriber, succeed, toString, username
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.couchbase.client.core.message.kv.BinaryRequest
key, keyBytes, opaque, partition, partition
-
Methods inherited from interface com.couchbase.client.core.message.kv.subdoc.BinarySubdocRequest
opcode
-
Methods inherited from interface com.couchbase.client.core.message.CouchbaseMessage
creationTime
-
Methods inherited from interface com.couchbase.client.core.message.CouchbaseRequest
bucket, complete, dispatchHostname, dispatchHostname, emit, fail, incrementRetryCount, isActive, lastLocalId, lastLocalId, lastLocalSocket, lastLocalSocket, lastRemoteSocket, lastRemoteSocket, maxRetryDuration, maxRetryDuration, observable, operationId, password, retryAfter, retryAfter, retryCount, retryDelay, retryDelay, span, span, subscriber, succeed, username
-
-
-
-
Field Detail
-
EXCEPTION_NULL_PATH
public static final NullPointerException EXCEPTION_NULL_PATH
ANullPointerException
that is thrown by constructors when a null path is provided.
-
EXCEPTION_EMPTY_PATH
public static final IllegalArgumentException EXCEPTION_EMPTY_PATH
AnIllegalArgumentException
that is thrown by constructors when a empty path is provided on an operation that doesn't allow them.
-
-
Constructor Detail
-
AbstractSubdocRequest
public AbstractSubdocRequest(String key, String path, String bucket, ByteBuf... restOfContent)
Creates a newAbstractSubdocRequest
.- Parameters:
key
- the key of the document.path
- the subdocument path to consider inside the document.bucket
- the bucket of the document.restOfContent
- the optional remainder of thecontent()
of the final protocol message, or null if not applicable- Throws:
NullPointerException
- if the path is null (seeEXCEPTION_NULL_PATH
)
-
AbstractSubdocRequest
public AbstractSubdocRequest(String key, String path, String bucket, rx.subjects.Subject<CouchbaseResponse,CouchbaseResponse> observable, ByteBuf... restOfContent)
Creates a newAbstractSubdocRequest
.- Parameters:
key
- the key of the document.path
- the subdocument path to consider inside the document.bucket
- the bucket of the document.observable
- the observable which receives responses.restOfContent
- the optional remainder of thecontent()
of the final protocol message, or null if not applicable- Throws:
NullPointerException
- if the path is null (seeEXCEPTION_NULL_PATH
)
-
-
Method Detail
-
cleanUpAndThrow
protected void cleanUpAndThrow(RuntimeException e)
Utility method to ensure good cleanup when throwing an exception from a constructor. Cleans the content composite buffer by releasing it before throwing the exception.
-
path
public String path()
Description copied from interface:BinarySubdocRequest
Returns the **path** inside a JSON document where values will be obtained/mutated. Some sub-document operations authorize the use of an empty path while other don't.- Specified by:
path
in interfaceBinarySubdocRequest
- Returns:
- the path to work from inside the JSON document.
-
pathLength
public int pathLength()
- Specified by:
pathLength
in interfaceBinarySubdocRequest
- Returns:
- the length of the path as encoded in the
BinarySubdocRequest.content()
(can serve as an offset from 0 to find the path in the content).
-
content
public ByteBuf content()
Description copied from interface:BinarySubdocRequest
TheByteBuf
bearing the full content for this request. The content is at a minimum comprised of theBinarySubdocRequest.path()
as UTF8 bytes, and can also have any other relevant payload appended (eg. a JSON fragment for mutative operations, seeBinarySubdocMutationRequest.fragment()
). This buffer is to be automatically released once the message has been written on the wire.- Specified by:
content
in interfaceBinarySubdocRequest
- Returns:
- the ByteBuf to serve as a memcached protocol message body.
-
-