gov.nist.microanalysis.EPQLibrary
Class Strategy

java.lang.Object
  extended by gov.nist.microanalysis.EPQLibrary.Strategy
All Implemented Interfaces:
java.lang.Cloneable

public class Strategy
extends java.lang.Object
implements java.lang.Cloneable

Algorithms often depend on other algorithms during the computation. Sometimes it is desirable to interchange dependent algorithms. Strategy objects facilitate this. A Strategy is a mechanism for interchanging the algorithms which are used to compute a quantity. A Strategy is a one-to-one mapping between algorithm type (such as BackscatterFactor.class or MassAbsorptionCoefficient.class) and the algorithm implementing this algorithm-type (such as BackscatterFactor.Pouchou1991 or MassAbsorptionCoefficient.Chantler2005). Each instance of the AlgorithmClass understands what other types of AlgorithmClass it requires to perform its operations and can provide a list of the default algorithms as its default Strategy. The defaults algorithms can be overridden using the AlgorithmClass.apply(Strategy ) method. Strategy objects enforce consistency across a calculation.


Constructor Summary
Strategy()
          Constructs a Strategy
 
Method Summary
 void addAlgorithm(java.lang.Class cls, AlgorithmClass value)
          Specify an implentation of an AlgorithmClass-derived abstract base class.
 void apply(Strategy st)
          apply - For those Class objects in this Stragegy, assign the Class-to-AlgorithmClass mappings in the argument Strategy to this Strategy.
 java.lang.Object clone()
           
 AlgorithmClass getAlgorithm(java.lang.Class cls)
          Get the implentation of an AlgorithmClass-derived abstract base class.
 AlgorithmClass getAlgorithm(java.lang.String clsName)
          Get the implentation of an AlgorithmClass-derived abstract base class from the name of the abstract base class.
 java.util.Collection listAlgorithmClasses()
          Returns a list of the name of the defined AlgorithmClass types
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Strategy

public Strategy()
Constructs a Strategy

Method Detail

listAlgorithmClasses

public java.util.Collection listAlgorithmClasses()
Returns a list of the name of the defined AlgorithmClass types

Returns:
A Collection of String objects

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

apply

public void apply(Strategy st)
apply - For those Class objects in this Stragegy, assign the Class-to-AlgorithmClass mappings in the argument Strategy to this Strategy. Preexisting assignments are overridden.

Parameters:
st -

addAlgorithm

public void addAlgorithm(java.lang.Class cls,
                         AlgorithmClass value)
Specify an implentation of an AlgorithmClass-derived abstract base class.

Parameters:
cls - - One of AbsorptionCorrection.class, BackscatterFactor.class, ...
value - - A class derived from the class specified in cls

getAlgorithm

public AlgorithmClass getAlgorithm(java.lang.Class cls)
Get the implentation of an AlgorithmClass-derived abstract base class.

Parameters:
cls -
Returns:
A class instance derived from AlgorithmClass or null

getAlgorithm

public AlgorithmClass getAlgorithm(java.lang.String clsName)
Get the implentation of an AlgorithmClass-derived abstract base class from the name of the abstract base class.

Parameters:
clsName -
Returns:
A class instance derived from AlgorithmClass or null