net.christopherschultz.evaluator
Class IdentifierExpression

java.lang.Object
  extended by net.christopherschultz.evaluator.Expression
      extended by net.christopherschultz.evaluator.ConstantExpression
          extended by net.christopherschultz.evaluator.IdentifierExpression

public class IdentifierExpression
extends ConstantExpression

An Expression which represents an identifier.

Version:
$Revision: 1.5 $ $Date: 2008-06-20 22:58:48 $
Author:
Chris Schultz

Constructor Summary
IdentifierExpression(String identifier)
          Creates a new IdentifierExpression with the given identifier.
 
Method Summary
 void acceptVisitor(ExpressionVisitor visitor)
          Accepts an ExpressionVisitor.
 Object evaluate(EvaluationContext ec)
          Evaluates this Expression by returning its constant value.
 String getIdentifier()
          Gets the symbol used by this identifier.
 String getSymbol()
          Gets the symbol used by this identifier.
 String toString()
          Returns a String representation of this Expression.
 
Methods inherited from class net.christopherschultz.evaluator.ConstantExpression
equals, getSubExpressions, getValue, hashCode
 
Methods inherited from class net.christopherschultz.evaluator.Expression
getParent, setParent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IdentifierExpression

public IdentifierExpression(String identifier)
Creates a new IdentifierExpression with the given identifier.

Parameters:
identifier - The identifier for this IdentifierExpressions.
Throws:
IllegalArgumentException - If the identifier is null or empty.
Method Detail

getSymbol

public String getSymbol()
Gets the symbol used by this identifier.


getIdentifier

public String getIdentifier()
Gets the symbol used by this identifier.


acceptVisitor

public void acceptVisitor(ExpressionVisitor visitor)
Description copied from class: Expression
Accepts an ExpressionVisitor.

Overrides:
acceptVisitor in class ConstantExpression

evaluate

public Object evaluate(EvaluationContext ec)
                throws EvaluationException
Description copied from class: ConstantExpression
Evaluates this Expression by returning its constant value.

Overrides:
evaluate in class ConstantExpression
Parameters:
ec - The EvaluationContext in which this expression should be evaluated.
Returns:
The value of this constant Expression.
Throws:
EvaluationException - If there is an error evaluating this Expression.

toString

public String toString()
Description copied from class: ConstantExpression
Returns a String representation of this Expression.

Overrides:
toString in class ConstantExpression
Returns:
A String representation of this Expression.