Package org.apache.jmeter.threads

# Class JMeterContext

java.lang.Object
org.apache.jmeter.threads.JMeterContext

public class JMeterContext extends Object
Holds context for a thread. Generated by JMeterContextService.
The class is not thread-safe - it is only intended for use within a single thread.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `JMeterContext.TestLogicalAction`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `cleanAfterSample()`
  Clean cached data after sample Internally called by JMeter, never call it directly
  `void`
  `clear()`
  Internally called by JMeter, never call it directly
  `Sampler`
  `getCurrentSampler()`
  `StandardJMeterEngine`
  `getEngine()`
  `SampleResult`
  `getPreviousResult()`
  `Sampler`
  `getPreviousSampler()`
  Returns the previousSampler.
  `Properties`
  `getProperties()`
  `Map<String,Object>`
  `getSamplerContext()`
  Sampler context is cleaned up as soon as Post-Processor have ended
  `JMeterContext.TestLogicalAction`
  `getTestLogicalAction()`
  `JMeterThread`
  `getThread()`
  `AbstractThreadGroup`
  `getThreadGroup()`
  `int`
  `getThreadNum()`
  `JMeterVariables`
  `getVariables()`
  Gives access to the JMeter variables for the current thread.
  `boolean`
  `isRecording()`
  `boolean`
  `isRestartNextLoop()`
  Deprecated.
  use `isStartNextThreadLoop()`
  `boolean`
  `isSamplingStarted()`
  `boolean`
  `isStartNextThreadLoop()`
  Deprecated.
  use `getTestLogicalAction()`
  `void`
  `setCurrentSampler(Sampler sampler)`
  Internally called by JMeter, never call it directly
  `void`
  `setEngine(StandardJMeterEngine engine)`
  Internally called by JMeter, never call it directly
  `void`
  `setPreviousResult(SampleResult result)`
  Internally called by JMeter, never call it directly
  `void`
  `setRecording(boolean recording)`
  Internally called by JMeter, never call it directly
  `void`
  `setRestartNextLoop(boolean restartNextLoop)`
  Deprecated.
  use `setStartNextThreadLoop(boolean)`
  `void`
  `setSamplingStarted(boolean b)`
  Internally called by JMeter, never call it directly
  `void`
  `setStartNextThreadLoop(boolean restartNextLoop)`
  Deprecated.
  use `setTestLogicalAction(TestLogicalAction)`
  `void`
  `setTestLogicalAction(JMeterContext.TestLogicalAction actionOnExecution)`
  `void`
  `setThread(JMeterThread thread)`
  Internally called by JMeter, never call it directly
  `void`
  `setThreadGroup(AbstractThreadGroup threadgrp)`
  Internally called by JMeter, never call it directly
  `void`
  `setThreadNum(int threadNum)`
  Internally called by JMeter, never call it directly
  `void`
  `setVariables(JMeterVariables vars)`
  Internally called by JMeter, never call it directly

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

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

- ## Method Details

  - ### clear

    public void clear()
    Internally called by JMeter, never call it directly

  - ### getVariables

    public JMeterVariables getVariables()
    Gives access to the JMeter variables for the current thread.
    Returns:
      a pointer to the JMeter variables.

  - ### getProperties

    public Properties getProperties()
    Returns:
      a pointer to the JMeter Properties.

  - ### setVariables

    public void setVariables(JMeterVariables vars)
    Internally called by JMeter, never call it directly
    Parameters:
      `vars` - JMeterVariables

  - ### getPreviousResult

    public SampleResult getPreviousResult()

  - ### setPreviousResult

    public void setPreviousResult(SampleResult result)
    Internally called by JMeter, never call it directly
    Parameters:
      `result` - SampleResult

  - ### getCurrentSampler

    public Sampler getCurrentSampler()

  - ### setCurrentSampler

    public void setCurrentSampler(Sampler sampler)
    Internally called by JMeter, never call it directly
    Parameters:
      `sampler` - Sampler

  - ### getPreviousSampler

    public Sampler getPreviousSampler()
    Returns the previousSampler.
    Returns:
      Sampler

  - ### getThreadNum

    public int getThreadNum()
    Returns:
      the threadNum starting from zero (0)

  - ### setThreadNum

    public void setThreadNum(int threadNum)
    Internally called by JMeter, never call it directly
    Parameters:
      `threadNum` - number of threads

  - ### getThread

    public JMeterThread getThread()

  - ### setThread

    public void setThread(JMeterThread thread)
    Internally called by JMeter, never call it directly
    Parameters:
      `thread` - to use

  - ### getThreadGroup

    public AbstractThreadGroup getThreadGroup()

  - ### setThreadGroup

    public void setThreadGroup(AbstractThreadGroup threadgrp)
    Internally called by JMeter, never call it directly
    Parameters:
      `threadgrp` - ThreadGroup to use

  - ### getEngine

    public StandardJMeterEngine getEngine()

  - ### setEngine

    public void setEngine(StandardJMeterEngine engine)
    Internally called by JMeter, never call it directly
    Parameters:
      `engine` - to use

  - ### isSamplingStarted

    public boolean isSamplingStarted()

  - ### setSamplingStarted

    public void setSamplingStarted(boolean b)
    Internally called by JMeter, never call it directly
    Parameters:
      `b` - flag whether sampling has started

  - ### setTestLogicalAction

    public void setTestLogicalAction(JMeterContext.TestLogicalAction actionOnExecution)
    Parameters:
      `actionOnExecution` - action to take for next iteration of current loop in which this component is present

  - ### getTestLogicalAction

    public JMeterContext.TestLogicalAction getTestLogicalAction()
    Returns:
      TestLogicalAction to start next iteration of current loop in which this component is present

  - ### setStartNextThreadLoop

    @Deprecated public void setStartNextThreadLoop(boolean restartNextLoop)
    Deprecated.
    use `setTestLogicalAction(TestLogicalAction)`
    Parameters:
      `restartNextLoop` - if set to `true` a restart of the loop will occur

  - ### isStartNextThreadLoop

    @Deprecated public boolean isStartNextThreadLoop()
    Deprecated.
    use `getTestLogicalAction()`
    Returns:
      `true` when current loop iteration of Thread Group will be interrupted and JMeter will go to next iteration of the Thread Group loop

  - ### setRestartNextLoop

    @Deprecated public void setRestartNextLoop(boolean restartNextLoop)
    Deprecated.
    use `setStartNextThreadLoop(boolean)`
    if set to `true` current loop iteration will be interrupted and JMeter will go to next iteration
    Parameters:
      `restartNextLoop` - flag whether to restart

  - ### isRestartNextLoop

    @Deprecated public boolean isRestartNextLoop()
    Deprecated.
    use `isStartNextThreadLoop()`
    Returns:
      flag whether restart is set

  - ### cleanAfterSample

    public void cleanAfterSample()
    Clean cached data after sample Internally called by JMeter, never call it directly

  - ### getSamplerContext

    public Map<String,Object> getSamplerContext()
    Sampler context is cleaned up as soon as Post-Processor have ended
    Returns:
      Context to use within PostProcessors to cache data

  - ### setRecording

    public void setRecording(boolean recording)
    Internally called by JMeter, never call it directly
    Parameters:
      `recording` - flag whether recording should be done

  - ### isRecording

    public boolean isRecording()