| 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$ |
| 19 | |
| 20 | package org.ktc.rbutils.api.audit; |
| 21 | |
| 22 | import org.apache.commons.lang.enums.Enum; |
| 23 | import org.ktc.rbutils.api.i18n.Message; |
| 24 | |
| 25 | /** |
| 26 | * MessageType are used to let the user know the message origin: Information, Errors or Exception. |
| 27 | * @since RbUtils 0.9.3.3 |
| 28 | * @version $Revision$ |
| 29 | * @author moishi |
| 30 | */ |
| 31 | public final class MessageType extends Enum { |
| 32 | /** |
| 33 | * Automaticly generated field for backward compatibility. |
| 34 | */ |
| 35 | private static final long serialVersionUID = -8377679743884427037L; |
| 36 | |
| 37 | /** |
| 38 | * The INFO <code>MessageType</code>. |
| 39 | */ |
| 40 | public static final MessageType INFO = new MessageType(messagetypedisplay.INFO); |
| 41 | /** |
| 42 | * The ERROR <code>MessageType</code>. |
| 43 | */ |
| 44 | public static final MessageType ERROR = new MessageType(messagetypedisplay.ERROR); |
| 45 | /** |
| 46 | * The EXCEPTION <code>MessageType</code>. |
| 47 | */ |
| 48 | public static final MessageType EXCEPTION = new MessageType(messagetypedisplay.EXCEPTION); |
| 49 | |
| 50 | /** |
| 51 | * Name of the bundle used to display this enumerated type. |
| 52 | */ |
| 53 | private final String bundlename = messagetypedisplay.class.getName(); |
| 54 | |
| 55 | /** |
| 56 | * Constructs a new MessageType. |
| 57 | * @param messagetype the type of the message as String. |
| 58 | */ |
| 59 | private MessageType(final String messagetype) { |
| 60 | super(messagetype); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Provides a human readable display of the MessageType. |
| 65 | * <p> |
| 66 | * The Locale used is the Locale of the Message class. |
| 67 | * @return the display form of this MessageType. |
| 68 | */ |
| 69 | public String getDisplay() { |
| 70 | final Message message = new Message(bundlename, getName(), null); |
| 71 | return message.getMessage(); |
| 72 | } |
| 73 | } |