|
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.VariableExpression<E>
E - The type of value the evaluation of this expression
produces.@Participant(value="NonTerminalExpression") public class VariableExpression<E>
A variable expression represents an expression that
can be assigned a given value, which will be stored
in a given context supplied at evaluation
time.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface dk.rode.thesis.interpreter.Expression |
|---|
Expression.SymbolIdiom |
| Field Summary | |
|---|---|
protected boolean |
includeTypeInfo
True if the type of this variable will be included in the symbolic representation of it, false if not. |
String |
name
The unique name identifying this expression. |
private Class<E> |
type
The type identifying the value returned by this expression. |
| Constructor Summary | |
|---|---|
VariableExpression(Class<E> type,
String name)
Constructor. |
|
VariableExpression(Class<E> type,
String name,
boolean includeTypeInfo)
Constructor. |
|
VariableExpression(VariableExpression<E> expression)
Copy constructor. |
|
| Method Summary | |
|---|---|
String |
asSymbol(Context context)
Returns x, where x is the name of
this variable, or if type information is included,
Type{x}, where Type is the simple
name of the type. |
boolean |
contains(Expression<?> expression)
Returns true if this expression is or contains the expression supplied as expression, false if not. |
VariableExpression<E> |
copy()
Copies this expression. |
boolean |
equals(Object object)
Returns true if object is an instance of this
expression type and have the same name and type, false if not. |
E |
evaluate(Context context)
Evaluates this expression and returns the result. |
int |
hashCode()
Returns the hash code of this expression. |
String |
name()
The stand-alone symbol name for this expression. |
List<Expression<?>> |
operands()
Returns the expression operands used by this expression, in order. |
String |
toString()
Returns the string representation of this expression. |
Class<E> |
type()
Return the type of value the evaluation of this expression produces. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final boolean includeTypeInfo
Default false.
public final String name
Names are case-sensitive.
Never null, nor empty.
This name is not the same as name()!
Context.lookup(String)private final Class<E> type
Never null.
| Constructor Detail |
|---|
public VariableExpression(Class<E> type,
String name)
The symbolic representation of this variable will not
include type information regarding type.
type - The type of the value represented by this expression;
cannot be null.name - The name of this expression; cannot be null or
empty.
NullPointerException - If either argument is null.
IllegalArgumentException - If name is illegal.Context.lookup(String)
public VariableExpression(Class<E> type,
String name,
boolean includeTypeInfo)
The symbolic representation of this variable will
include type information regarding type
if includeTypeInfo is true, not if false.
type - The type of the value represented by this expression;
cannot be null.name - The name of this expression; cannot be null or
empty.includeTypeInfo - True to include type information in
the symbolic representation, false if not.
NullPointerException - If either type or name are null.
IllegalArgumentException - If name is illegal.Context.lookup(String)public VariableExpression(VariableExpression<E> expression)
expression - The expression to copy; cannot be null.
NullPointerException - If expression is null.| Method Detail |
|---|
public String asSymbol(Context context)
x, where x is the name of
this variable, or if type information is included,
Type{x}, where Type is the simple
name of the type.
asSymbol in interface Expression<E>context - The context to use; never null.
Expression.contains(Expression)public boolean contains(Expression<?> expression)
Expressionexpression, false if not. The test is performed using identity (==).
Unlike Expression.asSymbol(Context), querying for containment
cannot handle cyclic expression references!
contains in interface Expression<E>expression - The expression to test; cannot be null.
expression is this expression or
contained within this expression, false if not.Expression.asSymbol(Context),
Context.touch(Expression)public VariableExpression<E> copy()
Expression
Unlike Expression.asSymbol(Context), copying
cannot handle cyclic expression references!
copy in interface Expression<E>copy in interface TypedExpression<E>copy in interface Copyable<Expression<E>>public boolean equals(Object object)
object is an instance of this
expression type and have the same name and type, false if not.
equals in class Objectobject - The object to test; can be null.
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 the evaluation fails.public int hashCode()
hashCode in class Objectpublic String name()
Expression
name in interface Expression<E>variablepublic List<Expression<?>> operands()
ExpressionModifying the returned list will not affect this expression.
operands in interface Expression<E>public String toString()
Expression
Unlike Expression.asSymbol(Context), the string generation
cannot handle cyclic expression references!
toString in interface Expression<E>toString in class Objectpublic Class<E> type()
TypedExpression
type in interface TypedExpression<E>BreakExpression!
|
Gunni Rode / rode.dk | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||