Class DataUtil


  • public class DataUtil
    extends java.lang.Object
    Utility class to facilitate Javascript programming for data operation. The basic data type such as int, double, boolean and string are exchangeable between JavaScript and Java, which means these types of JavaScript variables can be directly used as parameters of Java methods, but array is not exchangeable between JavaScript and Java. This utility class provides methods to create Java array or convert JavaScript array to Java array.
    • Constructor Summary

      Constructors 
      Constructor Description
      DataUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double[] createDoubleArray​(int size)
      Create a new double array with given size.
      static int[] createIntArray​(int size)
      Create a new int array with given size.
      static java.util.LinkedHashMap<java.lang.String,​java.lang.String> createMacrosInput​(boolean include_parent_macros)
      Create a MacrosInput, which can be used as the macros input for a container widget or display.
      static double[] toJavaDoubleArray​(java.lang.Object array)
      Convert JavaScript array to Java double array.
      static int[] toJavaIntArray​(java.lang.Object array)
      Convert JavaScript array to Java int array.
      • Methods inherited from class java.lang.Object

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

      • DataUtil

        public DataUtil()
    • Method Detail

      • createIntArray

        public static final int[] createIntArray​(int size)
        Create a new int array with given size.
        Parameters:
        size - the size of the array
        Returns:
        an int array with given size.
      • createDoubleArray

        public static final double[] createDoubleArray​(int size)
        Create a new double array with given size.
        Parameters:
        size - the size of the array
        Returns:
        a double array with given size.
      • toJavaIntArray

        public static final int[] toJavaIntArray​(java.lang.Object array)
        Convert JavaScript array to Java int array.
        Parameters:
        jsArray - JavaScript array
        Returns:
        java int array.
      • toJavaDoubleArray

        public static final double[] toJavaDoubleArray​(java.lang.Object array)
        Convert JavaScript array to Java double array.
        Parameters:
        jsArray - JavaScript array
        Returns:
        java array.
      • createMacrosInput

        public static final java.util.LinkedHashMap<java.lang.String,​java.lang.String> createMacrosInput​(boolean include_parent_macros)
        Create a MacrosInput, which can be used as the macros input for a container widget or display. New macro can be added or replaced by MacrosInput.put(String macroName, String macroValue);
        Parameters:
        include_parent_macros - If parent macros should be included.
        Returns:
        a new created LinkedHashMap.