org.rhq.enterprise.server.util
Class QueryUtility

java.lang.Object
  extended by org.rhq.enterprise.server.util.QueryUtility

public class QueryUtility
extends Object


Constructor Summary
QueryUtility()
           
 
Method Summary
static String escapeSearchParameter(String value)
          Given the settings for the current DatabaseType, properly handle escaping special SQL characters.
static String formatSearchParameter(String value)
          Given the settings for the current DatabaseType, properly handle escaping special SQL characters as well as UPCASING the value (standard for rhq filter searches) and wrapping with SQL wildcard for implicit "contains" (i.e.
static String getEscapeCharacter()
          Get the proper ESCAPE clause character for the current DatabaseType.
static String getEscapeClause()
          Get the proper LIKE operator escape clause for the current DatabaseType.
static String getEscapeClauseCharacter()
          Get the proper ESCAPE clause character for the current DatabaseType.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryUtility

public QueryUtility()
Method Detail

escapeSearchParameter

public static String escapeSearchParameter(String value)
Given the settings for the current DatabaseType, properly handle escaping special SQL characters.

Parameters:
value -
Returns:
the properly escaped value.

formatSearchParameter

public static String formatSearchParameter(String value)
Given the settings for the current DatabaseType, properly handle escaping special SQL characters as well as UPCASING the value (standard for rhq filter searches) and wrapping with SQL wildcard for implicit "contains" (i.e. '%' characters)

Parameters:
value -
Returns:
the properly escaped and formatted value.

getEscapeClause

public static String getEscapeClause()
Get the proper LIKE operator escape clause for the current DatabaseType.

Returns:
The escape clause buffered with single spaces. For example: " ESCAPE '\' "

getEscapeClauseCharacter

public static String getEscapeClauseCharacter()
Get the proper ESCAPE clause character for the current DatabaseType. This is for use when constructing query strings to be parsed (it may itself escape the escape character for proper parsing (like in Postgres when standard_conforming_strings is off). Call getEscapeCharacterParam() when needed for setting a NamedQuery parameter.

Returns:
The escape character as a String. The string may actually be multiple character but when parsed by the vendor it will parse out the single character.

getEscapeCharacter

public static String getEscapeCharacter()
Get the proper ESCAPE clause character for the current DatabaseType. This is for use when setting a NamedQuery paramater (unparsed, guaranteed to be a single char). If constructing query strings to be parsed Call getEscapeCharacter()

Returns:
The single escape character as a String.


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.