infix2postfix
Class StringPostfixEvaluator

java.lang.Object
  extended byinfix2postfix.PostfixEvaluator
      extended byinfix2postfix.StringPostfixEvaluator

public class StringPostfixEvaluator
extends PostfixEvaluator

This postfix evaluator can evaluate postfix in java.lang.String format.
The tokens in the expression are expected to be separated by POSTFIX_EXPRESSION_SEPARATOR specified in this evaluator. By default it is 'space' character but getPostfixExpressionSeparator() can be overridden to change it.

Author:
Maulin H. Vasavada

Field Summary
protected  java.lang.String POSTFIX_EXPRESSION_SEPARATOR
          Separator to tokenize the postfix expression
 
Fields inherited from class infix2postfix.PostfixEvaluator
inputStack, OPERAND, operandManager, OPERATOR, operators, outputStack
 
Constructor Summary
StringPostfixEvaluator(OperandManager operandManager)
          Constructor
 
Method Summary
protected  java.lang.String getPostfixExpressionSeparator()
          This method returns the separator for the postfix expression evaluated by this object.
protected  void populateInputStack(java.lang.Object postfixExpression)
          Populates the input stack needed for postfix evaluation.
protected  java.lang.String[] split(java.lang.String postfix)
          This method splits postfix expression into tokens and populate stack having symbols.
 
Methods inherited from class infix2postfix.PostfixEvaluator
addOperator, checkAndPopulateInputStack, evaluate, evaluate, evaluate, getOperators, removeOperator, setOperandManager, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POSTFIX_EXPRESSION_SEPARATOR

protected java.lang.String POSTFIX_EXPRESSION_SEPARATOR
Separator to tokenize the postfix expression

Constructor Detail

StringPostfixEvaluator

public StringPostfixEvaluator(OperandManager operandManager)
Constructor

Method Detail

populateInputStack

protected void populateInputStack(java.lang.Object postfixExpression)
                           throws InvalidExpressionFormatException
Populates the input stack needed for postfix evaluation. The input postfixExpression must be in java.lang.String format. More precisely postfixExpression must be instance of java.lang.String.

Specified by:
populateInputStack in class PostfixEvaluator
Throws:
InvalidExpressionFormatException - If the expression format is not in java.lang.String format.
See Also:
populateInputStack(Object), CollectionPostfixEvaluator.populateInputStack(Object)

getPostfixExpressionSeparator

protected java.lang.String getPostfixExpressionSeparator()
This method returns the separator for the postfix expression evaluated by this object.

Default separator is 'space'.

Returns:
java.lang.String Postfix separator for this object
See Also:
split(java.lang.String)

split

protected java.lang.String[] split(java.lang.String postfix)
This method splits postfix expression into tokens and populate stack having symbols. Default separator used for splitting is a 'space'.

It considers tab as a separator as well.

Parameters:
postfix - Postfix that is to be split into tokens
Returns:
java.lang.String[] Tokens as array of String
See Also:
#populateInputStack(java.lang.String)