|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Item
Represents an item (aka., node) of a iDOM tree. A iDOM tree is not necessary also a W3C/DOM tree. However, in iDOM's implement, it is because all Vertices also implement related interface, such as Node.
Some vertices, currently only Element, might support attributes by implementing Attributable.
Due to the implementation of both Item and W3C/DOM's interfaces, many methods seem redudant (e.g., parent vs. getParentNode, and children vs. getChildNodes). Caller could use them interchangeably . However, it is suggested to use Item's API instead of Node's, because, like JDOM, Item's API is based Java collection classes and more consistent (from my point of view). The W3C/DOM API is used to work with utilities that work only with W3C/DOM.
Be carefult that some methods look similar, but behave different. Refer to package.html.
Attributable
,
Binable
Field Summary | |
---|---|
static int |
FIND_BY_PREFIX
Indicates the namespace argument is a prefix rather than URI. |
static int |
FIND_BY_REGEX
Indicates the searching is based on regular expression (upon the name argument). |
static int |
FIND_BY_TAGNAME
Indicates the name argument is a tag name rather than local name. |
static int |
FIND_IGNORE_CASE
Indicates the searching is case insensitive. |
static int |
FIND_RECURSIVE
Indicates the searching looks for all descendants. |
Method Summary | |
---|---|
void |
clearModified(boolean includingDescendant)
Clears the modification flag of this item and all its children if includingDescendant is true. |
Item |
clone(boolean preserveModified)
Clones this item. |
Item |
detach()
Detach this item from its parent. |
Document |
getDocument()
Gets the document that owns this item. |
Locator |
getLocator()
Gets the locator of this item. |
java.lang.String |
getName()
Gets the name of the item. |
Group |
getParent()
Gets the parent item. |
java.lang.String |
getText()
Gets the text of this item, or null if it is neither Textual
nor Element . |
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. |
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 |
setParent(Group parent)
Sets the parent item. |
void |
setReadonly(boolean readonly)
Sets the read-only flag of this item. |
void |
setText(java.lang.String obj)
Sets the text of this item. |
Field Detail |
---|
static final int FIND_BY_REGEX
static final int FIND_IGNORE_CASE
static final int FIND_BY_TAGNAME
static final int FIND_BY_PREFIX
static final int FIND_RECURSIVE
Method Detail |
---|
boolean isReadonly()
setReadonly(boolean)
)
or any of its ancestor is read-only (i.e., the read-only flag is set).
void setReadonly(boolean readonly)
isReadonly()
.
java.lang.String getName()
Namespaceable.getTagName()
void setName(java.lang.String name)
DOMException
- with NOT_SUPPORTED_ERR if this item
doesn't allow to change the name, e.g., Document and DocTypeNamespaceable.setTagName(java.lang.String)
java.lang.String getText()
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.
void setText(java.lang.String obj)
DOMException
- with NOT_SUPPORTED_ERR if this item
doesn't allow to change the value, e.g., Document and ElementDocument getDocument()
Item detach()
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().
Group getParent()
Locator getLocator()
void setLocator(Locator loc)
Unlike other methods, it won't change the modification flag.
loc
- the locator; null if not availableItem clone(boolean preserveModified)
boolean isModified()
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 clone(boolean)
with
preservedModified==false has also no modification flag set.
void clearModified(boolean includingDescendant)
Unlike other methods, it doesn't affected by the read-only flag.
includingDescendant
- whether to clear the modified flags
of descendantsvoid setModified()
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.
void setParent(Group parent)
DO NOT call this method. It is used internally. Instead, use detach or thru getChildren().
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |