ca.quine.factorygen
Class Registrar

java.lang.Object
  |
  +--ca.quine.factorygen.Registrar
Direct Known Subclasses:
MarshallerFactoryTest, MessageHandlerFactoryTest

public class Registrar
extends Object

Registers a set of IRegistrant objects, which know how to register themselves.

See Also:
IRegistrant

Constructor Summary
Registrar()
           
 
Method Summary
protected  void addRegistrant(IRegistrant registrant)
          Subclasses can call this method to add an IRegistrant to the registered list of handlers.
 Iterator getRegistrantEntryIterator()
          Returns an Iterator over all the map entries.
 Iterator getRegistrantIterator()
          Returns an Iterator that iterates over all the IRegistrant instances registered with this Registrar, possibly with duplicates if an IRegistrant is registered with more than one key.
protected  IRegistrant getRegistrantProtected(Object key)
          Returns the IRegistrant that can handle the given key, or null if no such handler is found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Registrar

public Registrar()
Method Detail

addRegistrant

protected void addRegistrant(IRegistrant registrant)
Subclasses can call this method to add an IRegistrant to the registered list of handlers.

Parameters:
registrant -

getRegistrantProtected

protected IRegistrant getRegistrantProtected(Object key)
Returns the IRegistrant that can handle the given key, or null if no such handler is found. Subclasses of Registrar will call this internal method and cast the returned IRegistrant to the correct type.

Parameters:
key -
Returns:
the IRegistrant that is registered with the given key

getRegistrantEntryIterator

public Iterator getRegistrantEntryIterator()
Returns an Iterator over all the map entries. The keys are the registration keys, and each value is the IRegistrant instance that is registered for that key. This method can be used by an autogenerator to produce documentation on which mappings this Registrar has.

Returns:
an Iterator of Map.Entry objects, the keys are the

getRegistrantIterator

public Iterator getRegistrantIterator()
Returns an Iterator that iterates over all the IRegistrant instances registered with this Registrar, possibly with duplicates if an IRegistrant is registered with more than one key. This method can be used to implement the Chain of Responsibility pattern.

Returns:
an Iterator of IRegistrant instances