net.named_data.jndn.util
public class Blob extends Object implements Comparable
| Constructor and Description |
|---|
Blob()
Create a new Blob with a null pointer.
|
Blob(Blob blob)
Create a new Blob and take another pointer to the given blob's buffer.
|
Blob(byte[] value)
Create a new Blob with a copy of the bytes in the array.
|
Blob(byte[] value,
boolean copy)
Create a new Blob from the the byte array.
|
Blob(ByteBuffer buffer,
boolean copy)
Create a new Blob from an existing ByteBuffer.
|
Blob(int[] value)
Create a new Blob with a copy of the bytes in the array.
|
Blob(String value)
Create a new Blob from the UTF-8 encoding of the Unicode string.
|
| Modifier and Type | Method and Description |
|---|---|
ByteBuffer |
buf()
Get the read-only ByteBuffer.
|
int |
compare(Blob other)
Compare this to the other Blob using byte-by-byte comparison from their
position to their limit.
|
int |
compareTo(Object o) |
int |
CompareTo(Object o) |
boolean |
equals(Blob other) |
boolean |
equals(Object other) |
byte[] |
getImmutableArray()
Get a byte array by calling ByteBuffer.array() if possible (because the
ByteBuffer slice covers the entire backing array).
|
int |
hashCode()
If the hash code is already computed then return it, otherwise compute and
return the hash code.
|
boolean |
isNull()
Check if the buffer pointer is null.
|
int |
size()
Get the size of the buffer.
|
String |
toHex()
Return a hex string of buf() from position to limit.
|
static String |
toHex(ByteBuffer buffer)
Return a hex string of the contents of buffer from position to limit.
|
static void |
toHex(ByteBuffer buffer,
StringBuffer output)
Write a hex string of the contents of buffer from position to limit to the
output.
|
String |
toString()
Decode the byte array as UTF8 and return the Unicode string.
|
public Blob()
public Blob(Blob blob)
blob - The Blob from which we take another pointer to the same buffer.public Blob(ByteBuffer buffer, boolean copy)
buffer - The existing ByteBuffer. It is important that the buffer
position and limit are correct.copy - If true, copy the contents into a new byte array. If false,
just take a slice which uses the existing byte array in buffer.public Blob(byte[] value,
boolean copy)
value - The byte array. If copy is true, this makes a copy.copy - If true, copy the contents into a new byte array. If false,
just use ByteBuffer.wrap which uses the existing byte array.public Blob(byte[] value)
value - The byte array to copy.public Blob(int[] value)
value - The array of integer to copy where each integer is in
the range 0 to 255.public Blob(String value)
value - The Unicode string which is encoded as UTF-8.public final ByteBuffer buf()
public final byte[] getImmutableArray()
public final int size()
public final boolean isNull()
public final String toHex()
public static void toHex(ByteBuffer buffer, StringBuffer output)
buffer - The buffer.output - The StringBuffer to write to.public static String toHex(ByteBuffer buffer)
buffer - The buffer.public final boolean equals(Blob other)
public final int compare(Blob other)
other - The other Blob to compare with.public final int compareTo(Object o)
compareTo in interface Comparablepublic final int CompareTo(Object o)
public int hashCode()
Copyright © 2016. All rights reserved.