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