Package org.apache.jmeter.control

# Class SwitchController

java.lang.Object
org.apache.jmeter.testelement.AbstractTestElement
org.apache.jmeter.control.GenericController
org.apache.jmeter.control.SwitchController

All Implemented Interfaces:
  `Serializable`, `Cloneable`, `Controller`, `Searchable`, `org.apache.jmeter.testelement.TestElement`, `TestCompilerHelper`

public class SwitchController extends GenericController implements Serializable

Implements a controller which selects at most one of its children based on the condition value, which may be a number or a string.

For numeric input, the controller processes the appropriate child, where the numbering starts from 0. If the number is out of range, then the first (0th) child is selected. If the condition is the empty string, then it is assumed to be 0.

For non-empty non-numeric input, the child is selected by name. This may be the name of the controller or a sampler. If the string does not match any of the names, then the controller with the name "default" (any case) is processed. If there is no default entry, then unlike the numeric case, no child is selected.

See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface org.apache.jmeter.testelement.TestElement

  `org.apache.jmeter.testelement.TestElement.Companion`

- ## Field Summary

  ### Fields inherited from class org.apache.jmeter.control.GenericController

  `current, subControllersAndSamplers`

  ### Fields inherited from interface org.apache.jmeter.testelement.TestElement

  `COMMENTS, Companion, ENABLED, GUI_CLASS, NAME, TEST_CLASS`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SwitchController()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getSelection()`
  `protected void`
  `incrementCurrent()`
  incrementCurrent is called when the current child (whether sampler or controller) has been processed.
  `Sampler`
  `next()`
  Determines the next sampler to be processed.
  `void`
  `setSelection(String inputValue)`

  ### Methods inherited from class org.apache.jmeter.control.GenericController

  `addIterationListener, addTestElement, addTestElementOnce, currentReturnedNull, fireIterationStart, fireIterEvents, getCurrentElement, getIterCount, getProps, getSchema, getSubControllers, incrementIterCount, initialize, initializeSubControllers, isDone, isFirst, nextIsAController, nextIsASampler, nextIsNull, readResolve, reInitialize, removeCurrentElement, removeIterationListener, resetCurrent, resetIterCount, setCurrentElement, setDone, setFirst, triggerEndOfLoop`

  ### Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

  `addPropertiesValues, addProperty, addProperty, canRemove, clear, clearTemporary, clearTestElementChildren, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getPropertyOrNull, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty`

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

  `finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.apache.jmeter.testelement.TestElement

  `canRemove, clear, clearTestElementChildren, clone, get, get, get, get, get, get, get, get, get, getComment, getName, getOrCreate, getOrCreate, getOrNull, getOrNull, getOrNull, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getPropertyOrNull, getPropertyOrNull, getString, getThreadContext, getThreadName, isEnabled, isRunningVersion, isTemporary, propertyIterator, recoverRunningVersion, removed, removeProperty, removeProperty, set, set, set, set, set, set, set, set, set, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse`

- ## Constructor Details

  - ### SwitchController

    public SwitchController()

- ## Method Details

  - ### next

    public Sampler next()
    Description copied from class: `GenericController`

    Determines the next sampler to be processed.

    If `GenericController.isDone()` is `true`, returns null.

    Gets the list element using current pointer. If this is `null`, calls `GenericController.nextIsNull()`.

    If the list element is a `Sampler`, calls `GenericController.nextIsASampler(Sampler)`, otherwise calls `GenericController.nextIsAController(Controller)`

    If any of the called methods throws `NextIsNullException`, returns `null`, otherwise the value obtained above is returned.

    Specified by:
      `next` in interface `Controller`
    Overrides:
      `next` in class `GenericController`
    Returns:
      the next sampler or `null`

  - ### incrementCurrent

    protected void incrementCurrent()
    incrementCurrent is called when the current child (whether sampler or controller) has been processed.

    Setting it to int.max marks the controller as having processed all its children. Thus the controller processes one child per iteration.

    Increments the current pointer; called by currentReturnedNull to move the controller on to its next child.

    Overrides:
      `incrementCurrent` in class `GenericController`

  - ### setSelection

    public void setSelection(String inputValue)

  - ### getSelection

    public String getSelection()