|
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<E> dk.rode.thesis.interpreter.BinaryExpression<T,E>
T
- The type of value the evaluation of the expression
operands produces. Normally, but not required to
be, identical with E
.E
- The type of value the evaluation of this expression
produces.public abstract class BinaryExpression<T,E>
A binary expression represents any expression that involves (at least) two sub-expressions as operands.
The evaluation of a binary expression is not guaranteed to be commutative.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface dk.rode.thesis.interpreter.Expression |
---|
Expression.SymbolIdiom |
Field Summary | |
---|---|
protected Expression<? extends T> |
first
The first operand. |
protected Expression<? extends T> |
second
The second operand. |
Constructor Summary | |
---|---|
protected |
BinaryExpression(BinaryExpression<? extends T,E> expression)
Copy constructor. |
protected |
BinaryExpression(Expression<? extends T> first,
Expression<? extends T> second)
Constructor. |
Method Summary | |
---|---|
protected String |
asSymbol(Context context,
String separator)
Returns x separator y , where x is the symbolic
representation of the first expression operand and y
of the the second. |
protected StringBuilder |
asSymbol(Context context,
String separator,
StringBuilder sb)
Returns x separator y , where x is the symbolic
representation of the first expression operand and y
of the the second. |
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 |
---|
asSymbol, contains, copy, evaluate, name |
Field Detail |
---|
protected final Expression<? extends T> first
Never null.
protected final Expression<? extends T> second
Never null.
Constructor Detail |
---|
protected BinaryExpression(BinaryExpression<? extends T,E> expression)
expression
- The expression to copy; cannot be null.
NullPointerException
- If expression
is null.protected BinaryExpression(Expression<? extends T> first, Expression<? extends T> second)
first
- The first expression operand; cannot be null.second
- The second expression operand; cannot be null.
NullPointerException
- If either expression is null.Method Detail |
---|
protected String asSymbol(Context context, String separator) throws ExpressionException
x separator y
, where x
is the symbolic
representation of the first expression operand and y
of the the second.
context
- The context to use; cannot be null.separator
- The operand separator; cannot be null.
NullPointerException
- If either argument is null.
ExpressionException
- If the symbol cannot be generated.protected StringBuilder asSymbol(Context context, String separator, StringBuilder sb) throws ExpressionException
x separator y
, where x
is the symbolic
representation of the first expression operand and y
of the the second.
context
- The context to use; cannot be null.separator
- The operand separator; cannot be null.sb
- The string builder to use and return; cannot be null.
sb
; never null.
NullPointerException
- If either argument is null.
ExpressionException
- If the symbol cannot be generated.public List<Expression<?>> operands()
Expression
Modifying the returned list will not affect this expression.
operands
in interface Expression<E>
public String toString()
AbstractExpression
toString
in interface Expression<E>
toString
in class AbstractExpression<E>
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |