com.google.visualization.datasource.datatable.value
Class TimeOfDayValue

java.lang.Object
  extended by com.google.visualization.datasource.datatable.value.Value
      extended by com.google.visualization.datasource.datatable.value.TimeOfDayValue
All Implemented Interfaces:
java.lang.Comparable<Value>

public class TimeOfDayValue
extends Value

A value of type time-of-day. Time is represented internally by four fields: hours, minutes, seconds and milliseconds.

Author:
Hillel M.

Constructor Summary
TimeOfDayValue(com.ibm.icu.util.GregorianCalendar calendar)
          Creates a new instance based on the given GregorianCalendar.
TimeOfDayValue(int hours, int minutes, int seconds)
          Creates a new TimeOfDayValue.
TimeOfDayValue(int hours, int minutes, int seconds, int milliseconds)
          Creates a new TimeOfDayValue.
 
Method Summary
 int compareTo(Value other)
          Compares this value to another value of the same type.
 int getHours()
          Returns the underlying hours.
 int getMilliseconds()
          Returns the underlying milliseconds.
 int getMinutes()
          Returns the underlying minutes.
static TimeOfDayValue getNullValue()
          Static method to return the null value (same one for all calls).
 com.ibm.icu.util.Calendar getObjectToFormat()
          A method to retrieve a formattable object for this object.
 int getSeconds()
          Returns the underlying seconds.
 ValueType getType()
          Returns the type of this cell.
 int hashCode()
          Returns the hashcode of this value.
protected  java.lang.String innerToQueryString()
          Returns a string that, when parsed by the query parser, should return an identical value.
 boolean isNull()
          Tests whether this value is a logical null.
 java.lang.String toString()
          Returns the timeValue as a String using default formatting.
 
Methods inherited from class com.google.visualization.datasource.datatable.value.Value
equals, getLocalizedComparator, getNullValueFromValueType, toQueryString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeOfDayValue

public TimeOfDayValue(int hours,
                      int minutes,
                      int seconds)
Creates a new TimeOfDayValue.

Parameters:
hours - The hours.
minutes - The minutes.
seconds - The seconds.
Throws:
java.lang.IllegalArgumentException - Thrown when one of the paramters is illegal.

TimeOfDayValue

public TimeOfDayValue(int hours,
                      int minutes,
                      int seconds,
                      int milliseconds)
Creates a new TimeOfDayValue.

Parameters:
hours - The hours.
minutes - The minutes.
seconds - The seconds.
milliseconds - The milliseconds.
Throws:
java.lang.IllegalArgumentException - Thrown when one of the parameters is illegal.

TimeOfDayValue

public TimeOfDayValue(com.ibm.icu.util.GregorianCalendar calendar)
Creates a new instance based on the given GregorianCalendar. The given calendar's time zone must be set to "GMT" as a precondition to use this constructor. Note: The date time values: hour, minute, second and millisecond correspond to the values returned by calendar.get(field) of the given calendar.

Parameters:
calendar - A GregorianCalendar from which to extract this instance values: hour, minutes, seconds and milliseconds.
Throws:
java.lang.IllegalArgumentException - When calendar time zone is not set to GMT.
Method Detail

getNullValue

public static TimeOfDayValue getNullValue()
Static method to return the null value (same one for all calls).

Returns:
Null value.

getType

public ValueType getType()
Description copied from class: Value
Returns the type of this cell.

Specified by:
getType in class Value
Returns:
The type of this cell.

toString

public java.lang.String toString()
Returns the timeValue as a String using default formatting.

Overrides:
toString in class java.lang.Object
Returns:
The timeValue as a String using default formatting.

isNull

public boolean isNull()
Tests whether this value is a logical null.

Specified by:
isNull in class Value
Returns:
Indication of whether the value is null.

compareTo

public int compareTo(Value other)
Compares this value to another value of the same type.

Parameters:
other - Other value.
Returns:
0 if equal, negative if this is smaller, positive if larger.

hashCode

public int hashCode()
Description copied from class: Value
Returns the hashcode of this value. This is introduced here to force the subclasses to define this function.

Specified by:
hashCode in class Value
Returns:
The hashcode of this value.

getObjectToFormat

public com.ibm.icu.util.Calendar getObjectToFormat()
A method to retrieve a formattable object for this object. It is important to set the GMT TimeZone to avoid conversions related to TimeZone.

Specified by:
getObjectToFormat in class Value
Returns:
An object representing this value that can be formatted by a UFormat formatter, null for a NULL_VALUE.

getHours

public int getHours()
Returns the underlying hours.

Returns:
The underlying hours.
Throws:
NullValueException - Thrown when this Value is NULL_VALUE.

getMinutes

public int getMinutes()
Returns the underlying minutes.

Returns:
The underlying minutes.
Throws:
NullValueException - Thrown when this Value is NULL_VALUE.

getSeconds

public int getSeconds()
Returns the underlying seconds.

Returns:
The underlying seconds.
Throws:
NullValueException - Thrown when this Value is NULL_VALUE.

getMilliseconds

public int getMilliseconds()
Returns the underlying milliseconds.

Returns:
The underlying milliseconds.
Throws:
NullValueException - Thrown when this Value is NULL_VALUE.

innerToQueryString

protected java.lang.String innerToQueryString()
Returns a string that, when parsed by the query parser, should return an identical value. Assumes this value is not null.

Specified by:
innerToQueryString in class Value
Returns:
A string form of this value.


Copyright © 2009 Google. All Rights Reserved.