Package org.apache.jmeter.report.processor

# Class AbstractSampleConsumer

java.lang.Object
org.apache.jmeter.report.processor.AbstractSampleProcessor
org.apache.jmeter.report.processor.AbstractSampleConsumer

All Implemented Interfaces:
  `SampleConsumer`, `SampleProcessor`, `SampleProducer`

Direct Known Subclasses:
  `AbstractGraphConsumer`, `AbstractSummaryConsumer`, `AggregateConsumer`, `ExternalSampleSorter`, `FilterConsumer`, `NormalizerSampleConsumer`, `RequestsSummaryConsumer`, `SampleWriterConsumer`, `TaggerConsumer`

public abstract class AbstractSampleConsumer extends AbstractSampleProcessor implements SampleConsumer, SampleProducer
Base class for sample consumer implementations.
Every sample consumer should extends this class to support basic consumer features.

Since:
  3.0

## Constructor Summary

Constructors
Constructor
Description
`AbstractSampleConsumer()`

## Method Summary

Modifier and Type
Method
Description
`void`
`addSampleConsumer(SampleConsumer consumer)`
`int`
`getConsumedChannelCount()`
`SampleMetadata`
`getConsumedMetadata(int channel)`
`protected SampleConsumer`
`getConsumer(int i)`
`protected final Object`
`getDataFromContext(String key)`
Gets the data identified by the specified key from the current sample context
`String`
`getName()`
Gets the name of the consumer.
`final File`
`getWorkingDirectory()`
`void`
`produce(Sample s, int channel)`
Produce a single sample on the specified channel
`void`
`removeSampleConsumer(SampleConsumer consumer)`
`void`
`setChannelAttribute(int channel, String key, Object value)`
Associate an attribute to the specified channel for this sample processor
If the attribute already exist, it is replaced.
`void`
`setConsumedMetadata(SampleMetadata sampleMetadata, int channel)`
Set the metadata of samples that will be consumed on the specified channel.
`protected final void`
`setDataToContext(String key, Object value)`
Store data in the current sample context with the specified key identifier.
`void`
`setName(String name)`
Sets the name of the consumer.
`void`
`setProducedMetadata(SampleMetadata metadata, int channel)`
Set the metadata associated with the specified channel
`void`
`setSampleConsumer(SampleConsumer consumer)`
`void`
`setSampleConsumers(List<SampleConsumer> consumers)`
Sets the consumers
`void`
`setSampleContext(SampleContext sampleContext)`
Set sample context that this consumer should rely on.
`void`
`startProducing()`
Start producing samples, must be invoked before any call to `produce()`
`void`
`stopProducing()`
Stop producing samples, no `produce()` call should occur after this service has been called.

### Methods inherited from class org.apache.jmeter.report.processor.AbstractSampleProcessor

`getChannelAttribute, getSampleContext`

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

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

### Methods inherited from interface org.apache.jmeter.report.processor.SampleConsumer

`consume, startConsuming, stopConsuming`

### Methods inherited from interface org.apache.jmeter.report.processor.SampleProcessor

`getChannelAttribute, getSampleContext`

## Constructor Details

### AbstractSampleConsumer

public AbstractSampleConsumer()

## Method Details

### getDataFromContext

protected final Object getDataFromContext(String key)
Gets the data identified by the specified key from the current sample context

Parameters:
  `key` - the key
Returns:
  the data

### setDataToContext

protected final void setDataToContext(String key, Object value)
Store data in the current sample context with the specified key identifier.

Parameters:
  `key` - the key
  `value` - the value

### getName

public String getName()
Gets the name of the consumer.

Returns:
  the name of the consumer

### setName

public void setName(String name)
Sets the name of the consumer.

Parameters:
  `name` - the new name

### getWorkingDirectory

public final File getWorkingDirectory()

### setSampleContext

public void setSampleContext(SampleContext sampleContext)
Description copied from interface: `SampleProcessor`
Set sample context that this consumer should rely on.

Specified by:
  `setSampleContext` in interface `SampleProcessor`
Overrides:
  `setSampleContext` in class `AbstractSampleProcessor`
Parameters:
  `sampleContext` - the new sample context

### setSampleConsumers

public void setSampleConsumers(List<SampleConsumer> consumers)
Sets the consumers

Parameters:
  `consumers` - for the samples (must not be `null`)

### addSampleConsumer

public void addSampleConsumer(SampleConsumer consumer)

### setSampleConsumer

public void setSampleConsumer(SampleConsumer consumer)

### removeSampleConsumer

public void removeSampleConsumer(SampleConsumer consumer)

### setConsumedMetadata

public void setConsumedMetadata(SampleMetadata sampleMetadata, int channel)
Description copied from interface: `SampleConsumer`
Set the metadata of samples that will be consumed on the specified channel.

Specified by:
  `setConsumedMetadata` in interface `SampleConsumer`
Parameters:
  `sampleMetadata` - The sample metadata that are being consumed for the associated channel
  `channel` - The channel whose sample metadata are being defined

### getConsumedMetadata

public SampleMetadata getConsumedMetadata(int channel)

### getConsumedChannelCount

public int getConsumedChannelCount()

### setChannelAttribute

public void setChannelAttribute(int channel, String key, Object value)
Description copied from interface: `SampleProcessor`
Associate an attribute to the specified channel for this sample processor
If the attribute already exist, it is replaced.

Specified by:
  `setChannelAttribute` in interface `SampleProcessor`
Overrides:
  `setChannelAttribute` in class `AbstractSampleProcessor`
Parameters:
  `channel` - The channel number to associate the attribute on
  `key` - The attribute key
  `value` - The attribute value to be set

### setProducedMetadata

public void setProducedMetadata(SampleMetadata metadata, int channel)
Description copied from interface: `SampleProducer`
Set the metadata associated with the specified channel

Specified by:
  `setProducedMetadata` in interface `SampleProducer`
Parameters:
  `metadata` - The metadata to be associated to the specified channel
  `channel` - The channel whoses metadata are being associated with

### getConsumer

protected SampleConsumer getConsumer(int i)

### startProducing

public void startProducing()
Description copied from interface: `SampleProducer`
Start producing samples, must be invoked before any call to `produce()`

Specified by:
  `startProducing` in interface `SampleProducer`

### produce

public void produce(Sample s, int channel)
Description copied from interface: `SampleProducer`
Produce a single sample on the specified channel

Specified by:
  `produce` in interface `SampleProducer`
Parameters:
  `s` - The sample produced
  `channel` - The channel on which is produced the sample

### stopProducing

public void stopProducing()
Description copied from interface: `SampleProducer`
Stop producing samples, no `produce()` call should occur after this service has been called.

Specified by:
  `stopProducing` in interface `SampleProducer`