sos.dated.util
Class AbstractDatedValue

java.lang.Object
  |
  +--sos.dated.util.AbstractDatedObject
        |
        +--sos.dated.util.AbstractDatedValue
All Implemented Interfaces:
DatedObject, DatedValue
Direct Known Subclasses:
ValueByDate

public abstract class AbstractDatedValue
extends AbstractDatedObject
implements DatedValue

A partial implementation of a dated value. This abstract class makes it easier to implement the DatedValue interface. To implement an unmodifiable dated value, programmers should subclass this class and define get and dateIterator(Date). To make it modifiable, programmers must also define set.

Since:
1.0
See Also:
ValueByDate, DatedValue

Field Summary
 
Fields inherited from interface sos.dated.util.DatedObject
MAX_DATE, MIN_DATE
 
Constructor Summary
protected AbstractDatedValue()
          No-argument constructor available only to subclasses.
 
Method Summary
 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.
 int hashCode(java.util.Date date)
          This implementation invokes get to retrieve the value at the specified date If the value is null, it returns 0; otherwise, it returns the value's hash code.
 boolean is(java.lang.Object value, java.util.Date date)
          This implementation invokes get to retrieve the value at the specified date and tests for equality to the parameter (using equals if non-null).
 boolean isNotThroughout(java.lang.Object value, java.util.Date from, java.util.Date to)
          Returns true if this dated value does not have the specified value at any date within the specified date range.
 boolean isThroughout(java.lang.Object value, java.util.Date from, java.util.Date to)
          Returns true if this dated value has a specified value throughout the specified date range.
 DatedValue set(java.lang.Object value, java.util.Date from, java.util.Date to)
          Sets the value for a specified date range (optional operation).
 java.lang.String toString(java.util.Date date)
          This implementation invokes get to retrieve the value at the specified date and then invokes String.valueOf to convert the value to a string.
 
Methods inherited from class sos.dated.util.AbstractDatedObject
dateIterator, dateIterator, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface sos.dated.util.DatedValue
get
 
Methods inherited from interface sos.dated.util.DatedObject
dateIterator, dateIterator, equals, hashCode
 

Constructor Detail

AbstractDatedValue

protected AbstractDatedValue()
No-argument constructor available only to subclasses.

Method Detail

equals

public 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.

Specified by:
equals in interface DatedValue
Overrides:
equals in class AbstractDatedObject
Parameters:
date - date at which this object should be tested
obj - the other dated object to be compared to
objDate - the date of the other dated object
Returns:
true if this dated object at date equals another dated object at objDate

hashCode

public int hashCode(java.util.Date date)
This implementation invokes get to retrieve the value at the specified date If the value is null, it returns 0; otherwise, it returns the value's hash code.

Specified by:
hashCode in interface DatedValue
Overrides:
hashCode in class AbstractDatedObject
Parameters:
date - date to which the value should correspond
Returns:
the hash code value of this dated object at the specified date

is

public boolean is(java.lang.Object value,
                  java.util.Date date)
This implementation invokes get to retrieve the value at the specified date and tests for equality to the parameter (using equals if non-null).

Specified by:
is in interface DatedValue
Parameters:
value - value whose presence is to be tested
date - date at which this dated value is to be queried
Returns:
true if this dated value has a specified value at a specified date

isNotThroughout

public boolean isNotThroughout(java.lang.Object value,
                               java.util.Date from,
                               java.util.Date to)
Returns true if this dated value does not have the specified value at any date within the specified date range.

This implementation iterates through the dates of this dated value, invoking is at the start of each range.

Specified by:
isNotThroughout in interface DatedValue
Parameters:
value - value whose presence is to be tested
from - starting date (inclusive) at which containment should be tested
to - ending date (exclusive) at which containment should be tested
Returns:
true if this dated value has a specified value throughout the specified date range
Throws:
java.lang.NullPointerException - if from or to is null
java.lang.IllegalArgumentException - if from does not precede to

isThroughout

public boolean isThroughout(java.lang.Object value,
                            java.util.Date from,
                            java.util.Date to)
Returns true if this dated value has a specified value throughout the specified date range.

This implementation iterates through the dates of this dated value, invoking is at the start of each range.

Specified by:
isThroughout in interface DatedValue
Parameters:
value - Value whose presence is to be tested
from - starting date at which containment should be tested
to - ending date at which containment should be tested
Returns:
true if this dated value has a specified value throughout the specified date range
Throws:
java.lang.NullPointerException - if from or to is null
java.lang.IllegalArgumentException - if from does not precede to

set

public DatedValue set(java.lang.Object value,
                      java.util.Date from,
                      java.util.Date to)
Sets the value for a specified date range (optional operation).

The returned value holds the old values before the call to set and is applicable only for the specified date range. It may be read-only, and it is not tied to this dated value.

This implementation throws an UnsupportedOperationException.

Specified by:
set in interface DatedValue
Parameters:
value - value to be set
from - starting date (inclusive) at which the value should hold
to - ending date (exclusive) at which the value should hold
Returns:
Returns a DatedValue indicating the values held in the date range of interest before the call to set.
Throws:
java.lang.UnsupportedOperationException - always

toString

public java.lang.String toString(java.util.Date date)
This implementation invokes get to retrieve the value at the specified date and then invokes String.valueOf to convert the value to a string.

Specified by:
toString in interface DatedObject
Specified by:
toString in class AbstractDatedObject
Parameters:
date - to which the string should correspond
Returns:
a string representation of this dated object


Copyright 2003 Side of Software (SOS). All rights reserved.