|
|||||||||
| Home >> All >> gnu >> xml >> [ dom overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
gnu.xml.dom
Class DomAttr

java.lang.Objectgnu.xml.dom.DomNode
gnu.xml.dom.DomNsNode
gnu.xml.dom.DomAttr
- All Implemented Interfaces:
- org.w3c.dom.Attr, java.lang.Cloneable, java.lang.Comparable, org.w3c.dom.events.DocumentEvent, org.w3c.dom.events.EventTarget, org.w3c.dom.Node, org.w3c.dom.NodeList
- public class DomAttr
- extends DomNsNode
- implements org.w3c.dom.Attr
- extends DomNsNode
"Attr" implementation. In DOM, attributes cost quite a lot of memory because their values are complex structures rather than just simple strings. To reduce your costs, avoid having more than one child of an attribute; stick to a single Text node child, and ignore even that by using the attribute's "nodeValue" property.
As a bit of general advice, only look at attribute modification events through the DOMAttrModified event (sent to the associated element). Implementations are not guaranteed to report other events in the same order, so you're very likely to write nonportable code if you monitor events at the "children of Attr" level.
At this writing, not all attribute modifications will cause the DOMAttrModified event to be triggered ... only the ones using the string methods (setNodeValue, setValue, and Element.setAttribute) to modify those values. That is, if you manipulate those children directly, elements won't get notified that attribute values have changed. The natural fix for that will report other modifications, but won't be able to expose "previous" attribute value; it'll need to be cached or something (at which point why bother using child nodes).
You are strongly advised not to use "children" of any attribute nodes you work with.
| Nested Class Summary |
| Nested classes inherited from class gnu.xml.dom.DomNode |
DomNode.DomEventException, DomNode.ListenerRecord, DomNode.LiveNodeList, DomNode.ShadowList |
| Field Summary | |
private boolean |
specified
|
private java.lang.String |
value
|
| Fields inherited from class gnu.xml.dom.DomNsNode |
localName |
| Fields inherited from class gnu.xml.dom.DomNode |
depth, first, index, last, length, next, nodeType, owner, parent, previous, readonly, reportMutations |
| Constructor Summary | |
protected |
DomAttr(DomDocument owner,
java.lang.String namespaceURI,
java.lang.String name)
Constructs an Attr node associated with the specified document. |
| Method Summary | |
java.lang.Object |
clone()
Shallow clone of the attribute, breaking all ties with any elements. |
java.lang.String |
getBaseURI()
The base URI of an Attr is always null. |
org.w3c.dom.Node |
getFirstChild()
The first child of this node. |
org.w3c.dom.Node |
getLastChild()
The last child of this node. |
java.lang.String |
getName()
DOM L1 Returns the attribute name (same as getNodeName) |
org.w3c.dom.Node |
getNextSibling()
The node immediately following this node. |
java.lang.String |
getNodeValue()
DOM L1 Returns the attribute value, with character and entity references substituted. |
org.w3c.dom.Element |
getOwnerElement()
DOM L2 Returns the element with which this attribute is associated. |
org.w3c.dom.Node |
getParentNode()
The parent of this node. |
org.w3c.dom.Node |
getPreviousSibling()
The node immediately preceding this node. |
org.w3c.dom.TypeInfo |
getSchemaTypeInfo()
The type information associated with this attribute. |
boolean |
getSpecified()
DOM L1 Returns true if a parser reported this was in the source text. |
java.lang.String |
getValue()
DOM L1 Returns the value of the attribute as a non-null string; same as getNodeValue. |
boolean |
isId()
Returns whether this attribute is known to be of type ID (i.e. |
org.w3c.dom.Node |
item(int index)
DOM L1 (NodeList) Returns the item with the specified index in this NodeList, else null. |
private void |
mutating(java.lang.String oldValue,
java.lang.String newValue,
short why)
|
void |
setNodeValue(java.lang.String value)
DOM L1 Assigns the attribute value; using this API, no entity or character references will exist. |
void |
setOwnerElement(org.w3c.dom.Element e)
Records the element with which this attribute is associated. |
void |
setSpecified(boolean value)
Records whether this attribute was in the source text. |
void |
setValue(java.lang.String value)
DOM L1 Assigns the value of the attribute; it will have one child, which is a text node with the specified value (same as setNodeValue). |
| Methods inherited from class gnu.xml.dom.DomNsNode |
getLocalName, getNamespaceURI, getNodeName, getPrefix, setNamespaceURI, setNodeName, setPrefix |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.w3c.dom.Node |
appendChild, cloneNode, compareDocumentPosition, getAttributes, getChildNodes, getFeature, getLocalName, getNamespaceURI, getNodeName, getNodeType, getOwnerDocument, getPrefix, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setPrefix, setTextContent, setUserData |
| Field Detail |
specified
private boolean specified
value
private java.lang.String value
| Constructor Detail |
DomAttr
protected DomAttr(DomDocument owner, java.lang.String namespaceURI, java.lang.String name)
- Constructs an Attr node associated with the specified document.
The "specified" flag is initialized to true, since this DOM has
no current "back door" mechanisms to manage default values so
that every value must effectively be "specified".
This constructor should only be invoked by a Document as part of its createAttribute functionality, or through a subclass which is similarly used in a "Sub-DOM" style layer.
| Method Detail |
getName
public final java.lang.String getName()
- DOM L1
Returns the attribute name (same as getNodeName)
- Specified by:
getNamein interfaceorg.w3c.dom.Attr
getSpecified
public final boolean getSpecified()
- DOM L1
Returns true if a parser reported this was in the source text.
- Specified by:
getSpecifiedin interfaceorg.w3c.dom.Attr
setSpecified
public final void setSpecified(boolean value)
- Records whether this attribute was in the source text.
getNodeValue
public java.lang.String getNodeValue()
- DOM L1
Returns the attribute value, with character and entity
references substituted.
NOTE: entity refs as children aren't currently handled.
- Specified by:
getNodeValuein interfaceorg.w3c.dom.Node- Overrides:
getNodeValuein classDomNode
setValue
public final void setValue(java.lang.String value)
- DOM L1
Assigns the value of the attribute; it will have one child,
which is a text node with the specified value (same as
setNodeValue).
- Specified by:
setValuein interfaceorg.w3c.dom.Attr
getValue
public final java.lang.String getValue()
- DOM L1
Returns the value of the attribute as a non-null string; same
as getNodeValue.
NOTE: entity refs as children aren't currently handled.
- Specified by:
getValuein interfaceorg.w3c.dom.Attr
setNodeValue
public void setNodeValue(java.lang.String value)
- DOM L1
Assigns the attribute value; using this API, no entity or
character references will exist.
Causes a DOMAttrModified mutation event to be sent.
- Specified by:
setNodeValuein interfaceorg.w3c.dom.Node- Overrides:
setNodeValuein classDomNode
getFirstChild
public final org.w3c.dom.Node getFirstChild()
- Description copied from interface:
org.w3c.dom.Node - The first child of this node. If there is no such node, this returns
null.- Specified by:
getFirstChildin interfaceorg.w3c.dom.Node- Overrides:
getFirstChildin classDomNode
getLastChild
public final org.w3c.dom.Node getLastChild()
- Description copied from interface:
org.w3c.dom.Node - The last child of this node. If there is no such node, this returns
null.- Specified by:
getLastChildin interfaceorg.w3c.dom.Node- Overrides:
getLastChildin classDomNode
item
public org.w3c.dom.Node item(int index)
- Description copied from class:
DomNode - DOM L1 (NodeList)
Returns the item with the specified index in this NodeList,
else null.
- Specified by:
itemin interfaceorg.w3c.dom.NodeList- Overrides:
itemin classDomNode
getOwnerElement
public final org.w3c.dom.Element getOwnerElement()
- DOM L2
Returns the element with which this attribute is associated.
- Specified by:
getOwnerElementin interfaceorg.w3c.dom.Attr
getNextSibling
public final org.w3c.dom.Node getNextSibling()
- Description copied from interface:
org.w3c.dom.Node - The node immediately following this node. If there is no such node,
this returns
null.- Specified by:
getNextSiblingin interfaceorg.w3c.dom.Node- Overrides:
getNextSiblingin classDomNode
getPreviousSibling
public final org.w3c.dom.Node getPreviousSibling()
- Description copied from interface:
org.w3c.dom.Node - The node immediately preceding this node. If there is no such node,
this returns
null.- Specified by:
getPreviousSiblingin interfaceorg.w3c.dom.Node- Overrides:
getPreviousSiblingin classDomNode
getParentNode
public org.w3c.dom.Node getParentNode()
- Description copied from interface:
org.w3c.dom.Node - The parent of this node. All nodes, except
Attr,Document,DocumentFragment,Entity, andNotationmay 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 isnull.- Specified by:
getParentNodein interfaceorg.w3c.dom.Node- Overrides:
getParentNodein classDomNode
setOwnerElement
public final void setOwnerElement(org.w3c.dom.Element e)
- Records the element with which this attribute is associated.
getBaseURI
public final java.lang.String getBaseURI()
- The base URI of an Attr is always
null.- Specified by:
getBaseURIin interfaceorg.w3c.dom.Node- Overrides:
getBaseURIin classDomNode
clone
public java.lang.Object clone()
- Shallow clone of the attribute, breaking all ties with any
elements.
mutating
private void mutating(java.lang.String oldValue, java.lang.String newValue, short why)
getSchemaTypeInfo
public org.w3c.dom.TypeInfo getSchemaTypeInfo()
- Description copied from interface:
org.w3c.dom.Attr - The type information associated with this attribute. While the type
information contained in this attribute is guarantee to be correct
after loading the document or invoking
Document.normalizeDocument(),schemaTypeInfomay not be reliable if the node was moved.- Specified by:
getSchemaTypeInfoin interfaceorg.w3c.dom.Attr
isId
public boolean isId()
- Description copied from interface:
org.w3c.dom.Attr - Returns whether this attribute is known to be of type ID (i.e. to
contain an identifier for its owner element) or not. When it is and
its value is unique, the
ownerElementof this attribute can be retrieved using the methodDocument.getElementById. The implementation could use several ways to determine if an attribute node is known to contain an identifier:- If validation
occurred using an XML Schema [XML Schema Part 1]
while loading the document or while invoking
Document.normalizeDocument(), the post-schema-validation infoset contributions (PSVI contributions) values are used to determine if this attribute is a schema-determined ID attribute using the schema-determined ID definition in [XPointer] . - If validation occurred using a DTD while loading the document or
while invoking
Document.normalizeDocument(), the infoset [type definition] value is used to determine if this attribute is a DTD-determined ID attribute using the DTD-determined ID definition in [XPointer] . - from the use of the methods
Element.setIdAttribute(),Element.setIdAttributeNS(), orElement.setIdAttributeNode(), i.e. it is an user-determined ID attribute;Note: XPointer framework (see section 3.2 in [XPointer] ) consider the DOM user-determined ID attribute as being part of the XPointer externally-determined ID definition.
- using mechanisms that are outside the scope of this specification, it is then an externally-determined ID attribute. This includes using schema languages different from XML schema and DTD.
If validation occurred while invokingDocument.normalizeDocument(), all user-determined ID attributes are reset and all attribute nodes ID information are then reevaluated in accordance to the schema used. As a consequence, if theAttr.schemaTypeInfoattribute contains an ID type,isIdwill always return true.- Specified by:
isIdin interfaceorg.w3c.dom.Attr
- If validation
occurred using an XML Schema [XML Schema Part 1]
while loading the document or while invoking
|
|||||||||
| Home >> All >> gnu >> xml >> [ dom overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC