sos.dated.util
Class ValueByDate

java.lang.Object
  |
  +--sos.dated.util.AbstractDatedObject
        |
        +--sos.dated.util.AbstractDatedValue
              |
              +--sos.dated.util.ValueByDate
All Implemented Interfaces:
java.lang.Cloneable, DatedObject, DatedValue, java.io.Serializable

public class ValueByDate
extends AbstractDatedValue
implements DatedValue, java.io.Serializable, java.lang.Cloneable

An implementation of DatedValue that can efficiently produce the value at a given date.

This implementation is serializable and cloneable; however, it is not synchronized. To use it safely in a multi-threaded situation, wrap an instance of the dated object with a call to DatedCollections.synchronizedDatedValue.

Since:
1.0
See Also:
DatedValue, DatedCollections.synchronizedDatedValue(sos.dated.util.DatedValue)

Field Summary
 
Fields inherited from interface sos.dated.util.DatedObject
MAX_DATE, MIN_DATE
 
Constructor Summary
ValueByDate()
          Creates a ValueByDate with a null value over all dates.
ValueByDate(DatedValue datedValue)
          Creates a ValueByDate with the same values as the specified dated value.
 
Method Summary
 java.lang.Object clone()
          Creates and returns a copy of this object.
 DateIterator dateIterator(java.util.Date date)
          Returns an iterator of the dates of when this dated type has changed.
 java.lang.Object get(java.util.Date date)
          Returns the value at a specified date.
 DatedValue set(java.lang.Object value, java.util.Date from, java.util.Date to)
          Sets the value for a specified date range (optional operation).
 
Methods inherited from class sos.dated.util.AbstractDatedValue
equals, hashCode, is, isNotThroughout, isThroughout, toString
 
Methods inherited from class sos.dated.util.AbstractDatedObject
dateIterator, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface sos.dated.util.DatedValue
equals, hashCode, is, isNotThroughout, isThroughout
 
Methods inherited from interface sos.dated.util.DatedObject
dateIterator, equals, hashCode, toString
 

Constructor Detail

ValueByDate

public ValueByDate()
Creates a ValueByDate with a null value over all dates.


ValueByDate

public ValueByDate(DatedValue datedValue)
Creates a ValueByDate with the same values as the specified dated value.

Parameters:
datedValue - values used to initialized this object
Throws:
java.lang.NullPointerException - if datedValue is null
Method Detail

clone

public java.lang.Object clone()
Creates and returns a copy of this object.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this instance

dateIterator

public DateIterator dateIterator(java.util.Date date)
Returns an iterator of the dates of when this dated type has changed.

Specified by:
dateIterator in interface DatedObject
Specified by:
dateIterator in class AbstractDatedObject
Parameters:
date - date to position the iteration
Returns:
an iterator of the dates of when this dated type has changed.

get

public java.lang.Object get(java.util.Date date)
Returns the value at a specified date.

Specified by:
get in interface DatedValue
Parameters:
date - date at which this dated value is to be queried
Returns:
the value at a specified date
Throws:
java.lang.NullPointerException - if date is null

set

public DatedValue set(java.lang.Object value,
                      java.util.Date from,
                      java.util.Date to)
Description copied from interface: DatedValue
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.

Specified by:
set in interface DatedValue
Overrides:
set in class AbstractDatedValue
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.


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