Cytoscape 2.8.0 API

org.cytoscape.equations
Class AbstractFunction

java.lang.Object
  extended by org.cytoscape.equations.AbstractFunction
All Implemented Interfaces:
Function
Direct Known Subclasses:
Abs, 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 abstract class AbstractFunction
extends Object
implements Function


Constructor Summary
protected AbstractFunction(ArgDescriptor[] argDescriptors)
           
 
Method Summary
protected  boolean argTypesAreValid(Class[] argTypes)
           
abstract  Object evaluateFunction(Object[] args)
          Used to invoke this function.
abstract  String getFunctionSummary()
          Used to provide help for users.
abstract  String getName()
          Used to parse the function string.
 List<Class> getPossibleArgTypes(Class[] leadingArgs)
          Used with the equation builder.
abstract  Class getReturnType()
           
 String getUsageDescription()
          Used to provide help for users.
 Class validateArgTypes(Class[] argTypes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractFunction

protected AbstractFunction(ArgDescriptor[] argDescriptors)
Method Detail

getName

public abstract String getName()
Used to parse the function string. This name is treated in a case-insensitive manner!

Specified by:
getName in interface Function
Returns:
the name by which you must call the function when used in an attribute equation.

getFunctionSummary

public abstract String getFunctionSummary()
Used to provide help for users. Unlike getUsageDescription(), this is an informal English description, like "Calculates the sine of its argument."

Specified by:
getFunctionSummary in interface Function
Returns:
a description of what this function does

getUsageDescription

public final String getUsageDescription()
Used to provide help for users. Unlike getFunctionSummary(), this describes how to call this function, like "Call with SIN(number)."

Specified by:
getUsageDescription in interface Function
Returns:
a description of how to use this function

getReturnType

public abstract Class getReturnType()
Specified by:
getReturnType in interface Function
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.

argTypesAreValid

protected final boolean argTypesAreValid(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.

validateArgTypes

public final Class validateArgTypes(Class[] argTypes)
Specified by:
validateArgTypes in interface Function
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

public abstract Object evaluateFunction(Object[] args)
                                 throws FunctionError
Used to invoke this function.

Specified by:
evaluateFunction in interface 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

public final List<Class> getPossibleArgTypes(Class[] leadingArgs)
Used with the equation builder.

Specified by:
getPossibleArgTypes in interface Function
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.

Cytoscape 2.8.0 API

Copyright 2010 Cytoscape Consortium. All rights reserved.