JTP API Documentation

jtp.time.tp
Class CalendarTimePoint

java.lang.Object
  |
  +--jtp.time.tp.TimePoint
        |
        +--jtp.time.tp.CalendarTimePoint
All Implemented Interfaces:
Comparable

public class CalendarTimePoint
extends TimePoint
implements Comparable

A representation for time points that is grounded in an instance of GregorianCalendar.

This class also manages a sorted tree of all of the CalendarTimePoints which have been returned via getInstance(java.util.Calendar, jtp.time.tp.CalendarTimePoint[]).


Field Summary
static int[] calendarFields
           
protected  DateFormat format
           
protected static TreeMap points
           
 
Method Summary
 int compareTo(Object obj)
           
protected  boolean equalGranularity(CalendarTimePoint tp)
          Returns true if tp is specified at the same level of granularity as this.
 Calendar getCalendar()
           
protected  CalendarTimePoint getCalendarTimePointAfter()
          Returns the CalendarTimePoint in the point tree which is immediately after this one.
protected  CalendarTimePoint getCalendarTimePointBefore()
          Returns the CalendarTimePoint in the point tree which is immediately before this one.
static CalendarTimePoint getInstance(Calendar c, CalendarTimePoint[] beforeAndAfter)
          Returns an instance of CalendarTimePoint which has been properly situated in the point tree.
static CalendarTimePoint getInstance(int year, int month, int date, int hour, int minute, int second, CalendarTimePoint[] beforeAndAfter)
          Returns an instance of CalendarTimePoint which has been properly situated in the point tree.
static CalendarTimePoint getInstance(int year, int month, int date, int hour, int minute, int second, int ms, CalendarTimePoint[] beforeAndAfter)
          Returns an instance of CalendarTimePoint which has been properly situated in the point tree.
static CalendarTimePoint getInstance(int year, int month, int date, int hour, int minute, int second, int ms, TimeZone timezone, CalendarTimePoint[] beforeAndAfter)
          Returns an instance of CalendarTimePoint which has been properly situated in the point tree.
static CalendarTimePoint getInstance(long millis, CalendarTimePoint[] beforeAndAfter)
          Returns an instance of CalendarTimePoint which has been properly situated in the point tree.
protected  int getLargestUnsetField()
          Returns the CalendarTimePoint's largest unset field.
protected  int getSmallestSetField()
          Returns the CalendarTimePoint's smallest field which is set, and which the next smallest field is unset.
static void reset()
           
 String toString()
           
 
Methods inherited from class jtp.time.tp.TimePoint
getID, getNode, setNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

points

protected static TreeMap points

format

protected DateFormat format

calendarFields

public static final int[] calendarFields
Method Detail

getCalendar

public Calendar getCalendar()

reset

public static void reset()

getInstance

public static CalendarTimePoint getInstance(Calendar c,
                                            CalendarTimePoint[] beforeAndAfter)
Returns an instance of CalendarTimePoint which has been properly situated in the point tree.

Parameters:
c - a Calendar which the returned time point should be grounded in
beforeAndAfter - a two-element array which will be filled in with the CalendarTimePoints in the point tree immediately before and after the returned CalendarTimePoint if the CalendarTimePoint returned is newly created

getInstance

public static CalendarTimePoint getInstance(int year,
                                            int month,
                                            int date,
                                            int hour,
                                            int minute,
                                            int second,
                                            CalendarTimePoint[] beforeAndAfter)
Returns an instance of CalendarTimePoint which has been properly situated in the point tree. The Calendar on which the point is based has second granularity.

See getInstance(int, int, int, int, int, int, int, CalendarTimePoint[]) for a description of parameters.


getInstance

public static CalendarTimePoint getInstance(int year,
                                            int month,
                                            int date,
                                            int hour,
                                            int minute,
                                            int second,
                                            int ms,
                                            CalendarTimePoint[] beforeAndAfter)
Returns an instance of CalendarTimePoint which has been properly situated in the point tree. The Calendar on which the point is based has millisecond granularity.

int fields are used to initialize a Calendar object

Parameters:
year - the year represented by this point
month - the month represented by this point. First month of the year (January) is 0
date - the day of the month represented by this point. First day of the month is 1
hour - the hour of the day represented by this point. First hour of the day is 0 and last hour is 23
minute - the minute of the hour represented by this point. First minute is 0 and last minute is 59
second - the second of the minute represented by this point. First second is 0 and last second is 59
ms - the millisecond of the second represented by this point. First millisecond is 0 and last millisecond is 999
beforeAndAfter - a two-element array which will be filled in with the CalendarTimePoints in the point tree immediately before and after the returned CalendarTimePoint if the CalendarTimePoint returned is newly created

getInstance

public static CalendarTimePoint getInstance(int year,
                                            int month,
                                            int date,
                                            int hour,
                                            int minute,
                                            int second,
                                            int ms,
                                            TimeZone timezone,
                                            CalendarTimePoint[] beforeAndAfter)
Returns an instance of CalendarTimePoint which has been properly situated in the point tree. The Calendar on which the point is based has millisecond granularity.

int fields are used to initialize a Calendar object

Parameters:
year - the year represented by this point
month - the month represented by this point. First month of the year (January) is 0
date - the day of the month represented by this point. First day of the month is 1
hour - the hour of the day represented by this point. First hour of the day is 0 and last hour is 23
minute - the minute of the hour represented by this point. First minute is 0 and last minute is 59
second - the second of the minute represented by this point. First second is 0 and last second is 59
ms - the millisecond of the second represented by this point. First millisecond is 0 and last millisecond is 999
timezone - the TimeZone of the date represented by this point.
beforeAndAfter - a two-element array which will be filled in with the CalendarTimePoints in the point tree immediately before and after the returned CalendarTimePoint if the CalendarTimePoint returned is newly created

getInstance

public static CalendarTimePoint getInstance(long millis,
                                            CalendarTimePoint[] beforeAndAfter)
Returns an instance of CalendarTimePoint which has been properly situated in the point tree. The Calendar on which the point is based has millisecond granularity.

Parameters:
millis - with Calendar.setTime(java.util.Date), used to set time of Calendar object
beforeAndAfter - a two-element array which will be filled in with the CalendarTimePoints in the point tree immediately before and after the returned CalendarTimePoint if the CalendarTimePoint returned is newly created

equalGranularity

protected boolean equalGranularity(CalendarTimePoint tp)
Returns true if tp is specified at the same level of granularity as this. Returns false otherwise. Does not check to see if the specified fields are equal.

Only checks the Calendar fields Calendar.ERA, Calendar.YEAR, Calendar.MONTH, Calendar.DATE, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, and Calendar.MILLISECOND.


getCalendarTimePointBefore

protected CalendarTimePoint getCalendarTimePointBefore()
Returns the CalendarTimePoint in the point tree which is immediately before this one. This time point doesn't actually have to be in the tree for the return value to be correctly calculated.


getCalendarTimePointAfter

protected CalendarTimePoint getCalendarTimePointAfter()
Returns the CalendarTimePoint in the point tree which is immediately after this one. This time point doesn't actually have to be in the tree for the return value to be correctly calculated.


getLargestUnsetField

protected int getLargestUnsetField()
Returns the CalendarTimePoint's largest unset field. If the milliseconds are specified, milliseconds will still get returned.


getSmallestSetField

protected int getSmallestSetField()
Returns the CalendarTimePoint's smallest field which is set, and which the next smallest field is unset. Returns Calendar.MILLISECOND if all fields are specified.


compareTo

public int compareTo(Object obj)
Specified by:
compareTo in interface Comparable

toString

public String toString()
Overrides:
toString in class TimePoint

JTP API Documentation