Package org.jpos.iso
Class BinaryPrefixer
- java.lang.Object
-
- org.jpos.iso.BinaryPrefixer
-
- All Implemented Interfaces:
Prefixer
public class BinaryPrefixer extends java.lang.Object implements Prefixer
BinaryPrefixer constructs a prefix storing the length in binary.
-
-
Field Summary
Fields Modifier and Type Field Description static BinaryPrefixer
B
A length prefixer for up to 255 chars.static BinaryPrefixer
BB
A length prefixer for up to 65535 chars.
-
Constructor Summary
Constructors Constructor Description BinaryPrefixer(int nBytes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
decodeLength(byte[] b, int offset)
Decodes an encoded length.void
encodeLength(int length, byte[] b)
Fills a byte array with the field length data in raw form.int
getPackedLength()
Returns the number of bytes taken up by the length encoding.
-
-
-
Field Detail
-
B
public static final BinaryPrefixer B
A length prefixer for up to 255 chars. The length is encoded with 1 unsigned byte.
-
BB
public static final BinaryPrefixer BB
A length prefixer for up to 65535 chars. The length is encoded with 2 unsigned bytes.
-
-
Constructor Detail
-
BinaryPrefixer
public BinaryPrefixer(int nBytes)
-
-
Method Detail
-
encodeLength
public void encodeLength(int length, byte[] b)
Description copied from interface:Prefixer
Fills a byte array with the field length data in raw form.- Specified by:
encodeLength
in interfacePrefixer
- Parameters:
length
- The length to be encoded.b
- The byte array to fill with the encoded length.
-
decodeLength
public int decodeLength(byte[] b, int offset)
Description copied from interface:Prefixer
Decodes an encoded length.- Specified by:
decodeLength
in interfacePrefixer
- Parameters:
b
- The byte array to scan for the length.offset
- The offset to start scanning from.- Returns:
- The length in chars of the field data to follow this LengthPrefix.
-
getPackedLength
public int getPackedLength()
Description copied from interface:Prefixer
Returns the number of bytes taken up by the length encoding.- Specified by:
getPackedLength
in interfacePrefixer
-
-