|
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.builder.AbstractExpressionBuilder<E> dk.rode.thesis.builder.StandardExpressionBuilder<E>
E
- The type of value the evaluation of constructed
expressions produces.@Participant(value="ConcreteBuilder") public class StandardExpressionBuilder<E>
A standard expression builder construct various Expression
types having no bounds on the values produced by constructed expressions.
The constructed terminal
expressions
will all manipulate the same sequence
instance.
A standard expression builder uses a context
to
register all unique instances of constructed variables
and store all created constants
.
Implementation notes:
This builder does not use covariant return types to comply with the
canonical "Gang of Four" examples, but the TypedExpressionBuilder
class does use covariant return types.
ComparableExpressionBuilder
Field Summary |
---|
Fields inherited from class dk.rode.thesis.builder.AbstractExpressionBuilder |
---|
context, root, sequence |
Constructor Summary | |
---|---|
StandardExpressionBuilder(Context context,
Sequence<? extends E> sequence)
Constructor. |
|
StandardExpressionBuilder(Sequence<? extends E> sequence)
Constructor. |
|
StandardExpressionBuilder(StandardExpressionBuilder<E> builder)
Copy constructor. |
Method Summary | |
---|---|
Expression<Boolean> |
buildAndExpression(Expression<Boolean> first,
Expression<Boolean> second)
Builds a new short-circuit AND expression. |
Expression<E> |
buildAssignmentExpression(VariableExpression<E> variable,
Expression<? extends E> expression)
Builds a new ASSIGNMENT expression. |
Expression<E> |
buildBreakExpression(TypedExpression<E> expression)
Builds a new BREAK expression. |
Expression<E> |
buildConditionalExpression(Expression<Boolean> condition,
Expression<? extends E> first,
Expression<? extends E> second)
Builds a new CONDITIONAL expression. |
Expression<E> |
buildCurrentExpression()
Builds a new CURRENT expression. |
Expression<Boolean> |
buildEqualExpression(Expression<?> first,
Expression<?> second)
Builds a new EQUAL expression. |
FlowExpression<E> |
buildFlowExpression()
Builds a new uninitialised
FLOW expression. |
Expression<E> |
buildInitialisedFlowExpression(Expression<? extends E>... expressions)
Builds a new initialised
FLOW expression. |
Expression<E> |
buildNextExpression(Expression<? extends Number> count)
Builds a new NEXT expression. |
Expression<Boolean> |
buildNonShortCircuitAndExpression(Expression<Boolean> first,
Expression<Boolean> second)
Builds a new non short-circuit AND expression. |
Expression<Boolean> |
buildNonShortCircuitOrExpression(Expression<Boolean> first,
Expression<Boolean> second)
Builds a new non short-circuit OR expression. |
Expression<Boolean> |
buildNotExpression(Expression<Boolean> expression)
Builds a new NOT expression. |
Expression<Boolean> |
buildOrExpression(Expression<Boolean> first,
Expression<Boolean> second)
Builds a new short-circuit OR expression. |
Expression<E> |
buildResetExpression()
Builds a new RESET expression. |
Expression<Boolean> |
buildReverseExpression(Expression<Boolean> reverse)
Builds a new REVERSE expression. |
StandardExpressionBuilder<E> |
copy()
Returns a deep copy of this object. |
Methods inherited from class dk.rode.thesis.builder.AbstractExpressionBuilder |
---|
buildConstantExpression, buildExpression, buildVariableExpression, equals, getContext, getRootExpression, getSequence, hashCode, initialiseExpressions, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface dk.rode.thesis.builder.ExpressionBuilder |
---|
buildConstantExpression, buildExpression, buildVariableExpression, getRootExpression, getSequence |
Constructor Detail |
---|
public StandardExpressionBuilder(Context context, Sequence<? extends E> sequence)
The context
supplied as context
is
used to register created variables
and store constants
.
context
- The context to use; cannot be null.sequence
- The sequence to be manipulated by constructed
terminal expressions; cannot be null.
NullPointerException
- If either argument is null.AbstractExpressionBuilder.getContext()
public StandardExpressionBuilder(Sequence<? extends E> sequence)
A local context
is used to register created
variables
and store
constants
.
sequence
- The sequence to be manipulated by constructed
terminal expressions; cannot be null.
NullPointerException
- If sequence
is null.AbstractExpressionBuilder.getContext()
public StandardExpressionBuilder(StandardExpressionBuilder<E> builder)
The same context
and sequence
as used by builder
will be used by this builder.
The root expression from builder
is not copied.
Hence, this builder is ready to construct new expressions, and
return a unique root expression from AbstractExpressionBuilder.getRootExpression()
.
builder
- The builder to copy; cannot be null.
NullPointerException
- If builder
is null.Method Detail |
---|
public Expression<Boolean> buildAndExpression(Expression<Boolean> first, Expression<Boolean> second)
ExpressionBuilder
buildAndExpression
in interface ExpressionBuilder<E>
first
- The first expression operand; cannot be null.second
- The second expression operand; cannot be null.
public Expression<E> buildAssignmentExpression(VariableExpression<E> variable, Expression<? extends E> expression)
ExpressionBuilder
buildAssignmentExpression
in interface ExpressionBuilder<E>
variable
- The variable to be assigned the result of the
evaluation of expression
; cannot be null,
or be a constant
.expression
- The expression to deliver the variable value when
evaluated; cannot be null.
public Expression<E> buildBreakExpression(TypedExpression<E> expression)
ExpressionBuilder
buildBreakExpression
in interface ExpressionBuilder<E>
expression
- The target expression, if any; can be null.
public Expression<E> buildConditionalExpression(Expression<Boolean> condition, Expression<? extends E> first, Expression<? extends E> second)
ExpressionBuilder
buildConditionalExpression
in interface ExpressionBuilder<E>
condition
- The condition expression; cannot be null.first
- The first expression operand; cannot be null.second
- The second expression operand; cannot be null.
public Expression<E> buildCurrentExpression()
ExpressionBuilder
buildCurrentExpression
in interface ExpressionBuilder<E>
public Expression<Boolean> buildEqualExpression(Expression<?> first, Expression<?> second)
ExpressionBuilder
buildEqualExpression
in interface ExpressionBuilder<E>
first
- The first expression operand; cannot be null.second
- The second expression operand; cannot be null.
public FlowExpression<E> buildFlowExpression()
ExpressionBuilder
uninitialised
FLOW expression.
buildFlowExpression
in interface ExpressionBuilder<E>
public Expression<E> buildInitialisedFlowExpression(Expression<? extends E>... expressions) throws ExpressionException
ExpressionBuilder
initialised
FLOW expression.
buildInitialisedFlowExpression
in interface ExpressionBuilder<E>
expressions
- The expressions, in order, to be
associated with the returned expression;
cannot be null.
ExpressionException
- If the building fails.public Expression<E> buildNextExpression(Expression<? extends Number> count)
ExpressionBuilder
buildNextExpression
in interface ExpressionBuilder<E>
count
- The expression that will determine the number
of times next()
will be invoked on
the sequence
when the
constructed expression is evaluated.
public Expression<Boolean> buildNonShortCircuitAndExpression(Expression<Boolean> first, Expression<Boolean> second)
ExpressionBuilder
buildNonShortCircuitAndExpression
in interface ExpressionBuilder<E>
first
- The first expression operand; cannot be null.second
- The second expression operand; cannot be null.
public Expression<Boolean> buildNonShortCircuitOrExpression(Expression<Boolean> first, Expression<Boolean> second)
ExpressionBuilder
buildNonShortCircuitOrExpression
in interface ExpressionBuilder<E>
first
- The first expression operand; cannot be null.second
- The second expression operand; cannot be null.
public Expression<Boolean> buildNotExpression(Expression<Boolean> expression)
ExpressionBuilder
buildNotExpression
in interface ExpressionBuilder<E>
expression
- The expression operand; cannot be null.
public Expression<Boolean> buildOrExpression(Expression<Boolean> first, Expression<Boolean> second)
ExpressionBuilder
buildOrExpression
in interface ExpressionBuilder<E>
first
- The first expression operand; cannot be null.second
- The second expression operand; cannot be null.
public Expression<E> buildResetExpression()
ExpressionBuilder
buildResetExpression
in interface ExpressionBuilder<E>
public Expression<Boolean> buildReverseExpression(Expression<Boolean> reverse)
ExpressionBuilder
buildReverseExpression
in interface ExpressionBuilder<E>
reverse
- The expression that will determine if the
sequence
is tried
reversed when the constructed expression is
evaluated.
public StandardExpressionBuilder<E> copy()
Copyable
copy
in interface Copyable<ExpressionBuilder<E>>
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |