CodecSupport

Base abstract class that provides useful encoding and decoding operations, especially for character data.

@since 0.9

Members

Functions

isByteSource
bool isByteSource(Object o)

Returns {@code true} if the specified object can be easily converted to bytes by instances of this class, {@code false} otherwise. <p/> The default 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>

toBytes
byte[] toBytes(Object o)

Converts the specified Object into a byte array. <p/> If the argument is a {@code byte[]}, {@code char[]}, {@link ByteSource}, {@link String}, {@link File}, or {@link InputStream}, it will be converted automatically and returned.} <p/> If the argument is anything other than these types, it is passed to the {@link #objectToBytes(Object) objectToBytes} method which must be overridden by subclasses.

Static functions

toBytes
byte[] toBytes(char[] chars)

Converts the specified character array to a byte array using the Shiro's preferred encoding (UTF-8). <p/> This is a convenience method equivalent to calling the {@link #toBytes(String,String)} method with a a wrapping String and {@link CodecSupport#PREFERRED_ENCODING PREFERRED_ENCODING}, i.e. <p/> <code>toBytes( new String(chars), {@link CodecSupport#PREFERRED_ENCODING PREFERRED_ENCODING} );</code>

Variables

PREFERRED_ENCODING
enum string PREFERRED_ENCODING;

Shiro's default preferred character encoding, equal to <b><code>UTF-8</code></b>.

Meta