Class ISOBinaryFieldPackager
java.lang.Object
org.jpos.iso.ISOFieldPackager
org.jpos.iso.ISOBinaryFieldPackager
- Direct Known Subclasses:
IF_FBINARY, IFA_BINARY, IFA_LBINARY, IFA_LLBINARY, IFA_LLLBINARY, IFA_LLLLBINARY, IFA_LLLLLBINARY, IFA_LLLLLLBINARY, IFB_BINARY, IFB_LHBINARY, IFB_LLBINARY, IFB_LLHBINARY, IFB_LLHEX, IFB_LLLBINARY, IFB_LLLHBINARY, IFB_LLLHEX, IFB_LLLLBINARY, IFE_BINARY, IFE_LBINARY, IFE_LLBINARY, IFE_LLLBINARY, IFE_LLLEBINARY, IFE_LLLLBINARY, IFEP_LLLBINARY, ISOTagBinaryFieldPackager
Marker interface for
ISOFieldPackager implementations that handle binary fields.-
Field Summary
Fields inherited from class ISOFieldPackager
pad, trim -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a default ISOBinaryFieldPackager.ISOBinaryFieldPackager(int maxLength, String description, BinaryInterpreter interpreter, Prefixer prefixer) Creates an ISOBinaryFieldPackager.ISOBinaryFieldPackager(BinaryInterpreter interpreter, Prefixer prefixer) Creates an ISOBinaryFieldPackager. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckLength(int len, int maxLength) Checks the length of the data against the maximum, and throws an IllegalArgumentException.createComponent(int fieldNumber) component factoryintReturns the maximum number of bytes this packager can produce.byte[]pack(ISOComponent c) Convert the component into a byte[].voidsetInterpreter(BinaryInterpreter interpreter) Sets the Interpreter.voidsetPrefixer(Prefixer prefixer) Sets the length prefixer.intunpack(ISOComponent c, byte[] b, int offset) Unpacks a field from the binary image into the given component.voidunpack(ISOComponent c, InputStream in) Unpack from an input streamMethods inherited from class ISOFieldPackager
getDescription, getLength, pack, readBytes, setDescription, setLength, setPad, setTrimModifier and TypeMethodDescriptionReturns the field description.intReturns the maximum field length.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.
-
Constructor Details
-
ISOBinaryFieldPackager
public ISOBinaryFieldPackager()Constructs a default ISOBinaryFieldPackager. There is no length prefix and a literal interpretation. The set methods must be called to make this ISOBinaryFieldPackager useful. -
ISOBinaryFieldPackager
public ISOBinaryFieldPackager(int maxLength, String description, BinaryInterpreter interpreter, Prefixer prefixer) Creates an ISOBinaryFieldPackager.- 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.interpreter- The interpreter used to encode the field.prefixer- The type of length prefixer used to encode this field.
-
ISOBinaryFieldPackager
Creates an ISOBinaryFieldPackager.- Parameters:
interpreter- The interpreter used to encode the field.prefixer- The type of length prefixer used to encode this field.
-
-
Method Details
-
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
Description copied from class:ISOFieldPackagerReturns the maximum number of bytes this packager can produce.- Specified by:
getMaxPackedLengthin classISOFieldPackager- Returns:
- maximum packed length in bytes
-
pack
Convert the component into a byte[].- Specified by:
packin classISOFieldPackager- Parameters:
c- - a component- Returns:
- packed component
- Throws:
ISOException- on packing error
-
unpack
Description copied from class:ISOFieldPackagerUnpacks a field from the binary image into the given component.- Specified by:
unpackin classISOFieldPackager- Parameters:
c- - the Component to unpackb- - binary imageoffset- - starting offset within the binary image- Returns:
- consumed bytes
- Throws:
ISOException- on unpacking error
-
unpack
Unpack from an input stream- Overrides:
unpackin classISOFieldPackager- Parameters:
c- - the Component to unpackin- - input stream- Throws:
IOException- on I/O failureISOException- on unpacking error
-
createComponent
component factory- Overrides:
createComponentin classISOFieldPackager- Parameters:
fieldNumber- - the field number- Returns:
- the newly created component
-
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.
-