| 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 WarmupFilteredFactory implements IFilteredCollectionFactory { |
| 9 | |
| 10 | /** The properties settings for this filtered collection */ |
| 11 | protected Properties filterProperties = new Properties(); |
| 12 | |
| 13 | /** The property "warm up". */ |
| 14 | public static final String WARMUP = "Warm Up"; |
| 15 | /** Default warm up to use. */ |
| 16 | public static final long DEFAULT_WARMUP = 2500L; |
| 17 | |
| 18 | /** |
| 19 | * Initializes a new WarmupFilteredFactory without properties. |
| 20 | */ |
| 21 | public WarmupFilteredFactory() { |
| 22 | filterProperties.put(WARMUP, DEFAULT_WARMUP); |
| 23 | } |
| 24 | |
| 25 | /** {@inheritDoc} |
| 26 | */ |
| 27 | public AbstractMeasurementsCollection getFilteredCollection( |
| 28 | Collection<Measurement> filtrate) { |
| 29 | return new WarmupFilteredCollection(filtrate, DEFAULT_WARMUP); |
| 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, |
| 48 | Number attribute) { |
| 49 | return attribute.longValue() < filtrate.size(); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * {@inheritDoc} |
| 54 | */ |
| 55 | public AbstractMeasurementsCollection getFilteredCollection( |
| 56 | Collection<Measurement> filtrate, Number parameter) { |
| 57 | filterProperties.put(WARMUP, parameter.longValue()); |
| 58 | return new WarmupFilteredCollection(filtrate, parameter.longValue()); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * {@inheritDoc} |
| 63 | */ |
| 64 | public String getFilterFactoryID() { |
| 65 | return "Warm Up Filter"; |
| 66 | } |
| 67 | |
| 68 | /** {@inheritDoc} |
| 69 | */ |
| 70 | public Long convertToType(String type) { |
| 71 | return Long.parseLong(type); |
| 72 | } |
| 73 | } |