KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > knowgate > lucene > BugRecord


1 /*
2   Copyright (C) 2003 Know Gate S.L. All rights reserved.
3                       C/Oņa, 107 1š2 28050 Madrid (Spain)
4
5   Redistribution and use in source and binary forms, with or without
6   modification, are permitted provided that the following conditions
7   are met:
8
9   1. Redistributions of source code must retain the above copyright
10      notice, this list of conditions and the following disclaimer.
11
12   2. The end-user documentation included with the redistribution,
13      if any, must include the following acknowledgment:
14      "This product includes software parts from hipergate
15      (http://www.hipergate.org/)."
16      Alternately, this acknowledgment may appear in the software itself,
17      if and wherever such third-party acknowledgments normally appear.
18
19   3. The name hipergate must not be used to endorse or promote products
20      derived from this software without prior written permission.
21      Products derived from this software may not be called hipergate,
22      nor may hipergate appear in their name, without prior written
23      permission.
24
25   This library is distributed in the hope that it will be useful,
26   but WITHOUT ANY WARRANTY; without even the implied warranty of
27   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
28
29   You should have received a copy of hipergate License with this code;
30   if not, visit http://www.hipergate.org or mail to info@hipergate.org
31 */

32
33 package com.knowgate.lucene;
34
35 import java.util.Date JavaDoc;
36 import java.util.Comparator JavaDoc;
37 import java.text.SimpleDateFormat JavaDoc;
38
39 /**
40  * @author Sergio Montoro Ten
41  * @version 3.0
42  */

43 public class BugRecord {
44
45   public static class CompareAuthor implements Comparator JavaDoc {
46     public int compare(Object JavaDoc o1, Object JavaDoc o2) {
47       if (((BugRecord)o1).getAuthor()==null) return -1;
48       return ((BugRecord)o1).getAuthor().compareTo(((BugRecord)o2).getAuthor());
49     }
50   }
51
52   public static class CompareTitle implements Comparator JavaDoc {
53     public int compare(Object JavaDoc o1, Object JavaDoc o2) {
54       if (((BugRecord)o1).getTitle()==null) return -1;
55       return ((BugRecord)o1).getTitle().compareTo(((BugRecord)o2).getTitle());
56     }
57   }
58
59   public static class CompareDate implements Comparator JavaDoc {
60     public int compare(Object JavaDoc o1, Object JavaDoc o2) {
61       if (((BugRecord)o1).getDate()==null) return -1;
62       return ((BugRecord)o1).getDate().compareTo(((BugRecord)o2).getDate());
63     }
64   }
65
66   public static class ComparePriority implements Comparator JavaDoc {
67     public int compare(Object JavaDoc o1, Object JavaDoc o2) {
68       if (((BugRecord)o1).getPriority()==null) return -1;
69       return ((BugRecord)o1).getPriority().compareTo(((BugRecord)o2).getPriority());
70     }
71   }
72
73   public static class CompareSeverity implements Comparator JavaDoc {
74     public int compare(Object JavaDoc o1, Object JavaDoc o2) {
75       if (((BugRecord)o1).getSeverity()==null) return -1;
76       return ((BugRecord)o1).getSeverity().compareTo(((BugRecord)o2).getSeverity());
77     }
78   }
79
80   private static SimpleDateFormat JavaDoc fmt = new SimpleDateFormat JavaDoc("yyyy-MM-dd HH:mm:ss");
81   private int number;
82   private String JavaDoc guid;
83   private String JavaDoc project;
84   private String JavaDoc title;
85   private String JavaDoc author;
86   private Date JavaDoc created;
87   private String JavaDoc type;
88   private String JavaDoc status;
89   private Short JavaDoc priority;
90   private Short JavaDoc severity;
91   private String JavaDoc abstrct;
92
93   public BugRecord() { }
94
95   public BugRecord(int iNumber, String JavaDoc sGuid, String JavaDoc sProject, String JavaDoc sTitle,
96                    String JavaDoc sReportedBy, String JavaDoc sDate, String JavaDoc sType, String JavaDoc sStatus,
97                    String JavaDoc sPriority, String JavaDoc sSeverity, String JavaDoc sAbstract) {
98     number = iNumber;
99     guid = sGuid;
100     project = sProject;
101     title = sTitle;
102     author = sReportedBy;
103     try { created = fmt.parse(sDate); } catch (Exception JavaDoc ignore) {}
104     type = sType;
105     if (null!=sPriority)
106       priority = new Short JavaDoc(sPriority);
107     else
108       priority = null;
109     if (null!=sSeverity)
110       severity = new Short JavaDoc(sSeverity);
111     else
112       severity = null;
113     abstrct = sAbstract;
114   }
115
116   public String JavaDoc getProject() {
117     return project;
118   }
119
120   public int getNumber() throws NumberFormatException JavaDoc{
121     return number;
122   }
123
124   public String JavaDoc getGuid() {
125     return guid;
126   }
127
128   public String JavaDoc getTitle() {
129     return title;
130   }
131
132   public String JavaDoc getAuthor() {
133     return author;
134   }
135
136   public Date JavaDoc getDate() {
137     return created;
138   }
139
140   public String JavaDoc getDateAsString() {
141     return fmt.format(created);
142   }
143
144   public Short JavaDoc getPriority() {
145     return priority;
146   }
147
148   public Short JavaDoc getSeverity() {
149     return severity;
150   }
151
152   public String JavaDoc getStatus() {
153     return status;
154   }
155
156   public String JavaDoc getType() {
157     return type;
158   }
159
160   public void setProject(String JavaDoc sProjectGUID) {
161     project = sProjectGUID;
162   }
163
164   public void setGuid(String JavaDoc sGuid) {
165     guid = sGuid;
166   }
167
168   public void setTitle(String JavaDoc sTitle) {
169     title = sTitle;
170   }
171
172   public void setAuthor(String JavaDoc sAuthor) {
173     author = sAuthor;
174   }
175
176   public void setDate(Date JavaDoc oDtCreated) {
177     created = oDtCreated;
178   }
179
180   public void setPriority(Short JavaDoc oPriority) {
181     priority=oPriority;
182   }
183
184   public void setSeverity(Short JavaDoc oSeverity) {
185     severity=oSeverity;
186   }
187
188   public void setType(String JavaDoc sType) {
189     type=sType;
190   }
191
192   public void setStatus(String JavaDoc sStatus) {
193     status=sStatus;
194   }
195
196 }
197
Popular Tags