Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Javascript parsing example



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

Script interface

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

Javascript script

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

Final result

      importClass(org.scripthelper.context.ScriptContext);
      importClass(org.scripthelper.context.ScriptHelper);
      importClass(org.scripthelper.context.ContextListener);
      importClass(org.scripthelper.context.DefaultScriptContext)
      scriptClass = new JavaAdapter(org.scripthelper.js.samples.Script, org.scripthelper.context.ContextListener, {
      _ init: function(ctx) {
      _   context = ctx;
      _ },
      _ execute: function() {
      _   return 10;
      _ }
      });

See also


Categories: dev | impls

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