Class ISOComponent

java.lang.Object
org.jpos.iso.ISOComponent
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
ISOAmount, ISOBinaryField, ISOBitMap, ISODatasetField, ISOField, ISOMsg, ISOTaggedField

public abstract class ISOComponent extends Object implements Cloneable
implements a Component within a Composite pattern See Overview for details.
See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Default constructor; no instance state to initialise.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    dump(PrintStream p, String indent)
    Writes a human-readable dump of this component for diagnostics.
    byte[]
    get Value as bytes (when possible)
    dummy behaviour - return empty map
    In order to interchange Composites and Leafs we use getComposite().
    abstract int
    Returns the field number this component occupies within its container.
    valid on Leafs only.
    int
    a Composite must override this function
    valid on Leafs only.
    abstract byte[]
    Packs this component into its on-wire byte representation.
    void
    Packs this component and writes it to out.
    void
    Set a field within this message
    abstract void
    setFieldNumber(int fieldNumber)
    changes this Component field number
    Use with care, this method does not change any reference held by a Composite.
    abstract void
    Sets the value of this component.
    abstract int
    unpack(byte[] b)
    Unpacks this component from b starting at offset 0.
    abstract void
    Unpacks this component by reading from in.
    void
    unset(int fldno)
    Unset a field

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ISOComponent

      protected ISOComponent()
      Default constructor; no instance state to initialise.
  • Method Details

    • set

      public void set(ISOComponent c) throws ISOException
      Set a field within this message
      Parameters:
      c - - a component
      Throws:
      ISOException - always thrown by leaves; composites override this
    • unset

      public void unset(int fldno) throws ISOException
      Unset a field
      Parameters:
      fldno - - the field number
      Throws:
      ISOException - always thrown by leaves; composites override this
    • getComposite

      In order to interchange Composites and Leafs we use getComposite(). A Composite component returns itself and a Leaf returns null. The base class ISOComponent provides Leaf functionality.
      Returns:
      ISOComponent
    • getKey

      public Object getKey() throws ISOException
      valid on Leafs only. The value returned is used by ISOMsg as a key to this field.
      Returns:
      object representing the field number
      Throws:
      ISOException - thrown by composites; leaves return their key
    • getValue

      public Object getValue() throws ISOException
      valid on Leafs only.
      Returns:
      object representing the field value
      Throws:
      ISOException - thrown by composites; leaves return their value
    • getBytes

      public byte[] getBytes() throws ISOException
      get Value as bytes (when possible)
      Returns:
      byte[] representing this field
      Throws:
      ISOException - thrown by composites or when the value cannot be rendered as bytes
    • getMaxField

      public int getMaxField()
      a Composite must override this function
      Returns:
      the max field number associated with this message
    • getChildren

      public Map getChildren()
      dummy behaviour - return empty map
      Returns:
      children (in this case 0 children)
    • setFieldNumber

      public abstract void setFieldNumber(int fieldNumber)
      changes this Component field number
      Use with care, this method does not change any reference held by a Composite.
      Parameters:
      fieldNumber - new field number
    • getFieldNumber

      public abstract int getFieldNumber()
      Returns the field number this component occupies within its container.
      Returns:
      the field number
    • setValue

      public abstract void setValue(Object obj) throws ISOException
      Sets the value of this component.
      Parameters:
      obj - new value
      Throws:
      ISOException - if the value is rejected by the component implementation
    • pack

      public abstract byte[] pack() throws ISOException
      Packs this component into its on-wire byte representation.
      Returns:
      packed bytes
      Throws:
      ISOException - if packing fails
    • unpack

      public abstract int unpack(byte[] b) throws ISOException
      Unpacks this component from b starting at offset 0.
      Parameters:
      b - packed bytes
      Returns:
      number of bytes consumed
      Throws:
      ISOException - if unpacking fails
    • dump

      public abstract void dump(PrintStream p, String indent)
      Writes a human-readable dump of this component for diagnostics.
      Parameters:
      p - destination stream
      indent - prefix to apply to every emitted line
    • pack

      public void pack(OutputStream out) throws IOException, ISOException
      Packs this component and writes it to out.
      Parameters:
      out - destination stream
      Throws:
      IOException - if writing fails
      ISOException - if packing fails
    • unpack

      public abstract void unpack(InputStream in) throws IOException, ISOException
      Unpacks this component by reading from in.
      Parameters:
      in - source stream
      Throws:
      IOException - if reading fails
      ISOException - if unpacking fails