1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.chemistry.opencmis.client.api; 20 21 import java.util.Iterator; 22 23 /** 24 * Iterable for CMIS collections that allows ability to skip to specific 25 * position or return a subcollection. 26 * 27 * @param <T> 28 * the type of the items 29 */ 30 public interface ItemIterable<T> extends Iterable<T> { 31 32 /** 33 * Skips to position within CMIS collection. 34 * 35 * @param position 36 * offset where to skip to 37 * 38 * @return iterable whose starting point is the specified skip to position. 39 * This iterable <em>may</em> be the same as {@code this} 40 */ 41 ItemIterable<T> skipTo(long position); 42 43 /** 44 * Gets an iterable for the current sub collection within the CMIS 45 * collection using default maximum number of items. 46 * 47 * @return iterable for current page 48 */ 49 ItemIterable<T> getPage(); 50 51 /** 52 * Gets an iterable for the current sub collection within the CMIS 53 * collection. 54 * 55 * @param maxNumItems 56 * maximum number of items the sub collection will contain 57 * 58 * @return iterable for current page 59 */ 60 ItemIterable<T> getPage(int maxNumItems); 61 62 @Override 63 Iterator<T> iterator(); 64 65 /** 66 * Returns the number of items fetched for the current page. 67 * 68 * @return number of items for currently fetched collection 69 */ 70 long getPageNumItems(); 71 72 /** 73 * Returns whether the repository contains additional items beyond the page 74 * of items already fetched. 75 * 76 * @return {@code true} if further page requests will be made to the 77 * repository 78 */ 79 boolean getHasMoreItems(); 80 81 /** 82 * Returns the total number of items. If the repository knows the total 83 * number of items in a result set, the repository SHOULD include the number 84 * here. If the repository does not know the number of items in a result 85 * set, this parameter SHOULD not be set. The value in the parameter MAY NOT 86 * be accurate the next time the client retrieves the result set or the next 87 * page in the result set. 88 * 89 * @return total number of items or (-1) 90 */ 91 long getTotalNumItems(); 92 93 }