Class AbstractItem
- All Implemented Interfaces:
Serializable,Cloneable,Node,Item
- Direct Known Subclasses:
AbstractGroup,AbstractTextual,Attribute,DocType,ProcessingInstruction
Important methods that the deriving might want to override.
- Item.getName
- It must be overridden to provide a local name.
- Item.setName
- Override it if it allows to change the name. Default: throws an exception.
- Item.getText
- Override it if it has a text representation. Default: returns null.
- Item.setText
- Override it if it allows to change the text. Default: throws an exception.
- Node.getNodeType
- It must be overridden to provide the type.
- Item.clone
- Override it if any other members to handle specially. Note: by definition, we do deep clone only.
- Object.toString
- Override if you want a representation other than XMLOutputter does.
- Author:
- tomyeh
- See Also:
-
Field Summary
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 TypeMethodDescriptionappendChild(Node newChild) clone()Clones this object (a deep cloning not including contents contained in Textual nodes).final NodecloneNode(boolean deep) shortcompareDocumentPosition(Node other) detach()Detach this item from its parent.final booleanOverriding this method is prohibited.Gets the document that owns this item.getFeature(String feature, String version) final LocatorGets the locator of this item.final Nodefinal GroupGets the parent item.final Nodefinal NodegetText()getUserData(String key) booleanbooleanfinal inthashCode()Overriding this method is prohibited.insertBefore(Node newChild, Node refChild) booleanisDefaultNamespace(String namespaceURI) booleanisEqualNode(Node arg) booleanisSameNode(Node other) final booleanisSupported(String feature, String version) lookupNamespaceURI(String prefix) lookupPrefix(String namespaceURI) protected static booleanmatch(Namespaceable vtx, String namespace, String name, Pattern ptn, int mode) Tests whether a namespaceable item matches the criteria.final voidremoveChild(Node oldChild) replaceChild(Node newChild, Node oldChild) final voidsetLocator(Locator loc) Sets the locator of this item.voidSets the name of the item.voidsetNodeValue(String nodeValue) voidSets the parent item.voidvoidSets the text of this item.voidsetTextContent(String textContent) setUserData(String key, Object data, UserDataHandler handler) Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.w3c.dom.Node
getNodeType
-
Constructor Details
-
AbstractItem
protected AbstractItem()Constructor.
-
-
Method Details
-
match
protected static boolean match(Namespaceable vtx, String namespace, String name, Pattern ptn, int mode) Tests whether a namespaceable item matches the criteria. If mode don't contain FIND_BY_REGEX, ptn is ignored. -
setName
Description copied from interface:ItemSets the name of the item. For vertices that support namespace (implements Namespaceable), it is the same as setTagName. -
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.
-
setText
Description copied from interface:ItemSets the text of this item. -
getDocument
Description copied from interface:ItemGets the document that owns this item. The owning document is the first document in its ancestor. For DOM, the document can only be the root, so the owning documents of vertices in a DOM tree are all the same.- Specified by:
getDocumentin interfaceItem
-
detach
Description copied from interface:ItemDetach this item from its parent.Because each item can belong to at most one parent at a time, it is important to detach it first, before added to another tree -- even if it is the same tree/parent.
It has the similar effect as:
getParent().getChildren().remove(this).Naming reason: we don't call this method as getChildren() to be compatible with the naming style of Attributable.attributes -- which is limited to org.w3c.dom.Attr.getAttributes. Also, it doesn't have the setter and it is "live", so it 'seem' better to call it getChildren().
-
getParent
Description copied from interface:ItemGets the parent item. -
setParent
Description copied from interface:ItemSets the parent item.DO NOT call this method. It is used internally. Instead, use detach or thru getChildren().
-
getLocator
Description copied from interface:ItemGets the locator of this item.- Specified by:
getLocatorin interfaceItem- Returns:
- the locator; null if not available (default)
-
setLocator
Description copied from interface:ItemSets the locator of this item.Unlike other methods, it won't change the modification flag.
- Specified by:
setLocatorin interfaceItem- Parameters:
loc- the locator; null if not available
-
getNodeName
- Specified by:
getNodeNamein interfaceNode
-
getNodeValue
- Specified by:
getNodeValuein interfaceNode
-
setNodeValue
- Specified by:
setNodeValuein interfaceNode
-
getOwnerDocument
- Specified by:
getOwnerDocumentin interfaceNode
-
cloneNode
-
getParentNode
- Specified by:
getParentNodein interfaceNode
-
getPreviousSibling
- Specified by:
getPreviousSiblingin interfaceNode
-
getNextSibling
- Specified by:
getNextSiblingin interfaceNode
-
getChildNodes
- Specified by:
getChildNodesin interfaceNode
-
getFirstChild
- Specified by:
getFirstChildin interfaceNode
-
getLastChild
- Specified by:
getLastChildin interfaceNode
-
hasChildNodes
public boolean hasChildNodes()- Specified by:
hasChildNodesin interfaceNode
-
insertBefore
- Specified by:
insertBeforein interfaceNode
-
replaceChild
- Specified by:
replaceChildin interfaceNode
-
removeChild
- Specified by:
removeChildin interfaceNode
-
appendChild
- Specified by:
appendChildin interfaceNode
-
normalize
public final void normalize() -
isSupported
- Specified by:
isSupportedin interfaceNode
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceNode
-
getPrefix
-
getLocalName
- Specified by:
getLocalNamein interfaceNode
-
setPrefix
-
getAttributes
- Specified by:
getAttributesin interfaceNode
-
hasAttributes
public boolean hasAttributes()- Specified by:
hasAttributesin interfaceNode
-
getBaseURI
- Specified by:
getBaseURIin interfaceNode
-
compareDocumentPosition
- Specified by:
compareDocumentPositionin interfaceNode- Throws:
DOMException
-
getTextContent
- Specified by:
getTextContentin interfaceNode- Throws:
DOMException
-
setTextContent
- Specified by:
setTextContentin interfaceNode- Throws:
DOMException
-
isSameNode
- Specified by:
isSameNodein interfaceNode
-
lookupPrefix
- Specified by:
lookupPrefixin interfaceNode
-
isDefaultNamespace
- Specified by:
isDefaultNamespacein interfaceNode
-
lookupNamespaceURI
- Specified by:
lookupNamespaceURIin interfaceNode
-
isEqualNode
- Specified by:
isEqualNodein interfaceNode
-
getFeature
- Specified by:
getFeaturein interfaceNode
-
setUserData
- Specified by:
setUserDatain interfaceNode
-
getUserData
- Specified by:
getUserDatain interfaceNode
-
equals
Overriding this method is prohibited. -
hashCode
public final int hashCode()Overriding this method is prohibited. -
clone
Clones 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).
-