Class ISOStringFieldPackager
java.lang.Object
org.jpos.iso.ISOFieldPackager
org.jpos.iso.ISOStringFieldPackager
- Direct Known Subclasses:
IF_CHAR, IF_FCHAR, IFA_LCHAR, IFA_LLCHAR, IFA_LLLCHAR, IFA_LLLLCHAR, IFA_LLLLLCHAR, IFA_LLLLLLCHAR, IFA_LLLNUM, IFA_LLNUM, IFA_NUMERIC, IFAE_LLCHAR, IFB_FLLLNUM, IFB_FLLNUM, IFB_FNUMERIC, IFB_HEX, IFB_LLCHAR, IFB_LLHCHAR, IFB_LLHECHAR, IFB_LLHNUM, IFB_LLLCHAR, IFB_LLLHCHAR, IFB_LLLHECHAR, IFB_LLLHNUM, IFB_LLLLCHAR, IFB_LLLLLLCHAR, IFB_LLLNUM, IFB_LLNUM, IFB_NUMERIC, IFE_CHAR, IFE_LCHAR, IFE_LLCHAR, IFE_LLLCHAR, IFE_LLLLCHAR, IFE_LLLNUM, IFE_LLNUM, IFE_LNUM, IFE_NUMERIC, IFE_SIGNED_NUMERIC, IFEA_LLCHAR
-
Field Summary
Fields inherited from class ISOFieldPackager
pad, trim -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a default ISOStringFieldPackager.ISOStringFieldPackager(int maxLength, String description, Padder padder, Interpreter interpreter, Prefixer prefixer) Creates an ISOStringFieldPackager.ISOStringFieldPackager(Padder padder, Interpreter interpreter, Prefixer prefixer) Constructs an ISOStringFieldPackager with a specific Padder, Interpreter and Prefixer. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckLength(int len, int maxLength) Checks the length of the data against the maximum, and throws an IllegalArgumentException.intReturns the prefixer's packed length and the interpreter's packed length.byte[]pack(ISOComponent c) Convert the component into a byte[].voidsetInterpreter(Interpreter interpreter) Sets the Interpreter.voidSets the Padder.voidsetPrefixer(Prefixer prefixer) Sets the length prefixer.voidsetTrim(boolean trim) intunpack(ISOComponent c, byte[] b, int offset) Unpacks the byte array into the component.voidunpack(ISOComponent c, InputStream in) Unpack the input stream into the component.Methods inherited from class ISOFieldPackager
createComponent, getDescription, getLength, pack, readBytes, setDescription, setLength, setPad
-
Constructor Details
-
ISOStringFieldPackager
public ISOStringFieldPackager()Constructs a default ISOStringFieldPackager. There is no padding, no length prefix and a literal interpretation. The set methods must be called to make this ISOBaseFieldPackager useful. -
ISOStringFieldPackager
Constructs an ISOStringFieldPackager with a specific Padder, Interpreter and Prefixer. The length and description should be set with setLength() and setDescription methods.- Parameters:
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.
-
ISOStringFieldPackager
public ISOStringFieldPackager(int maxLength, String description, Padder padder, Interpreter interpreter, Prefixer prefixer) Creates an ISOStringFieldPackager.- 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.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.
-
-
Method Details
-
setPadder
-
setInterpreter
Sets the Interpreter.- Parameters:
interpreter- The interpreter to use in packing and unpacking.
-
setPrefixer
Sets the length prefixer.- Parameters:
prefixer- The length prefixer to use during packing and unpacking.
-
getMaxPackedLength
Returns the prefixer's packed length and the interpreter's packed length.- Specified by:
getMaxPackedLengthin classISOFieldPackager
-
pack
Convert the component into a byte[].- Specified by:
packin classISOFieldPackager- Parameters:
c- - a component- Returns:
- byte array representation of component
- Throws:
ISOException
-
unpack
Unpacks the byte array into the component.- Specified by:
unpackin 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
Unpack the input stream into the component.- Overrides:
unpackin classISOFieldPackager- Parameters:
c- The Component to unpack into.in- Input stream where the packed bytes come from.- Throws:
IOException- Thrown if there's a problem reading the input stream.ISOException
-
setTrim
- Overrides:
setTrimin classISOFieldPackager
-
checkLength
Checks the length of the data against the maximum, and throws an IllegalArgumentException. This is designed to be called from field Packager constructors and the setLength() method.- Parameters:
len- The length of the data for this field packager.maxLength- The maximum length allowed for this type of field packager. This depends on the prefixer that is used.- Throws:
IllegalArgumentException- If len > maxLength.
-