com.monoserv.patterns
Class ChainManager

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<IModule>
              extended by com.monoserv.patterns.ChainManager
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<IModule>, java.util.Collection<IModule>, java.util.List<IModule>, java.util.RandomAccess

public class ChainManager
extends java.util.ArrayList<IModule>

This is a class which will facilitate the logic between modules. It will implement a version of the "Chain Of Responsibility" Right now, it will be linear. Perhaps future possibility of expanding this into a tree or multiple branches may work. Note: This is not how I want it setup. This will be changed in the near future. It will be changed to reflect a generic "Chain Of Responsibiliy" and then another class (in another package) will eventually inherit that class. Makes more sense that way.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ChainManager()
          Constructor - just calls super();
 
Method Summary
 boolean add(IModule arg0)
          This is an overriden version of the add(E) inside of ArrayList.
 void add(int arg0, IModule arg1)
          This is an overriden version of the add(int, E) inside of ArrayList.
 java.lang.String getDataModule()
          Returns the module that was stored in the XML file.
 InstanceModifier getInstanceModifier()
          Returns the instance modifier.
 void ReadXml(java.io.File xmlFile)
          This will take a configuration XML file for the server and read it in.
 IModuleData RunThroughModuleBlocks(IModuleData objInput)
          This will take the initial input and feed it through all the registered modules.
 
Methods inherited from class java.util.ArrayList
addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

ChainManager

public ChainManager()
Constructor - just calls super();

Method Detail

add

public boolean add(IModule arg0)
            throws java.lang.NullPointerException
This is an overriden version of the add(E) inside of ArrayList. This does a check and only adds the element if the arg0 supplied is not null.

Specified by:
add in interface java.util.Collection<IModule>
Specified by:
add in interface java.util.List<IModule>
Overrides:
add in class java.util.ArrayList<IModule>
Parameters:
arg0 - The module to add to the list
Returns:
boolean Returns based on the contract of the add method in ArrayList
Throws:
java.lang.NullPointerException - if the module is null

add

public void add(int arg0,
                IModule arg1)
This is an overriden version of the add(int, E) inside of ArrayList. This does a check and only adds the element if the arg1 supplied is not null.

Specified by:
add in interface java.util.List<IModule>
Overrides:
add in class java.util.ArrayList<IModule>
Parameters:
arg0 - The index to add the ArrayList too
arg1 - The instance to add to the array list.

getInstanceModifier

public InstanceModifier getInstanceModifier()
                                     throws java.lang.NullPointerException
Returns the instance modifier. NOTE: This will throw a NullPointerException if you have not called RunThroughModuleBlocks first. That is the method in which this object is constructed.

Returns:
InstanceModifier The object thatis constructed in RunThroughModuleBlocks to inform the server how to act.
Throws:
java.lang.NullPointerException - If the InstanceModifier object was not initialized.

RunThroughModuleBlocks

public IModuleData RunThroughModuleBlocks(IModuleData objInput)
This will take the initial input and feed it through all the registered modules. The last module will to run will have the final piece of output which will be returned.

Parameters:
objInput - The first object to be used as input
Returns:
Object The output of the final module that runs

getDataModule

public java.lang.String getDataModule()
                               throws java.lang.NullPointerException
Returns the module that was stored in the XML file.

Returns:
String A string represention of the class to load for the data module
Throws:
java.lang.NullPointerException - If the string length() is 0 or if the String is null

ReadXml

public void ReadXml(java.io.File xmlFile)
             throws java.lang.RuntimeException
This will take a configuration XML file for the server and read it in. It will read in the data, store it and also populate the ArrayList with new instances of the objects (assuming they can be loaded).

Parameters:
xmlFile - A file object representing the file to be parsed.
Throws:
java.lang.RuntimeException - If something goes wrong (any number of things).