Class DataUtil

java.lang.Object
org.yamcs.studio.script.DataUtil
Direct Known Subclasses:
DataUtil

public class DataUtil extends 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 Details

    • DataUtil

      public DataUtil()
  • Method Details

    • 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(Object array)
      Convert JavaScript array to Java int array.
      Parameters:
      array - JavaScript array
      Returns:
      java int array.
    • toJavaDoubleArray

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

      public static final 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.