Class Attribute
- All Implemented Interfaces:
Serializable,Cloneable,Attr,Node,Item,Namespaceable
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...
- Author:
- tomyeh
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe local name.protected NamespaceThe namespace.protected ItemThe owner item.protected StringThe value.Fields inherited from interface org.zkoss.idom.Item
FIND_BY_PREFIX, FIND_BY_REGEX, FIND_BY_TAGNAME, FIND_IGNORE_CASE, FIND_RECURSIVEFields 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Clones this object (a deep cloning not including contents contained in Textual nodes).detach()Detach the attribute from its owner, if any.final DocumentGets the document that owns this attribute.final StringGets the local name of this item.final StringgetName()Gets the name of the item.final NamespaceGets the namespace.final Stringfinal shortfinal ItemgetOwner()Gets the item that owns this attribute.final Documentfinal Elementfinal Stringfinal booleanfinal StringGets the tag name of this item.final StringgetText()final StringgetValue()Gets the value of this attribute.booleanisId()final voidsetLocalName(String lname) Sets the local name of this attribute.final voidSets the name of the item.final voidsetNamespace(String prefix, String nsURI) Sets the namespace.final voidSets the namespace.final voidSets the item that owns this attribute.voidfinal voidSets the namespace prefix of this attribute.final voidsetTagName(String tname) Sets the tag name.final voidSets the text of this item.final voidSets the value of this attribute.final StringtoString()Methods inherited from class org.zkoss.idom.impl.AbstractItem
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, setUserDataMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.w3c.dom.Node
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
-
Field Details
-
_ns
The namespace. -
_owner
The owner item. -
_lname
The local name. -
_value
The value.
-
-
Constructor Details
-
Attribute
Constructor.Note: According to W3/DOM, the namespace of attributes must have a prefix if the uri is not empty.
- Parameters:
nsURI- the namespace URItname- the tag name
-
Attribute
Constructor.- Parameters:
ns- the namespacelname- the local name
-
Attribute
Constructor. -
Attribute
protected Attribute()Constructor.
-
-
Method Details
-
getValue
Gets the value of this attribute. -
setValue
Sets the value of this attribute. According to Section 3.3.3 of XML 1.0 spec, the value is always normalized. Whether to trim depends on whether an attribute is CDATA (default). In this version, we don't normalize or trim (i.e., consider it as CDATA). -
getOwner
Gets the item that owns this attribute. -
setOwner
Sets the item that owns this attribute.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.
-
setNamespace
Sets the namespace. -
setNamespace
Sets the namespace.According W3C/DOM, unlike element, an attribute doesn't allow a namespace that has an URI but without a prefix.
- Specified by:
setNamespacein interfaceNamespaceable
-
getNamespace
Description copied from interface:NamespaceableGets the namespace.- Specified by:
getNamespacein interfaceNamespaceable- Returns:
- the namespace; never null
-
getTagName
Description copied from interface:NamespaceableGets the tag name of this item. The tag name is also called the fully qualified name -- the name with the namespace prefix, e.g., prefix:name.To get the local name (the name without prefix), Namespaceable.getLocalName could be used.
- Specified by:
getTagNamein interfaceNamespaceable
-
setTagName
Sets the tag name.Changing a name improperly might cause replicated attribute names which won't be detected by this method.
- Specified by:
setTagNamein interfaceNamespaceable
-
getLocalName
Description copied from interface:NamespaceableGets the local name of this item. The local name is the name without prefix.To get the tag name (the name with prefix), Namespaceable.getTagName could be used.
- Specified by:
getLocalNamein interfaceNamespaceable- Specified by:
getLocalNamein interfaceNode- Overrides:
getLocalNamein classAbstractItem
-
setLocalName
Sets the local name of this attribute.Changing a name improperly might cause replicated attribute names which won't be detected by this method.
- Specified by:
setLocalNamein interfaceNamespaceable
-
getName
Description copied from interface:ItemGets the name of the item. For vertices that support namespace (implements Namespaceable), it is the same as getTagName. -
setName
Description copied from interface:ItemSets the name of the item. For vertices that support namespace (implements Namespaceable), it is the same as setTagName.- Specified by:
setNamein interfaceItem- Overrides:
setNamein classAbstractItem- See Also:
-
getText
Description copied from interface:ItemGets the text of this item, or null if it is neitherTextualnorElement. 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.
- Specified by:
getTextin interfaceItem- Overrides:
getTextin classAbstractItem
-
setText
Description copied from interface:ItemSets the text of this item.- Specified by:
setTextin interfaceItem- Overrides:
setTextin classAbstractItem
-
getDocument
Gets the document that owns this attribute.- Specified by:
getDocumentin interfaceItem- Overrides:
getDocumentin classAbstractItem
-
detach
Detach the attribute from its owner, if any. Only attributes that belongs to no item or the same item are allowed to be added to a item. So, detach is useful to move an attribute out from a item (and then you might add it to another item).- Specified by:
detachin interfaceItem- Overrides:
detachin classAbstractItem- Returns:
- this item
-
setParent
-
getNodeType
public final short getNodeType()- Specified by:
getNodeTypein interfaceNode
-
getOwnerDocument
- Specified by:
getOwnerDocumentin interfaceNode- Overrides:
getOwnerDocumentin classAbstractItem
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceNode- Overrides:
getNamespaceURIin classAbstractItem
-
getPrefix
- Specified by:
getPrefixin interfaceNode- Overrides:
getPrefixin classAbstractItem
-
setPrefix
Sets the namespace prefix of this attribute.Changing a prefix improperly might cause replicated attribute names which won't be detected by this method.
- Specified by:
setPrefixin interfaceNode- Overrides:
setPrefixin classAbstractItem
-
getSchemaTypeInfo
- Specified by:
getSchemaTypeInfoin interfaceAttr
-
isId
public boolean isId() -
getSpecified
public final boolean getSpecified()- Specified by:
getSpecifiedin interfaceAttr
-
getOwnerElement
- Specified by:
getOwnerElementin interfaceAttr
-
toString
-
clone
Description copied from class:AbstractItemClones this object (a deep cloning not including contents contained in Textual nodes). Note: after cloning, the read-only flag always becomes false, and the parent becomes null (i.e., detached).- Specified by:
clonein interfaceItem- Overrides:
clonein classAbstractItem
-