|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--viceroy.misc.typeSafeCollections.TypeSafeMap
Implementation of the java.util.Map class which accepts only key and value objects of a given type for put operations. Is backed by another implementation of Map.
| Nested Class Summary |
| Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
| Field Summary | |
private java.lang.Class |
_keytype
|
private java.util.Map |
_map
|
private java.lang.Class |
_valuetype
|
| Constructor Summary | |
TypeSafeMap(java.util.Map map,
java.lang.Class keyType,
java.lang.Class valueType)
Constructs a new TypeSafeMap object. |
|
| Method Summary | |
protected void |
checkKeyType(java.lang.Object o)
Tests whether a key object is an instance of the allowed type. |
protected void |
checkType(java.lang.Object o,
java.lang.Class type)
Tests whether an object is an instance of the allowed type. |
protected void |
checkValueType(java.lang.Object o)
Tests whether a value object is an instance of the allowed type. |
void |
clear()
see java.util.Map |
boolean |
containsKey(java.lang.Object key)
see java.util.Map |
boolean |
containsValue(java.lang.Object value)
see java.util.Map |
java.util.Set |
entrySet()
see java.util.Map Returns a type safe java.util.Set which prevents values of the wrong type to be set via the stored java.util.Map.Entry object. |
boolean |
equals(java.lang.Object o)
see java.util.Map |
java.lang.Object |
get(java.lang.Object key)
see java.util.Map |
protected java.lang.Class |
getKeyType()
Returns the type of the keys. |
protected java.lang.Class |
getValueType()
Returns the type of the values. |
boolean |
isEmpty()
see java.util.Map |
java.util.Set |
keySet()
see java.util.Map |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
see java.util.Map Checks the types of the key and value objects |
void |
putAll(java.util.Map t)
see java.util.Map Checks the types of the key and value objects in the Map |
java.lang.Object |
remove(java.lang.Object key)
see java.util.Map |
int |
size()
see java.util.Map |
java.util.Collection |
values()
see java.util.Map |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Map |
hashCode |
| Field Detail |
private java.util.Map _map
private java.lang.Class _keytype
private java.lang.Class _valuetype
| Constructor Detail |
public TypeSafeMap(java.util.Map map,
java.lang.Class keyType,
java.lang.Class valueType)
map - the map to be wrappedkeyType - the type of the objects which can be used as keysvalueType - the type of the objects which can be added as values| Method Detail |
protected void checkType(java.lang.Object o,
java.lang.Class type)
o - The object to be checked
java.lang.ClassCastException - if the object is not of the right typeprotected void checkKeyType(java.lang.Object o)
o - The key object to be checked
java.lang.ClassCastException - if the object is not of the right typeprotected void checkValueType(java.lang.Object o)
o - The value object to be checked
java.lang.ClassCastException - if the object is not of the right typeprotected java.lang.Class getKeyType()
protected java.lang.Class getValueType()
public int size()
size in interface java.util.Mappublic boolean isEmpty()
isEmpty in interface java.util.Mappublic boolean containsKey(java.lang.Object key)
containsKey in interface java.util.Mappublic boolean containsValue(java.lang.Object value)
containsValue in interface java.util.Mappublic java.lang.Object get(java.lang.Object key)
get in interface java.util.Map
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
put in interface java.util.Mappublic java.lang.Object remove(java.lang.Object key)
remove in interface java.util.Mappublic void putAll(java.util.Map t)
putAll in interface java.util.Mappublic void clear()
clear in interface java.util.Mappublic java.util.Set keySet()
keySet in interface java.util.Mappublic java.util.Collection values()
values in interface java.util.Mappublic java.util.Set entrySet()
entrySet in interface java.util.Mappublic boolean equals(java.lang.Object o)
equals in interface java.util.Mapequals in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||