Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
StringToMathExpression
public class StringToMathExpression
extends java.lang.Object
Field Summary | |
private int | |
private double | |
private int | |
private int | |
private int | |
private boolean | |
private boolean | |
private int | |
private boolean | |
private Vector | |
private int | |
private Vector | |
private boolean | |
private boolean |
Constructor Summary | |
|
Method Summary | |
void |
|
private int |
|
private String |
|
Vector |
|
private double |
|
private int |
|
private String |
|
private int |
|
private String |
|
private boolean |
|
private boolean |
|
private boolean |
|
private boolean |
|
private boolean |
|
private boolean |
|
private boolean |
|
private boolean |
|
private boolean |
|
private boolean |
|
private boolean |
|
private boolean |
|
private boolean |
|
private boolean |
|
private boolean |
|
private boolean |
|
void |
|
private void |
|
private void |
|
private final int COUNTER_STOP
private double algebraicSign
private int countedLeftParenthesis
private int countedRightParenthesis
private int counter
private boolean diracEmpty
private boolean eEmpty
private int eFunctionComplexLength
private boolean iError
private Vector infix
private int numberLength
private Vector sumData
private boolean sumEmpty
private boolean trigonometricFunctionEmpty
public StringToMathExpression()
StringToMathExpression Constructor initializes all Check Variables to proper state.
public void convertStringToMathExpression(String mathExpression) throws IllegalMathExpressionException
Converts an String Term into an valid Math Expression. The MathExpression is stored in an Vector. Every Expression separated as an singel Vector entry. TheString
will be converted to lower case and all whitespaces will be deleted. This should provide more flexibility for the givenString
.
- Parameters:
mathExpression
- theString
wich will be converted into an valid MathExpression.
private int getEFunctionComplexLength()
Gives you the String.length() of the last extracted eFunction.
- Returns:
- an
int
with the String.length() of the last extracted eFunction.
private String getFunctionTherm(String mathExpression)
Extracts the Therm which has to be calculated of the given Therm.
- Returns:
- an
String
with the extracted FunctionTherm.
public Vector getInfix()
Returns the infixVector
.
- Returns:
- the infix
Vector
.
private double getNumber(String numberToParse)
Extracts the number from the givenString
. It also accepts negative numbers.
- Parameters:
numberToParse
- theString
from wich the number will be extracted.
- Returns:
- an
double
with the extracted Number.
private int getNumberLength()
Gives you the Stringh.length() of the last extracted number.
- Returns:
- an
int
with the String.length() of the last extracted Number.
private String getOperator(String operatorToParse)
Extracts the operator from the givenString
.
- Parameters:
operatorToParse
- theString
from wich the operator will be extracted.
- Returns:
- an
String
with the extracted operator.
private int getSumLength()
Gives you the String.length() of the last extracted sum.
- Returns:
- an
int
with the String.length() of the last extracted sum.
private String getTrigonometricFunction(String trigonometricFunctionToParse)
Extracts the trigonometric function from the givenString
.
- Parameters:
trigonometricFunctionToParse
- theString
from wich the trigonometric function will be extracted.
- Returns:
- an
String
with the extracted trigonometric function.
private boolean isDigit(char character)
Tests if the givenchar
is a digit.
- Parameters:
- Returns:
- an
boolean
specifying the test result.
- See Also:
isNumber(String mathExpression)
private boolean isDirac(String mathExpression)
Tests if the givenString
contains a dirac function at the beginning.
- Parameters:
mathExpression
- theString
to test.
- Returns:
- an
boolean
specifying the test result.
private boolean isEFunction(String mathExpression)
Tests if the givenString
contains a e function at the beginning.
- Parameters:
mathExpression
- theString
to test.
- Returns:
- an
boolean
specifying the test result.
private boolean isEFunctionComplex(String mathExpression)
Tests if the givenString
contains a Complex e function at the beginning.
- Parameters:
mathExpression
- theString
to test.
- Returns:
- an
boolean
specifying the test result.
private boolean isImaginary(String mathExpression)
Tests if the givenString
is an Imaginary Value.
- Parameters:
mathExpression
- theString
to test.
- Returns:
- an
boolean
specifying the test result.
private boolean isLeftParenthesis(String mathExpression)
Tests if the givenString
contains an left parenthesis at the beginning.
- Parameters:
mathExpression
- theString
to test.
- Returns:
- an
boolean
specifying the test result.
- See Also:
isLeftParenthesis(char character)
private boolean isLeftParenthesis(char character)
Tests if the givenchar
is an left parenthesis.
- Parameters:
character
- thechar
to test.
- Returns:
- an
boolean
specifying the test result.
- See Also:
isLeftParenthesis(String mathExpression)
private boolean isNumber(String mathExpression)
Tests if the givenString
contains a number at the beginning. It also accepts negative numbers.
- Parameters:
mathExpression
- theString
to test.
- Returns:
- an
boolean
specifying the test result.
- See Also:
isDigit(char character)
private boolean isOperator(char character)
Tests if the givenchar
is an math operator (+,-,*,/,^).
- Parameters:
character
- thechar
to test.
- Returns:
- an
boolean
specifying the test result.
private boolean isPi(String mathExpression)
Tests if the givenString
contains a pi function at the beginning.
- Parameters:
mathExpression
- theString
to test.
- Returns:
- an
boolean
specifying the test result.
private boolean isPoint(char character)
Tests if the givenchar
is an point.
- Parameters:
character
- thechar
to test.
- Returns:
- an
boolean
specifying the test result.
private boolean isRightParenthesis(String mathExpression)
Tests if the givenString
contains an right parenthesis at the beginning.
- Parameters:
mathExpression
- theString
to test.
- Returns:
- an
boolean
specifying the test result.
- See Also:
isLeftParenthesis(char character)
private boolean isRightParenthesis(char character)
Tests if the givenchar
is an right parenthesis.
- Parameters:
character
- thechar
to test.
- Returns:
- an
boolean
specifying the test result.
- See Also:
isRightParenthesis(String mathExpression)
private boolean isSum(String mathExpression)
Tests if the givenString
contains a sum function at the beginning.
- Parameters:
mathExpression
- theString
to test.
- Returns:
- an
boolean
specifying the test result.
private boolean isTrigonometricFunction(String mathExpression)
Tests if the givenString
contains a trigonometric function (sin,cos,tan) at the beginning.
- Parameters:
mathExpression
- theString
to test.
- Returns:
- an
boolean
specifying the test result.
private boolean isVariable(char character)
Tests if the givenchar
contains a variable (f,n) at the beginning.
- Parameters:
character
- thechar
to test.
- Returns:
- an
boolean
specifying the test result.
public void printInfix()
Prints the infixVector
toSystem.out
. Only for debug!
private void processEFunctionComplex(String mathExpression)
Separates the eFunction, into cos(eFunction)+i*sin(eFunction) at the beginning of theString
.
- Parameters:
mathExpression
- theString
from wich the start, end and sumTerm will be extracted.
private void processSum(String mathExpression)
Separates the start, end and sumTerm of the sum at the beginning of theString
.
- Parameters:
mathExpression
- theString
from wich the start, end and sumTerm will be extracted.