Class Cursor
- java.lang.Object
-
- com.google.appengine.api.datastore.Cursor
-
- All Implemented Interfaces:
- java.io.Serializable
public final class Cursor extends java.lang.Object implements java.io.SerializableA cursor that represents a position in a query.To resume a
Queryat the position defined by aCursor, theCursormust be present in theFetchOptionspassed to aPreparedQueryidentical to the one it was created from.Cursors can be retrieved from
PreparedQuery.asQueryResult*functions. A typical use case would be:
The encoded cursor can then be passed safely in a get or post arg of a web request and on another request the next batch of results can be retrieved with:Cursor originalCursor = preparedQuery.asQueryResultList(withLimit(20)).getCursor(); String encodedCursor = original.toWebSafeString();
Cursor decodedCursor = Cursor.fromWebSafeString(encodedCursor); List<Entity> nextBatch = preparedQuery.asQueryResultList(withLimit(20).cursor(decoded));- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description booleanequals(java.lang.Object obj)static CursorfromWebSafeString(java.lang.String encodedCursor)Decodes the given encoded cursorinthashCode()Cursorreverse()Deprecated.It is no longer necessary to callreverse()on cursors.A cursor returned by a query may also be used in the query returned by
Query.reverse().java.lang.StringtoString()java.lang.StringtoWebSafeString()Encodes the current cursor as a web safe string that can later be decoded byfromWebSafeString(String)
-
-
-
Method Detail
-
reverse
@Deprecated public Cursor reverse()
Deprecated. It is no longer necessary to callreverse()on cursors.A cursor returned by a query may also be used in the query returned by
Query.reverse().- Returns:
- a cursor identical to
this
-
toWebSafeString
public java.lang.String toWebSafeString()
Encodes the current cursor as a web safe string that can later be decoded byfromWebSafeString(String)
-
fromWebSafeString
public static Cursor fromWebSafeString(java.lang.String encodedCursor)
Decodes the given encoded cursor- Parameters:
encodedCursor-- Returns:
- the decoded cursor
- Throws:
java.lang.IllegalArgumentException- if the provided string is not a valid encoded cursor
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-