Class SearchLanguageConversion

java.lang.Object
org.alfresco.util.SearchLanguageConversion

public class SearchLanguageConversion extends Object
Helper class to provide conversions between different search languages
Author:
Derek Hulley
  • Field Details

  • Constructor Details

    • SearchLanguageConversion

      public SearchLanguageConversion()
  • Method Details

    • escapeForXPathLike

      public static String escapeForXPathLike(String str)
      Escape a string according to the XPath like function syntax.
      Parameters:
      str - the string to escape
      Returns:
      Returns the escaped string
    • escapeForRegex

      public static String escapeForRegex(String str)
      Escape a string according to the regex language syntax.
      Parameters:
      str - the string to escape
      Returns:
      Returns the escaped string
    • escapeForLucene

      public static String escapeForLucene(String str)
      Escape a string according to the Lucene query syntax.
      Parameters:
      str - the string to escape
      Returns:
      Returns the escaped string
    • convertXPathLikeToRegex

      public static String convertXPathLikeToRegex(String xpathLikeClause)
      Convert an xpath like function clause into a regex query.
      Parameters:
      xpathLikeClause - String
      Returns:
      Returns a valid regular expression that is equivalent to the given xpath like clause.
    • convertXPathLikeToLucene

      public static String convertXPathLikeToLucene(String xpathLikeClause)
      Convert an xpath like function clause into a Lucene query.
      Parameters:
      xpathLikeClause - String
      Returns:
      Returns a valid Lucene expression that is equivalent to the given xpath like clause.
    • convertSQLLikeToLucene

      public static String convertSQLLikeToLucene(String sqlLikeClause)
      Convert a sql like function clause into a Lucene query.
      Parameters:
      sqlLikeClause - String
      Returns:
      Returns a valid Lucene expression that is equivalent to the given sql like clause.
    • convertSQLLikeToRegex

      public static String convertSQLLikeToRegex(String sqlLikeClause)
      Convert a sql like function clause into a regex query.
      Parameters:
      sqlLikeClause - String
      Returns:
      Returns a valid regular expression that is equivalent to the given sql like clause.
    • convertCifsToLucene

      public static String convertCifsToLucene(String cifsNamePath)
      Convert a CIFS name path into the equivalent Lucene query.
      Parameters:
      cifsNamePath - the CIFS named path
      Returns:
      Returns a valid Lucene expression that is equivalent to the given CIFS name path
    • convert

    • escapeLuceneQuery

      public static String escapeLuceneQuery(String query)
      We have to escape lucene query strings outside of lucene - as we do not depend on any given version of lucene The escaping here is taken from lucene 4.9.0 The reserved (and escaped characters) are: \ + - ! ( ) : ^ [ ] " { } ~ * ? | & / The escape character is \
      Parameters:
      query - String
      Returns:
      - the escaped query string
    • tokenizeString

      public static String[] tokenizeString(String query)