Apache JMeter

org.apache.jmeter.functions
Class AbstractFunction

java.lang.Object
  extended by org.apache.jmeter.functions.AbstractFunction
All Implemented Interfaces:
Function
Direct Known Subclasses:
BeanShell, CharFunction, CSVRead, EscapeHtml, EvalFunction, EvalVarFunction, FileToString, IntSum, IterationCounter, JavaScript, Jexl2Function, JexlFunction, LogFunction, LogFunction2, LongSum, MachineIP, MachineName, Property, Property2, Random, RandomString, RegexFunction, SamplerName, SetProperty, SplitFunction, StringFromFile, TestPlanName, ThreadNumber, TimeFunction, UnEscape, UnEscapeHtml, Variable, XPath

public abstract class AbstractFunction
extends Object
implements Function

Provides common methods for all functions


Constructor Summary
AbstractFunction()
           
 
Method Summary
protected  void checkMinParameterCount(Collection<CompoundVariable> parameters, int minimum)
          Utility method to check parameter counts.
protected  void checkParameterCount(Collection<CompoundVariable> parameters, int count)
          Utility method to check parameter counts.
protected  void checkParameterCount(Collection<CompoundVariable> parameters, int min, int max)
          Utility method to check parameter counts.
 String execute()
           
abstract  String execute(SampleResult previousResult, Sampler currentSampler)
           N.B. setParameters() and execute() are called from different threads, so both must be synchronized unless there are no parameters to save
abstract  String getReferenceKey()
          Return the name of your function.
protected  JMeterVariables getVariables()
          Gives access to the JMeter variables for the current thread.
abstract  void setParameters(Collection<CompoundVariable> parameters)
           N.B. setParameters() and execute() are called from different threads, so both must be synchronized unless there are no parameters to save
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jmeter.functions.Function
getArgumentDesc
 

Constructor Detail

AbstractFunction

public AbstractFunction()
Method Detail

execute

public abstract String execute(SampleResult previousResult,
                               Sampler currentSampler)
                        throws InvalidVariableException

N.B. setParameters() and execute() are called from different threads, so both must be synchronized unless there are no parameters to save

Specified by:
execute in interface Function
Throws:
InvalidVariableException
See Also:
Function.execute(SampleResult, Sampler)

execute

public String execute()
               throws InvalidVariableException
Throws:
InvalidVariableException

setParameters

public abstract void setParameters(Collection<CompoundVariable> parameters)
                            throws InvalidVariableException

N.B. setParameters() and execute() are called from different threads, so both must be synchronized unless there are no parameters to save

Specified by:
setParameters in interface Function
Throws:
InvalidVariableException
See Also:

Note: This is always called even if no parameters are provided (versions of JMeter after 2.3.1)

getReferenceKey

public abstract String getReferenceKey()
Description copied from interface: Function
Return the name of your function. Convention is to prepend "__" to the name (ie "__regexFunction")

Specified by:
getReferenceKey in interface Function
See Also:
Function.getReferenceKey()

getVariables

protected JMeterVariables getVariables()
Gives access to the JMeter variables for the current thread.

Returns:
a pointer to the JMeter variables.

checkParameterCount

protected void checkParameterCount(Collection<CompoundVariable> parameters,
                                   int min,
                                   int max)
                            throws InvalidVariableException
Utility method to check parameter counts.

Parameters:
parameters - collection of parameters
min - minimum number of parameters allowed
max - maximum number of parameters allowed
Throws:
InvalidVariableException - if the number of parameters is incorrect

checkParameterCount

protected void checkParameterCount(Collection<CompoundVariable> parameters,
                                   int count)
                            throws InvalidVariableException
Utility method to check parameter counts.

Parameters:
parameters - collection of parameters
count - number of parameters expected
Throws:
InvalidVariableException - if the number of parameters is incorrect

checkMinParameterCount

protected void checkMinParameterCount(Collection<CompoundVariable> parameters,
                                      int minimum)
                               throws InvalidVariableException
Utility method to check parameter counts.

Parameters:
parameters - collection of parameters
minimum - number of parameters expected
Throws:
InvalidVariableException - if the number of parameters is incorrect

Apache JMeter

Copyright © 1998-2012 Apache Software Foundation. All Rights Reserved.