KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > innig > macker > rule > RuleSeverity


1 /*______________________________________________________________________________
2  *
3  * Macker http://innig.net/macker/
4  *
5  * Copyright 2002 Paul Cantrell
6  *
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License version 2, as published by the
9  * Free Software Foundation. See the file LICENSE.html for more information.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the license for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
17  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
18  *______________________________________________________________________________
19  */

20  
21 package net.innig.macker.rule;
22
23 import net.innig.util.EnumeratedType;
24 import net.innig.util.OrderedType;
25
26 public final class RuleSeverity
27     extends OrderedType
28     {
29     public static final RuleSeverity
30         ERROR = new RuleSeverity("error", "errors", 0),
31         WARNING = new RuleSeverity("warning", "warnings", -1),
32         INFO = new RuleSeverity("info", "info", -2),
33         DEBUG = new RuleSeverity("debug", "debug", -3);
34     
35     public static RuleSeverity fromName(String JavaDoc name)
36         throws IllegalArgumentException JavaDoc
37         {
38         RuleSeverity severity = (RuleSeverity) EnumeratedType.resolveFromName(RuleSeverity.class, name);
39         if(severity == null)
40             throw new IllegalArgumentException JavaDoc(
41                 "Unknown severity level \"" + name + "\" (expected one of "
42                 + OrderedType.allTypeNamesSorted(RuleSeverity.class) + ")");
43         return severity;
44         }
45     
46     public String JavaDoc getNamePlural()
47         { return plural; }
48     
49     private RuleSeverity(String JavaDoc name, String JavaDoc plural, int order)
50         {
51         super(name, order);
52         this.plural = plural;
53         }
54     
55     private transient final String JavaDoc plural;
56     }
Popular Tags