dion 02/04/21 00:03:32
Modified: src/java/org/apache/maven/cvslib ChangeLogParser.java
ChangeLogEntry.java
src/dvsl/xdocs site.dvsl
src/test/org/apache/maven/cvslib ChangeLogEntryTest.java
Log:
- Added time to changelog output
- made the message format as it is from CVS
Revision Changes Path
1.15 +14 -9
jakarta-turbine-maven/src/java/org/apache/maven/cvslib/ChangeLogParser.java
Index: ChangeLogParser.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/cvslib/ChangeLogParser.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ChangeLogParser.java 21 Apr 2002 04:13:20 -0000 1.14
+++ ChangeLogParser.java 21 Apr 2002 07:03:32 -0000 1.15
@@ -61,6 +61,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
+import java.util.StringTokenizer;
import java.util.TreeMap;
/**
@@ -68,7 +69,7 @@
*
* @todo make previous revisions processing same as current revision
* @author <a href="mailto:[EMAIL PROTECTED]">dIon Gillard</a>
- * @version $Id: ChangeLogParser.java,v 1.14 2002/04/21 04:13:20 dion Exp $
+ * @version $Id: ChangeLogParser.java,v 1.15 2002/04/21 07:03:32 dion Exp $
*/
public class ChangeLogParser
{
@@ -174,8 +175,8 @@
// do not add if entry is not populated
if (entry.getAuthor() == null) return;
- String key = entry.getDateFormatted() + entry.getAuthor() +
- entry.getComment();
+ String key = entry.getDateFormatted() + entry.getTimeFormatted() +
+ entry.getAuthor() + entry.getComment();
if (!entries.containsKey(key))
{
entry.addFile(file);
@@ -229,12 +230,16 @@
{
if (line.startsWith(DATE_TAG))
{
- getCurrentLogEntry().setDate(
- line.substring(DATE_TAG.length(), 16));
- line = line.substring(line.indexOf(";") + 1);
- // 10 = ' author: '.length()
- getCurrentLogEntry().setAuthor(
- line.substring(10, line.indexOf(";")));
+ StringTokenizer tokenizer = new StringTokenizer(line, " ;");
+ // date: YYYY/mm/dd HH:mm:ss; author: name
+ tokenizer.nextToken(); // date tag
+ String date = tokenizer.nextToken();
+ String time = tokenizer.nextToken();
+ getCurrentLogEntry().setDate(date + " " + time);
+ tokenizer.nextToken(); // author tag
+ // assumes author can't contain spaces
+ String author = tokenizer.nextToken();
+ getCurrentLogEntry().setAuthor(author);
setStatus(GET_COMMENT);
}
}
1.11 +17 -6
jakarta-turbine-maven/src/java/org/apache/maven/cvslib/ChangeLogEntry.java
Index: ChangeLogEntry.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/cvslib/ChangeLogEntry.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ChangeLogEntry.java 21 Apr 2002 04:14:30 -0000 1.10
+++ ChangeLogEntry.java 21 Apr 2002 07:03:32 -0000 1.11
@@ -66,7 +66,7 @@
* @todo add time of change to the entry
* @todo investigate betwixt for toXML method
* @author <a href="mailto:[EMAIL PROTECTED]">dIon Gillard</a>
- * @version $Id: ChangeLogEntry.java,v 1.10 2002/04/21 04:14:30 dion Exp $
+ * @version $Id: ChangeLogEntry.java,v 1.11 2002/04/21 07:03:32 dion Exp $
*/
public class ChangeLogEntry
{
@@ -153,7 +153,7 @@
.append(getDateFormatted())
.append("</date>\n")
.append("\t\t<time>")
- .append(outputTime.format(date))
+ .append(getTimeFormatted())
.append("</time>\n")
.append("\t\t<author><![CDATA[")
.append(author)
@@ -239,11 +239,12 @@
/**
* Setter for property date that takes a string and parses it
- * @param date - a string in yyyy/MM/dd format
+ * @param date - a string in yyyy/MM/dd HH:mm:ss format
*/
public void setDate(String date)
{
- SimpleDateFormat inputDate = new SimpleDateFormat("yyyy/MM/dd");
+ SimpleDateFormat inputDate =
+ new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
try
{
this.date = inputDate.parse(date);
@@ -261,7 +262,17 @@
*/
public String getDateFormatted()
{
- SimpleDateFormat outputDate = new SimpleDateFormat("yyyy-MM-dd");
- return outputDate.format(getDate());
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ return dateFormat.format(getDate());
}
+
+ /**
+ * @return time in HH:mm:ss format
+ */
+ public String getTimeFormatted()
+ {
+ SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
+ return timeFormat.format(getDate());
+ }
+
}
1.25 +3 -2 jakarta-turbine-maven/src/dvsl/xdocs/site.dvsl
Index: site.dvsl
===================================================================
RCS file: /home/cvs/jakarta-turbine-maven/src/dvsl/xdocs/site.dvsl,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- site.dvsl 8 Apr 2002 00:10:21 -0000 1.24
+++ site.dvsl 21 Apr 2002 07:03:32 -0000 1.25
@@ -292,7 +292,7 @@
#set ($rowcount = 0)
<table>
<tr>
- <th>Date</th><th>Author</th><th>Files / Message</th>
+ <th>Date</th><th>Time</th><th>Author</th><th>Files / Message</th>
</tr>
$context.applyTemplates("changelog-entry")
</table>
@@ -306,10 +306,11 @@
#end
#set ($rowcount = $rowcount + 1)
<td>$node.date.value()</td>
+ <td>$node.time.value()</td>
<td>$context.toolbox.htmlescape.getText($node.author.value())</td>
<td>
$context.applyTemplates("file")
- <br/>$context.toolbox.htmlescape.getText($node.msg.value())
+ <br/><pre>$context.toolbox.htmlescape.getText($node.msg.value())</pre>
</td>
</tr>
#end
1.6 +12 -4
jakarta-turbine-maven/src/test/org/apache/maven/cvslib/ChangeLogEntryTest.java
Index: ChangeLogEntryTest.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/test/org/apache/maven/cvslib/ChangeLogEntryTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ChangeLogEntryTest.java 14 Apr 2002 16:49:02 -0000 1.5
+++ ChangeLogEntryTest.java 21 Apr 2002 07:03:32 -0000 1.6
@@ -66,7 +66,7 @@
* Tests for the {@link ChangeLogEntry} class
*
* @author dion
- * @version $Id: ChangeLogEntryTest.java,v 1.5 2002/04/14 16:49:02 dion Exp $
+ * @version $Id: ChangeLogEntryTest.java,v 1.6 2002/04/21 07:03:32 dion Exp $
*/
public class ChangeLogEntryTest extends TestCase {
@@ -105,7 +105,7 @@
instance = new ChangeLogEntry();
instance.setAuthor("dion");
instance.setComment("comment");
- instance.setDate("2002/04/01");
+ instance.setDate("2002/04/01 00:00:00");
}
/**
@@ -232,7 +232,7 @@
* Test of setDate method with String
*/
public void testSetDateFromString() {
- instance.setDate("2002/03/04");
+ instance.setDate("2002/03/04 00:00:00");
Calendar cal = Calendar.getInstance();
cal.set(2002, 2, 4, 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
@@ -248,7 +248,15 @@
assertEquals("Date not formatted correctly", "2002-04-01",
instance.getDateFormatted());
}
-
+
+ /**
+ * Test of getDateFormatted method
+ */
+ public void testGetTimeFormatted() {
+ assertEquals("Time not formatted correctly", "00:00:00",
+ instance.getTimeFormatted());
+ }
+
// Add test methods here, they have to start with 'test' name.
// for example:
// public void testHello() {}