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 Details

    • create

      public static ByteArrayDocument create​(String id)
      Creates a ByteArrayDocument 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 a ByteArrayDocument 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 a ByteArrayDocument 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 a ByteArrayDocument 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 a ByteArrayDocument 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 a ByteArrayDocument 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 different ByteArrayDocument, but changes the document ID and content.
      Parameters:
      doc - the original ByteArrayDocument 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 different ByteArrayDocument, but changes the CAS value.
      Parameters:
      doc - the original ByteArrayDocument to copy.
      cas - the CAS (compare and swap) value for optimistic concurrency.
      Returns:
      a copied ByteArrayDocument with the changed properties.