View Javadoc

1   package com.google.code.jetm.reporting.xml;
2   
3   import java.util.Collections;
4   import java.util.Map;
5   
6   import etm.core.aggregation.Aggregate;
7   
8   /**
9    * An implementation of {@link Aggregate} to be used to marshal and unmarshal to
10   * and from XML.
11   * 
12   * @author jrh3k5
13   * 
14   */
15  
16  public class XmlAggregate implements Aggregate {
17      private final double min;
18      private final double max;
19      private final double total;
20      private final long measurements;
21      private final String name;
22  
23      /**
24       * Create an aggregate.
25       * 
26       * @param min
27       *            The minimum amount of time that occurred within a measurement
28       *            collection.
29       * @param max
30       *            The maximum amount of time that occurred within a measurement
31       *            collection.
32       * @param total
33       *            The total amount of time collected.
34       * @param measurements
35       *            The number of times the measurement was collected.
36       * @param name
37       *            The name of the measurement.
38       */
39      public XmlAggregate(double min, double max, double total, long measurements, String name) {
40          this.min = min;
41          this.max = max;
42          this.total = total;
43          this.name = name;
44          this.measurements = measurements;
45      }
46  
47      /**
48       * {@inheritDoc}
49       */
50      public double getAverage() {
51          return measurements == 0 ? 0 : total / (double) measurements;
52      }
53  
54      /**
55       * {@inheritDoc}
56       */
57      public Map<?, ?> getChilds() {
58          return Collections.emptyMap();
59      }
60  
61      /**
62       * {@inheritDoc}
63       */
64      public double getMax() {
65          return max;
66      }
67  
68      /**
69       * {@inheritDoc}
70       */
71      public long getMeasurements() {
72          return measurements;
73      }
74  
75      /**
76       * {@inheritDoc}
77       */
78      public double getMin() {
79          return min;
80      }
81  
82      /**
83       * {@inheritDoc}
84       */
85      public String getName() {
86          return name;
87      }
88  
89      /**
90       * {@inheritDoc}
91       */
92      public double getTotal() {
93          return total;
94      }
95  
96      /**
97       * {@inheritDoc}
98       */
99      public boolean hasChilds() {
100         return false;
101     }
102 
103 }