Class BinaryPrefixer

java.lang.Object
org.jpos.iso.BinaryPrefixer
All Implemented Interfaces:
Prefixer

public class BinaryPrefixer extends Object implements Prefixer
BinaryPrefixer constructs a prefix storing the length in binary.
  • Field Details

    • B

      public static final BinaryPrefixer B
      Pre-built BinaryPrefixer for common binary length prefix sizes.
    • BB

      public static final BinaryPrefixer BB
      A length prefixer for up to 65535 chars. The length is encoded with 2 unsigned bytes.
  • Constructor Details

    • BinaryPrefixer

      public BinaryPrefixer(int nBytes)
      Creates a BinaryPrefixer with the given number of bytes.
      Parameters:
      nBytes - the number of bytes used for the length prefix
  • Method Details

    • encodeLength

      public void encodeLength(int length, byte[] b)
      Description copied from interface: Prefixer
      Encodes the field length into the byte array.
      Specified by:
      encodeLength in interface Prefixer
      Parameters:
      length - the field length to encode
      b - the byte array to write the length prefix into
    • decodeLength

      public int decodeLength(byte[] b, int offset)
      Description copied from interface: Prefixer
      Decodes an encoded length from the byte array.
      Specified by:
      decodeLength in interface Prefixer
      Parameters:
      b - the byte array containing the length prefix
      offset - the offset in b where the prefix starts
      Returns:
      the length in chars of the field data to follow this prefix
    • getPackedLength

      public int getPackedLength()
      Description copied from interface: Prefixer
      Returns the number of bytes taken up by the length encoding.
      Specified by:
      getPackedLength in interface Prefixer
      Returns:
      the number of bytes used by the length encoding