edu.isi.pegasus.planner.parser
Class PDAXParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by edu.isi.pegasus.planner.parser.Parser
          extended by edu.isi.pegasus.planner.parser.PDAXParser
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, 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: 2611 $
Author:
Karan Vahi

Field Summary
private  Callback mCallback
          The callback handler to which the callbacks are sent during designated points of parsing the pdax.
private  String mChild
          The current child.
private  int mCurrentDepth
          The current depth of parsing through the xml structure.
private  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 String SCHEMA_LOCATION
          The "not-so-official" location URL of the DAX schema definition.
static 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
PDAXParser(PegasusProperties properties)
          The default constructor.
PDAXParser(String fileName, PegasusProperties properties)
          The constructor initialises the parser, and turns on the validation feature in Xerces.
 
Method Summary
 void endDocument()
          This is called automatically when the end of the XML file is reached.
 void endElement(String uri, String local, String qName)
          An empty implementation is provided by DefaultHandler class.
 String getSchemaLocation()
          Helps the load database to locate the PDAX XML schema, if available.
 String getSchemaNamespace()
          Returns the XML schema namespace that a document being parsed conforms to.
private  void invalidAttribute(String element, String key, String value)
          Logs a message if an unknown key is come across, while parsing the xml document.
private  void invalidValue(String element, String key, 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(String uri, String local, String raw, Attributes attrs)
          An empty implementation is provided by DefaultHandler of ContentHandler.
 void startParser(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
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCHEMA_LOCATION

public static final String SCHEMA_LOCATION
The "not-so-official" location URL of the DAX schema definition.

See Also:
Constant Field Values

SCHEMA_NAMESPACE

public static final 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 String mChild
The current child.


mParents

private 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 - the PegasusProperties to be used.

PDAXParser

public PDAXParser(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 - the PegasusProperties to be used.
Method Detail

getSchemaNamespace

public String getSchemaNamespace()
Returns the XML schema namespace that a document being parsed conforms to.

Specified by:
getSchemaNamespace in class Parser
Returns:
the schema namespace

setCallback

public void setCallback(Callback callback)
Sets the callback handler for this parsing instance.


startParser

public void startParser(String file)
Ends up starting the parsing of the file , by the underlying parser.

Specified by:
startParser in class Parser
Parameters:
file - the path/url to the file that needs to be parsed.

startElement

public void startElement(String uri,
                         String local,
                         String raw,
                         Attributes attrs)
                  throws 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 interface ContentHandler
Specified by:
startElement in class Parser
Throws:
SAXException

endElement

public void endElement(String uri,
                       String local,
                       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 interface ContentHandler
Specified by:
endElement in class Parser

endDocument

public void endDocument()
This is called automatically when the end of the XML file is reached.

Specified by:
endDocument in interface ContentHandler
Specified by:
endDocument in class Parser

getSchemaLocation

public 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 class Parser
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(String element,
                              String key,
                              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(String element,
                          String key,
                          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.


Copyright © 2011 The University of Southern California. All Rights Reserved.