src/share/classes/javax/script/ScriptEngineFactory.java

Print this page




 143     /**
 144      * Returns a String which can be used to invoke a method of a  Java object using the syntax
 145      * of the supported scripting language.  For instance, an implementation for a Javascript
 146      * engine might be;
 147      *
 148      * <pre>{@code
 149      * public String getMethodCallSyntax(String obj,
 150      *                                   String m, String... args) {
 151      *      String ret = obj;
 152      *      ret += "." + m + "(";
 153      *      for (int i = 0; i < args.length; i++) {
 154      *          ret += args[i];
 155      *          if (i < args.length - 1) {
 156      *              ret += ",";
 157      *          }
 158      *      }
 159      *      ret += ")";
 160      *      return ret;
 161      * }
 162      * } </pre>
 163      * <p>
 164      *
 165      * @param obj The name representing the object whose method is to be invoked. The
 166      * name is the one used to create bindings using the <code>put</code> method of
 167      * <code>ScriptEngine</code>, the <code>put</code> method of an <code>ENGINE_SCOPE</code>
 168      * <code>Bindings</code>,or the <code>setAttribute</code> method
 169      * of <code>ScriptContext</code>.  The identifier used in scripts may be a decorated form of the
 170      * specified one.
 171      *
 172      * @param m The name of the method to invoke.
 173      * @param args names of the arguments in the method call.
 174      *
 175      * @return The String used to invoke the method in the syntax of the scripting language.
 176      */
 177     public String getMethodCallSyntax(String obj, String m, String... args);
 178 
 179     /**
 180      * Returns a String that can be used as a statement to display the specified String  using
 181      * the syntax of the supported scripting language.  For instance, the implementation for a Perl
 182      * engine might be;
 183      *




 143     /**
 144      * Returns a String which can be used to invoke a method of a  Java object using the syntax
 145      * of the supported scripting language.  For instance, an implementation for a Javascript
 146      * engine might be;
 147      *
 148      * <pre>{@code
 149      * public String getMethodCallSyntax(String obj,
 150      *                                   String m, String... args) {
 151      *      String ret = obj;
 152      *      ret += "." + m + "(";
 153      *      for (int i = 0; i < args.length; i++) {
 154      *          ret += args[i];
 155      *          if (i < args.length - 1) {
 156      *              ret += ",";
 157      *          }
 158      *      }
 159      *      ret += ")";
 160      *      return ret;
 161      * }
 162      * } </pre>

 163      *
 164      * @param obj The name representing the object whose method is to be invoked. The
 165      * name is the one used to create bindings using the <code>put</code> method of
 166      * <code>ScriptEngine</code>, the <code>put</code> method of an <code>ENGINE_SCOPE</code>
 167      * <code>Bindings</code>,or the <code>setAttribute</code> method
 168      * of <code>ScriptContext</code>.  The identifier used in scripts may be a decorated form of the
 169      * specified one.
 170      *
 171      * @param m The name of the method to invoke.
 172      * @param args names of the arguments in the method call.
 173      *
 174      * @return The String used to invoke the method in the syntax of the scripting language.
 175      */
 176     public String getMethodCallSyntax(String obj, String m, String... args);
 177 
 178     /**
 179      * Returns a String that can be used as a statement to display the specified String  using
 180      * the syntax of the supported scripting language.  For instance, the implementation for a Perl
 181      * engine might be;
 182      *