uk.ac.starlink.votable.dom
Class DelegatingDocument

java.lang.Object
  |
  +--uk.ac.starlink.votable.dom.DelegatingNode
        |
        +--uk.ac.starlink.votable.dom.DelegatingDocument
All Implemented Interfaces:
Document, Node
Direct Known Subclasses:
VODocument

public class DelegatingDocument
extends DelegatingNode
implements Document

DOM Document implementation which delegates its operations to a base Document instance. This is the basic class which must be used and extended when using the delegate DOM package.

In order to specialise the nodes which appear in a DOM, you have to override the protected createDelegating* methods to return your own custom DelegatingNode subclasses.

Since:
14 Sep 2004

Field Summary
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
DelegatingDocument(Document base, String documentURI)
          Constructs a new document which delegates its behaviour to a Document from another DOM.
DelegatingDocument(String documentURI)
          Constructs a new empty document based on a new empty document got from the default DOM implementation.
 
Method Summary
 Attr createAttribute(String name)
           
 Attr createAttributeNS(String namespaceURI, String qualifiedName)
           
 CDATASection createCDATASection(String data)
           
 Comment createComment(String data)
           
protected  DelegatingAttr createDelegatingAttr(Attr baseNode)
          Creates a new node in this document that delegates to an object of class Attr in the base model.
protected  DelegatingAttr createDelegatingAttr(Attr baseNode, boolean isId)
          Creates a new node in this document that delegates to an object of class Attr and knows whether it is an ID-type attribute or not.
protected  DelegatingCDATASection createDelegatingCDATASection(CDATASection baseNode)
          Creates a new node in this document that delegates to an object of class CDATASection in the base model.
protected  DelegatingCharacterData createDelegatingCharacterData(CharacterData baseNode)
          Creates a new node in this document that delegates to an object of class CharacterData (not one of its subclasses) in the base model.
protected  DelegatingComment createDelegatingComment(Comment baseNode)
          Creates a new node in this document that delegates to an object of class Comment in the base model.
protected  DelegatingDocumentFragment createDelegatingDocumentFragment(DocumentFragment baseNode)
          Creates a new node in this document that delegates to an object of class DocumentFragment in the base model.
protected  DelegatingDocumentType createDelegatingDocumentType(DocumentType baseNode)
          Creates a new node in this document that delegates to an object of class DocumentType in the base model.
protected  DelegatingElement createDelegatingElement(Element baseNode)
          Creates a new node in this document that delegates to an object of class Element in the base model.
protected  DelegatingEntity createDelegatingEntity(Entity baseNode)
          Creates a new node in this document that delegates to an object of class Entity in the base model.
protected  DelegatingEntityReference createDelegatingEntityReference(EntityReference baseNode)
          Creates a new node in this document that delegates to an object of class EntityReference in the base model.
protected  NamedNodeMap createDelegatingNamedNodeMap(NamedNodeMap baseMap)
          Returns a NamedNodeMap which will dispense nodes in this document.
protected  NodeList createDelegatingNodeList(NodeList baseList)
          Returns a NodeList which will dispense nodes in this document.
protected  DelegatingNotation createDelegatingNotation(Notation baseNode)
          Creates a new node in this document that delegates to an object of class Notation in the base model.
protected  DelegatingProcessingInstruction createDelegatingProcessingInstruction(ProcessingInstruction baseNode)
          Creates a new node in this document that delegates to an object of class ProcessingInstruction in the base model.
protected  DelegatingNode createDelegatingSimpleNode(Node baseNode)
          Creates a new node in this document that delegates to an object of class Node (not one of its subclasses) in the base model.
protected  DelegatingText createDelegatingText(Text baseNode)
          Creates a new node in this document that delegates to an object of class Text (not one of its subclasses) in the base model.
 DocumentFragment createDocumentFragment()
           
 Element createElement(String tagName)
           
 Element createElementNS(String namespaceURI, String qualifiedName)
           
 EntityReference createEntityReference(String name)
           
 ProcessingInstruction createProcessingInstruction(String target, String data)
           
 Text createTextNode(String data)
           
protected  Document getBaseDocument()
          Returns the base document (the one to which this delegates).
protected  DelegatingNode getDelegator(Node baseNode)
          Returns the node in this document which delegates to (is based on) a given node in the base document.
 DocumentType getDoctype()
           
 Element getDocumentElement()
           
 Element getElementById(String elementId)
           
 NodeList getElementsByTagName(String tagname)
           
 NodeList getElementsByTagNameNS(String namespaceURI, String localName)
           
 DOMImplementation getImplementation()
          Returns the implementation of the base document.
 Node importNode(Node importedNode, boolean deep)
           
 
Methods inherited from class uk.ac.starlink.votable.dom.DelegatingNode
appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Constructor Detail

DelegatingDocument

public DelegatingDocument(Document base,
                          String documentURI)
Constructs a new document which delegates its behaviour to a Document from another DOM.

Parameters:
base - delegate document node
documentURI - location of the document, or null

DelegatingDocument

public DelegatingDocument(String documentURI)
Constructs a new empty document based on a new empty document got from the default DOM implementation. This can theoretically result in a ParserConfigurationException, but shouldn't do for any sensibly set up JVM - any such condition is rethrown as a RuntimeException.

Parameters:
documentURI - location of the document, or null
Method Detail

getDelegator

protected DelegatingNode getDelegator(Node baseNode)
Returns the node in this document which delegates to (is based on) a given node in the base document. If this node has not previously been encountered, it will be created here.

Parameters:
baseNode - node in the base document
Returns:
corresponding node in this document

getBaseDocument

protected Document getBaseDocument()
Returns the base document (the one to which this delegates).

Returns:
base document

createDelegatingSimpleNode

protected DelegatingNode createDelegatingSimpleNode(Node baseNode)
Creates a new node in this document that delegates to an object of class Node (not one of its subclasses) in the base model. This may be overridden to create specialised node types.

Parameters:
baseNode - delegate node
Returns:
new node in this model based on baseNode

createDelegatingAttr

protected DelegatingAttr createDelegatingAttr(Attr baseNode)
Creates a new node in this document that delegates to an object of class Attr in the base model. This may be overridden to create specialised node types.

Parameters:
baseNode - delegate node
Returns:
new node in this model based on baseNode

createDelegatingAttr

protected DelegatingAttr createDelegatingAttr(Attr baseNode,
                                              boolean isId)
Creates a new node in this document that delegates to an object of class Attr and knows whether it is an ID-type attribute or not. This is not called by any method of this class, but can be used by subclass implementations of createDelegatingAttr(org.w3c.dom.Attr).

Parameters:
baseNode - delegate node
isId - true if this node knows it is an ID, false if it knows it isn't
Returns:
new node in this model based on baseNode

createDelegatingCDATASection

protected DelegatingCDATASection createDelegatingCDATASection(CDATASection baseNode)
Creates a new node in this document that delegates to an object of class CDATASection in the base model. This may be overridden to create specialised node types.

Parameters:
baseNode - delegate node
Returns:
new node in this model based on baseNode

createDelegatingCharacterData

protected DelegatingCharacterData createDelegatingCharacterData(CharacterData baseNode)
Creates a new node in this document that delegates to an object of class CharacterData (not one of its subclasses) in the base model. This may be overridden to create specialised node types.

Parameters:
baseNode - delegate node
Returns:
new node in this model based on baseNode

createDelegatingComment

protected DelegatingComment createDelegatingComment(Comment baseNode)
Creates a new node in this document that delegates to an object of class Comment in the base model. This may be overridden to create specialised node types.

Parameters:
baseNode - delegate node
Returns:
new node in this model based on baseNode

createDelegatingDocumentFragment

protected DelegatingDocumentFragment createDelegatingDocumentFragment(DocumentFragment baseNode)
Creates a new node in this document that delegates to an object of class DocumentFragment in the base model. This may be overridden to create specialised node types.

Parameters:
baseNode - delegate node
Returns:
new node in this model based on baseNode

createDelegatingDocumentType

protected DelegatingDocumentType createDelegatingDocumentType(DocumentType baseNode)
Creates a new node in this document that delegates to an object of class DocumentType in the base model. This may be overridden to create specialised node types.

Parameters:
baseNode - delegate node
Returns:
new node in this model based on baseNode

createDelegatingElement

protected DelegatingElement createDelegatingElement(Element baseNode)
Creates a new node in this document that delegates to an object of class Element in the base model. This may be overridden to create specialised node types.

Parameters:
baseNode - delegate node
Returns:
new node in this model based on baseNode

createDelegatingEntity

protected DelegatingEntity createDelegatingEntity(Entity baseNode)
Creates a new node in this document that delegates to an object of class Entity in the base model. This may be overridden to create specialised node types.

Parameters:
baseNode - delegate node
Returns:
new node in this model based on baseNode

createDelegatingEntityReference

protected DelegatingEntityReference createDelegatingEntityReference(EntityReference baseNode)
Creates a new node in this document that delegates to an object of class EntityReference in the base model. This may be overridden to create specialised node types.

Parameters:
baseNode - delegate node
Returns:
new node in this model based on baseNode

createDelegatingNotation

protected DelegatingNotation createDelegatingNotation(Notation baseNode)
Creates a new node in this document that delegates to an object of class Notation in the base model. This may be overridden to create specialised node types.

Parameters:
baseNode - delegate node
Returns:
new node in this model based on baseNode

createDelegatingProcessingInstruction

protected DelegatingProcessingInstruction createDelegatingProcessingInstruction(ProcessingInstruction baseNode)
Creates a new node in this document that delegates to an object of class ProcessingInstruction in the base model. This may be overridden to create specialised node types.

Parameters:
baseNode - delegate node
Returns:
new node in this model based on baseNode

createDelegatingText

protected DelegatingText createDelegatingText(Text baseNode)
Creates a new node in this document that delegates to an object of class Text (not one of its subclasses) in the base model. This may be overridden to create specialised node types.

Parameters:
baseNode - delegate node
Returns:
new node in this model based on baseNode

createDelegatingNodeList

protected NodeList createDelegatingNodeList(NodeList baseList)
Returns a NodeList which will dispense nodes in this document.

Parameters:
baseList - node list which dispenses nodes in the base document
Returns:
equivalent of baseList in this document

createDelegatingNamedNodeMap

protected NamedNodeMap createDelegatingNamedNodeMap(NamedNodeMap baseMap)
Returns a NamedNodeMap which will dispense nodes in this document.

Parameters:
baseMap - node map which dispenses nodes in the base document
Returns:
equivalent of baseMap in this document

getImplementation

public DOMImplementation getImplementation()
Returns the implementation of the base document.

Specified by:
getImplementation in interface Document

getDoctype

public DocumentType getDoctype()
Specified by:
getDoctype in interface Document

getDocumentElement

public Element getDocumentElement()
Specified by:
getDocumentElement in interface Document

createElement

public Element createElement(String tagName)
Specified by:
createElement in interface Document

createDocumentFragment

public DocumentFragment createDocumentFragment()
Specified by:
createDocumentFragment in interface Document

createTextNode

public Text createTextNode(String data)
Specified by:
createTextNode in interface Document

createComment

public Comment createComment(String data)
Specified by:
createComment in interface Document

createCDATASection

public CDATASection createCDATASection(String data)
Specified by:
createCDATASection in interface Document

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(String target,
                                                         String data)
Specified by:
createProcessingInstruction in interface Document

createAttribute

public Attr createAttribute(String name)
Specified by:
createAttribute in interface Document

createEntityReference

public EntityReference createEntityReference(String name)
Specified by:
createEntityReference in interface Document

getElementsByTagName

public NodeList getElementsByTagName(String tagname)
Specified by:
getElementsByTagName in interface Document

importNode

public Node importNode(Node importedNode,
                       boolean deep)
Specified by:
importNode in interface Document

createElementNS

public Element createElementNS(String namespaceURI,
                               String qualifiedName)
Specified by:
createElementNS in interface Document

createAttributeNS

public Attr createAttributeNS(String namespaceURI,
                              String qualifiedName)
Specified by:
createAttributeNS in interface Document

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(String namespaceURI,
                                       String localName)
Specified by:
getElementsByTagNameNS in interface Document

getElementById

public Element getElementById(String elementId)
Specified by:
getElementById in interface Document

Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.