displayablecollections
Interface DisplayableSortedMap<K,V>
- All Superinterfaces:
- DisplayableMap<K,V>, java.util.Map<K,V>, java.util.SortedMap<K,V>
- All Known Implementing Classes:
- DisplayableTreeMap
public interface DisplayableSortedMap<K,V>
- extends DisplayableMap<K,V>, java.util.SortedMap<K,V>
A DisplayableSortedMap encapsulates a SortedMap and allows it to be
displayed by a JList
Nested classes/interfaces inherited from interface java.util.Map |
java.util.Map.Entry<K,V> |
Method Summary |
java.util.SortedMap<K,V> |
headMap(K toKey)
Returns a view of the portion of this sorted map whose keys are strictly
less than toKey. |
javax.swing.ListModel |
keyOrderedListModel()
Create a list model for displaying the values in this map in a JList. |
java.util.SortedMap<K,V> |
subMap(K fromKey,
K toKey)
Returns a view of the portion of this sorted map whose keys range from
fromKey, inclusive, to toKey, exclusive. |
java.util.SortedMap<K,V> |
tailMap(K fromKey)
Returns a view of the portion of this sorted map whose keys are greater
than or equal to fromKey. |
Methods inherited from interface java.util.SortedMap |
comparator, entrySet, firstKey, keySet, lastKey, values |
Methods inherited from interface java.util.Map |
clear, containsKey, containsValue, equals, get, hashCode, isEmpty, put, putAll, remove, size |
keyOrderedListModel
javax.swing.ListModel keyOrderedListModel()
- Create a list model for displaying the values in this map in a JList.
The result of calling
toString()
is what will actually be
displayed for each. The values will be displayed in the order of their
keys.
headMap
java.util.SortedMap<K,V> headMap(K toKey)
- Returns a view of the portion of this sorted map whose keys are strictly
less than toKey. The returned sorted map is backed by this sorted map,
so changes in the returned sorted map are reflected in this sorted map,
and vice-versa. The returned map supports all optional map operations
that this sorted map supports.
The sorted map returned by this method implements the DisplayableSortedMap
interface to support enabling this map to notify its observers of
changes made through the headMap; but the headMap itself cannot have
observers of its own. Attempting to add an observer to the headMap will
result in an UnsupportedOperation exception.
- Specified by:
headMap
in interface java.util.SortedMap<K,V>
- Parameters:
toKey
- - high endpoint (exclusive) of the headMap
- Returns:
- a view of the specified initial range of this sorted map.
- Throws:
java.lang.ClassCastException
- - if toKey is not compatible with this
map's comparator (or, if the map has no comparator, if toKey
does not implement Comparable). Implementations may, but are
not required to, throw this exception if toKey cannot be
compared to keys currently in the map.
java.lang.NullPointerException
- - if toKey is null and the encapsulated
sorted map does not tolerate null keys.
subMap
java.util.SortedMap<K,V> subMap(K fromKey,
K toKey)
- Returns a view of the portion of this sorted map whose keys range from
fromKey, inclusive, to toKey, exclusive. (If fromKey and toKey are equal,
the returned sorted map is empty.) The returned sorted map is backed by
this sorted map, so changes in the returned sorted map are reflected in
this sorted map, and vice-versa. The returned Map supports all optional
map operations that this sorted map supports.
The sorted map returned by this method implements the DisplayableSortedMap
interface to support enabling this map to notify its observers of
changes made through the subMap; but the subMap itself cannot have
observers of its own. Attempting to add an observer to the subMap will
result in an UnsupportedOperation exception.
- Specified by:
subMap
in interface java.util.SortedMap<K,V>
- Parameters:
fromKey
- - low endpoint (inclusive) of the subMap.toKey
- - high endpoint (exclusive) of the subMap.
- Returns:
- a view of the specified initial range of this sorted map.
- Throws:
java.lang.ClassCastException
- - if fromKey and toKey cannot be compared
to one another using this map's comparator (or, if the map
has no comparator, using natural ordering). Implementations
may, but are not required to, throw this exception if fromKey
or toKey cannot be compared to keys currently in the map.
java.lang.IllegalArgumentException
- if fromKey is greater than toKey
java.lang.NullPointerException
- - if fromKey or toKey is null and the
encapsulated sorted map does not tolerate null keys.
tailMap
java.util.SortedMap<K,V> tailMap(K fromKey)
- Returns a view of the portion of this sorted map whose keys are greater
than or equal to fromKey. The returned sorted map is backed by this
sorted map, so changes in the returned sorted map are reflected in this
sorted map, and vice-versa. The returned map supports all optional map
operations that this sorted map supports.
The sorted map returned by this method implements the DisplayableSortedMap
interface to support enabling this map to notify its observers of
changes made through the tailMap; but the tailMap itself cannot have
observers of its own. Attempting to add an observer to the tailMap will
result in an UnsupportedOperation exception.
- Specified by:
tailMap
in interface java.util.SortedMap<K,V>
- Parameters:
fromKey
- - low endpoint (inclusive) of the tailMap.
- Returns:
- a view of the specified initial range of this sorted map.
- Throws:
java.lang.ClassCastException
- - if fromKey is not compatible with this
map's comparator (or, if the map has no comparator, if fromKey
does not implement Comparable). Implementations may, but are
not required to, throw this exception if fromKey cannot be
compared to keys currently in the map.
java.lang.NullPointerException
- - if fromKey is null and the encapsulated
sorted map does not tolerate null keys.