|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pfsw.plugin.ClassRegistry<T>
public class ClassRegistry<T>
A class registry is a container that keeps classes registered under a logical key. For a query by key it can return
Constructor Summary | |
---|---|
ClassRegistry()
Initialize the new instance with default values. |
|
ClassRegistry(java.lang.Class<T> typeOfRegisteredClasses)
Initialize the new instance with a type all classes that are registered must comply to. |
Method Summary | |
---|---|
protected void |
assertArgNotNull(java.lang.String methodName,
java.lang.String argName,
java.lang.Object arg)
|
protected void |
assertClassFound(org.pfsw.reflect.ClassInfo<T> classInfo)
|
protected void |
assertInstanceCreation(org.pfsw.reflect.ClassInfo<T> classInfo)
|
protected void |
assertValidType(org.pfsw.reflect.ClassInfo<T> classInfo)
|
java.lang.Class<T>[] |
classes()
Returns all class objects that are currently in this registry. |
java.lang.String[] |
classNames()
Returns all class names of the classes that are currently in this registry. |
protected java.util.List<java.lang.Class<T>> |
collectClasses()
Returns all classes that are currently in this registry. |
protected java.util.List<java.lang.String> |
collectNames()
Returns all class names that are currently in this registry. |
protected org.pfsw.reflect.ClassInfo<T> |
get(java.lang.Object key)
|
java.lang.Class<T> |
getClass(java.lang.String key)
Returns the class which is registered under the given key. |
org.pfsw.reflect.ClassInfo<T> |
getClassInfo(java.lang.String key)
Returns the class information object stored under the given key or null if nothing is found. |
java.lang.String |
getClassName(java.lang.Object key)
Returns the name of the class which is registered under the given key. |
protected java.lang.Class<T> |
getEntryType()
|
org.pfsw.reflect.ClassInfo<T> |
getFirst()
Returns the first class info object of null if the registry is empty. |
protected void |
handleException(java.lang.Exception ex)
|
protected void |
illegalArgumentException(java.lang.String methodName,
java.lang.String argName)
|
boolean |
isEmpty()
|
protected boolean |
isTyped()
|
boolean |
isValidType(java.lang.Class<?> type)
Returns true if the given type is compatible to the underlying entry type. |
java.lang.String[] |
keys()
Returns all keys known in this registry. |
T |
newInstance(java.lang.String key)
Returns a new instance of the class which is registered under the given key. |
void |
put(java.lang.String key,
java.lang.Class<T> aClass)
Registers the given class under the specified key. |
protected void |
put(java.lang.String key,
org.pfsw.reflect.ClassInfo<T> classInfo)
|
void |
put(java.lang.String key,
java.lang.String className)
Registers the class with the given name under the specified key. |
boolean |
register(java.lang.String key,
java.lang.Class<T> aClass)
Registers the class under the specified key. |
boolean |
register(java.lang.String key,
java.lang.String className)
Registers the class with the given name under the specified key. |
protected java.util.Map<java.lang.String,org.pfsw.reflect.ClassInfo<T>> |
registry()
|
protected void |
registry(java.util.Map<java.lang.String,org.pfsw.reflect.ClassInfo<T>> newValue)
|
boolean |
remove(java.lang.Object key)
Removes the entry in the registry which is defined by the given key. |
protected void |
setEntryType(java.lang.Class<T> newValue)
|
int |
size()
|
protected void |
validate(org.pfsw.reflect.ClassInfo<T> classInfo)
|
org.pfsw.reflect.ClassInfo<T>[] |
values()
Returns all class info objects that are currently in this registry. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClassRegistry()
public ClassRegistry(java.lang.Class<T> typeOfRegisteredClasses)
typeOfRegisteredClasses
- The type to which the classes that can be
registered must be compatible toMethod Detail |
---|
public java.lang.String getClassName(java.lang.Object key)
key
- The key under which the class is registeredpublic java.lang.Class<T> getClass(java.lang.String key)
key
- The key under which the class is registeredpublic T newInstance(java.lang.String key)
key
- The key under which the class is registered.public boolean register(java.lang.String key, java.lang.String className)
key
- The key under which the class is registeredclassName
- The fully qualified name of the class
public void put(java.lang.String key, java.lang.String className) throws ClassRegistryException
key
- The key under which the class is registered.className
- The fully qualified name of the class.
ClassRegistryException
- If the class can't be found or if it is of
the wrong type or can't be instantiated.public boolean register(java.lang.String key, java.lang.Class<T> aClass)
key
- The key under which the class is registeredaClass
- The class to be registered
public void put(java.lang.String key, java.lang.Class<T> aClass) throws ClassRegistryException
key
- The key under which the class is registeredaClass
- The class to be registered
ClassRegistryException
- If the class is of the wrong type or
can't be instantiatedpublic boolean remove(java.lang.Object key)
public java.lang.String[] keys()
public org.pfsw.reflect.ClassInfo<T>[] values()
public org.pfsw.reflect.ClassInfo<T> getFirst()
public java.lang.Class<T>[] classes()
public java.lang.String[] classNames()
public org.pfsw.reflect.ClassInfo<T> getClassInfo(java.lang.String key)
public boolean isValidType(java.lang.Class<?> type)
type
- The type to be checked.public int size()
public boolean isEmpty()
protected org.pfsw.reflect.ClassInfo<T> get(java.lang.Object key)
protected void put(java.lang.String key, org.pfsw.reflect.ClassInfo<T> classInfo) throws ClassRegistryException
ClassRegistryException
protected void validate(org.pfsw.reflect.ClassInfo<T> classInfo) throws ClassRegistryException
ClassRegistryException
protected void assertClassFound(org.pfsw.reflect.ClassInfo<T> classInfo) throws ClassRegistryException
ClassRegistryException
protected void assertValidType(org.pfsw.reflect.ClassInfo<T> classInfo) throws ClassRegistryException
ClassRegistryException
protected void assertInstanceCreation(org.pfsw.reflect.ClassInfo<T> classInfo) throws ClassRegistryException
ClassRegistryException
protected boolean isTyped()
protected void assertArgNotNull(java.lang.String methodName, java.lang.String argName, java.lang.Object arg)
protected void illegalArgumentException(java.lang.String methodName, java.lang.String argName)
protected java.util.List<java.lang.String> collectNames()
protected java.util.List<java.lang.Class<T>> collectClasses()
protected void handleException(java.lang.Exception ex)
protected java.lang.Class<T> getEntryType()
protected void setEntryType(java.lang.Class<T> newValue)
protected java.util.Map<java.lang.String,org.pfsw.reflect.ClassInfo<T>> registry()
protected void registry(java.util.Map<java.lang.String,org.pfsw.reflect.ClassInfo<T>> newValue)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |