public final class AttrImpl extends NodeImpl implements Attr
Some of the fields may have package visibility, so other classes belonging to the DOM implementation can easily access them while maintaining the DOM tree structure.
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
Modifier and Type | Method and Description |
---|---|
String |
getLocalName()
Returns the local part of the qualified name of this node.
|
String |
getName()
Returns the name of this attribute.
|
String |
getNamespaceURI()
The namespace URI of this node, or
null if it is
unspecified (see ). |
String |
getNodeName()
The name of this node, depending on its type; see the table above.
|
short |
getNodeType()
A code representing the type of the underlying object, as defined above.
|
String |
getNodeValue()
The value of this node, depending on its type; see the table above.
|
Element |
getOwnerElement()
The
Element node this attribute is attached to or
null if this attribute is not in use. |
String |
getPrefix()
The namespace prefix of this node, or
null if it is
unspecified. |
TypeInfo |
getSchemaTypeInfo()
The type information associated with this attribute.
|
boolean |
getSpecified()
True if this attribute was explicitly given a value in
the instance document, false otherwise. |
String |
getValue()
On retrieval, the value of the attribute is returned as a string.
|
boolean |
isId()
Returns whether this attribute is known to be of type ID (i.e.
|
void |
setPrefix(String prefix)
The namespace prefix of this node, or
null if it is
unspecified. |
void |
setValue(String value)
On retrieval, the value of the attribute is returned as a string.
|
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getNextSibling, getOwnerDocument, getParentNode, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setTextContent, setUserData
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getNextSibling, getOwnerDocument, getParentNode, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setTextContent, setUserData
public String getLocalName()
Node
ELEMENT_NODE
and
ATTRIBUTE_NODE
and nodes created with a DOM Level 1
method, such as Document.createElement()
, this is always
null
.getLocalName
in interface Node
getLocalName
in class NodeImpl
public String getName()
Attr
Node.localName
is
different from null
, this attribute is a qualified name.public String getNamespaceURI()
Node
null
if it is
unspecified (see ).
ELEMENT_NODE
and
ATTRIBUTE_NODE
and nodes created with a DOM Level 1
method, such as Document.createElement()
, this is always
null
.
Note: Per the Namespaces in XML Specification [XML Namespaces] an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.
getNamespaceURI
in interface Node
getNamespaceURI
in class NodeImpl
public String getNodeName()
Node
getNodeName
in interface Node
getNodeName
in class NodeImpl
public short getNodeType()
Node
getNodeType
in interface Node
getNodeType
in class NodeImpl
public String getNodeValue()
Node
null
, setting it has no effect,
including if the node is read-only.getNodeValue
in interface Node
getNodeValue
in class NodeImpl
public Element getOwnerElement()
Attr
Element
node this attribute is attached to or
null
if this attribute is not in use.getOwnerElement
in interface Attr
public String getPrefix()
Node
null
if it is
unspecified. When it is defined to be null
, setting it
has no effect, including if the node is read-only.
nodeName
attribute, which holds the qualified name, as
well as the tagName
and name
attributes of
the Element
and Attr
interfaces, when
applicable.
null
makes it unspecified,
setting it to an empty string is implementation dependent.
namespaceURI
and localName
do not change.
ELEMENT_NODE
and
ATTRIBUTE_NODE
and nodes created with a DOM Level 1
method, such as createElement
from the
Document
interface, this is always null
.public boolean getSpecified()
Attr
True
if this attribute was explicitly given a value in
the instance document, false
otherwise. If the
application changed the value of this attribute node (even if it ends
up having the same value as the default value) then it is set to
true
. The implementation may handle attributes with
default values from other schemas similarly but applications should
use Document.normalizeDocument()
to guarantee this
information is up-to-date.getSpecified
in interface Attr
public String getValue()
Attr
getAttribute
on the
Element
interface.
Text
node with the unparsed
contents of the string, i.e. any characters that an XML processor
would recognize as markup are instead treated as literal text. See
also the method Element.setAttribute()
.
public void setPrefix(String prefix)
Node
null
if it is
unspecified. When it is defined to be null
, setting it
has no effect, including if the node is read-only.
nodeName
attribute, which holds the qualified name, as
well as the tagName
and name
attributes of
the Element
and Attr
interfaces, when
applicable.
null
makes it unspecified,
setting it to an empty string is implementation dependent.
namespaceURI
and localName
do not change.
ELEMENT_NODE
and
ATTRIBUTE_NODE
and nodes created with a DOM Level 1
method, such as createElement
from the
Document
interface, this is always null
.public void setValue(String value) throws DOMException
Attr
getAttribute
on the
Element
interface.
Text
node with the unparsed
contents of the string, i.e. any characters that an XML processor
would recognize as markup are instead treated as literal text. See
also the method Element.setAttribute()
.
setValue
in interface Attr
DOMException
- NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.public TypeInfo getSchemaTypeInfo()
Attr
Document.normalizeDocument()
, schemaTypeInfo
may not be reliable if the node was moved.getSchemaTypeInfo
in interface Attr
public boolean isId()
Attr
ownerElement
of this attribute
can be retrieved using the method Document.getElementById
. The implementation could use several ways to determine if an
attribute node is known to contain an identifier:
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]
.
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]
.
Element.setIdAttribute()
,
Element.setIdAttributeNS()
, or
Element.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.
Document.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
the Attr.schemaTypeInfo
attribute contains an ID type,
isId
will always return true.