| java.lang.Object com.jidesoft.converter.CacheMap
CacheMap | public class CacheMap (Code) | | CacheMap is a two-level HashMap .
It uses Class as the key and you can map the key to an object and a context as a pair.
We use context because we want to register multiple objects with the same Class.
CacheMap.register(Class,Object,Object) is the method to register a new entry.
CacheMap.getRegisteredObject(Class,Object) will allow you to look up the object by specifying the Class and the context.
|
Inner Class :static class Cache extends HashMap | |
Constructor Summary | |
public | CacheMap(K defaultContext) Constructs a CacheMap . |
Method Summary | |
public void | addRegistrationListener(RegistrationListener l) Adds a listener to the list that's notified each time a change
to the registration occurs. | public void | clear() | public void | fireRegistrationChanged(RegistrationEvent e) Forwards the given notification event to all
RegistrationListeners that registered
themselves as listeners for this table model. | protected Cache<K, T> | getCache(Class> clazz) | public K[] | getKeys(Class> clazz, K[] a) Gets the secondary keys that are registered with the class in CacheMap.
Parameters: clazz - the class Parameters: a - the array to receive the keys. | public T | getRegisteredObject(Class> clazz, K context) Gets registered object from CacheMap. | public RegistrationListener[] | getRegistrationListeners() Returns an array of all the registration listeners
registered on this registration. | public List<T> | getValues() | protected Cache<K, T> | initCache(Class> clazz) | public void | register(Class> clazz, T object, K context) Regsiters an object with the specified clazz and object.
Parameters: clazz - the class which is used as the key. Parameters: object - the object, or the value of the mapping Parameters: context - the secondary key. | public void | removeRegistrationListener(RegistrationListener l) Removes a listener from the list that's notified each time a
change to the registration occurs. | public void | unregister(Class> clazz, K context) Unregistered the object associated with the specified class and context. |
CacheMap | public CacheMap(K defaultContext)(Code) | | Constructs a CacheMap .
Parameters: defaultContext - the default context. |
addRegistrationListener | public void addRegistrationListener(RegistrationListener l)(Code) | | Adds a listener to the list that's notified each time a change
to the registration occurs.
Parameters: l - the RegistrationListener |
clear | public void clear()(Code) | | |
getCache | protected Cache<K, T> getCache(Class> clazz)(Code) | | |
getKeys | public K[] getKeys(Class> clazz, K[] a)(Code) | | Gets the secondary keys that are registered with the class in CacheMap.
Parameters: clazz - the class Parameters: a - the array to receive the keys. the secondary keys. |
getRegisteredObject | public T getRegisteredObject(Class> clazz, K context)(Code) | | Gets registered object from CacheMap. The algorithm used to look up is
1. First check for exact match with clazz.
2. If didn't find, look for interfaces that clazz implements.
3. If still didn't find, look for super class of clazz
4. If still didn't find, return null.
If found a match in step 1, 2, and 3, it will return the registered object immediately.
Parameters: clazz - the class which is used as the primary key. Parameters: context - the context which is used as the secondary key. This parameter could be null in which case the default context is used. registered object the object associated with the class and the context. |
initCache | protected Cache<K, T> initCache(Class> clazz)(Code) | | |
register | public void register(Class> clazz, T object, K context)(Code) | | Regsiters an object with the specified clazz and object.
Parameters: clazz - the class which is used as the key. Parameters: object - the object, or the value of the mapping Parameters: context - the secondary key. It is used to register multiple objects to the same primary key (the clazz parameter in this case). |
removeRegistrationListener | public void removeRegistrationListener(RegistrationListener l)(Code) | | Removes a listener from the list that's notified each time a
change to the registration occurs.
Parameters: l - the RegistrationListener |
unregister | public void unregister(Class> clazz, K context)(Code) | | Unregistered the object associated with the specified class and context.
Parameters: clazz - the class Parameters: context - the context |
|
|