2004.04.29


com.jdc.rdb.sql
Class SQLClauseHelper

java.lang.Object
  |
  +--jdc.java.lang.Object
        |
        +--com.jdc.rdb.sql.SQLClauseHelper
All Implemented Interfaces:
Serializable

public class SQLClauseHelper
extends Object
implements Serializable

SQLClauseHelper is a utility class that provides Structured Query Language (SQL) clause helper methods.  The following methods are available:

The formatValue(Object) method supports the following Object types:

Refer to the formatValue(Object) method for additional documentation.

Version:
1.0
Author:
Jay Damon
See Also:
SQLHelper, Serialized Form

Constructor Summary
SQLClauseHelper()
          Constructs a new SQLClauseHelper object.
 
Method Summary
 String addCommas(ArrayList list)
          Returns a comma-delimited String corresponding to the ArrayList.
 String addParentheses(String sql)
          Adds parentheses to a Structured Query Language (SQL) clause value if not already enclosed in parentheses.
 String encodeValue(String sql)
          Escapes the Structured Query Language (SQL) clause value if the SQL clause contains any of the following special characters: double quotes, single quotes, and/or slashes.
 String formatValue(boolean value)
          Returns a Structured Query Language (SQL) formatted table Column value for the specified boolean value.
 String formatValue(double value)
          Returns a Structured Query Language (SQL) formatted table Column value for the specified double value.
 String formatValue(long value)
          Returns a Structured Query Language (SQL) formatted table Column value for the specified long value.
 String formatValue(Object value)
          Returns a Structured Query Language (SQL) formatted table Column value for the specified Object type.
static void main(String[] args)
          Executes unit tests for the SQLClauseHelper class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLClauseHelper

public SQLClauseHelper()
Constructs a new SQLClauseHelper object.

Method Detail

addCommas

public String addCommas(ArrayList list)
Returns a comma-delimited String corresponding to the ArrayList. Additionally, the String array values trimmed and a space (blank) added between the comma-delimited values.

Returns:
A comma-delimited String.

addParentheses

public String addParentheses(String sql)
Adds parentheses to a Structured Query Language (SQL) clause value if not already enclosed in parentheses.

Returns:
The SQL clause enclosed in parentheses.
See Also:
StringHelper.addParentheses(java.lang.String)

encodeValue

public String encodeValue(String sql)
Escapes the Structured Query Language (SQL) clause value if the SQL clause contains any of the following special characters: double quotes, single quotes, and/or slashes.

Returns:
The SQL clause with special characters encoded.
See Also:
com.jdc.type.StringHelper#escape

formatValue

public String formatValue(boolean value)
Returns a Structured Query Language (SQL) formatted table Column value for the specified boolean value.

Returns:
A formatted boolean database table Column value.

formatValue

public String formatValue(double value)
Returns a Structured Query Language (SQL) formatted table Column value for the specified double value.

Returns:
A formatted double database table Column value.

formatValue

public String formatValue(long value)
Returns a Structured Query Language (SQL) formatted table Column value for the specified long value.

Returns:
A formatted long database table Column value.

formatValue

public String formatValue(Object value)
Returns a Structured Query Language (SQL) formatted table Column value for the specified Object type. The following standard Object types are directly supported:

For non-standard Object types, the toString method is invoked. That value is used unless the method returns an Object address, i.e. the default Object.toString() method.

Returns:
A formatted database table Column value.

main

public static void main(String[] args)
Executes unit tests for the SQLClauseHelper class.


2004.04.29



Copyright © 2004 J. Damon & Co.; All Rights Reserved WorldWide.