Class EscapeQuerySyntaxImpl
java.lang.Object
org.apache.lucene.queryparser.flexible.standard.parser.EscapeQuerySyntaxImpl
- All Implemented Interfaces:
EscapeQuerySyntax
Implementation of
EscapeQuerySyntax for the standard lucene syntax.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.lucene.queryparser.flexible.core.parser.EscapeQuerySyntax
EscapeQuerySyntax.Type -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic UnescapedCharSequencediscardEscapeChar(CharSequence input) Returns a String where the escape char has been removed, or kept only once if there was a double escape.escape(CharSequence text, Locale locale, EscapeQuerySyntax.Type type) private static CharSequenceescapeChar(CharSequence str, Locale locale) private static CharSequenceescapeIgnoringCase(CharSequence string, CharSequence sequence1, CharSequence escapeChar, Locale locale) Prepend every case-insensitive occurrence of thesequence1in thestringwith theescapeChar.private static CharSequenceescapeQuoted(CharSequence str, Locale locale) private static CharSequenceescapeTerm(CharSequence term, Locale locale) private static CharSequenceescapeWhiteChar(CharSequence str, Locale locale) escape all tokens that are part of the parser syntax on a given stringprivate static inthexToInt(char c) Returns the numeric value of the hexadecimal character
-
Field Details
-
wildcardChars
private static final char[] wildcardChars -
escapableTermExtraFirstChars
-
escapableTermChars
-
escapableQuotedChars
-
escapableWhiteChars
-
escapableWordTokens
-
-
Constructor Details
-
EscapeQuerySyntaxImpl
public EscapeQuerySyntaxImpl()
-
-
Method Details
-
escapeChar
-
escapeQuoted
-
escapeTerm
-
escapeIgnoringCase
private static CharSequence escapeIgnoringCase(CharSequence string, CharSequence sequence1, CharSequence escapeChar, Locale locale) Prepend every case-insensitive occurrence of thesequence1in thestringwith theescapeChar. When thesequence1is empty, every character in thestringis escaped.- Parameters:
string- string to apply escaping tosequence1- the old character sequence in lowercaseescapeChar- the escape character to prefix sequence1 in the returned string- Returns:
- CharSequence with every occurrence of
sequence1prepended withescapeChar
-
escapeWhiteChar
escape all tokens that are part of the parser syntax on a given string- Parameters:
str- string to get replacedlocale- locale to be used when performing string compares- Returns:
- the new String
-
escape
- Specified by:
escapein interfaceEscapeQuerySyntax- Parameters:
text- - text to be escapedlocale- - locale for the current querytype- - select the type of escape operation to use- Returns:
- escaped text
-
discardEscapeChar
Returns a String where the escape char has been removed, or kept only once if there was a double escape.Supports escaped Unicode characters, e.g. translates
\u0041toA.- Throws:
ParseException
-
hexToInt
Returns the numeric value of the hexadecimal character- Throws:
ParseException
-