|
XML for Java EA2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.xml.dom.NodeImpl | +--com.ibm.xml.dom.ElementImpl
Elements represent most of the "markup" and structure of the document. They contain both the data for the element itself (element name and attributes), and any contained nodes, including document text (as children).
Elements may have Attributes associated with them; the API for this is defined in Node, but the function is implemented here. In general, XML applications should retrive Attributes as Nodes, since they may contain entity references and hence be a fairly complex sub-tree. HTML users will be dealing with simple string values, and convenience methods are provided to work in terms of Strings.
Field Summary | |
protected NamedNodeMapImpl |
attributes
Attributes. |
protected boolean |
enableNamespace
DOM2: support. |
protected java.lang.String |
localName
DOM2: localName. |
protected java.lang.String |
namespaceURI
DOM2: Namespace URI. |
protected java.lang.String |
prefix
DOM2: Prefix |
Fields inherited from class com.ibm.xml.dom.NodeImpl |
ELEMENT_DEFINITION_NODE,
firstChild,
kidOK,
lastChild,
name,
nextSibling,
ownerDocument,
parentNode,
previousSibling,
readOnly,
syncChildren,
syncData,
userData,
value |
Constructor Summary | |
|
ElementImpl(DocumentImpl ownerDoc,
java.lang.String name)
Factory constructor. |
protected |
ElementImpl(DocumentImpl ownerDocument,
java.lang.String namespaceURI,
java.lang.String qualifiedName)
DOM2: Constructor for Namespace implementation. |
Method Summary | |
Node |
cloneNode(boolean deep)
Return a duplicate copy of this Element. |
java.lang.String |
getAttribute(java.lang.String name)
Look up a single Attribute by name. |
Attr |
getAttributeNode(java.lang.String name)
Look up a single Attribute by name. |
Attr |
getAttributeNodeNS(java.lang.String namespaceURI,
java.lang.String localName)
Retrieves an Attr node by local name and namespace URI. |
java.lang.String |
getAttributeNS(java.lang.String namespaceURI,
java.lang.String localName)
Introduced in DOM Level 2. |
NamedNodeMap |
getAttributes()
Retrieve all the Attributes as a set. |
NodeList |
getElementsByTagName(java.lang.String tagname)
Returns a NodeList of all descendent nodes (children, grandchildren, and so on) which are Elements and which have the specified tag name. |
NodeList |
getElementsByTagNameNS(java.lang.String namespaceURI,
java.lang.String localName)
Introduced in DOM Level 2. |
java.lang.String |
getLocalName()
Introduced in DOM Level 2. |
java.lang.String |
getNamespaceURI()
Introduced in DOM Level 2. |
short |
getNodeType()
A short integer indicating what type of node this is. |
java.lang.String |
getNodeValue()
Returns the node value. |
java.lang.String |
getPrefix()
Introduced in DOM Level 2. |
java.lang.String |
getTagName()
Returns the name of the Element. |
java.lang.String |
getValue()
Returns the element value. |
void |
normalize()
In "normal form" (as read from a source file), there will never be two Text children in succession. |
void |
removeAttribute(java.lang.String name)
Remove the named attribute from this Element. |
Attr |
removeAttributeNode(Attr oldAttr)
Remove the specified attribute/value pair. |
void |
removeAttributeNS(java.lang.String namespaceURI,
java.lang.String localName)
Introduced in DOM Level 2. |
void |
setAttribute(java.lang.String name,
java.lang.String value)
Add a new name/value pair, or replace the value of the existing attribute having that name. |
Attr |
setAttributeNode(Attr newAttr)
Add a new attribute/value pair, or replace the value of the existing attribute with that name. |
Attr |
setAttributeNodeNS(Attr newAttr)
Introduced in DOM Level 2. |
void |
setAttributeNS(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String value)
Introduced in DOM Level 2. |
void |
setNodeValue(java.lang.String value)
Elements never have a nodeValue. |
void |
setPrefix(java.lang.String prefix)
Introduced in DOM Level 2. |
void |
setReadOnly(boolean readOnly,
boolean deep)
NON-DOM: Subclassed to flip the attributes' readonly switch as well. |
protected void |
setupDefaultAttributes()
Setup the default attributes. |
protected void |
synchronizeData()
Synchronizes the data (name and value) for fast nodes. |
Methods inherited from class com.ibm.xml.dom.NodeImpl |
appendChild,
changed,
getChildNodes,
getFirstChild,
getLastChild,
getLength,
getNextSibling,
getNodeName,
getOwnerDocument,
getParentNode,
getPreviousSibling,
getReadOnly,
getUserData,
hasChildNodes,
insertBefore,
item,
removeChild,
replaceChild,
setUserData,
supports,
synchronizeChildren,
toString |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected NamedNodeMapImpl attributes
protected java.lang.String namespaceURI
protected java.lang.String prefix
protected java.lang.String localName
protected boolean enableNamespace
Constructor Detail |
public ElementImpl(DocumentImpl ownerDoc, java.lang.String name)
protected ElementImpl(DocumentImpl ownerDocument, java.lang.String namespaceURI, java.lang.String qualifiedName)
Method Detail |
public short getNodeType()
public java.lang.String getNodeValue()
public void setNodeValue(java.lang.String value) throws DOMException
public NamedNodeMap getAttributes()
public Node cloneNode(boolean deep)
Node.cloneNode()
public java.lang.String getValue()
public java.lang.String getAttribute(java.lang.String name)
Note: Attributes may contain complex node trees. This method returns the "flattened" string obtained from Attribute.getValue(). If you need the structure information, see getAttributeNode().
public Attr getAttributeNode(java.lang.String name)
If no matching attribute is available, returns null.
public NodeList getElementsByTagName(java.lang.String tagname)
Note: NodeList is a "live" view of the DOM. Its contents will change as the DOM changes, and alterations made to the NodeList will be reflected in the DOM.
tagname
- The type of element to gather. To obtain a list of
all elements no matter what their names, use the wild-card tag
name "*".com.ibm.domimpl.DeepNodeListImpl
public java.lang.String getNamespaceURI()
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 created with a DOM Level 1 method, such as createElement from the Document interface, this is null.
public java.lang.String getPrefix()
The namespace prefix of this node, or null if it is unspecified.
For nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is null.
public void setPrefix(java.lang.String prefix) throws DOMException
Note that setting this attribute 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.
public java.lang.String getLocalName()
Returns the local part of the qualified name of this node.
public java.lang.String getTagName()
This is case-preserving in XML. HTML should uppercasify it on the way in.
public void normalize()
To normalize a Document, normalize its top-level Element child.
As of PR-DOM-Level-1-19980818, CDATA -- despite being a subclass of Text -- is considered "markup" and will _not_ be merged either with normal Text or with other CDATASections.
public void removeAttribute(java.lang.String name)
The default logic is actually implemented in NamedNodeMapImpl. PR-DOM-Level-1-19980818 doesn't fully address the DTD, so some of this behavior is likely to change in future versions. ?????
Note that this call "succeeds" even if no attribute by this name existed -- unlike removeAttributeNode, which will throw a not-found exception in that case.
public Attr removeAttributeNode(Attr oldAttr) throws DOMException
NOTE: Specifically removes THIS NODE -- not the node with this name, nor the node with these contents. If the specific Attribute object passed in is not stored in this Element, we throw a DOMException. If you really want to remove an attribute by name, use removeAttribute().
public void setAttribute(java.lang.String name, java.lang.String value)
public Attr setAttributeNode(Attr newAttr) throws DOMException
This method allows you to add an Attribute that has already been constructed, and hence avoids the limitations of the simple setAttribute() call. It can handle attribute values that have arbitrarily complex tree structure -- in particular, those which had entity references mixed into their text.
public java.lang.String getAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
Retrieves an attribute value by local name and namespace URI.
namespaceURI
- The namespace URI of the attribute to
retrieve. When it is null or an empty string,
this method behaves like getAttribute.localName
- The local name of the attribute to retrieve.public void setAttributeNS(java.lang.String namespaceURI, java.lang.String localName, java.lang.String value)
Adds a new attribute. If an attribute with that local name and namespace URI is already present in the element, its value is changed to be that of the value parameter. This value is a simple string, it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNodeNS or setAttributeNode to assign it as the value of an attribute. HTML-only DOM implementations do not need to implement this method.
namespaceURI
- The namespace URI of the attribute to create
or alter. When it is null or an empty string,
this method behaves like getAttribute.localName
- The local name of the attribute to create or
alter.value
- The value to set in string form.public void removeAttributeNS(java.lang.String namespaceURI, java.lang.String localName)
Removes an attribute by local name and namespace URI. If the removed attribute has a default value it is immediately replaced.
namespaceURI
- The namespace URI of the attribute to remove.
When it is null or an empty string, this method
behaves like removeAttribute.localName
- The local name of the attribute to remove.public Attr getAttributeNodeNS(java.lang.String namespaceURI, java.lang.String localName)
namespaceURI
- The namespace URI of the attribute to
retrieve. When it is null or an empty string,
this method behaves like getAttribute.localName
- The local name of the attribute to retrieve.public Attr setAttributeNodeNS(Attr newAttr) throws DOMException
Adds a new attribute. If an attribute with that local name and namespace URI is already present in the element, it is replaced by the new one.
Attr
- The Attr node to add to the attribute list. When
the Node has no namespaceURI, this method behaves
like setAttributeNode.public 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, starting from this node.
namespaceURI
- The namespace URI of the elements to match
on. The special value "*" matches all
namespaces. When it is null or an empty
string, this method behaves like
getElementsByTagName.localName
- The local name of the elements to match on.
The special value "*" matches all local names.public void setReadOnly(boolean readOnly, boolean deep)
NodeImpl.setReadOnly
protected void synchronizeData()
protected void setupDefaultAttributes()
|
XML for Java EA2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |