Class GenericPackager
java.lang.Object
org.jpos.iso.ISOBasePackager
org.jpos.iso.packager.GenericPackager
- All Implemented Interfaces:
Configurable, ISOPackager, GenericPackagerParams, LogSource
- Direct Known Subclasses:
BERTLVPackager, DatasetPackager, GenericSubFieldPackager, GenericTaggedFieldsPackager, GenericValidatingPackager, GICCSubFieldPackager, TaggedSequencePackager, X92GenericPackager
GenericPackager uses an XML config file to describe the layout of an ISOMessage
The general format is as follows
<isopackager>
<isofield
id="[field id]"
name="[field name]"
length="[max field length]"
class="[org.jpos.iso.IF_*]"
pad="true|false">
</isofield>
...
</isopackager>
Fields that contain subfields can be handled as follows
<isofieldpackager
id="[field id]"
name="[field name]"
length="[field length]"
class="[org.jpos.iso.IF_*]"
packager="[org.jpos.iso.packager.*]">
<isofield
id="[subfield id]"
name="[subfield name]"
length="[max subfield length]"
class="[org.jpos.iso.IF_*]"
pad="true|false">
</isofield>
...
</isofieldpackager>
The optional attributes maxValidField, bitmapField, thirdBitmapField, and emitBitmap
are allowed on the isopackager node.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassSAX content handler that builds the packager's field structure from the DTD-driven XML.static classSAX entity resolver that maps the GenericPackager DTD URIs to bundled resources. -
Field Summary
Fields inherited from class ISOBasePackager
fld, headerLength, logFieldName, logger, realm, thirdBitmapFieldModifier 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
ConstructorsConstructorDescriptionDefault constructor.GenericPackager(InputStream input) Create a GenericPackager with the field descriptions from an XML InputStreamGenericPackager(String filename) Create a GenericPackager with the field descriptions from an XML File -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanIndicates whether a primary bitmap is emitted on pack.protected ISOFieldPackagerReturns the field packager used for the primary bitmap.Returns a human-readable description of this packager.protected intusually 2 for normal fields, 1 for bitmap-less or ANSI X9.2protected intReturns the highest valid field number for this packager.voidreadFile(InputStream input) Parse the field descriptions from an XML InputStream.voidParse the field descriptions from an XML file.voidPackager Configuration.voidApplies packager configuration from the SAX attributes of the packager XML element.voidAttaches aLoggerand realm to this log source.Methods inherited from class ISOBasePackager
createISOMsg, fieldUnpackLogger, getFieldDescription, getFieldPackager, getHeaderLength, getLogger, getRealm, getThirdBitmapField, pack, setFieldPackager, setFieldPackager, setHeaderLength, setThirdBitmapField, unpack, unpackModifier and TypeMethodDescriptionFactory hook returning theISOMsgsubclass produced during unpack.protected static voidfieldUnpackLogger(LogEvent evt, int fldno, ISOComponent c, ISOFieldPackager fld, boolean logFieldName) Internal helper logging function.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.intReturns the configured ISO header length in bytes.Returns the Logger associated with this source.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 withISOBasePackager.unpack(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.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.
-
Constructor Details
-
GenericPackager
Default constructor.- Throws:
ISOException- if the underlying packager cannot be initialized
-
GenericPackager
Create a GenericPackager with the field descriptions from an XML File- Parameters:
filename- The XML field description file- Throws:
ISOException- if the field description file cannot be read or parsed
-
GenericPackager
Create a GenericPackager with the field descriptions from an XML InputStream- Parameters:
input- The XML field description InputStream- Throws:
ISOException- if the input stream cannot be read or parsed
-
-
Method Details
-
setConfiguration
Packager Configuration.- packager-config
- packager-logger
- packager-log-fieldname
- packager-realm
- Specified by:
setConfigurationin interfaceConfigurable- Parameters:
cfg- Configuration- Throws:
ConfigurationException- if the configuration is invalid
-
getMaxValidField
Description copied from class:ISOBasePackagerReturns the highest valid field number for this packager.- Overrides:
getMaxValidFieldin classISOBasePackager- Returns:
- 128 for ISO-8583, should return 64 for ANSI X9.2
-
emitBitMap
Description copied from class:ISOBasePackagerIndicates whether a primary bitmap is emitted on pack.- Overrides:
emitBitMapin classISOBasePackager- Returns:
trueif the field-1 packager is anISOBitMapPackager
-
getBitMapfieldPackager
Description copied from class:ISOBasePackagerReturns the field packager used for the primary bitmap.- Overrides:
getBitMapfieldPackagerin classISOBasePackager- Returns:
- suitable ISOFieldPackager for Bitmap
-
readFile
Parse the field descriptions from an XML file.Uses the sax parser specified by the system property 'sax.parser' The default parser is org.apache.crimson.parser.XMLReaderImpl
- Parameters:
filename- The XML field description file- Throws:
ISOException- if the file cannot be read or parsed
-
readFile
Parse the field descriptions from an XML InputStream.Uses the sax parser specified by the system property 'sax.parser' The default parser is org.apache.crimson.parser.XMLReaderImpl
- Parameters:
input- The XML field description InputStream- Throws:
ISOException- if the stream cannot be read or parsed
-
setLogger
-
getDescription
Description copied from interface:ISOPackagerReturns a human-readable description of this packager.- Specified by:
getDescriptionin interfaceISOPackager- Overrides:
getDescriptionin classISOBasePackager- Returns:
- Packager's Description
-
setGenericPackagerParams
Description copied from interface:GenericPackagerParamsApplies packager configuration from the SAX attributes of the packager XML element.- Specified by:
setGenericPackagerParamsin interfaceGenericPackagerParams- Parameters:
atts- the SAX attributes from the packager element
-
getFirstField
Description copied from class:ISOBasePackagerusually 2 for normal fields, 1 for bitmap-less or ANSI X9.2- Overrides:
getFirstFieldin classISOBasePackager- Returns:
- first valid field
-