|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--swpchat.server.SpecializedCollection
This class is a collection specialized in ClientConnection objects. The class is abstract, because you could not use the collection to receive objects of a special class, when you do not now the class at compile time. It means in detail, that to my oppinion it is not possible to do something as follows:
Class objectClass = Class.forName("someClassName"); public objectClass getClass() { return objectClass; }This would fail to compile, because the Class
objectClass
is no valid Class.
Therefore we need to use a subclass of this class, which
encapsulates for each special object to store, the correct method
to receive the correct instances of the stored values of the map.
Field Summary | |
private java.util.HashMap |
map
Map for the collection elements. |
private java.lang.Class |
objectClass
The class which represents the special objects that could be stored in the map. |
Constructor Summary | |
protected |
SpecializedCollection()
Constructor to create a new map with only spezified objects as values. |
Method Summary | |
boolean |
containsKey(java.lang.String key)
Method tests if a key is in the map. |
protected java.lang.Object |
getObject(java.lang.String key)
Method tries to return the object identified by its key. |
protected abstract java.lang.Class |
getSpecialObjectClass()
|
java.util.Iterator |
iterator()
Method could be invoked to get all values |
java.util.Iterator |
keyIterator()
Method could be invoked to get a keySet over all keys. |
void |
removeObject(java.lang.String key)
Remove the object identified by its key from the collection. |
boolean |
tryToAddObject(java.lang.String key,
java.lang.Object object)
Method tries to add an object to the map and is threadsave |
Methods inherited from class java.lang.Object |
|
Field Detail |
private java.util.HashMap map
private java.lang.Class objectClass
Constructor Detail |
protected SpecializedCollection()
Method Detail |
protected abstract java.lang.Class getSpecialObjectClass()
public boolean tryToAddObject(java.lang.String key, java.lang.Object object)
key
- represents the identifier for the object.object
- is the object to be added.public void removeObject(java.lang.String key) throws NoSuchMemberException
key
- identifies the object.NoSuchMemberException
- if there is no object
with the key in the collection.public java.util.Iterator iterator()
Iterator
containing any values of
the mappublic java.util.Iterator keyIterator()
Iterator
conaining all keys of the map.public boolean containsKey(java.lang.String key)
{@link
- java.lang.String} identifying the searched key.protected java.lang.Object getObject(java.lang.String key) throws NoSuchMemberException
{@link
- java.lang.String} identifying the object that is searched.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |