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

public abstract class XMLObjectImpl
extends 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)
          See org.w3c.dom.Document#adoptNode
 Node appendChild(Node newChild)
           
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(String qualifiedName)
           
 Attr createAttributeNS(String namespaceURI, String qualifiedName)
           
 CDATASection createCDATASection(String data)
           
 Comment createComment(String data)
           
 DocumentFragment createDocumentFragment()
           
 Element createElement(String tagName)
           
 Element createElementNS(String namespaceURI, String qualifiedName)
           
 EntityReference createEntityReference(String name)
           
 ProcessingInstruction createProcessingInstruction(String target, String data)
           
 Text createTextNode(String data)
           
protected  void doSetText(Element element, String text)
          Used internally to implement a setTextXXX() method.
 NamedNodeMap getAttributes()
           
 NodeList getChildNodes()
           
 XMLObject getDelegate()
          Get the delegate.
 DocumentType getDoctype()
           
 Document getDocument()
          Get the actual document object.
 Element getDocumentElement()
           
protected abstract  XMLCDomFactory getDomFactory()
          Get the XMLC DOM Factory associated with this document type and DOM implementation.
 Element getElementById(String elementId)
           
 NodeList getElementsByTagName(String tagname)
           
 NodeList getElementsByTagNameNS(String namespaceURI, String localName)
           
 String getEncoding()
          See org.w3c.dom.Document#getEncoding
 Node getFirstChild()
           
 DOMImplementation getImplementation()
           
 Node getLastChild()
           
 String getLocalName()
           
 String getMIMEType()
          Get the MIME type associated with the document, or null if none was associated.
 String getNamespaceURI()
           
 Node getNextSibling()
           
 String getNodeName()
           
 short getNodeType()
           
 String getNodeValue()
           
 Document getOwnerDocument()
           
 Node getParentNode()
           
 String getPrefix()
           
 Node getPreviousSibling()
           
 boolean getStandalone()
          See org.w3c.dom.Document#getStandalone
 boolean getStrictErrorChecking()
          See org.w3c.dom.Document#getStrictErrorChecking
 String getVersion()
          See org.w3c.dom.Document#getVersion()
 boolean hasAttributes()
           
 boolean hasChildNodes()
           
 Node importNode(Node importedNode, boolean deep)
           
 void initFields()
          Deprecated. Use syncAccessMethods() instead.
 Node insertBefore(Node newChild, Node refChild)
           
 boolean isSupported(String feature, String version)
           
 boolean isURLAttribute(Element element, String attrName)
          Determine if an attribute of an element can contain a URL.
 void normalize()
           
 Node removeChild(Node oldChild)
           
 Node replaceChild(Node newChild, Node oldChild)
           
 void setDelegate(XMLObject delegate)
          Set the delegate object.
protected  void setDocument(Document document, String mimeType, String encoding)
          Set the DOM document associated with this object and optional encoding.
 void setEncoding(String encoding)
          See org.w3c.dom.Document#setEncoding
 void setNodeValue(String nodeValue)
           
 void setPrefix(String prefix)
           
 void setStandalone(boolean standalone)
          See org.w3c.dom.Document#setStandalone
 void setStrictErrorChecking(boolean strictErrorChecking)
          See org.w3c.dom.Document#setStrictErrorChecking
 void setVersion(String version)
          See org.w3c.dom.Document#setVersion
 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.
 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,
                           String mimeType,
                           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 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
See Also:
Node.cloneNode(boolean)

getDoctype

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

getImplementation

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

getDocumentElement

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

importNode

public Node importNode(Node importedNode,
                       boolean deep)
                throws DOMException
Specified by:
importNode in interface Document
DOMException
See Also:
Document.importNode(org.w3c.dom.Node, boolean)

createElement

public Element createElement(String tagName)
                      throws DOMException
Specified by:
createElement in interface Document
DOMException
See Also:
Document.createElement(java.lang.String)

createElementNS

public Element createElementNS(String namespaceURI,
                               String qualifiedName)
                        throws DOMException
Specified by:
createElementNS in interface Document
DOMException
See Also:
Document.createElementNS(java.lang.String, java.lang.String)

createDocumentFragment

public DocumentFragment createDocumentFragment()
Specified by:
createDocumentFragment in interface Document
See Also:
Document.createDocumentFragment()

createTextNode

public Text createTextNode(String data)
Specified by:
createTextNode in interface Document
See Also:
Document.createTextNode(java.lang.String)

createComment

public Comment createComment(String data)
Specified by:
createComment in interface Document
See Also:
Document.createComment(java.lang.String)

createCDATASection

public CDATASection createCDATASection(String data)
                                throws DOMException
Specified by:
createCDATASection in interface Document
DOMException
See Also:
Document.createCDATASection(java.lang.String)

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(String target,
                                                         String data)
                                                  throws DOMException
Specified by:
createProcessingInstruction in interface Document
DOMException
See Also:
Document.createProcessingInstruction(java.lang.String, java.lang.String)

createAttribute

public Attr createAttribute(String qualifiedName)
                     throws DOMException
Specified by:
createAttribute in interface Document
DOMException
See Also:
Document.createAttribute(java.lang.String)

createAttributeNS

public Attr createAttributeNS(String namespaceURI,
                              String qualifiedName)
                       throws DOMException
Specified by:
createAttributeNS in interface Document
DOMException
See Also:
Document.createAttributeNS(java.lang.String, java.lang.String)

createEntityReference

public EntityReference createEntityReference(String name)
                                      throws DOMException
Specified by:
createEntityReference in interface Document
DOMException
See Also:
Document.createEntityReference(java.lang.String)

getElementsByTagName

public NodeList getElementsByTagName(String tagname)
Specified by:
getElementsByTagName in interface Document
See Also:
Document.getElementsByTagName(java.lang.String)

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(String namespaceURI,
                                       String localName)
Specified by:
getElementsByTagNameNS in interface Document
See Also:
Document.getElementsByTagNameNS(java.lang.String, java.lang.String)

getElementById

public Element getElementById(String elementId)
Specified by:
getElementById in interface Document
See Also:
Document.getElementById(java.lang.String)

getEncoding

public String getEncoding()
See org.w3c.dom.Document#getEncoding

Specified by:
getEncoding in interface XMLObject
Returns:
the encoding or null if no encoding was explicitly specified.
See Also:
DOMFormatter, OutputOptions

setEncoding

public void setEncoding(String encoding)
See org.w3c.dom.Document#setEncoding

Specified by:
setEncoding in interface XMLObject

getStandalone

public boolean getStandalone()
See org.w3c.dom.Document#getStandalone

Specified by:
getStandalone in interface XMLObject

setStandalone

public void setStandalone(boolean standalone)
See org.w3c.dom.Document#setStandalone

Specified by:
setStandalone in interface XMLObject

getStrictErrorChecking

public boolean getStrictErrorChecking()
See org.w3c.dom.Document#getStrictErrorChecking

Specified by:
getStrictErrorChecking in interface XMLObject

setStrictErrorChecking

public void setStrictErrorChecking(boolean strictErrorChecking)
See org.w3c.dom.Document#setStrictErrorChecking

Specified by:
setStrictErrorChecking in interface XMLObject

getVersion

public String getVersion()
See org.w3c.dom.Document#getVersion()

Specified by:
getVersion in interface XMLObject

setVersion

public void setVersion(String version)
See org.w3c.dom.Document#setVersion

Specified by:
setVersion in interface XMLObject

adoptNode

public Node adoptNode(Node source)
               throws DOMException
See org.w3c.dom.Document#adoptNode

Specified by:
adoptNode in interface XMLObject
DOMException

getNodeName

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

getNodeValue

public String getNodeValue()
                    throws DOMException
Specified by:
getNodeValue in interface Node
DOMException
See Also:
Node.getNodeValue()

setNodeValue

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

getNodeType

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

getParentNode

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

getChildNodes

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

getFirstChild

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

getLastChild

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

getPreviousSibling

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

getNextSibling

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

getAttributes

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

getOwnerDocument

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

insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
                  throws DOMException
Specified by:
insertBefore in interface Node
DOMException
See Also:
Node.insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)

replaceChild

public Node replaceChild(Node newChild,
                         Node oldChild)
                  throws DOMException
Specified by:
replaceChild in interface Node
DOMException
See Also:
Node.replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)

removeChild

public Node removeChild(Node oldChild)
                 throws DOMException
Specified by:
removeChild in interface Node
DOMException
See Also:
Node.removeChild(org.w3c.dom.Node)

appendChild

public Node appendChild(Node newChild)
                 throws DOMException
Specified by:
appendChild in interface Node
DOMException
See Also:
Node.appendChild(org.w3c.dom.Node)

normalize

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

isSupported

public boolean isSupported(String feature,
                           String version)
Specified by:
isSupported in interface Node
See Also:
Node.isSupported(String, String)

getNamespaceURI

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

getPrefix

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

setPrefix

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

getLocalName

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

hasChildNodes

public boolean hasChildNodes()
Specified by:
hasChildNodes in interface Node
See Also:
Node.hasChildNodes()

hasAttributes

public boolean hasAttributes()
Specified by:
hasAttributes in interface Node
See Also:
Node.hasAttributes()

toDocument

public 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,
                              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,
                               String text)
Used internally to implement a setTextXXX() method. Adds check for for null value and helps to minimizes the amount of generated code.



Copyright © 1999-2002 enhydra.org (Mark Diekhans, David Li, Richard Kunze). All Rights reserved.