Class Sample

java.lang.Object
org.apache.jmeter.report.core.Sample

public class Sample extends Object
Represents a sample read from a CSV source.

Getters with a string parameter are implemented for convenience but should be avoided as they are inefficient

Since:
3.0
  • Constructor Details

    • Sample

      public Sample(long row, SampleMetadata metadata, String... data)
      Build a sample from a string array
      Parameters:
      row - the row number in the CSV source from which this sample is built
      metadata - The sample metadata (contains column names)
      data - The sample data as a string array
  • Method Details

    • getSampleRow

      public long getSampleRow()
      Returns:
      the row number from the CSV source from which this sample has been built.
    • getData

      public String getData(int index)
      Gets the data stored in the column with the specified rank.
      Parameters:
      index - the rank of the column
      Returns:
      the data of the column
    • getData

      public String getData(String name)
      Gets the data stored in the column with the specified name.
      Parameters:
      name - the name of the column
      Returns:
      the data of the column
    • getData

      public <T> T getData(Class<T> clazz, int index, String fieldName)
      Gets the data of the column matching the specified rank and converts it to an alternative type.
      Type Parameters:
      T - type of data to be fetched
      Parameters:
      clazz - the target class of the data
      index - the rank of the column
      fieldName - Field name
      Returns:
      the converted value of the data
    • getData

      public <T> T getData(Class<T> clazz, String name)
      Gets the data of the column matching the specified name and converts it to an alternative type.
      Type Parameters:
      T - type of data to be fetched
      Parameters:
      clazz - the target class of the data
      name - the name of the column
      Returns:
      the converted value of the data
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getTimestamp

      public long getTimestamp()
      Gets the time stamp stored in the sample.
      Returns:
      the time stamp
    • getElapsedTime

      public long getElapsedTime()
      Gets the elapsed time stored in the sample.
      Returns:
      the elapsed time stored in the sample
    • getStartTime

      public long getStartTime()

      Gets the start time of the sample.

      Start time depends on sampleresult.timestamp.start property :

      • If the property is true, this method returns the time stamp stored in the sample.
      • If the property is false, this method returns the time stamp stored in the sample minus the elapsed time.
      Returns:
      the start time
    • getEndTime

      public long getEndTime()

      Gets the end time of the sample.

      End time depends on jmeter.timestamp.start property :

      • If the property is true, this method returns the time stamp recorded in the sample plus the elapsed time.
      • If the property is false, this method returns the time stamp recorded.
      Returns:
      the end time
    • getResponseCode

      public String getResponseCode()
      Gets the response code stored in the sample.
      Returns:
      the response code stored in the sample
    • getFailureMessage

      public String getFailureMessage()
      Gets the failure message stored in the sample.
      Returns:
      the failure message stored in the sample
    • getName

      public String getName()
      Gets the name stored in the sample.
      Returns:
      the name stored in the sample
    • getResponseMessage

      public String getResponseMessage()
      Gets the response message stored in the sample.
      Returns:
      the response message stored in the sample
    • getLatency

      public long getLatency()
      Gets the latency stored in the sample.
      Returns:
      the latency stored in the sample
    • getConnectTime

      public long getConnectTime()
      Gets the connect time stored in the sample.
      Returns:
      the connect time stored in the sample or 0 is column is not in results
    • getSuccess

      public boolean getSuccess()
      Gets the success status stored in the sample.
      Returns:
      the success status stored in the sample
    • getReceivedBytes

      public long getReceivedBytes()
      Gets the number of received bytes stored in the sample.
      Returns:
      the number of received bytes stored in the sample
    • getSentBytes

      public long getSentBytes()
      Gets the number of sent bytes stored in the sample. If column is not in results, we return 0
      Returns:
      the number of sent bytes stored in the sample
    • getGroupThreads

      public int getGroupThreads()
      Gets the number of threads in the group of this sample.
      Returns:
      the number of threads in the group of this sample
    • getAllThreads

      public int getAllThreads()
      Gets the overall number of threads.
      Returns:
      the overall number of threads
    • getThreadName

      public String getThreadName()
      Gets the thread name stored in the sample.
      Returns:
      the thread name stored in the sample
    • isController

      public boolean isController()
      Checks if this sample is a controller.
      Returns:
      true, if this sample is a controller; otherwise false
    • isEmptyController

      public boolean isEmptyController()
      Checks if this sample is an empty controller.
      Returns:
      true, if this sample is a controller; otherwise false