Package adams.parser
Class AbstractSymbolEvaluator<T>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.parser.AbstractExpressionEvaluator<T>
-
- adams.parser.AbstractSymbolEvaluator<T>
-
- Type Parameters:
T- the return type of the parser
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,GrammarSupplier,Serializable
- Direct Known Subclasses:
BooleanExpression,LookUpUpdate,MathematicalExpression,SpreadSheetFormula,SpreadSheetQuery,StringExpression
public abstract class AbstractSymbolEvaluator<T> extends AbstractExpressionEvaluator<T> implements GrammarSupplier
Abstract ancestor for classes that evaluate expressions with a parser generated by JFlex/CUP. Also supports supplied symbols.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected BaseString[]m_Symbolsthe symbols (key-value pairs).-
Fields inherited from class adams.parser.AbstractExpressionEvaluator
m_Environment, m_Expression
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractSymbolEvaluator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voiddefineOptions()Adds options to the internal list of options.protected abstract TdoEvaluate(HashMap symbols)Performs the actual evaluation.Tevaluate()Performs the evaluation.BaseString[]getSymbols()Returns the symbols to use for evaluation.protected voidinitialize()Initializes the members.protected abstract ObjectinitializeSymbol(String name, String value)Initializes the symbol.protected HashMapinitializeSymbols()Initializes the symbols.voidsetSymbols(BaseString[] value)Sets the symbols to use for evaluation.StringsymbolsTipText()Returns the tip text for this property.-
Methods inherited from class adams.parser.AbstractExpressionEvaluator
environmentTipText, expressionTipText, forCommandLine, forName, getDefaultExpression, getEnvironment, getExpression, runEvaluator, setEnvironment, setExpression
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.parser.GrammarSupplier
getGrammar
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Symbols
protected BaseString[] m_Symbols
the symbols (key-value pairs).
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractExpressionEvaluator<T>
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractOptionHandler
-
setSymbols
public void setSymbols(BaseString[] value)
Sets the symbols to use for evaluation.- Parameters:
value- the symbols
-
getSymbols
public BaseString[] getSymbols()
Returns the symbols to use for evaluation.- Returns:
- the symbols
-
symbolsTipText
public String symbolsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
initializeSymbol
protected abstract Object initializeSymbol(String name, String value)
Initializes the symbol.- Parameters:
name- the name of the symbolvalue- the string representation of the symbol- Returns:
- the object representation of the symbol
-
initializeSymbols
protected HashMap initializeSymbols()
Initializes the symbols.- Returns:
- the generated symbols
-
doEvaluate
protected abstract T doEvaluate(HashMap symbols) throws Exception
Performs the actual evaluation.- Parameters:
symbols- the symbols to use- Returns:
- the evaluation, or null in case of error
- Throws:
Exception- if evaluation fails
-
-