| 1 | package de.uka.ipd.sdq.sensorframework.filter; |
| 2 | |
| 3 | import java.util.Collection; |
| 4 | import java.util.Properties; |
| 5 | |
| 6 | import de.uka.ipd.sdq.sensorframework.entities.Measurement; |
| 7 | |
| 8 | public class OutlierFilteredFactory implements IFilteredCollectionFactory { |
| 9 | |
| 10 | /** The properties settings for this filtered collection */ |
| 11 | protected Properties filterProperties = new Properties(); |
| 12 | |
| 13 | /** The property "outlier". */ |
| 14 | private static final String OUTLIER = "Outlier removal"; |
| 15 | /** Default outlier to use. */ |
| 16 | private static final double DEFAULT_OUTLIER = 0.1; |
| 17 | |
| 18 | /** |
| 19 | * Initializes a new OutlierFilteredFactory without properties. |
| 20 | */ |
| 21 | public OutlierFilteredFactory(){ |
| 22 | filterProperties.put(OUTLIER, DEFAULT_OUTLIER); |
| 23 | } |
| 24 | |
| 25 | /** {@inheritDoc} |
| 26 | */ |
| 27 | public AbstractMeasurementsCollection getFilteredCollection( |
| 28 | Collection<Measurement> filtrate) { |
| 29 | return new OutlierFilteredCollection(filtrate, DEFAULT_OUTLIER); |
| 30 | } |
| 31 | |
| 32 | /** {@inheritDoc} |
| 33 | */ |
| 34 | public Properties getProperties() { |
| 35 | return filterProperties; |
| 36 | } |
| 37 | |
| 38 | /** {@inheritDoc} |
| 39 | */ |
| 40 | public void setProperties(Properties newProperties) { |
| 41 | filterProperties = newProperties; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * {@inheritDoc} |
| 46 | */ |
| 47 | public boolean canFilter(Collection<Measurement> filtrate, Number attribute) { |
| 48 | return attribute.doubleValue() < 1.0; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * {@inheritDoc} |
| 53 | */ |
| 54 | public AbstractMeasurementsCollection getFilteredCollection( |
| 55 | Collection<Measurement> filtrate, Number parameter) { |
| 56 | filterProperties.put(OUTLIER, parameter.doubleValue()); |
| 57 | return new OutlierFilteredCollection(filtrate, parameter |
| 58 | .doubleValue()); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * {@inheritDoc} |
| 63 | */ |
| 64 | public String getFilterFactoryID() { |
| 65 | return "Outlier Filter"; |
| 66 | } |
| 67 | |
| 68 | /** {@inheritDoc} |
| 69 | */ |
| 70 | public Double convertToType(String type) { |
| 71 | return Double.parseDouble(type); |
| 72 | } |
| 73 | } |