KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > subversion > ui > history > RepositoryRevision


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.subversion.ui.history;
20
21 import org.tigris.subversion.svnclientadapter.ISVNLogMessage;
22 import org.tigris.subversion.svnclientadapter.ISVNLogMessageChangePath;
23 import org.tigris.subversion.svnclientadapter.SVNUrl;
24 import java.io.File JavaDoc;
25 import java.util.*;
26
27 /**
28  * Describes log information for a file. This is the result of doing a
29  * cvs log command. The fields in instances of this object are populated
30  * by response handlers.
31  *
32  * @author Maros Sandor
33  */

34 class RepositoryRevision {
35
36     private ISVNLogMessage message;
37
38     private SVNUrl repositoryRootUrl;
39
40     /**
41      * List of events associated with the revision.
42      */

43     private final List<Event> events = new ArrayList<Event>(1);
44
45     public RepositoryRevision(ISVNLogMessage message, SVNUrl rootUrl) {
46         this.message = message;
47         this.repositoryRootUrl = rootUrl;
48         initEvents();
49     }
50
51     public SVNUrl getRepositoryRootUrl() {
52         return repositoryRootUrl;
53     }
54
55     private void initEvents() {
56         ISVNLogMessageChangePath [] paths = message.getChangedPaths();
57         if (paths == null) return;
58         for (ISVNLogMessageChangePath path : paths) {
59             events.add(new Event(path));
60         }
61     }
62
63     public List<Event> getEvents() {
64         return events;
65     }
66
67     public ISVNLogMessage getLog() {
68         return message;
69     }
70
71     public String JavaDoc toString() {
72         StringBuffer JavaDoc text = new StringBuffer JavaDoc();
73         text.append(getLog().getRevision().getNumber());
74         text.append("\t");
75         text.append(getLog().getDate());
76         text.append("\t");
77         text.append(getLog().getAuthor()); // NOI18N
78
text.append("\n"); // NOI18N
79
text.append(getLog().getMessage());
80         return text.toString();
81     }
82     
83     public class Event {
84     
85         /**
86          * The file or folder that this event is about. It may be null if the File cannot be computed.
87          */

88         private File JavaDoc file;
89     
90         private ISVNLogMessageChangePath changedPath;
91
92         private String JavaDoc name;
93         private String JavaDoc path;
94
95         public Event(ISVNLogMessageChangePath changedPath) {
96             this.changedPath = changedPath;
97             name = changedPath.getPath().substring(changedPath.getPath().lastIndexOf('/') + 1);
98             path = changedPath.getPath().substring(0, changedPath.getPath().lastIndexOf('/'));
99         }
100
101         public RepositoryRevision getLogInfoHeader() {
102             return RepositoryRevision.this;
103         }
104
105         public ISVNLogMessageChangePath getChangedPath() {
106             return changedPath;
107         }
108
109         /** Getter for property file.
110          * @return Value of property file.
111          */

112         public File JavaDoc getFile() {
113             return file;
114         }
115
116         /** Setter for property file.
117          * @param file New value of property file.
118          */

119         public void setFile(File JavaDoc file) {
120             this.file = file;
121         }
122
123         public String JavaDoc getName() {
124             return name;
125         }
126
127         public String JavaDoc getPath() {
128             return path;
129         }
130         
131         public String JavaDoc toString() {
132             StringBuffer JavaDoc text = new StringBuffer JavaDoc();
133             text.append("\t");
134             text.append(getPath());
135             return text.toString();
136         }
137
138         
139     }
140 }
141
Popular Tags