Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5827 amar.kumar 1
/*
2
 *	Copyright 2005 stat4j.org
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.sourceforge.stat4j;
18
 
19
import java.io.Serializable;
20
 
21
/**
22
 * Name:		Reading.java
23
 * Date:		Aug 29, 2004
24
 * Description:
25
 * 
26
 * A reading captured from the log at a point in time.
27
 * 
28
 * The reading value is derived from the log message itself
29
 * using a scrap expression. If no scrap expression is supplied 
30
 * the value defaults to 1.0.
31
 * 
32
 * 
33
 * @author Lara D'Abreo
34
 */
35
public class Reading implements Serializable{
36
 
37
	protected	long	timestamp;
38
	protected	long	freeMemory;
39
	protected	double	value;	
40
 
41
 
42
	public Reading() {
43
		this.timestamp = System.currentTimeMillis();
44
		this.freeMemory = Runtime.getRuntime().freeMemory();
45
		this.value = 1.0;
46
	}
47
 
48
	public Reading(double value) {
49
		this();
50
		this.value = value;
51
	}
52
 
53
	public double getReading(Unit unit) {
54
 
55
		if (unit == Unit.MEMORY) {
56
			return freeMemory;	
57
		}else if (unit == Unit.TIME) {
58
			return timestamp;
59
		}else {
60
			return value;
61
		}
62
	}
63
	/**
64
	 * @return
65
	 */
66
	public long getFreeMemory() {
67
		return freeMemory;
68
	}
69
 
70
	/**
71
	 * @return
72
	 */
73
	public long getTimestamp() {
74
		return timestamp;
75
	}
76
 
77
	/**
78
	 * @return
79
	 */
80
	public double getValue() {
81
		return value;
82
	}
83
 
84
}