Class JSFunction

  • All Implemented Interfaces:
    org.zkoss.json.JSONAware

    public class JSFunction
    extends Object
    implements org.zkoss.json.JSONAware
    A Javascript function wrap to generate as a formal Javascript code. Used for the implementation of Highcharts' dynamical attributes.
    Author:
    jumperchen
    • Constructor Detail

      • JSFunction

        public JSFunction()
    • Method Detail

      • evalAttribute

        public JSFunction evalAttribute​(String attribute)
        Evaluates an attribute of Javascript Object.
        Parameters:
        attribute - the name of the attribute
      • evalJavascript

        public JSFunction evalJavascript​(String javascript)
        Evaluates a Javascript code with parentheses, if any.
        Parameters:
        javascript - the formal Javascript code
        See Also:
        toExecFunction()
      • callFunction

        public JSFunction callFunction​(String funcName)
        Calls a Javascript Function without any arguments.
        Parameters:
        funcName - the name of the Javascript function without parentheses.
      • callFunction

        public JSFunction callFunction​(String funcName,
                                       Object... arguments)
        Calls a Javascript Function with any arguments.
        Parameters:
        funcName - the name of the Javascript function without parentheses.
        arguments - the arguments in ordering.
      • empty

        public void empty()
      • callArray

        public JSFunction callArray​(String attribute,
                                    int index)
        Calls a array with the given index.
        Parameters:
        attribute - the name of the array
        index - the index of the array.
      • reverse

        public JSFunction reverse()
        Sets the Javascript calls in a reverse ordering.
      • toJSONString

        public String toJSONString()
        Specified by:
        toJSONString in interface org.zkoss.json.JSONAware
      • isEmpty

        public boolean isEmpty()
      • toWrapFunction

        public String toWrapFunction()
        Returns the string in a wrap Javascript function.

        For example,

        function () { this.YourCodesHere;}
      • toExecFunction

        public String toExecFunction()
        Returns the string in a executable Javascript function.

        For example,

        function () { YourCodesHere;}
      • toReturnFunction

        public String toReturnFunction()
        Returns the string in a return value of Javascript function.

        For example,

        function () { return this.YourCodesHere;}