| java.lang.Object org.xml.sax.helpers.DefaultHandler com.sun.perseus.builder.ModelBuilder
ModelBuilder | public class ModelBuilder extends DefaultHandler (Code) | | NOTE: need to change currentElement management so that there is only a
need to do a getParent() and cast to (ElementNode).
ModelBuilder is a SAX2 ContentHandler that
builds a Model (i.e. a tree of ModelNode s from
the SAX2 events.
This class also offers a static method to synchronously builds a
Model given a URI:
ModelBuilder.loadDocument loadDocument .
version: $Id: ModelBuilder.java,v 1.10 2006/07/13 00:55:57 st125089 Exp $ |
Constructor Summary | |
| ModelBuilder(Vector modelFactoryIn, DocumentNode modelRootIn) The modelFactory is used to build
ModelNode instances corresponding
to individual nodes in the parsed XML documents. |
Method Summary | |
void | addToParent(ElementNode child, CompositeNode parent) Adds the input node to the given parent. | final public void | characters(char[] ch, int start, int length) Receive notification of character data inside an element.
By default, do nothing. | final public void | endDocument() Receive notification of the end of the document.
By default, do nothing. | final public void | endElement(String uri, String localName, String qName) Updates the currentElement. | final public void | fatalError(SAXParseException e) Report a fatal XML parsing error. | final DocumentNode | getModelRoot() | protected void | invokeAndWait(Runnable runnable) Utility method. | public static DocumentNode | loadDocument(String svgURI) Loads an SVG Tiny document from a given URI
Parameters: svgURI - the URI of the SVG document to load. | public static void | loadDocument(InputStream is, DocumentNode root) Load an SVG Tiny document at the given input stream.
This method uses JAXP to define the SAX parser to use.
Any error is reported to the input DocumentNode 's
UpdateListener 's loadFailed method.
Parameters: is - the InputStream from which the SVG content isread. | public static void | loadDocument(InputStream is, DocumentNode root, Vector modelFactory) Load an SVG Tiny document at the given input stream.
This method uses JAXP to define the SAX parser to use.
Any error is reported to the input DocumentNode 's
UpdateListener 's loadFailed method.
Parameters: is - the InputStream from which the SVG content isread. | protected static void | loadingFailed(UpdateListener updateListener, DocumentNode root, Exception e) Utility method to report an exception to the UpdateListener
in the proper thread. | final public InputSource | resolveEntity(String publicId, String systemId) Resolve an external entity.
Parameters: publicId - The public identifer, or null if none isavailable. Parameters: systemId - The system identifier provided in the XML document. | final public void | setDocumentLocator(Locator locator) Receive a Locator object for document events.
By default, do nothing. | final public void | startDocument() SAX: Implements
org.xml.sax.ContentHandler.startDocument ContentHander.startDocument . | final public void | startElement(String uri, String localName, String qName, Attributes attributes) Receive notification of the start of an element. | public void | startPrefixMapping(String prefix, String uri) Receive notification of the start of a Namespace mapping.
By default, do nothing. |
DTD_SUBSET | final public static String DTD_SUBSET(Code) | | The default DTD subset used when resolving the DTD entities.
|
LOAD_INTERRUPTED | final public static String LOAD_INTERRUPTED(Code) | | The message used in the SAXException when the
loading thread is interrupted
|
currentElement | protected ElementNode currentElement(Code) | | Object keeping track of the current node, i.e., the
last node that was built from an element.
|
dtdids | protected static String dtdids(Code) | | The accepted DTD public IDs.
|
pendingPrefixMapping | protected Vector pendingPrefixMapping(Code) | | Keeps pending namespaceURI to prefix mapping. This is used because
the prefix mapping is declared in the startPrefixMapping method
_before_ startElement is called. Therefore, the startElement method
will use this pendingPrefixMapping vector to declare prefix mappings
on the newly created element.
|
pendingPrefixMappingCache | protected Vector pendingPrefixMappingCache(Code) | | Used to allows quick check on pendingPrefixMapping.
|
ModelBuilder | ModelBuilder(Vector modelFactoryIn, DocumentNode modelRootIn)(Code) | | The modelFactory is used to build
ModelNode instances corresponding
to individual nodes in the parsed XML documents.
This ModelBuilder aggregates the nodes
manufactured by the modelFactory
Parameters: modelFactoryIn - the factory that contains elementprototypes for the supported element types Parameters: modelRootIn - the DocumentNode that should be populated with the result of the build process. |
addToParent | void addToParent(ElementNode child, CompositeNode parent) throws SAXException(Code) | | Adds the input node to the given parent. If there is no
associated RunnableQueue , the child is simply
added to the parent in the calling thread. If there is
a RunnableQueue , the child is added to the parent
the RunnableQueue thread, by invoking a
Runnable on the queue.
Parameters: child - node to add to the parent Parameters: parent - node to which the child is added. throws: SAXException - if the child cannot be added to the parentbecause the thread was interrupted or if the thread was interrupted to begin with. |
characters | final public void characters(char[] ch, int start, int length) throws SAXException(Code) | | Receive notification of character data inside an element.
By default, do nothing. Application writers may override this
method to take specific actions for each chunk of character data
(such as adding the data to a node or buffer, or printing it to
a file).
Parameters: ch - The characters. Parameters: start - The start position in the character array. Parameters: length - The number of characters to use from thecharacter array. exception: org.xml.sax.SAXException - Any SAX exception, possiblywrapping another exception. See Also: org.xml.sax.ContentHandler.characters |
endDocument | final public void endDocument() throws SAXException(Code) | | Receive notification of the end of the document.
By default, do nothing. Application writers may override this
method in a subclass to take specific actions at the end
of a document (such as finalising a tree or closing an output
file).
exception: org.xml.sax.SAXException - Any SAX exception, possiblywrapping another exception. See Also: org.xml.sax.ContentHandler.endDocument |
fatalError | final public void fatalError(SAXParseException e) throws SAXException(Code) | | Report a fatal XML parsing error.
The default implementation throws a SAXParseException.
Application writers may override this method in a subclass if
they need to take specific actions for each fatal error (such as
collecting all of the errors into a single report): in any case,
the application must stop all regular processing when this
method is invoked, since the document is no longer reliable, and
the parser may no longer report parsing events.
Parameters: e - The error information encoded as an exception. exception: org.xml.sax.SAXException - Any SAX exception, possiblywrapping another exception. See Also: org.xml.sax.ErrorHandler.fatalError See Also: org.xml.sax.SAXParseException |
getModelRoot | final DocumentNode getModelRoot()(Code) | | the root of the tree built by this builder.null is returned if no tree was built yet |
invokeAndWait | protected void invokeAndWait(Runnable runnable) throws SAXException(Code) | | Utility method. Invokes the Runnable on the
modelRoot.invokeAndWait .
Parameters: runnable - the Runnable to run throws: SAXException - if the input Runnable is interrupted while pending execution or while running. |
loadDocument | public static DocumentNode loadDocument(String svgURI) throws IOException(Code) | | Loads an SVG Tiny document from a given URI
Parameters: svgURI - the URI of the SVG document to load. the DocumentNode built from the requested svgURI. throws: IOException - if the file cannot be loaded. |
loadDocument | public static void loadDocument(InputStream is, DocumentNode root)(Code) | | Load an SVG Tiny document at the given input stream.
This method uses JAXP to define the SAX parser to use.
Any error is reported to the input DocumentNode 's
UpdateListener 's loadFailed method.
Parameters: is - the InputStream from which the SVG content isread. This might be GZIPed compressed stream. If the input streamis null, an input stream is opened from the root's document URI. Parameters: root - the documentNode to populate with the document's content throws: IllegalArgumentException - if the root's URI is null, if root is null or if the root's UpdateListener is null |
loadDocument | public static void loadDocument(InputStream is, DocumentNode root, Vector modelFactory)(Code) | | Load an SVG Tiny document at the given input stream.
This method uses JAXP to define the SAX parser to use.
Any error is reported to the input DocumentNode 's
UpdateListener 's loadFailed method.
Parameters: is - the InputStream from which the SVG content isread. This might be GZIPed compressed stream. If the input streamis null, an input stream is opened from the root's document URI. Parameters: root - the documentNode to populate with the document's content Parameters: modelFactory - the ModelFactory used to turn XML elements into ModelNode instances. throws: IllegalArgumentException - if the root's URI is null, if root is null or if the root's UpdateListener is null |
loadingFailed | protected static void loadingFailed(UpdateListener updateListener, DocumentNode root, Exception e)(Code) | | Utility method to report an exception to the UpdateListener
in the proper thread.
Parameters: updateListener - the UpdateListener to which the error should be reported. Parameters: root - the DocumentNode which was being loaded. Parameters: e - the Exception which caused the failure. |
setDocumentLocator | final public void setDocumentLocator(Locator locator)(Code) | | Receive a Locator object for document events.
By default, do nothing. Application writers may override this
method in a subclass if they wish to store the locator for use
with other document events.
Parameters: locator - A locator for all SAX document events. See Also: org.xml.sax.ContentHandler.setDocumentLocator See Also: org.xml.sax.Locator |
startElement | final public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException(Code) | | Receive notification of the start of an element.
Parameters: uri - The element's namespace uri Parameters: localName - The element's local name, i.e., within the given namespace Parameters: qName - The element's qualified name, i.e., including the namespace prefix Parameters: attributes - The specified or defaulted attributes. exception: org.xml.sax.SAXException - Any SAX exception, possiblywrapping another exception. See Also: org.xml.sax.ContentHandler.startElement |
startPrefixMapping | public void startPrefixMapping(String prefix, String uri) throws SAXException(Code) | | Receive notification of the start of a Namespace mapping.
By default, do nothing. Application writers may override this
method in a subclass to take specific actions at the start of
each Namespace prefix scope (such as storing the prefix mapping).
Parameters: prefix - The Namespace prefix being declared. Parameters: uri - The Namespace URI mapped to the prefix. exception: org.xml.sax.SAXException - Any SAX exception, possiblywrapping another exception. See Also: org.xml.sax.ContentHandler.startPrefixMapping |
Methods inherited from org.xml.sax.helpers.DefaultHandler | public void characters(char ch, int start, int length) throws SAXException(Code)(Java Doc) public void endDocument() throws SAXException(Code)(Java Doc) public void endElement(String uri, String localName, String qName) throws SAXException(Code)(Java Doc) public void endPrefixMapping(String prefix) throws SAXException(Code)(Java Doc) public void error(SAXParseException e) throws SAXException(Code)(Java Doc) public void fatalError(SAXParseException e) throws SAXException(Code)(Java Doc) public void ignorableWhitespace(char ch, int start, int length) throws SAXException(Code)(Java Doc) public void notationDecl(String name, String publicId, String systemId) throws SAXException(Code)(Java Doc) public void processingInstruction(String target, String data) throws SAXException(Code)(Java Doc) public InputSource resolveEntity(String publicId, String systemId) throws SAXException(Code)(Java Doc) public void setDocumentLocator(Locator locator)(Code)(Java Doc) public void skippedEntity(String name) throws SAXException(Code)(Java Doc) public void startDocument() throws SAXException(Code)(Java Doc) public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException(Code)(Java Doc) public void startPrefixMapping(String prefix, String uri) throws SAXException(Code)(Java Doc) public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException(Code)(Java Doc) public void warning(SAXParseException e) throws SAXException(Code)(Java Doc)
|
|
|