This class is thread-safe.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | BaseNCodec.
Holds thread context so classes can be thread-safe. |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final byte[] | CHUNK_SEPARATOR
Chunk separator per RFC 2045 section 2.1. |
| private final int | chunkSeparatorLength
Size of chunk separator. |
| private static final int | |
| private static final int | DEFAULT_BUFFER_SIZE
Defines the default buffer size - currently 128 - must be large enough for at least one encoded block+separator |
| private final int | encodedBlockSize
Number of bytes in each full block of encoded data, e.g. 3 for Base64 and 8 for Base32 |
| pack-priv static final int | EOF
EOF |
| protected final int | lineLength
Chunksize for encoding. |
| protected static final int | MASK_8BITS
Mask used to extract 8 bits, used in decoding bytes |
| private static final int | MAX_BUFFER_SIZE
The maximum size buffer to allocate. |
| public static final int | MIME_CHUNK_SIZE
MIME chunk size per RFC 2045 section 6.8. |
| protected final byte | pad
Pad byte. |
| protected static final byte | PAD_DEFAULT
Byte used to pad output. |
| protected static final StringManager | |
| private final int | unencodedBlockSize
Number of bytes in each full block of unencoded data, e.g. 4 for Base64 and 5 for Base32 |
| Access | Constructor and Description |
|---|---|
| protected | BaseNCodec(final int
the size of an unencoded block (e.g. Base64 = 3) unencodedBlockSize, final int the size of an encoded block (e.g. Base64 = 4) encodedBlockSize, final int if > 0, use chunking with a length lineLength, final int lineLengththe chunk separator length, if relevant chunkSeparatorLength)Note |
| protected | BaseNCodec(final int
the size of an unencoded block (e.g. Base64 = 3) unencodedBlockSize, final int the size of an encoded block (e.g. Base64 = 4) encodedBlockSize, final int if > 0, use chunking with a length lineLength, final int lineLengththe chunk separator length, if relevant chunkSeparatorLength, final byte byte used as padding byte. pad)Note |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv int | Returns: The amount of buffered data available for reading.the context to be used contextReturns the amount of buffered data available for reading. |
| protected boolean | Returns: true if any byte is a valid character in the alphabet or PAD; false otherwisebyte array to test arrayOctet)Tests a given byte array to see if it contains any characters within the alphabet or PAD. |
| private static int | Returns: the capacitythe minimum capacity minCapacity)Create a positive capacity at least as large the minimum required capacity. |
| public byte[] | Returns: a byte array containing binary dataA byte array containing Base-N character data pArray)Decodes a byte[] containing characters in the Base-N alphabet. |
| public byte[] | |
| pack-priv abstract void | |
| public byte[] | |
| public byte[] | Returns: A byte array containing only the base N alphabetic character dataa byte array containing binary data pArray)Encodes a byte[] containing binary data, into a byte[] containing characters in the alphabet. |
| public byte[] | Returns: A byte array containing only the base N alphabetic character dataa byte array containing binary data pArray, final int initial offset of the subarray. offset, final int length of the subarray. length)Encodes a byte[] containing binary data, into a byte[] containing characters in the alphabet. |
| pack-priv abstract void | |
| public String | Returns: String containing only character data in the appropriate alphabet.a byte array containing binary data pArray)Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet. |
| protected byte[] | Returns: the bufferminimum spare space required size, final BaseNCodec.the context to be used contextEnsure that the buffer has room for |
| protected int | |
| public long | Returns: amount of space needed to encode the supplied array. Returns a long since a max-len array will require > Integer.MAX_VALUEbyte[] array which will later be encoded pArray)Calculates the amount of space needed to encode the supplied array. |
| pack-priv boolean | Returns: true if there is data still available for reading.the context to be used contextReturns true if this object has buffered data for reading. |
| protected abstract boolean | Returns: true if the value is defined in the current alphabet, false otherwise.The value to test value)Returns whether or not the |
| pack-priv int | Returns: The number of bytes successfully extracted into the provided byte[] array.byte[] array to extract the buffered data into. b, final int position in byte[] array to start extraction at. bPos, final int amount of bytes we're allowed to extract. We may extract fewer (if fewer are available). bAvail, final BaseNCodec.the context to be used contextExtracts buffered data into the provided byte[] array, starting at position bPos, up to a maximum of bAvail bytes. |
| private static byte[] | Returns: the resized byte[] bufferthe context to be used context,the minimum required capacity minCapacity)Increases our buffer by the |
| CHUNK_SEPARATOR | back to summary |
|---|---|
| pack-priv static final byte[] CHUNK_SEPARATOR Chunk separator per RFC 2045 section 2.1.
| |
| chunkSeparatorLength | back to summary |
|---|---|
| private final int chunkSeparatorLength Size of chunk separator. Not used unless | |
| DEFAULT_BUFFER_RESIZE_FACTOR | back to summary |
|---|---|
| private static final int DEFAULT_BUFFER_RESIZE_FACTOR | |
| DEFAULT_BUFFER_SIZE | back to summary |
|---|---|
| private static final int DEFAULT_BUFFER_SIZE Defines the default buffer size - currently 128 - must be large enough for at least one encoded block+separator | |
| encodedBlockSize | back to summary |
|---|---|
| private final int encodedBlockSize Number of bytes in each full block of encoded data, e.g. 3 for Base64 and 8 for Base32 | |
| EOF | back to summary |
|---|---|
| pack-priv static final int EOF EOF
| |
| lineLength | back to summary |
|---|---|
| protected final int lineLength Chunksize for encoding. Not used when decoding. A value of zero or less implies no chunking of the encoded data. Rounded down to the nearest multiple of encodedBlockSize. | |
| MASK_8BITS | back to summary |
|---|---|
| protected static final int MASK_8BITS Mask used to extract 8 bits, used in decoding bytes | |
| MAX_BUFFER_SIZE | back to summary |
|---|---|
| private static final int MAX_BUFFER_SIZE The maximum size buffer to allocate. This is set to the same size used in the JDK Some VMs reserve some header words in an array. Attempts to allocate larger arrays may result in OutOfMemoryError: Requested array size exceeds VM limit. | |
| MIME_CHUNK_SIZE | back to summary |
|---|---|
| public static final int MIME_CHUNK_SIZE MIME chunk size per RFC 2045 section 6.8. The 76 character limit does not count the trailing CRLF, but counts all other characters, including any equal signs.
| |
| pad | back to summary |
|---|---|
| protected final byte pad Pad byte. Instance variable just in case it needs to vary later. | |
| PAD_DEFAULT | back to summary |
|---|---|
| protected static final byte PAD_DEFAULT Byte used to pad output. | |
| sm | back to summary |
|---|---|
| protected static final StringManager sm | |
| unencodedBlockSize | back to summary |
|---|---|
| private final int unencodedBlockSize Number of bytes in each full block of unencoded data, e.g. 4 for Base64 and 5 for Base32 | |
| BaseNCodec | back to summary |
|---|---|
| protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, final int lineLength, final int chunkSeparatorLength) Note
| |
| BaseNCodec | back to summary |
|---|---|
| protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, final int lineLength, final int chunkSeparatorLength, final byte pad) Note
| |
| available | back to summary |
|---|---|
| pack-priv int available(final BaseNCodec. Returns the amount of buffered data available for reading.
| |
| containsAlphabetOrPad | back to summary |
|---|---|
| protected boolean containsAlphabetOrPad(final byte[] arrayOctet) Tests a given byte array to see if it contains any characters within the alphabet or PAD. Intended for use in checking line-ending arrays
| |
| createPositiveCapacity | back to summary |
|---|---|
| private static int createPositiveCapacity(final int minCapacity) Create a positive capacity at least as large the minimum required capacity. If the minimum capacity is negative then this throws an OutOfMemoryError as no array can be allocated.
| |
| decode | back to summary |
|---|---|
| public byte[] decode(final byte[] pArray) Decodes a byte[] containing characters in the Base-N alphabet.
| |
| decode | back to summary |
|---|---|
| public byte[] decode(final byte[] pArray, final int off, final int len) | |
| decode | back to summary |
|---|---|
| pack-priv abstract void decode(byte[] pArray, int i, int length, BaseNCodec. | |
| decode | back to summary |
|---|---|
| public byte[] decode(final String pArray) Decodes a String containing characters in the Base-N alphabet.
| |
| encode | back to summary |
|---|---|
| public byte[] encode(final byte[] pArray) Encodes a byte[] containing binary data, into a byte[] containing characters in the alphabet.
| |
| encode | back to summary |
|---|---|
| public byte[] encode(final byte[] pArray, final int offset, final int length) Encodes a byte[] containing binary data, into a byte[] containing characters in the alphabet.
| |
| encode | back to summary |
|---|---|
| pack-priv abstract void encode(byte[] pArray, int i, int length, BaseNCodec. | |
| encodeAsString | back to summary |
|---|---|
| public String encodeAsString(final byte[] pArray) Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet. Uses UTF8 encoding.
| |
| ensureBufferSize | back to summary |
|---|---|
| protected byte[] ensureBufferSize(final int size, final BaseNCodec. Ensure that the buffer has room for
| |
| getDefaultBufferSize | back to summary |
|---|---|
| protected int getDefaultBufferSize() Get the default buffer size. Can be overridden.
| |
| getEncodedLength | back to summary |
|---|---|
| public long getEncodedLength(final byte[] pArray) Calculates the amount of space needed to encode the supplied array.
| |
| hasData | back to summary |
|---|---|
| pack-priv boolean hasData(final BaseNCodec. Returns true if this object has buffered data for reading.
| |
| isInAlphabet | back to summary |
|---|---|
| protected abstract boolean isInAlphabet(byte value) Returns whether or not the
| |
| readResults | back to summary |
|---|---|
| pack-priv int readResults(final byte[] b, final int bPos, final int bAvail, final BaseNCodec. Extracts buffered data into the provided byte[] array, starting at position bPos, up to a maximum of bAvail bytes. Returns how many bytes were actually extracted. Package protected for access from I/O streams.
| |
| resizeBuffer | back to summary |
|---|---|
| private static byte[] resizeBuffer(final BaseNCodec. Increases our buffer by the
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv byte[] | buffer
Buffer for streaming. |
| pack-priv int | currentLinePos
Variable tracks how many characters have been written to the current line. |
| pack-priv boolean | eof
Boolean flag to indicate the EOF has been reached. |
| pack-priv int | ibitWorkArea
Placeholder for the bytes we're dealing with for our based logic. |
| pack-priv int | modulus
Writes to the buffer only occur after every 3/5 reads when encoding, and every 4/8 reads when decoding. |
| pack-priv int | pos
Position where next character should be written in the buffer. |
| pack-priv int | readPos
Position where next character should be read from the buffer. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public String | Returns: a String useful for debugging.Overrides java. Returns a String useful for debugging (especially within a debugger.) |
| buffer | back to summary |
|---|---|
| pack-priv byte[] buffer Buffer for streaming. | |
| currentLinePos | back to summary |
|---|---|
| pack-priv int currentLinePos Variable tracks how many characters have been written to the current line. Only used when encoding. We use it to make sure each encoded line never goes beyond lineLength (if lineLength > 0). | |
| eof | back to summary |
|---|---|
| pack-priv boolean eof Boolean flag to indicate the EOF has been reached. Once EOF has been reached, this object becomes useless, and must be thrown away. | |
| ibitWorkArea | back to summary |
|---|---|
| pack-priv int ibitWorkArea Placeholder for the bytes we're dealing with for our based logic. Bitwise operations store and extract the encoding or decoding from this variable. | |
| modulus | back to summary |
|---|---|
| pack-priv int modulus Writes to the buffer only occur after every 3/5 reads when encoding, and every 4/8 reads when decoding. This variable helps track that. | |
| pos | back to summary |
|---|---|
| pack-priv int pos Position where next character should be written in the buffer. | |
| readPos | back to summary |
|---|---|
| pack-priv int readPos Position where next character should be read from the buffer. | |
| Context | back to summary |
|---|---|
| pack-priv Context() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a String useful for debugging (especially within a debugger.)
| |