Package org.epics.util.text
Class FunctionParser
- java.lang.Object
-
- org.epics.util.text.FunctionParser
-
public class FunctionParser extends Object
Utility class to parse string representations of functions with arguments.- Author:
- carcassi
-
-
Constructor Summary
Constructors Constructor Description FunctionParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ListDouble
asListDouble(List<Object> objects)
Convert the list of arguments to a ListDouble.static List<String>
asListString(List<Object> objects)
Convert the list of arguments to a List.static Object
asScalarOrList(List<Object> objects)
Converts the list of arguments into a scalar or an appropriate list.static List<Object>
parseFunctionAnyParameter(String string)
Parses the string and returns the name of the function plus the list of arguments.static List<Object>
parseFunctionAnyParameter(String nameRegex, String string)
Parses the string and returns the name of the function plus the list of arguments.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).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).
-
-
-
Method Detail
-
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 parsederrorMessage
- 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 namestring
- the string to be parsederrorMessage
- 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 namestring
- the string to be parsed- Returns:
- the function name and arguments; null if parsing fails
-
-