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
base class for the various IF*.java Field Packagers
Implements "FlyWeight" pattern
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault ConstructorISOFieldPackager(int len, String description) Creates an ISOFieldPackager with the given length and description. -
Method Summary
Modifier and TypeMethodDescriptioncreateComponent(int fieldNumber) Creates anISOComponentinstance appropriate for this packager.Returns the field description.intReturns the maximum field length.abstract intReturns the maximum number of bytes this packager can produce.abstract byte[]pack(ISOComponent c) Packs the given component into a byte array.voidpack(ISOComponent c, ObjectOutput out) Packs the component to an ObjectOutput stream.protected byte[]readBytes(InputStream in, int l) Reads exactlylbytes from the input stream.voidsetDescription(String description) Sets the field description.voidsetLength(int len) Sets the maximum field length.voidsetPad(boolean pad) Enables or disables padding for this field.voidsetTrim(boolean trim) Enables or disables trimming for this field.abstract intunpack(ISOComponent c, byte[] b, int offset) Unpacks a field from the binary image into the given component.voidunpack(ISOComponent c, InputStream in) Unpacks a field from an input stream into the given component.
-
Field Details
-
pad
Whentrue, values are padded to the field length. -
trim
Whentrue, values are trimmed before packing.
-
-
Constructor Details
-
ISOFieldPackager
public ISOFieldPackager()Default Constructor -
ISOFieldPackager
Creates an ISOFieldPackager with the given length and description.- Parameters:
len- - field Lendescription- - details
-
-
Method Details
-
getDescription
-
setDescription
Sets the field description.- Parameters:
description- the description text
-
getLength
-
setLength
-
setPad
Enables or disables padding for this field.- Parameters:
pad- true to enable padding
-
setTrim
Enables or disables trimming for this field.- Parameters:
trim- true to enable trimming
-
getMaxPackedLength
Returns the maximum number of bytes this packager can produce.- Returns:
- maximum packed length in bytes
-
createComponent
Creates anISOComponentinstance appropriate for this packager.- Parameters:
fieldNumber- the field number to assign to the new component- Returns:
- a new ISOComponent
-
pack
Packs the given component into a byte array.- Parameters:
c- - a component- Returns:
- packed component
- Throws:
ISOException- on packing error
-
unpack
Unpacks a field from the binary image into the given component.- Parameters:
c- - the Component to unpackb- - binary imageoffset- - starting offset within the binary image- Returns:
- consumed bytes
- Throws:
ISOException- on unpacking error
-
unpack
Unpacks a field from an input stream into the given component.- Parameters:
c- - the Component to unpackin- - input stream- Throws:
IOException- on I/O failureISOException- on unpacking error
-
pack
Packs the component to an ObjectOutput stream.- Parameters:
c- - the Component to packout- - output stream- Throws:
ISOException- on packing errorIOException- on I/O failure
-
readBytes
Reads exactlylbytes from the input stream.- Parameters:
in- the input streaml- the number of bytes to read- Returns:
- byte array of length
l - Throws:
IOException- on I/O failure or premature end of stream
-