org.hackystat.telemetry.analyzer.function
Class TelemetryFunction

java.lang.Object
  extended by org.hackystat.telemetry.analyzer.function.TelemetryFunction
Direct Known Subclasses:
AddFunction, DivFunction, FilterFunction, FilterZeroFunction, IdempotentFunction, MulFunction, SubFunction

public abstract class TelemetryFunction
extends java.lang.Object

Provides an abstract base class for telemetry functions. A telemetry function operates on an array of Number and/or TelemetryStreamCollection objects, and returns either a Number or a TelemetryStreamCollection object.

There will be exactly one instance of each implementation. Therefore, all implementation should be thread-safe.

Author:
(Cedric) Qin ZHANG

Constructor Summary
protected TelemetryFunction(java.lang.String name)
          Constructs this instance.
 
Method Summary
abstract  java.lang.Object compute(java.lang.Object[] parameters)
          Invokes the function.
 java.lang.String getName()
          The name of this function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TelemetryFunction

protected TelemetryFunction(java.lang.String name)
Constructs this instance.

Parameters:
name - The assigned name of this function.
Method Detail

getName

public java.lang.String getName()
The name of this function.

Returns:
The name.

compute

public abstract java.lang.Object compute(java.lang.Object[] parameters)
                                  throws TelemetryFunctionException
Invokes the function. Note that multiple thread might call this method at the same time. The implementation must be thread-safe.

Parameters:
parameters - An array of objects of type either String, Number, and/or TelemetryStreamCollection. Note: Since telemetry chart analyses might pass in parameter values as Strings, the implementation should be prepared to handle Strings even if it is expecting a number instance.
Returns:
Either an instance of Number or TelemetryStreamCollection.
Throws:
TelemetryFunctionException - If anything is wrong.