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
ConstructorsConstructorDescriptionBinary()Creates an empty Binary instance.Binary(byte[] data) Binary(byte[] data, int offset, int length) Binary(ProtonBuffer buffer) Creates anBinarythat 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 thisBinaryinstance.Creates a read-onlyByteBufferthat contains a copy of the bytes wrapped by this Binary instance.Creates a read-onlyProtonBufferthat contains a copy of the bytes wrapped by this Binary instance.copy()final booleanintfinal inthashCode()toString()
-
Constructor Details
-
Binary
public Binary()Creates an empty Binary instance. -
Binary
Creates anBinarythat 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- theProtonBufferto 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 thisBinaryinstance. 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-onlyByteBufferthat contains a copy of the bytes wrapped by this Binary instance. If the Binary has no backing buffer than this method returnsnull.- Returns:
- a
ByteBuffercopy of the Binary instance backing bytes
-
asProtonBuffer
Creates a read-onlyProtonBufferthat contains a copy of the bytes wrapped by this Binary instance. If the Binary has no backing buffer than this method returnsnull.- Returns:
- a
ProtonBuffercopy of the Binary instance backing bytes
-
hashCode
public final int hashCode() -
equals
-
getLength
public int getLength() -
toString
-