1 /*
2 * Copyright 2005 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package net.sf.sensor.meter;
18
19 /***
20 *
21 *
22 */
23 public class Meter {
24
25 // ==========================================================================
26 // Fields
27 // ==========================================================================
28
29 /*** The TimerData that will be fed with data from the new Timer instance. */
30 private MeterData meterData = null;
31
32
33 // ==========================================================================
34 // Constructors
35 // ==========================================================================
36
37 /***
38 * Constructs a new Meter instance for the specified MeterData.
39 * Package private since only MeterData instances are allowed to create Meters.
40 *
41 * @param meterData the MeterData that will be fed with data from the
42 * new Meter instance.
43 */
44 Meter(MeterData meterData) {
45 this.meterData = meterData;
46 }
47
48 // ==========================================================================
49 // Simple properties
50 // ==========================================================================
51
52 /***
53 * Returns the label straight from the nested TimerData.
54 * Unsynchronized since the label is immutable.
55 * @return Returns the label.
56 */
57 public String getLabel() {
58 return meterData.getLabel();
59 }
60
61
62 // ==========================================================================
63 // Timing API
64 // ==========================================================================
65
66 /***
67 * @param newValue
68 */
69 public void updateValue(long newValue) {
70 meterData.updateFromMeter(newValue);
71 }
72
73 }