SimpleByteSource

Very simple {@link ByteSource ByteSource} implementation that maintains an internal {@code byte[]} array and uses the {@link Hex Hex} and {@link Base64 Base64} codec classes to support the {@link #toHex() toHex()} and {@link #toBase64() toBase64()} implementations. <p/> The constructors on this class accept the following implicit byte-backed data types and will convert them to a byte-array automatically: <ul> <li>byte[]</li> <li>char[]</li> <li>string</li> <li>{@link ByteSource ByteSource}</li> <li>{@link File File}</li> <li>{@link InputStream InputStream}</li> </ul>

@since 1.0

Constructors

this
this(byte[] bytes)
Undocumented in source.
this
this(char[] chars)

Creates an instance by converting the characters to a byte array (assumes UTF-8 encoding).

this
this(string string)

Creates an instance by converting the string to a byte array (assumes UTF-8 encoding).

this
this(ByteSource source)

Creates an instance using the sources bytes directly - it does not create a copy of the argument's byte array.

Members

Functions

getBytes
byte[] getBytes()
Undocumented in source. Be warned that the author may not have intended to support it.
isEmpty
bool isEmpty()
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Object o)
Undocumented in source. Be warned that the author may not have intended to support it.
toBase64
string toBase64()
Undocumented in source. Be warned that the author may not have intended to support it.
toHash
size_t toHash()
Undocumented in source. Be warned that the author may not have intended to support it.
toHex
string toHex()
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

isCompatible
bool isCompatible(Object o)

Returns {@code true} if the specified object is a recognized data type that can be easily converted to bytes by instances of this class, {@code false} otherwise. <p/> This implementation returns {@code true} IFF the specified object is an instance of one of the following types: <ul> <li>{@code byte[]}</li> <li>{@code char[]}</li> <li>{@link ByteSource}</li> <li>{@link string}</li> <li>{@link File}</li> </li>{@link InputStream}</li> </ul>

Inherited Members

From ByteSource

getBytes
byte[] getBytes()

Returns the wrapped byte array.

toHex
string toHex()

Returns the <a href="http://en.wikipedia.org/wiki/Hexadecimal">Hex</a>-formatted string representation of the underlying wrapped byte array.

toBase64
string toBase64()

Returns the <a href="http://en.wikipedia.org/wiki/Base64">Base 64</a>-formatted string representation of the underlying wrapped byte array.

isEmpty
bool isEmpty()

Returns {@code true} if the underlying wrapped byte array is null or empty (zero length), {@code false} otherwise.

Meta