Index: /home/christoph/workspace/changelog/project.xml =================================================================== --- /home/christoph/workspace/changelog/project.xml (revision 396338) +++ /home/christoph/workspace/changelog/project.xml (working copy) @@ -83,6 +83,11 @@ Christoph Jerolimov + c.jerolimov@tarent.de + tarent GmbH, Germany + + Java Developer + Index: /home/christoph/workspace/changelog/src/main/org/apache/maven/mkslib/MksChangeLogParser.java =================================================================== --- /home/christoph/workspace/changelog/src/main/org/apache/maven/mkslib/MksChangeLogParser.java (revision 371829) +++ /home/christoph/workspace/changelog/src/main/org/apache/maven/mkslib/MksChangeLogParser.java (working copy) @@ -85,8 +85,74 @@ /** current changelog file */ private ChangeLogFile changeLogFile; + /** date filter, only entries after this date match */ + private Date filterDateStart; + + /** date filter, only entries before this date match */ + private Date filterDateEnd; + public void init( ChangeLog changeLog ) { + if (changeLog.getType().equals("range")) + { + try + { + if ( ( changeLog.getRange() != null ) + && ( changeLog.getRange().length() != 0 ) ) + { + long range = Integer.parseInt(changeLog.getRange()); + filterDateStart = new Date(System.currentTimeMillis() + - ( range * ( 24 * 60 * 60 * 1000 ) ) ); + filterDateEnd = null; + } + else + { + throw new NumberFormatException("no range"); + } + } + catch (NumberFormatException e) + { + e.printStackTrace(); + filterDateStart = null; + filterDateEnd = null; + } + } + else if (changeLog.getType().equals("date")) + { + if ( ( changeLog.getMarkerStart() != null ) + && ( changeLog.getMarkerStart().length() != 0 ) ) + { + try + { + filterDateStart = new SimpleDateFormat("y-M-d"). + parse(changeLog.getMarkerStart()); + } + catch (ParseException e) + { + e.printStackTrace(); + filterDateStart = null; + } + } + + if ( ( changeLog.getMarkerEnd() != null ) + && ( changeLog.getMarkerEnd().length() != 0 ) ) + { + try + { + filterDateEnd = new SimpleDateFormat("y-M-d"). + parse(changeLog.getMarkerEnd()); + } + catch (ParseException e) + { + e.printStackTrace(); + filterDateEnd = null; + } + } + } + else if (changeLog.getType().equals("tag")) + { + // MKS filter for 'tag' is not impl yet. + } } public void cleanup() @@ -269,6 +335,13 @@ return; } + // do not add if entry doesn't match date range. + if ( (filterDateStart != null && changeLogEntry.getDate().before(filterDateStart)) || + (filterDateEnd != null && changeLogEntry.getDate().after(filterDateEnd)) ) + { + return; + } + String key = ENTRY_KEY_TIMESTAMP_FORMAT.format( changeLogEntry.getDate() ) + changeLogEntry.getAuthor() + changeLogEntry.getComment(); Index: /home/christoph/workspace/changelog/src/test/org/apache/maven/mkslib/MksChangeLogParserTest.java =================================================================== --- /home/christoph/workspace/changelog/src/test/org/apache/maven/mkslib/MksChangeLogParserTest.java (revision 371829) +++ /home/christoph/workspace/changelog/src/test/org/apache/maven/mkslib/MksChangeLogParserTest.java (working copy) @@ -20,6 +20,7 @@ import junit.framework.TestCase; +import org.apache.maven.changelog.ChangeLog; import org.apache.maven.changelog.ChangeLogEntry; import java.io.FileInputStream; @@ -26,6 +27,7 @@ import java.io.IOException; import java.util.Collection; +import java.util.Date; import java.util.Iterator; import java.util.Locale; @@ -38,6 +40,9 @@ */ public class MksChangeLogParserTest extends TestCase { + /** the {link ChangeLog} used for testing */ + private ChangeLog changeLog; + /** the {@link MksChangeLogParser} used for testing */ private MksChangeLogParser instance; @@ -59,14 +64,25 @@ */ public void setUp() throws Exception { - // We force the english locale + // We force the german locale // because the test file uses it. - Locale.setDefault(Locale.ENGLISH); + Locale.setDefault(Locale.GERMAN); String baseDir = System.getProperty( "basedir" ); + if (baseDir == null) + baseDir = "/home/christoph/workspace/changelog"; assertNotNull( "The system property basedir was not defined.", baseDir ); testFile = baseDir + "/src/test-resources/mkslib/mkslog.txt"; + + System.out.println(new Date()); + + changeLog = new ChangeLog(); + changeLog.setType("date"); + changeLog.setMarkerStart("2006-01-15"); + changeLog.setMarkerEnd("2006-01-31"); + instance = new MksChangeLogParser(); + instance.init( changeLog ); } /** Index: /home/christoph/workspace/changelog/src/test-resources/mkslib/mkslog.txt =================================================================== --- /home/christoph/workspace/changelog/src/test-resources/mkslib/mkslog.txt (revision 371829) +++ /home/christoph/workspace/changelog/src/test-resources/mkslib/mkslog.txt (working copy) @@ -54,3 +54,19 @@ date: Jan 16, 2006 - 16:02 PM; author: AUTHOR; state: InWork; lines: +0 -0 Initial revision =============================================================================== +member name: myproject/oldfile; working file: /myproject/oldfile +head: 1.1 +member: 1.1 +branch: +locks: ; strict +attributes: +file format: text +revision storage: reverse deltas +total revisions: 1; branches: 0; branch revisions: 0 +description: +Initial Version +----------------------- +revision 1.1 +date: Jan 14, 2006 - 11:02 PM; author: AUTHOR; state: InWork; lines: +0 -0 +Initial revision +===============================================================================