Class BcdPrefixer

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

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

    • L

      public static final BcdPrefixer L
      Pre-built BcdPrefixer for common BCD length prefix sizes.
    • LL

      public static final BcdPrefixer LL
      A length prefixer for up to 99 chars. The length is encoded with 2 BCD digits.
    • LLL

      public static final BcdPrefixer LLL
      A length prefixer for up to 999 chars. The length is encoded with 3 BCD digits.
    • LLLL

      public static final BcdPrefixer LLLL
      A length prefixer for up to 9999 chars. The length is encoded with 4 BCD digits.
    • LLLLL

      public static final BcdPrefixer LLLLL
      A length prefixer for up to 99999 chars. The length is encoded with 5 BCD digits.
    • LLLLLL

      public static final BcdPrefixer LLLLLL
      A length prefixer for up to 999999 chars. The length is encoded with 6 BCD digits.
  • Constructor Details

    • BcdPrefixer

      public BcdPrefixer(int nDigits)
      Creates a BcdPrefixer with the given number of digits.
      Parameters:
      nDigits - the number of BCD digits 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