Class ISOFieldPackager

java.lang.Object
org.jpos.iso.ISOFieldPackager
Direct Known Subclasses:
BinaryHexTaggedSequencePackager.TagPackager, DatasetFieldPackager, IF_ECHAR, IF_FSTBINARY, IF_FSTCHAR, IF_NOP, IF_TBASE, IF_UNUSED, IFA_LLABINARY, IFA_LLBNUM, IFA_LLLABINARY, IFB_AMOUNT, IFB_LLHFBINARY, IFEB_LLLNUM, IFEB_LLNUM, IFELPE_LLLCHAR, IFEP_LLCHAR, IFEP_LLLCHAR, IFIPM_LLLCHAR, ISOAmountFieldPackager, ISOBinaryFieldPackager, ISOBitMapPackager, ISOFilledStringFieldPackager, ISOFormattableBinaryFieldPackager, ISOFormattableStringFieldPackager, ISOMsgFieldPackager, ISOStringFieldPackager, ISOTagStringFieldPackager, TaggedFieldPackagerBase

  • Field Details

    • pad

      protected boolean pad
      When true, values are padded to the field length.
    • trim

      protected boolean trim
      When true, values are trimmed before packing.
  • Constructor Details

    • ISOFieldPackager

      Default Constructor
    • ISOFieldPackager

      public ISOFieldPackager(int len, String description)
      Creates an ISOFieldPackager with the given length and description.
      Parameters:
      len - - field Len
      description - - details
  • Method Details

    • getDescription

      Returns the field description.
      Returns:
      field description
    • setDescription

      public void setDescription(String description)
      Sets the field description.
      Parameters:
      description - the description text
    • getLength

      public int getLength()
      Returns the maximum field length.
      Returns:
      max field length
    • setLength

      public void setLength(int len)
      Sets the maximum field length.
      Parameters:
      len - the maximum length
    • setPad

      public void setPad(boolean pad)
      Enables or disables padding for this field.
      Parameters:
      pad - true to enable padding
    • setTrim

      public void setTrim(boolean trim)
      Enables or disables trimming for this field.
      Parameters:
      trim - true to enable trimming
    • getMaxPackedLength

      public abstract int getMaxPackedLength()
      Returns the maximum number of bytes this packager can produce.
      Returns:
      maximum packed length in bytes
    • createComponent

      public ISOComponent createComponent(int fieldNumber)
      Creates an ISOComponent instance appropriate for this packager.
      Parameters:
      fieldNumber - the field number to assign to the new component
      Returns:
      a new ISOComponent
    • pack

      public abstract byte[] pack(ISOComponent c) throws ISOException
      Packs the given component into a byte array.
      Parameters:
      c - - a component
      Returns:
      packed component
      Throws:
      ISOException - on packing error
    • unpack

      public abstract int unpack(ISOComponent c, byte[] b, int offset) throws ISOException
      Unpacks a field from the binary image into the given component.
      Parameters:
      c - - the Component to unpack
      b - - binary image
      offset - - starting offset within the binary image
      Returns:
      consumed bytes
      Throws:
      ISOException - on unpacking error
    • unpack

      public void unpack(ISOComponent c, InputStream in) throws IOException, ISOException
      Unpacks a field from an input stream into the given component.
      Parameters:
      c - - the Component to unpack
      in - - input stream
      Throws:
      IOException - on I/O failure
      ISOException - on unpacking error
    • pack

      public void pack(ISOComponent c, ObjectOutput out) throws IOException, ISOException
      Packs the component to an ObjectOutput stream.
      Parameters:
      c - - the Component to pack
      out - - output stream
      Throws:
      ISOException - on packing error
      IOException - on I/O failure
    • readBytes

      protected byte[] readBytes(InputStream in, int l) throws IOException
      Reads exactly l bytes from the input stream.
      Parameters:
      in - the input stream
      l - the number of bytes to read
      Returns:
      byte array of length l
      Throws:
      IOException - on I/O failure or premature end of stream