Package org.apache.harmony.xml.dom
Class AttrImpl
java.lang.Object
org.apache.harmony.xml.dom.NodeImpl
org.apache.harmony.xml.dom.AttrImpl
public final class AttrImpl extends NodeImpl implements Attr
Provides a straightforward implementation of the corresponding W3C DOM
interface. The class is used internally only, thus only notable members that
are not in the original interface are documented (the W3C docs are quite
extensive). Hope that's ok.
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.
-
Field Summary
Fields inherited from interface org.w3c.dom.Node
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 -
Method Summary
Modifier and Type Method Description StringgetLocalName()Returns the local part of the qualified name of this node.StringgetName()Returns the name of this attribute.StringgetNamespaceURI()The namespace URI of this node, ornullif it is unspecified (see ).StringgetNodeName()The name of this node, depending on its type; see the table above.shortgetNodeType()A code representing the type of the underlying object, as defined above.StringgetNodeValue()The value of this node, depending on its type; see the table above.ElementgetOwnerElement()TheElementnode this attribute is attached to ornullif this attribute is not in use.StringgetPrefix()The namespace prefix of this node, ornullif it is unspecified.TypeInfogetSchemaTypeInfo()The type information associated with this attribute.booleangetSpecified()Trueif this attribute was explicitly given a value in the instance document,falseotherwise.StringgetValue()On retrieval, the value of the attribute is returned as a string.booleanisId()Returns whether this attribute is known to be of type ID (i.e.voidsetPrefix(String prefix)The namespace prefix of this node, ornullif it is unspecified.voidsetValue(String value)On retrieval, the value of the attribute is returned as a string.Methods inherited from class org.apache.harmony.xml.dom.NodeImpl
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, setUserDataMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.w3c.dom.Node
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
-
Method Details
-
getLocalName
Description copied from interface:NodeReturns the local part of the qualified name of this node.
For nodes of any type other thanELEMENT_NODEandATTRIBUTE_NODEand nodes created with a DOM Level 1 method, such asDocument.createElement(), this is alwaysnull.- Specified by:
getLocalNamein interfaceNode- Overrides:
getLocalNamein classNodeImpl
-
getName
Description copied from interface:AttrReturns the name of this attribute. IfNode.localNameis different fromnull, this attribute is a qualified name. -
getNamespaceURI
Description copied from interface:NodeThe namespace URI of this node, ornullif it is unspecified (see ).
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 of any type other thanELEMENT_NODEandATTRIBUTE_NODEand nodes created with a DOM Level 1 method, such asDocument.createElement(), this is alwaysnull.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.
- Specified by:
getNamespaceURIin interfaceNode- Overrides:
getNamespaceURIin classNodeImpl
-
getNodeName
Description copied from interface:NodeThe name of this node, depending on its type; see the table above.- Specified by:
getNodeNamein interfaceNode- Overrides:
getNodeNamein classNodeImpl
-
getNodeType
public short getNodeType()Description copied from interface:NodeA code representing the type of the underlying object, as defined above.- Specified by:
getNodeTypein interfaceNode- Specified by:
getNodeTypein classNodeImpl
-
getNodeValue
Description copied from interface:NodeThe value of this node, depending on its type; see the table above. When it is defined to benull, setting it has no effect, including if the node is read-only.- Specified by:
getNodeValuein interfaceNode- Overrides:
getNodeValuein classNodeImpl
-
getOwnerElement
Description copied from interface:AttrTheElementnode this attribute is attached to ornullif this attribute is not in use.- Specified by:
getOwnerElementin interfaceAttr
-
getPrefix
Description copied from interface:NodeThe namespace prefix of this node, ornullif it is unspecified. When it is defined to benull, setting it has no effect, including if the node is read-only.
Note that setting this attribute, when permitted, changes thenodeNameattribute, which holds the qualified name, as well as thetagNameandnameattributes of theElementandAttrinterfaces, when applicable.
Setting the prefix tonullmakes it unspecified, setting it to an empty string is implementation dependent.
Note also that changing the prefix of an attribute that is known to have a default value, does not make a new attribute with the default value and the original prefix appear, since thenamespaceURIandlocalNamedo not change.
For nodes of any type other thanELEMENT_NODEandATTRIBUTE_NODEand nodes created with a DOM Level 1 method, such ascreateElementfrom theDocumentinterface, this is alwaysnull. -
getSpecified
public boolean getSpecified()Description copied from interface:AttrTrueif this attribute was explicitly given a value in the instance document,falseotherwise. 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 totrue. The implementation may handle attributes with default values from other schemas similarly but applications should useDocument.normalizeDocument()to guarantee this information is up-to-date.- Specified by:
getSpecifiedin interfaceAttr
-
getValue
Description copied from interface:AttrOn retrieval, the value of the attribute is returned as a string. Character and general entity references are replaced with their values. See also the methodgetAttributeon theElementinterface.
On setting, this creates aTextnode 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 methodElement.setAttribute().
Some specialized implementations, such as some [SVG 1.1] implementations, may do normalization automatically, even after mutation; in such case, the value on retrieval may differ from the value on setting. -
setPrefix
Description copied from interface:NodeThe namespace prefix of this node, ornullif it is unspecified. When it is defined to benull, setting it has no effect, including if the node is read-only.
Note that setting this attribute, when permitted, changes thenodeNameattribute, which holds the qualified name, as well as thetagNameandnameattributes of theElementandAttrinterfaces, when applicable.
Setting the prefix tonullmakes it unspecified, setting it to an empty string is implementation dependent.
Note also that changing the prefix of an attribute that is known to have a default value, does not make a new attribute with the default value and the original prefix appear, since thenamespaceURIandlocalNamedo not change.
For nodes of any type other thanELEMENT_NODEandATTRIBUTE_NODEand nodes created with a DOM Level 1 method, such ascreateElementfrom theDocumentinterface, this is alwaysnull. -
setValue
Description copied from interface:AttrOn retrieval, the value of the attribute is returned as a string. Character and general entity references are replaced with their values. See also the methodgetAttributeon theElementinterface.
On setting, this creates aTextnode 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 methodElement.setAttribute().
Some specialized implementations, such as some [SVG 1.1] implementations, may do normalization automatically, even after mutation; in such case, the value on retrieval may differ from the value on setting.- Specified by:
setValuein interfaceAttr- Throws:
DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
-
getSchemaTypeInfo
Description copied from interface:AttrThe type information associated with this attribute. While the type information contained in this attribute is guarantee to be correct after loading the document or invokingDocument.normalizeDocument(),schemaTypeInfomay not be reliable if the node was moved.- Specified by:
getSchemaTypeInfoin interfaceAttr
-
isId
public boolean isId()Description copied from interface:AttrReturns 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, theownerElementof 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. - If validation
occurred using an XML Schema [XML Schema Part 1]
while loading the document or while invoking
-