Browse Source

A a class to hold enums for the level at which to log.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270399 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
91c816cbbb
1 changed files with 63 additions and 0 deletions
  1. +63
    -0
      proposal/myrmidon/src/java/org/apache/antlib/core/LogLevel.java

+ 63
- 0
proposal/myrmidon/src/java/org/apache/antlib/core/LogLevel.java View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.antlib.core;

import java.util.HashMap;
import java.util.Set;
import org.apache.avalon.framework.Enum;

/**
* Type safe Enum for Log Levels.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
*/
public final class LogLevel
extends Enum
{
//Map for all the levels
private static final HashMap c_levels = new HashMap();

//standard enums for version of JVM
public final static LogLevel FATAL_ERROR = new LogLevel( "fatalError" );
public final static LogLevel ERROR = new LogLevel( "error" );
public final static LogLevel WARN = new LogLevel( "warn" );
public final static LogLevel INFO = new LogLevel( "info" );
public final static LogLevel DEBUG = new LogLevel( "debug" );

/**
* Retrieve the log level for the specified name.
*
* @param name the name of the LogLevel object to retrieve
* @returns The LogLevel for specified name or null
*/
public static LogLevel getByName( final String name )
{
return (LogLevel)c_levels.get( name );
}

/**
* Retrieve the names of all the LogLevels.
*
* @returns The names of all the LogLevels
*/
public static String[] getNames( )
{
final Set keys = c_levels.keySet();
return (String[])keys.toArray( new String[ keys.size() ] );
}

/**
* Private constructor so no instance except here can be defined.
*
* @param name the name of Log Level
*/
private LogLevel( final String name )
{
super( name, c_levels );
}
}

Loading…
Cancel
Save