Class FacetChecker
- java.lang.Object
-
- com.google.appengine.api.search.checkers.FacetChecker
-
public final class FacetChecker extends Object
Provides checks for Facet names and values: atom or number.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcheckAtom(String value)Checks whether an atom is valid.static StringcheckFacetName(String name)Checks whether a facet name is valid.static StringcheckFacetName(String name, String callerContext)Checks whether a facet name is valid.static com.google.apphosting.api.search.DocumentPb.FacetValuecheckFacetValue(com.google.apphosting.api.search.DocumentPb.FacetValue value)Checks whether a facet value is valid.static DoublecheckNumber(Double value)Checks whether a number is valid.static com.google.apphosting.api.search.DocumentPb.FacetcheckValid(com.google.apphosting.api.search.DocumentPb.Facet facet)
-
-
-
Method Detail
-
checkFacetName
public static String checkFacetName(String name)
Checks whether a facet name is valid. The facet name length must be between 1 andSearchApiLimits.MAXIMUM_NAME_LENGTHinclusive, and it should matchSearchApiLimits.FIELD_NAME_PATTERN.- Parameters:
name- the facet name to check- Returns:
- the checked facet name
- Throws:
IllegalArgumentException- if the facet name is null or empty or is longer than SearchApiLimits#MAXIMUM_NAME_LENGTH or it doesn't match #FIELD_NAME_PATTERN.
-
checkFacetName
public static String checkFacetName(String name, String callerContext)
Checks whether a facet name is valid. The facet name length must be between 1 andSearchApiLimits.MAXIMUM_NAME_LENGTHinclusive, and it should matchSearchApiLimits.FIELD_NAME_PATTERN.- Parameters:
name- the facet name to checkcallerContext- the caller context used for creating error message in case of a failure.- Returns:
- the checked facet name
- Throws:
IllegalArgumentException- if the facet name is empty or is longer than SearchApiLimits#MAXIMUM_NAME_LENGTH or it doesn't match #FIELD_NAME_PATTERN.
-
checkAtom
public static String checkAtom(String value)
Checks whether an atom is valid. An atom can be null or a string between 1 and SearchApiLimits.MAXIMUM_ATOM_LENGTH in length, inclusive.- Parameters:
value- the atom value to check- Returns:
- the checked atom
- Throws:
IllegalArgumentException- if atom is too long or too short (i.e. empty)
-
checkNumber
public static Double checkNumber(Double value)
Checks whether a number is valid. A number can be null or a value betweenSearchApiLimits.MINIMUM_NUMBER_VALUEandSearchApiLimits.MAXIMUM_NUMBER_VALUE, inclusive.- Parameters:
value- the value to check- Returns:
- the checked number
- Throws:
IllegalArgumentException- if number is out of range
-
checkFacetValue
public static com.google.apphosting.api.search.DocumentPb.FacetValue checkFacetValue(com.google.apphosting.api.search.DocumentPb.FacetValue value)
Checks whether a facet value is valid.- Parameters:
value- the facet value to check- Returns:
- the checked facet value
- Throws:
IllegalArgumentException- if the facet value type is not recognized or if the facet value string is not valid based on the type. SeecheckNumber(java.lang.Double)andcheckAtom(java.lang.String).
-
checkValid
public static com.google.apphosting.api.search.DocumentPb.Facet checkValid(com.google.apphosting.api.search.DocumentPb.Facet facet)
-
-