KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2005, 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 import java.io.IOException JavaDoc;
23 import java.util.Date JavaDoc;
24
25 import edu.umd.cs.findbugs.xml.XMLAttributeList;
26 import edu.umd.cs.findbugs.xml.XMLOutput;
27 import edu.umd.cs.findbugs.xml.XMLWriteable;
28
29 /**
30  * A version of an analyzed application.
31  * Application versions are uniquely identified by a sequence number,
32  * which represents a run of FindBugs on the application.
33  * Timestamp is when FindBugs was run (according to System.currentTimeMillis()),
34  * and the release name is available if the user provided it.
35  *
36  * @author David Hovemeyer
37  */

38 public class AppVersion implements XMLWriteable, Cloneable JavaDoc {
39     /**
40      * XML element name for a stored AppVersion object.
41      */

42     public static final String JavaDoc ELEMENT_NAME = "AppVersion";
43     
44     private long sequence;
45     private long timestamp;
46     private String JavaDoc releaseName;
47     private int numClasses;
48     private int codeSize;
49     
50     public AppVersion(long sequence, long time, String JavaDoc name) {
51         this.sequence = sequence;
52         this.timestamp = time;
53         this.releaseName = name;
54     }
55     public AppVersion(long sequence, Date JavaDoc time, String JavaDoc name) {
56         this.sequence = sequence;
57         this.timestamp = time.getTime();
58         this.releaseName = name;
59     }
60     public AppVersion(long sequence) {
61         this.sequence = sequence;
62         this.timestamp = -1;
63         this.releaseName = "";
64     }
65     
66     /* (non-Javadoc)
67      * @see java.lang.Object#clone()
68      */

69     //@Override
70
@Override JavaDoc
71     public Object JavaDoc clone() {
72         try {
73             return super.clone();
74         } catch (CloneNotSupportedException JavaDoc e) {
75             throw new AssertionError JavaDoc(e);
76         }
77     }
78     
79     /**
80      * @return Returns the sequence.
81      */

82     public long getSequenceNumber() {
83         return sequence;
84     }
85     
86     /**
87      * @return Returns the timestamp.
88      */

89     public long getTimestamp() {
90         return timestamp;
91     }
92     
93     /**
94      * @return Returns the releaseName.
95      */

96     public String JavaDoc getReleaseName() {
97         return releaseName;
98     }
99     
100     /**
101      * @param timestamp The timestamp to set.
102      */

103     public AppVersion setTimestamp(long timestamp) {
104         this.timestamp = timestamp;
105         return this;
106     }
107     
108     /**
109      * @param releaseName The releaseName to set.
110      */

111     public AppVersion setReleaseName(String JavaDoc releaseName) {
112         this.releaseName = releaseName;
113         return this;
114     }
115     
116     /* (non-Javadoc)
117      * @see edu.umd.cs.findbugs.xml.XMLWriteable#writeXML(edu.umd.cs.findbugs.xml.XMLOutput)
118      */

119     public void writeXML(XMLOutput xmlOutput) throws IOException JavaDoc {
120         xmlOutput.openCloseTag(ELEMENT_NAME, new XMLAttributeList()
121                 .addAttribute("sequence", String.valueOf(sequence))
122                 .addAttribute("timestamp", String.valueOf(timestamp))
123                 .addAttribute("release", releaseName)
124                 .addAttribute("codeSize", String.valueOf(codeSize))
125                 .addAttribute("numClasses", String.valueOf(numClasses)));
126     }
127     
128     /* (non-Javadoc)
129      * @see java.lang.Object#toString()
130      */

131     //@Override
132
@Override JavaDoc
133     public String JavaDoc toString() {
134         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
135         buf.append(String.valueOf(sequence));
136         buf.append(',');
137         buf.append(String.valueOf(timestamp));
138         buf.append(',');
139         buf.append(releaseName);
140         buf.append(',');
141         buf.append(codeSize);
142         buf.append(',');
143         buf.append(codeSize);
144         return buf.toString();
145     }
146     /**
147      * @param numClasses The numClasses to set.
148      */

149     public AppVersion setNumClasses(int numClasses) {
150         this.numClasses = numClasses;
151         return this;
152     }
153     /**
154      * @return Returns the numClasses.
155      */

156     public int getNumClasses() {
157         return numClasses;
158     }
159     /**
160      * @param codeSize The codeSize to set.
161      */

162     public AppVersion setCodeSize(int codeSize) {
163         this.codeSize = codeSize;
164         return this;
165     }
166     /**
167      * @return Returns the codeSize.
168      */

169     public int getCodeSize() {
170         return codeSize;
171     }
172 }
173
Popular Tags