|
Expresso 5-5-0 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.lang.Throwable
java.lang.Exception
com.jcorporate.expresso.kernel.exception.ChainedException
com.jcorporate.expresso.core.db.DBException
com.jcorporate.expresso.core.dataobjects.DataException
com.jcorporate.expresso.core.dataobjects.jdbc.JDBCUtil
This class provides utility functions that are common across the jdbc.*
package classes. This class is normally not accessed except through other
classes in the jdbc package.
| Field Summary | |
static String |
DATE_FORMAT
|
static String |
DATETIME_FORMAT
|
static String |
TIME_FORMAT
|
| Constructor Summary | |
protected |
JDBCUtil()
|
| Method Summary | |
String |
buildWhereClause(JDBCDataObject criteria,
boolean useAllFields)
Build and return a string consisting of an SQL 'where' clause using the current field values as criteria for the search. |
FastStringBuffer |
buildWhereClauseBuffer(JDBCDataObject criteria,
boolean useAllFields,
FastStringBuffer allocatedBuffer)
Build and return a FastStringBuffer ring consisting of an SQL 'where' clause using the current field values as criteria for the search. |
boolean |
containsWildCards(JDBCDataObject ownerObject,
String fieldValue)
See if this field value contains wild cards (e.g. pattern matching criteria for the database). |
String |
formatDateTime(DataObject theObject,
String fieldName)
Given the value of a date/time or date/time field, return the value formatted as appropriate for the current DBMS. |
String |
formatDateTime(DataObject theObject,
String fieldName,
boolean surroundWithQuotes)
Given the value of a date/time or datetime field, return the value formatted as appropriate for the current DBMS. |
protected com.jcorporate.expresso.core.dataobjects.jdbc.JDBCUtil.DateReturnFormat |
formatDateTimeInternal(DataObject theObject,
String fieldName)
This class combines the old getFieldDate() with quoteIfNeeded() to format the Date-Time fields appropriately for storage. |
Date |
getDateField(DataObject theObject,
String fieldName)
Helper function that helps convert any string values from the database's format |
static JDBCUtil |
getInstance()
|
protected SimpleDateFormat |
getSimpleDateFormat(String pattern)
Get a SimpleDateFormat object that is cached. |
String |
makeLimitationStub(DBConnection theConnection,
DataObject theObj)
Creates the limitation syntax optimisation stub to embed inside the SQL command that performs search and retrieve. |
String |
quoteIfNeeded(JDBCDataObject targetObject,
String fieldName,
String rangeString)
Return the value of this field, placing double quotes around it if the field's datatype requires it. |
| Methods inherited from class com.jcorporate.expresso.core.db.DBException |
getDBMessage, getMessage |
| Methods inherited from class com.jcorporate.expresso.kernel.exception.ChainedException |
getErrorNumber, getNested, omitPackages, printStackTrace, printStackTrace, printStackTrace |
| Methods inherited from class java.lang.Throwable |
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, setStackTrace, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final String DATETIME_FORMAT
public static final String DATE_FORMAT
public static final String TIME_FORMAT
| Constructor Detail |
protected JDBCUtil()
| Method Detail |
public static JDBCUtil getInstance()
public String formatDateTime(DataObject theObject,
String fieldName)
throws DataException
fieldName - java.lang.String The value for the date/time field.theObject - the DataObject that the date field is coming
from.
DataException
public String formatDateTime(DataObject theObject,
String fieldName,
boolean surroundWithQuotes)
throws DataException
fieldName - java.lang.String The value for the date/time field.theObject - the DataObject that the date field is coming
from.surroundWithQuotes - set to true if you want the returned value
to be surrounded with single quotes, such as for a standard JDBC SELECT statement.
Use false if you want to use it, for example, in a PreparedStatement
DataExceptionprotected SimpleDateFormat getSimpleDateFormat(String pattern)
pattern - the format pattern to look up
public Date getDateField(DataObject theObject,
String fieldName)
throws DataException
theObject - the source data objectfieldName - the name of the field
DataException - upon error (possibly conversion error)
protected com.jcorporate.expresso.core.dataobjects.jdbc.JDBCUtil.DateReturnFormat formatDateTimeInternal(DataObject theObject,
String fieldName)
throws DataException
theObject - The object that contains the data to froatmfieldName - the name of the field to format
DataException - upon error
public String buildWhereClause(JDBCDataObject criteria,
boolean useAllFields)
throws DataException
criteria - the JDBCDataObject to build fromuseAllFields - True if all fields are to be used,
false for only key fields
DataException
public FastStringBuffer buildWhereClauseBuffer(JDBCDataObject criteria,
boolean useAllFields,
FastStringBuffer allocatedBuffer)
throws DataException
criteria - the JDBCDataObject to build fromuseAllFields - True if all fields are to be used,
false for only key fieldsallocatedBuffer - - An already allocated FastStringBuffer to fill out.
This allows for compatability with, for example, object pools.
DataException - upon error
public String makeLimitationStub(DBConnection theConnection,
DataObject theObj)
This method takes the limitation syntax string and performs a string replacement on the following tokens
ResultSet to skip
before reading the data.
ResultSet.
Also known as the rowlength.
ResultSet that the
search and retrieved should retrieve. The end record number
is equal to ( %offset% + %maxrecord% - 1 )
theConnection - the db connection to make this stub fromtheObj - the DataObject to query for the limitation stub
public String quoteIfNeeded(JDBCDataObject targetObject,
String fieldName,
String rangeString)
throws DataException
fieldName - The name of the field to be usedrangeString - the appropriately formatted stringtargetObject - the JDBCDataObject to query for metadata
DataException - If there is no such field or it's value cannot be
determined
public boolean containsWildCards(JDBCDataObject ownerObject,
String fieldValue)
throws DataException
fieldValue - The field value to check for wild cardsownerObject - the obejct to query for metadata
DataException
|
Expresso 5-5-0 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||