Package com.ibm.di.parser
Class XMLSaxParser
- java.lang.Object
-
- com.ibm.di.parser.ParserImpl
-
- com.ibm.di.parser.XMLSaxParser
-
- All Implemented Interfaces:
ParserInterface
,VersionInfoInterface
public class XMLSaxParser extends ParserImpl
A class reading Entries in XML format. XML Sax Parser doesn't support writing. This parser uses a SAX2 parser to read an XML document. For every start-tag read from the input document the parser concatenates this tag name with its parent tag name into a currentTag value. The currentTag value holds the path to the current position in the XML document. When character data is read an attribute is either created or appended to using the currentTag name and the character data as the value. Data collection is only done when a group tag is found (e.g. when any of the group tag values are found). When an end-tag is encountered the parser will first check to see if the currentTag matches the GroupTag configured for the parser, and if it does, the current entry is added to a queue which is read by the readEntry() method. Since SAX2 is event driven, this class creates a thread that performs the XML parsing and notifies the parser class when an entry is ready for consumption. The currentTag is composed of tag names concatenate with the "@" character. The GroupTag specifies which tag-path marks the boundary for an entry. If specified as a string not starting with an asterix, the tag is checked for equality with the currentTag. If the GroupTag starts with "*" then the currentTag is checked for containment of the GroupTag (e.g. "Root@Entry@X" matches "*Root@Entry" but not "Root@Entry"). You can specify multiple group tags by comma-separating the tags (e.g. a,b@x etc)Big Data Blue Data 12 88 Blue Data
-
-
Field Summary
-
Fields inherited from class com.ibm.di.parser.ParserImpl
_debug, myConfiguration
-
-
Constructor Summary
Constructors Constructor Description XMLSaxParser()
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeParser()
Stops the Sax Content Handler thread.java.lang.String
getVersion()
Version information.void
initParser()
Initializes queue object, reads configuration parameters, creates SaxContentHandler thread and starts the thread.Entry
readEntry()
readEntry() uses the queue object to check for new entries provided by the xml-parser thread.void
registerScriptBeans(ScriptEngine se)
Not usedvoid
writeEntry(Entry entry)
Not supported-
Methods inherited from class com.ibm.di.parser.ParserImpl
debug, debugMode, flush, getClassInstance, getContext, getDebug, getInputStream, getOutputStream, getParam, getParser, getReader, getWriter, isDeltaSupported, logmsg, querySchema, setConfiguration, setContext, setDebug, setInputStream, setInputStream, setInputStream, setOutputStream, setOutputStream, setParam, setParser
-
-
-
-
Method Detail
-
registerScriptBeans
public void registerScriptBeans(ScriptEngine se) throws java.lang.Exception
Not used- Specified by:
registerScriptBeans
in interfaceParserInterface
- Overrides:
registerScriptBeans
in classParserImpl
- Parameters:
se
-- Throws:
java.lang.Exception
-
initParser
public void initParser() throws java.lang.Exception
Initializes queue object, reads configuration parameters, creates SaxContentHandler thread and starts the thread.- Specified by:
initParser
in interfaceParserInterface
- Overrides:
initParser
in classParserImpl
- Throws:
java.lang.Exception
- if getInputStream() and getReader() both returns null.
-
closeParser
public void closeParser() throws java.lang.Exception
Stops the Sax Content Handler thread.- Specified by:
closeParser
in interfaceParserInterface
- Overrides:
closeParser
in classParserImpl
- Throws:
java.lang.Exception
-
readEntry
public Entry readEntry() throws java.lang.Exception
readEntry() uses the queue object to check for new entries provided by the xml-parser thread. The object found in the queue governs when an entry is ready, an end-of-file has been reached or if there is an error parsing the document. The method simply checks the class type for the object and decides what to do next.- Returns:
- The next Entry in the XML document.
- Throws:
java.lang.Exception
- if an error occurs.
-
writeEntry
public void writeEntry(Entry entry) throws java.lang.Exception
Not supported- Parameters:
entry
-- Throws:
java.lang.Exception
-
getVersion
public java.lang.String getVersion()
Description copied from interface:VersionInfoInterface
Version information.- Returns:
- version information
-
-