1 // Copyright 2012 Google Inc. All Rights Reserved.
3 package com
.google
.appengine
.api
.search
.checkers
;
6 * Checks values of {@link com.google.appengine.api.search.Cursor}.
9 public final class CursorChecker
{
12 * The maximum length of a cursor.
14 public static final int MAXIMUM_CURSOR_LENGTH
= 10000;
17 * Checks the cursor string if provided is not empty nor too long.
19 * @param cursor the search cursor to check
20 * @return the checked cursor
21 * @throws IllegalArgumentException if the cursor is empty or is too long
23 public static String
checkCursor(String cursor
) {
25 Preconditions
.checkArgument(!cursor
.isEmpty(),
26 "cursor cannot be empty");
27 Preconditions
.checkArgument(cursor
.length() <= MAXIMUM_CURSOR_LENGTH
,
28 String
.format("cursor cannot be longer than %d characters", MAXIMUM_CURSOR_LENGTH
));