com.novell.nds.dirxml.driver.jdbc.db
Interface DBTimeTranslator

All Known Implementing Classes:
DBTimestamp

public interface DBTimeTranslator

An interface for implementing custom timestamp, date, and time translators. Each implementing class MUST implement a constructor with four java.lang.String arguments.

The first argument is the native database timestamp/date/time value. All implementations MUST be able to corectly translate ODBC canoncial formats for timestamp yyyy-mm-dd hh:mm:ss.fffffffff, date yyyy-mm-dd and time hh:mm:ss in addition to native database formats for these types. This is easily accomplished by using the java.sql.Timestamp.valueOf(String), java.sql.Date.valueOf(String) and java.sql.Time.valueOf(String) methods, respectively.

The second argument is the name of the Java class this instance represents (i.e., "java.sql.Timestamp", "java.sql.Date", or "java.sql.Time"), "java.sql.Timestamp" being the default. The unqualified class name can also be used (e.g., "timestamp", "date" or "time"), case-insensitive.

The third argument is reserved for future use.

The fourth argument is the output format, either "1" (integer) or "2" (string), the default being "1" (integer).

See Also:
DBLib.NewTimestamp(java.lang.String), DBLib.NewDate(java.lang.String), DBLib.NewTime(java.lang.String)

Field Summary
static String CLASS_DATE
          java.sql.Date
static String CLASS_TIME
          java.sql.Time
static String CLASS_TIMESTAMP
          java.sql.Timestamp
 
Method Summary
 String getDSTime()
          Returns this timestamp/date/time value in the directory canonical string format (e.g. CCYYMMDDHHMMSSNNNNNNNNN, CCYYMMDD or HHMMSS) or in the 32-bit integer string format (e.g. "1013368206"), if translation was successful.
 String getErrorMessage()
          Returns the first parse error message, if any.
 List getExceptions()
          Returns any exceptions generated while parsing.
 boolean parseError()
          Indicates whether an error occurred parsing this timestamp/date/time value.
 boolean precisionLost()
          Indicates whether precision was lost translating this timestamp value to the specified directory format.
 void setDSTime(String nativeTime)
          Translates a database-native timestamp/date/time value into an equivalent directory format as per the arguments passed to the constructor.
 

Field Detail

CLASS_TIMESTAMP

public static final String CLASS_TIMESTAMP
java.sql.Timestamp


CLASS_DATE

public static final String CLASS_DATE
java.sql.Date


CLASS_TIME

public static final String CLASS_TIME
java.sql.Time

Method Detail

getDSTime

public String getDSTime()
Returns this timestamp/date/time value in the directory canonical string format (e.g. CCYYMMDDHHMMSSNNNNNNNNN, CCYYMMDD or HHMMSS) or in the 32-bit integer string format (e.g. "1013368206"), if translation was successful.

Returns:
an equivalent directory canonical string value (e.g. "20010101000000000000000", "20010101" or "000000") or a 32-bit integer string value (e.g. "1013368206") if conversion was successful; a native database timestamp otherwise; never returns null

setDSTime

public void setDSTime(String nativeTime)
               throws ParseException,
                      IllegalArgumentException
Translates a database-native timestamp/date/time value into an equivalent directory format as per the arguments passed to the constructor.

Parameters:
nativeTime - a database-native timestamp, date, or time value; may be null
Throws:
ParseException
IllegalArgumentException

parseError

public boolean parseError()
Indicates whether an error occurred parsing this timestamp/date/time value.

Returns:
true if there was a parse error; false otherwise

getErrorMessage

public String getErrorMessage()
Returns the first parse error message, if any.

Returns:
a string with length > 0 if there was a parse error; empty string otherwise; never returns null

getExceptions

public List getExceptions()
Returns any exceptions generated while parsing. Returns a List of Exceptions with length > 0 if exceptions were generated; Collections.EMPTY_LIST otherwise.

Returns:
true if there was a parse error; false otherwise; never returns null

precisionLost

public boolean precisionLost()
Indicates whether precision was lost translating this timestamp value to the specified directory format.

Returns:
true if precision was lost; false otherwise