]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - NodesWrapper.java
5765a389d0494618382ddd8ad608cbbc0ad6bc07
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
.ArgeoException
;
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 List
<WrappedNode
> getWrappedNodes() throws RepositoryException
{
25 List
<WrappedNode
> nodes
= new ArrayList
<WrappedNode
>();
26 for (NodeIterator nit
= node
.getNodes(); nit
.hasNext();)
27 nodes
.add(new WrappedNode(this, nit
.nextNode()));
31 public Object
[] getChildren() {
33 return getWrappedNodes().toArray();
34 } catch (RepositoryException e
) {
35 throw new ArgeoException("Cannot get wrapped children", e
);
40 * @return true by default because we don't want to compute the wrapped
43 public Boolean
hasChildren() {
47 public Node
getNode() {
52 public int hashCode() {
53 return node
.hashCode();
57 public boolean equals(Object obj
) {
58 if (obj
instanceof NodesWrapper
)
59 return node
.equals(((NodesWrapper
) obj
).getNode());
64 public String
toString() {
65 return "nodes wrapper based on " + node
;