This project has retired. For details please refer to its
Attic page.
CollectionPageIterator xref
1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19package org.apache.chemistry.opencmis.client.runtime.util;
2021import java.util.List;
2223import org.apache.chemistry.opencmis.client.runtime.util.AbstractPageFetcher.Page;
2425/**26 * Iterator for iterating over a page of items in a CMIS Collection.27 *28 * @param <T>29 */30publicclass CollectionPageIterator<T> extends AbstractIterator<T> {
3132/**33 * Construct34 *35 * @param skipCount36 * @param pageFetcher37 */38publicCollectionPageIterator(long skipCount, AbstractPageFetcher<T> pageFetcher) {
39super(skipCount, pageFetcher);
40 }
4142/*43 * (non-Javadoc)44 *45 * @see java.util.Iterator#hasNext()46 */47publicboolean hasNext() {
48 Page<T> page = getCurrentPage();
49if (page == null) {
50return false;
51 }
5253 List<T> items = page.getItems();
54if (items == null || getSkipOffset() >= items.size()) {
55return false;
56 }
5758returntrue;
59 }
6061/*62 * (non-Javadoc)63 *64 * @see java.util.Iterator#next()65 */66public T next() {
67 Page<T> page = getCurrentPage();
68if (page == null) {
69returnnull;
70 }
7172 List<T> items = page.getItems();
73if (items == null || items.isEmpty() || getSkipOffset() == items.size()) {
74returnnull;
75 }
7677return items.get(incrementSkipOffset());
78 }
79 }