org.favabeans.util
Interface InheritanceMap

All Superinterfaces:
Map
All Known Implementing Classes:
DagInheritanceMap

public interface InheritanceMap
extends Map

An InheritanceMap is a Map which imposes a partial ordering (see Poset) on its keys. When the Map.get(Object) method is invoked, if the supplied key is not found, the InheritanceMap searches in its set of keys for one that is greater than the supplied one and, if one is found, it returns the value mapped to that key. Thus, the supplied key can be said to "inherit" the value mapped to a key greater than itself.


Inner classes inherited from class java.util.Map
Map.Entry
 
Method Summary
 PoComparator comparator()
           
 boolean containsKey(Object key)
          Determine if this InheritanceMap maps a given key, or one of its super-keys, to a value.
 boolean containsKey(Object key, boolean inherit)
          Determine if this InheritanceMap maps a given key to a value.
 Object get(Object key)
          Return the associated value for the given key or a super-key of that key.
 Object get(Object key, boolean inherit)
          Return the associated value for the given key.
 Poset keyPoset()
          Return a Poset view of the keys of this InheritanceMap.
 Object put(Object key, Object value)
          Create a direct association from a key to a value.
 void putAll(Map map)
          Invoke put(Object, Object) for each (key, value) entry in a supplied Map.
 Object remove(Object key)
          Remove the direct association between a key and a value.
 
Methods inherited from interface java.util.Map
clear, containsValue, entrySet, equals, hashCode, isEmpty, keySet, size, values
 

Method Detail

containsKey

public boolean containsKey(Object key)
Determine if this InheritanceMap maps a given key, or one of its super-keys, to a value.
Specified by:
containsKey in interface Map
Parameters:
key - a key which may be in this InheritanceMap.
Returns:
true if the supplied key, or one of its super-keys, is mapped to a value.

containsKey

public boolean containsKey(Object key,
                           boolean inherit)
Determine if this InheritanceMap maps a given key to a value.
Parameters:
key - a key which may be in this InheritanceMap.
inherit - set to true if super-keys are to be included in the search; false if only directly mapped keys are to be searched.
Returns:
true if the supplied key or, if applicable, one of its super-keys, is mapped to a value.

get

public Object get(Object key)
Return the associated value for the given key or a super-key of that key.
Specified by:
get in interface Map
Parameters:
key - the key for which a value is required.
Returns:
the associated value, or null if none could be found.

get

public Object get(Object key,
                  boolean inherit)
Return the associated value for the given key.
Parameters:
key - the key for which a value is required.
inherit - set to true if super-keys are to be included in the search; false if only directly mapped keys are to be searched.
Returns:
the value associated with the supplied key or, if applicable, one of its super-keys, or null if none could be found.

put

public Object put(Object key,
                  Object value)
Create a direct association from a key to a value.
Specified by:
put in interface Map
Parameters:
key - the key with which to associate the value.
value - the value to associate with the supplied key.
Returns:
the value previously associated with the supplied key, or null if none existed.

remove

public Object remove(Object key)
Remove the direct association between a key and a value.
Specified by:
remove in interface Map
Parameters:
key - the key for which to remove the associated value.
Returns:
the previously associated value for key, or null if no value was previously associated.

putAll

public void putAll(Map map)
Invoke put(Object, Object) for each (key, value) entry in a supplied Map.
Specified by:
putAll in interface Map
Parameters:
map - the Map from which to obtain the (key, value) entries.

keyPoset

public Poset keyPoset()
Return a Poset view of the keys of this InheritanceMap.
Returns:
a Poset.

comparator

public PoComparator comparator()
Returns:
the PoComparator used to implement the partial ordering on the keys of this InheritanceMap, or null if this InheritanceMap expects its elements to be instances of PoComparable.


Copyright © 2000-2001, Regents of the University of Minnesota. All Rights Reserved.