Class BinaryPrefixer
java.lang.Object
org.jpos.iso.BinaryPrefixer
- All Implemented Interfaces:
Prefixer
BinaryPrefixer constructs a prefix storing the length in binary.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BinaryPrefixerPre-builtBinaryPrefixerfor common binary length prefix sizes.static final BinaryPrefixerA length prefixer for up to 65535 chars. -
Constructor Summary
ConstructorsConstructorDescriptionBinaryPrefixer(int nBytes) Creates a BinaryPrefixer with the given number of bytes. -
Method Summary
Modifier and TypeMethodDescriptionintdecodeLength(byte[] b, int offset) Decodes an encoded length from the byte array.voidencodeLength(int length, byte[] b) Encodes the field length into the byte array.intReturns the number of bytes taken up by the length encoding.
-
Field Details
-
B
Pre-builtBinaryPrefixerfor common binary length prefix sizes. -
BB
A length prefixer for up to 65535 chars. The length is encoded with 2 unsigned bytes.
-
-
Constructor Details
-
BinaryPrefixer
Creates a BinaryPrefixer with the given number of bytes.- Parameters:
nBytes- the number of bytes used for the length prefix
-
-
Method Details
-
encodeLength
Description copied from interface:PrefixerEncodes the field length into the byte array.- Specified by:
encodeLengthin interfacePrefixer- Parameters:
length- the field length to encodeb- the byte array to write the length prefix into
-
decodeLength
Description copied from interface:PrefixerDecodes an encoded length from the byte array.- Specified by:
decodeLengthin interfacePrefixer- Parameters:
b- the byte array containing the length prefixoffset- the offset inbwhere the prefix starts- Returns:
- the length in chars of the field data to follow this prefix
-
getPackedLength
Description copied from interface:PrefixerReturns the number of bytes taken up by the length encoding.- Specified by:
getPackedLengthin interfacePrefixer- Returns:
- the number of bytes used by the length encoding
-