Class Cursor
java.lang.Object
ubic.gemma.persistence.util.Cursor
Opaque cursor for keyset pagination of REST collections.
A cursor encodes:
version— payload format version, currently 1sortSpec— the sort specification this cursor was emitted for, e.g."+id"or"+lastUpdated,+id". The server must validate this against the endpoint's allowed sorts before using the cursor.keyTuple— the last seen key values, one entry per sort component. Must always end in a unique tie-breaker (typicallyid).direction—Cursor.Direction.FORWARD(next page) orCursor.Direction.BACKWARD(previous page).
The wire format is base64url-encoded JSON of the form:
{"v":1,"s":"+id","k":[12345],"d":"f"}
with "d":"f" for forward and "d":"b" for backward. "d" is
omitted when the direction is forward (the default).
Cursors are not signed; this is acceptable because the sortSpec is
server-validated and access control is enforced by the ACL layer.
- Author:
- phase3
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCurrent cursor payload format version. -
Constructor Summary
ConstructorsConstructorDescriptionCursor(int version, String sortSpec, Object[] keyTuple, Cursor.Direction direction) Build a cursor with an explicit payload format version.Cursor(String sortSpec, Object[] keyTuple, Cursor.Direction direction) Build a cursor with the current payload format version. -
Method Summary
-
Field Details
-
CURRENT_VERSION
public static final int CURRENT_VERSIONCurrent cursor payload format version. Bump and add a migration when the JSON shape changes incompatibly.- See Also:
-
-
Constructor Details
-
Cursor
Build a cursor with the current payload format version. -
Cursor
Build a cursor with an explicit payload format version. Intended for decoding; callers constructing new cursors should useCursor(String, Object[], Direction).
-
-
Method Details
-
getVersion
public int getVersion() -
getSortSpec
-
getKeyTuple
- Returns:
- a defensive copy of the key tuple; never null, never empty.
-
getDirection
-
encode
Encode this cursor as a base64url-encoded JSON string (no padding). -
decode
Decode a base64url-encoded cursor string.- Throws:
IllegalArgumentException- if the string is not valid base64url, not valid JSON, or is missing required fields. Callers in the REST layer should translate this into aMalformedArgException/ 400 response.
-
equals
-
hashCode
-
toString
-