Class AsciiPrefixer
java.lang.Object
org.jpos.iso.AsciiPrefixer
- All Implemented Interfaces:
Prefixer
AsciiPrefixer constructs a prefix for ASCII messages.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AsciiPrefixerA length prefixer for up to 9 chars.static final AsciiPrefixerA length prefixer for up to 99 chars.static final AsciiPrefixerA length prefixer for up to 999 chars.static final AsciiPrefixerA length prefixer for up to 9999 chars.static final AsciiPrefixerA length prefixer for up to 99999 chars.static final AsciiPrefixerA length prefixer for up to 999999 chars. -
Constructor Summary
ConstructorsConstructorDescriptionAsciiPrefixer(int nDigits) Creates an AsciiPrefixer that uses the specified number of ASCII decimal digits for the length prefix. -
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
-
L
A length prefixer for up to 9 chars. The length is encoded with 1 ASCII char representing 1 decimal digit. -
LL
A length prefixer for up to 99 chars. The length is encoded with 2 ASCII chars representing 2 decimal digits. -
LLL
A length prefixer for up to 999 chars. The length is encoded with 3 ASCII chars representing 3 decimal digits. -
LLLL
A length prefixer for up to 9999 chars. The length is encoded with 4 ASCII chars representing 4 decimal digits. -
LLLLL
A length prefixer for up to 99999 chars. The length is encoded with 5 ASCII chars representing 5 decimal digits. -
LLLLLL
A length prefixer for up to 999999 chars. The length is encoded with 6 ASCII chars representing 6 decimal digits.
-
-
Constructor Details
-
AsciiPrefixer
Creates an AsciiPrefixer that uses the specified number of ASCII decimal digits for the length prefix.- Parameters:
nDigits- number of ASCII decimal digits in 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- Throws:
ISOException- if the length exceeds the prefix capacity
-
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
- Throws:
ISOException- if the prefix cannot be decoded
-
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
-