jacquard 1.12.0 by The Web Engineering Factory and Toolworks

uk.co.weft.dbutil
Class ColumnDescriptor

java.lang.Object
  extended byuk.co.weft.dbutil.ColumnDescriptor
Direct Known Subclasses:
BitColumnDescriptor, BooleanColumnDescriptor, CharacterColumnDescriptor, ClobColumnDescriptor, DateColumnDescriptor, IntegerColumnDescriptor, ObjectColumnDescriptor, RealColumnDescriptor, TimeColumnDescriptor

public abstract class ColumnDescriptor
extends java.lang.Object

A cache to hold the essential features of a database column. In effect, a hack.

Version:
$Revision: 1.21.4.3 $ This revision: $Author: simon $
Author:
Simon Brooke

Constructor Summary
ColumnDescriptor()
           
 
Method Summary
static ColumnDescriptor createColumnDescriptor(int type, java.lang.String name, int size, int precision, int nullable)
          create an appropriate ColumnDescriptor for this type with these data
protected  java.lang.String format(Context c)
          format the value of my name in this context as a datatype of the appropriate kind for splicing into this column in a SQL query.
protected  java.lang.String formatForInsert(Context c)
          Deprecated. this has actually never worked as advertised and is wrong - probably for all purposes - but it has been in the toolkit so long that it is possible that some applications out there depend on its wrong behaviour, so this has not been corrected. If you are using it, consider formatForSelect( Context) instead.
protected  java.lang.String formatForMatch(Context c)
          Deprecated. use #formatForMatch(Context,boolean)
protected  java.lang.String formatForMatch(Context c, boolean exact)
          format me appropriately for use in the select operation of a match query.
protected  java.lang.String formatForSelect(Context c)
          format me appropriately for use in a select query or in the 'where' clause (not the 'update' clause) of an update query.
protected  java.lang.String formatForUpdate(Context c)
          format me appropriately for use in the 'update' clause (not the 'where' clause) of an update query.
protected  java.lang.Object genKey(Context c)
          generate a new unique key for me given this context
protected  java.lang.Object interpret(Context context, java.sql.ResultSet results)
          put into this context an interpretation of the value of my name in these results.
protected  java.lang.String quoteValue(java.lang.String s)
          enclose a string in single quote marks, escaping any embedded single quotes Keek this in sync with ClobColumnDescriptor.format() fun with quotes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnDescriptor

public ColumnDescriptor()
Method Detail

createColumnDescriptor

public static ColumnDescriptor createColumnDescriptor(int type,
                                                      java.lang.String name,
                                                      int size,
                                                      int precision,
                                                      int nullable)
                                               throws DataFormatException
create an appropriate ColumnDescriptor for this type with these data

Throws:
DataFormatException

format

protected java.lang.String format(Context c)
                           throws DataFormatException
format the value of my name in this context as a datatype of the appropriate kind for splicing into this column in a SQL query. Specialise: default handles simple character objects.

Throws:
DataFormatException

formatForInsert

protected java.lang.String formatForInsert(Context c)
                                    throws DataFormatException
Deprecated. this has actually never worked as advertised and is wrong - probably for all purposes - but it has been in the toolkit so long that it is possible that some applications out there depend on its wrong behaviour, so this has not been corrected. If you are using it, consider formatForSelect( Context) instead.

format me appropriately for use in an insert query

Parameters:
c - context in which to find my value
Throws:
DataFormatException - if anything goes wrong (this class does not throw it but specialisations may)

formatForMatch

protected java.lang.String formatForMatch(Context c)
                                   throws DataFormatException
Deprecated. use #formatForMatch(Context,boolean)

format me appropriately for use in the select operation of a match query. For most column descriptors this is exactly the same as formatForSelect()

Throws:
DataFormatException

formatForMatch

protected java.lang.String formatForMatch(Context c,
                                          boolean exact)
                                   throws DataFormatException
format me appropriately for use in the select operation of a match query. For most column descriptors this is exactly the same as formatForSelect()

Parameters:
c - the context to match
exact - whether or not an exact match is required
Throws:
DataFormatException

formatForSelect

protected java.lang.String formatForSelect(Context c)
                                    throws DataFormatException
format me appropriately for use in a select query or in the 'where' clause (not the 'update' clause) of an update query. The difference is subtle and relates to null values, as in 'update foo set bar = null where baz is null'; this method generates the 'bar is null' part

Parameters:
c - context in which to find my value
Throws:
DataFormatException - if anything goes wrong (this class does not throw it but specialisations may)

formatForUpdate

protected java.lang.String formatForUpdate(Context c)
                                    throws DataFormatException
format me appropriately for use in the 'update' clause (not the 'where' clause) of an update query. The difference is subtle and relates to null values, as in 'update foo set bar = null where baz is null'; this method generates the 'bar = null' part

Parameters:
c - context in which to find my value
Throws:
DataFormatException - if anything goes wrong (this class does not throw it but specialisations may)

genKey

protected java.lang.Object genKey(Context c)
                           throws DataStoreException
generate a new unique key for me given this context

Throws:
throws - DataStoreException if a unique key could not be generated
DataStoreException

interpret

protected java.lang.Object interpret(Context context,
                                     java.sql.ResultSet results)
                              throws DataFormatException
put into this context an interpretation of the value of my name in these results. Return the interpretation. Specialise: default handles simple character objects.

Throws:
DataFormatException

quoteValue

protected java.lang.String quoteValue(java.lang.String s)
enclose a string in single quote marks, escaping any embedded single quotes Keek this in sync with ClobColumnDescriptor.format() fun with quotes. Keep this in sync with ColumnDescriptor.quoteValue()

Parameters:
s - the unquoted string
Returns:
the quoted string, or null if s was null
See Also:
ClobColumnDescriptor.format(Context)

jacquard 1.12.0 by The Web Engineering Factory and Toolworks