org.apache.batik.dom.util
Class DocumentFactory

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--org.apache.batik.dom.util.DocumentFactory
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, LexicalHandler
Direct Known Subclasses:
SVGDocumentFactory

public class DocumentFactory
extends DefaultHandler
implements LexicalHandler

This class contains methods for creating Document instances from an URI using SAX2.


Field Summary
protected  Node currentNode
          The current node.
protected  Document document
          The created document.
protected  boolean documentElementParsed
          Whether the document element has been parsed.
protected  DOMImplementation implementation
          The DOM implementation used to create the document.
protected  boolean inCDATA
          Whether the parser currently parses a CDATA section.
protected  boolean inDTD
          Whether the parser currently parses a DTD.
protected  HashTableStack namespaces
          The stack used to store the namespace URIs.
protected  java.lang.String parserClassName
          The SAX2 parser classname.
 
Constructor Summary
DocumentFactory(DOMImplementation impl, java.lang.String parser)
          Creates a new DocumentFactory object.
 
Method Summary
 void characters(char[] ch, int start, int length)
          SAX: Implements ContentHandler.characters(char[],int,int).
 void comment(char[] ch, int start, int length)
          SAX: Implements LexicalHandler.comment(char[],int,int).
 Document createDocument(java.lang.String ns, java.lang.String root, java.lang.String uri, InputSource is)
          Creates a GenericDocument.
 void endCDATA()
          SAX: Implements LexicalHandler.endCDATA().
 void endDTD()
          SAX: Implements LexicalHandler.endDTD().
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName)
          SAX: Implements ContentHandler.endElement(String,String,String).
 void endEntity(java.lang.String name)
          SAX: Implements LexicalHandler.endEntity(String).
 void processingInstruction(java.lang.String target, java.lang.String data)
          SAX: Implements ContentHandler.processingInstruction(String,String).
 void startCDATA()
          SAX: Implements LexicalHandler.startCDATA().
 void startDocument()
          SAX: Implements ContentHandler.startDocument().
 void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          SAX: Implements LexicalHandler.startDTD(String,String,String).
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName, Attributes attributes)
          SAX: Implements ContentHandler.startElement(String,String,String,Attributes).
 void startEntity(java.lang.String name)
          SAX: Implements LexicalHandler.startEntity(String).
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

implementation

protected DOMImplementation implementation
The DOM implementation used to create the document.

parserClassName

protected java.lang.String parserClassName
The SAX2 parser classname.

document

protected Document document
The created document.

currentNode

protected Node currentNode
The current node.

inCDATA

protected boolean inCDATA
Whether the parser currently parses a CDATA section.

inDTD

protected boolean inDTD
Whether the parser currently parses a DTD.

documentElementParsed

protected boolean documentElementParsed
Whether the document element has been parsed.

namespaces

protected HashTableStack namespaces
The stack used to store the namespace URIs.
Constructor Detail

DocumentFactory

public DocumentFactory(DOMImplementation impl,
                       java.lang.String parser)
Creates a new DocumentFactory object.
Parameters:
impl - The DOM implementation to use for building the DOM tree.
parser - The SAX2 parser classname.
Method Detail

createDocument

public Document createDocument(java.lang.String ns,
                               java.lang.String root,
                               java.lang.String uri,
                               InputSource is)
                        throws DOMException,
                               SAXException,
                               java.lang.InterruptedException
Creates a GenericDocument.
Parameters:
ns - The namespace URI of the root element.
root - The name of the root element.
uri - The document URI.
is - The document input source.
Throws:
DOMException - if an error occured when building the document.
SAXException - if an error occured when reading the document.
java.lang.InterruptedException - if the current thread is interrupted.

startDocument

public void startDocument()
                   throws SAXException
SAX: Implements ContentHandler.startDocument().
Overrides:
startDocument in class DefaultHandler
Following copied from class: org.xml.sax.helpers.DefaultHandler
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.startDocument()

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String rawName,
                         Attributes attributes)
                  throws SAXException
SAX: Implements ContentHandler.startElement(String,String,String,Attributes).
Overrides:
startElement in class DefaultHandler
Following copied from class: org.xml.sax.helpers.DefaultHandler
Parameters:
name - The element type name.
attributes - The specified or defaulted attributes.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String rawName)
                throws SAXException
SAX: Implements ContentHandler.endElement(String,String,String).
Overrides:
endElement in class DefaultHandler
Following copied from class: org.xml.sax.helpers.DefaultHandler
Parameters:
name - The element type name.
attributes - The specified or defaulted attributes.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
SAX: Implements ContentHandler.characters(char[],int,int).
Overrides:
characters in class DefaultHandler
Following copied from class: org.xml.sax.helpers.DefaultHandler
Parameters:
ch - The characters.
start - The start position in the character array.
length - The number of characters to use from the character array.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.characters(char[], int, int)

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws SAXException
SAX: Implements ContentHandler.processingInstruction(String,String).
Overrides:
processingInstruction in class DefaultHandler
Following copied from class: org.xml.sax.helpers.DefaultHandler
Parameters:
target - The processing instruction target.
data - The processing instruction data, or null if none is supplied.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.processingInstruction(java.lang.String, java.lang.String)

startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
              throws SAXException
SAX: Implements LexicalHandler.startDTD(String,String,String).
Specified by:
startDTD in interface LexicalHandler
Following copied from interface: org.xml.sax.ext.LexicalHandler
Parameters:
name - The document type name.
publicId - The declared public identifier for the external DTD subset, or null if none was declared.
systemId - The declared system identifier for the external DTD subset, or null if none was declared.
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.endDTD(), LexicalHandler.startEntity(java.lang.String)

endDTD

public void endDTD()
            throws SAXException
SAX: Implements LexicalHandler.endDTD().
Specified by:
endDTD in interface LexicalHandler
Following copied from interface: org.xml.sax.ext.LexicalHandler
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.startDTD(java.lang.String, java.lang.String, java.lang.String)

startEntity

public void startEntity(java.lang.String name)
                 throws SAXException
SAX: Implements LexicalHandler.startEntity(String).
Specified by:
startEntity in interface LexicalHandler
Following copied from interface: org.xml.sax.ext.LexicalHandler
Parameters:
name - The name of the entity. If it is a parameter entity, the name will begin with '%'.
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.endEntity(java.lang.String), DeclHandler.internalEntityDecl(java.lang.String, java.lang.String), DeclHandler.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)

endEntity

public void endEntity(java.lang.String name)
               throws SAXException
SAX: Implements LexicalHandler.endEntity(String).
Specified by:
endEntity in interface LexicalHandler
Following copied from interface: org.xml.sax.ext.LexicalHandler
Parameters:
name - The name of the entity that is ending.
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.startEntity(java.lang.String)

startCDATA

public void startCDATA()
                throws SAXException
SAX: Implements LexicalHandler.startCDATA().
Specified by:
startCDATA in interface LexicalHandler
Following copied from interface: org.xml.sax.ext.LexicalHandler
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.endCDATA()

endCDATA

public void endCDATA()
              throws SAXException
SAX: Implements LexicalHandler.endCDATA().
Specified by:
endCDATA in interface LexicalHandler
Following copied from interface: org.xml.sax.ext.LexicalHandler
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.startCDATA()

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws SAXException
SAX: Implements LexicalHandler.comment(char[],int,int).
Specified by:
comment in interface LexicalHandler
Following copied from interface: org.xml.sax.ext.LexicalHandler
Parameters:
ch - An array holding the characters in the comment.
start - The starting position in the array.
length - The number of characters to use from the array.
Throws:
SAXException - The application may raise an exception.


Copyright © 2000 Apache Software Foundation. All Rights Reserved.