net.kano.joscar.snac
Class SnacCmdFactoryList

java.lang.Object
  extended bySnacCmdFactoryList
Direct Known Subclasses:
CmdFactoryMgr, DefaultSnacCmdFactoryList

public abstract class SnacCmdFactoryList
extends java.lang.Object

Provides an interface for grouping a set of SNAC command factories into a list. I can't quite remember why I didn't just use a List or something. :) See DefaultSnacCmdFactoryList for a simpler way to use SnacCmdFactoryLists.


Constructor Summary
SnacCmdFactoryList()
           
 
Method Summary
 SnacCmdFactory getFactory(CmdType type)
          Returns an the SnacCmdFactory registered for the given CmdType.
protected  void register(CmdType type, SnacCmdFactory factory)
          Registers the given command factory for the given command type.
protected  void registerAll(SnacCmdFactory factory)
          Registers the given factory for all command types provided by its getSupportedTypes method.
protected  void unregister(CmdType type, SnacCmdFactory factory)
          Unregisters the given factory for the given SNAC command type.
protected  void unregisterAll()
          Unregisters all SNAC factories from all registered command types.
protected  void unregisterAll(SnacCmdFactory factory)
          Unregisters the given factory for all types for which it is currently registered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnacCmdFactoryList

public SnacCmdFactoryList()
Method Detail

register

protected final void register(CmdType type,
                              SnacCmdFactory factory)
Registers the given command factory for the given command type. The factory will be added such that getFactory(type) == factory.

Note that the given factory must include the given command type in the list returned by its getSupportedTypes method.

Parameters:
type - the command type to register
factory - the factory to be registered with the given command type

registerAll

protected final void registerAll(SnacCmdFactory factory)
Registers the given factory for all command types provided by its getSupportedTypes method.

Parameters:
factory - the factory to register

unregister

protected final void unregister(CmdType type,
                                SnacCmdFactory factory)
Unregisters the given factory for the given SNAC command type. No change will take place if the given factory is not registered for the given type.

Parameters:
type - the command type for which the given factory should be unregistered
factory - the factory to unregister for the given type

unregisterAll

protected final void unregisterAll(SnacCmdFactory factory)
Unregisters the given factory for all types for which it is currently registered.

Parameters:
factory - the factory to completely unregister

unregisterAll

protected final void unregisterAll()
Unregisters all SNAC factories from all registered command types. Effectively resets this factory list.


getFactory

public final SnacCmdFactory getFactory(CmdType type)
Returns an the SnacCmdFactory registered for the given CmdType. Note that this only returns exact matches, so getFactory(new CmdType(CmdType.ALL, CmdType.ALL)) will return null if no factory has been registered specifically for that command type, even though, according to the CmdType specification, CmdType matches all possible command types.

Parameters:
type - the command type whose associated command factory will be returned
Returns:
the command factory associated with the given command type, or null if none exists