java.lang.Object
org.apache.lucene.queryparser.flexible.standard.parser.EscapeQuerySyntaxImpl
All Implemented Interfaces:
EscapeQuerySyntax

public class EscapeQuerySyntaxImpl extends Object implements EscapeQuerySyntax
Implementation of EscapeQuerySyntax for the standard lucene syntax.
  • Field Details

    • wildcardChars

      private static final char[] wildcardChars
    • escapableTermExtraFirstChars

      private static final String[] escapableTermExtraFirstChars
    • escapableTermChars

      private static final String[] escapableTermChars
    • escapableQuotedChars

      private static final String[] escapableQuotedChars
    • escapableWhiteChars

      private static final String[] escapableWhiteChars
    • escapableWordTokens

      private static final String[] escapableWordTokens
  • Constructor Details

    • EscapeQuerySyntaxImpl

      public EscapeQuerySyntaxImpl()
  • Method Details

    • escapeChar

      private static CharSequence escapeChar(CharSequence str, Locale locale)
    • escapeQuoted

      private static CharSequence escapeQuoted(CharSequence str, Locale locale)
    • escapeTerm

      private static CharSequence escapeTerm(CharSequence term, Locale locale)
    • escapeIgnoringCase

      private static CharSequence escapeIgnoringCase(CharSequence string, CharSequence sequence1, CharSequence escapeChar, Locale locale)
      Prepend every case-insensitive occurrence of the sequence1 in the string with the escapeChar. When the sequence1 is empty, every character in the string is escaped.
      Parameters:
      string - string to apply escaping to
      sequence1 - the old character sequence in lowercase
      escapeChar - the escape character to prefix sequence1 in the returned string
      Returns:
      CharSequence with every occurrence of sequence1 prepended with escapeChar
    • escapeWhiteChar

      private static CharSequence escapeWhiteChar(CharSequence str, Locale locale)
      escape all tokens that are part of the parser syntax on a given string
      Parameters:
      str - string to get replaced
      locale - locale to be used when performing string compares
      Returns:
      the new String
    • escape

      public CharSequence escape(CharSequence text, Locale locale, EscapeQuerySyntax.Type type)
      Specified by:
      escape in interface EscapeQuerySyntax
      Parameters:
      text - - text to be escaped
      locale - - locale for the current query
      type - - select the type of escape operation to use
      Returns:
      escaped text
    • discardEscapeChar

      public static UnescapedCharSequence discardEscapeChar(CharSequence input) throws ParseException
      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 to A.

      Throws:
      ParseException
    • hexToInt

      private static int hexToInt(char c) throws ParseException
      Returns the numeric value of the hexadecimal character
      Throws:
      ParseException