org.cytoscape.equations
Interface Function
- All Known Implementing Classes:
- Abs, AbstractFunction, ACos, And, ASin, ATan2, Average, BList, Combin, Concatenate, Cos, Cosh, Count, Degrees, Error, Exp, First, FList, GeoMean, HarMean, If, IList, Largest, Last, Left, Len, ListToString, Ln, Log, Lower, Max, Median, Mid, Min, Mod, Mode, NormDist, Not, Now, Nth, Or, Permut, Pi, Product, Radians, Right, Round, Sign, Sin, Sinh, SList, Sqrt, StDev, Substitute, Sum, Tan, Tanh, Text, Today, Trunc, Upper, Value, Var
public interface Function
getName
String getName()
- Used to parse the function string. This name is treated in a case-insensitive manner!
- Returns:
- the name by which you must call the function when used in an attribute equation.
getFunctionSummary
String getFunctionSummary()
- Used to provide help for users. Unlike getUsageDescription(), this is an informal English description,
like "Calculates the sine of its argument."
- Returns:
- a description of what this function does
getUsageDescription
String getUsageDescription()
- Used to provide help for users. Unlike getFunctionSummary(), this describes how to call this function,
like "Call with SIN(number)."
- Returns:
- a description of how to use this function
getReturnType
Class getReturnType()
- Returns:
- the static return type of this function, Object.class, Double.cLass, String.class, or Boolean.class.
If the static return type is Object.class, the dynamic return type will be one of Double.cLass, String.class, or Boolean.class
and will depend on the arguments passed to the function!
Note, this is used by external tools used to filter a list of functions based on what a valid return type might be.
In Cytoscape it is used in the attribute browser's formula builder.
validateArgTypes
Class validateArgTypes(Class[] argTypes)
- Returns:
- the return type for this function (Double.cLass, String.class, or Boolean.class)
or null if the args passed in had the wrong arity or a type mismatch
Note that this is different from getReturnType() in that it will never return the wildcard Object.class.
It is used by the parser which knows the actual type of the arguments in any given call to this function.
evaluateFunction
Object evaluateFunction(Object[] args)
throws FunctionError
- Used to invoke this function.
- Parameters:
args
- the function arguments which must correspond in type and number to what getParameterTypes() returns.
- Returns:
- the result of the function evaluation. The actual type of the returned object will be what getReturnType() returns.
- Throws:
ArithmeticException
- thrown if a numeric error, e.g. a division by zero occurred.
IllegalArgumentException
- thrown for any error that is not a numeric error, for example if a function only accepts positive numbers and a negative number was passed in.
FunctionError
getPossibleArgTypes
List<Class> getPossibleArgTypes(Class[] leadingArgs)
- Used with the equation builder.
- Parameters:
leadingArgs
- the types of the arguments that have already been selected by the user.
- Returns:
- the set of arguments (must be a collection of String.class, Long.class, Double.class, Boolean.class and List.class) that are candidates for the next argument. A null return indicates that no further arguments are valid.
Please note that if the returned set contains a null, this indicates an optional additional argument.
Copyright 2010 Cytoscape Consortium. All rights reserved.