HistoryEntry.java revision 308470174aea8cf0128aa8baf7018c9500f6131c
248N/A/*
248N/A * CDDL HEADER START
248N/A *
248N/A * The contents of this file are subject to the terms of the
248N/A * Common Development and Distribution License (the "License").
248N/A * You may not use this file except in compliance with the License.
248N/A *
248N/A * See LICENSE.txt included in this distribution for the specific
248N/A * language governing permissions and limitations under the License.
248N/A *
248N/A * When distributing Covered Code, include this CDDL HEADER in each
248N/A * file and include the License file at LICENSE.txt.
248N/A * If applicable, add the following below this CDDL HEADER, with the
248N/A * fields enclosed by brackets "[]" replaced with your own identifying
248N/A * information: Portions Copyright [yyyy] [name of copyright owner]
248N/A *
248N/A * CDDL HEADER END
248N/A */
248N/A
248N/A/*
248N/A * Copyright 2006 Trond Norbye. All rights reserved.
248N/A * Use is subject to license terms.
3996N/A */
248N/Apackage org.opensolaris.opengrok.history;
248N/A
814N/Aimport java.io.File;
814N/Aimport java.io.PrintWriter;
2238N/Aimport java.util.ArrayList;
814N/Aimport java.util.Date;
248N/Aimport java.util.List;
248N/A
248N/A/**
248N/A * Collect all information of a given revision
248N/A *
248N/A * @author Trond Norbye
248N/A */
844N/Apublic class HistoryEntry {
844N/A private String revision;
248N/A private Date date;
1273N/A private String author;
248N/A private StringBuffer message;
3661N/A private boolean active;
3661N/A private List<String> files;
3996N/A
3996N/A /* This holds the subversion repository's view of where the file is in a particular revision */
3996N/A private File repositoryPath;
248N/A
248N/A /* This holds the source root's view of where the file is in a particular revision */
248N/A private File sourceRootPath;
248N/A
248N/A /** Creates a new instance of HistoryEntry */
248N/A public HistoryEntry() {
690N/A message = new StringBuffer();
248N/A files = new ArrayList<String>();
248N/A }
690N/A
248N/A public HistoryEntry(String revision, Date date, String author,
248N/A String message, boolean active) {
248N/A this.revision = revision;
248N/A this.date = date;
248N/A this.author = author;
248N/A this.message = new StringBuffer(message);
248N/A this.active = active;
248N/A }
248N/A
248N/A public String getLine() {
248N/A return revision + " " + date + " " + author + " " + message + "\n";
248N/A }
248N/A
248N/A public String getAuthor() {
248N/A return author;
248N/A }
248N/A
2490N/A public Date getDate() {
248N/A return date;
248N/A }
248N/A
248N/A public String getMessage() {
248N/A return message.toString().trim();
248N/A }
248N/A
248N/A public String getRevision() {
248N/A return revision;
3996N/A }
3996N/A
3996N/A public void setAuthor(String author) {
3996N/A this.author = author;
3996N/A }
3996N/A
3996N/A public void setDate(Date date) {
this.date = date;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public void setMessage(String message) {
this.message.setLength(0);
this.message.append(message);
}
public void setRevision(String revision) {
this.revision = revision;
}
public void appendMessage(String message) {
this.message.append(message);
this.message.append("\n");
}
public void addFile(String file) {
files.add(file);
}
public List<String> getFiles() {
return files;
}
public void setFiles(List<String> files) {
this.files = files;
}
public String toString() {
return getLine();
}
/**
* Returns the subversion repository's view of where the file is
* in a particular revision.
*
* @return the path
*/
public File getRepositoryPath() {
return repositoryPath;
}
/**
* Sets the subversion repository's view of where the file is
* in a particular revision.
*
* @param path the path
*/
public void setRepositoryPath(File path) {
repositoryPath = path;
}
/**
* Returns the source root's view of where the file is in a particular revision.
*
* @return the path
*/
public File getSourceRootPath() {
return sourceRootPath;
}
/**
* Sets the source root's view of where the file is in a particular revision.
*
* @param path the path
*/
public void setSourceRootPath(File path) {
sourceRootPath = path;
}
/**
* Remove "unneeded" info such as multiline history and files list
*/
public void strip() {
int idx = message.indexOf("\n");
if (idx != -1) {
message.setLength(idx);
}
files.clear();
}
}