KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > BugCategory


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

19
20 package edu.umd.cs.findbugs;
21
22 /**
23  * A BugCategory object collects all of the metadata
24  * for a category of bugs. BugCategories derive from
25  * the BugCategory elements in messages*.xml files.
26  */

27 public class BugCategory implements Comparable JavaDoc<BugCategory> {
28     final private String JavaDoc category;
29     final private String JavaDoc shortDescription;
30      private String JavaDoc abbrev;
31      private String JavaDoc detailText;
32
33     /**
34      * Constructor.
35      *
36      * @param category the category
37      * @param shortDescription short (a word or three) description of the bug species
38      * @param abbrev the abbreviation (typically a single capital letter)
39      * @param detailText full description of the bug category (no HTML markup, may be null)
40      */

41     public BugCategory(String JavaDoc category, String JavaDoc shortDescription, String JavaDoc abbrev, String JavaDoc detailText) {
42         this.category = category;
43         this.shortDescription = shortDescription;
44         this.abbrev = abbrev;
45         this.detailText = detailText;
46     }
47
48     /**
49      * Constructor.
50      *
51      * @param category the category
52      * @param shortDescription short (a word or three) description of the bug species
53      */

54     public BugCategory(String JavaDoc category, String JavaDoc shortDescription) {
55         this(category, shortDescription, null, null);
56     }
57
58     /**
59      * Get the category.
60      */

61     public String JavaDoc getCategory() {
62         return category;
63     }
64
65     /**
66      * Get the short description (usually a word or three)
67      */

68     public String JavaDoc getShortDescription() {
69         return shortDescription;
70     }
71
72     /**
73      * Get the abbreviation (usually a single capital letter).
74      * May be null, but shouldn't be if the XML is correct.
75      */

76     public String JavaDoc getAbbrev() {
77         return abbrev;
78     }
79
80     /**
81      * Get the detail text describing the category.
82      * note: no HTML markup allowed, may be null
83      */

84     public String JavaDoc getDetailText() {
85         return detailText;
86     }
87
88     /**
89      * Set the abbreviation (typically a single capital letter)
90      */

91     public void setAbbrev(String JavaDoc abbrev) {
92         this.abbrev = abbrev;
93     }
94
95     /**
96      * Set the detail text describing the category.
97      * note: no HTML markup allowed, may be null
98      */

99     public void setDetailText(String JavaDoc detailText) {
100         this.detailText = detailText;
101     }
102
103
104     public int compareTo(BugCategory other) {
105         return category.compareTo(other.category);
106     }
107
108     @Override JavaDoc
109     public int hashCode() {
110         return category.hashCode();
111     }
112
113     @Override JavaDoc
114     public boolean equals(Object JavaDoc o) {
115         if (!(o instanceof BugCategory)) return false;
116         BugCategory other = (BugCategory)o;
117         return category.equals(other.category);
118     }
119
120     /** suitable for debugging. will be ugly if detailText has multiple lines */
121     @Override JavaDoc
122     public String JavaDoc toString() {
123         return "BugCategory["+category+"]{short="+shortDescription+",abbrev="+abbrev+",details="+detailText+'}';
124     }
125     
126 }
127
Popular Tags