summaryrefslogtreecommitdiff
path: root/SDL_Android/SmartDeviceLinkProxyAndroid/src/com/smartdevicelink/trace/DiagLevel.java
blob: f4b326e5af799ed230f651986e0a1724730b00f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// Copyright (c) 2013 Ford Motor Company
//
package com.smartdevicelink.trace;

import com.smartdevicelink.trace.enums.DetailLevel;
import com.smartdevicelink.trace.enums.Mod;

public class DiagLevel {

	static private DetailLevel[] levels;
	
	static {   // this is a static c-tor!!
		levels = new DetailLevel[Mod.values().length];
		setAllLevels(DetailLevel.OFF);
	}
	
	public static void setAllLevels(DetailLevel thisDetail) {
		for (int i=0; i < levels.length; i++) {
			levels[i] = thisDetail; //  
		}
	}
	
    public static void setLevel(Mod thisMod, DetailLevel thisDetail) {
    	levels[thisMod.ordinal()] = thisDetail;
    }
	
	public static DetailLevel getLevel(Mod thisMod) {
		return levels[thisMod.ordinal()];
	}
	
	public static boolean isValidDetailLevel(String dtString) {
		// Assume false
		Boolean isValid = false;
		
		if (dtString.equalsIgnoreCase("verbose"))
			isValid = true;
		else if (dtString.equalsIgnoreCase("terse"))
			isValid = true;
		else if (dtString.equalsIgnoreCase("off"))
			isValid = true;
		
		return isValid;
	}
	
	public static DetailLevel toDetailLevel(String dtString) {
		DetailLevel dt = DetailLevel.OFF;
		if (dtString.equalsIgnoreCase("verbose"))
			dt = DetailLevel.VERBOSE;
		else if (dtString.equalsIgnoreCase("terse"))
			dt = DetailLevel.TERSE;
		return dt;
	}
}