|
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.BinaryExpression<Boolean,Boolean>
dk.rode.thesis.interpreter.OrExpression
@Participant(value="NonTerminalExpression") public class OrExpression
A logical or expression for two expressions evaluating
to a Boolean value.
The logical OR operation may or may not be short-circuit,
which is determined at construction time.
AndExpression,
NotExpression,
CompareExpression| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface dk.rode.thesis.interpreter.Expression |
|---|
Expression.SymbolIdiom |
| Field Summary | |
|---|---|
boolean |
shortCircuit
True if a short-circuit logical OR operation is used, i.e. |
| Fields inherited from class dk.rode.thesis.interpreter.BinaryExpression |
|---|
first, second |
| Constructor Summary | |
|---|---|
OrExpression(boolean shortCircuit,
Expression<Boolean> first,
Expression<Boolean> second)
Constructor. |
|
OrExpression(Expression<Boolean> first,
Expression<Boolean> second)
Constructor. |
|
OrExpression(OrExpression expression)
Copy constructor. |
|
| Method Summary | |
|---|---|
String |
asSymbol(Context context)
Returns (x || y) if short-circuit, or (x | y),
where x is the symbolic representation of the
first expression operand and y of the second. |
OrExpression |
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. |
| Methods inherited from class dk.rode.thesis.interpreter.BinaryExpression |
|---|
asSymbol, asSymbol, operands, toString |
| 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, operands, toString |
| Field Detail |
|---|
public final boolean shortCircuit
||, false if not, i.e. |.
| Constructor Detail |
|---|
public OrExpression(boolean shortCircuit,
Expression<Boolean> first,
Expression<Boolean> second)
The logical OR operation performed is short-circuit, i.e.
||, if shortCircuit is true, otherwise not,
i.e |.
shortCircuit - True for short-circuit (||).first - The first expression operand; cannot be null.second - The second expression operand; cannot be null.
NullPointerException - If either expression is null.
public OrExpression(Expression<Boolean> first,
Expression<Boolean> second)
The logical OR operation performed is short-circuit,
i.e. ||.
first - The first expression operand; cannot be null.second - The second expression operand; cannot be null.
NullPointerException - If either expression is null.public OrExpression(OrExpression expression)
expression - The expression to copy; cannot be null.
NullPointerException - If expression is null.| Method Detail |
|---|
public String asSymbol(Context context)
throws ExpressionException
(x || y) if short-circuit, or (x | y),
where x is the symbolic representation of the
first expression operand and y of the second.
asSymbol in interface Expression<Boolean>context - The context to use; never null.
ExpressionException - If the symbol cannot be generated.Expression.contains(Expression)public OrExpression 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
ExpressionThere 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>or
|
Gunni Rode / rode.dk | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||