001: /*
002: * ====================================================================
003: * Copyright (c) 2004-2008 TMate Software Ltd. All rights reserved.
004: *
005: * This software is licensed as described in the file COPYING, which
006: * you should have received as part of this distribution. The terms
007: * are also available at http://svnkit.com/license.html
008: * If newer versions of this license are posted there, you may use a
009: * newer version instead, at your option.
010: * ====================================================================
011: */
012:
013: package org.tmatesoft.svn.core;
014:
015: import java.util.Date;
016:
017: /**
018: * The <b>SVNCommitInfo</b> class represents information about a committed
019: * revision. Commit information includes:
020: * <ol>
021: * <li>a revision number;
022: * <li>a datestamp when the revision was committed;
023: * <li>the name of the revision author.
024: * </ol>
025: * In addition, this class provides anexception that, if a commit has failed,
026: * has got a description of a failure reason.
027: *
028: * @version 1.1.1
029: * @author TMate Software Ltd.
030: */
031: public class SVNCommitInfo {
032: /**
033: * Denotes an unsuccessful commit.
034: */
035: public static final SVNCommitInfo NULL = new SVNCommitInfo(-1,
036: null, null, null);
037:
038: private long myNewRevision;
039: private Date myDate;
040: private String myAuthor;
041: private SVNErrorMessage myErrorMessage;
042:
043: /**
044: *
045: * Constructs an <b>SVNCommitInfo</b> object.
046: *
047: * @param revision a revision number
048: * @param author the name of the author who committed the revision
049: * @param date the datestamp when the revision was committed
050: */
051: public SVNCommitInfo(long revision, String author, Date date) {
052: this (revision, author, date, null);
053: }
054:
055: /**
056: * Constructs an <b>SVNCommitInfo</b> object.
057: *
058: * @param revision a revision number
059: * @param author the name of the author who committed the revision
060: * @param date the datestamp when the revision was committed
061: * @param error if a commit failed - this is an error description
062: * containing details on the failure
063: */
064: public SVNCommitInfo(long revision, String author, Date date,
065: SVNErrorMessage error) {
066: myNewRevision = revision;
067: myAuthor = author;
068: myDate = date;
069: myErrorMessage = error;
070: }
071:
072: /**
073: * Gets the revision number the repository was committed to.
074: *
075: * @return a revision number
076: */
077: public long getNewRevision() {
078: return myNewRevision;
079: }
080:
081: /**
082: * Gets the name of the revision author
083: *
084: * @return a revision author's name
085: */
086: public String getAuthor() {
087: return myAuthor;
088: }
089:
090: /**
091: * Gets the datestamp when the revision was committed.
092: *
093: * @return a revision datestamp
094: */
095: public Date getDate() {
096: return myDate;
097: }
098:
099: /**
100: * Gets an error message for a failed commit (if it
101: * has failed). This message will usually keep the entire
102: * stack trace of all the error messages as of results of errors
103: * occurred.
104: *
105: * @return an error messages or <span class="javakeyword">null</span>.
106: */
107: public SVNErrorMessage getErrorMessage() {
108: return myErrorMessage;
109: }
110:
111: /**
112: * @deprecated use {@link #getErrorMessage() } instead
113: */
114: public SVNException getError() {
115: if (myErrorMessage != null) {
116: return new SVNException(getErrorMessage());
117: }
118: return null;
119: }
120:
121: /**
122: * Gives a string representation of this object.
123: *
124: * @return a string describing commit info
125: */
126: public String toString() {
127: if (this == NULL) {
128: return "EMPTY COMMIT";
129: } else if (myErrorMessage == null) {
130: StringBuffer sb = new StringBuffer();
131: sb.append("r");
132: sb.append(myNewRevision);
133: if (myAuthor != null) {
134: sb.append(" by '");
135: sb.append(myAuthor);
136: sb.append("'");
137: }
138: if (myDate != null) {
139: sb.append(" at ");
140: sb.append(myDate);
141: }
142: return sb.toString();
143: } else {
144: return myErrorMessage.getFullMessage();
145: }
146: }
147: }
|