]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/ui/jcr/NodesWrapper.java
dcd3b42f692b64a3f2ed7be54c824edb15c9e368
2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.eclipse
.ui
.jcr
;
18 import java
.util
.ArrayList
;
19 import java
.util
.List
;
21 import javax
.jcr
.Node
;
22 import javax
.jcr
.NodeIterator
;
23 import javax
.jcr
.RepositoryException
;
25 import org
.argeo
.ArgeoException
;
28 * Element of tree which is based on a node, but whose children are not
29 * necessarily this node children.
31 public class NodesWrapper
{
32 private final Node node
;
34 public NodesWrapper(Node node
) {
39 protected NodeIterator
getNodeIterator() throws RepositoryException
{
40 return node
.getNodes();
43 protected List
<WrappedNode
> getWrappedNodes() throws RepositoryException
{
44 List
<WrappedNode
> nodes
= new ArrayList
<WrappedNode
>();
45 for (NodeIterator nit
= getNodeIterator(); nit
.hasNext();)
46 nodes
.add(new WrappedNode(this, nit
.nextNode()));
50 public Object
[] getChildren() {
52 return getWrappedNodes().toArray();
53 } catch (RepositoryException e
) {
54 throw new ArgeoException("Cannot get wrapped children", e
);
59 * @return true by default because we don't want to compute the wrapped
62 public Boolean
hasChildren() {
66 public Node
getNode() {
71 public int hashCode() {
72 return node
.hashCode();
76 public boolean equals(Object obj
) {
77 if (obj
instanceof NodesWrapper
)
78 return node
.equals(((NodesWrapper
) obj
).getNode());
83 public String
toString() {
84 return "nodes wrapper based on " + node
;