Class LuceneUtils

java.lang.Object
org.owasp.dependencycheck.data.lucene.LuceneUtils

@ThreadSafe public final class LuceneUtils extends Object

Lucene utils is a set of utilize written to make constructing Lucene queries simpler.

Author:
Jeremy Long
  • Method Details

    • isKeyword

      public static boolean isKeyword(String term)
      Determines if the given term is a Lucene keyword (e.g. AND, OR, NOT).
      Parameters:
      term - the term to test
      Returns:
      trueif the term is a keyword; otherwise false
    • appendEscapedLuceneQuery

      public static void appendEscapedLuceneQuery(StringBuilder buf, CharSequence text)
      Appends the text to the supplied StringBuilder escaping Lucene control characters in the process.
      Parameters:
      buf - a StringBuilder to append the escaped text to
      text - the data to be escaped
    • escapeLuceneQuery

      public static String escapeLuceneQuery(CharSequence text)
      Escapes the text passed in so that it is treated as data instead of control characters.
      Parameters:
      text - data to be escaped
      Returns:
      the escaped text.