| org.zkoss.idom.Group
All known Subclasses: org.zkoss.idom.impl.AbstractGroup,
Group | public interface Group extends Item(Code) | | Represents an item might have children. Group is also a item.
Developers usually extend new classes from
org.zkoss.idom.impl.AbstractGroup , rather than
implement this interface directly.
Design consideration: we don't support removeChildren and setChild
or alike, because they can be done easily with List's methods and
getAttributeIndex.
author: tomyeh See Also: Item See Also: Attributable See Also: Namespaceable See Also: Binable |
Method Summary | |
public int | coalesce(boolean recursive) Coalesces children if they are siblings with the same type
instances of Textual, Textual.isCoalesceable returns true. | public List | detachChildren() Detaches all children and returns them in a list.
Note: you cannot add children to anther Group by doing
group.addAll(e.getChildren()) , because you have to detach
them first. | public List | getChildren() Gets all children.
The returned list is "live". | public Element | getElement(String namespace, String name, int mode) Gets the first Element-type child that matches the giving criteria.
Note: only Element-type children are returned. | public Element | getElement(String tname) Gets the first Element-type child with the tag name.
It is the same as childOf(nsURI, lname, null, 0).
Note: only Element-type children are returned. | public int | getElementIndex(int indexFrom, String namespace, String name, int mode) Gets the index of the Element-type first child that match the specified
criteria. | public int | getElementIndex(int indexFrom, String tname) Gets the index of the first Element-type child with the specified name. | public Set | getElementNames() Returns a readonly set of names of element children. | public String | getElementValue(String namespace, String name, int mode, boolean trim) Gets the value of the first Element-type child that matches
the giving criteria, with a trimming option. | public String | getElementValue(String tname, boolean trim) Gets the text of the first Element-type child with the tag name,
with a trimming option. | public List | getElements(String namespace, String name, int mode) Gets a readonly list of Element-type children that match the giving
criteria.
Unlike
Element.getElementsByTagName , this method only
returns child elements, excluding grand children and other descedants.
The returned list is a 'live-facade' of the real ones, so
the performance is good, and any modification to
Group.getChildren will affect it.
Note: only Element-type children are returned. | public List | getElements(String tname) Gets a readonly list of children with the tag name.
Unlike
Element.getElementsByTagName , this method only
returns child elements, excluding grand children and other descedants.
The returned list is a 'live-facade' of the real ones, so
the performance is good, and any modification to
Group.getChildren will affect it.
Note: only Element-type children are returned. | public List | getElements() Returns a cloned copy of all element childrens
Unlike
Group.getChildren and
Group.getElementNames ,
the returned list is NOT a 'live-facade' of the real ones. |
coalesce | public int coalesce(boolean recursive)(Code) | | Coalesces children if they are siblings with the same type
instances of Textual, Textual.isCoalesceable returns true.
SAXBuilder.build will do the merging automatically.
Parameters: recursive - true to coalesce all descendants;false to coalesce only the direct children |
detachChildren | public List detachChildren()(Code) | | Detaches all children and returns them in a list.
Note: you cannot add children to anther Group by doing
group.addAll(e.getChildren()) , because you have to detach
them first. Then, you could use this method:
group.addAll(e.detachChildren());
|
getChildren | public List getChildren()(Code) | | Gets all children.
The returned list is "live". Any modification to it affects
the node. On the other hand,
Group.getElements(String) returns
a copy.
Unlike JDOM, it won't coalesce adjacent children automatically
since it might violate the caller's expection about List.
Rather, we provide coalesce to let caller do the merging
explicity.
Note: when building a iDOM tree from a source
(SAXBuilder.build), coalesce() will be inovked automatically.
Note: not all items supports children. If this item doesn't,
it returns an empty list. And, if any invocation tries to add
vertices to the returned list will cause UnsupportOperationException.
|
getElement | public Element getElement(String namespace, String name, int mode)(Code) | | Gets the first Element-type child that matches the giving criteria.
Note: only Element-type children are returned. Depending on
the mode, the searching is usually linear -- take O(n) to complete.
Parameters: namespace - the namspace URI if FIND_BY_PREFIX is not specified;the namespace prefix if FIND_BY_PREFIX specified; null to ingore Parameters: name - the local name if FIND_BY_TAGNAME is not sepcified;the tag name if FIND_BY_TAGNAME specified; null to ignore Parameters: mode - the search mode; zero or any combination of FIND_xxx. the found element; null if not found or not supported |
getElement | public Element getElement(String tname)(Code) | | Gets the first Element-type child with the tag name.
It is the same as childOf(nsURI, lname, null, 0).
Note: only Element-type children are returned. Also, we did some
optimization for this method so its access time is nearly constant.
Parameters: tname - the tag name (i.e., Namespaceable.getName) the found element; null if not found or not supported |
getElementIndex | public int getElementIndex(int indexFrom, String namespace, String name, int mode)(Code) | | Gets the index of the Element-type first child that match the specified
criteria.
Note: only Element-type children are returned, since others
have no name.
Parameters: indexFrom - the index to start searching from; 0 for beginning Parameters: namespace - the namspace URI if FIND_BY_PREFIX is not specified;the namespace prefix if FIND_BY_PREFIX specified; null to ingore Parameters: name - the local name if FIND_BY_TAGNAME is not sepcified;the tag name if FIND_BY_TAGNAME specified; null to ignore Parameters: mode - the serach mode; zero or any combination ofItem.FIND_xxx, except FIND_RECURSIVE the index if found; -1 if not found |
getElementIndex | public int getElementIndex(int indexFrom, String tname)(Code) | | Gets the index of the first Element-type child with the specified name.
Note: only Element-type children are returned, since others
have no name.
getChildren().add(getElementIndex(0, "pre:name"),
new Element("pre:another"));
Parameters: indexFrom - the index to start searching from; 0 for beginning Parameters: tname - the tag name (i.e., Namespaceable.getName) the index if found; -1 if not found
|
getElementNames | public Set getElementNames()(Code) | | Returns a readonly set of names of element children.
Then, you could use
Group.getElements to get elements.
The returned list is a 'live-facade' of the real ones, so
the performance is good, and any modification to
Group.getChildren will affect it.
See Also: Group.getElements() |
getElementValue | public String getElementValue(String namespace, String name, int mode, boolean trim)(Code) | | Gets the value of the first Element-type child that matches
the giving criteria, with a trimming option.
Parameters: namespace - the namspace URI if FIND_BY_PREFIX is not specified;the namespace prefix if FIND_BY_PREFIX specified; null to ingore Parameters: name - the local name if FIND_BY_TAGNAME is not sepcified;the tag name if FIND_BY_TAGNAME specified; null to ignore the value of the first Element-type child ; null if not found |
getElementValue | public String getElementValue(String tname, boolean trim)(Code) | | Gets the text of the first Element-type child with the tag name,
with a trimming option.
Parameters: tname - the tag name (i.e., Namespaceable.getName) the text of the first Element-type child withthe tag name; null if not found |
getElements | public List getElements(String namespace, String name, int mode)(Code) | | Gets a readonly list of Element-type children that match the giving
criteria.
Unlike
Element.getElementsByTagName , this method only
returns child elements, excluding grand children and other descedants.
The returned list is a 'live-facade' of the real ones, so
the performance is good, and any modification to
Group.getChildren will affect it.
Note: only Element-type children are returned. Depending on
the mode, the searching is usually linear -- take O(n) to complete.
Parameters: namespace - the namspace URI if FIND_BY_PREFIX is not specified;the namespace prefix if FIND_BY_PREFIX specified; null to ingore Parameters: name - the local name if FIND_BY_TAGNAME is not sepcified;the tag name if FIND_BY_TAGNAME specified; null to ignore Parameters: mode - the search mode; zero or any combination of FIND_xxx. a read-only list containing all matched children;an empty list if not found or not supported |
getElements | public List getElements(String tname)(Code) | | Gets a readonly list of children with the tag name.
Unlike
Element.getElementsByTagName , this method only
returns child elements, excluding grand children and other descedants.
The returned list is a 'live-facade' of the real ones, so
the performance is good, and any modification to
Group.getChildren will affect it.
Note: only Element-type children are returned. Also, we did some
optimization for this method so its access time is nearly constant.
Parameters: tname - the tag name (i.e., Namespaceable.getName) |
|
|