BEA Systems, Inc.

com.beasys.commerce.axiom.document.ref
Class StatementParams

java.lang.Object
  |
  +--com.beasys.commerce.axiom.document.ref.StatementParams

public class StatementParams
extends java.lang.Object

A little holder class for the information required to create and execute a PreparedStatement, plus how to convert a Search/Expression/Criteria/Logical into a StatementParams.

This class is specific to the table structure of the RefDocumentProvider.


Field Summary
static java.text.DateFormat dateFormat
          A date formatter for "MM/dd/yyyy HH:mm:ss z" (02/28/2000 15:58:35 MST).
static java.lang.String DOC_MD_TABLE
          The wlcs_document_metadata table name.
static java.lang.String DOC_TABLE
          The wlcs_document table name.
 long maxReturn
          The max number to return (0 or less for all).
 java.util.List params
          The list of input parameters that match up with the SQL string.
 SortCriteria[] sortCriteria
          The list of SortCriteria needing to be applied.
 java.lang.String sql
          The SQL string.
 
Constructor Summary
StatementParams()
           
 
Method Summary
protected static java.lang.String createStatementParams(Expression expr, java.util.List params)
          Utility method to convert an Expression into a SQL expression.
protected static void createStatementParams(java.lang.StringBuffer buf, Criteria c, java.util.List params)
          Utility to convert a Criteria into a SQL expression.
protected static void createStatementParams(java.lang.StringBuffer buf, Expression expr, java.util.List params)
          Utility method to convert an Expression into a SQL expression.
protected static void createStatementParams(java.lang.StringBuffer buf, Logical l, java.util.List params)
          Utility to convert a Logical into a SQL expression.
static java.lang.String getSQLOperator(java.lang.String c)
          Return the corresponding SQL operator for the given comparator.
static StatementParams getStatementParams(java.lang.String baseSql, Search params)
          Utility method to get a StatementParams from Search params.
static boolean isLegalSingleValueComparator(java.lang.String c)
          Determine if a comparator is legal, single-value attribute comparator.
 java.sql.PreparedStatement prepare(java.sql.Connection con)
          Prepare a statement from our sql and input params on the given database connection.
 void sort(java.util.List list)
          Sort a list of DocumentMetadataDefs based upon our sort criteria.
static java.lang.Object toSQLLike(java.lang.Object obj)
          Convert an object, which might be a string, to a SQL like string.
static java.lang.String toSQLLike(java.lang.String like)
          Convert a query LIKE value to a SQL LIKE value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOC_TABLE

public static final java.lang.String DOC_TABLE
The wlcs_document table name.
See Also:
RefDocumentProvider.DOC_TABLE

DOC_MD_TABLE

public static final java.lang.String DOC_MD_TABLE
The wlcs_document_metadata table name.
See Also:
RefDocumentProvider.DOC_MD_TABLE

dateFormat

public static final java.text.DateFormat dateFormat
A date formatter for "MM/dd/yyyy HH:mm:ss z" (02/28/2000 15:58:35 MST).

sql

public java.lang.String sql
The SQL string.

maxReturn

public long maxReturn
The max number to return (0 or less for all).

params

public java.util.List params
The list of input parameters that match up with the SQL string.

sortCriteria

public SortCriteria[] sortCriteria
The list of SortCriteria needing to be applied.

This will be null or empty if no additional sorting is required.

Constructor Detail

StatementParams

public StatementParams()
Method Detail

prepare

public java.sql.PreparedStatement prepare(java.sql.Connection con)
                                   throws java.sql.SQLException
Prepare a statement from our sql and input params on the given database connection.

sort

public void sort(java.util.List list)
          throws DocumentException
Sort a list of DocumentMetadataDefs based upon our sort criteria.

getStatementParams

public static StatementParams getStatementParams(java.lang.String baseSql,
                                                 Search params)
                                          throws DocumentException
Utility method to get a StatementParams from Search params.
Parameters:
baseSql - the base select part of the sql (no from, no where, "doc" is document table, "md" is document_metadata table).

createStatementParams

protected static java.lang.String createStatementParams(Expression expr,
                                                        java.util.List params)
                                                 throws DocumentException
Utility method to convert an Expression into a SQL expression.
Parameters:
expr - the expression object.
params - the prepared statement input parameters list (will be appended to).
Returns:
the SQL expression (no WHERE, no SELECT).
Throws:
DocumentException - thrown on invalid expression data.

createStatementParams

protected static void createStatementParams(java.lang.StringBuffer buf,
                                            Expression expr,
                                            java.util.List params)
                                     throws DocumentException
Utility method to convert an Expression into a SQL expression.
Parameters:
buf - the string buffer to write into.
expr - the expression object.
params - the prepared statement input parameters list (will be appended to).
Returns:
the SQL expression (no WHERE, no SELECT).
Throws:
DocumentException - thrown on invalid expression data.

createStatementParams

protected static void createStatementParams(java.lang.StringBuffer buf,
                                            Criteria c,
                                            java.util.List params)
                                     throws DocumentException
Utility to convert a Criteria into a SQL expression.
Parameters:
buf - the string buffer to write into.
c - the criteria object.
params - the prepared statement input parameters list (will be appended to).
Returns:
the SQL expression (no WHERE, no SELECT).
Throws:
DocumentException - thrown on invalid expression data.

createStatementParams

protected static void createStatementParams(java.lang.StringBuffer buf,
                                            Logical l,
                                            java.util.List params)
                                     throws DocumentException
Utility to convert a Logical into a SQL expression.
Parameters:
buf - the string buffer to write into.
l - the logical object.
params - the prepared statement input parameters list (will be appended to).
Returns:
the SQL expression (no WHERE, no SELECT).
Throws:
DocumentException - thrown on invalid expression data.

isLegalSingleValueComparator

public static boolean isLegalSingleValueComparator(java.lang.String c)
Determine if a comparator is legal, single-value attribute comparator.

getSQLOperator

public static java.lang.String getSQLOperator(java.lang.String c)
Return the corresponding SQL operator for the given comparator.
Parameters:
op - the comparator (one from TypesHelper).

toSQLLike

public static java.lang.String toSQLLike(java.lang.String like)
Convert a query LIKE value to a SQL LIKE value.

toSQLLike

public static java.lang.Object toSQLLike(java.lang.Object obj)
Convert an object, which might be a string, to a SQL like string.

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved