eu.beesoft.gantt.chart
Enum TimeUnit

java.lang.Object
  extended by java.lang.Enum<TimeUnit>
      extended by eu.beesoft.gantt.chart.TimeUnit
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<TimeUnit>

public enum TimeUnit
extends java.lang.Enum<TimeUnit>

Enumeration for time unit granularity. It contains constants from seconds to year.


Enum Constant Summary
DAY
           
HALF_HOUR
           
HOUR
           
MINUTE
           
MONTH
           
QUARTER
           
QUARTER_HOUR
           
SECOND
           
WEEK
           
YEAR
           
 
Method Summary
 int getCalendarField()
          Returns field constant of Calendar that reflects this TimeUnit.
 int getCardinality(TimeUnit child, java.util.Date date)
          Returns amount of child TimeUnits in this constant.
 int getFieldAmount()
          Returns amount of calendar units (returned by getCalendarField() method) in this constant.
 boolean isGreaterThan(TimeUnit granularity)
          Returns true if this instance is greater than given granularity.
 boolean isLessThan(TimeUnit granularity)
          Returns true if this instance is less than given granularity.
 TimeUnit nextGreater()
          Returns next greater constant than this.
 TimeUnit nextLesser()
          Returns next lesser constant than this.
static TimeUnit valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static TimeUnit[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

YEAR

public static final TimeUnit YEAR

QUARTER

public static final TimeUnit QUARTER

MONTH

public static final TimeUnit MONTH

WEEK

public static final TimeUnit WEEK

DAY

public static final TimeUnit DAY

HOUR

public static final TimeUnit HOUR

HALF_HOUR

public static final TimeUnit HALF_HOUR

QUARTER_HOUR

public static final TimeUnit QUARTER_HOUR

MINUTE

public static final TimeUnit MINUTE

SECOND

public static final TimeUnit SECOND
Method Detail

values

public static final TimeUnit[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(TimeUnit c : TimeUnit.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static TimeUnit valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name

getCalendarField

public int getCalendarField()
Returns field constant of Calendar that reflects this TimeUnit. For example, if you call this method on TimeUnit.YEAR constant, it returns Calendar.YEAR constant. If you call it on TimeUnit.HALF_HOUR, it returns Calendar.MINUTE constant.

Returns:
field constant from java.util.Calendar

getFieldAmount

public int getFieldAmount()
Returns amount of calendar units (returned by getCalendarField() method) in this constant. For example, if you call this method on TimeUnit.YEAR constant, it returns 1. If you call it on TimeUnit.HALF_HOUR, it returns 30.

Returns:
amount of calendar units in this TimeUnit

isLessThan

public boolean isLessThan(TimeUnit granularity)
Returns true if this instance is less than given granularity. For example, HOUR is less than YEAR.

Returns:
true if this instance is less than given

isGreaterThan

public boolean isGreaterThan(TimeUnit granularity)
Returns true if this instance is greater than given granularity. For example, YEAR is greater than HOUR.

Returns:
true if this instance is greater than given

nextGreater

public TimeUnit nextGreater()
Returns next greater constant than this. For example, next greater constant to the MINUTE is QUARTER_HOUR.

Returns:
next greater constant

nextLesser

public TimeUnit nextLesser()
Returns next lesser constant than this. For example, next lesser constant to the QUARTER_HOUR is MINUTE.

Returns:
next lesser constant

getCardinality

public int getCardinality(TimeUnit child,
                          java.util.Date date)
Returns amount of child TimeUnits in this constant. For example, when you call this on YEAR constant with argument child = MONTH, it returns 12. Argument date is important for some cases like DAY in MONTH etc.

Parameters:
child - - instance of TimeUnit which incidence is probed.
date - - date to which is cardinality probed
Returns:
if child is greater than this constant, returns 0
if child equals this constant, returns 1
otherwise returns number of child TimeUnits in this