|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
edu.isi.pegasus.planner.parser.InvocationParser
public class InvocationParser
This class uses the Xerces SAX2 parser to validate and parse an XML document which contains information from kickstart generated invocation record.
| Field Summary | |
|---|---|
private SimpleDateFormat |
m_coarse
Parsing for ISO dates without milliseconds |
private int |
m_depth
Count the depths of elements in the document |
private SimpleDateFormat |
m_fine
Parsing for ISO dates with millisecond extension. |
private Map |
m_forward
A Hashmap to forward resolve namespaces that were encountered during parsing. |
private 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 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 Map |
m_reverse
A Hashmap to reverse resolve namespaces that were encountered during parsing. |
private Stack |
m_stack
A stack of namespaces? |
protected static String |
vendorParserClass
Default parser is the Xerces parser. |
| Constructor Summary | |
|---|---|
InvocationParser(String schemaLocation)
The class constructor. |
|
| Method Summary | |
|---|---|
void |
characters(char[] ch,
int start,
int length)
This method is the callback function for characters in an element. |
private void |
complain(String subject,
String name,
String value)
Small helper method to bundle repetitive complaints in a template for reporting progress. |
protected Invocation |
createObject(Invocation parent,
String e,
List names,
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(String namespaceURI,
String localName,
String qName)
The parser is at the end of an element. |
void |
endPrefixMapping(String prefix)
Out of the reach of the prefix, remove it from the HashMap. |
private String |
full_where()
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Currently, ignorable whitespace will be ignored. |
private void |
log(String subject,
String name,
String value)
Small helper method to bundle repetitive parameters in a template for reporting progress. |
private String |
map(String uri)
Helper function to map prefixes correctly onto the elements. |
InvocationRecord |
parse(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(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 Date |
parseDate(String date)
Small helper to parse the different date varieties and deal with Java obnoxeity. |
void |
processingInstruction(String target,
String data)
Receive a processing instruction. |
private boolean |
set(String uri,
boolean flag)
Sets a feature while capturing failed features right here. |
void |
setDocumentLocator(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(String list)
Sets the list of external real locations where the XML schema may be found. |
private void |
setupJob(Job job,
List names,
List values)
Small helper method to set up the attributes for the job elements. |
void |
skippedEntity(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(String namespaceURI,
String localName,
String qName,
Attributes atts)
This method defines the action to take when the parser begins to parse an element. |
void |
startPrefixMapping(String prefix,
String uri)
There is a prefix or namespace defined, put the prefix and its URI in the HashMap. |
private String |
where()
|
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
|---|
error, fatalError, notationDecl, resolveEntity, unparsedEntityDecl, warning |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final String vendorParserClass
private XMLReader m_parser
XMLReader class.
private InvocationRecord m_result
private Locator m_location
private Map m_forward
private Map m_reverse
private SimpleDateFormat m_coarse
private SimpleDateFormat m_fine
private org.griphyn.vdl.util.Logging m_log
private int m_depth
private Stack m_stack
| Constructor Detail |
|---|
public InvocationParser(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.| Method Detail |
|---|
private boolean set(String uri,
boolean flag)
uri - is the feature's URI to modifyflag - is the new value to set.
public void setSchemaLocations(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(InputStream reader)
reader - is a bytestream opened for reading.
public InvocationRecord parse(Reader reader)
reader - is a character stream opened for reading.
public void setDocumentLocator(Locator locator)
setDocumentLocator in interface ContentHandlersetDocumentLocator in class DefaultHandlerlocator - is the externally set current positionprivate String full_where()
private String where()
public void startDocument()
startDocument in interface ContentHandlerstartDocument in class DefaultHandlerpublic void endDocument()
endDocument in interface ContentHandlerendDocument in class DefaultHandler
public void startPrefixMapping(String prefix,
String uri)
throws SAXException
startPrefixMapping in interface ContentHandlerstartPrefixMapping in class DefaultHandlerprefix - the Namespace prefix being declared.uri - the Namespace URI the prefix is mapped to.
SAXException
public void endPrefixMapping(String prefix)
throws SAXException
endPrefixMapping in interface ContentHandlerendPrefixMapping in class DefaultHandlerprefix - is the prefix that was being mapped previously.
SAXExceptionprivate String map(String uri)
uri - is the parser-returned URI that needs translation.
public void startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
throws SAXException
startElement in interface ContentHandlerstartElement in class DefaultHandlernamespaceURI - 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 attributes
SAXException
public void endElement(String namespaceURI,
String localName,
String qName)
throws SAXException
endElement in interface ContentHandlerendElement in class DefaultHandlernamespaceURI - is the URI of the namespace for the elementlocalName - is the element name without namespaceqName - is the element name as it appears in the docment
SAXException
public void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class DefaultHandlerch - are the characters from the XML documentstart - is the start position into the arraylength - is the amount of valid data in the array
SAXException
public void ignorableWhitespace(char[] ch,
int start,
int length)
throws SAXException
ignorableWhitespace in interface ContentHandlerignorableWhitespace in class DefaultHandlerch - are the characters from the XML documentstart - is the start position into the arraylength - is the amount of valid data in the array
SAXException
public void processingInstruction(String target,
String data)
throws SAXException
processingInstruction in interface ContentHandlerprocessingInstruction in class DefaultHandlertarget - 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.
SAXException
public void skippedEntity(String name)
throws SAXException
skippedEntity in interface ContentHandlerskippedEntity in class DefaultHandlername - 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]".
SAXException
private void log(String subject,
String name,
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(String subject,
String name,
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 Date parseDate(String date)
throws ParseException
date - is an ISO 8601 timestamp
ParseException - thrown if the date cannot be parsed
private void setupJob(Job job,
List names,
List values)
throws NumberFormatException,
ParseException
job - is the job to set up.names - is the list of attribute namesvalues - is the list of attribute values
NumberFormatException
ParseException
protected Invocation createObject(Invocation parent,
String e,
List names,
List values)
throws 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.
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
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||