Class ISODatasetField

java.lang.Object
org.jpos.iso.ISOComponent
org.jpos.iso.ISODatasetField
All Implemented Interfaces:
Cloneable

public class ISODatasetField extends ISOComponent
Composite ISO field that holds one or more datasets.
  • Constructor Details

    • ISODatasetField

      public ISODatasetField()
      Creates an unbound dataset field.
    • ISODatasetField

      public ISODatasetField(int fieldNumber)
      Creates a dataset field bound to an outer field number.
      Parameters:
      fieldNumber - outer field number
  • Method Details

    • addDataset

      public void addDataset(Dataset dataset)
      Appends a dataset to this field.
      Parameters:
      dataset - dataset to add
    • removeDataset

      public void removeDataset(Dataset dataset)
      Removes a dataset instance from this field.
      Parameters:
      dataset - dataset to remove
    • hasDatasets

      public boolean hasDatasets()
      Indicates whether this field still contains datasets.
      Returns:
      true when at least one dataset is present
    • getDatasets

      Returns all datasets in insertion order.
      Returns:
      immutable list of datasets
    • getDatasets

      public List<Dataset> getDatasets(int identifier)
      Returns all datasets that match the supplied identifier.
      Parameters:
      identifier - dataset identifier
      Returns:
      immutable list of matching datasets
    • getDataset

      public Dataset getDataset(int identifier)
      Returns the first dataset that matches the supplied identifier.
      Parameters:
      identifier - dataset identifier
      Returns:
      matching dataset or null
    • get

      public ISOComponent get(int datasetId, int elementId)
      Returns the component stored under the given dataset and element identifiers.
      Parameters:
      datasetId - dataset identifier
      elementId - element identifier
      Returns:
      matching component or null
    • getValue

      public Object getValue(int datasetId, int elementId) throws ISOException
      Returns the logical value stored under the given dataset and element identifiers.
      Parameters:
      datasetId - dataset identifier
      elementId - element identifier
      Returns:
      element value or null
      Throws:
      ISOException - on component access errors
    • getBytes

      public byte[] getBytes(int datasetId, int elementId) throws ISOException
      Returns the bytes stored under the given dataset and element identifiers.
      Parameters:
      datasetId - dataset identifier
      elementId - element identifier
      Returns:
      element bytes or null
      Throws:
      ISOException - on component access errors
    • getComposite

      Returns this composite field.
      Overrides:
      getComposite in class ISOComponent
      Returns:
      this field
    • getKey

      public Object getKey()
      Returns the outer ISO field number.
      Overrides:
      getKey in class ISOComponent
      Returns:
      outer field number
    • getValue

      public Object getValue()
      Returns the datasets carried by this field.
      Overrides:
      getValue in class ISOComponent
      Returns:
      dataset list
    • getBytes

      public byte[] getBytes() throws ISOException
      Dataset fields do not expose their bytes directly and must be packed via a DatasetFieldPackager.
      Overrides:
      getBytes in class ISOComponent
      Returns:
      never returns normally
      Throws:
      ISOException - always
    • setFieldNumber

      public void setFieldNumber(int fieldNumber)
      Sets the outer ISO field number.
      Specified by:
      setFieldNumber in class ISOComponent
      Parameters:
      fieldNumber - outer field number
    • getFieldNumber

      public int getFieldNumber()
      Returns the outer ISO field number.
      Specified by:
      getFieldNumber in class ISOComponent
      Returns:
      outer field number
    • setValue

      public void setValue(Object obj) throws ISOException
      Replaces the datasets held by this field.
      Specified by:
      setValue in class ISOComponent
      Parameters:
      obj - either a Dataset or a List of datasets
      Throws:
      ISOException - when the supplied value type is unsupported
    • pack

      public byte[] pack() throws ISOException
      Dataset fields must be packed through their field packager.
      Specified by:
      pack in class ISOComponent
      Returns:
      never returns normally
      Throws:
      ISOException - always
    • unpack

      public int unpack(byte[] b) throws ISOException
      Dataset fields must be unpacked through their field packager.
      Specified by:
      unpack in class ISOComponent
      Parameters:
      b - source buffer
      Returns:
      never returns normally
      Throws:
      ISOException - always
    • unpack

      public void unpack(InputStream in) throws ISOException
      Dataset fields must be unpacked through their field packager.
      Specified by:
      unpack in class ISOComponent
      Parameters:
      in - source stream
      Throws:
      ISOException - always
    • dump

      public void dump(PrintStream p, String indent)
      Dumps the field as dataset-aware XML.
      Specified by:
      dump in class ISOComponent
      Parameters:
      p - destination stream
      indent - indentation prefix