com.esri.core.internal.catalog
Class ResultCursor<T extends PageableResultType>

java.lang.Object
  extended by com.esri.core.internal.catalog.ResultCursor<T>
All Implemented Interfaces:
Enumeration<T>

public class ResultCursor<T extends PageableResultType>
extends Object
implements Enumeration<T>

A cursor for iterating over search results obtained from arcgis.com A "pageable" search performed on arcgis.com may yield a large number of results. By default, only the first ten result values are returned. The ResultCursor allows clients to retrieve results in batches and fetches more results from the server when necessary.


Constructor Summary
protected ResultCursor(Catalog catalog, String reqUrl, HashMap<String,String> params, org.codehaus.jackson.JsonParser response, Class<T> clazz, com.esri.core.internal.catalog.Filter filter)
           
 
Method Summary
 int available()
          Returns the number of elements that the ResultCursor can return without sending a request to the Server.
 void close()
          Closes the cursor
 int getCount()
          Returns the total number of elements returned from the server that can be iterated over.
 List<T> getElements(int startIndex, int endIndex)
          Returns a range of elements specified by startIndex and endIndex, inclusively.
 boolean hasMoreElements()
          Tells if there are more elements that can be iterated over.
protected  void init(org.codehaus.jackson.JsonParser response)
           
 T nextElement()
          Returns the next element, fetching more elements from the server, if necessary.
 List<T> nextTenElements()
          Returns the next ten elements, fetching more elements from the server if necessary.
 void reset()
          Resets the cursor
 void seek(int pos)
          Seeks the cursor to the specified position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultCursor

protected ResultCursor(Catalog catalog,
                       String reqUrl,
                       HashMap<String,String> params,
                       org.codehaus.jackson.JsonParser response,
                       Class<T> clazz,
                       com.esri.core.internal.catalog.Filter filter)
Method Detail

init

protected void init(org.codehaus.jackson.JsonParser response)

getCount

public int getCount()
Returns the total number of elements returned from the server that can be iterated over.

Returns:
the total number of results returned from the server.

reset

public void reset()
Resets the cursor


hasMoreElements

public boolean hasMoreElements()
Tells if there are more elements that can be iterated over.

Specified by:
hasMoreElements in interface Enumeration<T extends PageableResultType>
Returns:
true if there are more elements, else returns false

nextElement

public T nextElement()
Returns the next element, fetching more elements from the server, if necessary.

Specified by:
nextElement in interface Enumeration<T extends PageableResultType>
Returns:
a element that implements PageableResultType

nextTenElements

public List<T> nextTenElements()
Returns the next ten elements, fetching more elements from the server if necessary.

Returns:
a list of ten elements

available

public int available()
Returns the number of elements that the ResultCursor can return without sending a request to the Server.

Returns:
the number of elements available

seek

public void seek(int pos)
          throws IndexOutOfBoundsException
Seeks the cursor to the specified position.

Parameters:
pos - the position that the cursor should seek to
Throws:
IndexOutOfBoundsException

getElements

public List<T> getElements(int startIndex,
                           int endIndex)
Returns a range of elements specified by startIndex and endIndex, inclusively. A sublist of an internal list maintained by the ResultCursor is returned. Invoking getElements(0,3) will return a total of 4 elements. If endIndex is greater than the size of the internal list held within the ResultCursor and there are more results to be fetched, then this method will fetch more results from the server and then return. If endIndex exceeds the total number of results the server can return then it returns getCount() - startIndex - 1 number of elements. Invoking this method does not alter the position of an internal cursor that is employed for iterating elements using the nextElement() and nextTenElements() methods.

Parameters:
startIndex - the startIndex
endIndex - the endIndex
Returns:
a sublist of elements

close

public void close()
Closes the cursor



Copyright © 2012. All Rights Reserved.