Class ByteArrayDocument
java.lang.Object
com.couchbase.client.java.document.AbstractDocument<byte[]>
com.couchbase.client.java.document.ByteArrayDocument
- All Implemented Interfaces:
Document<byte[]>,Serializable
@Uncommitted @Public public class ByteArrayDocument extends AbstractDocument<byte[]> implements Serializable
Handles a byte array as the document value.
This document differs from
BinaryDocument in that there is no manual refcounting needed on the
underlying buffers. As a result, it is much safer to work with than the traditional BinaryDocument
and should be preferred as a result. Note that the cost is a single byte array copy from the buffer, so if this
is still too much then the BinaryDocument should be used as a last resort.- Since:
- 2.5.2
- Author:
- Michael Nitschinger
- See Also:
- Serialized Form
-
Method Summary
Modifier and Type Method Description static ByteArrayDocumentcreate(String id)Creates aByteArrayDocumentwhich the document id.static ByteArrayDocumentcreate(String id, byte[] content)Creates aByteArrayDocumentwhich the document id and content.static ByteArrayDocumentcreate(String id, byte[] content, long cas)Creates aByteArrayDocumentwhich the document id, content and the CAS value.static ByteArrayDocumentcreate(String id, int expiry, byte[] content)Creates aByteArrayDocumentwhich the document id, content and the expiration time.static ByteArrayDocumentcreate(String id, int expiry, byte[] content, long cas)Creates aByteArrayDocumentwhich the document id, content, CAS value, expiration time and status code.static ByteArrayDocumentcreate(String id, int expiry, byte[] content, long cas, MutationToken mutationToken)Creates aByteArrayDocumentwhich the document id, content, CAS value, expiration time and status code.static ByteArrayDocumentfrom(ByteArrayDocument doc, long cas)Creates a copy from a differentByteArrayDocument, but changes the CAS value.static ByteArrayDocumentfrom(ByteArrayDocument doc, String id, byte[] content)Creates a copy from a differentByteArrayDocument, but changes the document ID and content.Methods inherited from class com.couchbase.client.java.document.AbstractDocument
cas, content, equals, expiry, hashCode, id, mutationToken, readFromSerializedStream, toString, writeToSerializedStream
-
Method Details
-
create
Creates aByteArrayDocumentwhich the document id.- Parameters:
id- the per-bucket unique document id.- Returns:
- a
ByteArrayDocument.
-
create
Creates aByteArrayDocumentwhich the document id and content.- Parameters:
id- the per-bucket unique document id.content- the content of the document.- Returns:
- a
ByteArrayDocument.
-
create
Creates aByteArrayDocumentwhich the document id, content and the CAS value.- Parameters:
id- the per-bucket unique document id.content- the content of the document.cas- the CAS (compare and swap) value for optimistic concurrency.- Returns:
- a
ByteArrayDocument.
-
create
Creates aByteArrayDocumentwhich the document id, content and the expiration time.- Parameters:
id- the per-bucket unique document id.content- the content of the document.expiry- the expiration time of the document.- Returns:
- a
ByteArrayDocument.
-
create
Creates aByteArrayDocumentwhich the document id, content, CAS value, expiration time and status code. This factory method is normally only called within the client library when a response is analyzed and a document is returned which is enriched with the status code. It does not make sense to pre populate the status field from the user level code.- Parameters:
id- the per-bucket unique document id.content- the content of the document.cas- the CAS (compare and swap) value for optimistic concurrency.expiry- the expiration time of the document.- Returns:
- a
ByteArrayDocument.
-
create
public static ByteArrayDocument create(String id, int expiry, byte[] content, long cas, MutationToken mutationToken)Creates aByteArrayDocumentwhich the document id, content, CAS value, expiration time and status code. This factory method is normally only called within the client library when a response is analyzed and a document is returned which is enriched with the status code. It does not make sense to pre populate the status field from the user level code.- Parameters:
id- the per-bucket unique document id.content- the content of the document.cas- the CAS (compare and swap) value for optimistic concurrency.expiry- the expiration time of the document.- Returns:
- a
ByteArrayDocument.
-
from
Creates a copy from a differentByteArrayDocument, but changes the document ID and content.- Parameters:
doc- the originalByteArrayDocumentto copy.id- the per-bucket unique document id.content- the content of the document.- Returns:
- a copied
ByteArrayDocumentwith the changed properties.
-
from
Creates a copy from a differentByteArrayDocument, but changes the CAS value.- Parameters:
doc- the originalByteArrayDocumentto copy.cas- the CAS (compare and swap) value for optimistic concurrency.- Returns:
- a copied
ByteArrayDocumentwith the changed properties.
-