All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.enhydra.xml.xmlc.dom.generic.GenericLinkedDocument Maven / Gradle / Ivy

The newest version!
package org.enhydra.xml.xmlc.dom.generic;

import org.enhydra.xml.dom.DOMOps;
import org.enhydra.xml.xmlc.XMLObject;
import org.enhydra.xml.xmlc.XMLObjectLink;
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Comment;
import org.w3c.dom.DOMConfiguration;
import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.w3c.dom.EntityReference;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.ProcessingInstruction;
import org.w3c.dom.Text;
import org.w3c.dom.UserDataHandler;

/**
 * This is a generic wrapper around {@link Document} that adds {@link
 * XMLObjectLink} functionality.
 */
public class GenericLinkedDocument implements Document, XMLObjectLink {
    /** Delegate document */
    protected final Document DELEGATE;

    /** The {@link XMLObject instance} */
    private XMLObject objectLink;

    /**
     * Constructor.
     * @param inner the document to be wrapped.
     */
    public GenericLinkedDocument(Document inner) {
        DELEGATE = inner;
    }
    
    /**
     * @see XMLObjectLink#setXMLObject
     */
    public void setXMLObject(XMLObject xmlObject) {
        objectLink = xmlObject;
    }

    /**
     * @see XMLObjectLink#getXMLObject
     */
    public XMLObject getXMLObject() {
        return objectLink;
    }

    /** @see Node#cloneNode */
    public Node cloneNode(boolean deep) {
	// Make sure the cloned document is an object link as well,
	// and points back to the same object...
	GenericLinkedDocument clone =
	    new GenericLinkedDocument((Document)DELEGATE.cloneNode(deep));
	clone.setXMLObject(getXMLObject());
	return clone;
    }

    // Everything below here simply passes all calls through to the
    // wrapped object...

    // DOM Level 2, org.w3c.dom.Document
    public DocumentType getDoctype() {
        return DELEGATE.getDoctype();
    }
    public DOMImplementation getImplementation() {
        return DELEGATE.getImplementation();
    }
    public Element getDocumentElement() {
        return DELEGATE.getDocumentElement();
    }
    public Element createElement(String tagName) throws DOMException {
        return DELEGATE.createElement(tagName);
    }
    public DocumentFragment createDocumentFragment() {
        return DELEGATE.createDocumentFragment();
    }
    public Text createTextNode(String data) {
        return DELEGATE.createTextNode(data);
    }
    public Comment createComment(String data) {
        return DELEGATE.createComment(data);
    }
    public CDATASection createCDATASection(String data) throws DOMException {
        return DELEGATE.createCDATASection(data);
    }
    public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException {
        return DELEGATE.createProcessingInstruction(target, data);
    }
    public Attr createAttribute(String name) throws DOMException {
        return DELEGATE.createAttribute(name);
    }
    public EntityReference createEntityReference(String name) throws DOMException {
        return DELEGATE.createEntityReference(name);
    }
    public NodeList getElementsByTagName(String tagname) {
        return DELEGATE.getElementsByTagName(tagname);
    }
    public Node importNode(Node importedNode, boolean deep) throws DOMException {
        return DELEGATE.importNode(importedNode, deep);
    }
    public Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException {
        return DELEGATE.createElementNS(namespaceURI, qualifiedName);
    }
    public Attr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException {
        return DELEGATE.createAttributeNS(namespaceURI, qualifiedName);
    }
    public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
        return DELEGATE.getElementsByTagNameNS(namespaceURI, localName);
    }
    public Element getElementById(String elementId) {
        return DELEGATE.getElementById(elementId);
    }
    
    // org.w3c.dom.Node
    
    public String getNodeName() {
        return DELEGATE.getNodeName();
    }
    public String getNodeValue() throws DOMException {
        return DELEGATE.getNodeValue();
    }
    public void setNodeValue(String nodeValue) throws DOMException {
        DELEGATE.setNodeValue(nodeValue);
    }

    public short getNodeType() {
        return DELEGATE.getNodeType();
    }
    public Node getParentNode() {
        return DELEGATE.getParentNode();
    }
    public NodeList getChildNodes() {
        return DELEGATE.getChildNodes();
    }
    public Node getFirstChild() {
        return DELEGATE.getFirstChild();
    }
    public Node getLastChild() {
        return DELEGATE.getLastChild();
    }
    public Node getPreviousSibling() {
        return DELEGATE.getPreviousSibling();
    }
    public Node getNextSibling() {
        return DELEGATE.getNextSibling();
    }
    public NamedNodeMap getAttributes() {
        return DELEGATE.getAttributes();
    }
    public Document getOwnerDocument() {
        return DELEGATE.getOwnerDocument();
    }
    public Node insertBefore(Node newChild, Node refChild) throws DOMException {
        return DELEGATE.insertBefore(newChild, refChild);
    }
    public Node replaceChild(Node newChild,  Node oldChild) throws DOMException {
        return DELEGATE.replaceChild(newChild, oldChild);
    }
    public Node removeChild(Node oldChild) throws DOMException {
        return DELEGATE.removeChild(oldChild);
    }
    public Node appendChild(Node newChild) throws DOMException {
        return DELEGATE.appendChild(newChild);
    }
    public boolean hasChildNodes() {
        return DELEGATE.hasChildNodes();
    }
    public void normalize() {
        DELEGATE.normalize();
    }
    public boolean isSupported(String feature,  String version) {
        return DELEGATE.isSupported(feature, version);
    }
    public String getNamespaceURI() {
        return DELEGATE.getNamespaceURI();
    }
    public String getPrefix() {
        return DELEGATE.getPrefix();
    }
    public void setPrefix(String prefix) throws DOMException {
        DELEGATE.setPrefix(prefix);
    }
    public String getLocalName() {
        return DELEGATE.getLocalName();
    }
    public boolean hasAttributes() {
        return DELEGATE.hasAttributes();
    }

    // DOM level 3, org.w3c.dom.Document. This API may change as the
    // specification settles....
    public String getEncoding() {
        return DOMOps.getEncoding(DELEGATE);
    }
    public void setEncoding(String encoding) {
        DOMOps.setEncoding(DELEGATE, encoding);
    }

    public boolean getStandalone() {
        return DOMOps.getStandalone(DELEGATE);
    }
    public void setStandalone(boolean standalone) {
        DOMOps.setStandalone(DELEGATE, standalone);
    }

    public boolean getStrictErrorChecking() {
        return DOMOps.getStrictErrorChecking(DELEGATE);
    }
    public void setStrictErrorChecking(boolean strictErrorChecking) {
        DOMOps.setStrictErrorChecking(DELEGATE, strictErrorChecking);
    }

    public String getVersion() {
        return DOMOps.getVersion(DELEGATE);
    }
    public void setVersion(String version) {
        DOMOps.setVersion(DELEGATE, version);
    }

    public Node adoptNode(Node source) throws DOMException {
        return DOMOps.adoptNode(DELEGATE, source);
    }


//Below are DOM3 methods.  adoptNode() above is DOM3, but was used experimentally previously, so leaving as is.  There is a similar situation for getEncoding(), however the DOM3 method is getInputEncoding().  Leaving getEncoding() as is.
    
	public String getInputEncoding() {
		return DELEGATE.getInputEncoding();
	}

	public String getXmlEncoding() {
		return DELEGATE.getXmlEncoding();
	}

	public boolean getXmlStandalone() {
		return DELEGATE.getXmlStandalone();
	}

	public void setXmlStandalone(boolean xmlStandalone) throws DOMException {
		DELEGATE.setXmlStandalone(xmlStandalone);
	}

	public String getXmlVersion() {
		return DELEGATE.getXmlVersion();
	}

	public void setXmlVersion(String xmlVersion) throws DOMException {
		DELEGATE.setXmlVersion(xmlVersion);
	}

	public String getDocumentURI() {
		return DELEGATE.getDocumentURI();
	}

	public void setDocumentURI(String documentURI) {
		DELEGATE.setDocumentURI(documentURI);
	}

	public DOMConfiguration getDomConfig() {
		return DELEGATE.getDomConfig();
	}

	public void normalizeDocument() {
		DELEGATE.normalizeDocument();
	}

	public Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException {
		return DELEGATE.renameNode(n, namespaceURI, qualifiedName);
	}

	public String getBaseURI() {
		return DELEGATE.getBaseURI();
	}

	public short compareDocumentPosition(Node other) throws DOMException {
		return DELEGATE.compareDocumentPosition(other);
	}

	public String getTextContent() throws DOMException {
		return DELEGATE.getTextContent();
	}

	public void setTextContent(String textContent) throws DOMException {
		DELEGATE.setTextContent(textContent);
	}

	public boolean isSameNode(Node other) {
		return DELEGATE.isSameNode(other);
	}

	public String lookupPrefix(String namespaceURI) {
		return DELEGATE.lookupPrefix(namespaceURI);
	}

	public boolean isDefaultNamespace(String namespaceURI) {
		return DELEGATE.isDefaultNamespace(namespaceURI);
	}

	public String lookupNamespaceURI(String prefix) {
		return DELEGATE.lookupNamespaceURI(prefix);
	}

	public boolean isEqualNode(Node arg) {
		return DELEGATE.isEqualNode(arg);
	}

	public Object getFeature(String feature, String version) {
		return DELEGATE.getFeature(feature, version);
	}

	public Object setUserData(String key, Object data, UserDataHandler handler) {
		return DELEGATE.setUserData(key, data, handler);
	}

	public Object getUserData(String key) {
		return DELEGATE.getUserData(key);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy