|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--sos.dated.util.AbstractDatedObject
A partial implementation of a dated object. This class
makes it easier to define a class that implements the DatedObject interface.
This abstract class provides generic implementations of
equals, hashCode,
toString, and dateIterator().
Subclasses must define dateIterator(Date) and
toString(Date).
DatedObject| Field Summary |
| Fields inherited from interface sos.dated.util.DatedObject |
MAX_DATE, MIN_DATE |
| Constructor Summary | |
protected |
AbstractDatedObject()
No-argument constructor available only to subclasses. |
| Method Summary | |
DateIterator |
dateIterator()
Returns an iterator of the date ranges of when this dated object has changed. |
abstract 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 another dated object is equal to this dated object at specified dates. |
boolean |
equals(java.lang.Object obj)
Indicates if this dated object is equivalent to 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()
Returns a string representation of this dated object. |
abstract java.lang.String |
toString(java.util.Date date)
Returns a string representation of this dated object at the specified date. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
protected AbstractDatedObject()
| Method Detail |
public DateIterator dateIterator()
dateIterator( MIN_DATE ).
This implementation simply invokes dateIterator(Date),
passing MIN_DATE.
dateIterator in interface DatedObjectdateIterator(Date)public abstract DateIterator dateIterator(java.util.Date date)
DatedObjectnextFrom returns the
same date as previousTo.
Passing MAX_DATE as the argument will return an iterator positioned
at the end of the sequence.
dateIterator in interface DatedObjectdate - date to position the iteration
public boolean equals(java.lang.Object obj)
If the parameter is not a DatedObject, this implementation
returns false.
Otherwise, it returns true if the dates of these objects
are equivalent and if these objects are equivalent at the dates.
equals in interface DatedObjectequals in class java.lang.Objectobj - object to check for equality to this dated object
equals(Date,DatedObject,Date)
public boolean equals(java.util.Date date,
DatedObject obj,
java.util.Date objDate)
This implementation uses object identity to determine equality. In other
words, it returns true if
this == obj && date.equals( objDate )Subclasses should override this method to impose a weaker equality condition.
equals in interface DatedObjectdate - 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 thid dated object at date date equals
another dated object at date objDate
java.lang.NullPointerException - if any of the parameters equal nullpublic int hashCode()
This implementation sums the bitwise exclusive or of the date and the object's hash code value at the date, for each date the object changes. Specifically (in pseudocode):
hashCode = 0;
for each date d that a change in the object occurs
hashCode += d.hashCode() ^ hashCode( d )
hashCode in interface DatedObjecthashCode in class java.lang.ObjecthashCode(Date)public int hashCode(java.util.Date date)
This implementation returns the identity hash code value of this dated object.
hashCode in interface DatedObjectdate - date to which the value should correspond
java.lang.NullPointerException - if date is nullpublic java.lang.String toString()
This implemention forms a string as follows. Start with an open angled bracket
"<". For each date of this dated object, append "d:x, " where d is a change date
and x is the result of calling toString( d ). After the last date change, do
not append the comma, but add a closing angle bracket ">".
toString in class java.lang.Objectpublic abstract java.lang.String toString(java.util.Date date)
DatedObject
toString in interface DatedObjectdate - to which the string should correspond
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||