Package adams.parser
Class AbstractExpressionEvaluator<T>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.parser.AbstractExpressionEvaluator<T>
-
- Type Parameters:
T
- the return type of the parser
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,Serializable
- Direct Known Subclasses:
AbstractSymbolEvaluator
,ActorSuggestion
,ActorTemplateSuggestion
,BaseDateExpression
,BaseDateTimeExpression
,BaseDateTimeMsecExpression
,BaseTimeExpression
,BaseTimeMsecExpression
,ExternalActorSuggestion
,ReportMathExpression
public abstract class AbstractExpressionEvaluator<T> extends AbstractOptionHandler
Abstract ancestor for classes that evaluate expressions.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_Environment
the environment class (dummy option, happens all in runJavadoc method).protected String
m_Expression
the expression to evaluate.-
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 AbstractExpressionEvaluator()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.String
environmentTipText()
Returns the tip text for this property.abstract T
evaluate()
Performs the evaluation.abstract String
expressionTipText()
Returns the tip text for this property.static AbstractExpressionEvaluator
forCommandLine(String cmdline)
Instantiates the evaluator from the given commandline (i.e., classname and optional options).static AbstractExpressionEvaluator
forName(String classname, String[] options)
Instantiates the evaluator with the given options.protected abstract String
getDefaultExpression()
Returns the default expression to use.String
getEnvironment()
returns the current classname of the environment class to use.String
getExpression()
Returns the expression to evaluate.static void
runEvaluator(Class eval, String[] args)
Runs the evaluator from commandline.void
setEnvironment(String value)
sets the classname of the environment class to use.void
setExpression(String value)
Sets the expression to evaluate.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, 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.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
setEnvironment
public void setEnvironment(String value)
sets the classname of the environment class to use.- Parameters:
value
- the environment class name
-
getEnvironment
public String getEnvironment()
returns the current classname of the environment class to use.- Returns:
- the current classname of the environment class
-
environmentTipText
public String environmentTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultExpression
protected abstract String getDefaultExpression()
Returns the default expression to use.- Returns:
- the default expression
-
setExpression
public void setExpression(String value)
Sets the expression to evaluate.- Parameters:
value
- the expression
-
getExpression
public String getExpression()
Returns the expression to evaluate.- Returns:
- the expression
-
expressionTipText
public abstract String expressionTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
evaluate
public abstract T evaluate() throws Exception
Performs the evaluation.- Returns:
- the evaluation, or null in case of error
- Throws:
Exception
- if evaluation fails
-
forName
public static AbstractExpressionEvaluator forName(String classname, String[] options)
Instantiates the evaluator with the given options.- Parameters:
classname
- the classname of the evaluator to instantiateoptions
- the options for the evaluator- Returns:
- the instantiated evaluator or null if an error occurred
-
forCommandLine
public static AbstractExpressionEvaluator forCommandLine(String cmdline)
Instantiates the evaluator from the given commandline (i.e., classname and optional options).- Parameters:
cmdline
- the classname (and optional options) of the evaluator to instantiate- Returns:
- the instantiated evaluator or null if an error occurred
-
-