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
/**
20
 * Name:		Unit.java
21
 * Date:		Aug 30, 2004
22
 * Description:
23
 * 
24
 *  A Unit of measurement for a statistic.
25
 * 
26
 * @author Lara D'Abreo
27
 */
28
public class Unit {
29
 
30
	public static final Unit TIME = new Unit(0,"time");
31
	public static final Unit MEMORY = new Unit(1,"memory");
32
	public static final Unit VALUE = new Unit(2,"value");
33
 
34
	public static final Unit[] units = new Unit[]{TIME,MEMORY,VALUE};
35
 
36
	private	int	type;
37
	private String name;
38
 
39
	private Unit(int type,String name) {
40
		this.type = type;
41
		this.name = name;
42
	}
43
	/**
44
	 * @return
45
	 */
46
	public String getName() {
47
		return name;
48
	}
49
 
50
	/**
51
	 * @return
52
	 */
53
	public int getType() {
54
		return type;
55
	}
56
 
57
	public static Unit parse(String unitName) {
58
		for (int i = 0; i < units.length; ++i){
59
			if (units[i].getName().equals(unitName)) {
60
				return units[i];
61
			}
62
 
63
		}
64
		return null;
65
	}
66
 
67
 
68
}