public interface BaseNCodec
Abstract superclass for Base-N encoders and decoders.
- Author:
- Leonard Woo
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intbits widthstatic final intbits per encodedstatic final intbytes pre encodedstatic final longMask used to extract 2 bits, used when decoding character.static final longMask used to extract 4 bits, used when decoding character.static final longMask used to extract 5 bits, used when encoding bytesstatic final longMask used to extract 6 bits, used when encoding bytesstatic final longMask used to extract 8 bits, used in decoding bytesstatic final longMask used to extract the upper 4 bits, used when decoding character. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Decode the BaseN-encoded data in input and return the data in a new byte array.encodeString(byte[] data) BaseN-encode the given data and return a newly allocated String with the result.
-
Field Details
-
MASK_8BITS
static final long MASK_8BITSMask used to extract 8 bits, used in decoding bytes- See Also:
-
MASK_6BITS
static final long MASK_6BITSMask used to extract 6 bits, used when encoding bytes- See Also:
-
MASK_5BITS
static final long MASK_5BITSMask used to extract 5 bits, used when encoding bytes- See Also:
-
MASK_4BITS
static final long MASK_4BITSMask used to extract 4 bits, used when decoding character.- See Also:
-
MASK_2BITS
static final long MASK_2BITSMask used to extract 2 bits, used when decoding character.- See Also:
-
MASK_UPPER_4BITS
static final long MASK_UPPER_4BITSMask used to extract the upper 4 bits, used when decoding character.- See Also:
-
BITS_PER_ENCODED_BYTE
static final int BITS_PER_ENCODED_BYTEbits per encoded- See Also:
-
BYTES_PER_ENCODED_BLOCK
static final int BYTES_PER_ENCODED_BLOCKbytes pre encoded- See Also:
-
BIT_WIDTH
static final int BIT_WIDTHbits width- See Also:
-
-
Method Details
-
encodeString
BaseN-encode the given data and return a newly allocated String with the result.- Parameters:
data- the data to encode.- Returns:
- a newly allocated String with the result.
-
decode
Decode the BaseN-encoded data in input and return the data in a new byte array.- Parameters:
data- the data to decode.- Returns:
- the data in a new byte array.
- Throws:
IllegalArgumentException- data something is wrong.NullPointerException- data isnull.
-