|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.crimson.tree.NodeBase org.apache.crimson.tree.ParentNode org.apache.crimson.tree.NamespacedNode org.apache.crimson.tree.ElementNode2
Modified version of ElementNode to support DOM Level 2 methods. This class is named ElementNode2 for backward compatibility since old DOM Level 1 apps may have subclassed 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
Nested Class Summary |
Nested classes inherited from class org.apache.crimson.tree.NamespacedNode |
ParentNode.TagList, ParentNode.TagListNS |
Field Summary | |
protected AttributeSet |
attributes
|
private String |
idAttributeName
|
private static char[] |
tagEnd
|
private static char[] |
tagStart
|
private Object |
userObject
|
Fields inherited from class org.apache.crimson.tree.NamespacedNode |
namespaceURI, ownerDocument, qName, readonly |
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 | |
ElementNode2(String namespaceURI,
String qName)
|
Method Summary | |
(package private) static void |
checkArguments(String namespaceURI,
String qualifiedName)
|
(package private) void |
checkChildType(int type)
|
org.w3c.dom.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. |
(package private) ElementNode2 |
createCopyForImportNode(boolean deep)
|
String |
getAttribute(String name)
DOM: Returns the value of the named attribute, or an empty string |
org.w3c.dom.Attr |
getAttributeNode(String name)
DOM: returns the attribute |
org.w3c.dom.Attr |
getAttributeNodeNS(String namespaceURI,
String localName)
Retrieves an Attr node by local name and namespace URI. |
String |
getAttributeNS(String namespaceURI,
String localName)
Retrieves an attribute value by local name and namespace URI. |
org.w3c.dom.NamedNodeMap |
getAttributes()
DOM: Returns the attributes of this element. |
String |
getIdAttributeName()
Returns the name of the element's ID attribute, if one is known. |
short |
getNodeType()
DOM: Returns the ELEMENT_NODE node type. |
String |
getTagName()
DOM: Returns the name of the XML tag for this element. |
Object |
getUserObject()
Returns the object associated with this element. |
boolean |
hasAttribute(String name)
Returns true when an attribute with a given name is
specified on this element or has a default value, false
otherwise. |
boolean |
hasAttributeNS(String namespaceURI,
String localName)
Returns true when an attribute with a given local name
and namespace URI is specified on this element or has a default
value, false otherwise. |
boolean |
hasAttributes()
Returns whether this node (if it is an element) has any attributes. |
(package private) ElementNode2 |
makeClone()
Make a clone of this node and return it. |
void |
removeAttribute(String name)
DOM: Remove the named attribute. |
org.w3c.dom.Attr |
removeAttributeNode(org.w3c.dom.Attr oldAttr)
DOM: removes the attribute with the same name as this one |
void |
removeAttributeNS(String namespaceURI,
String localName)
DOM2: |
void |
setAttribute(String name,
String value)
DOM: Assigns or modifies the value of the specified attribute. |
org.w3c.dom.Attr |
setAttributeNode(org.w3c.dom.Attr newAttr)
DOM: assigns the attribute |
org.w3c.dom.Attr |
setAttributeNodeNS(org.w3c.dom.Attr newAttr)
DOM2: |
void |
setAttributeNS(String namespaceURI,
String qualifiedName,
String value)
DOM2: |
(package private) void |
setAttributes(AttributeSet a)
|
void |
setIdAttributeName(String attName)
Assigns the name of the element's ID attribute; only one attribute may have the ID type. |
void |
setReadonly(boolean deep)
Sets the node to be readonly; applies recursively to the children of this node if the parameter is true. |
void |
setUserObject(Object userObject)
Assigns an object to be associated with this element. |
String |
toString()
Returns the element and its content as a string, which includes all the markup embedded in this element. |
void |
trimToSize()
Requests that the element minimize the amount of space it uses, to conserve memory. |
void |
write(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 org.apache.crimson.tree.NamespacedNode |
appendChild, getChildNodes, getElementsByTagName, getElementsByTagNameNS, getFirstChild, getIndexOf, getInheritedAttribute, getLanguage, getLastChild, getLength, getLocalName, getMessage, getMessage, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentImpl, getParentNode, getPrefix, getPreviousSibling, hasChildNodes, insertBefore, isReadonly, isSupported, item, normalize, reduceWaste, removeChild, removeWhiteSpaces, replaceChild, setNodeValue, setOwnerDocument, setParentNode, setPrefix, writeChildrenXml |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.w3c.dom.Element |
getElementsByTagName, getElementsByTagNameNS |
Methods inherited from interface org.w3c.dom.Node |
appendChild, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix |
Methods inherited from interface org.apache.crimson.tree.NodeEx |
getIndexOf, getInheritedAttribute, getLanguage, isReadonly |
Methods inherited from interface org.apache.crimson.tree.XmlWritable |
writeChildrenXml |
Field Detail |
protected AttributeSet attributes
private String idAttributeName
private Object userObject
private static final char[] tagStart
private static final char[] tagEnd
Constructor Detail |
public ElementNode2(String namespaceURI, String qName) throws DomEx
Method Detail |
ElementNode2 makeClone()
ElementNode2 createCopyForImportNode(boolean deep)
static void checkArguments(String namespaceURI, String qualifiedName) throws DomEx
DomEx
public void trimToSize()
ElementEx
trimToSize
in interface ElementEx
trimToSize
in class ParentNode
void setAttributes(AttributeSet a)
void checkChildType(int type) throws org.w3c.dom.DOMException
checkChildType
in class ParentNode
org.w3c.dom.DOMException
public void setReadonly(boolean deep)
NodeEx
setReadonly
in interface NodeEx
setReadonly
in class NodeBase
public org.w3c.dom.NamedNodeMap getAttributes()
getAttributes
in interface org.w3c.dom.Node
getAttributes
in class NodeBase
public boolean hasAttributes()
hasAttributes
in interface org.w3c.dom.Node
hasAttributes
in class NodeBase
public String toString()
toString
in class Object
public void writeXml(XmlWriteContext context) throws IOException
writeXml
in interface XmlWritable
IOException
public void setIdAttributeName(String attName)
public String getIdAttributeName()
getIdAttributeName
in interface ElementEx
public void setUserObject(Object userObject)
ElementEx
setUserObject
in interface ElementEx
public Object getUserObject()
ElementEx
getUserObject
in interface ElementEx
public short getNodeType()
getNodeType
in interface org.w3c.dom.Node
public String getTagName()
getTagName
in interface org.w3c.dom.Element
public boolean hasAttribute(String name)
true
when an attribute with a given name is
specified on this element or has a default value, false
otherwise.
hasAttribute
in interface org.w3c.dom.Element
public boolean hasAttributeNS(String namespaceURI, String localName)
true
when an attribute with a given local name
and namespace URI is specified on this element or has a default
value, false
otherwise.
hasAttributeNS
in interface org.w3c.dom.Element
public String getAttribute(String name)
getAttribute
in interface org.w3c.dom.Element
public String getAttributeNS(String namespaceURI, String localName)
getAttributeNS
in interface org.w3c.dom.Element
public org.w3c.dom.Attr getAttributeNodeNS(String namespaceURI, String localName)
Attr
node by local name and namespace URI.
getAttributeNodeNS
in interface org.w3c.dom.Element
public void setAttribute(String name, String value) throws org.w3c.dom.DOMException
setAttribute
in interface org.w3c.dom.Element
org.w3c.dom.DOMException
public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws org.w3c.dom.DOMException
setAttributeNS
in interface org.w3c.dom.Element
org.w3c.dom.DOMException
public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr) throws org.w3c.dom.DOMException
setAttributeNodeNS
in interface org.w3c.dom.Element
org.w3c.dom.DOMException
public void removeAttribute(String name) throws org.w3c.dom.DOMException
removeAttribute
in interface org.w3c.dom.Element
org.w3c.dom.DOMException
public void removeAttributeNS(String namespaceURI, String localName) throws org.w3c.dom.DOMException
removeAttributeNS
in interface org.w3c.dom.Element
org.w3c.dom.DOMException
public org.w3c.dom.Attr getAttributeNode(String name)
getAttributeNode
in interface org.w3c.dom.Element
public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr) throws org.w3c.dom.DOMException
setAttributeNode
in interface org.w3c.dom.Element
org.w3c.dom.DOMException
public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr) throws org.w3c.dom.DOMException
removeAttributeNode
in interface org.w3c.dom.Element
org.w3c.dom.DOMException
public org.w3c.dom.Node cloneNode(boolean deep)
cloneNode
in interface org.w3c.dom.Node
public void write(Writer out) throws IOException
out
- where to emit the XML content of this node
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |