Class FormulaParser
java.lang.Object
de.fho.jump.pirol.utilities.FormulaParsing.FormulaParser
This class is a utility to parse formulas, that describe how an additional attribute value is to be calculated on a by feature basis.
Formulas thereby can contain constant values as well as attribute values, that need to be extracted for each feature.
Formulas are exspected to be space-separated: Each attribute name, constant value, bracket or operator has to be surrounded by empty spaces.
A valid formulas (for a FeatureSchema that has the attributes "yield" and "grain mois") would look like this:
or
Formulas are exspected to be space-separated: Each attribute name, constant value, bracket or operator has to be surrounded by empty spaces.
A valid formulas (for a FeatureSchema that has the attributes "yield" and "grain mois") would look like this:
( 4 + 6 ) * yieldor
grain mois / 2.- Version:
- $Rev$
- Author:
- Ole Rahn
FH Osnabrück - University of Applied Sciences Osnabrück,
Project: PIROL (2005),
Subproject: Daten- und Wissensmanagement - See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static PersonalLogger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static intfindFirstAddSubOperatorOutsideABracket(String formula, int fromIndex) protected static intfindFirstMultiDivOperatorOutsideABracket(String formula, int fromIndex) protected static intfindFirstOccuranceOutsideABracket(String toBeFound, String formula, int fromIndex) protected static StringgetFirstCompleteBracketString(String formula, int fromIndex) static FormulaValuegetValue(String formula, FeatureSchema featSchema) Recursively parses a given (sub-) formula into a FormulaValue, which can be an operation with sub-FormularValues or a value.protected static booleanprotected static booleanisOperator(String op) protected static StringkickOutSurroundingBracket(String formula) deletes a bracket that surrounds the whole formula from the formula.protected static String[]splitToFirstLevelOperation(String formula)
-
Field Details
-
logger
-
KEY_SQRT
- See Also:
-
KEY_POW
- See Also:
-
KEY_PI
- See Also:
-
KEY_LOG
- See Also:
-
KEY_SIN
- See Also:
-
KEY_COS
- See Also:
-
KEY_TAN
- See Also:
-
KEY_EXP
- See Also:
-
KEY_ASIN
- See Also:
-
KEY_ACOS
- See Also:
-
KEY_ATAN
- See Also:
-
KEY_LOG10
- See Also:
-
KEY_TODEG
- See Also:
-
KEY_TORAD
- See Also:
-
-
Constructor Details
-
FormulaParser
public FormulaParser()
-
-
Method Details
-
getValue
Recursively parses a given (sub-) formula into a FormulaValue, which can be an operation with sub-FormularValues or a value.- Parameters:
formula- the formula passed as a StringfeatSchema- The feature schema to check attribute names, if neccessary- Returns:
- the given formula parsed into a FormulaValue or null if the given String did not contain formula information
-
isOperator
-
isBracket
-
findFirstOccuranceOutsideABracket
-
findFirstAddSubOperatorOutsideABracket
-
findFirstMultiDivOperatorOutsideABracket
-
splitToFirstLevelOperation
-
getFirstCompleteBracketString
-
kickOutSurroundingBracket
-