AFLPcore
Class Manager

java.lang.Object
  |
  +--AFLPcore.Manager
Direct Known Subclasses:
AnalysisMgr, BinOpMgr, CutoffMgr, GelOpMgr, ImportMgr, LaneOpMgr, PeakMgr, ScoreManager, SizeMgr, StandardMgr

public abstract class Manager
extends java.lang.Object

This class contains a list of Operations which can be used to perform different functions in the program. Each op is associated with a String, which represents its name. The associations are currently mantained in a hash table.

Both this class and Operation are abstract and must be extended. The op should be similar in some way, like ImportFilter which extends Operation and is an abstract class for filtering in input files. The ImportMgr is a subclass of this class and checks to see that all of the Operations are of type ImportFilter. Therefore, the only method that needs to be implemented by a subclass is the classTypeOk, which checks to make sure that the operation is a valid one.

Classes that extend this class should call this classes constructor to set up the hashtable.

The ops can be retrieved based on their name, and a lists of names can be obtained from the Manager. The Op will contain addtional information.

Currently, ops can be added with methods, but ideally the Manager would be able to analyze something like a directory and add all of the ops it found there. This would mean that different operations could be add by simply dropping a class that extended the appropriate Operation subclass into the appropriate directory.

See Also:
Operation, Hashtable, ImportMgr, ImportFilter

Constructor Summary
Manager()
          Creates a new Manager, with a default capacity of 4 and a loadFactor of 1.0.
Manager(int capacity, float loadFactor)
          Creates a new Manager with the specified values.
 
Method Summary
 void add(java.lang.String name, Operation operation)
          Adds the specified operation with the given name to the Manager.
abstract  boolean classTypeOk(Operation op)
          Checks to see if the specified operation is compatible with the manager.
 Operation get(java.lang.String opName)
          Retrieves the operation associated with the given name.
 Operation getDefault()
          Gives the default operation for this manager.
 java.lang.String getDefaultName()
          Gives the name of the default operation for this manager.
 java.lang.String[] getNames()
          Gets the names of all of the Operations known to the Manager.
 void setDefault(java.lang.String name)
          Sets the default operation to the one specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Manager

public Manager()
Creates a new Manager, with a default capacity of 4 and a loadFactor of 1.0. Sets up the Hashtable for the String/Operation pairs.

Manager

public Manager(int capacity,
               float loadFactor)
        throws java.lang.IllegalArgumentException
Creates a new Manager with the specified values.
Parameters:
capacity - the initial number of operations that can be stored.
loadFactor - controls memory efficiency vs. lookup speed, it must be between 0.0 and 1.0, where 1.0 has the greatest memory efficiency
Throws:
java.lang.IllegalArgumentException - when capacitly is less than zero or the loadFactor is out of bounds.
Method Detail

getNames

public java.lang.String[] getNames()
Gets the names of all of the Operations known to the Manager. It works be creating an Enumeration from the hash table. The Enumeration is turned into an array be simply retrieveing the next element and storing it in an array. The size of the hashtable becomes the size of the array.
See Also:
Enumeration

get

public Operation get(java.lang.String opName)
              throws java.util.NoSuchElementException
Retrieves the operation associated with the given name. This can be used to analyze an operation and to retrieve specific information about it.
Parameters:
filterName - the name of a filter known to this Manager
Throws:
java.util.NoSuchElementException - the specified operation does not exist In other words, opName does not have an associated value.

add

public void add(java.lang.String name,
                Operation operation)
         throws java.lang.IllegalArgumentException
Adds the specified operation with the given name to the Manager. The operation must be compatible with the type of operation that this class handles.
Parameters:
name - the name of the operation to be associated with it
operation - the operation object
Throws:
java.lang.IllegalArgumentException - occurs when the given operation is not compatible with the Manager.

classTypeOk

public abstract boolean classTypeOk(Operation op)
Checks to see if the specified operation is compatible with the manager. For example, here is the implementation used by ImportMgr.
   return (op instanceof ImportFilter);
 
Returns:
true if it is compatible, false if it is not.

setDefault

public void setDefault(java.lang.String name)
                throws java.util.NoSuchElementException
Sets the default operation to the one specified.
Parameters:
name - the name of the operation to use as the default. If it is null, then no default method will be set and an exception will be thrown when getDefault is called.
Throws:
java.util.NoSuchElementException - when the specified name is not null and does not match any filter known to the ImportMgr, this will be thrown.

getDefault

public Operation getDefault()
Gives the default operation for this manager.
Returns:
the operation, or null if the default is not set.

getDefaultName

public java.lang.String getDefaultName()
Gives the name of the default operation for this manager.
Returns:
the name of the operation, or null if the default is not set.