KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > jcr > version > VersionListIterator


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.version;
18
19 import java.util.List JavaDoc;
20
21 import javax.jcr.version.Version;
22 import javax.jcr.version.VersionIterator;
23
24 import org.alfresco.jcr.util.AbstractRangeIterator;
25
26
27 /**
28  * Alfresco implementation of a Property Iterator
29  *
30  * @author David Caruana
31  */

32 public class VersionListIterator extends AbstractRangeIterator
33     implements VersionIterator
34 {
35     private VersionHistoryImpl versionHistory;
36     private List JavaDoc<org.alfresco.service.cmr.version.Version> versions;
37     
38     
39     /**
40      * Construct
41      *
42      * @param context session context
43      * @param versions version list
44      */

45     public VersionListIterator(VersionHistoryImpl versionHistory, List JavaDoc<org.alfresco.service.cmr.version.Version> versions)
46     {
47         this.versionHistory = versionHistory;
48         this.versions = versions;
49     }
50     
51     /*
52      * (non-Javadoc)
53      * @see javax.jcr.version.VersionIterator#nextVersion()
54      */

55     public Version nextVersion()
56     {
57         long position = skip();
58         org.alfresco.service.cmr.version.Version version = versions.get((int)position);
59         return new VersionImpl(versionHistory, version).getProxy();
60     }
61     
62     /* (non-Javadoc)
63      * @see javax.jcr.RangeIterator#getSize()
64      */

65     public long getSize()
66     {
67         return versions.size();
68     }
69
70     /* (non-Javadoc)
71      * @see java.util.Iterator#next()
72      */

73     public Object JavaDoc next()
74     {
75         return nextVersion();
76     }
77
78 }
79
Popular Tags