This project has retired. For details please refer to its
Attic page.
AbstractPageFetcher 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.math.BigInteger;
22import java.util.List;
2324/**25 * Abstract page fetcher.26 *27 * @param <T> the type of items fetched28 */29publicabstractclass AbstractPageFetcher<T> {
3031protectedlong maxNumItems;
3233protectedAbstractPageFetcher(long maxNumItems) {
34this.maxNumItems = maxNumItems;
35 }
3637/**38 * Fetches the given page from the server.39 *40 * @param skipCount initial offset where to start fetching41 */42protectedabstract Page<T> fetchPage(long skipCount);
4344/**45 * A fetched page.46 *47 * @param <T> the type of items fetched48 */49publicstaticclass Page<T> {
50privatefinal List<T> items;
51privatefinal Long totalNumItems;
52privatefinal Boolean hasMoreItems;
5354publicPage(List<T> items, BigInteger totalNumItems, Boolean hasMoreItems) {
55this.items = items;
56this.totalNumItems = totalNumItems == null ? null57 : Long.valueOf(totalNumItems.longValue());
58this.hasMoreItems = hasMoreItems;
59 }
6061publicPage(List<T> items, long totalNumItems, boolean hasMoreItems) {
62this.items = items;
63this.totalNumItems = Long.valueOf(totalNumItems);
64this.hasMoreItems = Boolean.valueOf(hasMoreItems);
65 }
6667public List<T> getItems() {
68return items;
69 }
7071public Long getTotalNumItems() {
72return totalNumItems;
73 }
7475public Boolean getHasMoreItems() {
76return hasMoreItems;
77 }
78 }
7980publicvoid setMaxNumItems(int maxNumItems) {
81this.maxNumItems = maxNumItems;
82 }
8384 }