Package org.jpos.iso
Class ISOFormattableBinaryFieldPackager
- java.lang.Object
-
- org.jpos.iso.ISOFieldPackager
-
- org.jpos.iso.ISOFormattableBinaryFieldPackager
-
public class ISOFormattableBinaryFieldPackager extends ISOFieldPackager
Generic class for handling binary fields in Tag-Len-Value formatFormat is assemblied by header formatter Where TT is the n>0 digit field number (Tag) LL is the n>=0 digit field length (if n=0 it's means fixed length field with prefixer) .. is the field content
-
-
Field Summary
-
Fields inherited from class org.jpos.iso.ISOFieldPackager
pad, trim
-
-
Constructor Summary
Constructors Constructor Description ISOFormattableBinaryFieldPackager()
Constructs a default ISOTagBinaryFieldPackager.ISOFormattableBinaryFieldPackager(int maxLength, java.lang.String description, Prefixer tagPrefixer, Padder padder, BinaryInterpreter interpreter, Prefixer lengthPrefixer, IsoFieldHeaderFormatter headerFormatter)
Creates an ISOTagBinaryFieldPackager.ISOFormattableBinaryFieldPackager(Prefixer tagPrefixer, Padder padder, BinaryInterpreter interpreter, Prefixer prefixer)
Constructs an ISOTagBinaryFieldPackager with a specific Padder, Interpreter and Prefixer.ISOFormattableBinaryFieldPackager(Prefixer tagPrefixer, Padder padder, BinaryInterpreter interpreter, Prefixer lengthPrefixer, IsoFieldHeaderFormatter headerFormatter)
Constructs an ISOTagBinaryFieldPackager with a specific Padder, Interpreter and Prefixer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IsoFieldHeaderFormatter
getHeaderFormatter()
Gets the formatter, which assembles tag TT and length LL parts in required formatint
getMaxPackedLength()
Returns the prefixer's packed length and the interpreter's packed length.byte[]
pack(ISOComponent c)
Convert the component into a byte[].void
setHeaderFormatter(IsoFieldHeaderFormatter headerFormatter)
Sets the formatter, which assembles tag TT and length LL parts in required formatvoid
setInterpreter(BinaryInterpreter interpreter)
Sets the Interpreter.void
setPadder(Padder padder)
Sets the Padder.void
setPrefixer(Prefixer prefixer)
Sets the length prefixer.int
unpack(ISOComponent c, byte[] b, int offset)
Unpacks the byte array into the component.void
unpack(ISOComponent c, java.io.InputStream in)
Unpack the input stream into the component.-
Methods inherited from class org.jpos.iso.ISOFieldPackager
createComponent, getDescription, getLength, pack, readBytes, setDescription, setLength, setPad, setTrim
-
-
-
-
Constructor Detail
-
ISOFormattableBinaryFieldPackager
public ISOFormattableBinaryFieldPackager()
Constructs a default ISOTagBinaryFieldPackager. There is ASCII tag L prefixer, no padding, no length prefix and a literal binary interpretation. The set methods must be called to make this ISOBaseFieldPackager useful.
-
ISOFormattableBinaryFieldPackager
public ISOFormattableBinaryFieldPackager(Prefixer tagPrefixer, Padder padder, BinaryInterpreter interpreter, Prefixer prefixer)
Constructs an ISOTagBinaryFieldPackager with a specific Padder, Interpreter and Prefixer. The length and description should be set with setLength() and setDescription methods.- Parameters:
tagPrefixer
- The type of tag prefixer used to encode tag.padder
- The type of padding used.interpreter
- The interpreter used to encode the field.prefixer
- The type of length prefixer used to encode this field.
-
ISOFormattableBinaryFieldPackager
public ISOFormattableBinaryFieldPackager(Prefixer tagPrefixer, Padder padder, BinaryInterpreter interpreter, Prefixer lengthPrefixer, IsoFieldHeaderFormatter headerFormatter)
Constructs an ISOTagBinaryFieldPackager with a specific Padder, Interpreter and Prefixer. The length and description should be set with setLength() and setDescription methods.- Parameters:
tagPrefixer
- The type of tag prefixer used to encode tag.padder
- The type of padding used.interpreter
- The interpreter used to encode the field.lengthPrefixer
- The type of length prefixer used to encode this field.headerFormatter
- The format of TAG TT and Length LL part
-
ISOFormattableBinaryFieldPackager
public ISOFormattableBinaryFieldPackager(int maxLength, java.lang.String description, Prefixer tagPrefixer, Padder padder, BinaryInterpreter interpreter, Prefixer lengthPrefixer, IsoFieldHeaderFormatter headerFormatter)
Creates an ISOTagBinaryFieldPackager.- Parameters:
maxLength
- The maximum length of the field in characters or bytes depending on the datatype.description
- The description of the field. For human readable output.tagPrefixer
- The type of tag prefixer used to encode tag.interpreter
- The interpreter used to encode the field.padder
- The type of padding used.lengthPrefixer
- The type of length prefixer used to encode this field.headerFormatter
- The format of TAG TT and Length LL part
-
-
Method Detail
-
setPadder
public void setPadder(Padder padder)
Sets the Padder.- Parameters:
padder
- The padder to use during packing and unpacking.
-
setInterpreter
public void setInterpreter(BinaryInterpreter interpreter)
Sets the Interpreter.- Parameters:
interpreter
- The interpreter to use in packing and unpacking.
-
setPrefixer
public void setPrefixer(Prefixer prefixer)
Sets the length prefixer.- Parameters:
prefixer
- The length prefixer to use during packing and unpacking.
-
getHeaderFormatter
public IsoFieldHeaderFormatter getHeaderFormatter()
Gets the formatter, which assembles tag TT and length LL parts in required format- Returns:
- the formatter of the header part (length and tag parts)
-
setHeaderFormatter
public void setHeaderFormatter(IsoFieldHeaderFormatter headerFormatter)
Sets the formatter, which assembles tag TT and length LL parts in required format- Parameters:
headerFormatter
- the formatter of the header part (length and tag parts)
-
getMaxPackedLength
public int getMaxPackedLength()
Returns the prefixer's packed length and the interpreter's packed length.- Specified by:
getMaxPackedLength
in classISOFieldPackager
- See Also:
ISOFieldPackager.getMaxPackedLength()
-
pack
public byte[] pack(ISOComponent c) throws ISOException
Convert the component into a byte[].- Specified by:
pack
in classISOFieldPackager
- Parameters:
c
- - a component- Returns:
- packed component
- Throws:
ISOException
-
unpack
public int unpack(ISOComponent c, byte[] b, int offset) throws ISOException
Unpacks the byte array into the component.- Specified by:
unpack
in classISOFieldPackager
- Parameters:
c
- The component to unpack into.b
- The byte array to unpack.offset
- The index in the byte array to start unpacking from.- Returns:
- The number of bytes consumed unpacking the component.
- Throws:
ISOException
-
unpack
public void unpack(ISOComponent c, java.io.InputStream in) throws java.io.IOException, ISOException
Unpack the input stream into the component.- Overrides:
unpack
in classISOFieldPackager
- Parameters:
c
- The Component to unpack into.in
- Input stream where the packed bytes come from.- Throws:
java.io.IOException
- Thrown if there's a problem reading the input stream.ISOException
-
-