Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Groovy parsing example



This article shows an example of parsing for a Groovy Script.

Script interface

Suppose the following script interface:
      public interface Script {
        public String execute();
      }

Groovy script

We have the following script:
      public String execute() {
        return context.getScriptFile().getName();
      }

Final result

      import org.scripthelper.context.ScriptContext;
      import org.scripthelper.context.ScriptHelper;
      import org.scripthelper.context.DefaultScriptContext;
      import org.scripthelper.model.samples.Script;
      class GroovyClass implements org.scripthelper.model.samples.Script, org.scripthelper.context.ContextListener {
        DefaultScriptContext context;
        public void init(ScriptContext ctx) {
          context = (DefaultScriptContext)ctx;
        }

        public String execute() {
          return 10;
        }
      }

See also


Categories: dev | impls

Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence