KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > changelog > LogInfoRevision


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.changelog;
20
21 import java.io.*;
22 import java.text.*;
23 import java.util.*;
24
25 import org.netbeans.modules.vcscore.ui.views.*;
26 import org.openide.nodes.*;
27
28 /**
29  * @author Milos Kleint, Ralph
30  */

31
32 public class LogInfoRevision extends FileVcsInfo {
33
34     private static final String JavaDoc NUMBER = "rev-Number";
35     private static final String JavaDoc DATE = "date";
36     private static final String JavaDoc AUTHOR = "author";
37     private static final String JavaDoc STATE = "state";
38     private static final String JavaDoc LINES = "lines";
39     private static final String JavaDoc BRANCH = "branch";
40     private static final String JavaDoc HEADER = "header";
41     
42     public LogInfoRevision(File file) {
43         super(file, "ChangeLogInfo", Children.LEAF);
44     }
45     
46     
47     public String JavaDoc getNumber() {
48         return getAttributeNonNull(NUMBER);
49     }
50     
51     /**
52      * Sets the number of revision..
53      */

54     public void setNumber(String JavaDoc number) {
55         setAttribute(NUMBER, number);
56     }
57     
58     public Date getDate() {
59         return (Date)getAttribute(DATE);
60     }
61     
62     
63     public void setDate(Date newDate) {
64         setAttribute(DATE, newDate);
65     }
66     
67     public String JavaDoc getAuthor() {
68         return getAttributeNonNull(AUTHOR);
69     }
70     
71     public void setAuthor(String JavaDoc author) {
72         setAttribute(AUTHOR, author);
73     }
74     
75     public String JavaDoc getState() {
76         return getAttributeNonNull(STATE);
77     }
78     
79     public void setState(String JavaDoc state) {
80         setAttribute(STATE, state);
81     }
82     
83     public String JavaDoc getLines() {
84         return getAttributeNonNull(LINES);
85     }
86     
87     public void setLines(String JavaDoc lines) {
88         setAttribute(LINES, lines);
89     }
90     
91     /**
92      * Returns how many lines were added in this revision.
93      */

94     public int getAddedLines() {
95         String JavaDoc lines = (String JavaDoc)getAttribute(LINES);
96         if (lines != null) {
97             int start = lines.indexOf('+');
98             int end = lines.indexOf(' ');
99             if (start >= 0 && end > start) {
100                 String JavaDoc added = lines.substring(start + 1, end);
101                 try {
102                     int toReturn = Integer.parseInt(added);
103                     return toReturn;
104                 } catch (NumberFormatException JavaDoc exc) {
105                     //TODO BUGLog..
106
}
107             }
108         }
109         return 0;
110     }
111     
112     public int getRemovedLines() {
113         String JavaDoc lines = (String JavaDoc)getAttribute(LINES);
114         if (lines != null) {
115             int start = lines.indexOf('-');
116             if (start >= 0) {
117                 String JavaDoc removed = lines.substring(start + 1);
118                 try {
119                     int toReturn = Integer.parseInt(removed);
120                     return toReturn;
121                 } catch (NumberFormatException JavaDoc exc) {
122                     //TODO BUGLog..
123
}
124             }
125         }
126         return 0;
127         
128     }
129
130     /**
131      * Returns the branch on which the change was done.
132      * Empty String when no branch..
133      */

134     
135     public String JavaDoc getBranch() {
136         return getAttributeNonNull(BRANCH);
137     }
138     
139     /**
140      * Specifies the branch on which the change was done.
141      */

142     
143     public void setBranch(String JavaDoc branch) {
144         setAttribute(BRANCH, branch);
145     }
146     
147     /**
148      * sets class that represents the file-related information that
149      * belongs to the revision..
150      * Warning: for optimalization reasons, make sure that all revisions
151      * belonging to a file have the same instance of LogInfoHeader.
152      * The number of revisions can be quite high and memory consumption
153      * might become a problem..
154      */

155     public void setLogInfoHeader(LogInfoHeader header) {
156         setAttribute(HEADER, header);
157     }
158     
159     
160     public LogInfoHeader getLogInfoHeader() {
161         return (LogInfoHeader)getAttribute(HEADER);
162     }
163     
164     
165     public static class LogInfoHeader {
166         private File file;
167         private String JavaDoc repositoryFilename;
168         private String JavaDoc headRevision;
169         private String JavaDoc branch;
170         private String JavaDoc accessList;
171         private String JavaDoc keywordSubstitution;
172         private String JavaDoc totalRevisions;
173         private String JavaDoc selectedRevisions;
174         private String JavaDoc description;
175         private String JavaDoc locks;
176         
177         public LogInfoHeader() {
178         }
179         
180         /** Getter for property file.
181          * @return Value of property file.
182          */

183         public File getFile() {
184             return file;
185         }
186         
187         /** Setter for property file.
188          * @param file New value of property file.
189          */

190         public void setFile(File file) {
191             this.file = file;
192         }
193         
194         /** Getter for property repositoryFilename.
195          * @return Value of property repositoryFilename.
196          */

197         public String JavaDoc getRepositoryFilename() {
198             return repositoryFilename;
199         }
200         
201         /** Setter for property repositoryFilename.
202          * @param repositoryFilename New value of property repositoryFilename.
203          */

204         public void setRepositoryFilename(String JavaDoc repositoryFilename) {
205             this.repositoryFilename = repositoryFilename;
206         }
207         
208         /** Getter for property headRevision.
209          * @return Value of property headRevision.
210          */

211         public String JavaDoc getHeadRevision() {
212             return headRevision;
213         }
214         
215         /** Setter for property headRevision.
216          * @param headRevision New value of property headRevision.
217          */

218         public void setHeadRevision(String JavaDoc headRevision) {
219             this.headRevision = headRevision;
220         }
221         
222         /** Getter for property branch.
223          * @return Value of property branch.
224          */

225         public String JavaDoc getBranch() {
226             return branch;
227         }
228         
229         /** Setter for property branch.
230          * @param branch New value of property branch.
231          */

232         public void setBranch(String JavaDoc branch) {
233             this.branch = branch;
234         }
235         
236         /** Getter for property accessList.
237          * @return Value of property accessList.
238          */

239         public String JavaDoc getAccessList() {
240             return accessList;
241         }
242         
243         /** Setter for property accessList.
244          * @param accessList New value of property accessList.
245          */

246         public void setAccessList(String JavaDoc accessList) {
247             this.accessList = accessList;
248         }
249         
250         /** Getter for property keywordSubstitution.
251          * @return Value of property keywordSubstitution.
252          */

253         public String JavaDoc getKeywordSubstitution() {
254             return keywordSubstitution;
255         }
256         
257         /** Setter for property keywordSubstitution.
258          * @param keywordSubstitution New value of property keywordSubstitution.
259          */

260         public void setKeywordSubstitution(String JavaDoc keywordSubstitution) {
261             this.keywordSubstitution = keywordSubstitution;
262         }
263         
264         /** Getter for property totalRevisions.
265          * @return Value of property totalRevisions.
266          */

267         public String JavaDoc getTotalRevisions() {
268             return totalRevisions;
269         }
270         
271         /** Setter for property totalRevisions.
272          * @param totalRevisions New value of property totalRevisions.
273          */

274         public void setTotalRevisions(String JavaDoc totalRevisions) {
275             this.totalRevisions = totalRevisions;
276         }
277         
278         /** Getter for property selectedRevisions.
279          * @return Value of property selectedRevisions.
280          */

281         public String JavaDoc getSelectedRevisions() {
282             return selectedRevisions;
283         }
284         
285         /** Setter for property selectedRevisions.
286          * @param selectedRevisions New value of property selectedRevisions.
287          */

288         public void setSelectedRevisions(String JavaDoc selectedRevisions) {
289             this.selectedRevisions = selectedRevisions;
290         }
291         
292         /** Getter for property description.
293          * @return Value of property description.
294          */

295         public String JavaDoc getDescription() {
296             return description;
297         }
298         
299         /** Setter for property description.
300          * @param description New value of property description.
301          */

302         public void setDescription(String JavaDoc description) {
303             this.description = description;
304         }
305         
306         /** Getter for property locks.
307          * @return Value of property locks.
308          */

309         public String JavaDoc getLocks() {
310             return locks;
311         }
312         
313         /** Setter for property locks.
314          * @param locks New value of property locks.
315          */

316         public void setLocks(String JavaDoc locks) {
317             this.locks = locks;
318         }
319         
320     }
321     
322     
323     
324 }
325
326
327
328
Popular Tags