Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.interpreter
Class AbstractExpression<E>

java.lang.Object
  extended by dk.rode.thesis.interpreter.AbstractExpression<E>
Type Parameters:
E - The type of value the evaluation of this expression produces.
All Implemented Interfaces:
Expression<E>, Copyable<Expression<E>>, StrictCopyable<Expression<E>>
Direct Known Subclasses:
AssignmentExpression, BinaryExpression, BreakExpression, FlowExpression, NotExpression, SequenceExpression

public abstract class AbstractExpression<E>
extends Object
implements Expression<E>

An abstract expression represents the basic traits of any expression.

An abstract expression is stateless.

Author:
Gunni Rode / rode.dk

Nested Class Summary
 
Nested classes/interfaces inherited from interface dk.rode.thesis.interpreter.Expression
Expression.SymbolIdiom
 
Constructor Summary
protected AbstractExpression()
          No-arg sub-class constructor.
 
Method Summary
 boolean contains(Expression<?> expression)
          Returns true if this expression is or contains the expression supplied as expression, false if not.
 boolean equals(Object object)
          Returns true if object is an instance of this expression type having the same name and all operands are equal using equals(Object), respectively, false otherwise.
 int hashCode()
          Returns the hash code of this expression.
 String toString()
          Returns the string representation of this expression.
 
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, copy, evaluate, name, operands
 

Constructor Detail

AbstractExpression

protected AbstractExpression()
No-arg sub-class constructor.

Method Detail

contains

public boolean contains(Expression<?> expression)
Description copied from interface: Expression
Returns true if this expression is or contains the expression supplied as expression, false if not.

The test is performed using identity (==).

Unlike Expression.asSymbol(Context), querying for containment cannot handle cyclic expression references!

Specified by:
contains in interface Expression<E>
Parameters:
expression - The expression to test; cannot be null.
Returns:
True if expression is this expression or contained within this expression, false if not.
See Also:
Expression.asSymbol(Context), Context.touch(Expression)

equals

public boolean equals(Object object)
Returns true if object is an instance of this expression type having the same name and all operands are equal using equals(Object), respectively, false otherwise.

Overrides:
equals in class Object
Parameters:
object - The object to test; can be null.
Returns:
True if equal, false if not.

hashCode

public int hashCode()
Returns the hash code of this expression.

Overrides:
hashCode in class Object
Returns:
The hash code; never null.

toString

public String toString()
Returns the string representation of this expression.

Specified by:
toString in interface Expression<E>
Overrides:
toString in class Object
Returns:
The string representation; never null.

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.