gnu.xml.dom

Class Consumer.Backdoor

Enclosing Class:
Consumer
Implemented Interfaces:
ContentHandler, DeclHandler, DTDHandler, LexicalHandler

public static class Consumer.Backdoor
extends DomConsumer.Handler

Implements the backdoors needed by DOM. All methods in this class use implementation-specific APIs that are implied by the DOM specification (needed to implement testable behavior) but which are excluded from the DOM specification.

Field Summary

Fields inherited from class gnu.xml.pipeline.DomConsumer.Handler

consumer

Constructor Summary

Backdoor(DomConsumer consumer)
Constructor.

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.
protected Text
createText(boolean isCDATA, buf[] , int off, int len)
void
elementDecl(String name, String model)
void
endDTD()
Report the end of DTD declarations.
void
endDocument()
void
endElement(String uri, String localName, String qName)
void
endEntity(String name)
Report the end of an entity.
void
externalEntityDecl(String name, String publicId, String systemId)
void
internalEntityDecl(String name, String value)
void
notationDecl(String name, String publicId, String systemId)
void
startDTD(String name, String publicId, String systemId)
Report the start of DTD declarations, if any.
void
startDocument()
void
startElement(String uri, String localName, String qName, Attributes atts)
void
startEntity(String name)
Report the beginning of some internal and external XML entities.
void
unparsedEntityDecl(String name, String publicId, String systemId, String notationName)

Methods inherited from class gnu.xml.pipeline.DomConsumer.Handler

attributeDecl, canPopulateEntityRefs, characters, comment, createText, elementDecl, endCDATA, endDTD, endDocument, endElement, endEntity, endPrefixMapping, externalEntityDecl, getDocument, getTop, ignorableWhitespace, internalEntityDecl, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDTD, startDocument, startElement, startEntity, startPrefixMapping, unparsedEntityDecl

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

Backdoor

protected Backdoor(DomConsumer consumer)
            throws SAXException
Constructor.
Parameters:
consumer - must have been initialized to use the DomDocument class (or a subclass) for constructing DOM trees

Method Details

attributeDecl

public void attributeDecl(String ename,
                          String aname,
                          String type,
                          String mode,
                          String value)
            throws SAXException
Specified by:
attributeDecl in interface DeclHandler
Overrides:
attributeDecl in interface DomConsumer.Handler

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.
Overrides:
canPopulateEntityRefs in interface DomConsumer.Handler

createText

protected Text createText(boolean isCDATA,
                          buf[] ,
                          int off,
                          int len)

elementDecl

public void elementDecl(String name,
                        String model)
            throws SAXException
Specified by:
elementDecl in interface DeclHandler
Overrides:
elementDecl in interface DomConsumer.Handler

endDTD

public void endDTD()
            throws SAXException
Report the end of DTD declarations.

This method is intended to report the end of the DOCTYPE declaration; if the document has no DOCTYPE declaration, this method will not be invoked.

Specified by:
endDTD in interface LexicalHandler
Overrides:
endDTD in interface DomConsumer.Handler
Throws:
SAXException - The application may raise an exception.

endDocument

public void endDocument()
            throws SAXException
Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in interface DomConsumer.Handler

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
            throws SAXException
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in interface DomConsumer.Handler

endEntity

public void endEntity(String name)
            throws SAXException
Report the end of an entity.
Specified by:
endEntity in interface LexicalHandler
Overrides:
endEntity in interface DomConsumer.Handler
Parameters:
name - The name of the entity that is ending.
Throws:
SAXException - The application may raise an exception.

externalEntityDecl

public void externalEntityDecl(String name,
                               String publicId,
                               String systemId)
            throws SAXException
Specified by:
externalEntityDecl in interface DeclHandler
Overrides:
externalEntityDecl in interface DomConsumer.Handler

internalEntityDecl

public void internalEntityDecl(String name,
                               String value)
            throws SAXException
Specified by:
internalEntityDecl in interface DeclHandler
Overrides:
internalEntityDecl in interface DomConsumer.Handler

notationDecl

public void notationDecl(String name,
                         String publicId,
                         String systemId)
            throws SAXException
Specified by:
notationDecl in interface DTDHandler
Overrides:
notationDecl in interface DomConsumer.Handler

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
            throws SAXException
Report the start of DTD declarations, if any.

This method is intended to report the beginning of the DOCTYPE declaration; if the document has no DOCTYPE declaration, this method will not be invoked.

All declarations reported through DTDHandler or DeclHandler events must appear between the startDTD and endDTD events. Declarations are assumed to belong to the internal DTD subset unless they appear between startEntity and endEntity events. Comments and processing instructions from the DTD should also be reported between the startDTD and endDTD events, in their original order of (logical) occurrence; they are not required to appear in their correct locations relative to DTDHandler or DeclHandler events, however.

Note that the start/endDTD events will appear within the start/endDocument events from ContentHandler and before the first startElement event.

Specified by:
startDTD in interface LexicalHandler
Overrides:
startDTD in interface DomConsumer.Handler
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. (Note that this is not resolved against the document base URI.)
Throws:
SAXException - The application may raise an exception.

startDocument

public void startDocument()
            throws SAXException
Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in interface DomConsumer.Handler

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
            throws SAXException
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in interface DomConsumer.Handler

startEntity

public void startEntity(String name)
            throws SAXException
Report the beginning of some internal and external XML entities.

The reporting of parameter entities (including the external DTD subset) is optional, and SAX2 drivers that report LexicalHandler events may not implement it; you can use the http://xml.org/sax/features/lexical-handler/parameter-entities feature to query or control the reporting of parameter entities.

General entities are reported with their regular names, parameter entities have '%' prepended to their names, and the external DTD subset has the pseudo-entity name "[dtd]".

When a SAX2 driver is providing these events, all other events must be properly nested within start/end entity events. There is no additional requirement that events from DeclHandler or DTDHandler be properly ordered.

Note that skipped entities will be reported through the skippedEntity event, which is part of the ContentHandler interface.

Because of the streaming event model that SAX uses, some entity boundaries cannot be reported under any circumstances:

  • general entities within attribute values
  • parameter entities within declarations

These will be silently expanded, with no indication of where the original entity boundaries were.

Note also that the boundaries of character references (which are not really entities anyway) are not reported.

All start/endEntity events must be properly nested.

Specified by:
startEntity in interface LexicalHandler
Overrides:
startEntity in interface DomConsumer.Handler
Parameters:
name - The name of the entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be "[dtd]".
Throws:
SAXException - The application may raise an exception.

unparsedEntityDecl

public void unparsedEntityDecl(String name,
                               String publicId,
                               String systemId,
                               String notationName)
            throws SAXException
Specified by:
unparsedEntityDecl in interface DTDHandler
Overrides:
unparsedEntityDecl in interface DomConsumer.Handler

Consumer.java -- Copyright (C) 2001,2004 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.