|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectdk.rode.thesis.interpreter.AbstractExpression<E>
dk.rode.thesis.interpreter.FlowExpression<E>
E - The type of value the evaluation of this expression
produces.@Participant(value="NonTerminalExpression") public class FlowExpression<E>
A flow expression represents one or more expressions to be evaluated in order, one at a time. The result of the evaluation is the result of the last expression evaluated.
Expressions to be evaluated by a flow expression must explicitly be
added. Once the last expression has been
added, the flow expression must be initialised
before evaluation, or the evaluation will fail. Once initialised,
additional expressions cannot be added.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface dk.rode.thesis.interpreter.Expression |
|---|
Expression.SymbolIdiom |
| Field Summary | |
|---|---|
private List<Expression<? extends E>> |
expressions
The expressions to evaluate, in order. |
private boolean |
initialised
True if this expression has been initialised, false if not. |
| Constructor Summary | |
|---|---|
FlowExpression()
No-arg constructor. |
|
FlowExpression(FlowExpression<E> expression)
Copy constructor. |
|
| Method Summary | |
|---|---|
FlowExpression<E> |
add(Expression<? extends E> expression)
Adds the expression supplied as expression to
this flow expression. |
String |
asSymbol(Context context)
Returns x, y, z, .., where x, y,
z, .., are the symbol representations of the
contained expressions. |
FlowExpression<E> |
copy()
Copies this expression. |
E |
evaluate(Context context)
Evaluates this expression and returns the result. |
FlowExpression<E> |
initialise()
Initialises this expression before evaluation. |
boolean |
isInitialised()
Returns true if this expression has been initialised, and hence ready to be evaluated, false if not. |
String |
name()
The stand-alone symbol name for this expression. |
List<Expression<?>> |
operands()
Returns the expression operands used by this expression, in order. |
| Methods inherited from class dk.rode.thesis.interpreter.AbstractExpression |
|---|
contains, equals, hashCode, toString |
| 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, toString |
| Field Detail |
|---|
private final List<Expression<? extends E>> expressions
Never null, and never empty.
private boolean initialised
| Constructor Detail |
|---|
public FlowExpression()
Expressions to be evaluated must be
added before evaluation or the
evaluation of this expression will fail.
public FlowExpression(FlowExpression<E> expression)
expression - The expression to copy; cannot be null.
NullPointerException - If expression is null.| Method Detail |
|---|
public FlowExpression<E> add(Expression<? extends E> expression)
throws ExpressionException
expression to
this flow expression. The same expression can be added several times.
After the last expression has been added, this flow
expression must be initialised
before it can be evaluated.
expression - The expression to add; cannot be null.
NullPointerException - If expression is null.
ExpressionException - If this flow expression has already
been initialised.
public String asSymbol(Context context)
throws ExpressionException
x, y, z, .., where x, y,
z, .., are the symbol representations of the
contained expressions.
asSymbol in interface Expression<E>context - The context to use; never null.
ExpressionException - If the symbol cannot be generated.Expression.contains(Expression)public FlowExpression<E> copy()
Expression
Unlike Expression.asSymbol(Context), copying
cannot handle cyclic expression references!
copy in interface Expression<E>copy in interface InitialisableExpression<E>copy in interface Copyable<Expression<E>>
public E evaluate(Context context)
throws ExpressionException
ExpressionThere is no guarantee that the evaluation of this expression will terminate!
evaluate in interface Expression<E>context - The context to use; cannot be null.
ExpressionException - If this expression has not been
initialised, or if the evaluation fails.
public FlowExpression<E> initialise()
throws ExpressionException
InitialisableExpressionContained initialisable expressions are not initialised!
initialise in interface InitialisableExpression<E>ExpressionException - If this expression has already
been initialised.public boolean isInitialised()
InitialisableExpressioninitialised, and hence ready to be evaluated, false if not. If this expression has not been initialised when evaluated, the evaluation will throw an exception.
isInitialised in interface InitialisableExpression<E>public final String name()
Expression
name in interface Expression<E>flowpublic List<Expression<?>> operands()
ExpressionModifying the returned list will not affect this expression.
operands in interface Expression<E>
|
Gunni Rode / rode.dk | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||