Package org.apache.qpid.protonj2.types
Class Binary
java.lang.Object
org.apache.qpid.protonj2.types.Binary
A Binary wrapper that presents an immutable view of a payload.
-
Constructor Summary
ConstructorDescriptionBinary()
Creates an empty Binary instance.Binary
(byte[] data) Binary
(byte[] data, int offset, int length) Binary
(ProtonBuffer buffer) Creates anBinary
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. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
Creates abyte[]
that contains a copy of the bytes wrapped by thisBinary
instance.Creates a read-onlyByteBuffer
that contains a copy of the bytes wrapped by this Binary instance.Creates a read-onlyProtonBuffer
that contains a copy of the bytes wrapped by this Binary instance.copy()
final boolean
int
final int
hashCode()
toString()
-
Constructor Details
-
Binary
public Binary()Creates an empty Binary instance. -
Binary
Creates anBinary
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
- theProtonBuffer
to wrap or copy.
-
Binary
public Binary(byte[] data) -
Binary
public Binary(byte[] data, int offset, int length)
-
-
Method Details
-
copy
-
asByteArray
public byte[] asByteArray()Creates abyte[]
that contains a copy of the bytes wrapped by thisBinary
instance. If the Binary has no backing buffer than this method returnsnull
.- Returns:
- a byte array based copy of the Binary instance backing bytes
-
asByteBuffer
Creates a read-onlyByteBuffer
that contains a copy of the bytes wrapped by this Binary instance. If the Binary has no backing buffer than this method returnsnull
.- Returns:
- a
ByteBuffer
copy of the Binary instance backing bytes
-
asProtonBuffer
Creates a read-onlyProtonBuffer
that contains a copy of the bytes wrapped by this Binary instance. If the Binary has no backing buffer than this method returnsnull
.- Returns:
- a
ProtonBuffer
copy of the Binary instance backing bytes
-
hashCode
public final int hashCode() -
equals
-
getLength
public int getLength() -
toString
-