View Javadoc

1   /*
2   The MIT License
3   
4   Copyright (c) 2004, The Codehaus
5   
6   Permission is hereby granted, free of charge, to any person obtaining a copy of
7   this software and associated documentation files (the "Software"), to deal in
8   the Software without restriction, including without limitation the rights to
9   use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10  of the Software, and to permit persons to whom the Software is furnished to do
11  so, subject to the following conditions:
12  
13  The above copyright notice and this permission notice shall be included in all
14  copies or substantial portions of the Software.
15  
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  SOFTWARE.
23   */
24  package org.codehaus.mojo.scmchangelog.changelog.log;
25  
26  import java.util.Date;
27  
28  /**
29   * Represents a log entry from the subversion repository.
30   * @author ehsavoie
31   * @version $Id: ScmLogEntry.java 10735 2009-09-21 20:14:44Z ehsavoie $
32   */
33  public class ScmLogEntry
34      implements Comparable
35  {
36  
37    /**
38     * Holds value of property revision.
39     */
40    private String revision;
41    /**
42     * Holds value of property date.
43     */
44    private Date date;
45    /**
46     * Holds value of property message.
47     */
48    private Message message;
49    /**
50     * Holds value of property author.
51     */
52    private String author;
53  
54    /** Creates a new instance of ScmLogEntry */
55    public ScmLogEntry()
56    {
57    }
58  
59    /**
60     * Getter for property revision.
61     * @return Value of property revision.
62     */
63    public String getRevision()
64    {
65      return this.revision;
66    }
67  
68    /**
69     * Setter for property revision.
70     * @param revision New value of property revision.
71     */
72    public void setRevision( String revision )
73    {
74      this.revision = revision;
75    }
76  
77    /**
78     * Getter for property date.
79     * @return Value of property date.
80     */
81    public Date getDate()
82    {
83      return this.date;
84    }
85  
86    /**
87     * Setter for property date.
88     * @param date New value of property date.
89     */
90    public void setDate( Date date )
91    {
92      this.date = date;
93    }
94  
95    /**
96     * Getter for property message.
97     * @return Value of property message.
98     */
99    public Message getMessage()
100   {
101     return this.message;
102   }
103 
104   /**
105    * Setter for property message.
106    * @param message New value of property message.
107    */
108   public void setMessage( Message message )
109   {
110     this.message = message;
111   }
112 
113   /**
114    * Getter for property author.
115    * @return Value of property author.
116    */
117   public String getAuthor()
118   {
119     return this.author;
120   }
121 
122   /**
123    * Setter for property author.
124    * @param author New value of property author.
125    */
126   public void setAuthor( String author )
127   {
128     this.author = author;
129   }
130 
131   /**
132    * Compare method, to order log entries.
133    * @param object the object to be compred with this.
134    * @return a positive integer if this is after object -
135    * a negative integer if this is before object and 0 if they are equal.
136    */
137   public int compareTo( Object object )
138   {
139     if ( object != null )
140     {
141       ScmLogEntry entry = (ScmLogEntry) object;
142       try
143       {
144         int currentRevision = Integer.parseInt( revision );
145         int otherRevision = Integer.parseInt( entry.getRevision() );
146         return currentRevision - otherRevision;
147       }
148       catch ( NumberFormatException nfex )
149       {
150         //Do nothing revisions are not numbers.
151       }
152       return this.revision.compareTo( entry.getRevision() );
153     }
154     return -1;
155   }
156 }