| 1 | package de.uka.ipd.sdq.sensorframework.entities.impl; |
| 2 | |
| 3 | import de.uka.ipd.sdq.sensorframework.entities.dao.IDAOFactory; |
| 4 | |
| 5 | @javax.persistence.Entity |
| 6 | public class TimeSpanMeasurementImpl extends de.uka.ipd.sdq.sensorframework.entities.base.AbstractTimeSpanMeasurement { |
| 7 | |
| 8 | /** Difference up to which two values are considered as equal. |
| 9 | */ |
| 10 | public static final double EPSILON_ERROR = 1e-5; |
| 11 | |
| 12 | public TimeSpanMeasurementImpl(IDAOFactory myFactory) { |
| 13 | super(myFactory); |
| 14 | } |
| 15 | |
| 16 | /** {@inheritDoc} |
| 17 | */ |
| 18 | public void setTimeSpan(double value) { |
| 19 | if (value < -EPSILON_ERROR) |
| 20 | throw new RuntimeException("TimeSpan Measurements are not allowed to be smaller than 0."); |
| 21 | if (value < 0) |
| 22 | value = 0; |
| 23 | |
| 24 | super.setTimeSpan(value); |
| 25 | } |
| 26 | |
| 27 | /* (non-Javadoc) |
| 28 | * @see java.lang.Object#toString() |
| 29 | */ |
| 30 | public String toString(){ |
| 31 | return "TimeSpanMeasurementImpl: ID="+this.getMeasurementID()+", " + |
| 32 | "eventTime="+this.getEventTime()+", timeSpan="+this.getTimeSpan(); |
| 33 | } |
| 34 | } |