Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.interpreter
Class ResetExpression<E>

java.lang.Object
  extended by dk.rode.thesis.interpreter.AbstractExpression<E>
      extended by dk.rode.thesis.interpreter.SequenceExpression<E,E>
          extended by dk.rode.thesis.interpreter.ResetExpression<E>
Type Parameters:
E - The type of value the evaluation of this expression produces. The value corresponds to the (super-) type of values delivered by the manipulated sequence.
All Implemented Interfaces:
Expression<E>, TerminalExpression<E>, Copyable<Expression<E>>, StrictCopyable<Expression<E>>

@Participant(value="TerminalExpression")
public class ResetExpression<E>
extends SequenceExpression<E,E>

A reset expression will invoke reset() on a given sequence when evaluated.

Author:
Gunni Rode / rode.dk
See Also:
CurrentExpression, NextExpression, SetExpression, ReverseExpression

Nested Class Summary
 
Nested classes/interfaces inherited from interface dk.rode.thesis.interpreter.Expression
Expression.SymbolIdiom
 
Field Summary
 
Fields inherited from class dk.rode.thesis.interpreter.SequenceExpression
includeHashCode, sequence
 
Constructor Summary
ResetExpression(ResetExpression<E> expression)
          Copy constructor.
ResetExpression(Sequence<? extends E> sequence)
          Constructor.
ResetExpression(Sequence<? extends E> sequence, boolean includeHashCode)
          Constructor.
 
Method Summary
 ResetExpression<E> copy()
          Returns a deep copy of this object.
 E evaluate(Context context)
          Evaluates this expression and returns the result.
 String name()
          The stand-alone symbol name for this expression.
 
Methods inherited from class dk.rode.thesis.interpreter.SequenceExpression
asSymbol, equals, hashCode, operands, toString
 
Methods inherited from class dk.rode.thesis.interpreter.AbstractExpression
contains
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface dk.rode.thesis.interpreter.Expression
contains
 

Constructor Detail

ResetExpression

public ResetExpression(ResetExpression<E> expression)
Copy constructor.

The actual sequence manipulated by expression is not copied, but used as is.

Parameters:
expression - The expression to copy; cannot be null.
Throws:
NullPointerException - If expression is null.

ResetExpression

public ResetExpression(Sequence<? extends E> sequence)
Constructor.

The identity hash code of sequence is not included in the symbolic representation of this expression.

Parameters:
sequence - The sequence to manipulate by this expression; cannot be null.
Throws:
NullPointerException - If sequence is null.

ResetExpression

public ResetExpression(Sequence<? extends E> sequence,
                       boolean includeHashCode)
Constructor.

The identity hash code of sequence is included in the symbolic representation of this expression if includeHashCode is true.

Parameters:
sequence - The sequence to manipulate by this expression; cannot be null.
includeHashCode - True to include the identity hash code of sequence in the symbolic representation, false not to.
Throws:
NullPointerException - If sequence is null.
Method Detail

copy

public ResetExpression<E> copy()
Description copied from interface: Copyable
Returns a deep copy of this object.

Returns:
The copy; never null.

evaluate

public E evaluate(Context context)
           throws ExpressionException
Description copied from interface: Expression
Evaluates this expression and returns the result.

There is no guarantee that the evaluation of this expression will terminate!

Parameters:
context - The context to use; cannot be null.
Returns:
The current value of the manipulated sequence after Sequence.reset() has been invoked; never null.
Throws:
ExpressionException - If the evaluation fails.

name

public final String name()
Description copied from interface: Expression
The stand-alone symbol name for this expression.

Returns:
reset

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.