|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.xml.tree.NodeBase | +--com.sun.xml.tree.ParentNode | +--com.sun.xml.tree.ElementNode
This class represents XML elements in a parse tree, and is often subclassed to add custom behaviors. When an XML Document object is built using an XmlDocumentBuilder instance, simple declarative configuration information may be used to control whether this class, or some specialized subclass (e.g. supporting HTML DOM methods) is used for elements in the resulting tree.
As well as defining new methods to provide behaviors which are specific to application frameworks, such as Servlets or Swing, such subclasses may also override methods such as doneParse and appendChild to perform some kinds of processing during tree construction. Such processing can include transforming tree structure to better suit the needs of a given application. When such transformation is done, the XmlWritable methods may need to be overridden to make elements transform themselves back to XML without losing information. (One common transformation is eliminating redundant representations of data; attributes of an XML element may correspond to defaultable object properties, and so on.)
Element nodes also support a single userObject property,
which may be used to bind objects to elements where subclassing is
either not possible or is inappropriate. For example, user interface
objects often derive from java.awt.Component
, so that
they can't extend a different class (ElementNode).
XmlDocumentBuilder
Constructor Summary | |
ElementNode()
Partially constructs an element; its tag will be assigned by the factory (or subclass), while attributes and the parent (and implicitly, siblings) will assigned when it is joined to a DOM document. |
Method Summary | |
Node |
cloneNode(boolean deep)
Creates a new unparented node whose attributes are the same as this node's attributes; if deep is true, the children of this node are cloned as children of the new node. |
java.lang.String |
getAttribute(java.lang.String name)
DOM: Returns the value of the named attribute, or null |
java.lang.String |
getAttribute(java.lang.String uri,
java.lang.String name)
|
Attr |
getAttributeNode(java.lang.String name)
DOM: returns the attribute |
Attr |
getAttributeNode(java.lang.String uri,
java.lang.String name)
|
NamedNodeMap |
getAttributes()
DOM: Returns the attributes of this element. |
java.lang.String |
getIdAttributeName()
Returns the name of the element's ID attribute, if one is known. |
java.lang.String |
getLocalName()
|
java.lang.String |
getNamespace()
|
java.lang.String |
getNodeName()
DOM: Returns the name of the XML tag for this element. |
short |
getNodeType()
DOM: Returns the ELEMENT_NODE node type. |
java.lang.String |
getTagName()
DOM: Returns the name of the XML tag for this element. |
java.lang.Object |
getUserObject()
|
void |
normalize()
DOM: Merges all adjacent Text nodes in the tree rooted by this element. |
void |
removeAttribute(java.lang.String name)
DOM: Remove the named attribute. |
Attr |
removeAttributeNode(Attr oldAttr)
DOM: removes the attribute with the same name as this one |
void |
setAttribute(java.lang.String name,
java.lang.String value)
DOM: Assigns or modifies the value of the specified attribute. |
Attr |
setAttributeNode(Attr newAttr)
DOM: assigns the attribute |
void |
setIdAttributeName(java.lang.String attName)
Assigns the name of the element's ID attribute; only one attribute may have the ID type. |
protected void |
setTag(java.lang.String t)
Assigns the element's tag, when the element has been constructed using the default constructor. |
void |
setUserObject(java.lang.Object userObject)
|
java.lang.String |
toString()
Returns the element and its content as a string, which includes all the markup embedded in this element. |
void |
trimToSize()
|
void |
write(java.io.Writer out)
Convenience method to construct a non-prettyprinting XML write context and call writeXml with it. |
void |
writeXml(XmlWriteContext context)
Writes this element and all of its children out, as well formed XML. |
Methods inherited from class com.sun.xml.tree.ParentNode |
appendChild,
doneChild,
doneParse,
getElementsByTagName,
getFirstChild,
getIndexOf,
getLastChild,
getLength,
hasChildNodes,
insertBefore,
item,
removeChild,
replaceChild,
startParse,
writeChildrenXml |
Methods inherited from class com.sun.xml.tree.NodeBase |
getChildNodes,
getInheritedAttribute,
getInheritedAttribute,
getLanguage,
getNextSibling,
getNodeValue,
getOwnerDocument,
getParentNode,
getPreviousSibling,
setNodeValue |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public ElementNode()
Method Detail |
public void trimToSize()
protected void setTag(java.lang.String t)
public java.lang.String getNamespace()
public java.lang.String getLocalName()
public NamedNodeMap getAttributes()
public java.lang.String toString()
public void writeXml(XmlWriteContext context) throws java.io.IOException
public void setIdAttributeName(java.lang.String attName)
public java.lang.String getIdAttributeName()
public void setUserObject(java.lang.Object userObject)
public java.lang.Object getUserObject()
public short getNodeType()
public java.lang.String getTagName()
public java.lang.String getNodeName()
public java.lang.String getAttribute(java.lang.String name)
public java.lang.String getAttribute(java.lang.String uri, java.lang.String name)
public Attr getAttributeNode(java.lang.String uri, java.lang.String name)
public void setAttribute(java.lang.String name, java.lang.String value) throws DOMException
public void removeAttribute(java.lang.String name) throws DOMException
public Attr getAttributeNode(java.lang.String name)
public Attr setAttributeNode(Attr newAttr) throws DOMException
public Attr removeAttributeNode(Attr oldAttr) throws DOMException
public void normalize()
As a compatible extension to DOM, this normalizes treatment of whitespace except when the xml:space='preserve' attribute value applies to a node. All whitespace is normalized to one space. This ensures that text which is pretty-printed and then reread (and normalized) retains the same content.
public Node cloneNode(boolean deep)
public void write(java.io.Writer out) throws java.io.IOException
out
- where to emit the XML content of this node
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |