<commit_before>package de.ptb.epics.eve.viewer.views.deviceinspectorview;

import java.util.Formatter;
import java.util.Locale;

import de.ptb.epics.eve.ecp1.client.interfaces.IMeasurementDataListener;
import de.ptb.epics.eve.ecp1.client.model.MeasurementData;
import de.ptb.epics.eve.ecp1.types.DataModifier;
import de.ptb.epics.eve.ecp1.types.DataType;
import de.ptb.epics.eve.viewer.Activator;

/**
 * <code>CommonTableElementEngineData</code>.
 * 
 * @author <NAME>
 * @author <NAME>
 */
public class CommonTableElementEngineData implements IMeasurementDataListener {
	
	private String dataId;
	private DataModifier datamodifier;
	private Boolean isActive;
	private String textvalue;
	private CommonTableElement tableElement;
	
	/**
	 * Constructs a <code>CommonTableElementEngineData</code<.
	 * 
	 * @param dataId the id of the data
	 * @param tableElement the 
	 * {@link de.ptb.epics.eve.viewer.views.deviceinspectorview.CommonTableElement}
	 * 		the data corresponds to
	 */
	public CommonTableElementEngineData(String dataId, CommonTableElement tableElement) {
		this.dataId = dataId;
		this.tableElement = tableElement;
		Activator.getDefault().getEcp1Client().addMeasurementDataListener(this);
		datamodifier = DataModifier.UNMODIFIED;
		isActive = true;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected void finalize() throws Throwable {
		Activator.getDefault().getEcp1Client()
				.removeMeasurementDataListener(this);
		super.finalize();
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void measurementDataTransmitted(final MeasurementData measurementData) {
		if (!isActive || measurementData == null || dataId == null) {
			return;
		}
		
		if (this.dataId.equals(measurementData.getName()) && 
			(measurementData.getDataModifier() == datamodifier)) {
			if (measurementData.getDataType() == DataType.DOUBLE) {
				Double value = (Double) measurementData.getValues().get(0);
				Formatter formatter = new Formatter(
						new Locale(Locale.ENGLISH.getCountry()));
				textvalue = formatter.format("%12.4g", value).out().
						toString();
				formatter.close();
			} else if 
				(measurementData.getDataType() == DataType.FLOAT) {
					Float value = (float) measurementData.getValues().get(0);
					Formatter formatter = new Formatter(
							new Locale(Locale.ENGLISH.getCountry()));
					textvalue = formatter.format("%12.4g", value).out().
							toString();
					formatter.close();
			} else {
				textvalue = measurementData.getValues().get( 0 ).toString();
			}
			tableElement.update();
		}
	}
	
	/**
	 * 
	 * @param dataId
	 */
	public void setDataId(String dataId) {
		this.dataId = dataId;
	}

	/**
	 * 
	 * @return
	 */
	public String getValue() {
		return textvalue;
	}
<commit_msg>cast to object (not primitive float)<commit_after>package de.ptb.epics.eve.viewer.views.deviceinspectorview;

import java.util.Formatter;
import java.util.Locale;

import de.ptb.epics.eve.ecp1.client.interfaces.IMeasurementDataListener;
import de.ptb.epics.eve.ecp1.client.model.MeasurementData;
import de.ptb.epics.eve.ecp1.types.DataModifier;
import de.ptb.epics.eve.ecp1.types.DataType;
import de.ptb.epics.eve.viewer.Activator;

/**
 * <code>CommonTableElementEngineData</code>.
 * 
 * @author <NAME>
 * @author <NAME>
 */
public class CommonTableElementEngineData implements IMeasurementDataListener {
	
	private String dataId;
	private DataModifier datamodifier;
	private Boolean isActive;
	private String textvalue;
	private CommonTableElement tableElement;
	
	/**
	 * Constructs a <code>CommonTableElementEngineData</code<.
	 * 
	 * @param dataId the id of the data
	 * @param tableElement the 
	 * {@link de.ptb.epics.eve.viewer.views.deviceinspectorview.CommonTableElement}
	 * 		the data corresponds to
	 */
	public CommonTableElementEngineData(String dataId, CommonTableElement tableElement) {
		this.dataId = dataId;
		this.tableElement = tableElement;
		Activator.getDefault().getEcp1Client().addMeasurementDataListener(this);
		datamodifier = DataModifier.UNMODIFIED;
		isActive = true;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected void finalize() throws Throwable {
		Activator.getDefault().getEcp1Client()
				.removeMeasurementDataListener(this);
		super.finalize();
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void measurementDataTransmitted(final MeasurementData measurementData) {
		if (!isActive || measurementData == null || dataId == null) {
			return;
		}
		
		if (this.dataId.equals(measurementData.getName()) && 
			(measurementData.getDataModifier() == datamodifier)) {
			if (measurementData.getDataType() == DataType.DOUBLE) {
				Double value = (Double) measurementData.getValues().get(0);
				Formatter formatter = new Formatter(
						new Locale(Locale.ENGLISH.getCountry()));
				textvalue = formatter.format("%12.4g", value).out().
						toString();
				formatter.close();
			} else if 
				(measurementData.getDataType() == DataType.FLOAT) {
					Float value = (Float) measurementData.getValues().get(0);
					Formatter formatter = new Formatter(
							new Locale(Locale.ENGLISH.getCountry()));
					textvalue = formatter.format("%12.4g", value).out().
							toString();
					formatter.close();
			} else {
				textvalue = measurementData.getValues().get( 0 ).toString();
			}
			tableElement.update();
		}
	}
	
	/**
	 * 
	 * @param dataId
	 */
	public void setDataId(String dataId) {
		this.dataId = dataId;
	}

	/**
	 * 
	 * @return
	 */
	public String getValue() {
		return textvalue;
	}

{'fraction_non_alphanumeric': 0.13018833424757725, 'fraction_numerical': 0.005485463521667581, 'mean_word_length': 4.036832412523021, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, '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': '1096149', 'n_tokens_mistral': 1978, 'n_tokens_neox': 1736, 'n_words': 323}