|
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.Interpreter<T>
T
- The type of value the evaluated expressions evaluate to.public class Interpreter<T>
An interpreter can interpret expressions
.
Only expressions evaluating to values of a given type can be used.
The type is supplied at construction
time.
An interpreter supports break
expressions
storing typed
expressions with a matching
(sub-) type
.
Context
Field Summary | |
---|---|
private Class<T> |
type
The super-type of expression values handled by this interpreter. |
Constructor Summary | |
---|---|
Interpreter(Class<T> type)
Constructor. |
|
Interpreter(TypeLiteral<T> type)
Constructor. |
Method Summary | ||
---|---|---|
|
interpret(Context context,
Expression<E> expression)
Interpret the expression syntax tree having
the root supplied as expression , and returns the
result. |
|
|
interpret(Context context,
Expression<E> expression,
Class<? super E> type)
Interpret the expression syntax tree having
the root supplied as expression , and returns the
result. |
|
String |
toString()
Returns the string representation of this interpreter. |
|
Class<T> |
type()
Return the super-type of expression values handled by this interpreter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final Class<T> type
Never null.
Constructor Detail |
---|
public Interpreter(Class<T> type)
type
- The super-type of expression values handled by this
interpreter.
NullPointerException
- If type
is null.public Interpreter(TypeLiteral<T> type)
type
- The super-type of expression values handled by this
interpreter.
NullPointerException
- If type
is null.Method Detail |
---|
public <E extends T> T interpret(Context context, Expression<E> expression) throws ExpressionException
expression
syntax tree having
the root supplied as expression
, and returns the
result. The is no guarantee that the evaluation will ever complete!
E
- The type of value the evaluation of expression
produces.context
- The variable context to use; cannot be null.expression
- The root expression; cannot be null.
exited
prematurely.
NullPointerException
- If either argument is null.
ExpressionException
- If the evaluation fails.public <E extends T> E interpret(Context context, Expression<E> expression, Class<? super E> type) throws ExpressionException
expression
syntax tree having
the root supplied as expression
, and returns the
result. The is no guarantee that the evaluation will ever complete!
E
- The type of value the evaluation of expression
produces.context
- The variable context to use; cannot be null.expression
- The root expression; cannot be null.type
- The type of value the evaluation of expression
produces; cannot be null.
exited
prematurely.
NullPointerException
- If either argument is null.
ExpressionException
- If the evaluation fails.public String toString()
toString
in class Object
public Class<T> type()
TypedExpression.type()
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |