hussam.math.operations.parser
Class SmartExpressionReader

java.lang.Object
extended by hussam.math.operations.parser.ExpressionReader
extended by hussam.math.operations.parser.SmartExpressionReader
All Implemented Interfaces:
OperationReader

public class SmartExpressionReader
extends ExpressionReader

This class is not in use by the package since there is a new Class called HussamExpressionReader which should be used instead. This class is Version 5 of all previously created readers. I need people to test this class with different expressions.

Since:
Version 2.7
Author:
Hussam Almulhim حسام الملحم
See Also:
Operation

Constructor Summary
SmartExpressionReader()
          Creates a new ExpressionReader.
SmartExpressionReader(OperationsParser parser)
          Creates a new ExpressionReader given this spicific parser.
SmartExpressionReader(OperationsParser parser, OperatorSource source)
          creates a new Expression Reader using a this OperatorSource.
SmartExpressionReader(OperatorSource source)
          Creates a new ExpressionReader given this spicific operator source.
 
Method Summary
 java.util.List<Operation>getExpressionOperations()
          This will return a list of all read operations.
 java.util.List<java.lang.String>getExpressionPartitioned()
          This will return a list of all symbols, numbers, words(variables or function names) and Baraks.
 OperatorSourcegetOperatorSource()
          gets the OperatorSource for all expressions read!
static voidmain(java.lang.String[] args)
          A test method.
 OperationreadOperation(java.lang.String operationString)
          Reads an expression
 
Methods inherited from class hussam.math.operations.parser.ExpressionReader
getInstance, getInstance, getInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmartExpressionReader

public SmartExpressionReader()
Creates a new ExpressionReader.


SmartExpressionReader

public SmartExpressionReader(OperationsParser parser)
Creates a new ExpressionReader given this spicific parser.

Parameters:
parser - the parser used to parse expressions.

SmartExpressionReader

public SmartExpressionReader(OperatorSource source)
Creates a new ExpressionReader given this spicific operator source.

Parameters:
source - the source used to evaluate expressions.

SmartExpressionReader

public SmartExpressionReader(OperationsParser parser,
OperatorSource source)
creates a new Expression Reader using a this OperatorSource.

Parameters:
parser - The parser used, can be null.
source - The source used to find resources. can be null.
Method Detail

getOperatorSource

public OperatorSource getOperatorSource()
Description copied from interface: OperationReader
gets the OperatorSource for all expressions read!

Returns:
the OperatorSource for all expressions read.

getExpressionOperations

public java.util.List<Operation> getExpressionOperations()
This will return a list of all read operations. For example: if you read 3+5, you will get a list containing:
[ConstantNumber, Operand, ConstantNumber]
you will notice that (,) commas are treated as null;

Returns:
a list of operations.

getExpressionPartitioned

public java.util.List<java.lang.String> getExpressionPartitioned()
This will return a list of all symbols, numbers, words(variables or function names) and Baraks. This list is collected from all expressions read.

Returns:
a list of String

readOperation

public Operation readOperation(java.lang.String operationString)
                        throws MathException
Description copied from interface: OperationReader
Reads an expression

Parameters:
operationString - the expression to be evaluated.
Returns:
the Operation from which you can call result() to get the result of the expression.
Throws:
MathException - Thrown if the expression has a problemSyntaxErrorException MathLogicException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
A test method.

Throws:
java.lang.Exception