All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.jse4conf.JS.html Maven / Gradle / Ivy

Go to download

A parser and interpreter library for JavaScript expressions embedded in a configuration file.

The newest version!





JS











com.google.jse4conf

Class JS

  • java.lang.Object
    • com.google.jse4conf.JS


  • public class JS
    extends java.lang.Object
    Rhino JS/Java conversions, naming, and error messages.
    • Constructor Summary

      Constructors 
      Constructor and Description
      JS()
      Create a new global default scope.
      JS(JS js)
      Create a clone with same initCode.
      JS(java.lang.String initCode)
      Create a new global default scope initilized with given JS code.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.String dumpObjectKeyValue(java.lang.String name, org.mozilla.javascript.NativeObject obj, java.lang.String key)
      Dump the key value of an object, of the given name, in the simplest JS source form.
      java.lang.String dumpSource(java.lang.String name, boolean inComment)
      Return the JS source form of a named variable; enclosed in comment if inComment is true.
      static java.lang.Object eval(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, java.lang.String code)
      Eval JS code in the given context and scope.
      static java.lang.Object eval(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, java.lang.String code, java.lang.String file)
      Eval JS code of a file in the given context and scope.
      java.lang.Object eval(java.lang.String code) 
      java.lang.Object eval(java.lang.String code, java.lang.String fileName)
      Eval JS code in this context and scope, caller should catch exception.
      static java.lang.String eval2String(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, java.lang.String code)
      Eval JS code in the given context and scope, and convert to a String.
      static java.lang.String eval2String(org.mozilla.javascript.Context cx, org.mozilla.javascript.Scriptable scope, java.lang.String code, java.lang.String file)
      Eval JS code in the given context and scope, and convert to a String.
      java.lang.String eval2String(java.lang.String code) 
      java.lang.String eval2String(java.lang.String code, java.lang.String fileName)
      Eval JS code in this context and scope, no exception.
      void exit()
      Must call exit before release this object.
      static java.lang.Boolean from(boolean value)
      Convert Java boolean to JS Object.
      static java.lang.Double from(double value)
      Convert Java int to JS Object.
      static java.lang.Float from(float value)
      Convert Java float to JS Object.
      static java.lang.Integer from(int value)
      Convert Java int to JS Object.
      static java.lang.Long from(long value)
      Convert Java long to JS Object.
      org.mozilla.javascript.Context getContext()
      Return this context.
      org.mozilla.javascript.Scriptable getScope()
      Return this global scope.
      static java.lang.String keyMissingValue(java.lang.String key)
      Error message for a key that has no parsed value.
      static java.lang.String keyValueException(java.lang.String key, java.lang.String value, java.lang.String e)
      Error message for a key's JavaScript expression with given exception.
      org.mozilla.javascript.NativeArray newArray(int length)
      Create JS NativeArray in this context and global scope.
      org.mozilla.javascript.NativeArray newArray(java.lang.Object[] elements)
      Create JS NativeArray in this context and global scope.
      org.mozilla.javascript.Scriptable newObject()
      Create JS NativeObject in this context and global scope.
      void reset()
      Reset to a new global scope.
      java.lang.Object reset(java.lang.String initCode)
      Reset to a new global scope with optional initCode and return last value or null.
      static java.lang.String rhinoSyntaxError(java.lang.String msg, java.lang.String file, int lineNum)
      Exception thrown by Rhino for a syntax error.
      static java.lang.String rhinoUndefinedError(java.lang.String name, java.lang.String file, int lineNum)
      Exception thrown by Rhino for an undefined name.
      static boolean toJava(java.lang.Object obj, boolean defaultBoolean)
      Convert JS obj to Java boolean, or return defaultBoolean.
      static double toJava(java.lang.Object obj, double defaultDouble)
      Convert JS obj to Java double, or return defaultDouble.
      static float toJava(java.lang.Object obj, float defaultFloat)
      Convert JS obj to Java float, or return defaultFloat.
      static int toJava(java.lang.Object obj, int defaultInt)
      Convert JS obj to Java int, or return defaultInt.
      static long toJava(java.lang.Object obj, long defaultLong)
      Convert JS obj to Java long, or return defaultLong.
      static java.lang.String toJavaString(java.lang.Object obj, java.lang.String defaultString)
      Convert JS obj to Java String, or return defaultString.
      static java.lang.String toJSName(java.lang.String name)
      Convert a string to a valid jse4conf identifier.
      static java.lang.String undefinedError(java.lang.String key, java.lang.String value, java.lang.String name)
      Error message for undefined names in a key's JavaScript expression.
      static boolean validIdChar(char c)
      Check if c is a valid character for a jse4conf identifier.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JS

        public JS()
        Create a new global default scope.
      • JS

        public JS(JS js)
        Create a clone with same initCode.
      • JS

        public JS(java.lang.String initCode)
        Create a new global default scope initilized with given JS code.
    • Method Detail

      • reset

        public void reset()
        Reset to a new global scope.
      • reset

        public java.lang.Object reset(java.lang.String initCode)
        Reset to a new global scope with optional initCode and return last value or null.
      • exit

        public void exit()
        Must call exit before release this object.
      • getContext

        public org.mozilla.javascript.Context getContext()
        Return this context.
      • getScope

        public org.mozilla.javascript.Scriptable getScope()
        Return this global scope.
      • newArray

        public org.mozilla.javascript.NativeArray newArray(int length)
        Create JS NativeArray in this context and global scope.
      • newArray

        public org.mozilla.javascript.NativeArray newArray(java.lang.Object[] elements)
        Create JS NativeArray in this context and global scope.
      • newObject

        public org.mozilla.javascript.Scriptable newObject()
        Create JS NativeObject in this context and global scope.
      • eval

        public java.lang.Object eval(java.lang.String code,
                                     java.lang.String fileName)
        Eval JS code in this context and scope, caller should catch exception.
      • eval

        public java.lang.Object eval(java.lang.String code)
      • eval

        public static java.lang.Object eval(org.mozilla.javascript.Context cx,
                                            org.mozilla.javascript.Scriptable scope,
                                            java.lang.String code,
                                            java.lang.String file)
        Eval JS code of a file in the given context and scope.
      • eval

        public static java.lang.Object eval(org.mozilla.javascript.Context cx,
                                            org.mozilla.javascript.Scriptable scope,
                                            java.lang.String code)
        Eval JS code in the given context and scope.
      • eval2String

        public java.lang.String eval2String(java.lang.String code,
                                            java.lang.String fileName)
        Eval JS code in this context and scope, no exception.
      • eval2String

        public java.lang.String eval2String(java.lang.String code)
      • eval2String

        public static java.lang.String eval2String(org.mozilla.javascript.Context cx,
                                                   org.mozilla.javascript.Scriptable scope,
                                                   java.lang.String code,
                                                   java.lang.String file)
        Eval JS code in the given context and scope, and convert to a String.
      • eval2String

        public static java.lang.String eval2String(org.mozilla.javascript.Context cx,
                                                   org.mozilla.javascript.Scriptable scope,
                                                   java.lang.String code)
        Eval JS code in the given context and scope, and convert to a String.
      • toJava

        public static int toJava(java.lang.Object obj,
                                 int defaultInt)
        Convert JS obj to Java int, or return defaultInt.
      • toJava

        public static long toJava(java.lang.Object obj,
                                  long defaultLong)
        Convert JS obj to Java long, or return defaultLong.
      • toJava

        public static float toJava(java.lang.Object obj,
                                   float defaultFloat)
        Convert JS obj to Java float, or return defaultFloat.
      • toJava

        public static double toJava(java.lang.Object obj,
                                    double defaultDouble)
        Convert JS obj to Java double, or return defaultDouble.
      • toJava

        public static boolean toJava(java.lang.Object obj,
                                     boolean defaultBoolean)
        Convert JS obj to Java boolean, or return defaultBoolean.
      • toJavaString

        public static java.lang.String toJavaString(java.lang.Object obj,
                                                    java.lang.String defaultString)
        Convert JS obj to Java String, or return defaultString.
      • from

        public static java.lang.Integer from(int value)
        Convert Java int to JS Object.
      • from

        public static java.lang.Long from(long value)
        Convert Java long to JS Object.
      • from

        public static java.lang.Float from(float value)
        Convert Java float to JS Object.
      • from

        public static java.lang.Double from(double value)
        Convert Java int to JS Object.
      • from

        public static java.lang.Boolean from(boolean value)
        Convert Java boolean to JS Object.
      • dumpObjectKeyValue

        public java.lang.String dumpObjectKeyValue(java.lang.String name,
                                                   org.mozilla.javascript.NativeObject obj,
                                                   java.lang.String key)
        Dump the key value of an object, of the given name, in the simplest JS source form.
      • dumpSource

        public java.lang.String dumpSource(java.lang.String name,
                                           boolean inComment)
        Return the JS source form of a named variable; enclosed in comment if inComment is true.
      • rhinoSyntaxError

        public static java.lang.String rhinoSyntaxError(java.lang.String msg,
                                                        java.lang.String file,
                                                        int lineNum)
        Exception thrown by Rhino for a syntax error.
      • rhinoUndefinedError

        public static java.lang.String rhinoUndefinedError(java.lang.String name,
                                                           java.lang.String file,
                                                           int lineNum)
        Exception thrown by Rhino for an undefined name.
      • keyMissingValue

        public static java.lang.String keyMissingValue(java.lang.String key)
        Error message for a key that has no parsed value.
      • keyValueException

        public static java.lang.String keyValueException(java.lang.String key,
                                                         java.lang.String value,
                                                         java.lang.String e)
        Error message for a key's JavaScript expression with given exception.
      • undefinedError

        public static java.lang.String undefinedError(java.lang.String key,
                                                      java.lang.String value,
                                                      java.lang.String name)
        Error message for undefined names in a key's JavaScript expression.
      • validIdChar

        public static boolean validIdChar(char c)
        Check if c is a valid character for a jse4conf identifier.
      • toJSName

        public static java.lang.String toJSName(java.lang.String name)
        Convert a string to a valid jse4conf identifier.




© 2015 - 2025 Weber Informatics LLC | Privacy Policy