com.metamatrix.common.util
Class SqlUtil

java.lang.Object
  extended by com.metamatrix.common.util.SqlUtil

public class SqlUtil
extends java.lang.Object

Utilities for dealing with SQL strings.


Field Summary
static char CR_CHAR
           
static char NL_CHAR
           
static char SPACE_CHAR
           
static char TAB_CHAR
           
 
Method Summary
static java.sql.SQLException createFeatureNotSupportedException()
           
static boolean isUpdateSql(java.lang.String sql)
          Determines whether a sql statement is an update (INSERT, UPDATE, or DELETE).
static java.lang.String normalize(java.lang.String inputSqlString)
          Simple method which normalizes a SQL string by replacing CR characters, new line characters and Tab characters with spaces, then trimming the string to remove unneeded spaces.
static boolean stringsAreDifferent(java.lang.String newSql, java.lang.String oldSql)
          determine if the supplied sql Strings are different
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CR_CHAR

public static final char CR_CHAR
See Also:
Constant Field Values

NL_CHAR

public static final char NL_CHAR
See Also:
Constant Field Values

SPACE_CHAR

public static final char SPACE_CHAR
See Also:
Constant Field Values

TAB_CHAR

public static final char TAB_CHAR
See Also:
Constant Field Values
Method Detail

isUpdateSql

public static boolean isUpdateSql(java.lang.String sql)
                           throws java.lang.IllegalArgumentException
Determines whether a sql statement is an update (INSERT, UPDATE, or DELETE). Throws exception if SQL statement appears to be invalid (because it's null, has 0 length, etc.

Parameters:
sql - Sql string
Returns:
True if INSERT, UPDATE, or DELETE, and false otherwise
Throws:
java.lang.IllegalArgumentException - If sql string is invalid and neither a query or an update

normalize

public static java.lang.String normalize(java.lang.String inputSqlString)
Simple method which normalizes a SQL string by replacing CR characters, new line characters and Tab characters with spaces, then trimming the string to remove unneeded spaces.

Parameters:
inputSqlString -
Returns:
Since:
5.0

stringsAreDifferent

public static boolean stringsAreDifferent(java.lang.String newSql,
                                          java.lang.String oldSql)
determine if the supplied sql Strings are different

Parameters:
newSql - the new SQL String
oldSql - the old SQL String
Returns:
'true' if strings differ, 'false' if same

createFeatureNotSupportedException

public static java.sql.SQLException createFeatureNotSupportedException()


Copyright © 2009. All Rights Reserved.