Class DelegatingDocument

  • All Implemented Interfaces:
    org.w3c.dom.Document, org.w3c.dom.Node
    Direct Known Subclasses:
    VODocument

    public class DelegatingDocument
    extends DelegatingNode
    implements org.w3c.dom.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
    Author:
    Mark Taylor (Starlink)
    • Constructor Detail

      • DelegatingDocument

        public DelegatingDocument​(org.w3c.dom.Document base,
                                  java.lang.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​(java.lang.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​(org.w3c.dom.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 org.w3c.dom.Document getBaseDocument()
        Returns the base document (the one to which this delegates).
        Returns:
        base document
      • createDelegatingSimpleNode

        protected DelegatingNode createDelegatingSimpleNode​(org.w3c.dom.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​(org.w3c.dom.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​(org.w3c.dom.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​(org.w3c.dom.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​(org.w3c.dom.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​(org.w3c.dom.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​(org.w3c.dom.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​(org.w3c.dom.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​(org.w3c.dom.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​(org.w3c.dom.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​(org.w3c.dom.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​(org.w3c.dom.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​(org.w3c.dom.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​(org.w3c.dom.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 org.w3c.dom.NodeList createDelegatingNodeList​(org.w3c.dom.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 org.w3c.dom.NamedNodeMap createDelegatingNamedNodeMap​(org.w3c.dom.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 org.w3c.dom.DOMImplementation getImplementation()
        Returns the implementation of the base document.
        Specified by:
        getImplementation in interface org.w3c.dom.Document
      • getDoctype

        public org.w3c.dom.DocumentType getDoctype()
        Specified by:
        getDoctype in interface org.w3c.dom.Document
      • getDocumentElement

        public org.w3c.dom.Element getDocumentElement()
        Specified by:
        getDocumentElement in interface org.w3c.dom.Document
      • createElement

        public org.w3c.dom.Element createElement​(java.lang.String tagName)
        Specified by:
        createElement in interface org.w3c.dom.Document
      • createDocumentFragment

        public org.w3c.dom.DocumentFragment createDocumentFragment()
        Specified by:
        createDocumentFragment in interface org.w3c.dom.Document
      • createTextNode

        public org.w3c.dom.Text createTextNode​(java.lang.String data)
        Specified by:
        createTextNode in interface org.w3c.dom.Document
      • createComment

        public org.w3c.dom.Comment createComment​(java.lang.String data)
        Specified by:
        createComment in interface org.w3c.dom.Document
      • createCDATASection

        public org.w3c.dom.CDATASection createCDATASection​(java.lang.String data)
        Specified by:
        createCDATASection in interface org.w3c.dom.Document
      • createProcessingInstruction

        public org.w3c.dom.ProcessingInstruction createProcessingInstruction​(java.lang.String target,
                                                                             java.lang.String data)
        Specified by:
        createProcessingInstruction in interface org.w3c.dom.Document
      • createAttribute

        public org.w3c.dom.Attr createAttribute​(java.lang.String name)
        Specified by:
        createAttribute in interface org.w3c.dom.Document
      • createEntityReference

        public org.w3c.dom.EntityReference createEntityReference​(java.lang.String name)
        Specified by:
        createEntityReference in interface org.w3c.dom.Document
      • getElementsByTagName

        public org.w3c.dom.NodeList getElementsByTagName​(java.lang.String tagname)
        Specified by:
        getElementsByTagName in interface org.w3c.dom.Document
      • importNode

        public org.w3c.dom.Node importNode​(org.w3c.dom.Node importedNode,
                                           boolean deep)
        Specified by:
        importNode in interface org.w3c.dom.Document
      • createElementNS

        public org.w3c.dom.Element createElementNS​(java.lang.String namespaceURI,
                                                   java.lang.String qualifiedName)
        Specified by:
        createElementNS in interface org.w3c.dom.Document
      • createAttributeNS

        public org.w3c.dom.Attr createAttributeNS​(java.lang.String namespaceURI,
                                                  java.lang.String qualifiedName)
        Specified by:
        createAttributeNS in interface org.w3c.dom.Document
      • getElementsByTagNameNS

        public org.w3c.dom.NodeList getElementsByTagNameNS​(java.lang.String namespaceURI,
                                                           java.lang.String localName)
        Specified by:
        getElementsByTagNameNS in interface org.w3c.dom.Document
      • getElementById

        public org.w3c.dom.Element getElementById​(java.lang.String elementId)
        Specified by:
        getElementById in interface org.w3c.dom.Document
      • getInputEncoding

        public java.lang.String getInputEncoding()
        Specified by:
        getInputEncoding in interface org.w3c.dom.Document
      • getXmlEncoding

        public java.lang.String getXmlEncoding()
        Specified by:
        getXmlEncoding in interface org.w3c.dom.Document
      • getXmlStandalone

        public boolean getXmlStandalone()
        Specified by:
        getXmlStandalone in interface org.w3c.dom.Document
      • setXmlStandalone

        public void setXmlStandalone​(boolean xmlStandalone)
        Specified by:
        setXmlStandalone in interface org.w3c.dom.Document
      • getXmlVersion

        public java.lang.String getXmlVersion()
        Specified by:
        getXmlVersion in interface org.w3c.dom.Document
      • setXmlVersion

        public void setXmlVersion​(java.lang.String xmlVersion)
        Specified by:
        setXmlVersion in interface org.w3c.dom.Document
      • getStrictErrorChecking

        public boolean getStrictErrorChecking()
        Specified by:
        getStrictErrorChecking in interface org.w3c.dom.Document
      • setStrictErrorChecking

        public void setStrictErrorChecking​(boolean strictErrorChecking)
        Specified by:
        setStrictErrorChecking in interface org.w3c.dom.Document
      • getDocumentURI

        public java.lang.String getDocumentURI()
        Specified by:
        getDocumentURI in interface org.w3c.dom.Document
      • setDocumentURI

        public void setDocumentURI​(java.lang.String documentURI)
        Specified by:
        setDocumentURI in interface org.w3c.dom.Document
      • adoptNode

        public org.w3c.dom.Node adoptNode​(org.w3c.dom.Node source)
        Specified by:
        adoptNode in interface org.w3c.dom.Document
      • getDomConfig

        public org.w3c.dom.DOMConfiguration getDomConfig()
        Specified by:
        getDomConfig in interface org.w3c.dom.Document
      • normalizeDocument

        public void normalizeDocument()
        Specified by:
        normalizeDocument in interface org.w3c.dom.Document
      • renameNode

        public org.w3c.dom.Node renameNode​(org.w3c.dom.Node node,
                                           java.lang.String namespaceURI,
                                           java.lang.String qualifiedName)
        Specified by:
        renameNode in interface org.w3c.dom.Document