Classes | |
class | Context |
Public Member Functions | |
Object | encode (final Object obj) throws EncoderException |
String | encodeToString (final byte[] pArray) |
String | encodeAsString (final byte[] pArray) |
Object | decode (final Object obj) throws DecoderException |
byte[] | decode (final String pArray) |
byte[] | decode (final byte[] pArray) |
byte[] | encode (final byte[] pArray) |
boolean | isInAlphabet (final byte[] arrayOctet, final boolean allowWSPad) |
boolean | isInAlphabet (final String basen) |
long | getEncodedLength (final byte[] pArray) |
![]() | |
byte[] | encode (byte[] source) throws EncoderException |
![]() | |
Object | encode (Object source) throws EncoderException |
![]() | |
byte[] | decode (byte[] source) throws DecoderException |
![]() | |
Object | decode (Object source) throws DecoderException |
Static Public Attributes | |
static final int | MIME_CHUNK_SIZE = 76 |
static final int | PEM_CHUNK_SIZE = 64 |
Protected Member Functions | |
BaseNCodec (final int unencodedBlockSize, final int encodedBlockSize, final int lineLength, final int chunkSeparatorLength) | |
int | getDefaultBufferSize () |
byte[] | ensureBufferSize (final int size, final Context context) |
abstract boolean | isInAlphabet (byte value) |
boolean | containsAlphabetOrPad (final byte[] arrayOctet) |
Static Protected Member Functions | |
static boolean | isWhiteSpace (final byte byteToCheck) |
Protected Attributes | |
final byte | PAD = PAD_DEFAULT |
final int | lineLength |
Static Protected Attributes | |
static final int | MASK_8BITS = 0xff |
static final byte | PAD_DEFAULT = '=' |
Package Functions | |
boolean | hasData (final Context context) |
int | available (final Context context) |
int | readResults (final byte[] b, final int bPos, final int bAvail, final Context context) |
abstract void | encode (byte[] pArray, int i, int length, Context context) |
abstract void | decode (byte[] pArray, int i, int length, Context context) |
Static Package Attributes | |
static final int | EOF = -1 |
Private Member Functions | |
byte[] | resizeBuffer (final Context context) |
Private Attributes | |
final int | unencodedBlockSize |
final int | encodedBlockSize |
final int | chunkSeparatorLength |
Static Private Attributes | |
static final int | DEFAULT_BUFFER_RESIZE_FACTOR = 2 |
static final int | DEFAULT_BUFFER_SIZE = 8192 |
Abstract superclass for Base-N encoders and decoders.
This class is thread-safe.
Definition at line 34 of file BaseNCodec.java.
|
protected |
Note lineLength
is rounded down to the nearest multiple of encodedBlockSize If chunkSeparatorLength
is zero, then chunking is disabled.
unencodedBlockSize | the size of an unencoded block (e.g. Base64 = 3) |
encodedBlockSize | the size of an encoded block (e.g. Base64 = 4) |
lineLength | if > 0, use chunking with a length lineLength |
chunkSeparatorLength | the chunk separator length, if relevant |
Definition at line 182 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.chunkSeparatorLength, org.apache.commons.codec.binary.BaseNCodec.encodedBlockSize, and org.apache.commons.codec.binary.BaseNCodec.unencodedBlockSize.
|
package |
Returns the amount of buffered data available for reading.
context | the context to be used |
Definition at line 207 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.Context.buffer, org.apache.commons.codec.binary.BaseNCodec.Context.pos, and org.apache.commons.codec.binary.BaseNCodec.Context.readPos.
Referenced by org.apache.commons.codec.binary.BaseNCodec.readResults(), and webiopi.devices.serial.Serial.readString().
|
protected |
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
arrayOctet | byte array to test |
Definition at line 470 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.isInAlphabet().
Referenced by org.apache.commons.codec.binary.Base64.Base64().
Object org.apache.commons.codec.binary.BaseNCodec.decode | ( | final Object | obj | ) | throws DecoderException |
Decodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of the Decoder interface, and will throw a DecoderException if the supplied object is not of type byte[] or String.
obj | Object to decode |
DecoderException | if the parameter supplied is not of type byte[] |
Definition at line 351 of file BaseNCodec.java.
Referenced by org.apache.commons.codec.binary.BaseNCodec.decode().
byte [] org.apache.commons.codec.binary.BaseNCodec.decode | ( | final String | pArray | ) |
Decodes a String containing characters in the Base-N alphabet.
pArray | A String containing Base-N character data |
Definition at line 368 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.decode(), and org.apache.commons.codec.binary.StringUtils.getBytesUtf8().
byte [] org.apache.commons.codec.binary.BaseNCodec.decode | ( | final byte[] | pArray | ) |
Decodes a byte[] containing characters in the Base-N alphabet.
pArray | A byte array containing Base-N character data |
Definition at line 380 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.decode(), org.apache.commons.codec.binary.BaseNCodec.Context.pos, org.apache.commons.codec.binary.BaseNCodec.readResults(), and webiopi.utils.version.result.
|
abstractpackage |
Object org.apache.commons.codec.binary.BaseNCodec.encode | ( | final Object | obj | ) | throws EncoderException |
Encodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of the Encoder interface, and will throw an EncoderException if the supplied object is not of type byte[].
obj | Object to encode |
EncoderException | if the parameter supplied is not of type byte[] |
Definition at line 309 of file BaseNCodec.java.
Referenced by org.apache.commons.codec.binary.BaseNCodec.encode(), org.apache.commons.codec.binary.BaseNCodec.encodeAsString(), and org.apache.commons.codec.binary.BaseNCodec.encodeToString().
byte [] org.apache.commons.codec.binary.BaseNCodec.encode | ( | final byte[] | pArray | ) |
Encodes a byte[] containing binary data, into a byte[] containing characters in the alphabet.
pArray | a byte array containing binary data |
Definition at line 400 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.encode(), org.apache.commons.codec.binary.BaseNCodec.Context.pos, org.apache.commons.codec.binary.BaseNCodec.Context.readPos, and org.apache.commons.codec.binary.BaseNCodec.readResults().
|
abstractpackage |
String org.apache.commons.codec.binary.BaseNCodec.encodeAsString | ( | final byte[] | pArray | ) |
Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet. Uses UTF8 encoding.
pArray | a byte array containing binary data |
Definition at line 335 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.encode(), and org.apache.commons.codec.binary.StringUtils.newStringUtf8().
String org.apache.commons.codec.binary.BaseNCodec.encodeToString | ( | final byte[] | pArray | ) |
Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet. Uses UTF8 encoding.
pArray | a byte array containing binary data |
Definition at line 324 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.encode(), and org.apache.commons.codec.binary.StringUtils.newStringUtf8().
|
protected |
Ensure that the buffer has room for size
bytes
size | minimum spare space required |
context | the context to be used |
Definition at line 243 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.Context.buffer, org.apache.commons.codec.binary.BaseNCodec.Context.pos, and org.apache.commons.codec.binary.BaseNCodec.resizeBuffer().
Referenced by org.apache.commons.codec.binary.Base64.decode(), and org.apache.commons.codec.binary.Base64.encode().
|
protected |
Get the default buffer size. Can be overridden.
Definition at line 216 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.DEFAULT_BUFFER_SIZE.
Referenced by org.apache.commons.codec.binary.BaseNCodec.resizeBuffer().
long org.apache.commons.codec.binary.BaseNCodec.getEncodedLength | ( | final byte[] | pArray | ) |
Calculates the amount of space needed to encode the supplied array.
pArray | byte[] array which will later be encoded |
Definition at line 490 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.chunkSeparatorLength.
Referenced by org.apache.commons.codec.binary.Base64.encodeBase64().
|
package |
Returns true if this object has buffered data for reading.
context | the context to be used |
Definition at line 197 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.Context.buffer.
|
abstractprotected |
Returns whether or not the octet
is in the current alphabet. Does not allow whitespace or pad.
value | The value to test |
Referenced by org.apache.commons.codec.binary.BaseNCodec.containsAlphabetOrPad(), and org.apache.commons.codec.binary.BaseNCodec.isInAlphabet().
boolean org.apache.commons.codec.binary.BaseNCodec.isInAlphabet | ( | final byte[] | arrayOctet, |
final boolean | allowWSPad | ||
) |
Tests a given byte array to see if it contains only valid characters within the alphabet. The method optionally treats whitespace and pad as valid.
arrayOctet | byte array to test |
allowWSPad | if true
|
Definition at line 438 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.isInAlphabet(), and org.apache.commons.codec.binary.BaseNCodec.isWhiteSpace().
boolean org.apache.commons.codec.binary.BaseNCodec.isInAlphabet | ( | final String | basen | ) |
Tests a given String to see if it contains only valid characters within the alphabet. The method treats whitespace and PAD as valid.
basen | String to test |
Definition at line 457 of file BaseNCodec.java.
References org.apache.commons.codec.binary.StringUtils.getBytesUtf8(), and org.apache.commons.codec.binary.BaseNCodec.isInAlphabet().
|
staticprotected |
Checks if a byte value is whitespace or not. Whitespace is taken to mean: space, tab, CR, LF
byteToCheck | the byte to check |
Definition at line 286 of file BaseNCodec.java.
Referenced by org.apache.commons.codec.binary.Base64.isBase64(), and org.apache.commons.codec.binary.BaseNCodec.isInAlphabet().
|
package |
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.
b | byte[] array to extract the buffered data into. |
bPos | position in byte[] array to start extraction at. |
bAvail | amount of bytes we're allowed to extract. We may extract fewer (if fewer are available). |
context | the context to be used |
Definition at line 266 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.available(), org.apache.commons.codec.binary.BaseNCodec.Context.buffer, org.apache.commons.codec.binary.BaseNCodec.Context.eof, org.apache.commons.codec.binary.BaseNCodec.Context.pos, and org.apache.commons.codec.binary.BaseNCodec.Context.readPos.
Referenced by org.apache.commons.codec.binary.BaseNCodec.decode(), and org.apache.commons.codec.binary.BaseNCodec.encode().
|
private |
Increases our buffer by the DEFAULT_BUFFER_RESIZE_FACTOR.
context | the context to be used |
Definition at line 224 of file BaseNCodec.java.
References org.apache.commons.codec.binary.BaseNCodec.Context.buffer, org.apache.commons.codec.binary.BaseNCodec.DEFAULT_BUFFER_RESIZE_FACTOR, org.apache.commons.codec.binary.BaseNCodec.getDefaultBufferSize(), org.apache.commons.codec.binary.BaseNCodec.Context.pos, and org.apache.commons.codec.binary.BaseNCodec.Context.readPos.
Referenced by org.apache.commons.codec.binary.BaseNCodec.ensureBufferSize().
|
private |
Size of chunk separator. Not used unless lineLength > 0.
Definition at line 172 of file BaseNCodec.java.
Referenced by org.apache.commons.codec.binary.BaseNCodec.BaseNCodec(), and org.apache.commons.codec.binary.BaseNCodec.getEncodedLength().
|
staticprivate |
Definition at line 138 of file BaseNCodec.java.
Referenced by org.apache.commons.codec.binary.BaseNCodec.resizeBuffer().
|
staticprivate |
Defines the default buffer size - currently {}
Definition at line 144 of file BaseNCodec.java.
Referenced by org.apache.commons.codec.binary.BaseNCodec.getDefaultBufferSize().
|
private |
Number of bytes in each full block of encoded data, e.g. 3 for Base64 and 8 for Base32
Definition at line 160 of file BaseNCodec.java.
Referenced by org.apache.commons.codec.binary.BaseNCodec.BaseNCodec().
|
staticpackage |
|
protected |
Chunksize for encoding. Not used when decoding. A value of zero or less implies no chunking of the encoded data. Rounded down to nearest multiple of encodedBlockSize.
Definition at line 167 of file BaseNCodec.java.
Referenced by org.apache.commons.codec.binary.Base64.Base64(), and org.apache.commons.codec.binary.Base64.encode().
|
staticprotected |
Mask used to extract 8 bits, used in decoding bytes
Definition at line 147 of file BaseNCodec.java.
Referenced by org.apache.commons.codec.binary.Base64.decode().
|
static |
MIME chunk size per RFC 2045 section 6.8.
The {} character limit does not count the trailing CRLF, but counts all other characters, including any equal signs.
Definition at line 124 of file BaseNCodec.java.
Referenced by org.apache.commons.codec.binary.Base64.Base64().
|
protected |
Definition at line 154 of file BaseNCodec.java.
Referenced by org.apache.commons.codec.binary.Base64.decode(), and org.apache.commons.codec.binary.Base64.encode().
|
staticprotected |
Byte used to pad output.
Definition at line 152 of file BaseNCodec.java.
Referenced by org.apache.commons.codec.binary.Base64.isBase64().
|
static |
PEM chunk size per RFC 1421 section 4.3.2.4.
The {} character limit does not count the trailing CRLF, but counts all other characters, including any equal signs.
Definition at line 136 of file BaseNCodec.java.
|
private |
Number of bytes in each full block of unencoded data, e.g. 4 for Base64 and 5 for Base32
Definition at line 157 of file BaseNCodec.java.
Referenced by org.apache.commons.codec.binary.BaseNCodec.BaseNCodec().