| 1 | package de.uka.ipd.sdq.probespec.framework; |
| 2 | |
| 3 | import java.util.Collection; |
| 4 | import java.util.Vector; |
| 5 | |
| 6 | import javax.measure.quantity.Quantity; |
| 7 | |
| 8 | import de.uka.ipd.sdq.probespec.framework.matching.IMatchRule; |
| 9 | |
| 10 | /** |
| 11 | * Represents a sample which is taken for a ProbeSet in a {@link RequestContext} |
| 12 | * . |
| 13 | * <p> |
| 14 | * The probe set sample is the result of a probe set measurement. It contains |
| 15 | * one or more probe samples; one for each probe assigned to the underlying |
| 16 | * probe set. In other words: The contained probe samples constitute the |
| 17 | * combined sample for the annotated model element which is named probe set |
| 18 | * sample. |
| 19 | * <p> |
| 20 | * A probe set (notice: not the resulting sample) encapsulates one or more |
| 21 | * probes whose results are taken for the identical model element which is |
| 22 | * annotated by the probe set. |
| 23 | * |
| 24 | * @author pmerkle |
| 25 | * @author Faber |
| 26 | */ |
| 27 | public class ProbeSetSample { |
| 28 | |
| 29 | private Collection<ProbeSample<?, ? extends Quantity>> probeSamples; |
| 30 | |
| 31 | private ProbeSetAndRequestContext probeSetAndRequestContext; |
| 32 | |
| 33 | /** The id of the annotated model element */ |
| 34 | private String modelElementID; |
| 35 | |
| 36 | /** |
| 37 | * Class constructor specifying the encapsulated probe samples, the context |
| 38 | * id, the model element id and the probe set id. |
| 39 | * |
| 40 | * @param probeSamples |
| 41 | * the probe samples to be encapsulated within this probe set |
| 42 | * sample |
| 43 | * @param ctxID |
| 44 | * the identifier for the context in which the contained probe |
| 45 | * samples have been taken |
| 46 | * @param modelElementID |
| 47 | * the id of the model element which is annotated by the |
| 48 | * underlying probe set |
| 49 | * @param probeSetID |
| 50 | * the id of the probe set according to the underlying model |
| 51 | * @see RequestContext |
| 52 | */ |
| 53 | public ProbeSetSample( |
| 54 | Vector<ProbeSample<?, ? extends Quantity>> probeSamples, |
| 55 | RequestContext ctxID, String modelElementID, Integer probeSetID) { |
| 56 | super(); |
| 57 | |
| 58 | this.probeSamples = probeSamples; |
| 59 | this.probeSetAndRequestContext = new ProbeSetAndRequestContext( |
| 60 | probeSetID, ctxID); |
| 61 | |
| 62 | // TODO modelElementId really needed? |
| 63 | this.modelElementID = modelElementID; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Returns the encapsulated probe samples satisfying the specified rule set. |
| 68 | * |
| 69 | * @param matchingRules |
| 70 | * the rule set |
| 71 | * @return |
| 72 | * @see ProbeSample |
| 73 | */ |
| 74 | public Vector<ProbeSample<?, ? extends Quantity>> getProbeSamples( |
| 75 | IMatchRule[] matchingRules) { |
| 76 | Vector<ProbeSample<?, ? extends Quantity>> res = new Vector<ProbeSample<?, ? extends Quantity>>(); |
| 77 | |
| 78 | for (ProbeSample<?, ? extends Quantity> sample : probeSamples) { |
| 79 | boolean match = true; |
| 80 | for (IMatchRule rule : matchingRules) { |
| 81 | match = match && rule.match(sample); |
| 82 | } |
| 83 | if (match) |
| 84 | res.add(sample); |
| 85 | } |
| 86 | |
| 87 | return res; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Returns the id of the model element which is annotated by the underlying |
| 92 | * probe set. |
| 93 | * |
| 94 | * @return the model element id |
| 95 | */ |
| 96 | public String getModelElementID() { |
| 97 | return modelElementID; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * This method returns the (ProbeSet, RequestContext)-pair for this sample. |
| 102 | * It indicates |
| 103 | * <ul> |
| 104 | * <li>from which ProbeSet the sample originates</li> |
| 105 | * <li>the {@link RequestContext} in which the sample has been taken</li> |
| 106 | * </ul> |
| 107 | * |
| 108 | * @return the originating ProbeSet and {@link RequestContext} |
| 109 | */ |
| 110 | public ProbeSetAndRequestContext getProbeSetAndRequestContext() { |
| 111 | return probeSetAndRequestContext; |
| 112 | } |
| 113 | |
| 114 | } |