]>
git.argeo.org Git - gpl/argeo-jcr.git/blob - swt/org.argeo.cms.jcr.ui/src/org/argeo/eclipse/ui/jcr/NodesWrapper.java
1 package org
.argeo
.eclipse
.ui
.jcr
;
3 import java
.util
.ArrayList
;
7 import javax
.jcr
.NodeIterator
;
8 import javax
.jcr
.RepositoryException
;
10 import org
.argeo
.eclipse
.ui
.EclipseUiException
;
13 * Element of tree which is based on a node, but whose children are not
14 * necessarily this node children.
16 public class NodesWrapper
{
17 private final Node node
;
19 public NodesWrapper(Node node
) {
24 protected NodeIterator
getNodeIterator() throws RepositoryException
{
25 return node
.getNodes();
28 protected List
<WrappedNode
> getWrappedNodes() throws RepositoryException
{
29 List
<WrappedNode
> nodes
= new ArrayList
<WrappedNode
>();
30 for (NodeIterator nit
= getNodeIterator(); nit
.hasNext();)
31 nodes
.add(new WrappedNode(this, nit
.nextNode()));
35 public Object
[] getChildren() {
37 return getWrappedNodes().toArray();
38 } catch (RepositoryException e
) {
39 throw new EclipseUiException("Cannot get wrapped children", e
);
44 * @return true by default because we don't want to compute the wrapped
47 public Boolean
hasChildren() {
51 public Node
getNode() {
56 public int hashCode() {
57 return node
.hashCode();
61 public boolean equals(Object obj
) {
62 if (obj
instanceof NodesWrapper
)
63 return node
.equals(((NodesWrapper
) obj
).getNode());
68 public String
toString() {
69 return "nodes wrapper based on " + node
;