|
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.Object dk.rode.thesis.interpreter.AbstractExpression<Boolean> dk.rode.thesis.interpreter.NotExpression
public class NotExpression
A not expression (!) for any expression evaluating
to a Boolean
value.
This class does not declare a copy constructor, but can
still be copied
.
AndExpression
,
OrExpression
,
CompareExpression
,
EqualExpression
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface dk.rode.thesis.interpreter.Expression |
---|
Expression.SymbolIdiom |
Field Summary | |
---|---|
private Expression<Boolean> |
expression
The expression to evaluated and the result negated. |
Constructor Summary | |
---|---|
NotExpression(Expression<Boolean> expression)
Constructor. |
Method Summary | |
---|---|
String |
asSymbol(Context context)
Returns {@code (! |
NotExpression |
copy()
Copies this expression. |
Boolean |
evaluate(Context context)
Evaluates this expression and returns the result. |
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. |
Methods inherited from class dk.rode.thesis.interpreter.AbstractExpression |
---|
contains, equals, hashCode |
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 |
Field Detail |
---|
private final Expression<Boolean> expression
Never null.
Constructor Detail |
---|
public NotExpression(Expression<Boolean> expression)
expression
- The expression to use; cannot be null and
is not copied.
NullPointerException
- If expression
is null.Method Detail |
---|
public String asSymbol(Context context) throws ExpressionException
(!x)
, where x
is the symbol
representation of the expression negated by this
expression.
asSymbol
in interface Expression<Boolean>
context
- The context to use; never null.
ExpressionException
- If the symbol cannot be generated.Expression.contains(Expression)
public NotExpression copy()
Expression
Unlike Expression.asSymbol(Context)
, copying
cannot handle cyclic expression references!
copy
in interface Expression<Boolean>
copy
in interface Copyable<Expression<Boolean>>
public Boolean evaluate(Context context) throws ExpressionException
Expression
There is no guarantee that the evaluation of this expression will terminate!
evaluate
in interface Expression<Boolean>
context
- The context to use; cannot be null.
ExpressionException
- If the evaluation fails.public final String name()
Expression
name
in interface Expression<Boolean>
not
public List<Expression<?>> operands()
Expression
Modifying the returned list will not affect this expression.
operands
in interface Expression<Boolean>
public String toString()
AbstractExpression
toString
in interface Expression<Boolean>
toString
in class AbstractExpression<Boolean>
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |