1 // Copyright 2011 Google Inc. All Rights Reserved.
3 package com
.google
.appengine
.api
.search
.checkers
;
5 import com
.google
.appengine
.api
.search
.SearchServicePb
.ScorerSpec
;
6 import com
.google
.apphosting
.api
.AppEngineInternal
;
9 * Checks the values of a {@link SortOptions}.
13 public class SortOptionsChecker
{
16 * The maximum number of documents that can be requested to be scored.
17 * @deprecated From 1.7.4, use {@link SearchApiLimits#SEARCH_MAXIMUM_SORTED_LIMIT}
19 @Deprecated public static final int MAXIMUM_LIMIT
= 10000;
22 * The default number of documents to score.
23 * @deprecated From 1.7.4, use {@link SearchApiLimits#SEARCH_DEFAULT_SORTED_LIMIT}
25 @Deprecated public static final int DEFAULT_LIMIT
= 1000;
28 * Checks whether the limit on number of documents to score is between 0 and
31 * @param limit the maximum number of documents to score in the search
32 * @return the checked limit
33 * @throws IllegalArgumentException if the limit is out of range
35 public static int checkLimit(int limit
) {
36 Preconditions
.checkArgument(limit
>= 0 && limit
<= SearchApiLimits
.SEARCH_MAXIMUM_SORTED_LIMIT
,
37 "The limit %d must be between 0 and %d", limit
,
38 SearchApiLimits
.SEARCH_MAXIMUM_SORTED_LIMIT
);
43 * Checks the {@link ScorerSpec} is valid, specifically checking the limit
44 * on number of documents to score is not too large.
46 * @param spec the {@link ScorerSpec} to check
47 * @return the checked spec
48 * @throws IllegalArgumentException if the spec is invalid
50 public static ScorerSpec
checkValid(ScorerSpec spec
) {
51 checkLimit(spec
.getLimit());