Class FieldChecker (2.0.0)

public final class FieldChecker

Provides checks for Field names, language code, and values: text, HTML, atom or date.

Inheritance

java.lang.Object > FieldChecker

Static Methods

checkAtom(String atom)

public static String checkAtom(String atom)

Checks whether an atom is valid. An atom can be null or a string between 1 and SearchApiLimits.MAXIMUM_ATOM_LENGTH in length.

Parameter
NameDescription
atomString

the atom to check

Returns
TypeDescription
String

the checked atom

checkDate(Date date)

public static Date checkDate(Date date)

Checks whether a date is within range. Date is nullable.

Parameter
NameDescription
dateDate

the date to check

Returns
TypeDescription
Date

the checked date

Exceptions
TypeDescription
IllegalArgumentException

if date is out of range

checkExpression(String expression)

public static String checkExpression(String expression)

Checks whether a field expression is not null and is parsable.

Parameter
NameDescription
expressionString

the expression to check

Returns
TypeDescription
String

the checked expression

checkFieldName(String name)

public static String checkFieldName(String name)

Checks whether a field name is valid. The field name length must be between 1 and SearchApiLimits#MAXIMUM_NAME_LENGTH and it should match SearchApiLimits#FIELD_NAME_PATTERN.

Parameter
NameDescription
nameString

the field name to check

Returns
TypeDescription
String

the checked field name

checkFieldName(String name, String fieldName)

public static String checkFieldName(String name, String fieldName)

Checks whether a field name is valid. The field name length must be between 1 and SearchApiLimits#MAXIMUM_NAME_LENGTH and it should match SearchApiLimits#FIELD_NAME_PATTERN.

Parameters
NameDescription
nameString

the field name to check

fieldNameString

the name of the Java field name of the class where name is checked

Returns
TypeDescription
String

the checked field name

checkHTML(String html)

public static String checkHTML(String html)

Checks whether a html is valid. A html can be null or a string between 0 and SearchApiLimits.MAXIMUM_TEXT_LENGTH in length.

Parameter
NameDescription
htmlString

the html to check

Returns
TypeDescription
String

the checked html

checkNumber(Double value)

public static Double checkNumber(Double value)

Checks whether a number is valid. A number can be null or a value between SearchApiLimits#MINIMUM_NUMBER_VALUE and SearchApiLimits#MAXIMUM_NUMBER_VALUE, inclusive.

Parameter
NameDescription
valueDouble

the value to check

Returns
TypeDescription
Double

the checked number

checkPrefix(String prefix)

public static String checkPrefix(String prefix)

Checks whether a prefix field is valid. A prefix field can be null or a string between 1 and SearchApiLimits.MAXIMUM_PREFIX_LENGTH in length.

Parameter
NameDescription
prefixString

the prefix to check

Returns
TypeDescription
String

the checked prefix

checkSortExpression(String expression)

public static String checkSortExpression(String expression)

Checks whether a sort bexpression is not null and is parsable.

Parameter
NameDescription
expressionString

the expression to check

Returns
TypeDescription
String

the checked expression

checkText(String text)

public static String checkText(String text)

Checks whether a text is valid. A text can be null, or a string between 0 and SearchApiLimits.MAXIMUM_TEXT_LENGTH in length.

Parameter
NameDescription
textString

the text to check

Returns
TypeDescription
String

the checked text

checkValid(DocumentPb.Field field)

public static DocumentPb.Field checkValid(DocumentPb.Field field)
Parameter
NameDescription
fieldcom.google.apphosting.api.search.DocumentPb.Field
Returns
TypeDescription
com.google.apphosting.api.search.DocumentPb.Field

checkVector(List<Double> vector)

public static List<Double> checkVector(List<Double> vector)

Checks whether a vector field is valid. A vector field can be an array of any number with size less than SearchApiLimits.VECTOR_FIELD_MAX_SIZE.

Parameter
NameDescription
vectorList<Double>

the vector to check

Returns
TypeDescription
List<Double>

parseLocale(String locale)

public static Locale parseLocale(String locale)

Returns a Locale parsed from the given locale string.

Parameter
NameDescription
localeString

a string representation of a Locale

Returns
TypeDescription
Locale

a Locale parsed from the given locale string

Constructors

FieldChecker()

public FieldChecker()