Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.batik.dom.util
Class SAXDocumentFactory

    java.lang.Object
      org.xml.sax.helpers.DefaultHandler
          org.apache.batik.dom.util.SAXDocumentFactory

All Implemented Interfaces:
  DocumentFactory, ContentHandler, DTDHandler, EntityResolver, ErrorHandler, LexicalHandler

Direct Known Subclasses:
  SAXSVGDocumentFactory

    public class SAXDocumentFactory

extends DefaultHandler
implements LexicalHandler, DocumentFactory

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

Nested Class Summary
`protected static interface` | `SAXDocumentFactory.PreInfo`

Field Summary
`protected boolean` | `createDocumentDescriptor` Whether a document descriptor must be generated.
`protected Node` | `currentNode` The current node.
`protected Document` | `document` The created document.
`protected DocumentDescriptor` | `documentDescriptor` The created document descriptor.
`protected ErrorHandler` | `errorHandler` The error handler.
`protected DOMImplementation` | `implementation` The DOM implementation used to create the document.
`protected boolean` | `inCDATA` True if the parser is currently parsing a CDATA section.
`protected boolean` | `inDTD` True if the parser is currently parsing a DTD.
`protected boolean` | `inProlog` Whether the parser still hasn't read the document element's opening tag.
`protected boolean` | `isStandalone` Whether the document just parsed was standalone.
`protected boolean` | `isValidating` Whether the parser is in validating mode.
`protected Locator` | `locator` The locator.
`protected HashTableStack` | `namespaces` The stack used to store the namespace URIs.
`protected XMLReader` | `parser` The SAX2 parser object.
`protected String` | `parserClassName` The SAX2 parser classname.
`protected List` | `preInfo` Various elements encountered prior to real document root element.
`protected StringBuffer` | `stringBuffer` Contains collected string data.
`protected boolean` | `stringContent` Indicates if stringBuffer has content, needed in case of zero sized "text" content.
`protected String` | `xmlVersion` XML version of the document just parsed.

Constructor Summary
`SAXDocumentFactory(DOMImplementation impl, String parser)` Creates a new SAXDocumentFactory object.
`SAXDocumentFactory(DOMImplementation impl, String parser, boolean dd)` Creates a new SAXDocumentFactory object.

Method Summary
`void` | `appendStringData()`
`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)`.
`protected Document` | `createDocument(InputSource is)` Creates a Document.
`Document` | `createDocument(String uri)` Creates a Document instance.
`Document` | `createDocument(String uri, InputStream is)` Creates a Document instance.
`Document` | `createDocument(String uri, Reader r)` Creates a Document instance.
`Document` | `createDocument(String ns, String root, String uri)` Creates a Document instance.
`protected Document` | `createDocument(String ns, String root, String uri, InputSource is)` Creates a Document.
`Document` | `createDocument(String ns, String root, String uri, InputStream is)` Creates a Document instance.
`Document` | `createDocument(String ns, String root, String uri, Reader r)` Creates a Document instance.
`Document` | `createDocument(String ns, String root, String uri, XMLReader r)` Creates a Document instance.
`void` | `endCDATA()` SAX: Implements `LexicalHandler.endCDATA()`.
`void` | `endDTD()` SAX: Implements `LexicalHandler.endDTD()`.
`void` | `endElement(String uri, String localName, String rawName)` SAX: Implements `ContentHandler.endElement(String,String,String)`.
`void` | `endEntity(String name)` SAX: Implements `LexicalHandler.endEntity(String)`.
`void` | `error(SAXParseException ex)` SAX: Implements `ErrorHandler.error(SAXParseException)`.
`void` | `fatalError(SAXParseException ex)` SAX: Implements `ErrorHandler.fatalError(SAXParseException)`.
`DocumentDescriptor` | `getDocumentDescriptor()` Returns the document descriptor associated with the latest created document.
`DOMImplementation` | `getDOMImplementation(String ver)`
`void` | `ignorableWhitespace(char[] ch, int start, int length)` SAX: Implements `ContentHandler.ignorableWhitespace(char[],int,int)`.
`boolean` | `isValidating()` Returns true if the XML parser validates the XML stream, false otherwise.
`void` | `processingInstruction(String target, String data)` SAX: Implements `ContentHandler.processingInstruction(String,String)`.
`void` | `setDocumentLocator(Locator l)` SAX: Implements `ContentHandler.setDocumentLocator(Locator)`.
`void` | `setErrorHandler(ErrorHandler eh)` Sets a custom error handler.
`void` | `setValidating(boolean isValidating)` Sets whether or not the XML parser will validate the XML document depending on the specified parameter.
`void` | `startCDATA()` SAX: Implements `LexicalHandler.startCDATA()`.
`void` | `startDocument()` SAX: Implements `ContentHandler.startDocument()`.
`void` | `startDTD(String name, String publicId, String systemId)` SAX: Implements `LexicalHandler.startDTD(String,String,String)`.
`void` | `startElement(String uri, String localName, String rawName, Attributes attributes)` SAX: Implements `ContentHandler.startElement(String,String,String,Attributes)`.
`void` | `startEntity(String name)` SAX: Implements `LexicalHandler.startEntity(String)`.
`void` | `warning(SAXParseException ex)` SAX: Implements `ErrorHandler.warning(SAXParseException)`.

Methods inherited from class org.xml.sax.helpers.DefaultHandler
`endDocument, endPrefixMapping, notationDecl, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl`

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 String parserClassName

  The SAX2 parser classname.

### parser

    protected XMLReader parser

  The SAX2 parser object.

### document

    protected Document document

  The created document.

### documentDescriptor

    protected DocumentDescriptor documentDescriptor

  The created document descriptor.

### createDocumentDescriptor

    protected boolean createDocumentDescriptor

  Whether a document descriptor must be generated.

### currentNode

    protected Node currentNode

  The current node.

### locator

    protected Locator locator

  The locator.

### stringBuffer

    protected StringBuffer stringBuffer

  Contains collected string data. May be Text, CDATA or Comment.

### stringContent

    protected boolean stringContent

  Indicates if stringBuffer has content, needed in case of zero sized "text" content.

### inDTD

    protected boolean inDTD

  True if the parser is currently parsing a DTD.

### inCDATA

    protected boolean inCDATA

  True if the parser is currently parsing a CDATA section.

### inProlog

    protected boolean inProlog

  Whether the parser still hasn't read the document element's opening tag.

### isValidating

    protected boolean isValidating

  Whether the parser is in validating mode.

### isStandalone

    protected boolean isStandalone

  Whether the document just parsed was standalone.

### xmlVersion

    protected String xmlVersion

  XML version of the document just parsed.

### namespaces

    protected HashTableStack namespaces

  The stack used to store the namespace URIs.

### errorHandler

    protected ErrorHandler errorHandler

  The error handler.

### preInfo

    protected List preInfo

  Various elements encountered prior to real document root element. List of PreInfo objects.

Constructor Detail

### SAXDocumentFactory

    public SAXDocumentFactory(DOMImplementation impl,
                              String parser)

  Creates a new SAXDocumentFactory object. No document descriptor will be created while generating a document.

  Parameters:
    `impl` - The DOM implementation to use for building the DOM tree.
    `parser` - The SAX2 parser classname.

### SAXDocumentFactory

    public SAXDocumentFactory(DOMImplementation impl,
                              String parser,
                              boolean dd)

  Creates a new SAXDocumentFactory object.

  Parameters:
    `impl` - The DOM implementation to use for building the DOM tree.
    `parser` - The SAX2 parser classname.
    `dd` - Whether a document descriptor must be generated.

Method Detail

### createDocument

    public Document createDocument(String ns,
                                   String root,
                                   String uri)
                            throws IOException

  Creates a Document instance.

  Specified by:
    `createDocument` in interface `DocumentFactory`
  Parameters:
    `ns` - The namespace URI of the root element of the document.
    `root` - The name of the root element of the document.
    `uri` - The document URI.
  Throws:
    `IOException` - if an error occured while reading the document.

### createDocument

    public Document createDocument(String uri)
                            throws IOException

  Creates a Document instance.

  Parameters:
    `uri` - The document URI.
  Throws:
    `IOException` - if an error occured while reading the document.

### createDocument

    public Document createDocument(String ns,
                                   String root,
                                   String uri,
                                   InputStream is)
                            throws IOException

  Creates a Document instance.

  Specified by:
    `createDocument` in interface `DocumentFactory`
  Parameters:
    `ns` - The namespace URI of the root element of the document.
    `root` - The name of the root element of the document.
    `uri` - The document URI.
    `is` - The document input stream.
  Throws:
    `IOException` - if an error occured while reading the document.

### createDocument

    public Document createDocument(String uri,
                                   InputStream is)
                            throws IOException

  Creates a Document instance.

  Parameters:
    `uri` - The document URI.
    `is` - The document input stream.
  Throws:
    `IOException` - if an error occured while reading the document.

### createDocument

    public Document createDocument(String ns,
                                   String root,
                                   String uri,
                                   Reader r)
                            throws IOException

  Creates a Document instance.

  Specified by:
    `createDocument` in interface `DocumentFactory`
  Parameters:
    `ns` - The namespace URI of the root element of the document.
    `root` - The name of the root element of the document.
    `uri` - The document URI.
    `r` - The document reader.
  Throws:
    `IOException` - if an error occured while reading the document.

### createDocument

    public Document createDocument(String ns,
                                   String root,
                                   String uri,
                                   XMLReader r)
                            throws IOException

  Creates a Document instance.

  Specified by:
    `createDocument` in interface `DocumentFactory`
  Parameters:
    `ns` - The namespace URI of the root element of the document.
    `root` - The name of the root element of the document.
    `uri` - The document URI.
    `r` - an XMLReaderInstance
  Throws:
    `IOException` - if an error occured while reading the document.

### createDocument

    public Document createDocument(String uri,
                                   Reader r)
                            throws IOException

  Creates a Document instance.

  Parameters:
    `uri` - The document URI.
    `r` - The document reader.
  Throws:
    `IOException` - if an error occured while reading the document.

### createDocument

    protected Document createDocument(String ns,
                                      String root,
                                      String uri,
                                      InputSource is)
                               throws IOException

  Creates a Document.

  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:
    `IOException` - if an error occured while reading the document.

### createDocument

    protected Document createDocument(InputSource is)
                               throws IOException

  Creates a Document.

  Parameters:
    `is` - The document input source.
  Throws:
    `IOException` - if an error occured while reading the document.

### getDocumentDescriptor

    public DocumentDescriptor getDocumentDescriptor()

  Returns the document descriptor associated with the latest created document.

  Specified by:
    `getDocumentDescriptor` in interface `DocumentFactory`
  Returns:
    null if no document or descriptor was previously generated.

### setDocumentLocator

    public void setDocumentLocator(Locator l)

  SAX: Implements `ContentHandler.setDocumentLocator(Locator)`.

  Specified by:
    `setDocumentLocator` in interface `ContentHandler`
  Overrides:
    `setDocumentLocator` in class `DefaultHandler`

### setValidating

    public void setValidating(boolean isValidating)

  Sets whether or not the XML parser will validate the XML document depending on the specified parameter.

  Specified by:
    `setValidating` in interface `DocumentFactory`
  Parameters:
    `isValidating` - indicates that the XML parser will validate the XML document

### isValidating

    public boolean isValidating()

  Returns true if the XML parser validates the XML stream, false otherwise.

  Specified by:
    `isValidating` in interface `DocumentFactory`

### setErrorHandler

    public void setErrorHandler(ErrorHandler eh)

  Sets a custom error handler.

### getDOMImplementation

    public DOMImplementation getDOMImplementation(String ver)

### fatalError

    public void fatalError(SAXParseException ex)
                    throws SAXException

  SAX: Implements `ErrorHandler.fatalError(SAXParseException)`.

  Specified by:
    `fatalError` in interface `ErrorHandler`
  Overrides:
    `fatalError` in class `DefaultHandler`
  Throws:
    `SAXException`

### error

    public void error(SAXParseException ex)
               throws SAXException

  SAX: Implements `ErrorHandler.error(SAXParseException)`.

  Specified by:
    `error` in interface `ErrorHandler`
  Overrides:
    `error` in class `DefaultHandler`
  Throws:
    `SAXException`

### warning

    public void warning(SAXParseException ex)
                 throws SAXException

  SAX: Implements `ErrorHandler.warning(SAXParseException)`.

  Specified by:
    `warning` in interface `ErrorHandler`
  Overrides:
    `warning` in class `DefaultHandler`
  Throws:
    `SAXException`

### startDocument

    public void startDocument()
                       throws SAXException

  SAX: Implements `ContentHandler.startDocument()`.

  Specified by:
    `startDocument` in interface `ContentHandler`
  Overrides:
    `startDocument` in class `DefaultHandler`
  Throws:
    `SAXException`

### startElement

    public void startElement(String uri,
                             String localName,
                             String rawName,
                             Attributes attributes)
                      throws SAXException

  SAX: Implements `ContentHandler.startElement(String,String,String,Attributes)`.

  Specified by:
    `startElement` in interface `ContentHandler`
  Overrides:
    `startElement` in class `DefaultHandler`
  Throws:
    `SAXException`

### endElement

    public void endElement(String uri,
                           String localName,
                           String rawName)
                    throws SAXException

  SAX: Implements `ContentHandler.endElement(String,String,String)`.

  Specified by:
    `endElement` in interface `ContentHandler`
  Overrides:
    `endElement` in class `DefaultHandler`
  Throws:
    `SAXException`

### appendStringData

    public void appendStringData()

### characters

    public void characters(char[] ch,
                           int start,
                           int length)
                    throws SAXException

  SAX: Implements `ContentHandler.characters(char[],int,int)`.

  Specified by:
    `characters` in interface `ContentHandler`
  Overrides:
    `characters` in class `DefaultHandler`
  Throws:
    `SAXException`

### ignorableWhitespace

    public void ignorableWhitespace(char[] ch,
                                    int start,
                                    int length)
                             throws SAXException

  SAX: Implements `ContentHandler.ignorableWhitespace(char[],int,int)`.

  Specified by:
    `ignorableWhitespace` in interface `ContentHandler`
  Overrides:
    `ignorableWhitespace` in class `DefaultHandler`
  Throws:
    `SAXException`

### processingInstruction

    public void processingInstruction(String target,
                                      String data)
                               throws SAXException

  SAX: Implements `ContentHandler.processingInstruction(String,String)`.

  Specified by:
    `processingInstruction` in interface `ContentHandler`
  Overrides:
    `processingInstruction` in class `DefaultHandler`
  Throws:
    `SAXException`

### startDTD

    public void startDTD(String name,
                         String publicId,
                         String systemId)
                  throws SAXException

  SAX: Implements `LexicalHandler.startDTD(String,String,String)`.

  Specified by:
    `startDTD` in interface `LexicalHandler`
  Throws:
    `SAXException`

### endDTD

    public void endDTD()
                throws SAXException

  SAX: Implements `LexicalHandler.endDTD()`.

  Specified by:
    `endDTD` in interface `LexicalHandler`
  Throws:
    `SAXException`

### startEntity

    public void startEntity(String name)
                     throws SAXException

  SAX: Implements `LexicalHandler.startEntity(String)`.

  Specified by:
    `startEntity` in interface `LexicalHandler`
  Throws:
    `SAXException`

### endEntity

    public void endEntity(String name)
                   throws SAXException

  SAX: Implements `LexicalHandler.endEntity(String)`.

  Specified by:
    `endEntity` in interface `LexicalHandler`
  Throws:
    `SAXException`

### startCDATA

    public void startCDATA()
                    throws SAXException

  SAX: Implements `LexicalHandler.startCDATA()`.

  Specified by:
    `startCDATA` in interface `LexicalHandler`
  Throws:
    `SAXException`

### endCDATA

    public void endCDATA()
                  throws SAXException

  SAX: Implements `LexicalHandler.endCDATA()`.

  Specified by:
    `endCDATA` in interface `LexicalHandler`
  Throws:
    `SAXException`

### 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`
  Throws:
    `SAXException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008 Apache Software Foundation. All Rights Reserved.