de.fho.jump.pirol.utilities.FormulaParsing
Class FormulaParser
java.lang.Object
de.fho.jump.pirol.utilities.FormulaParsing.FormulaParser
public class FormulaParser
- extends java.lang.Object
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:
( 4 + 6 ) * yield
or
grain mois / 2.
- Version:
- $Rev: 1559 $
- Author:
- Ole Rahn
FH Osnabrück - University of Applied Sciences Osnabrück,
Project: PIROL (2005),
Subproject: Daten- und Wissensmanagement
- See Also:
de.fho.jump.pirol.utilities.FeatureCollectionTools#applyFormulaToFeatureCollection(FeatureCollection, AttributeInfo, FormulaValue, boolean)
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
protected static PersonalLogger logger
KEY_SQRT
public static final java.lang.String KEY_SQRT
- See Also:
- Constant Field Values
KEY_POW
public static final java.lang.String KEY_POW
- See Also:
- Constant Field Values
FormulaParser
public FormulaParser()
getValue
public static FormulaValue getValue(java.lang.String formula,
FeatureSchema featSchema)
- Recursively parses a given (sub-) formula into a FormulaValue, which can be an operation with
sub-FormularValues or a value.
- Parameters:
formula - featSchema - 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
protected static boolean isOperator(java.lang.String op)
isBracket
protected static boolean isBracket(java.lang.String brack)
findFirstOccuranceOutsideABracket
protected static int findFirstOccuranceOutsideABracket(java.lang.String toBeFound,
java.lang.String formula,
int fromIndex)
findFirstAddSubOperatorOutsideABracket
protected static int findFirstAddSubOperatorOutsideABracket(java.lang.String formula,
int fromIndex)
findFirstMultiDivOperatorOutsideABracket
protected static int findFirstMultiDivOperatorOutsideABracket(java.lang.String formula,
int fromIndex)
splitToFirstLevelOperation
protected static java.lang.String[] splitToFirstLevelOperation(java.lang.String formula)
getFirstCompleteBracketString
protected static java.lang.String getFirstCompleteBracketString(java.lang.String formula,
int fromIndex)
kickOutSurroundingBracket
protected static java.lang.String kickOutSurroundingBracket(java.lang.String formula)
- deletes a bracket that surrounds the whole formula from the formula.
- Parameters:
formula - formula String
- Returns:
- formula String without surrounding bracket