Package adams.parser

Class ActorTemplateSuggestion

  • All Implemented Interfaces:
    Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, SizeOfHandler, GrammarSupplier, Serializable

    public class ActorTemplateSuggestion
    extends AbstractExpressionEvaluator<AbstractActorTemplate>
    implements GrammarSupplier
    Evaluates rules for suggesting actor templates.

    It uses the following grammar:

    expr_list ::= expr_list expr_part | expr_part ;
    expr_part ::= boolexpr : <classname | "classname+options">;

    boolexpr ::= ( boolean )
    | boolean
    | boolexpr AND boolexpr
    | boolexpr OR boolexpr
    | TRUE
    | FALSE
    | NOT boolexpr
    | ISFIRST
    | ISLAST
    | PARENT IS <classname|interface>
    | BEFORE STANDALONE
    | AFTER STANDALONE
    | BEFORE SOURCE
    | AFTER SOURCE
    | BEFORE TRANSFORMER
    | AFTER TRANSFORMER
    | BEFORE SINK
    | AFTER SINK
    | BEFORE <classname|interface>
    | AFTER <classname|interface>
    ;


    Valid options are:

    -D <int> (property: debugLevel)
        The greater the number the more additional info the scheme may output to 
        the console (0 = off).
        default: 0
        minimum: 0
     
    -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 template to propose (result is null if 
        rul does not apply).
        default: TRUE: adams.flow.template.UpdateVariable
     
    -parent <adams.flow.core.Actor> (property: parent)
        The parent actor to use.
        default: adams.flow.control.Flow
     
    -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: 
     
    Version:
    $Revision$
    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 template.
      • m_Position

        protected int m_Position
        the position the actor template is to be inserted at.
      • m_Actors

        protected Actor[] m_Actors
        the actors in which the proposed actor template gets inserted.
    • Constructor Detail

      • ActorTemplateSuggestion

        public ActorTemplateSuggestion()
    • 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.
      • 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.
      • evaluate

        public static AbstractActorTemplate evaluate​(String expr,
                                                     Actor parent,
                                                     int position,
                                                     Actor[] actors)
                                              throws Exception
        Performs the evaluation.
        Parameters:
        expr - the expression/rule to evaluate
        parent - the parent of the proposed actor
        position - the position of the proposed actor
        actors - the actors to insert the proposed actor in
        Returns:
        the proposed classname in case of a match, otherwise null
        Throws:
        Exception - if evaluation fails
      • evaluate

        public static AbstractActorTemplate[] evaluate​(String[] expr,
                                                       Actor parent,
                                                       int position,
                                                       Actor[] actors)
                                                throws Exception
        Performs the evaluation.
        Parameters:
        expr - the expressions/rules to evaluate
        parent - the parent of the proposed actor
        position - the position of the proposed actor
        actors - the actors to insert the proposed actor in
        Returns:
        array with proposed classnames (cells are null if rule wasn't a match)
        Throws:
        Exception - if evaluation fails