org.apache.jmeter.functions

## Interface Function

- All Known Implementing Classes:
    AbstractFunction, BeanShell, ChangeCase, CharFunction, CompoundVariable, CSVRead, DateTimeConvertFunction, DigestEncodeFunction, EscapeHtml, EscapeOroRegexpChars, EscapeXml, EvalFunction, EvalVarFunction, FileToString, Groovy, IntSum, IsPropDefined, IsVarDefined, IterationCounter, JavaScript, Jexl2Function, Jexl3Function, LogFunction, LogFunction2, LongSum, MachineIP, MachineName, Property, Property2, Random, RandomDate, RandomFromMultipleVars, RandomString, RegexFunction, SamplerName, SetProperty, SplitFunction, StringFromFile, StringToFile, TestPlanName, ThreadGroupName, ThreadNumber, TimeFunction, TimeShift, UnEscape, UnEscapeHtml, UrlDecode, UrlEncode, Uuid, Variable, XPath

      public interface Function

  Methods that a function must implement

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `execute(SampleResult previousResult, Sampler currentSampler)` Given the previous SampleResult and the current Sampler, return a string to use as a replacement value for the function call.
    `List<String>` | `getArgumentDesc()` Return a list of strings briefly describing each parameter your function takes.
    `String` | `getReferenceKey()` Return the name of your function.
    `void` | `setParameters(Collection<CompoundVariable> parameters)` A collection of the parameters used to configure your function.

- - ### Method Detail

    - #### execute

          String execute(SampleResult previousResult,
                         Sampler currentSampler)
                  throws InvalidVariableException

      Given the previous SampleResult and the current Sampler, return a string to use as a replacement value for the function call. Assume "setParameter" was previously called. This method must be threadsafe - multiple threads will be using the same object.
      Parameters:
        `previousResult` - The previous `SampleResult`
        `currentSampler` - The current `Sampler`
      Returns:
        The replacement value, which was generated by the function
      Throws:
        `InvalidVariableException` - - when the variables for the function call can't be evaluated

    - #### setParameters

          void setParameters(Collection<CompoundVariable> parameters)
                      throws InvalidVariableException

      A collection of the parameters used to configure your function. Each parameter is a CompoundVariable and can be resolved by calling the execute() method of the CompoundVariable (which should be done at execution.)
      Parameters:
        `parameters` - The parameters for the function call
      Throws:
        `InvalidVariableException` - - when the variables for the function call can't be evaluated

    - #### getReferenceKey

          String getReferenceKey()

      Return the name of your function. Convention is to prepend "__" to the name (ie "__regexFunction")
      Returns:
        The name of the function

    - #### getArgumentDesc

          List<String> getArgumentDesc()

      Return a list of strings briefly describing each parameter your function takes. Please use JMeterUtils.getResString(resource_name) to grab a resource string. Otherwise, your help text will be difficult to internationalize. This list is not optional. If you don't wish to write help, you must at least return a List containing the correct number of blank strings, one for each argument.
      Returns:
        List with brief descriptions for each parameter the function takes

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