gnu.xml.pipeline

Class DomConsumer.Handler

Enclosing Class:
DomConsumer
Implemented Interfaces:
ContentHandler, DeclHandler, DTDHandler, LexicalHandler
Known Direct Subclasses:
Consumer.Backdoor

public static class DomConsumer.Handler
extends Object
implements ContentHandler, LexicalHandler, DTDHandler, DeclHandler

Class used to intercept various parsing events and use them to populate a DOM document. Subclasses would typically know and use backdoors into specific DOM implementations, used to implement DTD-related functionality.

Note that if this ever throws a DOMException (runtime exception) that will indicate a bug in the DOM (e.g. doesn't support something per specification) or the parser (e.g. emitted an illegal name, or accepted illegal input data).

Field Summary

protected DomConsumer
consumer

Constructor Summary

Handler(DomConsumer consumer)
Subclasses may use SAX2 events to provide additional behaviors in the resulting DOM.

Method Summary

void
attributeDecl(String eName, String aName, String type, String mode, String value)
boolean
canPopulateEntityRefs()
May be overridden by subclasses to return true, indicating that entity reference nodes can be populated and then made read-only.
void
characters(ch[] , int start, int length)
void
comment(ch[] , int start, int length)
protected Text
createText(boolean isCDATA, ch[] , int start, int length)
Subclasses may overrride this method to provide a more efficient way to construct text nodes.
void
elementDecl(String name, String model)
void
endCDATA()
void
endDTD()
void
endDocument()
void
endElement(String uri, String localName, String qName)
void
endEntity(String name)
void
endPrefixMapping(String prefix)
void
externalEntityDecl(String name, String publicId, String SystemId)
protected Document
getDocument()
Returns the document under construction.
protected Node
getTop()
Returns the current node being populated.
void
ignorableWhitespace(ch[] , int start, int length)
void
internalEntityDecl(String name, String value)
void
notationDecl(String name, String publicId, String SystemId)
void
processingInstruction(String target, String data)
void
setDocumentLocator(Locator locator)
void
skippedEntity(String name)
void
startCDATA()
void
startDTD(String name, String publicId, String SystemId)
void
startDocument()
void
startElement(String uri, String localName, String qName, Attributes atts)
void
startEntity(String name)
void
startPrefixMapping(String prefix, String uri)
void
unparsedEntityDecl(String name, String publicId, String SystemId, String notationName)

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

consumer

protected DomConsumer consumer

Constructor Details

Handler

protected Handler(DomConsumer consumer)
            throws SAXException
Subclasses may use SAX2 events to provide additional behaviors in the resulting DOM.

Method Details

attributeDecl

public void attributeDecl(String eName,
                          String aName,
                          String type,
                          String mode,
                          String value)
            throws SAXException

canPopulateEntityRefs

public boolean canPopulateEntityRefs()
May be overridden by subclasses to return true, indicating that entity reference nodes can be populated and then made read-only.

characters

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

comment

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

createText

protected Text createText(boolean isCDATA,
                          ch[] ,
                          int start,
                          int length)
Subclasses may overrride this method to provide a more efficient way to construct text nodes. Typically, copying the text into a single character array will be more efficient than doing that as well as allocating other needed for a String, including an internal StringBuffer. Those additional memory and CPU costs can be incurred later, if ever needed. Unfortunately the standard DOM factory APIs encourage those costs to be incurred early.

elementDecl

public void elementDecl(String name,
                        String model)
            throws SAXException

endCDATA

public void endCDATA()
            throws SAXException

endDTD

public void endDTD()
            throws SAXException

endDocument

public void endDocument()
            throws SAXException

endElement

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

endEntity

public void endEntity(String name)
            throws SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
            throws SAXException

externalEntityDecl

public void externalEntityDecl(String name,
                               String publicId,
                               String SystemId)
            throws SAXException

getDocument

protected Document getDocument()
Returns the document under construction.

getTop

protected Node getTop()
Returns the current node being populated. This is usually an Element or Document, but it might be an EntityReference node if some implementation-specific code knows how to put those into the result tree and later mark them as readonly.

ignorableWhitespace

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

internalEntityDecl

public void internalEntityDecl(String name,
                               String value)
            throws SAXException

notationDecl

public void notationDecl(String name,
                         String publicId,
                         String SystemId)
            throws SAXException

processingInstruction

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

setDocumentLocator

public void setDocumentLocator(Locator locator)

skippedEntity

public void skippedEntity(String name)
            throws SAXException

startCDATA

public void startCDATA()
            throws SAXException

startDTD

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

startDocument

public void startDocument()
            throws SAXException

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
            throws SAXException

startEntity

public void startEntity(String name)
            throws SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
            throws SAXException

unparsedEntityDecl

public void unparsedEntityDecl(String name,
                               String publicId,
                               String SystemId,
                               String notationName)
            throws SAXException

DomConsumer.java -- Copyright (C) 1999,2000,2001 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.