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

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

public class DateValue
extends Value

A value of type date. Used to represent a specific day in a given year. This differs from DateTimeValue, which represents a specific day in a given year as well as a specific time during that day. Date is represented internally by three values: year, month and dayOfMonth. This class stores only legitimate dates where the validation is done using ibm.icu.GregorianCalendar.

Author:
Hillel M.

Constructor Summary
DateValue(com.ibm.icu.util.GregorianCalendar calendar)
          Creates a new instance based on the given GregorianCalendar.
DateValue(int year, int month, int dayOfMonth)
          Creates a new date value.
 
Method Summary
 int compareTo(Value other)
          Compares this value to another value of the same type.
 int getDayOfMonth()
          Returns the underlying dayOfMonth.
 int getMonth()
          Returns the underlying month.
static DateValue getNullValue()
          Static method to return the null value (same one for all calls).
 com.ibm.icu.util.Calendar getObjectToFormat()
          Uses an ibm.icu.text.UFormat instance to format Values.
 ValueType getType()
          Returns the type of this cell.
 int getYear()
          Returns the underlying year.
 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 a logical null.
 java.lang.String toString()
          Returns the dateValue as a String using temporary 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

DateValue

public DateValue(int year,
                 int month,
                 int dayOfMonth)
Creates a new date value. The input is checked using a GregorianCalendar. Note that we use java convention for months: January = 0, ..., December = 11.

Parameters:
year - The year.
month - The month.
dayOfMonth - The day in the month.
Throws:
java.lang.IllegalArgumentException - Thrown when one of the parameters is illegal.

DateValue

public DateValue(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 values: year, month, dayOfMonth correspond to the values returned by calendar.get(field) of the given calendar.

Parameters:
calendar - A gregorian to extract this instance values: year, month and dayOfMonth.
Throws:
java.lang.IllegalArgumentException - When calendar time zone is not set to GMT.
Method Detail

getNullValue

public static DateValue 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 dateValue as a String using temporary formatting.

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

isNull

public boolean isNull()
Tests whether this value 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()
Description copied from class: Value
Uses an ibm.icu.text.UFormat instance to format Values. The following method returns an object representing this Value that a UFormat can format.

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.

getYear

public int getYear()
Returns the underlying year.

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

getMonth

public int getMonth()
Returns the underlying month.

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

getDayOfMonth

public int getDayOfMonth()
Returns the underlying dayOfMonth.

Returns:
the underlying dayOfMonth.
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.