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 fromBinaryDocument
in that there is no manual refcounting needed on the underlying buffers. As a result, it is much safer to work with than the traditionalBinaryDocument
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 theBinaryDocument
should be used as a last resort.- Since:
- 2.5.2
- Author:
- Michael Nitschinger
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ByteArrayDocument
create(String id)
Creates aByteArrayDocument
which the document id.static ByteArrayDocument
create(String id, byte[] content)
Creates aByteArrayDocument
which the document id and content.static ByteArrayDocument
create(String id, byte[] content, long cas)
Creates aByteArrayDocument
which the document id, content and the CAS value.static ByteArrayDocument
create(String id, int expiry, byte[] content)
Creates aByteArrayDocument
which the document id, content and the expiration time.static ByteArrayDocument
create(String id, int expiry, byte[] content, long cas)
Creates aByteArrayDocument
which the document id, content, CAS value, expiration time and status code.static ByteArrayDocument
create(String id, int expiry, byte[] content, long cas, MutationToken mutationToken)
Creates aByteArrayDocument
which the document id, content, CAS value, expiration time and status code.static ByteArrayDocument
from(ByteArrayDocument doc, long cas)
Creates a copy from a differentByteArrayDocument
, but changes the CAS value.static ByteArrayDocument
from(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 Detail
-
create
public static ByteArrayDocument create(String id)
Creates aByteArrayDocument
which the document id.- Parameters:
id
- the per-bucket unique document id.- Returns:
- a
ByteArrayDocument
.
-
create
public static ByteArrayDocument create(String id, byte[] content)
Creates aByteArrayDocument
which the document id and content.- Parameters:
id
- the per-bucket unique document id.content
- the content of the document.- Returns:
- a
ByteArrayDocument
.
-
create
public static ByteArrayDocument create(String id, byte[] content, long cas)
Creates aByteArrayDocument
which 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
public static ByteArrayDocument create(String id, int expiry, byte[] content)
Creates aByteArrayDocument
which 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
public static ByteArrayDocument create(String id, int expiry, byte[] content, long cas)
Creates aByteArrayDocument
which 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 aByteArrayDocument
which 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
public static ByteArrayDocument from(ByteArrayDocument doc, String id, byte[] content)
Creates a copy from a differentByteArrayDocument
, but changes the document ID and content.- Parameters:
doc
- the originalByteArrayDocument
to copy.id
- the per-bucket unique document id.content
- the content of the document.- Returns:
- a copied
ByteArrayDocument
with the changed properties.
-
from
public static ByteArrayDocument from(ByteArrayDocument doc, long cas)
Creates a copy from a differentByteArrayDocument
, but changes the CAS value.- Parameters:
doc
- the originalByteArrayDocument
to copy.cas
- the CAS (compare and swap) value for optimistic concurrency.- Returns:
- a copied
ByteArrayDocument
with the changed properties.
-
-