|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.codec.binary.BinaryCodec
public class BinaryCodec
Translates between byte arrays and strings of "0"s and "1"s. TODO: may want to add more bit vector functions like and/or/xor/nand TODO: also might be good to generate boolean[] from byte[] et. cetera.
Constructor Summary | |
---|---|
BinaryCodec()
|
Method Summary | |
---|---|
byte[] |
decode(byte[] ascii)
Decodes a byte array where each byte represents an ASCII '0' or '1'. |
Object |
decode(Object ascii)
Decodes a byte array where each byte represents an ASCII '0' or '1'. |
byte[] |
encode(byte[] raw)
Converts an array of raw binary data into an array of ASCII 0 and 1 characters. |
Object |
encode(Object raw)
Converts an array of raw binary data into an array of ASCII 0 and 1 chars. |
static byte[] |
fromAscii(byte[] ascii)
Decodes a byte array where each byte represents an ASCII '0' or '1'. |
static byte[] |
fromAscii(char[] ascii)
Decodes a char array where each char represents an ASCII '0' or '1'. |
static byte[] |
toAsciiBytes(byte[] raw)
Converts an array of raw binary data into an array of ASCII 0 and 1 character bytes - each byte is a truncated char. |
static char[] |
toAsciiChars(byte[] raw)
Converts an array of raw binary data into an array of ASCII 0 and 1 characters. |
static String |
toAsciiString(byte[] raw)
Converts an array of raw binary data into a String of ASCII 0 and 1 characters. |
byte[] |
toByteArray(String ascii)
Decodes a String where each char of the String represents an ASCII '0' or '1'. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BinaryCodec()
Method Detail |
---|
public byte[] encode(byte[] raw)
encode
in interface BinaryEncoder
raw
- the raw binary data to convert
BinaryEncoder.encode(byte[])
public Object encode(Object raw) throws EncoderException
encode
in interface Encoder
raw
- the raw binary data to convert
EncoderException
- if the argument is not a byte[]Encoder.encode(Object)
public Object decode(Object ascii) throws DecoderException
decode
in interface Decoder
ascii
- each byte represents an ASCII '0' or '1'
DecoderException
- if argument is not a byte[], char[] or StringDecoder.decode(Object)
public byte[] decode(byte[] ascii)
decode
in interface BinaryDecoder
ascii
- each byte represents an ASCII '0' or '1'
Decoder.decode(Object)
public byte[] toByteArray(String ascii)
ascii
- String of '0' and '1' characters
Decoder.decode(Object)
public static byte[] fromAscii(char[] ascii)
ascii
- each char represents an ASCII '0' or '1'
public static byte[] fromAscii(byte[] ascii)
ascii
- each byte represents an ASCII '0' or '1'
public static byte[] toAsciiBytes(byte[] raw)
raw
- the raw binary data to convert
BinaryEncoder.encode(byte[])
public static char[] toAsciiChars(byte[] raw)
raw
- the raw binary data to convert
BinaryEncoder.encode(byte[])
public static String toAsciiString(byte[] raw)
raw
- the raw binary data to convert
BinaryEncoder.encode(byte[])
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |