<commit_before>package eu.fbk.mpba.sensorsflows;

import java.util.ArrayList;
import java.util.List;

import eu.fbk.mpba.sensorsflows.base.ISensor;
import eu.fbk.mpba.sensorsflows.base.ISensorDataCallback;
import eu.fbk.mpba.sensorsflows.base.SensorStatus;
import eu.fbk.mpba.sensorsflows.util.ReadOnlyIterable;

/**
 * This class adds internal support for the library data-paths.
 */
public abstract class SensorComponent<TimeT, ValueT> implements ISensor {
    protected DevicePlugin<TimeT, ValueT> _parent = null;
    protected ISensorDataCallback<SensorComponent<TimeT, ValueT>, TimeT, ValueT> _handler;
    protected ArrayList<OutputDecorator<TimeT, ValueT>> _outputs = new ArrayList<>();

    protected SensorComponent(DevicePlugin<TimeT, ValueT> parent) {
        _parent = parent;
    }

    private int mForwardedMessages = 0;
    private boolean mListened = true;
    protected SensorStatus mStatus = SensorStatus.OFF;

    void addOutput(OutputDecorator<TimeT, ValueT> _output) {
        _outputs.add(_output);
    }

    void setManager(ISensorDataCallback<SensorComponent<TimeT, ValueT>, TimeT, ValueT> man) {
        _handler = man;
    }

    Iterable<OutputDecorator<TimeT, ValueT>> getOutputs() {
        return new ReadOnlyIterable<>(_outputs.iterator());
    }

    // Managed protected getters setters

    protected void changeStatus(SensorStatus state) {
        _handler.sensorStateChanged(this, null, mStatus = state);
    }

    // Managed Overrides

    public int getForwardedMessagesCount() {
        return mForwardedMessages;
    }

    public int getReceivedMessagesCount() {
        return getForwardedMessagesCount();
    }

    public DevicePlugin<TimeT, ValueT> getParentDevicePlugin() {
        return _parent;
    }

    @Override
    public SensorStatus getState() {
        return mStatus;
    }

    // Notify methods

    public void sensorValue(TimeT time, ValueT value) {
        if (_handler != null) {
            _handler.sensorValue(this, time, value);
            mForwardedMessages++;
        }
    }

    public void sensorEvent(TimeT time, int type, String message) {
        if (_handler != null) {
            _handler.sensorEvent(this, time, type, message);
            mForwardedMessages++;
        }
    }

    // Listenage

    public boolean isListened() {
        return mListened;
    }

    public void setListened(boolean listened) {
        this.mListened = listened;
    }

    // To implement

    public abstract List<Object> getValuesDescriptors();
}
<commit_msg>Fixes in s/f<commit_after>package eu.fbk.mpba.sensorsflows;

import java.util.ArrayList;
import java.util.List;

import eu.fbk.mpba.sensorsflows.base.ISensor;
import eu.fbk.mpba.sensorsflows.base.ISensorDataCallback;
import eu.fbk.mpba.sensorsflows.base.SensorStatus;
import eu.fbk.mpba.sensorsflows.util.ReadOnlyIterable;

/**
 * This class adds internal support for the library data-paths.
 */
public abstract class SensorComponent<TimeT, ValueT> implements ISensor {
    protected DevicePlugin<TimeT, ValueT> _parent = null;
    protected ISensorDataCallback<SensorComponent<TimeT, ValueT>, TimeT, ValueT> _handler;
    protected ArrayList<OutputDecorator<TimeT, ValueT>> _outputs = new ArrayList<>();

    protected SensorComponent(DevicePlugin<TimeT, ValueT> parent) {
        _parent = parent;
    }

    private int mForwardedMessages = 0;
    private boolean mListened = true;
    protected SensorStatus mStatus = SensorStatus.OFF;

    void addOutput(OutputDecorator<TimeT, ValueT> _output) {
        _outputs.add(_output);
    }

    void setManager(ISensorDataCallback<SensorComponent<TimeT, ValueT>, TimeT, ValueT> man) {
        _handler = man;
    }

    Iterable<OutputDecorator<TimeT, ValueT>> getOutputs() {
        return new ReadOnlyIterable<>(_outputs.iterator());
    }

    // Managed protected getters setters

    protected void changeStatus(SensorStatus state) {
        _handler.sensorStateChanged(this, null, mStatus = state);
    }

    // Managed Overrides

    public int getForwardedMessagesCount() {
        return mForwardedMessages;
    }

    public int getReceivedMessagesCount() {
        return getForwardedMessagesCount();
    }

    public DevicePlugin<TimeT, ValueT> getParentDevicePlugin() {
        return _parent;
    }

    @Override
    public SensorStatus getState() {
        return mStatus;
    }

    public String getName() {
        return this.getClass().getSimpleName();
    }

    // Notify methods

    public void sensorValue(TimeT time, ValueT value) {
        if (_handler != null) {
            _handler.sensorValue(this, time, value);
            mForwardedMessages++;
        }
    }

    public void sensorEvent(TimeT time, int type, String message) {
        if (_handler != null) {
            _handler.sensorEvent(this, time, type, message);
            mForwardedMessages++;
        }
    }

    // Listenage

    public boolean isListened() {
        return mListened;
    }

    public void setListened(boolean listened) {
        this.mListened = listened;
    }

    // To implement

    public abstract List<Object> getValuesDescriptors();
}

{'fraction_non_alphanumeric': 0.09447900466562986, 'fraction_numerical': 0.00038880248833592535, 'mean_word_length': 3.070411392405063, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1220785', 'n_tokens_mistral': 1527, 'n_tokens_neox': 1490, 'n_words': 345}