001 /*
002 * The MIT License
003 * Copyright (c) 2012 Microsoft Corporation
004 *
005 * Permission is hereby granted, free of charge, to any person obtaining a copy
006 * of this software and associated documentation files (the "Software"), to deal
007 * in the Software without restriction, including without limitation the rights
008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
009 * copies of the Software, and to permit persons to whom the Software is
010 * furnished to do so, subject to the following conditions:
011 *
012 * The above copyright notice and this permission notice shall be included in
013 * all copies or substantial portions of the Software.
014 *
015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
021 * THE SOFTWARE.
022 */
023
024 package microsoft.exchange.webservices.data.search;
025
026 import microsoft.exchange.webservices.data.core.service.item.Item;
027
028 import java.util.ArrayList;
029 import java.util.Iterator;
030
031 /**
032 * Represents the results of an item search operation.
033 *
034 * @param <TItem> The type of item returned by the search operation.
035 */
036 public final class GroupedFindItemsResults<TItem extends Item> implements
037 Iterable<ItemGroup<TItem>> {
038
039 /**
040 * The total count.
041 */
042 private int totalCount;
043
044 /**
045 * The next page offset.
046 */
047 private Integer nextPageOffset;
048
049 /**
050 * The more available.
051 */
052 private boolean moreAvailable;
053
054 /**
055 * List of ItemGroups.
056 */
057 private ArrayList<ItemGroup<TItem>> itemGroups =
058 new ArrayList<ItemGroup<TItem>>();
059
060 /**
061 * Initializes a new instance of the GroupedFindItemsResults class.
062 */
063 public GroupedFindItemsResults() {
064 }
065
066 /**
067 * Gets the total number of item matching the search criteria available in
068 * the searched folder.
069 *
070 * @return the total count
071 */
072 public int getTotalCount() {
073 return totalCount;
074 }
075
076 /**
077 * Gets the total number of item matching the search criteria available in
078 * the searched folder.
079 *
080 * @param totalCount Total number of item
081 */
082 public void setTotalCount(int totalCount) {
083 this.totalCount = totalCount;
084 }
085
086 /**
087 * Gets the offset that should be used with ItemView to retrieve the next
088 * page of item in a FindItems operation.
089 *
090 * @return the next page offset
091 */
092 public Integer getNextPageOffset() {
093 return nextPageOffset;
094 }
095
096 /**
097 * Sets the offset that should be used with ItemView to retrieve the next
098 * page of item in a FindItems operation.
099 *
100 * @param nextPageOffset the new next page offset
101 */
102 public void setNextPageOffset(Integer nextPageOffset) {
103 this.nextPageOffset = nextPageOffset;
104 }
105
106 /**
107 * Gets a value indicating whether more item corresponding to the search
108 * criteria are available in the searched folder.
109 *
110 * @return true, if is more available
111 */
112 public boolean isMoreAvailable() {
113 return moreAvailable;
114 }
115
116 /**
117 * Sets a value indicating whether more item corresponding to the search
118 * criteria are available in the searched folder.
119 *
120 * @param moreAvailable the new more available
121 */
122 public void setMoreAvailable(boolean moreAvailable) {
123 this.moreAvailable = moreAvailable;
124 }
125
126 /**
127 * Gets the item groups returned by the search operation.
128 *
129 * @return the item groups
130 */
131 public ArrayList<ItemGroup<TItem>> getItemGroups() {
132 return itemGroups;
133 }
134
135 /**
136 * Returns an iterator that iterates through the collection.
137 *
138 * @return the iterator
139 */
140 @Override
141 public Iterator<ItemGroup<TItem>> iterator() {
142 return this.itemGroups.iterator();
143 }
144
145 }