gov.nist.microanalysis.EPQLibrary
Class AlgorithmClass

java.lang.Object
  extended by gov.nist.microanalysis.EPQLibrary.AlgorithmClass
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
BetheElectronEnergyLoss, CharacteristicXRayGeneration, EdgeEnergy, ElectronRange, FluorescenceYield, IonizationCrossSection, MassAbsorptionCoefficient, MeanIonizationPotential, TransitionEnergy

public abstract class AlgorithmClass
extends java.lang.Object
implements java.lang.Comparable

A simple class that implements various common properties of classes that implement algorithms.

AlgorithmClass objects have a general type ('class') name and a specific instance name. They can also contain a reference detailing the source of the algorithm.

AlgorithmClass objects also define a list of default AlgorithmClass instances on which they depend. Replacements for these default AlgorithmClass instances can be specified using the Strategy mechanism.

Copyright: Pursuant to title 17 Section 105 of the United States Code this software is not subject to copyright protection and is in the public domain

Company: National Institute of Standards and Technology

Version:
1.0
Author:
Nicholas W. M. Ritchie

Constructor Summary
protected AlgorithmClass(java.lang.String clss, java.lang.String name, Reference ref)
           
protected AlgorithmClass(java.lang.String clss, java.lang.String name, java.lang.String ref)
           
 
Method Summary
protected  void addDefaultAlgorithm(java.lang.Class cls, AlgorithmClass ac)
          addDefaultAlgorithm - Specify a default algorithm.
static java.lang.String[] allAlgorithmNames()
          allAlgorithmNames - Gets an array of String containing a description of all algorithms as returned by toString().
static java.util.SortedSet allAlgorithms()
          allAlgorithms - An unmodifiable list of all available algorithms of all various different classes.
static void applyGlobalOverride(Strategy strat)
          applyGlobalOverride - Apply the specified Strategy as a gloabal overrride for all AlgorithmClass objects.
static void clearGlobalOverride()
          clearGlobalOverride - Clear the global strategy override restoring each algorithm to use its default algorithms.
 int compareTo(java.lang.Object o)
          compareTo - Sort by name
 void documentStrategy(java.io.Writer wr)
          Outputs a description of the current Strategy to the specified Writer.
 Strategy getActiveStrategy()
          getActiveStrategy - Returns a Strategy object containing a complete set of the the AlgorithmClass objects on which this AlgorithmClass object depends.
protected  AlgorithmClass getAlgorithm(java.lang.Class cls)
          getAlgorithm - Returns the specific algorithm associated with the base class provided as an argument.
 java.lang.String getAlgorithmClass()
          getAlgorithmClass - Get the base AlgorithmClass instance of which this class is an instance.
abstract  java.util.List getAllImplementations()
          getAllImplementations - Returns a list of all implementations of the derived algorithm class.
 java.lang.String getName()
          getName - Get the abbreviated name of the algorithm.
 java.lang.String getReference()
          getReference - Get the literature reference describing the implementation of this algorithm.
protected abstract  void initializeDefaultStrategy()
          initializeDefaultStrategy - Implement this method in derived classes to specify the contents (possibly null) of the default Strategy using the addDefaultAlgorithm(Class,AlgorithmClass) method.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AlgorithmClass

protected AlgorithmClass(java.lang.String clss,
                         java.lang.String name,
                         Reference ref)

AlgorithmClass

protected AlgorithmClass(java.lang.String clss,
                         java.lang.String name,
                         java.lang.String ref)
Method Detail

getAllImplementations

public abstract java.util.List getAllImplementations()
getAllImplementations - Returns a list of all implementations of the derived algorithm class. Typically this method is implemented by the abstract base class from which more specific implementations are derived.

Returns:
List

initializeDefaultStrategy

protected abstract void initializeDefaultStrategy()
initializeDefaultStrategy - Implement this method in derived classes to specify the contents (possibly null) of the default Strategy using the addDefaultAlgorithm(Class,AlgorithmClass) method.


getActiveStrategy

public Strategy getActiveStrategy()
getActiveStrategy - Returns a Strategy object containing a complete set of the the AlgorithmClass objects on which this AlgorithmClass object depends.

Returns:
Strategy

getAlgorithm

protected AlgorithmClass getAlgorithm(java.lang.Class cls)
getAlgorithm - Returns the specific algorithm associated with the base class provided as an argument.

Parameters:
cls -
Returns:
AlgorithmClass

applyGlobalOverride

public static void applyGlobalOverride(Strategy strat)
applyGlobalOverride - Apply the specified Strategy as a gloabal overrride for all AlgorithmClass objects.

Parameters:
strat -

clearGlobalOverride

public static void clearGlobalOverride()
clearGlobalOverride - Clear the global strategy override restoring each algorithm to use its default algorithms.


addDefaultAlgorithm

protected void addDefaultAlgorithm(java.lang.Class cls,
                                   AlgorithmClass ac)
addDefaultAlgorithm - Specify a default algorithm. (Use applyStrategy to override)

Parameters:
cls -
ac -

allAlgorithms

public static java.util.SortedSet allAlgorithms()
allAlgorithms - An unmodifiable list of all available algorithms of all various different classes.

Note: Classes are only added to this list when they are first instanciated. However this may never happen if the algorithm is never used.

Returns:
SortedSet

allAlgorithmNames

public static java.lang.String[] allAlgorithmNames()
allAlgorithmNames - Gets an array of String containing a description of all algorithms as returned by toString().

Note: Classes are only added to this list when they are first instanciated. However this may never happen if the algorithm is never used.

Returns:
String[]

compareTo

public int compareTo(java.lang.Object o)
compareTo - Sort by name

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - Object
Returns:
int

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getAlgorithmClass

public java.lang.String getAlgorithmClass()
getAlgorithmClass - Get the base AlgorithmClass instance of which this class is an instance.

Returns:
String

getName

public java.lang.String getName()
getName - Get the abbreviated name of the algorithm.

Returns:
String

getReference

public java.lang.String getReference()
getReference - Get the literature reference describing the implementation of this algorithm.

Returns:
String

documentStrategy

public void documentStrategy(java.io.Writer wr)
                      throws java.io.IOException
Outputs a description of the current Strategy to the specified Writer.

Parameters:
wr -
Throws:
java.io.IOException