Class XMLPackager
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.jpos.iso.packager.XMLPackager
- All Implemented Interfaces:
ISOPackager, LogSource, ContentHandler, DTDHandler, EntityResolver, ErrorHandler
- Direct Known Subclasses:
XML2003Packager
packs/unpacks ISOMsgs into XML representation
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringLiteral name for ASCII encoding declarations.static final StringXML attribute name holding currency metadata.static final StringXML element name used for datasets.static final StringXML element name used for dataset elements.static final StringXML attribute name used for charset declarations.static final StringXML attribute name holding dataset format metadata.static final StringXML element name used for message headers.static final StringXML attribute name holding field identifiers.static final StringXML element name used for ISO fields.static final StringXML element name used for ISO messages.protected LoggerLogger used to emit pack/unpack events.protected StringLogging realm associated with this packager.static final StringXML type marker for amount field content.static final StringXML attribute name holding type metadata.static final StringXML type marker for binary field content.static final StringXML type marker for bitmap field content.static final StringXML type marker for dataset field content.static final StringXML attribute name holding scalar values. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an XML packager with a hardened SAX parser configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) Creates and returns a new ISOMsg instance appropriate for this packager.protected XMLReaderCreates the SAX reader used to parse XML ISO messages.voidendElement(String ns, String name, String qname) protected voidfixupBinary(ISOMsg m, int[] bfields) Converts selected message fields from hexadecimal strings into binary values.voidforceBinary(int... bfields) Marks the supplied fields so their XML values are always decoded as binary.Returns a human-readable description of this packager.getFieldDescription(ISOComponent m, int fldNumber) Emits a description of the field identified byfldnoin the given message to the log event.Returns the Logger associated with this source.getRealm()Returns the log realm associated with this source.byte[]pack(ISOComponent c) Packs an ISO-8583 message into a byte array.voidAttaches aLoggerand realm to this log source.voidsetXMLParserFeature(String fname, boolean val) Sets a SAX feature on the underlying XML parser.voidstartElement(String ns, String name, String qName, Attributes atts) intunpack(ISOComponent c, byte[] b) Unpacks an ISO-8583 byte array into the given message container.voidunpack(ISOComponent c, InputStream in) Unpacks an ISO-8583 message from an input stream into the given container.Methods inherited from class DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warningMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContentHandler
declaration
-
Field Details
-
logger
-
realm
-
ISOMSG_TAG
-
ISOFIELD_TAG
-
ID_ATTR
-
VALUE_ATTR
-
TYPE_ATTR
-
TYPE_BINARY
-
TYPE_BITMAP
-
TYPE_AMOUNT
-
TYPE_DATASET
-
CURRENCY_ATTR
-
HEADER_TAG
-
ENCODING_ATTR
XML attribute name used for charset declarations.- See Also:
-
ASCII_ENCODING
-
DATASET_TAG
-
ELEMENT_TAG
-
FORMAT_ATTR
XML attribute name holding dataset format metadata.- See Also:
-
-
Constructor Details
-
XMLPackager
Creates an XML packager with a hardened SAX parser configuration.- Throws:
ISOException- if the XML reader cannot be created or configured
-
-
Method Details
-
forceBinary
Marks the supplied fields so their XML values are always decoded as binary.- Parameters:
bfields- field numbers to force as binary
-
pack
Description copied from interface:ISOPackagerPacks an ISO-8583 message into a byte array.- Specified by:
packin interfaceISOPackager- Parameters:
c- the Component to pack- Returns:
- Message image
- Throws:
ISOException- on packing error
-
unpack
Description copied from interface:ISOPackagerUnpacks an ISO-8583 byte array into the given message container.- Specified by:
unpackin interfaceISOPackager- Parameters:
c- the Container of this messageb- ISO message image- Returns:
- consumed bytes
- Throws:
ISOException- on unpacking error
-
unpack
Description copied from interface:ISOPackagerUnpacks an ISO-8583 message from an input stream into the given container.- Specified by:
unpackin interfaceISOPackager- Parameters:
c- the containerin- the input stream- Throws:
ISOException- on unpacking errorIOException- on I/O failure
-
startElement
- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException
-
characters
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler
-
endElement
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Throws:
SAXException
-
fixupBinary
Converts selected message fields from hexadecimal strings into binary values.- Parameters:
m- message being adjustedbfields- field numbers to convert- Throws:
ISOException- if any field cannot be converted
-
getFieldDescription
Description copied from interface:ISOPackagerEmits a description of the field identified byfldnoin the given message to the log event.- Specified by:
getFieldDescriptionin interfaceISOPackager- Parameters:
m- the Container (i.e. an ISOMsg)fldNumber- the Field Number- Returns:
- Field Description
-
setLogger
-
getRealm
-
getLogger
-
createISOMsg
Description copied from interface:ISOPackagerCreates and returns a new ISOMsg instance appropriate for this packager.- Specified by:
createISOMsgin interfaceISOPackager- Returns:
- a new ISOMsg
-
getDescription
Description copied from interface:ISOPackagerReturns a human-readable description of this packager.- Specified by:
getDescriptionin interfaceISOPackager- Returns:
- Packager's Description
-
createXMLReader
Creates the SAX reader used to parse XML ISO messages.- Returns:
- configured XML reader instance
- Throws:
SAXException- if the reader cannot be created
-
setXMLParserFeature
Sets a SAX feature on the underlying XML parser.- Parameters:
fname- feature name URIval- feature value to apply- Throws:
SAXException- if the parser rejects the feature
-