public final class FunctionUtil extends Object
Module: equations-api
To use this in your app, include the following dependency in your POM:
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>equations-api</artifactId>
</dependency>| Modifier and Type | Method and Description |
|---|---|
static void |
addScalarArgumentTypes(List<Class> argTypes)
Adds the scalar types that equations use internally to the argument, i.e.
|
static double |
calcSampleVariance(double[] x)
Calculates the sample variance of some numbers.
|
static boolean |
getArgAsBoolean(Object arg)
Assumes that "arg" is a "String", "Boolean", "Long" or a "Double and converts it to "boolean".
|
static double |
getArgAsDouble(Object arg)
Assumes that "arg" is a "String", "Boolean", "Long" or a "Double and converts it to "double".
|
static long |
getArgAsLong(Object arg)
Assumes that "arg" is a "String", "Boolean", "Long" or a "Double and converts it to "long".
|
static String |
getArgAsString(Object arg)
Assumes that "arg" is a "String", "Boolean", "Long" or a "Double and converts it to "String".
|
static boolean[] |
getBooleans(Object[] args)
Attempts to convert all arguments, including Lists to a uniform array of booleans.
|
static double[] |
getDoubles(Object[] args)
Attempts to convert all arguments, including Lists to a uniform array of doubles.
|
static long[] |
getLongs(Object[] args)
Attempts to convert all arguments, including Lists to a uniform array of longs.
|
static String |
getOrdinal(int i)
Converts an integer to an ordinal string.
|
static String[] |
getStrings(Object[] args)
Converts all arguments, including Lists to a uniform array of strings.
|
static boolean |
isScalarArgType(Class type)
Tests whether the argument is one of the scalar types used by equations.
|
static boolean |
isTypeOfList(Class listClassCandidate)
Tests whether the argument is some kind of
List. |
static double[] |
listToArray(List<Double> a)
Converts a List
|
static double |
numericallySafeSum(double[] a)
Carefully adds the numbers in "a" minimising loss of precision.
|
static Object |
translateObjectType(Object input)
Tries to map "input" to one of
Double, Long, Boolean or String |
public static double getArgAsDouble(Object arg) throws IllegalArgumentException
arg - the object instance that will be converted to a double, if possibleIllegalArgumentException - if the argument cannot be converted to a "double"public static String getArgAsString(Object arg) throws IllegalArgumentException
arg - the object instance that will be converted to a StringIllegalArgumentException - if the argument cannot be converted to a "double"public static long getArgAsLong(Object arg) throws IllegalArgumentException
arg - the object instance that will be converted to a long, if possibleIllegalArgumentException - if the argument cannot be converted to a "long"public static boolean getArgAsBoolean(Object arg) throws IllegalArgumentException
arg - the object instance that will be converted to a boolean, if possibleIllegalArgumentException - if the argument cannot be converted to a "boolean"public static double numericallySafeSum(double[] a)
a - the numbers that will be summed uppublic static String getOrdinal(int i)
i - the integer that will be convertedpublic static double calcSampleVariance(double[] x)
x - the numbers whose sample variance will be calculatedpublic static double[] listToArray(List<Double> a)
a - the list that will be convertedpublic static boolean isScalarArgType(Class type)
type - the type that will be testedpublic static boolean isTypeOfList(Class listClassCandidate)
List.listClassCandidate - the type that will be testedpublic static void addScalarArgumentTypes(List<Class> argTypes)
Double.class, Long.class, String.class and
Boolean.class to "argTypes".argTypes - the list that will be augmentedpublic static double[] getDoubles(Object[] args) throws FunctionError
args - the objects that will be converted to doubles, if possibleFunctionErrorIllegalArgumentException - if any scalar argument cannot be converted to a double or any list
argument contains an element that cannot be converted to a number.public static long[] getLongs(Object[] args) throws FunctionError
args - the objects that will be converted to longs, if possibleFunctionErrorIllegalArgumentException - if any scalar argument cannot be converted to a long or any list
argument contains an element that cannot be converted to a number.public static String[] getStrings(Object[] args)
args - the objects that will be converted to Stringspublic static boolean[] getBooleans(Object[] args) throws FunctionError
args - the objects that will be converted to booleans, if possibleFunctionErrorIllegalArgumentException - if any scalar argument cannot be converted to a boolean or any list
argument contains an element that cannot be converted to a number.public static Object translateObjectType(Object input)
Double, Long, Boolean or String.input - the object that will be mapped to one of the scalar types that are internally supported by equationsCopyright 2011-2015 Cytoscape Consortium. All rights reserved.