com.webmethods.caf.jcr.faces.util
Class QueryUtil

java.lang.Object
  extended by com.webmethods.caf.jcr.faces.util.QueryUtil

public class QueryUtil
extends Object

Helper utilities to assist in the construction of a JCR query string


Nested Class Summary
static class QueryUtil.QuoteChar
          Enum to specify which quote style to use
 
Constructor Summary
QueryUtil()
           
 
Method Summary
static String encodeAttributeValue(String rawValue, QueryUtil.QuoteChar wrappingQuoteCharacter)
          Encodes the special characters of a term to provide a valid attribute value match
static String encodeForLikeClause(String rawValue, QueryUtil.QuoteChar wrappingQuoteCharacter)
          Encodes the special characters of a term to provide a valid like clause
static String escapeIllegalXpathSearchChars(String s)
          Escapes illegal XPath search characters at the end of a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryUtil

public QueryUtil()
Method Detail

encodeForLikeClause

public static String encodeForLikeClause(String rawValue,
                                         QueryUtil.QuoteChar wrappingQuoteCharacter)
Encodes the special characters of a term to provide a valid like clause

Parameters:
rawValue - the value to encode
wrappingQuoteCharacter - the character wrapping the term in the final query string
Returns:
encoded value safe to use in a query like clause

encodeAttributeValue

public static String encodeAttributeValue(String rawValue,
                                          QueryUtil.QuoteChar wrappingQuoteCharacter)
Encodes the special characters of a term to provide a valid attribute value match

Parameters:
rawValue - the value to encode
wrappingQuoteCharacter - the character wrapping the term in the final query string
Returns:
encoded value safe to use in a query attribute value match

escapeIllegalXpathSearchChars

public static String escapeIllegalXpathSearchChars(String s)
Escapes illegal XPath search characters at the end of a string.

Example:
A search string like 'test?' will run into a ParseException documented in http://issues.apache.org/jira/browse/JCR-1248

Parameters:
s - the string to encode
Returns:
the escaped string