|
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<E,Boolean>
dk.rode.thesis.interpreter.CompareExpression<E>
E - The type of value the evaluation of this expression
produces.public class CompareExpression<E extends Comparable<? super E>>
A compare expression can compare two expressions
evaluating to the same Comparable type
as smaller than, smaller than or equal,
equal, not equal, greater than, or
equal or greater than.
EqualExpression,
AndExpression,
OrExpression,
NotExpression| Nested Class Summary | |
|---|---|
static class |
CompareExpression.Comparison
The comparison type to be performed by a compare expression. |
| Nested classes/interfaces inherited from interface dk.rode.thesis.interpreter.Expression |
|---|
Expression.SymbolIdiom |
| Field Summary | |
|---|---|
CompareExpression.Comparison |
comparison
The type of comparison performed by this expression. |
| Fields inherited from class dk.rode.thesis.interpreter.BinaryExpression |
|---|
first, second |
| Constructor Summary | |
|---|---|
CompareExpression(CompareExpression.Comparison comparison,
Expression<? extends E> first,
Class<E> type,
E value)
Constructor. |
|
CompareExpression(CompareExpression.Comparison comparison,
Expression<? extends E> first,
Class<E> type,
String name)
Constructor. |
|
CompareExpression(CompareExpression.Comparison comparison,
Expression<? extends E> first,
Expression<? extends E> second)
Constructor. |
|
CompareExpression(CompareExpression<E> expression)
Copy constructor. |
|
| Method Summary | |
|---|---|
String |
asSymbol(Context context)
Returns x operator y, where x is the symbolic
representation of the first expression operand, y
of the the second, and operator is the operator used
for the comparison. |
CompareExpression<E> |
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. |
String |
toString()
Returns the string representation of this expression. |
| Methods inherited from class dk.rode.thesis.interpreter.BinaryExpression |
|---|
asSymbol, asSymbol, operands |
| 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 |
| Field Detail |
|---|
public final CompareExpression.Comparison comparison
Never null.
| Constructor Detail |
|---|
public CompareExpression(CompareExpression.Comparison comparison,
Expression<? extends E> first,
Class<E> type,
E value)
The second expression used is a constant
expression created based on type and value.
comparison - The comparison type; cannot be null.first - The first expression operand; cannot be null.type - The type of the constant expression to use
as the second expression operand; cannot be null.value - The value of the constant expression to use
as the second expression operand; cannot be null.
NullPointerException - If either argument is null.
public CompareExpression(CompareExpression.Comparison comparison,
Expression<? extends E> first,
Class<E> type,
String name)
The second expression used is a variable
expression created based on type and name.
comparison - The comparison type; cannot be null.first - The first expression operand; cannot be null.type - The type of the variable expression to use
as the second expression operand; cannot be null.name - The name of the variable expression to use
as the second expression operand; cannot be null.
NullPointerException - If either argument is null.
public CompareExpression(CompareExpression.Comparison comparison,
Expression<? extends E> first,
Expression<? extends E> second)
comparison - The comparison type; cannot be null.first - The first expression operand; cannot be null.second - The second expression operand; cannot be null.
NullPointerException - If either argument is null.public CompareExpression(CompareExpression<E> expression)
expression - The expression to copy; cannot be null.
NullPointerException - If expression is null.| Method Detail |
|---|
public String asSymbol(Context context)
throws ExpressionException
x operator y, where x is the symbolic
representation of the first expression operand, y
of the the second, and operator is the operator used
for the comparison.
asSymbol in interface Expression<Boolean>context - The context to use; never null.
ExpressionException - If the symbol cannot be generated.Expression.contains(Expression)public CompareExpression<E> 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>comparepublic String toString()
AbstractExpression
toString in interface Expression<Boolean>toString in class BinaryExpression<E extends Comparable<? super E>,Boolean>
|
Gunni Rode / rode.dk | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||