Class Binary

java.lang.Object
org.apache.qpid.protonj2.types.Binary

public final class Binary extends Object
A Binary wrapper that presents an immutable view of a payload.
  • Constructor Details

    • Binary

      public Binary()
      Creates an empty Binary instance.
    • Binary

      public Binary(ProtonBuffer buffer)
      Creates an Binary that wraps the given buffer or copies it if the given buffer is not read-only to preserves the immutable nature of this Binary instance.
      Parameters:
      buffer - the ProtonBuffer to wrap or copy.
    • Binary

      public Binary(byte[] data)
    • Binary

      public Binary(byte[] data, int offset, int length)
  • Method Details

    • copy

      public Binary copy()
    • asByteArray

      public byte[] asByteArray()
      Creates a byte[] that contains a copy of the bytes wrapped by this Binary instance. If the Binary has no backing buffer than this method returns null.
      Returns:
      a byte array based copy of the Binary instance backing bytes
    • asByteBuffer

      public ByteBuffer asByteBuffer()
      Creates a read-only ByteBuffer that contains a copy of the bytes wrapped by this Binary instance. If the Binary has no backing buffer than this method returns null.
      Returns:
      a ByteBuffer copy of the Binary instance backing bytes
    • asProtonBuffer

      public ProtonBuffer asProtonBuffer()
      Creates a read-only ProtonBuffer that contains a copy of the bytes wrapped by this Binary instance. If the Binary has no backing buffer than this method returns null.
      Returns:
      a ProtonBuffer copy of the Binary instance backing bytes
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object o)
      Overrides:
      equals in class Object
    • getLength

      public int getLength()
    • toString

      public String toString()
      Overrides:
      toString in class Object