|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.util.Date
com.davisor.data.CalendarFieldData
CalendarFieldData represents the calendar field value. Unlike traditional dates, a calendar field does not represent an exact moment of time, or even a fixed period of time. Instead, calendar dates represent abstract calendar time periods like "five years" or "three weeks". The interpretation of such values depends on which calendar system is used, and what calendar date it is.
| Field Summary | |
protected CalendarField |
M_field
Calendar field. |
protected DateFormatType |
M_type
The type of this data. |
| Constructor Summary | |
CalendarFieldData()
Default constructor. |
|
CalendarFieldData(CalendarFieldData cfd,
boolean deep)
Deep or shallow copy constructor. |
|
CalendarFieldData(DateFormatType type)
Creates a calendar field data value from a given type and default value (0 ms). |
|
CalendarFieldData(DateFormatType type,
CalendarField field)
Creates a calendar field data value from a given type and a calendar field value. |
|
CalendarFieldData(DateFormatType type,
CalendarFieldData data)
Creates a calendar field data value from a given type and a calendar field data value. |
|
CalendarFieldData(DateFormatType type,
int[] fieldValue)
Creates a calendar field data value from a given type and a calendar field value. |
|
CalendarFieldData(DateFormatType type,
java.lang.String stringValue,
java.text.ParsePosition status)
Creates a calendar field data value from a string value. |
|
| Method Summary | |
DataValue |
abs()
Returns absolute data value of current value. |
DataValue |
add(DataValue value)
Adds given value to current value. |
DataValue |
ceil(DataValue precision)
Quantizes the current value up to an even value within given precision. |
int |
compareTo(java.lang.Object o)
Compares this timestamp against other Date objects. |
double |
deinterpolate(DataValue min,
DataValue max)
De-interpolates the current data value to a scalar value, in respect, with given data value range. |
DataValue |
div(DataValue value)
Divides the current value with given value. |
com.davisor.core.Dupable |
dup()
Makes a deep copy of this object. |
DataValue |
floor(DataValue precision)
Quantizes the current value down to an even value within given precision. |
CalendarField |
getField()
Gets the calendar field. |
java.lang.String |
getFormat()
Gets the type specification optimal for this particular value. |
long |
getTime()
Gets the duration of this calendar field in milliseconds. |
Type |
getType()
Gets data type. |
DataValue |
interpolate(double value,
DataValue max)
Interpolates the given scalar value to data value, in respect, with the range defined by this value and the given maximum value. |
boolean |
isNull()
Tests if this data object value is undetermined. |
DataValue |
max(DataValue value)
Finds the larger of this and the given data value. |
DataValue |
min(DataValue value)
Finds the smaller of this and the given data value. |
DataValue |
mul(DataValue value)
Multipies the current value with given value. |
DataValue |
negate()
Returns the negation of current value. |
void |
setField(CalendarField field)
Sets the calendar field. |
void |
setTime(long time)
Sets the duration of this calendar date in milliseconds. |
void |
setValue(int value)
Sets the calendar field value. |
void |
setValue(java.lang.String stringValue,
java.text.ParsePosition status)
Sets data value from a string value. |
DataValue |
sub(DataValue value)
Substracts given value from current value. |
void |
toStatement(java.sql.PreparedStatement statement,
int parameter)
Converts data to a prepared statement input parameter. |
java.lang.String |
toString()
Gets the string representation of this calendar date. |
java.lang.String |
toXML()
Gets the XML string representation of this value. |
DataValue |
unit(DataValue targetValue,
double maxSteps)
Gets the largest suitable unit step to represent a value change between this value and the given target value. |
| Methods inherited from class java.util.Date |
after, before, clone, compareTo, equals, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, 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 |
| Field Detail |
protected DateFormatType M_type
protected CalendarField M_field
| Constructor Detail |
public CalendarFieldData()
Assosiates this data with the default type, and sets the current calendar field to zero milliseconds.
CalendarField
public CalendarFieldData(CalendarFieldData cfd,
boolean deep)
cfd - source calendar field data (may be null)deep - determines if the copying is deep or shallowgetType(),
Type.dup()public CalendarFieldData(DateFormatType type)
type - calendar field type
public CalendarFieldData(DateFormatType type,
java.lang.String stringValue,
java.text.ParsePosition status)
throws InvalidDataException
type - calendar field typestringValue - string value to be parsedstatus - parse status (may be null)
InvalidDataException - if string value could not be parsersetValue(String,ParsePosition),
DateFormatType.dateValue(String,ParsePosition)
public CalendarFieldData(DateFormatType type,
int[] fieldValue)
type - calendar field typefieldValue - Java Calendar field code and value
public CalendarFieldData(DateFormatType type,
CalendarFieldData data)
type - calendar field typedata - calendar field data
public CalendarFieldData(DateFormatType type,
CalendarField field)
type - calendar field type (may be null)field - Java Calendar field (may be null)| Method Detail |
public int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparableo - a Date object to compare this timestamp against with
java.lang.ClassCastException - if the given object is not a DateTimestampData.compareTo(java.util.Date,Object)
public Type getType()
throws InvalidDataException
getType in interface DataInvalidDataException - if type retrieval failspublic boolean isNull()
isNull in interface SerializableDataType.isNull(com.davisor.data.SerializableData)
public DataValue abs()
throws InvalidDataException
Absolute values must satisfy a requirement that when added to any other value, the result must be greater than or equal to the original value.
abs in interface DataValueInvalidDataException - if absolute value can not be computed
public DataValue add(DataValue value)
throws InvalidDataException
If the value is an instance of CalendarData, the
current calendar field value is added to it.
If the value is an instance of CalendarFieldData,
and the field type is equal to current field, the field values
are added. If the field types are not equal, a new calendar
containing the two fields is created.
If the value is an instance of Date, it is
converted to a calendar value, to which the current field
value is then added.
In any other case, the operation fails.
add in interface DataValuevalue - a data value to be added to this data value
InvalidDataException - if the data values cannot be addedsub(com.davisor.data.DataValue),
DateFormatType.toData(java.util.Date)
public DataValue ceil(DataValue precision)
throws InvalidDataException
ceil in interface DataValueprecision - the precision within quantization occurs
InvalidDataException - if precision was of unacceptable typefloor(com.davisor.data.DataValue)
public double deinterpolate(DataValue min,
DataValue max)
throws InvalidDataException
Timestamp values are de-interpolated with the equation:
(thisValue - minValue) / (maxValue - minValue)
deinterpolate in interface DataValuemin - a data value representing a range's lower limitmax - a data value representing a range's higher limit
InvalidDataException - if the de-interpolation failsDataValue.interpolate(double, com.davisor.data.DataValue),
DeinterpolationException,
TupleData.deinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue)
public DataValue div(DataValue value)
throws InvalidDataException
div in interface DataValuevalue - the divider
InvalidDataException - if divider is not a number.
public DataValue floor(DataValue precision)
throws InvalidDataException
floor in interface DataValueprecision - the precision within quantization occurs
InvalidDataException - if precision was of unacceptable typeceil(com.davisor.data.DataValue),
DateFormatType.toData(Object)public java.lang.String getFormat()
This method is currently unimplemented.
getFormat in interface DataValueData.getType(),
Type.getFormat(),
Type.setFormat(java.lang.String)
public DataValue interpolate(double value,
DataValue max)
throws InvalidDataException
All number values can interpolate with this simple equation:
minValue + value * (maxValue - minValue)
interpolate in interface DataValuevalue - the scalar value to be interpolatedmax - a data value representing a range's higher limit
InvalidDataException - if the interpolation failsDateFormatType.toData(Object)
public DataValue max(DataValue value)
throws InvalidDataException
This method is currently unimplemented.
max in interface DataValuevalue - a data value to be compared with this data value
InvalidDataException - if the data value cannot be compared.min(com.davisor.data.DataValue)
public DataValue min(DataValue value)
throws InvalidDataException
This method is currently unimplemented.
min in interface DataValuevalue - a data value to be compared with this data value
InvalidDataException - if the data value cannot be compared.max(com.davisor.data.DataValue)
public DataValue mul(DataValue value)
throws InvalidDataException
mul in interface DataValuevalue - the multiplier
InvalidDataException - if multiplier is not a number.
public DataValue negate()
throws InvalidDataException
negate in interface DataValueInvalidDataException - if absolute value can not be computed
public void setValue(java.lang.String stringValue,
java.text.ParsePosition status)
throws InvalidDataException
setValue in interface DataValuestringValue - string value to be parsed (may be null)status - parse status (may be null)
InvalidDataException - if string value could not be parserDateFormatType.dateValue(String,ParsePosition)
public DataValue sub(DataValue value)
throws InvalidDataException
If the value is an instance of CalendarData, the
current calendar field is converted to a calendar value, from
which the other calendar value is then substracted from.
If the value is an instance of CalendarFieldData, and
the field type is equal to current field, the field values
are subtracted. If the field types are not equal, the current
calendar field is converted to a calendar value, from
which the other calendar value is then substracted from.
If the value is an instance of Date, the
current calendar field is converted to a calendar value, from
which the other calendar value is then substracted from.
In any other case, the operation fails.
sub in interface DataValuevalue - a data value to be substracted from this data value
InvalidDataException - if the data values cannot be substractedadd(com.davisor.data.DataValue),
DateFormatType.toData(java.util.Date)
public void toStatement(java.sql.PreparedStatement statement,
int parameter)
throws java.sql.SQLException
toStatement in interface DataValuejava.sql.SQLException - if a SQL error occurs.public java.lang.String toXML()
toXML in interface DataValuetoString(),
XMLUnicodeEncoder.encode(java.lang.String, boolean)
public DataValue unit(DataValue targetValue,
double maxSteps)
throws InvalidDataException
Calendar field data objects are designed to represent time steps.
Therefore, the result will be a new calendar field, equal to to
the current value of this object. The given
targetValue and maxSteps is ignored.
unit in interface DataValuetargetValue - target value to be reached (ignored)maxSteps - maximum number of steps (zero leaves the choise open)
InvalidDataException - if target value is unsuitableDateFormatType.toData(Object)public long getTime()
DateFormatType.createCalendar(CalendarField)public void setTime(long time)
public com.davisor.core.Dupable dup()
dup in interface com.davisor.core.Dupablepublic java.lang.String toString()
toString in interface DataValuepublic CalendarField getField()
setField(com.davisor.data.CalendarField)public void setField(CalendarField field)
field - calendar fieldgetField()public void setValue(int value)
value - calendar field valuegetField()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||