Class FunctionParser

java.lang.Object
org.yamcs.studio.data.FunctionParser

public class FunctionParser extends Object
Utility class to parse variable names and create simulated signals.
  • Field Details

    • STRING_ESCAPE_SEQUENCE_REGEX

      public static final String STRING_ESCAPE_SEQUENCE_REGEX
      The pattern of a string fragment with escape sequences.
      See Also:
    • QUOTED_STRING_REGEX

      public static final String QUOTED_STRING_REGEX
      The pattern of a string, including double quotes.
      See Also:
    • DOUBLE_REGEX

      public static final String DOUBLE_REGEX
      The pattern of a double value.
      See Also:
  • Constructor Details

    • FunctionParser

      public FunctionParser()
  • Method Details

    • parseFunctionWithScalarOrArrayArguments

      public static List<Object> parseFunctionWithScalarOrArrayArguments(String string, String errorMessage)
      Parse a function that accepts a scalar value (number or string) or an array value (number or string).
      Parameters:
      string - the string to be parsed
      errorMessage - the error message
      Returns:
      the name of the function and the argument
    • parseFunctionWithScalarOrArrayArguments

      public static List<Object> parseFunctionWithScalarOrArrayArguments(String nameRegex, String string, String errorMessage)
      Parse a function that accepts a scalar value (number or string) or an array value (number or string).
      Parameters:
      nameRegex - regex for function name
      string - the string to be parsed
      errorMessage - the error message for the exception if parsing fails
      Returns:
      the name of the function and the argument
    • asScalarOrList

      public static Object asScalarOrList(List<Object> objects)
      Converts the list of arguments into a scalar or an appropriate list. Returns null if it's not possible.
      Parameters:
      objects - the argument list
      Returns:
      the value converted or null
    • asListDouble

      public static ListDouble asListDouble(List<Object> objects)
      Convert the list of arguments to a ListDouble. Returns null if it's not possible.
      Parameters:
      objects - a list of arguments
      Returns:
      the converted list or null
    • asListString

      public static List<String> asListString(List<Object> objects)
      Convert the list of arguments to a List. Returns null if it's not possible.
      Parameters:
      objects - a list of arguments
      Returns:
      the converted list of null
    • parseFunctionAnyParameter

      public static List<Object> parseFunctionAnyParameter(String string)
      Parses the string and returns the name of the function plus the list of arguments. The arguments can either be doubles or Strings. Returns null if parsing fails.
      Parameters:
      string - the string to be parsed
      Returns:
      the function name and arguments; null if parsing fails
    • parseFunctionAnyParameter

      public static List<Object> parseFunctionAnyParameter(String nameRegex, String string)
      Parses the string and returns the name of the function plus the list of arguments. The arguments can either be doubles or Strings. Returns null if parsing fails.
      Parameters:
      nameRegex - the syntax for the function name
      string - the string to be parsed
      Returns:
      the function name and arguments; null if parsing fails