KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > finalist > util > log > CustomLevel


1 /* Copyright (C) 2003 Finalist IT Group
2  *
3  * This file is part of JAG - the Java J2EE Application Generator
4  *
5  * JAG is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * JAG is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  * You should have received a copy of the GNU General Public License
14  * along with JAG; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */

17
18 package com.finalist.util.log;
19
20 import java.util.logging.Level JavaDoc;
21
22 /**
23  * A class for making custom levels for logging.
24  *
25  * @author Ronald Kramp - Finalist IT Group
26  * @version $Revision: 1.1 $, $Date: 2004/11/12 14:06:44 $
27  */

28 class CustomLevel extends Level JavaDoc {
29
30    /** a Level for DEBUG */
31    public static final Level JavaDoc DEBUG = new CustomLevel("DEBUG", Level.INFO.intValue() - 1);
32
33    /** a Level for ERROR */
34    public static final Level JavaDoc ERROR = new CustomLevel("ERROR", Level.SEVERE.intValue() - 1);
35
36    /** a Level for FATAL */
37    public static final Level JavaDoc FATAL = new CustomLevel("FATAL", Level.SEVERE.intValue() + 1);
38
39
40    /**
41     * Constrcutor for making a custom level.
42     * @param name, the name of the Level
43     * @param value, the value for the level
44     */

45    public CustomLevel(String JavaDoc name, int value) {
46       super(name, value);
47    }
48
49
50    /**
51     * Parse a levelName to a Level object.
52     * @param levelName the name of the Level to parse to a Level obhect
53     * @return Level the Level object parsed
54     */

55    public static Level JavaDoc parse(String JavaDoc levelName) {
56       if (levelName.equals("DEBUG")) {
57          return DEBUG;
58       }
59       else if (levelName.equals("ERROR")) {
60          return ERROR;
61       }
62       else if (levelName.equals("FATAL")) {
63          return FATAL;
64       }
65       else {
66          return Level.parse(levelName);
67       }
68    }
69 }
Popular Tags