| 1 | /* |
| 2 | * Copyright 2005-2006 The RbUtils Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | // $Id: LoggerType.java,v 1.1 2006/11/07 03:11:38 moishi Exp $ |
| 19 | |
| 20 | package org.ktc.rbutils.rb; |
| 21 | |
| 22 | import java.util.List; |
| 23 | |
| 24 | import org.apache.commons.lang.enums.Enum; |
| 25 | |
| 26 | /** |
| 27 | * Enumerated attribute for RbUtils logger type. |
| 28 | * @since RbUtils 0.9.3.3 |
| 29 | * @version $Revision: 1.1 $ |
| 30 | * @author moishi |
| 31 | */ |
| 32 | public final class LoggerType extends Enum { |
| 33 | /** |
| 34 | * Automaticly generated for backward compatibility. |
| 35 | */ |
| 36 | private static final long serialVersionUID = 7118013368071710756L; |
| 37 | |
| 38 | /** Class of the LoggerType. */ |
| 39 | private static final Class CLASS = LoggerType.class; |
| 40 | |
| 41 | /** String value for a plain logger. */ |
| 42 | public static final String PLAIN_STRING = "plain"; |
| 43 | /** Enum value for a plain logger. */ |
| 44 | public static final LoggerType PLAIN = new LoggerType(LoggerType.PLAIN_STRING); |
| 45 | |
| 46 | /** String value for a quiet logger. */ |
| 47 | public static final String QUIET_STRING = "quiet"; |
| 48 | /** Enum value for a quiet logger. */ |
| 49 | public static final LoggerType QUIET = new LoggerType(LoggerType.QUIET_STRING); |
| 50 | |
| 51 | /** String value for an xml logger. */ |
| 52 | public static final String XML_STRING = "xml"; |
| 53 | /** Enum value for an xml logger. */ |
| 54 | public static final LoggerType XML = new LoggerType(LoggerType.XML_STRING); |
| 55 | |
| 56 | /** |
| 57 | * Constructs a new MessageType. |
| 58 | * @param loggerType the type of the message as String. |
| 59 | */ |
| 60 | private LoggerType(final String loggerType) { |
| 61 | super(loggerType); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Indicates if the argument is a logger type value. |
| 66 | * @param loggerType type value to be checked. |
| 67 | * @return <code>true</code> if the argument is a logger type value; otherwise returns |
| 68 | * <code>false</code>. |
| 69 | */ |
| 70 | public static boolean isLoggerTypeValue(final String loggerType) { |
| 71 | final LoggerType logtype = getEnum(loggerType); |
| 72 | final boolean isLogType; |
| 73 | if (logtype != null) { |
| 74 | isLogType = true; |
| 75 | } |
| 76 | else { |
| 77 | isLogType = false; |
| 78 | } |
| 79 | return isLogType; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Returns an instance of LoggerType according to a String representation. |
| 84 | * @param loggerType the String representation to be used to create the LoggerType. |
| 85 | * @return the logger type if the argument is a logger type <code>String</code> value; |
| 86 | * <code>null</code> otherwise. |
| 87 | */ |
| 88 | public static LoggerType getEnum(final String loggerType) { |
| 89 | return (LoggerType) getEnum(CLASS, loggerType); |
| 90 | } |
| 91 | |
| 92 | // public static Map getEnumMap() { |
| 93 | // return getEnumMap(CLASS); |
| 94 | // } |
| 95 | |
| 96 | /** |
| 97 | * Gets the List of LoggerType objects. |
| 98 | * @see Enum#getEnumList(java.lang.Class) |
| 99 | * @return the List. |
| 100 | */ |
| 101 | public static List getEnumList() { |
| 102 | return getEnumList(CLASS); |
| 103 | } |
| 104 | |
| 105 | // public static Iterator iterator() { |
| 106 | // return iterator(CLASS); |
| 107 | // } |
| 108 | } |