com.triactive.jdo.store.mapping
Class SqlTimestampMapping

java.lang.Object
  extended bycom.triactive.jdo.store.mapping.Mapping
      extended bycom.triactive.jdo.store.mapping.ColumnMapping
          extended bycom.triactive.jdo.store.mapping.SqlTimestampMapping
Direct Known Subclasses:
DateMapping, SqlTimestampCharMapping

public class SqlTimestampMapping
extends ColumnMapping


Field Summary
 
Fields inherited from class com.triactive.jdo.store.mapping.ColumnMapping
col, typeInfo
 
Fields inherited from class com.triactive.jdo.store.mapping.Mapping
dba, fmd, type
 
Constructor Summary
SqlTimestampMapping(DatabaseAdapter dba, java.lang.Class type)
           
SqlTimestampMapping(DatabaseAdapter dba, FieldMetaData fmd)
           
 
Method Summary
 java.lang.Object getObject(PersistenceManager pm, java.sql.ResultSet rs, int param)
           
protected  java.sql.Timestamp getTimestamp(java.sql.ResultSet rs, int param)
           
 void mapTo(Column col)
          Links this mapping to a specific column.
 SqlExpression newSqlExpression(QueryStatement.QueryColumn qsc)
          Returns an SQL expression representing a reference to a column in a query statement.
 SqlExpression newSqlLiteral(QueryStatement qs, java.lang.Object value)
          Returns an SQL expression representing the literal value of a Java object.
 void setObject(PersistenceManager pm, java.sql.PreparedStatement ps, int param, java.lang.Object value)
           
static java.sql.Timestamp stringToTimestamp(java.lang.String s, java.util.Calendar cal)
          Converts a string in JDBC timestamp escape format to a java.sql.Timestamp object using the "UTC" time zone.
static java.lang.String timestampToString(java.sql.Timestamp ts, java.util.Calendar cal)
          Formats a timestamp in JDBC timestamp escape format using the "UTC" time zone.
 
Methods inherited from class com.triactive.jdo.store.mapping.ColumnMapping
accessAsFieldIn, chooseColumnType, defineConstraints, defineStorage, equals, getBoolean, getByte, getChar, getColumn, getDouble, getFloat, getInt, getLong, getShort, getSqlInsertionValue, getSqlUpdateValue, getString, getTypeInfo, hashCode, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setShort, setString
 
Methods inherited from class com.triactive.jdo.store.mapping.Mapping
getDefaultMappingsByType, getFieldMetaData, getType
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlTimestampMapping

public SqlTimestampMapping(DatabaseAdapter dba,
                           java.lang.Class type)

SqlTimestampMapping

public SqlTimestampMapping(DatabaseAdapter dba,
                           FieldMetaData fmd)
Method Detail

mapTo

public void mapTo(Column col)
Description copied from class: ColumnMapping
Links this mapping to a specific column. Linkage involves at least two steps:
  1. Calling the column's Column.mapWith(com.triactive.jdo.store.mapping.ColumnMapping) method
  2. Setting this mapping's ColumnMapping.typeInfo to match the column's

This method can be called at most once for a given mapping. Subclasses may do extra work as a consequence of mapping themselves to a column, but they should always call super.mapTo(col) first.

Overrides:
mapTo in class ColumnMapping

setObject

public void setObject(PersistenceManager pm,
                      java.sql.PreparedStatement ps,
                      int param,
                      java.lang.Object value)
Overrides:
setObject in class ColumnMapping

getTimestamp

protected java.sql.Timestamp getTimestamp(java.sql.ResultSet rs,
                                          int param)

getObject

public java.lang.Object getObject(PersistenceManager pm,
                                  java.sql.ResultSet rs,
                                  int param)
Overrides:
getObject in class ColumnMapping

newSqlLiteral

public SqlExpression newSqlLiteral(QueryStatement qs,
                                   java.lang.Object value)
Description copied from class: Mapping
Returns an SQL expression representing the literal value of a Java object. The object must be of a type used with this mapping.

Specified by:
newSqlLiteral in class Mapping
Parameters:
qs - the surrounding query statement for the expression
value - the literal value

newSqlExpression

public SqlExpression newSqlExpression(QueryStatement.QueryColumn qsc)
Description copied from class: ColumnMapping
Returns an SQL expression representing a reference to a column in a query statement.

Specified by:
newSqlExpression in class ColumnMapping
Parameters:
qsc - the query column reference

stringToTimestamp

public static java.sql.Timestamp stringToTimestamp(java.lang.String s,
                                                   java.util.Calendar cal)
Converts a string in JDBC timestamp escape format to a java.sql.Timestamp object using the "UTC" time zone.

Parameters:
s - Timestamp string in format yyyy-mm-dd hh:mm:ss.fffffffff.
Returns:
Corresponding java.sql.Timestamp value.
Throws:
java.lang.IllegalArgumentException - If the given argument does not have the format yyyy-mm-dd hh:mm:ss.fffffffff.
See Also:
Timestamp

timestampToString

public static java.lang.String timestampToString(java.sql.Timestamp ts,
                                                 java.util.Calendar cal)
Formats a timestamp in JDBC timestamp escape format using the "UTC" time zone.

Parameters:
ts - The timestamp to be formatted.
Returns:
A String in yyyy-mm-dd hh:mm:ss.fffffffff format.
See Also:
Timestamp


Copyright © 2001-2007 The TJDO Project All Rights Reserved.