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
024package microsoft.exchange.webservices.data.search;
025
026import microsoft.exchange.webservices.data.core.service.item.Item;
027
028import java.util.ArrayList;
029import 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 */
036public final class FindItemsResults<TItem extends Item> implements
037    Iterable<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   * The item.
056   */
057  private ArrayList<TItem> items = new ArrayList<TItem>();
058
059  /**
060   * Initializes a new instance of the FindItemsResults class.
061   */
062  public FindItemsResults() {
063  }
064
065  /**
066   * Gets the total number of item matching the search criteria available in
067   * the searched folder.
068   *
069   * @return the total count
070   */
071  public int getTotalCount() {
072    return this.totalCount;
073  }
074
075  /**
076   * Sets the total number of item matching the search criteria available in
077   * the searched folder.
078   *
079   * @param totalCount the new total count
080   */
081  public void setTotalCount(int totalCount) {
082    this.totalCount = totalCount;
083  }
084
085  /**
086   * Gets the offset that should be used with ItemView to retrieve the next
087   * page of item in a FindItems operation.
088   *
089   * @return the next page offset
090   */
091  public Integer getNextPageOffset() {
092    return nextPageOffset;
093  }
094
095  /**
096   * Sets the offset that should be used with ItemView to retrieve the next
097   * page of item in a FindItems operation.
098   *
099   * @param nextPageOffset the new next page offset
100   */
101  public void setNextPageOffset(Integer nextPageOffset) {
102    this.nextPageOffset = nextPageOffset;
103  }
104
105  /**
106   * Gets a value indicating whether more item matching the search criteria
107   * are available in the searched folder.
108   *
109   * @return true, if is more available
110   */
111  public boolean isMoreAvailable() {
112    return moreAvailable;
113  }
114
115  /**
116   * Sets a value indicating whether more item matching the search criteria
117   * are available in the searched folder.
118   *
119   * @param moreAvailable the new more available
120   */
121  public void setMoreAvailable(boolean moreAvailable) {
122    this.moreAvailable = moreAvailable;
123  }
124
125  /**
126   * Gets a collection containing the item that were found by the search
127   * operation.
128   *
129   * @return the item
130   */
131  public ArrayList<TItem> getItems() {
132    return this.items;
133  }
134
135  /**
136   * Returns an iterator that iterates through the collection.
137   *
138   * @return the iterator
139   */
140  @Override
141  public Iterator<TItem> iterator() {
142    return items.iterator();
143  }
144
145}