org.csstudio.opibuilder.scriptUtil

## Class DataUtil

- java.lang.Object
- - org.csstudio.opibuilder.scriptUtil.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.
  Author:
    Xihui Chen

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataUtil()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and 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 org.csstudio.opibuilder.util.MacrosInput` | `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(org.mozilla.javascript.NativeArray jsArray)` Convert JavaScript array to Java double array.
    `static int[]` | `toJavaIntArray(org.mozilla.javascript.NativeArray jsArray)` 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(org.mozilla.javascript.NativeArray jsArray)

      Convert JavaScript array to Java int array.
      Parameters:
        `jsArray` - JavaScript array
      Returns:
        java int array.

    - #### toJavaDoubleArray

          public static final double[] toJavaDoubleArray(org.mozilla.javascript.NativeArray jsArray)

      Convert JavaScript array to Java double array.
      Parameters:
        `jsArray` - JavaScript array
      Returns:
        java array.

    - #### createMacrosInput

          public static final org.csstudio.opibuilder.util.MacrosInput 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 MacrosInput.