com.davisor.data
Class TimeData

java.lang.Object
  extended byjava.util.Date
      extended bycom.davisor.data.TimestampData
          extended bycom.davisor.data.TimeData
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, Data, DataValue, com.davisor.core.Dupable, java.io.Serializable, SerializableData

public class TimeData
extends TimestampData

TimeData represents the time of day, as opposed to date values that represent dates and timestamps that represent them both.

Since:
JDK1.1
See Also:
setTime(long), TimeType, Serialized Form

Field Summary
 
Fields inherited from class com.davisor.data.TimestampData
M_type, NaT
 
Constructor Summary
TimeData()
          Create a new time data object with the current time and default type.
TimeData(DateFormatType type)
          Create a new time data object with the current time and the given type.
TimeData(DateFormatType type, java.util.Date value)
          Create a new time data object with the current time and the given type and value
TimeData(DateFormatType type, long milliseconds)
          Create a new time data object with the current time and the given type and value.
TimeData(DateFormatType type, java.lang.String stringValue, java.text.ParsePosition status)
          Creates a time data value from a string value.
TimeData(TimeData data, boolean deep)
          Deep or shallow copy constructor.
 
Method Summary
 double deinterpolate(DataValue min, DataValue max)
          De-interpolates the current data value to a scalar value, in respect, with given data value range.
 com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 void setTime(long milliseconds)
          Sets the current time value, but enforcing time over date by stripping all the date information from the given timestamp value.
 void toStatement(java.sql.PreparedStatement statement, int parameter)
          Convert data to a prepared statement input parameter.
 
Methods inherited from class com.davisor.data.TimestampData
abs, add, ceil, ceil, compareTo, compareTo, createCalendar, div, floor, floor, getFormat, getType, initTime, interpolate, isNull, max, min, mul, negate, setTime, setValue, sub, toString, toXML, unit
 
Methods inherited from class java.util.Date
after, before, clone, compareTo, equals, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTime, getTimezoneOffset, getYear, hashCode, parse, setDate, setHours, setMinutes, setMonth, setSeconds, setYear, toGMTString, toLocaleString, UTC
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeData

public TimeData()
Create a new time data object with the current time and default type.


TimeData

public TimeData(TimeData data,
                boolean deep)
Deep or shallow copy constructor. If it is shallow, then the new object shares an underlying type with the original object. If it is deep, then the type is dupped.

Parameters:
data - source data (may be null)
deep - determines if the copying is deep or shallow
See Also:
TimestampData.getType(), Type.dup()

TimeData

public TimeData(DateFormatType type)
Create a new time data object with the current time and the given type.

Parameters:
type - time type

TimeData

public TimeData(DateFormatType type,
                java.util.Date value)
Create a new time data object with the current time and the given type and value

Parameters:
type - time type
value - time value (may be null)
See Also:
TimeData(DateFormatType,long)

TimeData

public TimeData(DateFormatType type,
                long milliseconds)
Create a new time data object with the current time and the given type and value. The given milliseconds value is interpreted as a calendar date, from which all but the time fields are then cleared away. The resulting milliseconds value represents a time value during the calendar default epoch day.

Parameters:
type - time type
milliseconds - time value
See Also:
TimeData(DateFormatType,java.util.Date), TimestampData.initTime(com.davisor.data.DateFormatType, long)

TimeData

public TimeData(DateFormatType type,
                java.lang.String stringValue,
                java.text.ParsePosition status)
         throws InvalidDataException
Creates a time data value from a string value.

Parameters:
stringValue - string value to be parsed
status - parse status (may be null)
Throws:
InvalidDataException - if string value could not be parser
See Also:
TimestampData.setValue(String,ParsePosition)
Method Detail

toStatement

public void toStatement(java.sql.PreparedStatement statement,
                        int parameter)
                 throws java.sql.SQLException
Convert data to a prepared statement input parameter.

Specified by:
toStatement in interface DataValue
Overrides:
toStatement in class TimestampData
Throws:
java.sql.SQLException - if a SQL error occurs.

setTime

public void setTime(long milliseconds)
Sets the current time value, but enforcing time over date by stripping all the date information from the given timestamp value.

Parameters:
milliseconds - date time value
See Also:
TimestampData.initTime(com.davisor.data.DateFormatType, long), DateData.setTime(long)

deinterpolate

public double deinterpolate(DataValue min,
                            DataValue max)
                     throws InvalidDataException
De-interpolates the current data value to a scalar value, in respect, with given data value range. This gives scalar values between [0,1] when the current data value in within the range, negative scalar values when the data value falls below the range and scalar values greater than 1.0 otherwise.

Timestamp values are de-interpolated with the equation:

(thisValue - minValue) / (maxValue - minValue)

Specified by:
deinterpolate in interface DataValue
Overrides:
deinterpolate in class TimestampData
Parameters:
min - a data value representing a range's lower limit
max - a data value representing a range's higher limit
Returns:
de-interpolated scalar value
Throws:
InvalidDataException - if the de-interpolation fails

dup

public com.davisor.core.Dupable dup()
Makes a deep copy of this object.

Specified by:
dup in interface com.davisor.core.Dupable
Overrides:
dup in class TimestampData


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.