displayablecollections
Interface DisplayableMap<K,V>

All Superinterfaces:
java.util.Map<K,V>
All Known Subinterfaces:
DisplayableSortedMap<K,V>
All Known Implementing Classes:
DisplayableHashMap, DisplayableLinkedHashMap, DisplayableTreeMap

public interface DisplayableMap<K,V>
extends java.util.Map<K,V>

A DisplayableMap encapsulates a Map and allows it to be displayed by a JList


Nested Class Summary
static interface DisplayableMap.MapChangedNotification<K,V>
          An object that implements this interface encapsulates information about changes to an DisplayableMap Such an object will be the second parameter when the update() method of an Observer is called following a change to this DisplayableList.
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Method Summary
 void addObserver(java.util.Observer observer)
          Add an observer to the set of observers of this map
 void deleteObservers()
          Clear the observers list so this map no longer has any observers
 java.util.Set<java.util.Map.Entry<K,V>> entrySet()
          Returns a set view of the mappings contained in this map.
 java.util.Set<K> keySet()
          Returns a set view of the keys contained in this map.
 javax.swing.ListModel listModel()
          Create a list model for displaying this map's values in a JList.
 javax.swing.ListModel valueOrderedListModel()
          Create a list model for displaying the values in this map in a JList.
 javax.swing.ListModel valueOrderedListModel(java.util.Comparator<V> comparator)
          Create a list model for displaying the values in this map in a JList.
 java.util.Collection<V> values()
          Returns a collection view of the values contained in this map.
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, equals, get, hashCode, isEmpty, put, putAll, remove, size
 

Method Detail

listModel

javax.swing.ListModel listModel()
Create a list model for displaying this map's values in a JList. The result of calling toString() is what will actually be displayed for each. There will be no necessary connection between the order of display and any order in the map, since this method can be invoked on any map implementing this interface. (The method valueOrderedListModel specified below can be used with any map if it is desired to display the values in some order based on their natural order or that induced by a specified comparator. For maps having an inherent order of keys, keyOrderedListModel can also be used to display the values in an order corresponding to the order of the keys.)

See Also:
valueOrderedListModel() in this interface and keyOrderedListModel in DisplayableSortedMap

valueOrderedListModel

javax.swing.ListModel valueOrderedListModel()
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 an order determined by the natural order of the values


valueOrderedListModel

javax.swing.ListModel valueOrderedListModel(java.util.Comparator<V> comparator)
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 an order determined by the specified comparator

Parameters:
comparator - the comparator to use

addObserver

void addObserver(java.util.Observer observer)
Add an observer to the set of observers of this map

Parameters:
observer - the observer to add

deleteObservers

void deleteObservers()
Clear the observers list so this map no longer has any observers


entrySet

java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Returns a set view of the mappings contained in this map. Each element in the returned set is a Map.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

The set returned by this method will actually be of a class that implements DisplayableSet, and can be safely cast to this type. Any observers added to the set will be notified of changes in the map through any of the map's methods and vice versa.

Specified by:
entrySet in interface java.util.Map<K,V>
Returns:
a set view of the mappings contained in this map.

keySet

java.util.Set<K> keySet()
Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, `which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll retainAll, and clear operations. It does not support the add or addAll operations.

The set returned by this method will actually be of a class that implements DisplayableSet, and can be safely cast to this type. Any observers added to the set will be notified of changes in the map through any of the map's methods and vice versa.

Specified by:
keySet in interface java.util.Map<K,V>
Returns:
a set view of the keys contained in this map.

values

java.util.Collection<V> values()
Returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

The collection returned by this method will actually be of a class that implements DisplayableCollection, and can be safely cast to this type. Any observers added to the collection will be notified of changes in the map through any of the map's methods and vice versa.

Specified by:
values in interface java.util.Map<K,V>
Returns:
a collection view of the values contained in this map.