public class Attribute extends AbstractItem implements Namespaceable, org.w3c.dom.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 FormModifier and Type | Field and Description |
---|---|
protected java.lang.String |
_lname
The local name.
|
protected Namespace |
_ns
The namespace.
|
protected Item |
_owner
The owner item.
|
protected java.lang.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_NODE
FIND_BY_PREFIX, FIND_BY_REGEX, FIND_BY_TAGNAME, FIND_IGNORE_CASE, FIND_RECURSIVE
Modifier | Constructor and Description |
---|---|
protected |
Attribute()
Constructor.
|
|
Attribute(Namespace ns,
java.lang.String lname,
java.lang.String value)
Constructor.
|
|
Attribute(java.lang.String lname,
java.lang.String value)
Constructor.
|
|
Attribute(java.lang.String nsURI,
java.lang.String tname,
java.lang.String value)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.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.
|
java.lang.String |
getLocalName()
Gets the local name of this item.
|
java.lang.String |
getName()
Gets the name of the item.
|
Namespace |
getNamespace()
Gets the namespace.
|
java.lang.String |
getNamespaceURI() |
short |
getNodeType() |
Item |
getOwner()
Gets the item that owns this attribute.
|
org.w3c.dom.Document |
getOwnerDocument() |
org.w3c.dom.Element |
getOwnerElement() |
java.lang.String |
getPrefix() |
org.w3c.dom.TypeInfo |
getSchemaTypeInfo() |
boolean |
getSpecified() |
java.lang.String |
getTagName()
Gets the tag name of this item.
|
java.lang.String |
getText()
|
java.lang.String |
getValue()
Gets the value of this attribute.
|
boolean |
isId() |
void |
setLocalName(java.lang.String lname)
Sets the local name of this attribute.
|
void |
setName(java.lang.String tname)
Sets the name of the item.
|
void |
setNamespace(Namespace ns)
Sets the namespace.
|
void |
setNamespace(java.lang.String prefix,
java.lang.String nsURI)
Sets the namespace.
|
void |
setOwner(Item owner)
Sets the item that owns this attribute.
|
void |
setParent(Item parent) |
void |
setPrefix(java.lang.String prefix)
Sets the namespace prefix of this attribute.
|
void |
setTagName(java.lang.String tname)
Sets the tag name.
|
void |
setText(java.lang.String text)
Sets the text of this item.
|
void |
setValue(java.lang.String value)
Sets the value of this attribute.
|
java.lang.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, setUserData
finalize, getClass, notify, notifyAll, wait, wait, wait
appendChild, 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, setUserData
protected Namespace _ns
protected Item _owner
protected java.lang.String _lname
protected java.lang.String _value
public Attribute(java.lang.String nsURI, java.lang.String tname, java.lang.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, java.lang.String lname, java.lang.String value)
ns
- the namespacelname
- the local namepublic Attribute(java.lang.String lname, java.lang.String value)
protected Attribute()
public final java.lang.String getValue()
getValue
in interface org.w3c.dom.Attr
public final void setValue(java.lang.String value)
setValue
in interface org.w3c.dom.Attr
value
- the new value; null is considered as emptypublic 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(java.lang.String prefix, java.lang.String nsURI)
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 Namespaceable
public final Namespace getNamespace()
Namespaceable
getNamespace
in interface Namespaceable
public final java.lang.String getTagName()
Namespaceable
To get the local name (the name without prefix), Namespaceable.getLocalName could be used.
getTagName
in interface Namespaceable
public final void setTagName(java.lang.String tname)
Changing a name improperly might cause replicated attribute names which won't be detected by this method.
setTagName
in interface Namespaceable
public final java.lang.String getLocalName()
Namespaceable
To get the tag name (the name with prefix), Namespaceable.getTagName could be used.
getLocalName
in interface org.w3c.dom.Node
getLocalName
in interface Namespaceable
getLocalName
in class AbstractItem
public final void setLocalName(java.lang.String lname)
Changing a name improperly might cause replicated attribute names which won't be detected by this method.
setLocalName
in interface Namespaceable
public final java.lang.String getName()
Item
getName
in interface org.w3c.dom.Attr
getName
in interface Item
Namespaceable.getTagName()
public final void setName(java.lang.String tname)
Item
setName
in interface Item
setName
in class AbstractItem
Namespaceable.setTagName(java.lang.String)
public final java.lang.String getText()
Item
Textual
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 Item
getText
in class AbstractItem
public final void setText(java.lang.String text)
Item
setText
in interface Item
setText
in class AbstractItem
public final Document getDocument()
getDocument
in interface Item
getDocument
in class AbstractItem
public Item detach()
detach
in interface Item
detach
in class AbstractItem
public void setParent(Item parent)
public final short getNodeType()
getNodeType
in interface org.w3c.dom.Node
public final org.w3c.dom.Document getOwnerDocument()
getOwnerDocument
in interface org.w3c.dom.Node
getOwnerDocument
in class AbstractItem
public final java.lang.String getNamespaceURI()
getNamespaceURI
in interface org.w3c.dom.Node
getNamespaceURI
in class AbstractItem
public final java.lang.String getPrefix()
getPrefix
in interface org.w3c.dom.Node
getPrefix
in class AbstractItem
public final void setPrefix(java.lang.String prefix)
Changing a prefix improperly might cause replicated attribute names which won't be detected by this method.
setPrefix
in interface org.w3c.dom.Node
setPrefix
in class AbstractItem
public org.w3c.dom.TypeInfo getSchemaTypeInfo()
getSchemaTypeInfo
in interface org.w3c.dom.Attr
public boolean isId()
isId
in interface org.w3c.dom.Attr
public final boolean getSpecified()
getSpecified
in interface org.w3c.dom.Attr
public final org.w3c.dom.Element getOwnerElement()
getOwnerElement
in interface org.w3c.dom.Attr
public final java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object clone()
AbstractItem
clone
in interface Item
clone
in class AbstractItem
Copyright © 2005-2011 Potix Corporation. All Rights Reserved.