ptolemy.backtrack.xmlparser
Class ConfigXmlHandler

java.lang.Object
  extended by ptolemy.backtrack.xmlparser.XmlHandler
      extended by ptolemy.backtrack.xmlparser.ConfigXmlHandler
All Implemented Interfaces:
XmlHandler

public class ConfigXmlHandler
extends XmlHandler

XML handler that generates the library description for backtracking actors.

Since:
Ptolemy II 5.1
Version:
$Id: ConfigXmlHandler.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Thomas Feng
Accepted Rating:
Red (tfeng)
Proposed Rating:
Red (tfeng)

Field Summary
private  java.util.Set<java.lang.String> _excludedFiles
          The canonical paths of the XML documents that should be excluded from the parsing.
private  java.util.Set<java.lang.String> _includedClasses
          The names of the classes that should be kept in the transformed XML document.
private  java.util.Set<java.lang.String> _parsedFiles
          The canonical paths of the XML documents that have been parsed by this parser, or by the parsers that parse the ancestor nodes of the current tree.
private static java.util.Set<java.lang.String> _REMOVED_CLASS_SET
          The class in the original XML document that should be removed when it is transformed to the library description of backtracking actors.
private static java.lang.String[] _REMOVED_CLASSES
          The class in the original XML document that should be removed when it is transformed to the library description of backtracking actors.
private static java.util.Set<java.lang.String> _REMOVED_ELEMENT_SET
          The elements in the original XML document that should be removed when it is transformed to the library description of backtracking actors.
private static java.lang.String[] _REMOVED_ELEMENTS
          The elements in the original XML document that should be removed when it is transformed to the library description of backtracking actors.
 
Fields inherited from class ptolemy.backtrack.xmlparser.XmlHandler
MoML_DTD_1, MoML_PUBLIC_ID_1
 
Constructor Summary
ConfigXmlHandler(ConfigXmlTree tree, java.lang.String systemId, java.util.Set<java.lang.String> includedClasses)
          Construct an XML handler.
 
Method Summary
 void addExcludedFile(java.lang.String canonicalPath)
          Exclude the specified XML document from the scan.
 void addExcludedFiles(java.util.Collection<java.lang.String> canonicalPaths)
          Exclude the specified XML documents from the scan.
 void endElement(java.lang.String elementName)
          Handle the end tag of an XML element.
 void processingInstruction(java.lang.String target, java.lang.String data)
          Process the instruction given in the data.
 void startElement(java.lang.String elementName)
          Handle the start tag of an XML element.
 
Methods inherited from class ptolemy.backtrack.xmlparser.XmlHandler
attribute, charData, doctypeDecl, endDocument, endExternalEntity, error, getCurrentTree, getSystemId, ignorableWhitespace, resolveEntity, startDocument, startExternalEntity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_REMOVED_CLASSES

private static final java.lang.String[] _REMOVED_CLASSES
The class in the original XML document that should be removed when it is transformed to the library description of backtracking actors.


_REMOVED_CLASS_SET

private static java.util.Set<java.lang.String> _REMOVED_CLASS_SET
The class in the original XML document that should be removed when it is transformed to the library description of backtracking actors.


_REMOVED_ELEMENTS

private static final java.lang.String[] _REMOVED_ELEMENTS
The elements in the original XML document that should be removed when it is transformed to the library description of backtracking actors.


_REMOVED_ELEMENT_SET

private static java.util.Set<java.lang.String> _REMOVED_ELEMENT_SET
The elements in the original XML document that should be removed when it is transformed to the library description of backtracking actors.


_excludedFiles

private java.util.Set<java.lang.String> _excludedFiles
The canonical paths of the XML documents that should be excluded from the parsing.


_includedClasses

private java.util.Set<java.lang.String> _includedClasses
The names of the classes that should be kept in the transformed XML document. If it is null, all classes will be kept.


_parsedFiles

private java.util.Set<java.lang.String> _parsedFiles
The canonical paths of the XML documents that have been parsed by this parser, or by the parsers that parse the ancestor nodes of the current tree.

Constructor Detail

ConfigXmlHandler

ConfigXmlHandler(ConfigXmlTree tree,
                 java.lang.String systemId,
                 java.util.Set<java.lang.String> includedClasses)
Construct an XML handler.

Parameters:
tree - The XML tree to be scanned.
systemId - The system ID representing the location of the original XML document.
includedClasses - The classes in the original XML document that should be transformed in the new XML document.
Method Detail

addExcludedFile

public void addExcludedFile(java.lang.String canonicalPath)
Exclude the specified XML document from the scan.

Parameters:
canonicalPath - The canonical path of the XML document to be excluded.

addExcludedFiles

public void addExcludedFiles(java.util.Collection<java.lang.String> canonicalPaths)
Exclude the specified XML documents from the scan.

Parameters:
canonicalPaths - The canonical paths of the XML documents to be excluded.

endElement

public void endElement(java.lang.String elementName)
                throws java.lang.Exception
Handle the end tag of an XML element. This method tests whether the XML element has a "class" attribute, whose value is a class name in the set of classes to keep. If so, the element is kept in the transformed XML document. Otherwise, the element is not output to the transformed XML document.

Specified by:
endElement in interface XmlHandler
Overrides:
endElement in class XmlHandler
Parameters:
elementName - The name of the XML element.
Throws:
java.lang.Exception - If the overrided method in the superclass throws an Exception.
See Also:
XmlHandler.startElement(java.lang.String), XmlParser.declaredElements(), XmlParser.getElementContentType(java.lang.String)

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws java.lang.Exception
Process the instruction given in the data. This method only handles the "moml" target type.

Specified by:
processingInstruction in interface XmlHandler
Overrides:
processingInstruction in class XmlHandler
Parameters:
target - The target (the name at the start of the processing instruction).
data - The data, if any (the rest of the processing instruction).
Throws:
java.lang.Exception - If the MoML parser throws an exception.

startElement

public void startElement(java.lang.String elementName)
                  throws java.lang.Exception
Handle the start tag of an XML element. If the element is an "input" element, the source referred to is parsed.

Specified by:
startElement in interface XmlHandler
Overrides:
startElement in class XmlHandler
Parameters:
elementName - The name of the XML element.
Throws:
java.lang.Exception - If the overridden method in the superclass throws an Exception.
See Also:
XmlHandler.attribute(java.lang.String, java.lang.String, boolean), XmlHandler.endElement(java.lang.String), XmlParser.declaredElements(), XmlParser.getElementContentType(java.lang.String)