Class DatasetPackager
java.lang.Object
org.jpos.iso.ISOBasePackager
org.jpos.iso.packager.GenericPackager
org.jpos.iso.packager.DatasetPackager
- All Implemented Interfaces:
Configurable, ISODatasetPackager, ISOPackager, ISOSubFieldPackager, GenericPackagerParams, LogSource
- Direct Known Subclasses:
ICCDataPackager
Packager for ISO 8583:2023 composite fields that contain one or more datasets.
-
Nested Class Summary
Nested classes/interfaces inherited from class GenericPackager
GenericPackager.GenericContentHandler, GenericPackager.GenericEntityResolverModifier 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the outer ISO field number this dataset packager is bound to.byte[]pack(ISOComponent m) Packs a dataset field payload, including each dataset envelope.protected byte[]packDatasetContent(Dataset dataset) Packs the inner dataset payload without the outer dataset envelope.protected byte[]Encodes a DBM dataset payload.protected byte[]Encodes a TLV dataset payload.protected DatasetFormatresolveDatasetFormat(int identifier) Resolves the format implied by a dataset identifier.voidCaptures the outer field id declared in the XML packager definition.intunpack(ISOComponent m, byte[] b) Unpacks one or more datasets from a field payload.voidunpack(ISOComponent m, InputStream in) Unpacks one or more datasets from a stream-backed payload.protected DatasetunpackDataset(int identifier, DatasetFormat format, byte[] content) Decodes a dataset payload without the outer dataset envelope.protected ISODatasetunpackDBM(int identifier, byte[] content) Decodes a DBM dataset payload.protected ISODatasetunpackTLV(int identifier, byte[] content) Decodes a TLV dataset payload.Methods inherited from class GenericPackager
emitBitMap, getBitMapfieldPackager, getDescription, getFirstField, getMaxValidField, readFile, readFile, setConfiguration, setLoggerModifier 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.voidAttaches aLoggerand realm to this log source.Methods inherited from class ISOBasePackager
createISOMsg, fieldUnpackLogger, getFieldDescription, getFieldPackager, getHeaderLength, getLogger, getRealm, getThirdBitmapField, setFieldPackager, setFieldPackager, setHeaderLength, setThirdBitmapFieldModifier 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.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.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ISODatasetPackager
hasDatasetEnvelopeModifier and TypeMethodDescriptiondefault booleanIndicates whether datasets handled by this packager use the standard dataset identifier and length envelope.
-
Constructor Details
-
DatasetPackager
Creates an empty dataset packager.- Throws:
ISOException- on packager initialization errors
-
-
Method Details
-
getFieldNumber
Returns the outer ISO field number this dataset packager is bound to.- Specified by:
getFieldNumberin interfaceISOSubFieldPackager- Returns:
- outer field number, or
0when not initialized from XML
-
setGenericPackagerParams
Captures the outer field id declared in the XML packager definition.- Specified by:
setGenericPackagerParamsin interfaceGenericPackagerParams- Overrides:
setGenericPackagerParamsin classGenericPackager- Parameters:
atts- XML attributes for the current field packager
-
pack
Packs a dataset field payload, including each dataset envelope.- Specified by:
packin interfaceISOPackager- Overrides:
packin classISOBasePackager- Parameters:
m- dataset field component- Returns:
- packed payload bytes
- Throws:
ISOException- on packing errors
-
unpack
Unpacks one or more datasets from a field payload.- Specified by:
unpackin interfaceISOPackager- Overrides:
unpackin classISOBasePackager- Parameters:
m- destination dataset fieldb- payload bytes- Returns:
- number of bytes consumed
- Throws:
ISOException- on unpacking errors
-
unpack
Unpacks one or more datasets from a stream-backed payload.- Specified by:
unpackin interfaceISOPackager- Overrides:
unpackin classISOBasePackager- Parameters:
m- destination dataset fieldin- source stream- Throws:
IOException- on stream errorsISOException- on unpacking errors
-
resolveDatasetFormat
Resolves the format implied by a dataset identifier.- Parameters:
identifier- dataset identifier- Returns:
- inferred dataset format
-
packDatasetContent
Packs the inner dataset payload without the outer dataset envelope.- Parameters:
dataset- dataset to encode- Returns:
- encoded dataset payload
- Throws:
ISOException- on packing errors
-
unpackDataset
protected Dataset unpackDataset(int identifier, DatasetFormat format, byte[] content) throws ISOException Decodes a dataset payload without the outer dataset envelope.- Parameters:
identifier- dataset identifierformat- dataset formatcontent- dataset payload bytes- Returns:
- decoded dataset
- Throws:
ISOException- on decoding errors
-
unpackTLV
Decodes a TLV dataset payload.- Parameters:
identifier- dataset identifiercontent- TLV payload bytes- Returns:
- decoded dataset
- Throws:
ISOException- on decoding errors
-
packTLV
Encodes a TLV dataset payload.- Parameters:
dataset- dataset to encode- Returns:
- TLV payload bytes
- Throws:
ISOException- on encoding errors
-
unpackDBM
Decodes a DBM dataset payload.- Parameters:
identifier- dataset identifiercontent- DBM payload bytes- Returns:
- decoded dataset
- Throws:
ISOException- on decoding errors
-
packDBM
Encodes a DBM dataset payload.- Parameters:
dataset- dataset to encode- Returns:
- DBM payload bytes
- Throws:
ISOException- on encoding errors
-