|
Side of Software Dated Collections Library 2.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sos.dated.util.AbstractDatedObject<D> sos.dated.util.AbstractDatedMap<K,V,D> sos.dated.util.AbstractMapByDate<K,V,D>
K
- the type of keys maintained by this dated mapV
- the type of values maintained by this dated mapD
- the type of dates used by this dated mappublic abstract class AbstractMapByDate<K,V,D>
A partial implementation of DatedMap
that maintains a complete, non-dated
map at each date where a change occurs. This class allows the client to use
a custom implementation of java.util.Map
inside a date-indexed map with
minimal effort. To do so, simply extend this class and implement the abstract
createMap
method.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface sos.dated.util.DatedMap |
---|
DatedMap.Entry<K,V,D> |
Constructor Summary | |
---|---|
protected |
AbstractMapByDate()
No-argument constructor available only to subclasses. |
Method Summary | |
---|---|
protected void |
checkForComodification(int expectedModCount,
D at)
Throws a ConcurrentModificationException if the expected modification count does not equal the actual modification count for the specified date. |
protected java.lang.Object |
clone()
Creates and returns a shallow copy of this object. |
boolean |
containsKey(java.lang.Object key,
D at)
Returns true if this dated map contains the specified key at the
specified date. |
boolean |
containsValue(java.lang.Object value,
D at)
Returns true if any key maps to the specified value at the
specified date. |
protected java.util.Map<K,V> |
copyMap(java.util.Map<K,V> map,
D from,
D to)
Returns a fresh map equivalent to the specified map. |
protected abstract java.util.Map<K,V> |
createMap(D from,
D to)
Creates and returns a new empty map given the specified date range. |
DateIterator<D> |
dateIterator(D at)
Returns an iterator of the dates of when this dated type has changed. |
DatedSet<DatedMap.Entry<K,V,D>,D> |
entrySet()
Returns a modifiable view of the mappings of this dated map. |
V |
get(java.lang.Object key,
D at)
Retrieves the value associated with the specified key on the specified date, or null if this dated map does not contain a mapping for the
key at that date. |
protected int |
modCount(D at)
Returns the modification count at the specified date, if assertions are enabled; otherwise, returns 0. |
DatedValue<V,D> |
put(K key,
V value,
D from,
D to)
Associates key with value in this dated map during
the specified date range (optional operation). |
void |
putAll(DatedMap<? extends K,? extends V,D> datedMap)
Places all mappings in datedMap into this dated map (optional operation). |
DatedValue<V,D> |
remove(java.lang.Object key,
D from,
D to)
Removes any values associated with the specified key in the specified date range (optional operation). |
protected void |
upModCount(D from,
D to)
Adds 1 to the modification counts throughout the specified date range, if assertions are enabled; otherwise, does nothing. |
Methods inherited from class sos.dated.util.AbstractDatedMap |
---|
clear, containsKeyThroughout, containsValueThroughout, equals, excludesKeyThroughout, excludesValueThroughout, get, hashCode, hasSizeThroughout, isEmpty, isEmptyThroughout, keySet, size, toString, values |
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.DatedMap |
---|
clear, containsKeyThroughout, containsValueThroughout, equals, excludesKeyThroughout, excludesValueThroughout, get, hashCode, hasSizeThroughout, isEmpty, isEmptyThroughout, keySet, size, values |
Methods inherited from interface sos.dated.util.DatedObject |
---|
dateIterator, equals, hashCode, toString |
Constructor Detail |
---|
protected AbstractMapByDate()
Method Detail |
---|
protected void checkForComodification(int expectedModCount, D at)
expectedModCount
- the caller's expected modification countat
- the date in question
java.util.ConcurrentModificationException
- if the expected modification
count does not equal the actual modification count for the specified dateprotected java.lang.Object clone() throws java.lang.CloneNotSupportedException
AbstractDatedMap
clone
method.
clone
in class AbstractDatedMap<K,V,D>
java.lang.CloneNotSupportedException
- if this object's class does not
support the Cloneable
interface.public boolean containsKey(java.lang.Object key, D at)
AbstractDatedMap
true
if this dated map contains the specified key at the
specified date.
This implementation iterates through the entries at the specified date,
returning true
if the specified key is found.
containsKey
in interface DatedMap<K,V,D>
containsKey
in class AbstractDatedMap<K,V,D>
key
- key whose presence is to be testedat
- date at which this map is to be queried
true
if this dated map contains the specified key at the
specified datepublic boolean containsValue(java.lang.Object value, D at)
AbstractDatedMap
true
if any key maps to the specified value at the
specified date.
This implementation iterates through the entries at the specified date
and returns true
if it encounters the specified value.
containsValue
in interface DatedMap<K,V,D>
containsValue
in class AbstractDatedMap<K,V,D>
value
- value whose presence is to be testedat
- date at which this map is to be queried
true
if any key maps to the specified value at the
specified dateprotected java.util.Map<K,V> copyMap(java.util.Map<K,V> map, D from, D to)
createMap
to get a new,
empty map and then putAll
to populate the map.
A subclass should override this method if it can copy the specified map
more efficiently (such as by invoking clone or using a copy constructor).
This AbstractMapByDate will not work properly if the returned map is not
independent of the parameter map.
map
- mappings to be included in the new map
protected abstract java.util.Map<K,V> createMap(D from, D to)
put
and putAll
operations.
from
- start date (inclusive) for which to create the mapto
- end date (exclusive) for which to create the map
public DateIterator<D> dateIterator(D at)
dateIterator
in interface DatedObject<D>
dateIterator
in class AbstractDatedObject<D>
at
- date to position the iteration
public DatedSet<DatedMap.Entry<K,V,D>,D> entrySet()
DatedMap
entrySet
in interface DatedMap<K,V,D>
entrySet
in class AbstractDatedMap<K,V,D>
public V get(java.lang.Object key, D at)
AbstractDatedMap
null
if this dated map does not contain a mapping for the
key at that date.This implementation iterates through the entry set at this date, returning the associated value if the key is found.
get
in interface DatedMap<K,V,D>
get
in class AbstractDatedMap<K,V,D>
key
- key whose mapping is to be retrievedat
- date at which this map is to be queried
protected int modCount(D at)
at
- date for which the modification count is requested
public DatedValue<V,D> put(K key, V value, D from, D to)
AbstractDatedMap
key
with value
in this dated map during
the specified date range (optional operation).
This implementation throws an UnsupportedOperationException.
put
in interface DatedMap<K,V,D>
put
in class AbstractDatedMap<K,V,D>
key
- key to put in this dated mapvalue
- value to map to the keyfrom
- starting date (inclusive) at which to put the mappingto
- ending date (exclusive) at which to put the mapping
public void putAll(DatedMap<? extends K,? extends V,D> datedMap)
AbstractDatedMap
datedMap
into this dated map (optional operation).
If this dated map and the map passed in are connected in a way that the map
changes during any additions, this method is undefined. This means that this
method cannot handle this
as the parameter.
This implementation iterates through the dates of datedMap
, invoking
put
for each mapping and date range defined in datedMap
.
putAll
in interface DatedMap<K,V,D>
putAll
in class AbstractDatedMap<K,V,D>
datedMap
- mappings to put in this dated mappublic DatedValue<V,D> remove(java.lang.Object key, D from, D to)
AbstractDatedMap
from
and to
and invokes remove
on the
iterator at the first occurrence of an entry with the key key
.
remove
in interface DatedMap<K,V,D>
remove
in class AbstractDatedMap<K,V,D>
key
- key indicating which mapping to removefrom
- starting date (inclusive) at which to remove the mappingto
- ending date (exclusive) at which to remove the mapping
protected void upModCount(D from, D to)
from
- start date (inclusive) for which to increase the modification countsto
- end date (inclusive) for which to increase the modification countsmodCount(D)
|
Side of Software Dated Collections Library 2.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |