org.apache.jmeter.samplers

## Class SampleEvent

- java.lang.Object
- - org.apache.jmeter.samplers.SampleEvent

- All Implemented Interfaces:
    java.io.Serializable

      public class SampleEvent
      extends java.lang.Object
      implements java.io.Serializable

  Packages information regarding the target of a sample event, such as the result from that event and the thread group it ran in.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `HOSTNAME`
    `static java.lang.String` | `SAMPLE_VARIABLES` The property "sample_variables" is used to define additional variables to be saved

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SampleEvent()` Constructor used for Unit tests only.
    `SampleEvent(SampleResult result, java.lang.String threadGroup)` Creates SampleEvent without saving any variables.
    `SampleEvent(SampleResult result, java.lang.String threadGroup, JMeterVariables jmvars)` Constructor used for normal samples, saves variable values if any are defined.
    `SampleEvent(SampleResult result, java.lang.String threadGroup, JMeterVariables jmvars, boolean isTransactionSampleEvent)`
    `SampleEvent(SampleResult result, java.lang.String threadGroup, java.lang.String hostname)` Only intended for use when loading results from a file.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getHostname()` Get the name of the host for which this event was recorded
    `SampleResult` | `getResult()` Get the `SampleResult` associated with this event
    `java.lang.String` | `getThreadGroup()` Get the name of the thread group for which this event was recorded
    `static int` | `getVarCount()` Get the number of defined variables
    `static java.lang.String` | `getVarName(int i)` Get the nth variable name (zero-based)
    `java.lang.String` | `getVarValue(int i)` Get the nth variable value (zero-based)
    `static void` | `initSampleVariables()` Set up the additional variable names to be saved from the value in the `SAMPLE_VARIABLES` property
    `boolean` | `isTransactionSampleEvent()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SAMPLE_VARIABLES

          public static final java.lang.String SAMPLE_VARIABLES

      The property "sample_variables" is used to define additional variables to be saved
      See Also:
        Constant Field Values

    - #### HOSTNAME

          public static final java.lang.String HOSTNAME

  - ### Constructor Detail

    - #### SampleEvent

          public SampleEvent()

      Constructor used for Unit tests only. Uses `null` for the associated `SampleResult` and the `threadGroup`-name.

    - #### SampleEvent

          public SampleEvent(SampleResult result,
                             java.lang.String threadGroup)

      Creates SampleEvent without saving any variables.

      Use by `ProxyControl` and `StatisticalSampleSender`.

      Parameters:
        `result` - The SampleResult to be associated with this event
        `threadGroup` - The name of the thread, the `SampleResult` was recorded

    - #### SampleEvent

          public SampleEvent(SampleResult result,
                             java.lang.String threadGroup,
                             JMeterVariables jmvars)

      Constructor used for normal samples, saves variable values if any are defined.
      Parameters:
        `result` - The SampleResult to be associated with this event
        `threadGroup` - The name of the thread, the `SampleResult` was recorded
        `jmvars` - the `JMeterVariables` of the thread, the `SampleResult` was recorded

    - #### SampleEvent

          public SampleEvent(SampleResult result,
                             java.lang.String threadGroup,
                             java.lang.String hostname)

      Only intended for use when loading results from a file.
      Parameters:
        `result` - The SampleResult to be associated with this event
        `threadGroup` - The name of the thread, the `SampleResult` was recorded
        `hostname` - The name of the host, for which the `SampleResult` was recorded

    - #### SampleEvent

          public SampleEvent(SampleResult result,
                             java.lang.String threadGroup,
                             JMeterVariables jmvars,
                             boolean isTransactionSampleEvent)

      Parameters:
        `result` - The SampleResult to be associated with this event
        `threadGroup` - The name of the thread, the `SampleResult` was recorded
        `jmvars` - the `JMeterVariables` of the thread, the `SampleResult` was recorded
        `isTransactionSampleEvent` - Flag whether this event is an transaction sample event

  - ### Method Detail

    - #### initSampleVariables

          public static void initSampleVariables()

      Set up the additional variable names to be saved from the value in the `SAMPLE_VARIABLES` property

    - #### getVarCount

          public static int getVarCount()

      Get the number of defined variables
      Returns:
        the number of variables defined

    - #### getVarName

          public static java.lang.String getVarName(int i)

      Get the nth variable name (zero-based)
      Parameters:
        `i` - specifies which variable name should be returned (zero-based)
      Returns:
        the variable name of the nth variable

    - #### getVarValue

          public java.lang.String getVarValue(int i)

      Get the nth variable value (zero-based)
      Parameters:
        `i` - specifies which variable value should be returned (zero-based)
      Returns:
        the value of the nth variable
      Throws:
        `JMeterError` - when an invalid index `i` was given

    - #### getResult

          public SampleResult getResult()

      Get the `SampleResult` associated with this event
      Returns:
        the associated `SampleResult`

    - #### getThreadGroup

          public java.lang.String getThreadGroup()

      Get the name of the thread group for which this event was recorded
      Returns:
        the name of the thread group

    - #### getHostname

          public java.lang.String getHostname()

      Get the name of the host for which this event was recorded
      Returns:
        the name of the host

    - #### isTransactionSampleEvent

          public boolean isTransactionSampleEvent()

      Returns:
        the isTransactionSampleEvent

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