wt.eff
Class EffHistoryMap

java.lang.Object
  extended byjava.util.AbstractMap
      extended bywt.eff.EffHistoryMap
All Implemented Interfaces:
Map, Serializable, SortedMap

class EffHistoryMap
extends AbstractMap
implements SortedMap, Serializable

This class is an unmodifiable implementation of the java.util.SortedMap interface for representing a historical sequence of mutually compatible (see EffSet) sets of Eff objects. Each key of this map is a wt.fc.ObjectReference object identifying an EffChangeAudit object, to which is mapped a set of mutually compatible Eff objects resulting from the effectivity change represented by the EffChangeAudit object.

Note: this map does not assert the mutual compatibility of the members of its value sets; this is the responsibility of the application.

This map supports null keys, but not null values.


Nested Class Summary
 
Nested classes inherited from class java.util.AbstractMap
 
Nested classes inherited from class java.util.Map
Map.Entry
 
Field Summary
private  SortedMap map
           
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
  EffHistoryMap(Eff[] effs, boolean chronological)
          Creates a new EffHistoryMap object based on the argument array of Eff objects, in chronological or anti-chronological order, as specified.
private EffHistoryMap(SortedMap map)
          Creates a new EffHistoryMap object based on the argument java.util.SortedMap.
 
Method Summary
 Comparator comparator()
          Returns the comparator used to order this sorted map.
 boolean containsKey(Object key)
          Returns true if this map contains a mapping for the specified key.
 Set entrySet()
          Returns a set view of the mappings contained in this map.
 Object firstKey()
          Returns the first (lowest) key currently in this sorted map.
 Object get(Object key)
          Returns the value to which this map maps the specified key.
 SortedMap headMap(Object toKey)
          Returns a view of the portion of this sorted map whose keys are strictly less than toKey.
 Object lastKey()
          Returns the last (highest) key currently in this sorted map.
private  void put(ObjectReference key, Eff value, int index)
          Put the specified Eff object in this map, using the specified key and index.
 Object remove(Object key)
          This implementation always throws an UnsupportedOperationException, efficiently in O(1) time.
 SortedMap subMap(Object fromKey, Object toKey)
          Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.
 SortedMap tailMap(Object fromKey)
          Returns a view of the portion of this sorted map whose keys are greater than or equal to fromKey.
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsValue, equals, hashCode, isEmpty, keySet, put, putAll, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
clear, containsValue, equals, hashCode, isEmpty, keySet, put, putAll, size, values
 

Field Detail

map

private SortedMap map
Constructor Detail

EffHistoryMap

public EffHistoryMap(Eff[] effs,
                     boolean chronological)
Creates a new EffHistoryMap object based on the argument array of Eff objects, in chronological or anti-chronological order, as specified. These Eff objects are assumed to be mutually compatible.

Parameters:
effs - array of mutually compatible Eff objects constituting a valid historical sequence chronological boolean flag specifying whether this sorted map is sorted in chronological or anti-chronological order
Throws:
NullPointerException - if the argument array or any of its elements are null. wt.util.WTRuntimeException if the argument Eff objects are not all mutually compatible; note:/b> a failure to throw a wt.util.WTRuntimeException does not imply that all elements are mutually compatible

EffHistoryMap

private EffHistoryMap(SortedMap map)
Creates a new EffHistoryMap object based on the argument java.util.SortedMap. This constructor is used internally to support the implementation of the java.util.SortedMap interface.

Method Detail

put

private void put(ObjectReference key,
                 Eff value,
                 int index)
Put the specified Eff object in this map, using the specified key and index.


containsKey

public boolean containsKey(Object key)
Returns true if this map contains a mapping for the specified key. This is an efficient O(log n) implementation of key lookup.

Specified by:
containsKey in interface Map
Parameters:
key - key whose presence in this map is to be tested.
Throws:
ClassCastException - if !(key instanceof wt.fc.ObjectReference)

get

public Object get(Object key)
Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key. This is an efficient O(log n) implementation of value lookup.

Specified by:
get in interface Map
Parameters:
key - key whose associated value is to be returned.
Throws:
ClassCastException - if !(key instanceof wt.fc.ObjectReference)

remove

public Object remove(Object key)
This implementation always throws an UnsupportedOperationException, efficiently in O(1) time.

Specified by:
remove in interface Map
Parameters:
key - key whose mapping is to be removed from the map.
Throws:
UnsupportedOperationException - on all invocations.

entrySet

public Set entrySet()
Returns a set view of the mappings contained in this map. Obeys the general contract of java.util.Map.entrySet. The returned set's iterator does not support the remove operation. Also, the java.util.Map.EntrySet objects contained in the set do not support the setValue operation.

Specified by:
entrySet in interface Map

comparator

public Comparator comparator()
Returns the comparator used to order this sorted map.

Specified by:
comparator in interface SortedMap

subMap

public SortedMap subMap(Object fromKey,
                        Object toKey)
Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive. Obeys the general contract of java.util.SortedMap.subMap.

Specified by:
subMap in interface SortedMap
Parameters:
fromKey - low endpoint (inclusive) of the sub map, toKey high endpoint (exclusive) of the sub map.
Throws:
ClassCastException - if !(fromKey instanceof wt.fc.ObjectReference && toKey instanceof wt.fc.ObjectReference), IllegalArgumentException if fromKey is greater than toKey, or if fromKey or toKey is not within the range of this sorted map.

headMap

public SortedMap headMap(Object toKey)
Returns a view of the portion of this sorted map whose keys are strictly less than toKey. Obeys the general contract of java.util.SortedMap.headMap.

Specified by:
headMap in interface SortedMap
Parameters:
toKey - high endpoint (exclusive) of the head map.
Throws:
ClassCastException - if !(toKey instanceof wt.fc.ObjectReference), IllegalArgumentException if toKey is not within the range of this sorted map.

tailMap

public SortedMap tailMap(Object fromKey)
Returns a view of the portion of this sorted map whose keys are greater than or equal to fromKey. Obeys the general contract of java.util.SortedMap.tailMap.

Specified by:
tailMap in interface SortedMap
Parameters:
fromKey - low endpoint (inclusive) of the tail map.
Throws:
ClassCastException - if !(fromKey instanceof wt.fc.ObjectReference), IllegalArgumentException if fromKey is not within the range of this sorted map.

firstKey

public Object firstKey()
Returns the first (lowest) key currently in this sorted map.

Specified by:
firstKey in interface SortedMap
Throws:
java.util.NoSuchElementException - if this sorted map is empty

lastKey

public Object lastKey()
Returns the last (highest) key currently in this sorted map.

Specified by:
lastKey in interface SortedMap
Throws:
java.util.NoSuchElementException - if this sorted map is empty