|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.farrago.type.runtime.SqlDateTimeWithoutTZ
public abstract class SqlDateTimeWithoutTZ
Runtime type for basic date/time/timestamp values without time zone
information. All of these types are represented by subclasses of ZonelessDatetime
and have a similar internal representation. This class
interoperates with java.sql (Jdbc) types since they are commonly used for
external data.
TODO: we can probably be smarter about how we allocate Java objects
TODO: precision and milliseconds for TIME and TIMESTAMP
Nested Class Summary | |
---|---|
static class |
SqlDateTimeWithoutTZ.SqlDate
SQL date value. |
static class |
SqlDateTimeWithoutTZ.SqlTime
SQL time value. |
static class |
SqlDateTimeWithoutTZ.SqlTimestamp
SQL timestamp value. |
Field Summary | |
---|---|
static String |
ADJUST_PRECISION_METHOD_NAME
Name of adjustPrecision(int) method. |
private Calendar |
cal
Calendar, which holds the client time zone. |
static String |
CEIL_METHOD_NAME
Name of ceil(org.eigenbase.sql.SqlIntervalQualifier.TimeUnit)
method. |
static String |
DateFormatStr
|
private static TimeZone |
defaultZone
|
static String |
FLOOR_METHOD_NAME
Name of floor(org.eigenbase.sql.SqlIntervalQualifier.TimeUnit)
method. |
private static TimeZone |
gmtZone
|
static String |
INTERNAL_TIME_FIELD_NAME
|
boolean |
isNull
Whether this value is null. |
private Calendar |
tempCal
The calendar to use as a temporary variable. |
static String |
TimeFormatStr
|
static String |
TimestampFormatStr
|
ZonelessDatetime |
value
The raw value of this SqlDateTimeWithoutTZ |
Fields inherited from interface net.sf.farrago.type.runtime.AssignableValue |
---|
ASSIGNMENT_METHOD_NAME |
Constructor Summary | |
---|---|
SqlDateTimeWithoutTZ()
Constructs a runtime object |
Method Summary | |
---|---|
void |
adjustPrecision(int precision)
Adjusts the precision of the value. |
void |
assignFrom(long l)
Assigns a value from another object. |
void |
assignFrom(Object date)
Assigns a value from another object. |
void |
assignFrom(String date,
String format,
TimeZone timeZone)
Assigns a value from a formatted string, optionally performing timezone translation. |
protected abstract void |
assignFromString(String s,
String format,
TimeZone timeZone)
Assigns the value from a string. |
private void |
attemptParse(String s,
String format,
TimeZone timeZone)
Attempts to parse the string, throwing an understandable exception if an error was detected. |
void |
ceil(int timeUnitOrdinal)
Rounds this datetime value up to a unit of time expressed using its ordinal. |
void |
ceil(SqlIntervalQualifier.TimeUnit timeUnit)
Rounds this datetime value up to a unit of time. |
void |
floor(int timeUnitOrdinal)
Rounds this datetime value down to a unit of time expressed using its ordinal. |
void |
floor(SqlIntervalQualifier.TimeUnit timeUnit)
Rounds this datetime value down to a unit of time. |
Calendar |
getCal()
Deprecated. please review this code |
protected TimeZone |
getClientTimeZone()
Returns the client time zone, as indicated by Calendar |
protected abstract String |
getFormat()
Returns the format string for this type. |
protected abstract Object |
getJdbcValue()
Gets data, casted as a Jdbc value. |
Object |
getNullableData()
Per the NullableValue contract, returns either null or the value
of this object as a Jdbc compatible value. |
static Class |
getPrimitiveClass()
|
Object |
getSpecialData()
Return data to result sets as ZonelessDatetime so that it may be properly localized by a Jdbc driver or client application. |
protected Calendar |
getTempCal()
Gets a temporary calendar object, initialized with this object's time zone and milliseconds value. |
protected abstract String |
getTypeName()
Returns the name of this type: DATE, TIME, or TIMESTAMP. |
protected TimeZone |
getValueTimeZone()
Returns the time zone used to store the value |
boolean |
isNull()
|
void |
setCal(Calendar cal)
Deprecated. please review this code |
void |
setNull(boolean b)
(Optionally) implements NullableValue |
String |
toString()
Returns a string in default format representing the datetime. |
String |
toString(String format)
Deprecated. please review this code |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String DateFormatStr
public static final String TimeFormatStr
public static final String TimestampFormatStr
private static final TimeZone gmtZone
private static final TimeZone defaultZone
public static final String INTERNAL_TIME_FIELD_NAME
public static final String ADJUST_PRECISION_METHOD_NAME
adjustPrecision(int)
method.
public static final String FLOOR_METHOD_NAME
floor(org.eigenbase.sql.SqlIntervalQualifier.TimeUnit)
method.
public static final String CEIL_METHOD_NAME
ceil(org.eigenbase.sql.SqlIntervalQualifier.TimeUnit)
method.
private Calendar cal
private Calendar tempCal
public ZonelessDatetime value
public boolean isNull
Constructor Detail |
---|
public SqlDateTimeWithoutTZ()
Method Detail |
---|
public static Class getPrimitiveClass()
protected abstract Object getJdbcValue()
public void setNull(boolean b)
public Object getNullableData()
NullableValue
contract, returns either null or the value
of this object as a Jdbc compatible value. The Jdbc value is constructed
relative to the server default time zone.
getNullableData
in interface DataValue
public Object getSpecialData()
getSpecialData
in interface SpecialDataValue
public boolean isNull()
public void assignFrom(Object date)
The Object may be a Long
or long
if it is being
intialized from a constant, or being translated from a Fennel value. If
so, then the Fennel type must match the Farrago type. It is legal to
assign a ZonelessDate
to a ZonelessDate
and a ZonelessTime
to a ZonelessTime
, but it is not valid to assign a
Timestamp to either, or vice versa.
assignFrom
in interface AssignableValue
date
- value to assign, or null to set nullpublic void assignFrom(String date, String format, TimeZone timeZone)
If format
is null, uses the default format string of this
type, as per getFormat()
.
If timeZone
is not null, performs translation assuming
that the input string is in that time zone. For example,
assignFrom('06:00', 'HH:mm', TimeZone.PST)
returns the Time value
'14:00', because '06:00 PST' equals '14:00 GMT'.
timeZone
is ignored for date values.
date
- stringformat
- format string, as per SimpleDateFormat
, or nulltimeZone
- target timezoneassignFrom(Object)
public void assignFrom(long l)
assignFrom(Object)
private void attemptParse(String s, String format, TimeZone timeZone)
protected abstract void assignFromString(String s, String format, TimeZone timeZone)
s
- a string representing a datetime in the given formatformat
- format string as per SimpleDateFormat
, not nulltimeZone
- target timezonepublic Calendar getCal()
public void setCal(Calendar cal)
cal
- calendar value to assign frompublic String toString(String format)
protected TimeZone getClientTimeZone()
protected TimeZone getValueTimeZone()
public String toString()
toString
in class Object
protected abstract String getFormat()
protected abstract String getTypeName()
public void floor(SqlIntervalQualifier.TimeUnit timeUnit)
For example, floor(MINUTE)
applied to TIMESTAMP
'2006-07-03 12:34:56.7'
returns TIMESTAMP '2006-07-03
12:00:00.0'
.
timeUnit
- Time unitpublic void floor(int timeUnitOrdinal)
timeUnitOrdinal
- Ordinal of SqlIntervalQualifier.TimeUnit
valuepublic void ceil(SqlIntervalQualifier.TimeUnit timeUnit)
For example, ceil(MINUTE)
applied to TIMESTAMP
'2006-07-03 12:34:56.7'
returns TIMESTAMP '2006-07-03
13:00:00.0'
.
timeUnit
- Time unitpublic void ceil(int timeUnitOrdinal)
timeUnitOrdinal
- Ordinal of SqlIntervalQualifier.TimeUnit
valuepublic void adjustPrecision(int precision)
For example, adjustPrecision(2)
applied to the value
TIME '12:34:56.789'
rounds to 10 milliseconds, and returns
TIME '12:34:56.79'
.
precision
- Number of digits to keep the right of the decimal point
in the seconds valueprotected Calendar getTempCal()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |