Class ISOComponent
java.lang.Object
org.jpos.iso.ISOComponent
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
ISOAmount, ISOBinaryField, ISOBitMap, ISODatasetField, ISOField, ISOMsg, ISOTaggedField
implements a Component
within a Composite pattern
See
Overview for details.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor; no instance state to initialise. -
Method Summary
Modifier and TypeMethodDescriptionabstract voiddump(PrintStream p, String indent) Writes a human-readable dump of this component for diagnostics.byte[]getBytes()get Value as bytes (when possible)dummy behaviour - return empty mapIn order to interchange Composites and Leafs we use getComposite().abstract intReturns the field number this component occupies within its container.getKey()valid on Leafs only.inta Composite must override this functiongetValue()valid on Leafs only.abstract byte[]pack()Packs this component into its on-wire byte representation.voidpack(OutputStream out) Packs this component and writes it toout.voidset(ISOComponent c) Set a field within this messageabstract voidsetFieldNumber(int fieldNumber) changes this Component field number
Use with care, this method does not change any reference held by a Composite.abstract voidSets the value of this component.abstract intunpack(byte[] b) Unpacks this component frombstarting at offset 0.abstract voidunpack(InputStream in) Unpacks this component by reading fromin.voidunset(int fldno) Unset a field
-
Constructor Details
-
ISOComponent
protected ISOComponent()Default constructor; no instance state to initialise.
-
-
Method Details
-
set
Set a field within this message- Parameters:
c- - a component- Throws:
ISOException- always thrown by leaves; composites override this
-
unset
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
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
valid on Leafs only.- Returns:
- object representing the field value
- Throws:
ISOException- thrown by composites; leaves return their value
-
getBytes
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
a Composite must override this function- Returns:
- the max field number associated with this message
-
getChildren
dummy behaviour - return empty map- Returns:
- children (in this case 0 children)
-
setFieldNumber
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
Returns the field number this component occupies within its container.- Returns:
- the field number
-
setValue
Sets the value of this component.- Parameters:
obj- new value- Throws:
ISOException- if the value is rejected by the component implementation
-
pack
Packs this component into its on-wire byte representation.- Returns:
- packed bytes
- Throws:
ISOException- if packing fails
-
unpack
Unpacks this component frombstarting at offset 0.- Parameters:
b- packed bytes- Returns:
- number of bytes consumed
- Throws:
ISOException- if unpacking fails
-
dump
Writes a human-readable dump of this component for diagnostics.- Parameters:
p- destination streamindent- prefix to apply to every emitted line
-
pack
Packs this component and writes it toout.- Parameters:
out- destination stream- Throws:
IOException- if writing failsISOException- if packing fails
-
unpack
Unpacks this component by reading fromin.- Parameters:
in- source stream- Throws:
IOException- if reading failsISOException- if unpacking fails
-