Exposing Java Enums in the Rhino JavaScript engine -


i'm writing program incorporates rhino scripting engine. ale expose couple of program's enums, can't figure out how that, if it's possible. there way make java enum usable in scripts?

do mean use java enum script, converted java rhino?. if case, like:

  • given java class enum:

    package com.stackoverflow.example; public class order {      private string field;     private by;      public enum {         asc, desc     }      public order(string field, by) {         this.field = field;         this.by = by;     } } 
  • and in script can do

    // importing class enum importclass(packages.com.stackoverflow.example.order);  // instancing new order object using existing enum in order class var order = new order("db_field", order.by.desc); 

i hope helps.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -