|
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.SequenceExpression<E,E> dk.rode.thesis.interpreter.NextExpression<E>
E
- The type of value the evaluation of this expression
produces. The value corresponds to the (super-) type of
values delivered by the manipulated sequence
.@Participant(value="TerminalExpression") public class NextExpression<E>
A next expression will invoke next()
a number of times on a given sequence
when
evaluated.
The number of times to invoke next()
can be
constant
,
but it can also be represented by any
expression of the type Expression<? extends Number>
,
where the actual count is the absolute integer value of the
result of the expression evaluation (if zero, a count of
one is used).
CurrentExpression
,
SetExpression
,
ResetExpression
,
ReverseExpression
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface dk.rode.thesis.interpreter.Expression |
---|
Expression.SymbolIdiom |
Field Summary | |
---|---|
private Expression<? extends Number> |
count
The number of times Sequence.next() is invoked
for the manipulated sequence . |
Fields inherited from class dk.rode.thesis.interpreter.SequenceExpression |
---|
includeHashCode, sequence |
Constructor Summary | |
---|---|
NextExpression(NextExpression<E> expression)
Copy constructor. |
|
NextExpression(Sequence<? extends E> sequence)
Constructor, which will call Sequence.next() a single
time on sequence when this expression is evaluated. |
|
NextExpression(Sequence<? extends E> sequence,
boolean includeHashCode)
Constructor, which will call Sequence.next() a single
time on sequence when this expression is evaluated. |
|
NextExpression(Sequence<? extends E> sequence,
Expression<? extends Number> count)
Constructor, which will call Sequence.next() the
number of times corresponding to the absolute value of
the result of evaluating count when this
expression is evaluated. |
|
NextExpression(Sequence<? extends E> sequence,
Expression<? extends Number> count,
boolean includeHashCode)
Constructor, which will call Sequence.next() the
number of times corresponding to the absolute value of
the result of evaluating count when this
expression is evaluated. |
|
NextExpression(Sequence<? extends E> sequence,
int count)
Constructor, which will call Sequence.next() count
time(s) on sequence when this expression is evaluated. |
|
NextExpression(Sequence<? extends E> sequence,
int count,
boolean includeHashCode)
Constructor, which will call Sequence.next() count
time(s) on sequence when this expression is evaluated. |
Method Summary | |
---|---|
String |
asSymbol(Context context)
Returns next[x] , where x is the symbolic
representation of the expression that will determine the
number of times to invoke next() , or next#123[x] ,
where 123 is the identity hash code of the manipulated
sequence. |
NextExpression<E> |
copy()
Returns a deep copy of this object. |
E |
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.SequenceExpression |
---|
equals, hashCode |
Methods inherited from class dk.rode.thesis.interpreter.AbstractExpression |
---|
contains |
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<? extends Number> count
Sequence.next()
is invoked
for the manipulated sequence
. The absolute integer value is used. If zero, a count of one is used.
Constructor Detail |
---|
public NextExpression(NextExpression<E> expression)
The actual sequence
manipulated by
expression
is not copied, but used
as is.
expression
- The expression to copy; cannot be null.
NullPointerException
- If expression
is null.public NextExpression(Sequence<? extends E> sequence)
Sequence.next()
a single
time on sequence
when this expression is evaluated.
The identity hash code of sequence
is not included
in the symbolic
representation of
this expression.
sequence
- The sequence to manipulate by this expression;
cannot be null.
NullPointerException
- If sequence
is null.public NextExpression(Sequence<? extends E> sequence, boolean includeHashCode)
Sequence.next()
a single
time on sequence
when this expression is evaluated.
The identity hash code of sequence
is included
in the symbolic
representation of
this expression if includeHashCode
is true.
sequence
- The sequence to manipulate by this expression;
cannot be null.includeHashCode
- True to include the identity hash code
of sequence
in the symbolic
representation, false not to.
NullPointerException
- If sequence
is null.public NextExpression(Sequence<? extends E> sequence, Expression<? extends Number> count)
Sequence.next()
the
number of times corresponding to the absolute value of
the result of evaluating count
when this
expression is evaluated.
The identity hash code of sequence
is not included
in the symbolic
representation of
this expression.
sequence
- The sequence to manipulate by this expression;
cannot be null.count
- The expression that will determine the number of
times next()
will be invoked on sequence
when this expression is evaluated.
NullPointerException
- If either argument is null.public NextExpression(Sequence<? extends E> sequence, Expression<? extends Number> count, boolean includeHashCode)
Sequence.next()
the
number of times corresponding to the absolute value of
the result of evaluating count
when this
expression is evaluated.
The identity hash code of sequence
is included
in the symbolic
representation of
this expression if includeHashCode
is true.
sequence
- The sequence to manipulate by this expression;
cannot be null.count
- The expression that will determine the number of
times next()
will be invoked on sequence
when this expression is evaluated.includeHashCode
- True to include the identity hash code
of sequence
in the symbolic
representation, false not to.
NullPointerException
- If sequence
or count
are null.public NextExpression(Sequence<? extends E> sequence, int count)
Sequence.next()
count
time(s) on sequence
when this expression is evaluated. The absolute value of count is used.
The identity hash code of sequence
is not included
in the symbolic
representation of
this expression.
sequence
- The sequence to manipulate by this expression;
cannot be null.count
- The number of times to call next()
on
sequence
when this expression is
evaluated.
NullPointerException
- If sequence
is null.public NextExpression(Sequence<? extends E> sequence, int count, boolean includeHashCode)
Sequence.next()
count
time(s) on sequence
when this expression is evaluated. The absolute value of count is used.
The identity hash code of sequence
is included
in the symbolic
representation of
this expression if includeHashCode
is true.
sequence
- The sequence to manipulate by this expression;
cannot be null.count
- The number of times to call next()
on
sequence
when this expression is
evaluated.includeHashCode
- True to include the identity hash code
of sequence
in the symbolic
representation, false not to.
NullPointerException
- If sequence
is null.Method Detail |
---|
public String asSymbol(Context context) throws ExpressionException
next[x]
, where x
is the symbolic
representation of the expression that will determine the
number of times to invoke next()
, or next#123[x]
,
where 123
is the identity hash code of the manipulated
sequence.
asSymbol
in interface Expression<E>
asSymbol
in class SequenceExpression<E,E>
context
- The context to use; never null.
ExpressionException
- If the symbol cannot be generated.Expression.contains(Expression)
public NextExpression<E> copy()
Copyable
public E evaluate(Context context) throws ExpressionException
Expression
There is no guarantee that the evaluation of this expression will terminate!
context
- The context to use; cannot be null.
Sequence.next()
; never null.
ExpressionException
- If the evaluation fails.public final String name()
Expression
next
public List<Expression<?>> operands()
Expression
Modifying the returned list will not affect this expression.
operands
in interface Expression<E>
operands
in class SequenceExpression<E,E>
public String toString()
AbstractExpression
toString
in interface Expression<E>
toString
in class SequenceExpression<E,E>
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |