Package de.saar.chorus.domgraph
Class ExampleManager
java.lang.Object
org.xml.sax.helpers.DefaultHandler
de.saar.chorus.domgraph.ExampleManager
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
An example manager for facilitating access to example input files.
This class allows the user to register example files and get
Reader objects for reading from them conveniently.
TODO: Right now, the example manager's behaviour is undefined when there is more than one example with the same filename.
- Author:
- Alexander Koller
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA parser exception that occurred while reading an examples specification file. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllExamples(String directory) Adds all examples from a given example specification file.voidaddExample(String filename, String directory, String description) Adds an example to the registry.getDescriptionForExample(String example) Returns the description for the example of the given name.Returns the list of all registered example names.getExampleReader(String name) Returns a Reader for the specified example file.voidstartElement(String uri, String localName, String qName, Attributes attributes) Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warningMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
ExampleManager
public ExampleManager()
-
-
Method Details
-
getExampleNames
Returns the list of all registered example names.- Returns:
-
getDescriptionForExample
Returns the description for the example of the given name.- Parameters:
example-- Returns:
-
getExampleReader
Returns a Reader for the specified example file. This reader looks for the file at its original pathname relative to the classpath. It is robust towards packaging in a Jar or the use of alternative class loaders, and provides the preferred way of accessing an example file.- Parameters:
name-- Returns:
-
addAllExamples
Adds all examples from a given example specification file. An example specification file is an XML file with the name "examples.xml" in the given directory. It is assumed to have the following form:<examples> <example filename="..." description="..." /> </examples>
Eachexampleelement specifies a filename and a description for one example file. The filename is interpreted relative to the directory which contains the "examples.xml" file.- Parameters:
directory- a directory containing a file with the name "examples.xml".- Throws:
ExampleManager.ParserException- if a parsing error occurred while reading the XML file.
-
addExample
Adds an example to the registry.- Parameters:
filename-directory-description-
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException - Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException
-