|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
An object that maintains its state explicitly over time. This interface serves
as the root of all dated objects, just as java.lang.Object tops the hierarchy
of non-dated objects. Unlike java.lang.Object, however, this class provides
no implementation but an API that all dated objects should adhere to.
All dated objects use the standard java.util.Date to represent time.
The earliest time possible is given by MIN_DATE, and the latest time possible by
MAX_DATE. The state of the object is undefined at the instant of MAX_DATE.
All dated objects have "change dates" that specify when the object's state
has changed. The method dateIterator
allows the client to iterate through these dates. The state from one
date up to (but not including) the next date is guaranteed to be static.
Some implementations may
maintain these dates explicitly, while others may calculate them on-the-fly.
The following sample while-loop iterates through the dates of a dated object:
DatedObject obj = ...
DateIterator dateIter = obj.dateIterator();
while( dateIter.hasNext() ) {
Date from = dateIter.nextFrom();
Date to = dateIter.nextTo();
dateIter.next(); // don't forget to advance the iterator
...
}
Similarly, one can use a for-loop to iterate through the dates:
DatedObject obj = ...
for( DateIterator i = obj.dateIterator(); i.hasNext(); i.next() ) {
Date from = dateIter.nextFrom();
Date to = dateIter.nextTo();
...
}
Also, this interface defines equals, hashCode, and toString
at a specified date.
DatedCollection,
AbstractDatedObject| Field Summary | |
static java.util.Date |
MAX_DATE
A date representing the latest possible date. |
static java.util.Date |
MIN_DATE
A date representing the earliest possible date. |
| Method Summary | |
DateIterator |
dateIterator()
Returns an iterator of the date ranges of when this dated object has changed. |
DateIterator |
dateIterator(java.util.Date date)
Returns an iterator of the date ranges of when this dated object has changed, starting at the range that contains the specified date. |
boolean |
equals(java.util.Date date,
DatedObject obj,
java.util.Date objDate)
Indicates if this dated object at date is equal to
obj at objDate. |
boolean |
equals(java.lang.Object obj)
Indicates if this dated object equals the specified object. |
int |
hashCode()
Returns the hash code value of this dated object. |
int |
hashCode(java.util.Date date)
Returns a hash code value of this dated object at the specified date. |
java.lang.String |
toString(java.util.Date date)
Returns a string representation of this dated object at the specified date. |
| Field Detail |
public static final java.util.Date MIN_DATE
Date object
that is passed Long.MIN_VALUE to its constructor.
public static final java.util.Date MAX_DATE
Date object
that is passed Long.MAX_VALUE to its constructor.
| Method Detail |
public DateIterator dateIterator()
dateIterator( MIN_DATE ).
dateIterator(Date)public DateIterator dateIterator(java.util.Date date)
nextFrom returns the
same date as previousTo.
Passing MAX_DATE as the argument will return an iterator positioned
at the end of the sequence.
date - date to position the iteration
java.lang.NullPointerException - if date is nullpublic boolean equals(java.lang.Object obj)
DatedObjects are equal if they have the same dates and if they are equal
at each of these dates, as seen by equals(Date,DatedObject,Date).
equals in class java.lang.Objectobj - object to compare this dated object to
true if this dated object equals the specified objectequals(Date,DatedObject,Date)
public boolean equals(java.util.Date date,
DatedObject obj,
java.util.Date objDate)
date is equal to
obj at objDate.
date - date at which this object should be testedobj - the other dated object to be compared toobjDate - the date of the other dated object
true if this dated object at date equals
another dated object at objDate
java.lang.NullPointerException - if any argument is nullpublic int hashCode()
hashCode in class java.lang.Objectpublic int hashCode(java.util.Date date)
o1 and o2 and two dates
d1 and d2, if
o1.equals( d1, o2, d2 ) returns true,
then o1.hashCode( d1 )
must equal o2.hashCode( d2 ).
date - date to which the value should correspond
java.lang.NullPointerException - if date is nullpublic java.lang.String toString(java.util.Date date)
date - to which the string should correspond
java.lang.NullPointerException - if date is null
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||