edu.isi.pegasus.planner.parser
Class SiteCatalogParser

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.StackBasedXMLParser
              extended by edu.isi.pegasus.planner.parser.SiteCatalogParser
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class SiteCatalogParser
extends StackBasedXMLParser

This class uses the Xerces SAX2 parser to validate and parse an XML document conforming to the Site Catalog schema v3.0

Version:
$Revision: 4507 $
Author:
Karan Vahi vahi@isi.edu

Field Summary
private  boolean mLoadAll
          A boolean indicating whether to load all sites.
private  SiteStore mResult
          The final result constructed.
private  Set<String> mSites
          The set of sites that need to be parsed.
static String SCHEMA_LOCATION
          The "not-so-official" location URL of the Site Catalog Schema.
static String SCHEMA_NAMESPACE
          uri namespace
 
Fields inherited from class edu.isi.pegasus.planner.parser.StackBasedXMLParser
mDepth, mParsingDone, mStack
 
Fields inherited from class edu.isi.pegasus.planner.parser.Parser
DEFAULT_PARSER_NAME, mAdjFName, mLocator, mLogger, mLogMsg, mParser, mProps, mTextContent, mTextString
 
Constructor Summary
SiteCatalogParser(PegasusBag bag, List<String> sites)
          The overloaded constructor.
 
Method Summary
 void complain(String element, String attribute, String value)
          This is called when an attribute is encountered for an element that is invalid from the schema context and is not supported.
 Object createObject(String element, List names, List values)
          Composes the SiteData object corresponding to the element name in the XML document.
 String getSchemaLocation()
          Returns the local path to the XML schema against which to validate.
 String getSchemaNamespace()
          Returns the XML schema namespace that a document being parsed conforms to.
 SiteStore getSiteStore()
          Returns the constructed site store object
private  boolean loadSite(SiteCatalogEntry site)
          Whether to laod a site or not in the SiteStore
static void main(String[] args)
           
 boolean setElementRelation(String childElement, Object parent, Object child)
          This method sets the relations between the currently finished XML element and its containing element in terms of Java objects.
 void startParser(String file)
          The main method that starts the parsing.
 
Methods inherited from class edu.isi.pegasus.planner.parser.StackBasedXMLParser
attributeNotSupported, endDocument, endElement, log, startElement, unSupportedNestingOfElements
 
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 Site Catalog Schema.

See Also:
Constant Field Values

SCHEMA_NAMESPACE

public static final String SCHEMA_NAMESPACE
uri namespace

See Also:
Constant Field Values

mResult

private SiteStore mResult
The final result constructed.


mSites

private Set<String> mSites
The set of sites that need to be parsed.


mLoadAll

private boolean mLoadAll
A boolean indicating whether to load all sites.

Constructor Detail

SiteCatalogParser

public SiteCatalogParser(PegasusBag bag,
                         List<String> sites)
The overloaded constructor.

Parameters:
bag - the bag of initialization objects.
sites - the list of sites that need to be parsed. * means all.
Method Detail

getSiteStore

public SiteStore getSiteStore()
Returns the constructed site store object

Returns:
SiteStore if parsing completed

startParser

public void startParser(String file)
The main method that starts the parsing.

Specified by:
startParser in class Parser
Parameters:
file - the XML file to be parsed.

createObject

public Object createObject(String element,
                           List names,
                           List values)
Composes the SiteData object corresponding to the element name in the XML document.

Specified by:
createObject in class StackBasedXMLParser
Parameters:
element - the element name encountered while parsing.
names - is a list of attribute names, as strings.
values - is a list of attribute values, to match the key list.
Returns:
the relevant SiteData object, else null if unable to construct.
Throws:
IllegalArgumentException - if the element name is too short.

loadSite

private boolean loadSite(SiteCatalogEntry site)
Whether to laod a site or not in the SiteStore

Parameters:
site - the SiteCatalogEntry object.
Returns:
boolean

setElementRelation

public boolean setElementRelation(String childElement,
                                  Object parent,
                                  Object child)
This method sets the relations between the currently finished XML element and its containing element in terms of Java objects. Usually it involves adding the object to the parent's child object list.

Specified by:
setElementRelation in class StackBasedXMLParser
Parameters:
childElement - name is the the child element name
parent - is a reference to the parent's Java object
child - is the completed child object to connect to the parent
Returns:
true if the element was added successfully, false, if the child does not match into the parent.

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

getSchemaLocation

public String getSchemaLocation()
Returns the local path to the XML schema against which to validate.

Specified by:
getSchemaLocation in class Parser
Returns:
path to the schema

complain

public void complain(String element,
                     String attribute,
                     String value)
Description copied from class: StackBasedXMLParser
This is called when an attribute is encountered for an element that is invalid from the schema context and is not supported.

Overrides:
complain in class StackBasedXMLParser
Parameters:
element -
attribute -
value -

main

public static void main(String[] args)
Parameters:
args -


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