KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > jcr > item > NodeRefNodeIteratorImpl


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.jcr.item;
18
19 import java.util.List JavaDoc;
20
21 import javax.jcr.Node;
22 import javax.jcr.NodeIterator;
23 import javax.jcr.query.QueryResult;
24
25 import org.alfresco.jcr.session.SessionImpl;
26 import org.alfresco.jcr.util.AbstractRangeIterator;
27 import org.alfresco.jcr.util.JCRProxyFactory;
28 import org.alfresco.service.cmr.repository.NodeRef;
29
30
31 /**
32  * Alfresco implementation of a Node Iterator
33  *
34  * @author David Caruana
35  */

36 public class NodeRefNodeIteratorImpl extends AbstractRangeIterator
37     implements NodeIterator
38 {
39     private SessionImpl sessionImpl;
40     private List JavaDoc<NodeRef> nodeRefs;
41     
42     /**
43      * Construct
44      *
45      * @param context session context
46      * @param nodes node list
47      */

48     public NodeRefNodeIteratorImpl(SessionImpl sessionImpl, List JavaDoc<NodeRef> nodeRefs)
49     {
50         this.sessionImpl = sessionImpl;
51         this.nodeRefs = nodeRefs;
52     }
53     
54     /* (non-Javadoc)
55      * @see javax.jcr.NodeIterator#nextNode()
56      */

57     public Node nextNode()
58     {
59         long position = skip();
60         NodeRef nodeRef = nodeRefs.get((int)position);
61         NodeImpl nodeImpl = new NodeImpl(sessionImpl, nodeRef);
62         return nodeImpl.getProxy();
63     }
64
65     /* (non-Javadoc)
66      * @see javax.jcr.RangeIterator#getSize()
67      */

68     public long getSize()
69     {
70         return nodeRefs.size();
71     }
72
73     /* (non-Javadoc)
74      * @see java.util.Iterator#next()
75      */

76     public Object JavaDoc next()
77     {
78         return nextNode();
79     }
80
81 }
82
Popular Tags