Package adams.parser
Class ActorSuggestion
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,GrammarSupplier,Serializable
public class ActorSuggestion extends AbstractExpressionEvaluator<Actor> implements GrammarSupplier
Evaluates rules for suggesting actors.
It uses the following grammar:
expr_list ::= expr_list expr_part | expr_part ;
expr_part ::= IF boolexpr THEN cmdexpr ;
boolexpr ::= ( boolean )
| boolean
| boolexpr AND boolexpr
| boolexpr OR boolexpr
| TRUE
| FALSE
| NOT boolexpr
| ISFIRST
| ISLAST
| PARENT IS classexpr
| PARENT LIKE classexpr
| PARENT ALLOWS STANDALONE
| PARENT ALLOWS SOURCE
| ANYPARENT IS classexpr
| ANYPARENT LIKE classexpr
| PRECEDING GENERATES classexpr
| FOLLOWING ACCEPTS classexpr
| BEFORE STANDALONE
| AFTER STANDALONE
| BEFORE SOURCE
| AFTER SOURCE
| BEFORE TRANSFORMER
| AFTER TRANSFORMER
| BEFORE SINK
| AFTER SINK
| BEFORE classexpr
| AFTER classexpr
;
classexpr ::= "classname (interface or class)"
;
cmdexpr ::= classname
| "classname + options"
;
Notes:
- 'ANYPARENT' tests any parent to the root until successful or no more parents
- 'IS' uses exact classname testing
- 'LIKE' tests whether the class is either a subclass of a class or implements a class
- A 'cmdexpr' string surrounded by double quotes can also contain placeholders:
classname: ${PARENT.CLASS}, ${PRECEDING.CLASS}, ${FOLLOWING.CLASS}
actor's name: ${PARENT.NAME}, ${PRECEDING.NAME}, ${FOLLOWING.NAME}
actor's fullname: ${PARENT.FULL}, ${PRECEDING.FULL}, ${FOLLOWING.FULL}
- '${PARENT.X}' refers to the last parent that was located, e.g., using 'IF ANYPARENT...'
or 'IF PARENT...'. If none set, then the immediate parent is used.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-env <java.lang.String> (property: environment) The class to use for determining the environment. default: adams.env.Environment
-expression <java.lang.String> (property: expression) The rule for determining the actor to propose (result is null if rul does not apply). default: ISFIRST: adams.flow.standalone.CallableActors
-parent <adams.flow.core.Actor> (property: parent) The parent actor to use. default: adams.flow.control.Flow -flow-execution-listener adams.flow.execution.NullListener
-position <int> (property: position) The position to add the proposed actor at. default: 0 minimum: 0
-actor <adams.flow.core.Actor> [-actor ...] (property: actors) The actors to insert the proposed actor in. default:
In order to get access to the full name, theNodes from the tree for parent and actors must be set programmatically.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classActorSuggestion.SuggestionDataContainer class for data required for making suggestions.
-
Field Summary
Fields Modifier and Type Field Description protected Node[]m_ActorNodesthe nodes in which the proposed actor gets inserted.protected Actor[]m_Actorsthe actors in which the proposed actor gets inserted.protected Actorm_Parentthe parent of the proposed actor.protected Nodem_ParentNodethe parent node.protected intm_Positionthe position the actor is to be inserted at.-
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 ActorSuggestion()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringactorsTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.Actorevaluate()Performs the evaluation.static Actor[]evaluate(String[] expr, ActorSuggestion.SuggestionData data)Performs the evaluation.static Actorevaluate(String expr, ActorSuggestion.SuggestionData data)Performs the evaluation.StringexpressionTipText()Returns the tip text for this property.Node[]getActorNodes()Returns the nodes to insert the proposed actor in.Actor[]getActors()Returns the actors to insert the proposed actor in.protected StringgetDefaultExpression()Returns the default expression to use.StringgetGrammar()Returns a string representation of the grammar.ActorgetParent()Returns the current parent in use.NodegetParentNode()Returns the current parent node in use.intgetPosition()Returns the position to add the proposed actor at.StringglobalInfo()Returns a string describing the object.StringparentTipText()Returns the tip text for this property.StringpositionTipText()Returns the tip text for this property.voidsetActorNodes(Node[] value)Sets the nodes to insert the proposed actor in.voidsetActors(Actor[] value)Sets the actors to insert the proposed actor in.voidsetParent(Actor value)Sets the parent to use.voidsetParentNode(Node value)Sets the parent node to use.voidsetPosition(int value)The position to add the proposed actor at.-
Methods inherited from class adams.parser.AbstractExpressionEvaluator
environmentTipText, forCommandLine, forName, getEnvironment, getExpression, runEvaluator, setEnvironment, setExpression
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, 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
-
-
-
-
Field Detail
-
m_Parent
protected Actor m_Parent
the parent of the proposed actor.
-
m_ParentNode
protected transient Node m_ParentNode
the parent node.
-
m_Position
protected int m_Position
the position the actor is to be inserted at.
-
m_Actors
protected Actor[] m_Actors
the actors in which the proposed actor gets inserted.
-
m_ActorNodes
protected transient Node[] m_ActorNodes
the nodes in which the proposed actor gets inserted.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
getGrammar
public String getGrammar()
Returns a string representation of the grammar.- Specified by:
getGrammarin interfaceGrammarSupplier- Returns:
- the grammar, null if not available
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractExpressionEvaluator<Actor>
-
getDefaultExpression
protected String getDefaultExpression()
Returns the default expression to use.- Specified by:
getDefaultExpressionin classAbstractExpressionEvaluator<Actor>- Returns:
- the default expression
-
expressionTipText
public String expressionTipText()
Returns the tip text for this property.- Specified by:
expressionTipTextin classAbstractExpressionEvaluator<Actor>- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setParent
public void setParent(Actor value)
Sets the parent to use.- Parameters:
value- the parent
-
getParent
public Actor getParent()
Returns the current parent in use.- Returns:
- the parent
-
parentTipText
public String parentTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setParentNode
public void setParentNode(Node value)
Sets the parent node to use.- Parameters:
value- the parent
-
getParentNode
public Node getParentNode()
Returns the current parent node in use.- Returns:
- the parent
-
setPosition
public void setPosition(int value)
The position to add the proposed actor at.- Parameters:
value- the position
-
getPosition
public int getPosition()
Returns the position to add the proposed actor at.- Returns:
- the position
-
positionTipText
public String positionTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setActors
public void setActors(Actor[] value)
Sets the actors to insert the proposed actor in.- Parameters:
value- the actors
-
getActors
public Actor[] getActors()
Returns the actors to insert the proposed actor in.- Returns:
- the actors
-
actorsTipText
public String actorsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setActorNodes
public void setActorNodes(Node[] value)
Sets the nodes to insert the proposed actor in.- Parameters:
value- the nodes
-
getActorNodes
public Node[] getActorNodes()
Returns the nodes to insert the proposed actor in.- Returns:
- the nodes
-
evaluate
public Actor evaluate() throws Exception
Performs the evaluation.- Specified by:
evaluatein classAbstractExpressionEvaluator<Actor>- Returns:
- the evaluation, or null in case of error
- Throws:
Exception- if evaluation fails
-
evaluate
public static Actor evaluate(String expr, ActorSuggestion.SuggestionData data) throws Exception
Performs the evaluation.- Parameters:
expr- the expression/rule to evaluatedata- the suggestion data- Returns:
- the proposed classname in case of a match, otherwise null
- Throws:
Exception- if evaluation fails
-
evaluate
public static Actor[] evaluate(String[] expr, ActorSuggestion.SuggestionData data) throws Exception
Performs the evaluation.- Parameters:
expr- the expressions/rules to evaluatedata- the suggestion data- Returns:
- array with proposed classnames (cells are null if rule wasn't a match)
- Throws:
Exception- if evaluation fails
-
-