Package org.ametys.cms.search.query
Class AbstractTextQuery
- java.lang.Object
-
- org.ametys.cms.search.query.AbstractFieldQuery
-
- org.ametys.cms.search.query.AbstractTextQuery
-
- All Implemented Interfaces:
Query
- Direct Known Subclasses:
RichTextQuery,StringQuery
public abstract class AbstractTextQuery extends AbstractFieldQuery
Represents aQuerytesting a text field.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.cms.search.query.Query
Query.LogicalOperator, Query.Operator
-
-
Field Summary
Fields Modifier and Type Field Description protected String_languageThe language.protected Query.Operator_operatorThe operator.protected String_valueThe value to test.protected boolean_valueAlreadyEscapedtrueif the value is already escaped and there is no need to escape again the value duringthe build of the query.-
Fields inherited from class org.ametys.cms.search.query.AbstractFieldQuery
_fieldPath
-
-
Constructor Summary
Constructors Constructor Description AbstractTextQuery(String fieldPath)Build a AbstractTextQuery testing the existence of the field.AbstractTextQuery(String fieldPath, String value)Build a text query.AbstractTextQuery(String fieldPath, String value, String language)Build a text query.AbstractTextQuery(String fieldPath, Query.Operator op, String value, String language)Build a text query.AbstractTextQuery(String fieldPath, Query.Operator op, String value, String language, boolean alreadyEscaped)Build a text query.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static String_escapeQueryCharsExceptStarsAndWhitespaces(String s)Stringbuild()Build the solr query string representing the Query object.static voidcheckStringValue(String value)Ensure that the string value is valid (i.e.booleanequals(Object obj)static StringescapeStringValue(String value, Query.Operator operator)Escape from a string value the characters that can modify the query fieldStringgetLanguage()Get the language.Query.OperatorgetOperator()Get the operator.StringgetValue()Get the value.inthashCode()-
Methods inherited from class org.ametys.cms.search.query.AbstractFieldQuery
getFieldPath
-
-
-
-
Field Detail
-
_operator
protected Query.Operator _operator
The operator.
-
_valueAlreadyEscaped
protected boolean _valueAlreadyEscaped
trueif the value is already escaped and there is no need to escape again the value duringthe build of the query.
-
-
Constructor Detail
-
AbstractTextQuery
public AbstractTextQuery(String fieldPath)
Build a AbstractTextQuery testing the existence of the field.- Parameters:
fieldPath- the field path
-
AbstractTextQuery
public AbstractTextQuery(String fieldPath, String value)
Build a text query.- Parameters:
fieldPath- the field's pathvalue- the value.
-
AbstractTextQuery
public AbstractTextQuery(String fieldPath, String value, String language)
Build a text query.- Parameters:
fieldPath- the field's pathvalue- the value.language- the query language (can be null).
-
AbstractTextQuery
public AbstractTextQuery(String fieldPath, Query.Operator op, String value, String language)
Build a text query.- Parameters:
fieldPath- the field's pathop- the operator.value- the value.language- the query language (can be null).
-
AbstractTextQuery
public AbstractTextQuery(String fieldPath, Query.Operator op, String value, String language, boolean alreadyEscaped)
Build a text query.- Parameters:
fieldPath- the field's pathop- the operator.value- the value.language- the query language (can be null).alreadyEscaped- true if the value is already escaped and there is no need to escape again the value duringthe build of the query.
-
-
Method Detail
-
getOperator
public Query.Operator getOperator()
Get the operator.- Returns:
- the operator.
-
getLanguage
public String getLanguage()
Get the language.- Returns:
- the language.
-
build
public String build() throws QuerySyntaxException
Description copied from interface:QueryBuild the solr query string representing the Query object.- Returns:
- the solr query string representing the Query object.
- Throws:
QuerySyntaxException- if the query can't be built because of a syntax error.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractFieldQuery
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin classAbstractFieldQuery
-
checkStringValue
public static void checkStringValue(String value) throws QuerySyntaxException
Ensure that the string value is valid (i.e. the parentheses are balanced), and throw an exception if it isn't.- Parameters:
value- the string value to check.- Throws:
QuerySyntaxException- if the value is invalid.
-
escapeStringValue
public static String escapeStringValue(String value, Query.Operator operator)
Escape from a string value the characters that can modify the query field- Parameters:
value- the string value.operator- the operator- Returns:
- the escaped value.
-
_escapeQueryCharsExceptStarsAndWhitespaces
private static String _escapeQueryCharsExceptStarsAndWhitespaces(String s)
-
-