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 UnescapedCharSequence
discardEscapeChar
(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 CharSequence
escapeChar
(CharSequence str, Locale locale) private static CharSequence
escapeIgnoringCase
(CharSequence string, CharSequence sequence1, CharSequence escapeChar, Locale locale) Prepend every case-insensitive occurrence of thesequence1
in thestring
with theescapeChar
.private static CharSequence
escapeQuoted
(CharSequence str, Locale locale) private static CharSequence
escapeTerm
(CharSequence term, Locale locale) private static CharSequence
escapeWhiteChar
(CharSequence str, Locale locale) escape all tokens that are part of the parser syntax on a given stringprivate static int
hexToInt
(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 thesequence1
in thestring
with theescapeChar
. When thesequence1
is empty, every character in thestring
is 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
sequence1
prepended 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:
escape
in 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
\u0041
toA
.- Throws:
ParseException
-
hexToInt
Returns the numeric value of the hexadecimal character- Throws:
ParseException
-