JUtil

net.cscott.jutil
Class UnmodifiableMultiMap<K,V>

java.lang.Object
  extended by net.cscott.jutil.MapWrapper<K,V>
      extended by net.cscott.jutil.UnmodifiableMap<K,V>
          extended by net.cscott.jutil.UnmodifiableMultiMap<K,V>
All Implemented Interfaces:
Map<K,V>, MultiMap<K,V>

public abstract class UnmodifiableMultiMap<K,V>
extends UnmodifiableMap<K,V>
implements MultiMap<K,V>

UnmodifiableMultiMap is an abstract superclass to save developers the trouble of implementing the various mutator methds of the MultiMap interface.

Version:
$Id: UnmodifiableMultiMap.java,v 1.5 2006-10-30 19:58:07 cananian Exp $
Author:
Felix S. Klock II

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
protected UnmodifiableMultiMap()
           
 
Method Summary
 boolean add(K key, V value)
          Throws UnsupportedOperationException.
 boolean addAll(K key, Collection<? extends V> values)
          Throws UnsupportedOperationException.
 boolean addAll(MultiMap<? extends K,? extends V> mm)
          Throws UnsupportedOperationException.
 boolean contains(Object a, Object b)
          Returns true if a has a mapping to b in this.
abstract  UnmodifiableMultiMapSet<K,V> entrySet()
          Returns a Set view that allows you to recapture the MultiMap view.
 Collection<V> getValues(K key)
          Returns the collection of Values associated with key.
static
<K,V> MultiMap<K,V>
proxy(MultiMap<K,V> mmap)
          Constructs and returns an unmodifiable MultiMap backed by mmap.
 boolean remove(Object key, Object value)
          Throws UnsupportedOperationException.
 boolean removeAll(K key, Collection<?> values)
          Throws UnsupportedOperationException.
 boolean retainAll(K key, Collection<?> values)
          Throws UnsupportedOperationException.
protected abstract  MultiMap<K,V> wrapped()
           
 
Methods inherited from class net.cscott.jutil.UnmodifiableMap
clear, keySet, proxy, put, putAll, remove, values
 
Methods inherited from class net.cscott.jutil.MapWrapper
containsKey, containsValue, equals, get, hashCode, isEmpty, size, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.cscott.jutil.MultiMap
get, put, putAll, remove, size
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, equals, hashCode, isEmpty, keySet, values
 

Constructor Detail

UnmodifiableMultiMap

protected UnmodifiableMultiMap()
Method Detail

wrapped

protected abstract MultiMap<K,V> wrapped()
Specified by:
wrapped in class MapWrapper<K,V>

proxy

public static <K,V> MultiMap<K,V> proxy(MultiMap<K,V> mmap)
Constructs and returns an unmodifiable MultiMap backed by mmap.


entrySet

public abstract UnmodifiableMultiMapSet<K,V> entrySet()
Returns a Set view that allows you to recapture the MultiMap view.

Specified by:
entrySet in interface Map<K,V>
Specified by:
entrySet in interface MultiMap<K,V>
Specified by:
entrySet in class UnmodifiableMap<K,V>

getValues

public Collection<V> getValues(K key)
Description copied from interface: MultiMap
Returns the collection of Values associated with key. Modifications to the returned Collection affect this as well. If there are no Values currently associated with key, constructs a new, potentially mutable, empty Collection and returns it. (MultiMap specific operation).

Specified by:
getValues in interface MultiMap<K,V>

contains

public boolean contains(Object a,
                        Object b)
Description copied from interface: MultiMap
Returns true if a has a mapping to b in this. (MultiMap specific operation).

Specified by:
contains in interface MultiMap<K,V>

remove

public boolean remove(Object key,
                      Object value)
Throws UnsupportedOperationException.

Specified by:
remove in interface MultiMap<K,V>

add

public boolean add(K key,
                   V value)
Throws UnsupportedOperationException.

Specified by:
add in interface MultiMap<K,V>
Returns:
true if this mapping changed as a result of the call

addAll

public boolean addAll(K key,
                      Collection<? extends V> values)
Throws UnsupportedOperationException.

Specified by:
addAll in interface MultiMap<K,V>
Returns:
true if this mapping changed as a result of the call

addAll

public boolean addAll(MultiMap<? extends K,? extends V> mm)
Throws UnsupportedOperationException.

Specified by:
addAll in interface MultiMap<K,V>

retainAll

public boolean retainAll(K key,
                         Collection<?> values)
Throws UnsupportedOperationException.

Specified by:
retainAll in interface MultiMap<K,V>
Returns:
true if this mapping changed as a result of the call

removeAll

public boolean removeAll(K key,
                         Collection<?> values)
Throws UnsupportedOperationException.

Specified by:
removeAll in interface MultiMap<K,V>
Returns:
true if this mapping changed as a result of the call

JUtil

Copyright (c) 2006 C. Scott Ananian