gov.sandia.cognition.evaluator
Class AbstractStatefulEvaluator<InputType,OutputType,StateType extends CloneableSerializable>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.evaluator.AbstractStatefulEvaluator<InputType,OutputType,StateType>
Type Parameters:
InputType - Input of the Evaluator
OutputType - Output of the Evaluator
StateType - State object contain in this
All Implemented Interfaces:
Evaluator<InputType,OutputType>, StatefulEvaluator<InputType,OutputType,StateType>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
AutoRegressiveMovingAverageFilter, DelayFunction, KolmogorovSmirnovEvaluator, LinearDynamicalSystem, LinearRegressionCoefficientExtractor, MovingAverageFilter, PIDController

@CodeReviews(reviews={@CodeReview(reviewer="Kevin R. Dixon",date="2008-02-08",changesNeeded=false,comments="Looks fine."),@CodeReview(reviewer="Justin Basilico",date="2007-11-20",changesNeeded=false,comments="Cleaned up.")})
public abstract class AbstractStatefulEvaluator<InputType,OutputType,StateType extends CloneableSerializable>
extends AbstractCloneableSerializable
implements StatefulEvaluator<InputType,OutputType,StateType>

The AbstractStatefulEvalutor class is an abstract implementation of the StatefulEvalutor interface. It provides a state object field plus a getter and setter for the field plus an implementation of the method to reset the state.

Since:
2.0
Author:
Kevin R. Dixon
See Also:
StatefulEvaluator, Serialized Form

Constructor Summary
AbstractStatefulEvaluator()
          Creates a new instance of AbstractStatefulEvaluator.
AbstractStatefulEvaluator(StateType initialState)
          Creates a new instance of AbstractStatefulEvaluator.
 
Method Summary
 AbstractStatefulEvaluator<InputType,OutputType,StateType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 OutputType evaluate(InputType input, StateType state)
          Evaluates the object using the given input and the given state object, returning the output.
 StateType getState()
          Gets the current state of the evaluator.
 void resetState()
          Resets the state of the evaluator to a default state.
 void setState(StateType state)
          Sets the current state of the evaluator.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.evaluator.StatefulEvaluator
createDefaultState, evaluate
 

Constructor Detail

AbstractStatefulEvaluator

public AbstractStatefulEvaluator()
Creates a new instance of AbstractStatefulEvaluator.


AbstractStatefulEvaluator

public AbstractStatefulEvaluator(StateType initialState)
Creates a new instance of AbstractStatefulEvaluator.

Parameters:
initialState - The initial state object.
Method Detail

clone

public AbstractStatefulEvaluator<InputType,OutputType,StateType> clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A clone of this object.

evaluate

public OutputType evaluate(InputType input,
                           StateType state)
Description copied from interface: StatefulEvaluator
Evaluates the object using the given input and the given state object, returning the output. The given state object may be modified by side effect. The current state of the Evaluator is also set to be the given state. Typically, the evaluator will set the current state to the given state and then call the single-parameter version of evaluate on the input.

Specified by:
evaluate in interface StatefulEvaluator<InputType,OutputType,StateType extends CloneableSerializable>
Parameters:
input - The input to evaluate.
state - The state to use, which can be modified by side effect. The current state of the Evaluator will be based on this given state.
Returns:
The output of the evaluation. The state is also modified by side effect.

getState

public StateType getState()
Description copied from interface: StatefulEvaluator
Gets the current state of the evaluator. This is a reference to the current state, which may later be modified by side-effect. If a true copy of the state is needed, this returned value should be copied.

Specified by:
getState in interface StatefulEvaluator<InputType,OutputType,StateType extends CloneableSerializable>
Returns:
The current state.

setState

public void setState(StateType state)
Description copied from interface: StatefulEvaluator
Sets the current state of the evaluator. Only states that are created by createDefaultState() or getState() should be used for proper behavior.

Specified by:
setState in interface StatefulEvaluator<InputType,OutputType,StateType extends CloneableSerializable>
Parameters:
state - The new state for the evaluator.

resetState

public void resetState()
Description copied from interface: StatefulEvaluator
Resets the state of the evaluator to a default state.

Specified by:
resetState in interface StatefulEvaluator<InputType,OutputType,StateType extends CloneableSerializable>