org.modeshape.jcr.query.engine

## Class QueryUtil

- java.lang.Object
- - org.modeshape.jcr.query.engine.QueryUtil

-     public class QueryUtil
      extends Object

  Utility methods for query processing.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `addSnsIndexesToLikeExpression(String pathLikeExpression)` Process the supplied LIKE expression for an absolute path and return a copy that has a SNS index (wildcard or literal) for all literal segments in the expression.
    `protected static boolean` | `hasWildcardCharacters(String expression)`
    `static boolean` | `includeFullTextScores(Constraint constraint)`
    `static boolean` | `includeFullTextScores(Iterable<Constraint> constraints)`
    `static String` | `toRegularExpression(String likeExpression)` Convert the JCR like expression to a regular expression.
    `protected static String` | `toWildcardExpression(String likeExpression)` Convert the JCR like expression to a Lucene wildcard expression.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### hasWildcardCharacters

          protected static boolean hasWildcardCharacters(String expression)

    - #### toWildcardExpression

          protected static String toWildcardExpression(String likeExpression)

      Convert the JCR like expression to a Lucene wildcard expression. The JCR like expression uses '%' to match 0 or more characters, '_' to match any single character, '\x' to match the 'x' character, and all other characters to match themselves.
      Parameters:
        `likeExpression` - the like expression; may not be null
      Returns:
        the expression that can be used with a WildcardQuery; never null

    - #### toRegularExpression

          public static String toRegularExpression(String likeExpression)

      Convert the JCR like expression to a regular expression. The JCR like expression uses '%' to match 0 or more characters, '_' to match any single character, '\x' to match the 'x' character, and all other characters to match themselves. Note that if any regex metacharacters appear in the like expression, they will be escaped within the resulting regular expression.
      Parameters:
        `likeExpression` - the like expression; may not be null
      Returns:
        the expression that can be used with a WildcardQuery; never null

    - #### includeFullTextScores

          public static boolean includeFullTextScores(Iterable<Constraint> constraints)

    - #### includeFullTextScores

          public static boolean includeFullTextScores(Constraint constraint)

    - #### addSnsIndexesToLikeExpression

          public static String addSnsIndexesToLikeExpression(String pathLikeExpression)

      Process the supplied LIKE expression for an absolute path and return a copy that has a SNS index (wildcard or literal) for all literal segments in the expression. For example, this method will convert:

            /alpha/beta[%]

      into

            /alpha[1]/beta[%]

      and

            /alpha/%/beta[%]

      into

            /alpha[1]/%/beta[%]

      Parameters:
        `pathLikeExpression` - the LIKE expression for a path; may not be null
      Returns:
        the updated like expression with SNS indexes in all literal segments

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.