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, the Nodes from the tree for parent and actors must be set programmatically.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • 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.
    • Constructor Detail

      • ActorSuggestion

        public ActorSuggestion()
    • Method Detail

      • getGrammar

        public String getGrammar()
        Returns a string representation of the grammar.
        Specified by:
        getGrammar in interface GrammarSupplier
        Returns:
        the grammar, null if not available
      • 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 static Actor evaluate​(String expr,
                                     ActorSuggestion.SuggestionData data)
                              throws Exception
        Performs the evaluation.
        Parameters:
        expr - the expression/rule to evaluate
        data - 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 evaluate
        data - the suggestion data
        Returns:
        array with proposed classnames (cells are null if rule wasn't a match)
        Throws:
        Exception - if evaluation fails