KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > core > client > listeners > LogEntry


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.core.client.listeners;
12
13  
14 import java.util.Date JavaDoc;
15
16 import org.eclipse.core.runtime.PlatformObject;
17 import org.eclipse.team.internal.ccvs.core.*;
18 import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
19
20 public class LogEntry extends PlatformObject implements ILogEntry {
21
22     private RemoteFile file;
23     private String JavaDoc author;
24     private Date JavaDoc date;
25     private String JavaDoc comment;
26     private String JavaDoc state;
27     private CVSTag[] tags;
28     private String JavaDoc[] revisions;
29     
30     /*
31      * Flatten the text in the multi-line comment
32      */

33     public static String JavaDoc flattenText(String JavaDoc string) {
34         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(string.length() + 20);
35         boolean skipAdjacentLineSeparator = true;
36         for (int i = 0; i < string.length(); i++) {
37             char c = string.charAt(i);
38             if (c == '\r' || c == '\n') {
39                 if (!skipAdjacentLineSeparator)
40                     buffer.append(CVSMessages.LogEntry_0);
41                 skipAdjacentLineSeparator = true;
42             } else {
43                 buffer.append(c);
44                 skipAdjacentLineSeparator = false;
45             }
46         }
47         return buffer.toString();
48     }
49     
50     public LogEntry(RemoteFile file, String JavaDoc revision, String JavaDoc author, Date JavaDoc date, String JavaDoc comment, String JavaDoc state, CVSTag[] tags) {
51         this.file = file.toRevision(revision);
52         this.author = author;
53         this.date = date;
54         this.comment = comment;
55         this.state = state;
56         this.tags = tags;
57     }
58     
59     public LogEntry(RemoteFile file, String JavaDoc revision, String JavaDoc author, Date JavaDoc date, String JavaDoc comment, String JavaDoc state, CVSTag[] tags, String JavaDoc[] revisions) {
60         this(file,revision,author,date,comment,state,tags);
61         this.revisions=revisions;
62     }
63
64     /**
65      * @see ILogEntry#getRevision()
66      */

67     public String JavaDoc getRevision() {
68         return file.getRevision();
69     }
70
71     /**
72      * @see ILogEntry#getAuthor()
73      */

74     public String JavaDoc getAuthor() {
75         return author;
76     }
77
78     /**
79      * @see ILogEntry#getDate()
80      */

81     public Date JavaDoc getDate() {
82         return date;
83     }
84
85     /**
86      * @see ILogEntry#getComment()
87      */

88     public String JavaDoc getComment() {
89         return comment;
90     }
91
92     /**
93      * @see ILogEntry#getState()
94      */

95     public String JavaDoc getState() {
96         return state;
97     }
98
99     /**
100      * @see ILogEntry#getTags()
101      */

102     public CVSTag[] getTags() {
103         CVSTag[] result = new CVSTag[tags.length];
104         System.arraycopy(tags, 0, result, 0, tags.length);
105         return result;
106     }
107
108     /**
109      * @see ILogEntry#getRemoteFile()
110      */

111     public ICVSRemoteFile getRemoteFile() {
112         return file;
113     }
114     
115     /**
116      * @see ILogEntry#isDeletion()
117      */

118     public boolean isDeletion() {
119         return getState().equals("dead"); //$NON-NLS-1$
120
}
121
122     /**
123      * In the case where files on a branch haven't been modified since their initial branch point,
124      * they keep the revision number of their predecessor. In this case no revision info will be displayed
125      * while doing a log, so all branch revision numbers are recorded. This allows the user to pick which revision
126      * they are interested in.
127      * @return an array of branch revision strings or an empty array if no branch revisions were recorded
128      */

129     public String JavaDoc[] getBranchRevisions(){
130         
131         if (revisions != null)
132             return revisions;
133         
134         return new String JavaDoc[0];
135     }
136 }
137
138
Popular Tags