diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/LogLevel.java b/proposal/myrmidon/src/java/org/apache/antlib/core/LogLevel.java new file mode 100644 index 000000000..acd94816c --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/antlib/core/LogLevel.java @@ -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 Peter Donald + */ +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 ); + } +}