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
`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 and 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
`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`

### 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 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` - the `PegasusProperties` 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` - the `PegasusProperties` 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 class `Parser`
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 class `Parser`
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 interface `org.xml.sax.ContentHandler`
Specified by:
  `startElement` in class `Parser`
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 interface `org.xml.sax.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 `org.xml.sax.ContentHandler`
Specified by:
  `endDocument` in class `Parser`

#### 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 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(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.