Methods Summary |
---|
private java.util.Map | addNewKey(java.lang.Object key)
final Map v = new HashMap();
map.put(key, v);
return ( v );
|
public void | clear()
map.clear();
|
public boolean | containsKey(java.lang.Object key)
return ( map.containsKey(key) );
|
public boolean | containsValue(java.lang.Object value)Throws {@link UnsupportedOperationException}, as there is no real application.
throw new UnsupportedOperationException("ValueListMap:containsValue() - Not supported");
|
public java.util.Set | entrySet()
return ( map.entrySet() );
|
public java.lang.Object | get(java.lang.Object key)Always returns a map or null if there is no mapping that exists for this key. Thus
for unmapped keys, the behavior resembles the {@link HashMap}. In case there is a
mapping, it returns a map such that the keys in returned map are the values
that were put using the put call.
return ( map.get(key) );
|
private boolean | implementsValueClass(java.lang.Object value)
boolean ivc = false;
final Class[] ics = value.getClass().getInterfaces();
for (int i = 0 ; i < ics.length ; i++) {
if (valueClass.equals(ics[i])) {
ivc = true;
break;
}
}
return ( ivc );
|
public boolean | isEmpty()
return ( map.isEmpty() );
|
public java.util.Set | keySet()
return ( map.keySet() );
|
public java.lang.Object | put(java.lang.Object key, java.lang.Object value)If the key already exists, a new mapping is created which will be put in an
inner map for that key. If the key does not exist, a new key is created and
then an inner map is created. The inner map is actually for the faster lookup.
Thus the method renders the map like:
key1 -> Map1
key2 -> Map2
Map1 -> value1, value2, value3 ... -> 1 . This 1 is an arbitrary mapping.
String msg = null;
if (key == null || value == null) {
msg = sm.getString("sm.illegal_arg");
throw new IllegalArgumentException ("Null Argument");
}
if (! implementsValueClass(value)) {
msg = sm.getString("sm.illegal_arg_class", valueClass.getName());
throw new IllegalArgumentException(msg);
}
Map mm = (Map) map.get(key); // the mapped map
if (mm == null) {
mm = addNewKey(key);
}
return mm.put(value, Integer.valueOf(1)); // the value can be mapped arbitrarily to anything!
|
public void | putAll(java.util.Map t)Throws {@link UnsupportedOperationException}
throw new UnsupportedOperationException("ValueListMap:putAll() - Not supported");
|
public java.lang.Object | remove(java.lang.Object keyOrValue)Either removes the key (mapping) from the outer map or removes a key
from inner mapping. Please see #put.
Collection removed = null;
if (valueClass.isAssignableFrom(keyOrValue.getClass())) {
final Object value = keyOrValue; //indicating that we should try to remove this value
removed = removeValues(value);
}
else {
final Object key = keyOrValue; //indicating that we should try to remove this key
removed = removeKeyedValues(key);
map.remove(key);
}
return ( removed );
|
private java.util.Collection | removeKeyedValues(java.lang.Object key)
Collection list = new ArrayList();
final Object value = this.get(key);
if (value != null && value instanceof Map) {
list = ((Map)value).keySet();
}
return ( list );
|
private java.util.Collection | removeValues(java.lang.Object value)
final Collection list = new ArrayList();
final Iterator iter = map.keySet().iterator();
while (iter.hasNext()) {
final Map mm = (Map) map.get(iter.next()); //has to be map
mm.remove(value); // this will return the value Integer(1), which is ignored
list.add(value);
}
return ( list );
|
public int | size()
return ( map.size() );
|
public java.util.Collection | values()Returns a Collection of ALL the values that were put by put calls till
this point in time.
//return all the mapped map's keys
final Collection values = new ArrayList();
final Iterator iter = this.keySet().iterator();
while (iter.hasNext()) {
final Map mm = (Map) map.get(iter.next());
values.addAll(mm.keySet());
}
return ( values );
|