|
Cytoscape 3.0.0-beta1 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.cytoscape.equations.FunctionUtil
public final class FunctionUtil
A collection of static methods that may be useful for the implementation of built-in functions.
Method Summary | |
---|---|
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static double getArgAsDouble(Object arg) throws IllegalArgumentException
arg
- the object instance that will be converted to a double
, if possible
IllegalArgumentException
- 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 String
IllegalArgumentException
- 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 possible
IllegalArgumentException
- 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 possible
IllegalArgumentException
- if the argument cannot be converted to a "boolean"public static double numericallySafeSum(double[] a)
a
- the numbers that will be summed up
public static String getOrdinal(int i)
i
- the integer that will be converted
public static double calcSampleVariance(double[] x)
x
- the numbers whose sample variance will be calculated
public static double[] listToArray(List<Double> a)
a
- the list that will be converted
public static boolean isScalarArgType(Class type)
type
- the type that will be tested
public static boolean isTypeOfList(Class listClassCandidate)
List
.
listClassCandidate
- the type that will be tested
public 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 possible
FunctionError
IllegalArgumentException
- 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 possible
FunctionError
IllegalArgumentException
- 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 Strings
public static boolean[] getBooleans(Object[] args) throws FunctionError
args
- the objects that will be converted to booleans, if possible
FunctionError
IllegalArgumentException
- 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.
- Parameters:
input
- the object that will be mapped to one of the scalar types that are internally supported by equations
- Returns:
- null if the translation failed, the input object if no translation was necessary or a new object if a successful translation was possible
|
Cytoscape 3.0.0-beta1 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |