public class Attribute extends AbstractItem implements Namespaceable, Attr
Design decision: Attribute is also a item. The reason is it simplifies the use of XPath. An XPath might return either elements or attributes, so...
Element,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected String |
_lname
The local name.
|
protected Namespace |
_ns
The namespace.
|
protected Item |
_owner
The owner item.
|
protected String |
_value
The value.
|
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_NODEFIND_BY_PREFIX, FIND_BY_REGEX, FIND_BY_TAGNAME, FIND_IGNORE_CASE, FIND_RECURSIVE| Modifier | Constructor and Description |
|---|---|
protected |
Attribute()
Constructor.
|
|
Attribute(Namespace ns,
String lname,
String value)
Constructor.
|
|
Attribute(String lname,
String value)
Constructor.
|
|
Attribute(String nsURI,
String tname,
String value)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Clones this object (a deep cloning not including contents contained
in Textual nodes).
|
Item |
detach()
Detach the attribute from its owner, if any.
|
Document |
getDocument()
Gets the document that owns this attribute.
|
String |
getLocalName()
Gets the local name of this item.
|
String |
getName()
Gets the name of the item.
|
Namespace |
getNamespace()
Gets the namespace.
|
String |
getNamespaceURI() |
short |
getNodeType() |
Item |
getOwner()
Gets the item that owns this attribute.
|
Document |
getOwnerDocument() |
Element |
getOwnerElement() |
String |
getPrefix() |
TypeInfo |
getSchemaTypeInfo() |
boolean |
getSpecified() |
String |
getTagName()
Gets the tag name of this item.
|
String |
getText()
|
String |
getValue()
Gets the value of this attribute.
|
boolean |
isId() |
void |
setLocalName(String lname)
Sets the local name of this attribute.
|
void |
setName(String tname)
Sets the name of the item.
|
void |
setNamespace(Namespace ns)
Sets the namespace.
|
void |
setNamespace(String prefix,
String nsURI)
Sets the namespace.
|
void |
setOwner(Item owner)
Sets the item that owns this attribute.
|
void |
setParent(Item parent) |
void |
setPrefix(String prefix)
Sets the namespace prefix of this attribute.
|
void |
setTagName(String tname)
Sets the tag name.
|
void |
setText(String text)
Sets the text of this item.
|
void |
setValue(String value)
Sets the value of this attribute.
|
String |
toString() |
appendChild, cloneNode, compareDocumentPosition, equals, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocator, getNextSibling, getNodeName, getNodeValue, getParent, getParentNode, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, hashCode, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, match, normalize, removeChild, replaceChild, setLocator, setNodeValue, setParent, setTextContent, setUserDatafinalize, getClass, notify, notifyAll, wait, wait, waitappendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getNextSibling, getNodeName, getNodeValue, getParentNode, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setTextContent, setUserDataprotected Namespace _ns
protected Item _owner
protected String _lname
protected String _value
public Attribute(String nsURI, String tname, String value)
Note: According to W3/DOM, the namespace of attributes must have a prefix if the uri is not empty.
nsURI - the namespace URItname - the tag namepublic Attribute(Namespace ns, String lname, String value)
ns - the namespacelname - the local nameprotected Attribute()
public final String getValue()
public final void setValue(String value)
public final Item getOwner()
public final void setOwner(Item owner)
DO NOT call this method. It is used internally. For user's point of view, the owner item is maintained automatically, so user never needs to update it.
public final void setNamespace(Namespace ns)
According W3C/DOM, unlike element, an attribute doesn't allow a namespace that has an URI but without a prefix.
setNamespace in interface Namespaceablepublic final Namespace getNamespace()
NamespaceablegetNamespace in interface Namespaceablepublic final String getTagName()
NamespaceableTo get the local name (the name without prefix), Namespaceable.getLocalName could be used.
getTagName in interface Namespaceablepublic final void setTagName(String tname)
Changing a name improperly might cause replicated attribute names which won't be detected by this method.
setTagName in interface Namespaceablepublic final String getLocalName()
NamespaceableTo get the tag name (the name with prefix), Namespaceable.getTagName could be used.
getLocalName in interface NodegetLocalName in interface NamespaceablegetLocalName in class AbstractItempublic final void setLocalName(String lname)
Changing a name improperly might cause replicated attribute names which won't be detected by this method.
setLocalName in interface Namespaceablepublic final String getName()
ItemgetName in interface AttrgetName in interface ItemNamespaceable.getTagName()public final void setName(String tname)
ItemsetName in interface ItemsetName in class AbstractItemNamespaceable.setTagName(java.lang.String)public final String getText()
ItemTextual
nor Element.
For Element, the text is the concatenation of all its textual
children, including Text, CDATA, and Binary.
Besides String-type value, some item, e.g., Binary, allows any type of objects. Caller could test whether a item implements the Binable interface, and use Binable.getValue instead. For binable vertices, getText is actually getValue().toString().
The returned value is neither trimmed nor normalized.
getText in interface ItemgetText in class AbstractItempublic final void setText(String text)
ItemsetText in interface ItemsetText in class AbstractItempublic final Document getDocument()
getDocument in interface ItemgetDocument in class AbstractItempublic Item detach()
detach in interface Itemdetach in class AbstractItempublic void setParent(Item parent)
public final short getNodeType()
getNodeType in interface Nodepublic final Document getOwnerDocument()
getOwnerDocument in interface NodegetOwnerDocument in class AbstractItempublic final String getNamespaceURI()
getNamespaceURI in interface NodegetNamespaceURI in class AbstractItempublic final String getPrefix()
getPrefix in interface NodegetPrefix in class AbstractItempublic final void setPrefix(String prefix)
Changing a prefix improperly might cause replicated attribute names which won't be detected by this method.
setPrefix in interface NodesetPrefix in class AbstractItempublic TypeInfo getSchemaTypeInfo()
getSchemaTypeInfo in interface Attrpublic final boolean getSpecified()
getSpecified in interface Attrpublic final Element getOwnerElement()
getOwnerElement in interface Attrpublic Object clone()
AbstractItemclone in interface Itemclone in class AbstractItemCopyright © 2018. All rights reserved.