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
Name Description
atom String

the atom to check

Returns
Type Description
String

the checked atom

checkDate(Date date)

public static Date checkDate(Date date)

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

Parameter
Name Description
date Date

the date to check

Returns
Type Description
Date

the checked date

Exceptions
Type Description
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
Name Description
expression String

the expression to check

Returns
Type Description
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
Name Description
name String

the field name to check

Returns
Type Description
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
Name Description
name String

the field name to check

fieldName String

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

Returns
Type Description
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
Name Description
html String

the html to check

Returns
Type Description
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
Name Description
value Double

the value to check

Returns
Type Description
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
Name Description
prefix String

the prefix to check

Returns
Type Description
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
Name Description
expression String

the expression to check

Returns
Type Description
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
Name Description
text String

the text to check

Returns
Type Description
String

the checked text

checkValid(DocumentPb.Field field)

public static DocumentPb.Field checkValid(DocumentPb.Field field)
Parameter
Name Description
field com.google.apphosting.api.search.DocumentPb.Field
Returns
Type Description
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
Name Description
vector List<Double>

the vector to check

Returns
Type Description
List<Double>

parseLocale(String locale)

public static Locale parseLocale(String locale)

Returns a Locale parsed from the given locale string.

Parameter
Name Description
locale String

a string representation of a Locale

Returns
Type Description
Locale

a Locale parsed from the given locale string

Constructors

FieldChecker()

public FieldChecker()