Enhydra 5.1 API

org.enhydra.xml.xmlc
Class XMLObjectImpl

java.lang.Object
  |
  +--org.enhydra.xml.xmlc.XMLObjectImpl
All Implemented Interfaces:
Document, DocumentInfo, Node, XMLObject
Direct Known Subclasses:
HTMLObjectImpl, XMLObject

public abstract class XMLObjectImpl
extends java.lang.Object
implements XMLObject, Document, DocumentInfo

Base class for all compiled XML objects.

See Also:
XMLObject

Field Summary
 
Fields inherited from interface org.enhydra.xml.xmlc.XMLObject
XMLC_GENERATED_CLASS_FIELD_NAME, XMLC_SOURCE_FILE_FIELD_NAME
 
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
protected XMLObjectImpl()
          Constructor.
 
Method Summary
 Node adoptNode(Node source)
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 Node appendChild(Node newChild)
          Adds the node newChild to the end of the list of children of this node.
protected  void cloneDeepCheck(boolean deep)
          Check that cloneNode on an entire document is done with the deep option.
abstract  Node cloneNode(boolean deep)
          Clone the entire document.
 Attr createAttribute(java.lang.String qualifiedName)
          Creates an Attr of the given name.
 Attr createAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          Creates an attribute of the given qualified name and namespace URI.
 CDATASection createCDATASection(java.lang.String data)
          Creates a CDATASection node whose value is the specified string.
 Comment createComment(java.lang.String data)
          Creates a Comment node given the specified string.
 DocumentFragment createDocumentFragment()
          Creates an empty DocumentFragment object.
 Element createElement(java.lang.String tagName)
          Creates an element of the type specified.
 Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
          Creates an element of the given qualified name and namespace URI.
 EntityReference createEntityReference(java.lang.String name)
          Creates an EntityReference object.
 ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data)
          Creates a ProcessingInstruction node given the specified name and data strings.
 Text createTextNode(java.lang.String data)
          Creates a Text node given the specified string.
protected  void doSetText(Element element, java.lang.String text)
          Used internally to implement a setTextXXX() method.
 NamedNodeMap getAttributes()
          A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
 NodeList getChildNodes()
          A NodeList that contains all children of this node.
 XMLObject getDelegate()
          Get the delegate.
 DocumentType getDoctype()
          The Document Type Declaration (see DocumentType) associated with this document.
 Document getDocument()
          Get the actual document object.
 Element getDocumentElement()
          This is a convenience attribute that allows direct access to the child node that is the root element of the document.
protected abstract  XMLCDomFactory getDomFactory()
          Get the XMLC DOM Factory associated with this document type and DOM implementation.
 Element getElementById(java.lang.String elementId)
          Returns the Element whose ID is given by elementId.
 NodeList getElementsByTagName(java.lang.String tagname)
          Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.
 NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
          Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree.
 java.lang.String getEncoding()
          Get the encoding specified in the document.
 Node getFirstChild()
          The first child of this node.
 DOMImplementation getImplementation()
          The DOMImplementation object that handles this document.
 Node getLastChild()
          The last child of this node.
 java.lang.String getLocalName()
          Returns the local part of the qualified name of this node.
 java.lang.String getMIMEType()
          Get the MIME type associated with the document, or null if none was associated.
 java.lang.String getNamespaceURI()
          The namespace URI of this node, or null if it is unspecified.
 Node getNextSibling()
          The node immediately following this node.
 java.lang.String getNodeName()
          The name of this node, depending on its type; see the table above.
 short getNodeType()
          A code representing the type of the underlying object, as defined above.
 java.lang.String getNodeValue()
          The value of this node, depending on its type; see the table above.
 Document getOwnerDocument()
          The Document object associated with this node.
 Node getParentNode()
          The parent of this node.
 java.lang.String getPrefix()
          The namespace prefix of this node, or null if it is unspecified.
 Node getPreviousSibling()
          The node immediately preceding this node.
 boolean getStandalone()
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 boolean getStrictErrorChecking()
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 java.lang.String getVersion()
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 boolean hasAttributes()
          Returns whether this node (if it is an element) has any attributes.
 boolean hasChildNodes()
          Returns whether this node has any children.
 Node importNode(Node importedNode, boolean deep)
          Imports a node from another document to this document.
 void initFields()
          Deprecated. Use syncAccessMethods() instead.
 Node insertBefore(Node newChild, Node refChild)
          Inserts the node newChild before the existing child node refChild.
 boolean isSupported(java.lang.String feature, java.lang.String version)
          Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.
 boolean isURLAttribute(Element element, java.lang.String attrName)
          Determine if an attribute of an element can contain a URL.
 void normalize()
          Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.
 Node removeChild(Node oldChild)
          Removes the child node indicated by oldChild from the list of children, and returns it.
 Node replaceChild(Node newChild, Node oldChild)
          Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
 void setDelegate(XMLObject delegate)
          Set the delegate object.
protected  void setDocument(Document document, java.lang.String mimeType, java.lang.String encoding)
          Set the DOM document associated with this object and optional encoding.
 void setEncoding(java.lang.String encoding)
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 void setNodeValue(java.lang.String nodeValue)
           
 void setPrefix(java.lang.String prefix)
           
 void setStandalone(boolean standalone)
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 void setStrictErrorChecking(boolean strictErrorChecking)
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 void setVersion(java.lang.String version)
          EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..
 void syncAccessMethods()
          Initialize the fields used by the generated access methods from the current state of the document.
protected abstract  void syncWithDocument(Node node)
          Generated function to synchronize the fields used by the access methods.
 java.lang.String toDocument()
          Convert the document to a string representation of the document, that is a string containing XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.enhydra.xml.xmlc.XMLObject
buildDocument
 

Constructor Detail

XMLObjectImpl

protected XMLObjectImpl()
Constructor. The setDocument() method must be called to associate a document with this object.

Method Detail

setDocument

protected void setDocument(Document document,
                           java.lang.String mimeType,
                           java.lang.String encoding)
Set the DOM document associated with this object and optional encoding. This is used by buildDocument() to set the new document. It is done separately from the constructor to allow buildDocument() to not be called immediatly.


getDomFactory

protected abstract XMLCDomFactory getDomFactory()
Get the XMLC DOM Factory associated with this document type and DOM implementation.


getDocument

public Document getDocument()
Description copied from interface: XMLObject
Get the actual document object. One should normally just use the XMLObject methods to access the Document functionality, this is for the initialization of derived objects.

Specified by:
getDocument in interface XMLObject
See Also:
XMLObject.getDocument()

getMIMEType

public java.lang.String getMIMEType()
Description copied from interface: XMLObject
Get the MIME type associated with the document, or null if none was associated.

Specified by:
getMIMEType in interface XMLObject
See Also:
XMLObject.getMIMEType()

setDelegate

public void setDelegate(XMLObject delegate)
Description copied from interface: XMLObject
Set the delegate object. Delegation is used to support automatic recompilation of documents into XMLC objects. If the delegate is not null, the methods of the delegate are called to handle most of the methods of this object.

Specified by:
setDelegate in interface XMLObject
Parameters:
delegate - The delegate object, or null to remove delegation. The delegate must implement the same interface as the derived, generate object.
See Also:
XMLObject.setDelegate(org.enhydra.xml.xmlc.XMLObject)

getDelegate

public XMLObject getDelegate()
Description copied from interface: XMLObject
Get the delegate.

Specified by:
getDelegate in interface XMLObject
Returns:
The delegate object, or null if there is no delegate.
See Also:
XMLObject.getDelegate()

cloneDeepCheck

protected void cloneDeepCheck(boolean deep)
Check that cloneNode on an entire document is done with the deep option.


cloneNode

public abstract Node cloneNode(boolean deep)
Clone the entire document. Derived objects should override this to get the correct derived type. Cloning with deep being false is not allowed.

Specified by:
cloneNode in interface Node
Returns:
The duplicate node.
See Also:
Node.cloneNode(boolean)

getDoctype

public DocumentType getDoctype()
Description copied from interface: Document
The Document Type Declaration (see DocumentType) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns null. The DOM Level 2 does not support editing the Document Type Declaration. docType cannot be altered in any way, including through the use of methods inherited from the Node interface, such as insertNode or removeNode.

Specified by:
getDoctype in interface Document
See Also:
Document.getDoctype()

getImplementation

public DOMImplementation getImplementation()
Description copied from interface: Document
The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations.

Specified by:
getImplementation in interface Document
See Also:
Document.getImplementation()

getDocumentElement

public Element getDocumentElement()
Description copied from interface: Document
This is a convenience attribute that allows direct access to the child node that is the root element of the document. For HTML documents, this is the element with the tagName "HTML".

Specified by:
getDocumentElement in interface Document
See Also:
Document.getDocumentElement()

importNode

public Node importNode(Node importedNode,
                       boolean deep)
                throws DOMException
Description copied from interface: Document
Imports a node from another document to this document. The returned node has no parent; (parentNode is null). The source node is not altered or removed from the original document; this method creates a new copy of the source node.
For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's nodeName and nodeType, plus the attributes related to namespaces (prefix, localName, and namespaceURI). As in the cloneNode operation on a Node, the source node is not altered.
Additional information is copied as appropriate to the nodeType, attempting to mirror the behavior expected if a fragment of XML or HTML source was copied from one document to another, recognizing that the two documents may have different DTDs in the XML case. The following list describes the specifics for each type of node.
ATTRIBUTE_NODE
The ownerElement attribute is set to null and the specified flag is set to true on the generated Attr. The descendants of the source Attr are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Note that the deep parameter has no effect on Attr nodes; they always carry their children with them when imported.
DOCUMENT_FRAGMENT_NODE
If the deep option was set to true, the descendants of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Otherwise, this simply generates an empty DocumentFragment.
DOCUMENT_NODE
Document nodes cannot be imported.
DOCUMENT_TYPE_NODE
DocumentType nodes cannot be imported.
ELEMENT_NODE
Specified attribute nodes of the source element are imported, and the generated Attr nodes are attached to the generated Element. Default attributes are not copied, though if the document being imported into defines default attributes for this element name, those are assigned. If the importNode deep parameter was set to true, the descendants of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree.
ENTITY_NODE
Entity nodes can be imported, however in the current release of the DOM the DocumentType is readonly. Ability to add these imported nodes to a DocumentType will be considered for addition to a future release of the DOM.On import, the publicId, systemId, and notationName attributes are copied. If a deep import is requested, the descendants of the the source Entity are recursively imported and the resulting nodes reassembled to form the corresponding subtree.
ENTITY_REFERENCE_NODE
Only the EntityReference itself is copied, even if a deep import is requested, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned.
NOTATION_NODE
Notation nodes can be imported, however in the current release of the DOM the DocumentType is readonly. Ability to add these imported nodes to a DocumentType will be considered for addition to a future release of the DOM.On import, the publicId and systemId attributes are copied. Note that the deep parameter has no effect on Notation nodes since they never have any children.
PROCESSING_INSTRUCTION_NODE
The imported node copies its target and data values from those of the source node.
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE
These three types of nodes inheriting from CharacterData copy their data and length attributes from those of the source node.

Specified by:
importNode in interface Document
Returns:
The imported node that belongs to this Document.
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if the type of node being imported is not supported.
See Also:
Document.importNode(org.w3c.dom.Node, boolean)

createElement

public Element createElement(java.lang.String tagName)
                      throws DOMException
Description copied from interface: Document
Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object.
In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element.
To create an element with a qualified name and namespace URI, use the createElementNS method.

Specified by:
createElement in interface Document
Returns:
A new Element object with the nodeName attribute set to tagName, and localName, prefix, and namespaceURI set to null.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.
See Also:
Document.createElement(java.lang.String)

createElementNS

public Element createElementNS(java.lang.String namespaceURI,
                               java.lang.String qualifiedName)
                        throws DOMException
Description copied from interface: Document
Creates an element of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method.

Specified by:
createElementNS in interface Document
Returns:
A new Element object with the following attributes:AttributeValueNode.nodeName qualifiedNameNode.namespaceURI namespaceURINode.prefixprefix, extracted from qualifiedName, or null if there is no prefixNode.localNamelocal name, extracted from qualifiedNameElement.tagName qualifiedName
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null, or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from " http://www.w3.org/XML/1998/namespace" .
See Also:
Document.createElementNS(java.lang.String, java.lang.String)

createDocumentFragment

public DocumentFragment createDocumentFragment()
Description copied from interface: Document
Creates an empty DocumentFragment object.

Specified by:
createDocumentFragment in interface Document
Returns:
A new DocumentFragment.
See Also:
Document.createDocumentFragment()

createTextNode

public Text createTextNode(java.lang.String data)
Description copied from interface: Document
Creates a Text node given the specified string.

Specified by:
createTextNode in interface Document
Returns:
The new Text object.
See Also:
Document.createTextNode(java.lang.String)

createComment

public Comment createComment(java.lang.String data)
Description copied from interface: Document
Creates a Comment node given the specified string.

Specified by:
createComment in interface Document
Returns:
The new Comment object.
See Also:
Document.createComment(java.lang.String)

createCDATASection

public CDATASection createCDATASection(java.lang.String data)
                                throws DOMException
Description copied from interface: Document
Creates a CDATASection node whose value is the specified string.

Specified by:
createCDATASection in interface Document
Returns:
The new CDATASection object.
Throws:
DOMException - NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
See Also:
Document.createCDATASection(java.lang.String)

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(java.lang.String target,
                                                         java.lang.String data)
                                                  throws DOMException
Description copied from interface: Document
Creates a ProcessingInstruction node given the specified name and data strings.

Specified by:
createProcessingInstruction in interface Document
Returns:
The new ProcessingInstruction object.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified target contains an illegal character.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
See Also:
Document.createProcessingInstruction(java.lang.String, java.lang.String)

createAttribute

public Attr createAttribute(java.lang.String qualifiedName)
                     throws DOMException
Description copied from interface: Document
Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttributeNode method.
To create an attribute with a qualified name and namespace URI, use the createAttributeNS method.

Specified by:
createAttribute in interface Document
Returns:
A new Attr object with the nodeName attribute set to name, and localName, prefix, and namespaceURI set to null. The value of the attribute is the empty string.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.
See Also:
Document.createAttribute(java.lang.String)

createAttributeNS

public Attr createAttributeNS(java.lang.String namespaceURI,
                              java.lang.String qualifiedName)
                       throws DOMException
Description copied from interface: Document
Creates an attribute of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method.

Specified by:
createAttributeNS in interface Document
Returns:
A new Attr object with the following attributes: AttributeValueNode.nodeNamequalifiedName Node.namespaceURInamespaceURI Node.prefixprefix, extracted from qualifiedName, or null if there is no prefixNode.localNamelocal name, extracted from qualifiedNameAttr.name qualifiedNameNode.nodeValuethe empty string
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null, if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from " http://www.w3.org/XML/1998/namespace", or if the qualifiedName is "xmlns" and the namespaceURI is different from " http://www.w3.org/2000/xmlns/".
See Also:
Document.createAttributeNS(java.lang.String, java.lang.String)

createEntityReference

public EntityReference createEntityReference(java.lang.String name)
                                      throws DOMException
Description copied from interface: Document
Creates an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node.If any descendant of the Entity node has an unbound namespace prefix, the corresponding descendant of the created EntityReference node is also unbound; (its namespaceURI is null). The DOM Level 2 does not support any mechanism to resolve namespace prefixes.

Specified by:
createEntityReference in interface Document
Returns:
The new EntityReference object.
Throws:
DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
See Also:
Document.createEntityReference(java.lang.String)

getElementsByTagName

public NodeList getElementsByTagName(java.lang.String tagname)
Description copied from interface: Document
Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.

Specified by:
getElementsByTagName in interface Document
Returns:
A new NodeList object containing all the matched Elements.
See Also:
Document.getElementsByTagName(java.lang.String)

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(java.lang.String namespaceURI,
                                       java.lang.String localName)
Description copied from interface: Document
Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of the Document tree.

Specified by:
getElementsByTagNameNS in interface Document
Returns:
A new NodeList object containing all the matched Elements.
See Also:
Document.getElementsByTagNameNS(java.lang.String, java.lang.String)

getElementById

public Element getElementById(java.lang.String elementId)
Description copied from interface: Document
Returns the Element whose ID is given by elementId. If no such element exists, returns null. Behavior is not defined if more than one element has this ID. The DOM implementation must have information that says which attributes are of type ID. Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return null.

Specified by:
getElementById in interface Document
Returns:
The matching element.
See Also:
Document.getElementById(java.lang.String)

getEncoding

public java.lang.String getEncoding()
Description copied from interface: XMLObject
Get the encoding specified in the document. Note that this is the symbolic name of the XML encoding, which is not the same as the Java encoding names.

Specified by:
getEncoding in interface XMLObject
Returns:
the encoding or null if no encoding was explicitly specified.
See Also:
Document.getEncoding()

setEncoding

public void setEncoding(java.lang.String encoding)
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when unspecified.

Specified by:
setEncoding in interface XMLObject
See Also:
Document.setEncoding(java.lang.String)

getStandalone

public boolean getStandalone()
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, whether this document is standalone.

Specified by:
getStandalone in interface XMLObject
See Also:
Document.getStandalone()

setStandalone

public void setStandalone(boolean standalone)
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, whether this document is standalone.

Specified by:
setStandalone in interface XMLObject
See Also:
Document.setStandalone(boolean)

getStrictErrorChecking

public boolean getStrictErrorChecking()
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying whether errors checking is enforced or not. When set to false, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException. In case of error, the behavior is undefined. This attribute is true by defaults.

Specified by:
getStrictErrorChecking in interface XMLObject
See Also:
Document.getStrictErrorChecking()

setStrictErrorChecking

public void setStrictErrorChecking(boolean strictErrorChecking)
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying whether errors checking is enforced or not. When set to false, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any DOMException. In case of error, the behavior is undefined. This attribute is true by defaults.

Specified by:
setStrictErrorChecking in interface XMLObject
See Also:
Document.setStrictErrorChecking(boolean)

getVersion

public java.lang.String getVersion()
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the version number of this document. This is null when unspecified.

Specified by:
getVersion in interface XMLObject
See Also:
Document.getVersion()

setVersion

public void setVersion(java.lang.String version)
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

An attribute specifying, as part of the XML declaration, the version number of this document. This is null when unspecified.

Specified by:
setVersion in interface XMLObject
See Also:
Document.setVersion(java.lang.String)

adoptNode

public Node adoptNode(Node source)
               throws DOMException
Description copied from interface: Document

EXPERIMENTAL! Based on the Document Object Model (DOM) Level 3 Core Working Draft of 5 June 2001..

Changes the ownerDocument of a node, its children, as well as the attached attribute nodes if there are any. If the node has a parent it is first removed from its parent child list. This effectively allows moving a subtree from one document to another. The following list describes the specifics for each type of node.

ATTRIBUTE_NODE
The ownerElement attribute is set to null and the specified flag is set to true on the adopted Attr. The descendants of the source Attr are recursively adopted.
DOCUMENT_FRAGMENT_NODE
The descendants of the source node are recursively adopted.
DOCUMENT_NODE
Document nodes cannot be adopted.
DOCUMENT_TYPE_NODE
DocumentType nodes cannot be adopted.
ELEMENT_NODE
Specified attribute nodes of the source element are adopted, and the generated Attr nodes. Default attributes are discarded, though if the document being adopted into defines default attributes for this element name, those are assigned. The descendants of the source element are recursively adopted.
ENTITY_NODE
Entity nodes cannot be adopted.
ENTITY_REFERENCE_NODE
Only the EntityReference node itself is adopted, the descendants are discarded, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned.
NOTATION_NODE
Notation nodes cannot be adopted.
PROCESSING_INSTRUCTION_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE
These nodes can all be adopted. No specifics.
Should this method simply return null when it fails? How "exceptional" is failure for this method?Stick with raising exceptions only in exceptional circumstances, return null on failure (F2F 19 Jun 2000).Can an entity node really be adopted?No, neither can Notation nodes (Telcon 13 Dec 2000).Does this affect keys and hashCode's of the adopted subtree nodes?If so, what about readonly-ness of key and hashCode?if not, would appendChild affect keys/hashCodes or would it generate exceptions if key's are duplicate? Update: Hashcodes have been dropped. Given that the key is only unique within a document an adopted node needs to be given a new key, but what does it mean for the application?

Specified by:
adoptNode in interface XMLObject
DOMException
See Also:
Document.adoptNode(org.w3c.dom.Node)

getNodeName

public java.lang.String getNodeName()
Description copied from interface: Node
The name of this node, depending on its type; see the table above.

Specified by:
getNodeName in interface Node
See Also:
Node.getNodeName()

getNodeValue

public java.lang.String getNodeValue()
                              throws DOMException
Description copied from interface: Node
The value of this node, depending on its type; see the table above. When it is defined to be null, setting it has no effect.

Specified by:
getNodeValue in interface Node
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
See Also:
Node.getNodeValue()

setNodeValue

public void setNodeValue(java.lang.String nodeValue)
                  throws DOMException
Specified by:
setNodeValue in interface Node
DOMException
See Also:
Node.setNodeValue(java.lang.String)

getNodeType

public short getNodeType()
Description copied from interface: Node
A code representing the type of the underlying object, as defined above.

Specified by:
getNodeType in interface Node
See Also:
Node.getNodeType()

getParentNode

public Node getParentNode()
Description copied from interface: Node
The parent of this node. All nodes, except Attr, Document, DocumentFragment, Entity, and Notation may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is null.

Specified by:
getParentNode in interface Node
See Also:
Node.getParentNode()

getChildNodes

public NodeList getChildNodes()
Description copied from interface: Node
A NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes.

Specified by:
getChildNodes in interface Node
See Also:
Node.getChildNodes()

getFirstChild

public Node getFirstChild()
Description copied from interface: Node
The first child of this node. If there is no such node, this returns null.

Specified by:
getFirstChild in interface Node
See Also:
Node.getFirstChild()

getLastChild

public Node getLastChild()
Description copied from interface: Node
The last child of this node. If there is no such node, this returns null.

Specified by:
getLastChild in interface Node
See Also:
Node.getLastChild()

getPreviousSibling

public Node getPreviousSibling()
Description copied from interface: Node
The node immediately preceding this node. If there is no such node, this returns null.

Specified by:
getPreviousSibling in interface Node
See Also:
Node.getPreviousSibling()

getNextSibling

public Node getNextSibling()
Description copied from interface: Node
The node immediately following this node. If there is no such node, this returns null.

Specified by:
getNextSibling in interface Node
See Also:
Node.getNextSibling()

getAttributes

public NamedNodeMap getAttributes()
Description copied from interface: Node
A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.

Specified by:
getAttributes in interface Node
See Also:
Node.getAttributes()

getOwnerDocument

public Document getOwnerDocument()
Description copied from interface: Node
The Document object associated with this node. This is also the Document object used to create new nodes. When this node is a Document or a DocumentType which is not used with any Document yet, this is null.

Specified by:
getOwnerDocument in interface Node
See Also:
Node.getOwnerDocument()

insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
                  throws DOMException
Description copied from interface: Node
Inserts the node newChild before the existing child node refChild. If refChild is null, insert newChild at the end of the list of children.
If newChild is a DocumentFragment object, all of its children are inserted, in the same order, before refChild. If the newChild is already in the tree, it is first removed.

Specified by:
insertBefore in interface Node
Returns:
The node being inserted.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to insert is one of this node's ancestors.
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the parent of the node being inserted is readonly.
NOT_FOUND_ERR: Raised if refChild is not a child of this node.
See Also:
Node.insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)

replaceChild

public Node replaceChild(Node newChild,
                         Node oldChild)
                  throws DOMException
Description copied from interface: Node
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
If newChild is a DocumentFragment object, oldChild is replaced by all of the DocumentFragment children, which are inserted in the same order. If the newChild is already in the tree, it is first removed.

Specified by:
replaceChild in interface Node
Returns:
The node replaced.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to put in is one of this node's ancestors.
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of the new node is readonly.
NOT_FOUND_ERR: Raised if oldChild is not a child of this node.
See Also:
Node.replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)

removeChild

public Node removeChild(Node oldChild)
                 throws DOMException
Description copied from interface: Node
Removes the child node indicated by oldChild from the list of children, and returns it.

Specified by:
removeChild in interface Node
Returns:
The node removed.
Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised if oldChild is not a child of this node.
See Also:
Node.removeChild(org.w3c.dom.Node)

appendChild

public Node appendChild(Node newChild)
                 throws DOMException
Description copied from interface: Node
Adds the node newChild to the end of the list of children of this node. If the newChild is already in the tree, it is first removed.

Specified by:
appendChild in interface Node
Returns:
The node added.
Throws:
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the newChild node, or if the node to append is one of this node's ancestors.
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
See Also:
Node.appendChild(org.w3c.dom.Node)

normalize

public void normalize()
Description copied from interface: Node
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used.In cases where the document contains CDATASections, the normalize operation alone may not be sufficient, since XPointers do not differentiate between Text nodes and CDATASection nodes.

Specified by:
normalize in interface Node
See Also:
Node.normalize()

isSupported

public boolean isSupported(java.lang.String feature,
                           java.lang.String version)
Description copied from interface: Node
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.

Specified by:
isSupported in interface Node
Returns:
Returns true if the specified feature is supported on this node, false otherwise.
See Also:
Node.isSupported(String, String)

getNamespaceURI

public java.lang.String getNamespaceURI()
Description copied from interface: Node
The namespace URI of this node, or null if it is unspecified.
This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.Per the Namespaces in XML Specification an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.

Specified by:
getNamespaceURI in interface Node
See Also:
Node.getNamespaceURI()

getPrefix

public java.lang.String getPrefix()
Description copied from interface: Node
The namespace prefix of this node, or null if it is unspecified.
Note that setting this attribute, when permitted, changes the nodeName attribute, which holds the qualified name, as well as the tagName and name attributes of the Element and Attr interfaces, when applicable.
Note also that changing the prefix of an attribute that is known to have a default value, does not make a new attribute with the default value and the original prefix appear, since the namespaceURI and localName do not change.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.

Specified by:
getPrefix in interface Node
See Also:
Node.getPrefix()

setPrefix

public void setPrefix(java.lang.String prefix)
Specified by:
setPrefix in interface Node
See Also:
Node.setPrefix(java.lang.String)

getLocalName

public java.lang.String getLocalName()
Description copied from interface: Node
Returns the local part of the qualified name of this node.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.

Specified by:
getLocalName in interface Node
See Also:
Node.getLocalName()

hasChildNodes

public boolean hasChildNodes()
Description copied from interface: Node
Returns whether this node has any children.

Specified by:
hasChildNodes in interface Node
Returns:
true if this node has any children, false otherwise.
See Also:
Node.hasChildNodes()

hasAttributes

public boolean hasAttributes()
Description copied from interface: Node
Returns whether this node (if it is an element) has any attributes.

Specified by:
hasAttributes in interface Node
Returns:
true if this node has any attributes, false otherwise.
See Also:
Node.hasAttributes()

toDocument

public java.lang.String toDocument()
Description copied from interface: XMLObject
Convert the document to a string representation of the document, that is a string containing XML. The results are parsable into the same DOM hierarchy. The formatting provided by this method does not begin to cover all of the issues involved with publishing a XML document, such as character encoding. Use the DOMFormatter class if more options are required.

Specified by:
toDocument in interface XMLObject
Returns:
A string containing the full XML.
See Also:
XMLObject.toDocument()

syncWithDocument

protected abstract void syncWithDocument(Node node)
Generated function to synchronize the fields used by the access methods. This syncronizes just the node and is not recursive.


syncAccessMethods

public void syncAccessMethods()
Description copied from interface: XMLObject
Initialize the fields used by the generated access methods from the current state of the document. Missing DOM element ids will result in their acccess method returning null.

Specified by:
syncAccessMethods in interface XMLObject
See Also:
XMLObject.syncAccessMethods()

initFields

public void initFields()
Deprecated. Use syncAccessMethods() instead.

Old method to initialize the fields used by the generated access methods from the current state of the document. This method was poorly named and is deprecated.

See Also:
syncAccessMethods

isURLAttribute

public boolean isURLAttribute(Element element,
                              java.lang.String attrName)
Description copied from interface: DocumentInfo
Determine if an attribute of an element can contain a URL.

Specified by:
isURLAttribute in interface DocumentInfo
See Also:
DocumentInfo.isURLAttribute(org.w3c.dom.Element, java.lang.String)

doSetText

protected final void doSetText(Element element,
                               java.lang.String text)
Used internally to implement a setTextXXX() method. Adds check for for null value and helps to minimizes the amount of generated code.


Enhydra 5.1 API