|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.zkoss.idom.impl.AbstractItem
public abstract class AbstractItem
A semi-implemented item for leaf vertices. A leaf item is a item without any children. For cores having child cores, use Group.
Important methods that the deriving might want to override.
Item
,
Serialized FormField Summary | |
---|---|
protected boolean |
_modified
The modification flag. |
Fields inherited from interface org.zkoss.idom.Item |
---|
FIND_BY_PREFIX, FIND_BY_REGEX, FIND_BY_TAGNAME, FIND_IGNORE_CASE, FIND_RECURSIVE |
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 |
Constructor Summary | |
---|---|
protected |
AbstractItem()
Constructor. |
Method Summary | |
---|---|
org.w3c.dom.Node |
appendChild(org.w3c.dom.Node newChild)
|
protected void |
checkWritable()
Checks whether this item is writable (ie, isReady). |
void |
clearModified(boolean includingDescendant)
Clears the modification flag of this item and all its children if includingDescendant is true. |
java.lang.Object |
clone()
Clones this object (a deep cloning not including contents contained in Textual nodes). |
Item |
clone(boolean preserveModified)
Clones this item. |
org.w3c.dom.Node |
cloneNode(boolean deep)
|
short |
compareDocumentPosition(org.w3c.dom.Node other)
|
Item |
detach()
Detach this item from its parent. |
boolean |
equals(java.lang.Object o)
Overriding this method is prohibited. |
org.w3c.dom.NamedNodeMap |
getAttributes()
|
java.lang.String |
getBaseURI()
|
org.w3c.dom.NodeList |
getChildNodes()
|
Document |
getDocument()
Gets the document that owns this item. |
java.lang.Object |
getFeature(java.lang.String feature,
java.lang.String version)
|
org.w3c.dom.Node |
getFirstChild()
|
org.w3c.dom.Node |
getLastChild()
|
java.lang.String |
getLocalName()
|
Locator |
getLocator()
Gets the locator of this item. |
java.lang.String |
getNamespaceURI()
|
org.w3c.dom.Node |
getNextSibling()
|
java.lang.String |
getNodeName()
|
java.lang.String |
getNodeValue()
|
org.w3c.dom.Document |
getOwnerDocument()
|
Group |
getParent()
Gets the parent item. |
org.w3c.dom.Node |
getParentNode()
|
java.lang.String |
getPrefix()
|
org.w3c.dom.Node |
getPreviousSibling()
|
java.lang.String |
getText()
Gets the text of this item, or null if it is neither Textual
nor Element . |
java.lang.String |
getTextContent()
|
java.lang.Object |
getUserData(java.lang.String key)
|
boolean |
hasAttributes()
|
boolean |
hasChildNodes()
|
int |
hashCode()
Overriding this method is prohibited. |
org.w3c.dom.Node |
insertBefore(org.w3c.dom.Node newChild,
org.w3c.dom.Node refChild)
|
boolean |
isDefaultNamespace(java.lang.String namespaceURI)
|
boolean |
isEqualNode(org.w3c.dom.Node arg)
|
boolean |
isModified()
Tests whether this item (or any of its children) is modified, i.e., the modification flag is set. |
boolean |
isReadonly()
Tests whether this item is read-only. |
boolean |
isSameNode(org.w3c.dom.Node other)
|
boolean |
isSupported(java.lang.String feature,
java.lang.String version)
|
java.lang.String |
lookupNamespaceURI(java.lang.String prefix)
|
java.lang.String |
lookupPrefix(java.lang.String namespaceURI)
|
protected static boolean |
match(Namespaceable vtx,
java.lang.String namespace,
java.lang.String name,
java.util.regex.Pattern ptn,
int mode)
Tests whether a namespaceable item matches the criteria. |
void |
normalize()
|
org.w3c.dom.Node |
removeChild(org.w3c.dom.Node oldChild)
|
org.w3c.dom.Node |
replaceChild(org.w3c.dom.Node newChild,
org.w3c.dom.Node oldChild)
|
void |
setLocator(Locator loc)
Sets the locator of this item. |
void |
setModified()
Sets the modification flag. |
void |
setName(java.lang.String name)
Sets the name of the item. |
void |
setNodeValue(java.lang.String nodeValue)
|
void |
setParent(Group parent)
Sets the parent item. |
void |
setPrefix(java.lang.String prefix)
|
void |
setReadonly(boolean readonly)
Sets the read-only flag of this item. |
void |
setText(java.lang.String text)
Sets the text of this item. |
void |
setTextContent(java.lang.String textContent)
|
java.lang.Object |
setUserData(java.lang.String key,
java.lang.Object data,
org.w3c.dom.UserDataHandler handler)
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.zkoss.idom.Item |
---|
getName |
Methods inherited from interface org.w3c.dom.Node |
---|
getNodeType |
Field Detail |
---|
protected transient boolean _modified
Constructor Detail |
---|
protected AbstractItem()
Method Detail |
---|
protected final void checkWritable()
DOMException
- with NO_MODIFICATION_ALLOWED_ERR if not writableprotected static boolean match(Namespaceable vtx, java.lang.String namespace, java.lang.String name, java.util.regex.Pattern ptn, int mode)
public boolean isReadonly()
Item
Item.setReadonly(boolean)
)
or any of its ancestor is read-only (i.e., the read-only flag is set).
isReadonly
in interface Item
public void setReadonly(boolean readonly)
isReadonly()
.
Deriving class might restrict more conditions here.
setReadonly
in interface Item
public boolean isModified()
Item
IDOM is smart enough to set the modification flag only if it is really modified -- i.e., assigning a different value (not just calling any setter).
When an object is serialized, the modification flag is reset.
Also, an object generated by Item.clone(boolean)
with
preservedModified==false has also no modification flag set.
isModified
in interface Item
public void clearModified(boolean includingDescendant)
Item
Unlike other methods, it doesn't affected by the read-only flag.
clearModified
in interface Item
includingDescendant
- whether to clear the modified flags
of descendantspublic void setModified()
Item
Item.clearModified(boolean)
, it won't set
children's modification flags, rather it sets its parent's modification
flag.
The modifiaction flag is maintain automatically, so you rarely needs to call this method.
Unlike other methods, it doesn't affected by the read-only flag.
setModified
in interface Item
public void setName(java.lang.String name)
Item
setName
in interface Item
Namespaceable.setTagName(java.lang.String)
public java.lang.String getText()
Item
Textual
nor Element
.
For Element, the text is the catenation 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
public void setText(java.lang.String text)
Item
setText
in interface Item
public Document getDocument()
Item
getDocument
in interface Item
public Item detach()
Item
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().
detach
in interface Item
public Item clone(boolean preserveModified)
Item
clone
in interface Item
public final Group getParent()
Item
getParent
in interface Item
public void setParent(Group parent)
Item
DO NOT call this method. It is used internally. Instead, use detach or thru getChildren().
setParent
in interface Item
public final Locator getLocator()
Item
getLocator
in interface Item
public final void setLocator(Locator loc)
Item
Unlike other methods, it won't change the modification flag.
setLocator
in interface Item
loc
- the locator; null if not availablepublic java.lang.String getNodeName()
getNodeName
in interface org.w3c.dom.Node
public java.lang.String getNodeValue()
getNodeValue
in interface org.w3c.dom.Node
public void setNodeValue(java.lang.String nodeValue)
setNodeValue
in interface org.w3c.dom.Node
public org.w3c.dom.Document getOwnerDocument()
getOwnerDocument
in interface org.w3c.dom.Node
public final org.w3c.dom.Node cloneNode(boolean deep)
cloneNode
in interface org.w3c.dom.Node
public final org.w3c.dom.Node getParentNode()
getParentNode
in interface org.w3c.dom.Node
public final org.w3c.dom.Node getPreviousSibling()
getPreviousSibling
in interface org.w3c.dom.Node
public final org.w3c.dom.Node getNextSibling()
getNextSibling
in interface org.w3c.dom.Node
public org.w3c.dom.NodeList getChildNodes()
getChildNodes
in interface org.w3c.dom.Node
public org.w3c.dom.Node getFirstChild()
getFirstChild
in interface org.w3c.dom.Node
public org.w3c.dom.Node getLastChild()
getLastChild
in interface org.w3c.dom.Node
public boolean hasChildNodes()
hasChildNodes
in interface org.w3c.dom.Node
public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
insertBefore
in interface org.w3c.dom.Node
public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)
replaceChild
in interface org.w3c.dom.Node
public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
removeChild
in interface org.w3c.dom.Node
public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
appendChild
in interface org.w3c.dom.Node
public final void normalize()
normalize
in interface org.w3c.dom.Node
public final boolean isSupported(java.lang.String feature, java.lang.String version)
isSupported
in interface org.w3c.dom.Node
public java.lang.String getNamespaceURI()
getNamespaceURI
in interface org.w3c.dom.Node
public java.lang.String getPrefix()
getPrefix
in interface org.w3c.dom.Node
public java.lang.String getLocalName()
getLocalName
in interface org.w3c.dom.Node
public void setPrefix(java.lang.String prefix)
setPrefix
in interface org.w3c.dom.Node
public org.w3c.dom.NamedNodeMap getAttributes()
getAttributes
in interface org.w3c.dom.Node
public boolean hasAttributes()
hasAttributes
in interface org.w3c.dom.Node
public java.lang.String getBaseURI()
getBaseURI
in interface org.w3c.dom.Node
public short compareDocumentPosition(org.w3c.dom.Node other) throws DOMException
compareDocumentPosition
in interface org.w3c.dom.Node
DOMException
public java.lang.String getTextContent() throws DOMException
getTextContent
in interface org.w3c.dom.Node
DOMException
public void setTextContent(java.lang.String textContent) throws DOMException
setTextContent
in interface org.w3c.dom.Node
DOMException
public boolean isSameNode(org.w3c.dom.Node other)
isSameNode
in interface org.w3c.dom.Node
public java.lang.String lookupPrefix(java.lang.String namespaceURI)
lookupPrefix
in interface org.w3c.dom.Node
public boolean isDefaultNamespace(java.lang.String namespaceURI)
isDefaultNamespace
in interface org.w3c.dom.Node
public java.lang.String lookupNamespaceURI(java.lang.String prefix)
lookupNamespaceURI
in interface org.w3c.dom.Node
public boolean isEqualNode(org.w3c.dom.Node arg)
isEqualNode
in interface org.w3c.dom.Node
public java.lang.Object getFeature(java.lang.String feature, java.lang.String version)
getFeature
in interface org.w3c.dom.Node
public java.lang.Object setUserData(java.lang.String key, java.lang.Object data, org.w3c.dom.UserDataHandler handler)
setUserData
in interface org.w3c.dom.Node
public java.lang.Object getUserData(java.lang.String key)
getUserData
in interface org.w3c.dom.Node
public final boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
public java.lang.Object clone()
clone
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |