Enhydra 3.0.3 API

org.enhydra.xml.xmlc
Class XMLObjectImpl

java.lang.Object
  |
  +--org.enhydra.xml.xmlc.XMLObjectImpl
Direct Known Subclasses:
HTMLObjectImpl

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

Base class for all compiled XML objects.

See Also:
XMLObject

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
 
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 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.
 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.
 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 would be 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 would be 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 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 hasChildNodes()
          This is a convenience method to allow easy determination of whether a 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.
 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 markup (e.g., tags, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are no adjacent 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 doc)
          Set the DOM document associated with this object.
protected  void setEncoding(java.lang.String enc)
          Set the encoding.
 void setNodeValue(java.lang.String nodeValue)
           
 void setPrefix(java.lang.String prefix)
           
 boolean supports(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.
 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
 

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 doc)
Set the DOM document associated with this object. 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.

setEncoding

protected void setEncoding(java.lang.String enc)
Set the encoding.

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()

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
See Also:
XMLObject.getEncoding()

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
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
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.
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, therefore docType cannot be altered in any way, including through the use of methods, such as insertNode or removeNode, inherited from Node.
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 and namespaces URI). 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 every type of node. ELEMENT_NODESpecified 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 importNode deep parameter was set to true, the descendants of the source element will be recursively imported and the resulting nodes reassembled to form the corresponding subtree. ATTRIBUTE_NODEThe specified flag is set to true on the generated Attr. The descendants of the the source Attr are recursively imported and the resulting nodes reassembled to form the corresponding subtree.Note that the deep parameter does not apply to Attr nodes; they always carry their children with them when imported.TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODEThese three types of nodes inheriting from CharacterData copy their data and length attributes from those of the source node.ENTITY_REFERENCE_NODEOnly 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.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 is recursively imported and the resulting nodes reassembled to form the corresponding subtree. PROCESSING_INSTRUCTION_NODEThe imported node copies its target and data values from those of the source node.DOCUMENT_NODEDocument nodes cannot be imported.DOCUMENT_TYPE_NODEDocumentType nodes cannot be imported.DOCUMENT_FRAGMENT_NODEIf the deep option was set true, the descendants of the source element will be recursively imported and the resulting nodes reassembled to form the corresponding subtree. Otherwise, this simply generates an empty DocumentFragment.NOTATION_NODENotation 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 does not apply to Notation nodes since they never have any children.
Specified by:
importNode in interface Document
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
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. If the given namespaceURI is null or an empty string and the qualifiedName has a prefix that is "xml", the created element is bound to the predefined namespace "http://www.w3.org/XML/1998/namespace" .
HTML-only DOM implementations do not need to implement this method.
Specified by:
createElementNS in interface Document
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
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
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
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
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
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 setAttribute method.
To create an attribute with a qualified name and namespace URI, use the createAttributeNS method.
Specified by:
createAttribute in interface Document
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. If the given namespaceURI is null or an empty string and the qualifiedName has a prefix that is "xml", the created attribute is bound to the predefined namespace "http://www.w3.org/XML/1998/namespace" .
HTML-only DOM implementations do not need to implement this method.
Specified by:
createAttributeNS in interface Document
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
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 would be encountered in a preorder traversal of the Document tree.
Specified by:
getElementsByTagName in interface Document
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 would be encountered in a preorder traversal of the Document tree.
Specified by:
getElementsByTagNameNS in interface Document
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
See Also:
Document.getElementById(java.lang.String)

getNodeName

public java.lang.String getNodeName()
Description copied from interface: Node
The name of this node, depending on its type; see the table above.
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.
See Also:
Node.getNodeValue()

setNodeValue

public void setNodeValue(java.lang.String nodeValue)
                  throws 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.
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.
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. The content of the returned NodeList is "live" in the sense that, for instance, changes to the children of the node object that it was created from are immediately reflected in the nodes returned by the NodeList accessors; it is not a static snapshot of the content of the node. This is true for every NodeList, including the ones returned by the getElementsByTagName method.
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.
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.
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.
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.
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.
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.
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.
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, refChild 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.
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.
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.
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 markup (e.g., tags, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are no adjacent 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.
See Also:
Node.normalize()

supports

public boolean supports(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.
See Also:
Node.supports(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.
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.
See Also:
Node.getPrefix()

setPrefix

public void setPrefix(java.lang.String prefix)
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 created with a DOM Level 1 method, such as createElement from the Document interface, it is null.
See Also:
Node.getLocalName()

hasChildNodes

public boolean hasChildNodes()
Description copied from interface: Node
This is a convenience method to allow easy determination of whether a node has any children.
See Also:
Node.hasChildNodes()

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 org.enhydra.xml.io.DOMFormatter DOMFormatter class if more options are required.
Specified by:
toDocument in interface XMLObject
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

Enhydra 3.0.3 API