Class EventDrivenParser


  • public class EventDrivenParser
    extends Object
    An event driven parser for functors. Note that this does allow for escape characters. Any single character preceeded by a backslash will be passed along unaltered.

    Created by Jeff Gaynor
    on 7/16/18 at 11:27 AM

    • Field Detail

      • debugOn

        public boolean debugOn
    • Constructor Detail

      • EventDrivenParser

        public EventDrivenParser()
      • EventDrivenParser

        public EventDrivenParser​(JFunctorFactory functorFactory)
        Create and initialize this parser.
        Parameters:
        functorFactory -
    • Method Detail

      • reset

        public void reset()
        Completely reset the internal state of this parser.
      • addCommaListener

        public void addCommaListener​(CommaListener c)
      • removeCommaListener

        public void removeCommaListener​(CommaListener c)
      • removeParenthesisListener

        public void removeParenthesisListener​(DelimiterListener d)
      • addParenthesisListener

        public void addParenthesisListener​(DelimiterListener d)
      • execute

        protected void execute()
      • getFunctor

        public JFunctor getFunctor()
      • init

        public void init​(String raw)
        If you prefer to create the SwitchHandler yourself, pass it in. You can always get it back after parsing via getSwitchHandler().
        Parameters:
        raw -
      • getType

        protected int getType​(String raw)
        The parser is rather stupid on purpose. It can evolve but for now, the strict format is all that is allowed. This method is a very simple-minded way to turn a simple functor or even simple conditional into something the parser understands. It should be amended, improved and replaced as time goes on.
        Parameters:
        raw -
        Returns:
      • parse

        public AbstractHandler parse​(String input,
                                     Map<String,​String> replacements)
        Parse a single line. If you supply a map of replacements with key-value pairs, then every occurance of the form ${key} will be replaced by its value. E.g. if
             key = vo
             value = voPersonExternalID
         
        then the following transformation on the input line
             get("${vo}");
         
        would result in the execution of
             get("voPersonExternalID");
         
        You may set these values with the jsetEnv function in your script.
        Parameters:
        input -
        replacements -
        Returns:
      • hasSwitch

        public boolean hasSwitch()
      • hasConditional

        public boolean hasConditional()
      • hasFunctor

        public boolean hasFunctor()