< prev index next >

## src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptUtils.java

Print this page

      20  *
      21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
      22  * or visit www.oracle.com if you need additional information or have any
      23  * questions.
      24  */
      25
      26 package jdk.nashorn.api.scripting;
      27
      28 import java.lang.invoke.MethodHandle;
      29 import jdk.dynalink.beans.StaticClass;
      30 import jdk.dynalink.linker.LinkerServices;
      31 import jdk.nashorn.internal.runtime.Context;
      32 import jdk.nashorn.internal.runtime.ScriptFunction;
      33 import jdk.nashorn.internal.runtime.ScriptObject;
      34 import jdk.nashorn.internal.runtime.ScriptRuntime;
      35 import jdk.nashorn.internal.runtime.linker.Bootstrap;
      36
      37 /**
      38  * Utilities that are to be called from script code.
      39  *

      40  * @since 1.8u40
      41  */

      42 public final class ScriptUtils {
      43     private ScriptUtils() {}
      44
      45     /**
      46      * Returns AST as JSON compatible string. This is used to
      47      * implement "parse" function in resources/parse.js script.
      48      *
      49      * @param code code to be parsed
      50      * @param name name of the code source (used for location)
      51      * @param includeLoc tells whether to include location information for nodes or not
      52      * @return JSON string representation of AST of the supplied code
      53      */
      54     public static String parse(final String code, final String name, final boolean includeLoc) {
      55         return ScriptRuntime.parse(code, name, includeLoc);
      56     }
      57
      58     /**
      59      * Method which converts javascript types to java types for the
      60      * String.format method (jrunscript function sprintf).
      61      *
      20  *
      21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
      22  * or visit www.oracle.com if you need additional information or have any
      23  * questions.
      24  */
      25
      26 package jdk.nashorn.api.scripting;
      27
      28 import java.lang.invoke.MethodHandle;
      29 import jdk.dynalink.beans.StaticClass;
      30 import jdk.dynalink.linker.LinkerServices;
      31 import jdk.nashorn.internal.runtime.Context;
      32 import jdk.nashorn.internal.runtime.ScriptFunction;
      33 import jdk.nashorn.internal.runtime.ScriptObject;
      34 import jdk.nashorn.internal.runtime.ScriptRuntime;
      35 import jdk.nashorn.internal.runtime.linker.Bootstrap;
      36
      37 /**
      38  * Utilities that are to be called from script code.
      39  *
      40  * @deprecated Nashorn JavaScript script engine and APIs, and the jjs tool
      41  * are deprecated with the intent to remove them in a future release.
      42  *
      43  * @since 1.8u40
      44  */
      45 @Deprecated(since="11", forRemoval=true)
      46 public final class ScriptUtils {
      47     private ScriptUtils() {}
      48
      49     /**
      50      * Returns AST as JSON compatible string. This is used to
      51      * implement "parse" function in resources/parse.js script.
      52      *
      53      * @param code code to be parsed
      54      * @param name name of the code source (used for location)
      55      * @param includeLoc tells whether to include location information for nodes or not
      56      * @return JSON string representation of AST of the supplied code
      57      */
      58     public static String parse(final String code, final String name, final boolean includeLoc) {
      59         return ScriptRuntime.parse(code, name, includeLoc);
      60     }
      61
      62     /**
      63      * Method which converts javascript types to java types for the
      64      * String.format method (jrunscript function sprintf).
      65      *

< prev index next >