org.aitools.programd.util
Class ObjectExemplarRegistry<B>

java.lang.Object
  extended by org.aitools.programd.util.ObjectExemplarRegistry<B>
Type Parameters:
B - the base class for objects that will be registered
Direct Known Subclasses:
ShellCommandRegistry

public abstract class ObjectExemplarRegistry<B>
extends java.lang.Object

Similar to ClassRegistry, but registers object exemplars.


Field Summary
protected  java.util.Hashtable<java.lang.String,B> registry
          The Hashtable that stores the objects.
private  java.lang.Class<B> type
          The type of B (why, oh why, should I have to do this?
 
Constructor Summary
ObjectExemplarRegistry(java.lang.String[] classnames, java.lang.Class<B> objectType, java.lang.Object... constructorArguments)
          Loads the registry with a set of exemplar objects.
 
Method Summary
 B get(java.lang.String classname)
          A wrapper for the internal HashSet's get method.
 void register(java.lang.String classname, java.lang.Object... constructorArguments)
          Registers an individual exemplar object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

private java.lang.Class<B> type
The type of B (why, oh why, should I have to do this?


registry

protected java.util.Hashtable<java.lang.String,B> registry
The Hashtable that stores the objects.

Constructor Detail

ObjectExemplarRegistry

public ObjectExemplarRegistry(java.lang.String[] classnames,
                              java.lang.Class<B> objectType,
                              java.lang.Object... constructorArguments)
Loads the registry with a set of exemplar objects.

Parameters:
classnames - the classnames for which to register exemplar objects
objectType - the type of B (seems stupid to have to pass this in, but necessary to avoid some compiler errors)
constructorArguments - the arguments for B's constructor
Method Detail

register

public void register(java.lang.String classname,
                     java.lang.Object... constructorArguments)
Registers an individual exemplar object.

Parameters:
classname - the name of the object to register
constructorArguments - the arguments to the constructor

get

public B get(java.lang.String classname)
      throws NotARegisteredObjectException
A wrapper for the internal HashSet's get method.

Parameters:
classname - the classname for which an exemplar object is desired
Returns:
the registered exemplar object corresponding to the classname
Throws:
NotARegisteredObjectException - if the given class is not registered