public class InvocationParser
extends org.xml.sax.helpers.DefaultHandler
Modifier and Type | Field and Description |
---|---|
private java.text.SimpleDateFormat |
m_coarse
Parsing for ISO dates without milliseconds
|
private int |
m_depth
Count the depths of elements in the document
|
private java.text.SimpleDateFormat |
m_fine
Parsing for ISO dates with millisecond extension.
|
private java.util.Map |
m_forward
A Hashmap to forward resolve namespaces that were encountered
during parsing.
|
private org.xml.sax.Locator |
m_location
Keep the location within the document
|
private org.griphyn.vdl.util.Logging |
m_log
Obtain our logger once for multiple uses.
|
private org.xml.sax.XMLReader |
m_parser
Holds the instance of a
XMLReader class. |
private InvocationRecord |
m_result
Holds the result, will be overwritten by each invocation of parse().
|
private java.util.Map |
m_reverse
A Hashmap to reverse resolve namespaces that were encountered
during parsing.
|
private java.util.Stack |
m_stack
A stack of namespaces?
|
protected static java.lang.String |
vendorParserClass
Default parser is the Xerces parser.
|
Constructor and Description |
---|
InvocationParser(java.lang.String schemaLocation)
The class constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] ch,
int start,
int length)
This method is the callback function for characters in an element.
|
private void |
complain(java.lang.String subject,
java.lang.String name,
java.lang.String value)
Small helper method to bundle repetitive complaints in a template
for reporting progress.
|
protected Invocation |
createObject(Invocation parent,
java.lang.String e,
java.util.List names,
java.util.List values)
This method determines the actively parsed element, creates the
Java object that corresponds to the element, and sets the member
variables with the values of the attributes of the element.
|
void |
endDocument()
The parser comes to the end of the document.
|
void |
endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName)
The parser is at the end of an element.
|
void |
endPrefixMapping(java.lang.String prefix)
Out of the reach of the prefix, remove it from the HashMap.
|
private java.lang.String |
full_where() |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Currently, ignorable whitespace will be ignored.
|
private void |
log(java.lang.String subject,
java.lang.String name,
java.lang.String value)
Small helper method to bundle repetitive parameters in a template
for reporting progress.
|
private java.lang.String |
map(java.lang.String uri)
Helper function to map prefixes correctly onto the elements.
|
InvocationRecord |
parse(java.io.InputStream reader)
This function parses a XML source from an InputStream source, and
creates java class instances that correspond to different elements
in the XML source.
|
InvocationRecord |
parse(java.io.Reader reader)
This function parses a XML source from the new Reader source, and
creates java class instances that correspond to different elements
in the XML source.
|
private java.util.Date |
parseDate(java.lang.String date)
Small helper to parse the different date varieties and deal with
Java obnoxeity.
|
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Receive a processing instruction.
|
private boolean |
set(java.lang.String uri,
boolean flag)
Sets a feature while capturing failed features right here.
|
void |
setDocumentLocator(org.xml.sax.Locator locator)
Obtains the document locator from the parser.
|
protected boolean |
setElementRelation(char initial,
Invocation parent,
Invocation child)
This method sets the relations between the currently finished XML
element and its containing element in terms of Java objects.
|
void |
setSchemaLocations(java.lang.String list)
Sets the list of external real locations where the XML schema may
be found.
|
private void |
setupJob(Job job,
java.util.List names,
java.util.List values)
Small helper method to set up the attributes for the job elements.
|
void |
skippedEntity(java.lang.String name)
Receive a notification that an entity was skipped.
|
void |
startDocument()
This method specifies what to do when the parser is at the beginning
of the document.
|
void |
startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes atts)
This method defines the action to take when the parser begins to parse
an element.
|
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
There is a prefix or namespace defined, put the prefix and its URI
in the HashMap.
|
private java.lang.String |
where() |
protected static final java.lang.String vendorParserClass
private org.xml.sax.XMLReader m_parser
XMLReader
class.private InvocationRecord m_result
private org.xml.sax.Locator m_location
private java.util.Map m_forward
private java.util.Map m_reverse
private java.text.SimpleDateFormat m_coarse
private java.text.SimpleDateFormat m_fine
private org.griphyn.vdl.util.Logging m_log
private int m_depth
private java.util.Stack m_stack
public InvocationParser(java.lang.String schemaLocation)
schemaLocation
- is the default location of the XML Schema
which this parser is capable of parsing. It may be null to use
the defaults provided in the document.private boolean set(java.lang.String uri, boolean flag)
uri
- is the feature's URI to modifyflag
- is the new value to set.public void setSchemaLocations(java.lang.String list)
list
- is a list of strings representing schema locations. The
content exists in pairs, one of the namespace URI, one of the
location URL.public InvocationRecord parse(java.io.InputStream reader)
reader
- is a bytestream opened for reading.public InvocationRecord parse(java.io.Reader reader)
reader
- is a character stream opened for reading.public void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator
in interface org.xml.sax.ContentHandler
setDocumentLocator
in class org.xml.sax.helpers.DefaultHandler
locator
- is the externally set current positionprivate java.lang.String full_where()
private java.lang.String where()
public void startDocument()
startDocument
in interface org.xml.sax.ContentHandler
startDocument
in class org.xml.sax.helpers.DefaultHandler
public void endDocument()
endDocument
in interface org.xml.sax.ContentHandler
endDocument
in class org.xml.sax.helpers.DefaultHandler
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
startPrefixMapping
in interface org.xml.sax.ContentHandler
startPrefixMapping
in class org.xml.sax.helpers.DefaultHandler
prefix
- the Namespace prefix being declared.uri
- the Namespace URI the prefix is mapped to.org.xml.sax.SAXException
public void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXException
endPrefixMapping
in interface org.xml.sax.ContentHandler
endPrefixMapping
in class org.xml.sax.helpers.DefaultHandler
prefix
- is the prefix that was being mapped previously.org.xml.sax.SAXException
private java.lang.String map(java.lang.String uri)
uri
- is the parser-returned URI that needs translation.public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
namespaceURI
- is the URI of the namespace for the elementlocalName
- is the element name without namespaceqName
- is the element name as it appears in the docmentatts
- has the names and values of all the attributesorg.xml.sax.SAXException
public void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
namespaceURI
- is the URI of the namespace for the elementlocalName
- is the element name without namespaceqName
- is the element name as it appears in the docmentorg.xml.sax.SAXException
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
characters
in interface org.xml.sax.ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
ch
- are the characters from the XML documentstart
- is the start position into the arraylength
- is the amount of valid data in the arrayorg.xml.sax.SAXException
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException
ignorableWhitespace
in interface org.xml.sax.ContentHandler
ignorableWhitespace
in class org.xml.sax.helpers.DefaultHandler
ch
- are the characters from the XML documentstart
- is the start position into the arraylength
- is the amount of valid data in the arrayorg.xml.sax.SAXException
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
processingInstruction
in interface org.xml.sax.ContentHandler
processingInstruction
in class org.xml.sax.helpers.DefaultHandler
target
- the processing instruction targetdata
- the processing instruction data, or null if none was supplied.
The data does not include any whitespace separating it from the target.org.xml.sax.SAXException
public void skippedEntity(java.lang.String name) throws org.xml.sax.SAXException
skippedEntity
in interface org.xml.sax.ContentHandler
skippedEntity
in class org.xml.sax.helpers.DefaultHandler
name
- The name of the skipped entity. If it is a parameter
entity, the name will begin with '%', and if it is the external DTD
subset, it will be the string "[dtd]".org.xml.sax.SAXException
private void log(java.lang.String subject, java.lang.String name, java.lang.String value)
subject
- is the name of the XML element that is being scrutinized.name
- is then name of the element we are working with.value
- is the attribute value.private void complain(java.lang.String subject, java.lang.String name, java.lang.String value)
subject
- is the name of the XML element that is being scrutinized.name
- is then name of the element we are working with.value
- is the attribute value.private java.util.Date parseDate(java.lang.String date) throws java.text.ParseException
date
- is an ISO 8601 timestampjava.text.ParseException
- thrown if the date cannot be parsedprivate void setupJob(Job job, java.util.List names, java.util.List values) throws java.lang.NumberFormatException, java.text.ParseException
job
- is the job to set up.names
- is the list of attribute namesvalues
- is the list of attribute valuesjava.lang.NumberFormatException
java.text.ParseException
protected Invocation createObject(Invocation parent, java.lang.String e, java.util.List names, java.util.List values) throws java.lang.IllegalArgumentException
parent
- is the parent elemente
- is the name of the elementnames
- is a list of attribute names, as strings.values
- is a list of attribute values, to match the key list.java.lang.IllegalArgumentException
- if the element name is too short.protected boolean setElementRelation(char initial, Invocation parent, Invocation child)
initial
- is the first charactor of the parent element nameparent
- is a reference to the parent's Java objectchild
- is the completed child object to connect to the parent