Package edu.isi.pegasus.planner.parser
Class PDAXParser
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- edu.isi.pegasus.planner.parser.Parser
-
- edu.isi.pegasus.planner.parser.PDAXParser
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler
,org.xml.sax.DTDHandler
,org.xml.sax.EntityResolver
,org.xml.sax.ErrorHandler
public class PDAXParser extends Parser
This is a parser class for the parsing the pdax that contain the jobs in the various partitions and the relations between the partitions.- Version:
- $Revision$
- Author:
- Karan Vahi
-
-
Field Summary
Fields Modifier and Type Field Description private Callback
mCallback
The callback handler to which the callbacks are sent during designated points of parsing the pdax.private java.lang.String
mChild
The current child.private int
mCurrentDepth
The current depth of parsing through the xml structure.private java.util.List
mParents
List of parents for a particular child.private Partition
mPartition
The object holding the contents of one partition as indicated in the pdax.static java.lang.String
SCHEMA_LOCATION
The "not-so-official" location URL of the DAX schema definition.static java.lang.String
SCHEMA_NAMESPACE
URI namespace-
Fields inherited from class edu.isi.pegasus.planner.parser.Parser
DEFAULT_PARSER_NAME, mAdjFName, mLocator, mLogger, mLogMsg, mParser, mProps, mTextContent, mTextString
-
-
Constructor Summary
Constructors Constructor Description PDAXParser(PegasusProperties properties)
The default constructor.PDAXParser(java.lang.String fileName, PegasusProperties properties)
The constructor initialises the parser, and turns on the validation feature in Xerces.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
endDocument()
This is called automatically when the end of the XML file is reached.void
endElement(java.lang.String uri, java.lang.String local, java.lang.String qName)
An empty implementation is provided by DefaultHandler class.java.lang.String
getSchemaLocation()
Helps the load database to locate the PDAX XML schema, if available.java.lang.String
getSchemaNamespace()
Returns the XML schema namespace that a document being parsed conforms to.private void
invalidAttribute(java.lang.String element, java.lang.String key, java.lang.String value)
Logs a message if an unknown key is come across, while parsing the xml document.private void
invalidValue(java.lang.String element, java.lang.String key, java.lang.String value)
Logs a message if an unknown value is come across, while parsing the xml document.void
setCallback(Callback callback)
Sets the callback handler for this parsing instance.void
startElement(java.lang.String uri, java.lang.String local, java.lang.String raw, org.xml.sax.Attributes attrs)
An empty implementation is provided by DefaultHandler of ContentHandler.void
startParser(java.lang.String file)
Ends up starting the parsing of the file , by the underlying parser.-
Methods inherited from class edu.isi.pegasus.planner.parser.Parser
characters, ignoreWhitespace, ignoreWhitespace, setDocumentLocator, setParserFeature, setSchemaLocations, testForFile
-
-
-
-
Field Detail
-
SCHEMA_LOCATION
public static final java.lang.String SCHEMA_LOCATION
The "not-so-official" location URL of the DAX schema definition.- See Also:
- Constant Field Values
-
SCHEMA_NAMESPACE
public static final java.lang.String SCHEMA_NAMESPACE
URI namespace- See Also:
- Constant Field Values
-
mPartition
private Partition mPartition
The object holding the contents of one partition as indicated in the pdax.
-
mCurrentDepth
private int mCurrentDepth
The current depth of parsing through the xml structure.
-
mChild
private java.lang.String mChild
The current child.
-
mParents
private java.util.List mParents
List of parents for a particular child.
-
mCallback
private Callback mCallback
The callback handler to which the callbacks are sent during designated points of parsing the pdax.
-
-
Constructor Detail
-
PDAXParser
public PDAXParser(PegasusProperties properties)
The default constructor.- Parameters:
properties
- thePegasusProperties
to be used.
-
PDAXParser
public PDAXParser(java.lang.String fileName, PegasusProperties properties)
The constructor initialises the parser, and turns on the validation feature in Xerces.- Parameters:
fileName
- the file which one has to parse using the parser.properties
- thePegasusProperties
to be used.
-
-
Method Detail
-
getSchemaNamespace
public java.lang.String getSchemaNamespace()
Returns the XML schema namespace that a document being parsed conforms to.- Specified by:
getSchemaNamespace
in classParser
- Returns:
- the schema namespace
-
setCallback
public void setCallback(Callback callback)
Sets the callback handler for this parsing instance.
-
startParser
public void startParser(java.lang.String file)
Ends up starting the parsing of the file , by the underlying parser.- Specified by:
startParser
in classParser
- Parameters:
file
- the path/url to the file that needs to be parsed.
-
startElement
public void startElement(java.lang.String uri, java.lang.String local, java.lang.String raw, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
An empty implementation is provided by DefaultHandler of ContentHandler. This method receives the notification from the sacks parser when start tag of an element comes. Any parser class must implement this method.- Specified by:
startElement
in interfaceorg.xml.sax.ContentHandler
- Specified by:
startElement
in classParser
- Throws:
org.xml.sax.SAXException
-
endElement
public void endElement(java.lang.String uri, java.lang.String local, java.lang.String qName)
An empty implementation is provided by DefaultHandler class. This method is called automatically by the Sax parser when the end tag of an element comes in the xml file. Any parser class should implement this method- Specified by:
endElement
in interfaceorg.xml.sax.ContentHandler
- Specified by:
endElement
in classParser
-
endDocument
public void endDocument()
This is called automatically when the end of the XML file is reached.- Specified by:
endDocument
in interfaceorg.xml.sax.ContentHandler
- Specified by:
endDocument
in classParser
-
getSchemaLocation
public java.lang.String getSchemaLocation()
Helps the load database to locate the PDAX XML schema, if available. Please note that the schema location URL in the instance document is only a hint, and may be overriden by the findings of this method.- Specified by:
getSchemaLocation
in classParser
- Returns:
- a location pointing to a definition document of the XML schema that can read PDAX. Result may be null, if such a document is unknown or unspecified.
-
invalidAttribute
private void invalidAttribute(java.lang.String element, java.lang.String key, java.lang.String value)
Logs a message if an unknown key is come across, while parsing the xml document.- Parameters:
element
- the xml element in which the invalid key was come across.key
- the key that is construed to be invalid.value
- the value associated with the key.
-
invalidValue
private void invalidValue(java.lang.String element, java.lang.String key, java.lang.String value)
Logs a message if an unknown value is come across, while parsing the xml document.- Parameters:
element
- the xml element in which the invalid key was come across.key
- the key that is construed to be invalid.value
- the value associated with the key.
-
-