1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.assembly.io;
20
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.Collections;
24 import java.util.List;
25
26
27
28
29 final class MessageLevels {
30
31
32
33
34 public static final int LEVEL_DEBUG = 0;
35
36
37
38 public static final int LEVEL_INFO = 1;
39
40
41
42 public static final int LEVEL_WARNING = 2;
43
44
45
46 public static final int LEVEL_ERROR = 3;
47
48
49
50 public static final int LEVEL_SEVERE = 4;
51
52
53
54 public static final int LEVEL_DISABLED = 5;
55
56 private static final List<String> LEVEL_NAMES;
57
58 static {
59 List<String> names = new ArrayList<>();
60 names.add("DEBUG");
61 names.add("INFO");
62 names.add("WARN");
63 names.add("ERROR");
64 names.add("SEVERE");
65
66 LEVEL_NAMES = Collections.unmodifiableList(names);
67 }
68
69 private MessageLevels() {}
70
71
72
73
74
75 static boolean[] getLevelStates(int maxMessageLevel) {
76 boolean[] states = new boolean[5];
77
78 Arrays.fill(states, false);
79
80 switch (maxMessageLevel) {
81 case (LEVEL_DEBUG):
82 states[LEVEL_DEBUG] = true;
83 case (LEVEL_INFO):
84 states[LEVEL_INFO] = true;
85 case (LEVEL_WARNING):
86 states[LEVEL_WARNING] = true;
87 case (LEVEL_ERROR):
88 states[LEVEL_ERROR] = true;
89 case (LEVEL_SEVERE):
90 states[LEVEL_SEVERE] = true;
91 default:
92 }
93
94 return states;
95 }
96
97
98
99
100
101 static String getLevelLabel(int messageLevel) {
102 if (messageLevel > -1 && LEVEL_NAMES.size() > messageLevel) {
103 return LEVEL_NAMES.get(messageLevel);
104 }
105
106 throw new IllegalArgumentException("Invalid message level: " + messageLevel);
107 }
108 }