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