Class ISOBasePackager
java.lang.Object
org.jpos.iso.ISOBasePackager
- All Implemented Interfaces:
ISOPackager, LogSource
- Direct Known Subclasses:
Base1Packager, Base1Packager.F127Packager, Base1SubFieldPackager, BASE24Packager, EuroPackager, EuroSubFieldPackager, GenericPackager, ISO87APackager, ISO87APackagerBBitmap, ISO87BPackager, ISO93APackager, ISO93BPackager, ISOBaseValidatingPackager, PostPackager, PostPackager.PostPrivatePackager, VAPSMSPackager, VAPVIPPackager, VAPVIPPackager.F127Packager, X92Packager
provides base functionality for the actual packagers
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ISOFieldPackager[]Per-field packagers indexed by field number.protected intNumber of leading bytes treated as the ISO header during unpack.protected booleanWhentrue, field descriptions are emitted as XML comments in unpack logs.protected LoggerLogger used to record pack/unpack diagnostics;nulldisables logging.protected StringLogger realm associated with this packager.protected intField number that carries the tertiary bitmap as a Data Element, or-999if not used. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor; no instance state to initialise. -
Method Summary
Modifier and TypeMethodDescriptionFactory hook returning theISOMsgsubclass produced during unpack.protected booleanIndicates whether a primary bitmap is emitted on pack.protected static voidfieldUnpackLogger(LogEvent evt, int fldno, ISOComponent c, ISOFieldPackager fld, boolean logFieldName) Internal helper logging function.protected ISOFieldPackagerReturns the field packager used for the primary bitmap.Returns a human-readable description of this packager.getFieldDescription(ISOComponent m, int fldNumber) Returns the human-readable description of a field as defined by its packager.getFieldPackager(int fldNumber) Returns the field packager registered for the given field number.protected intusually 2 for normal fields, 1 for bitmap-less or ANSI X9.2intReturns the configured ISO header length in bytes.Returns the Logger associated with this source.protected intReturns the highest valid field number for this packager.getRealm()Returns the log realm associated with this source.intReturns the field number carrying the tertiary bitmap as a Data Element.byte[]pack(ISOComponent m) pack method that works in conjunction withunpack(ISOComponent, byte[]).voidsetFieldPackager(int fldNumber, ISOFieldPackager fieldPackager) Replaces the packager registered for a single field.voidsetFieldPackager(ISOFieldPackager[] fld) Replaces the per-field packager array.voidsetHeaderLength(int len) Sets the ISO header length in bytes.voidAttaches aLoggerand realm to this log source.voidsetThirdBitmapField(int f) Configures the Data Element field that holds the tertiary bitmap.intunpack(ISOComponent m, byte[] b) Unpacks an ISO-8583 byte array into the given message container.voidunpack(ISOComponent m, InputStream in) Unpacks an ISO-8583 message from an input stream into the given container.
-
Field Details
-
fld
Per-field packagers indexed by field number. -
thirdBitmapField
Field number that carries the tertiary bitmap as a Data Element, or-999if not used. -
logger
-
logFieldName
Whentrue, field descriptions are emitted as XML comments in unpack logs. -
realm
-
headerLength
Number of leading bytes treated as the ISO header during unpack.
-
-
Constructor Details
-
ISOBasePackager
protected ISOBasePackager()Default constructor; no instance state to initialise.
-
-
Method Details
-
setFieldPackager
Replaces the per-field packager array.- Parameters:
fld- new array of field packagers indexed by field number
-
setThirdBitmapField
Configures the Data Element field that holds the tertiary bitmap.- Parameters:
f- field number in the range [0, 128]- Throws:
ISOException- iffis outside the valid range
-
getThirdBitmapField
Returns the field number carrying the tertiary bitmap as a Data Element.- Returns:
- the configured third-bitmap field number, or
-999if not set
-
emitBitMap
Indicates whether a primary bitmap is emitted on pack.- Returns:
trueif the field-1 packager is anISOBitMapPackager
-
getFirstField
usually 2 for normal fields, 1 for bitmap-less or ANSI X9.2- Returns:
- first valid field
-
pack
pack method that works in conjunction withunpack(ISOComponent, byte[]).Handles a tertiary bitmap possibly appearing in Data Element
thirdBitmapField.- Specified by:
packin interfaceISOPackager- Parameters:
m- the Component to pack- Returns:
- Message image
- Throws:
ISOException- if the component cannot be packed
-
unpack
Description copied from interface:ISOPackagerUnpacks an ISO-8583 byte array into the given message container.- Specified by:
unpackin interfaceISOPackager- Parameters:
m- the Container of this messageb- ISO message image- Returns:
- consumed bytes
- Throws:
ISOException- if the message image cannot be unpacked
-
unpack
Description copied from interface:ISOPackagerUnpacks an ISO-8583 message from an input stream into the given container.- Specified by:
unpackin interfaceISOPackager- Parameters:
m- the containerin- the input stream- Throws:
IOException- on I/O failureISOException- on unpacking error
-
fieldUnpackLogger
protected static void fieldUnpackLogger(LogEvent evt, int fldno, ISOComponent c, ISOFieldPackager fld, boolean logFieldName) throws ISOException Internal helper logging function. Assumes evt is not null.- Parameters:
evt- the log event to append messages to (must not benull)fldno- the field number being unpackedc- the unpacked component carrying the field valuefld- the field packager that producedclogFieldName- whentrue, emits the field description as an XML comment- Throws:
ISOException- if the value cannot be rendered for logging
-
getFieldDescription
Returns the human-readable description of a field as defined by its packager.- Specified by:
getFieldDescriptionin interfaceISOPackager- Parameters:
m- the Container (i.e. an ISOMsg)fldNumber- the Field Number- Returns:
- Field Description
-
getFieldPackager
Returns the field packager registered for the given field number.- Parameters:
fldNumber- the Field Number- Returns:
- Field Packager for this field
-
setFieldPackager
Replaces the packager registered for a single field.- Parameters:
fldNumber- the Field NumberfieldPackager- the Field Packager
-
createISOMsg
Factory hook returning theISOMsgsubclass produced during unpack.- Specified by:
createISOMsgin interfaceISOPackager- Returns:
- a new
ISOMsginstance
-
getMaxValidField
Returns the highest valid field number for this packager.- Returns:
- 128 for ISO-8583, should return 64 for ANSI X9.2
-
getBitMapfieldPackager
Returns the field packager used for the primary bitmap.- Returns:
- suitable ISOFieldPackager for Bitmap
-
setLogger
-
getRealm
-
getLogger
-
getHeaderLength
Returns the configured ISO header length in bytes.- Returns:
- number of leading bytes treated as the ISO header during unpack
-
setHeaderLength
Sets the ISO header length in bytes.- Parameters:
len- number of leading bytes to treat as the ISO header during unpack
-
getDescription
Description copied from interface:ISOPackagerReturns a human-readable description of this packager.- Specified by:
getDescriptionin interfaceISOPackager- Returns:
- Packager's Description
-