You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by lt...@apache.org on 2006/01/18 20:12:55 UTC
svn commit: r370221 [1/3] - in /maven/maven-1/plugins/trunk/changelog/src:
main/org/apache/maven/changelog/ main/org/apache/maven/clearcaselib/
main/org/apache/maven/cvslib/ main/org/apache/maven/perforcelib/
main/org/apache/maven/starteamlib/ main/org...
Author: ltheussl
Date: Wed Jan 18 11:12:42 2006
New Revision: 370221
URL: http://svn.apache.org/viewcvs?rev=370221&view=rev
Log:
Jalopy source code formatting - fix a bunch of pmd and checkstyle warnings
Modified:
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/AbstractChangeLogGenerator.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogEntry.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogFile.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogGenerator.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogParser.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogSet.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogFactory.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogGenerator.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogParser.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/cvslib/CvsChangeLogFactory.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/cvslib/CvsChangeLogGenerator.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/cvslib/CvsChangeLogParser.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/cvslib/CvsConnection.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/cvslib/CvsLogListener.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/perforcelib/PerforceChangeLogFactory.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/perforcelib/PerforceChangeLogGenerator.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/perforcelib/PerforceChangeLogParser.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/starteamlib/StarteamChangeLogFactory.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/starteamlib/StarteamChangeLogGenerator.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/starteamlib/StarteamChangeLogParser.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/svnlib/SvnChangeLogFactory.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/svnlib/SvnChangeLogGenerator.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/svnlib/SvnChangeLogParser.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/util/AsyncStreamReader.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/util/RepositoryUtils.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/vsslib/VssChangeLogFactory.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/vsslib/VssChangeLogGenerator.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/vsslib/VssChangeLogParser.java
maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/vsslib/VssConnection.java
maven/maven-1/plugins/trunk/changelog/src/test/org/apache/maven/starteamlib/StarteamChangeLogParser2Test.java
maven/maven-1/plugins/trunk/changelog/src/test/org/apache/maven/starteamlib/StarteamChangeLogParserTest.java
Modified: maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/AbstractChangeLogGenerator.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/AbstractChangeLogGenerator.java?rev=370221&r1=370220&r2=370221&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/AbstractChangeLogGenerator.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/AbstractChangeLogGenerator.java Wed Jan 18 11:12:42 2006
@@ -19,22 +19,26 @@
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
+
import java.text.ParseException;
import java.text.SimpleDateFormat;
+
import java.util.Collection;
import java.util.Date;
-// maven imports
-import org.apache.maven.util.AsyncStreamReader;
// commons imports
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+// maven imports
+import org.apache.maven.util.AsyncStreamReader;
+import org.apache.tools.ant.taskdefs.Execute;
+
// ant imports
import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
-import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.types.Commandline;
/**
@@ -48,413 +52,447 @@
* @author <a href="mailto:bodewig@apache.org">Stefan Bodewig</a>
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @author <a href="mailto:pete-apache-dev@kazmier.com">Pete Kazmier</a>
- * @version
+ * @version
* $Id$
*/
-public abstract class AbstractChangeLogGenerator implements ChangeLogGenerator, ExecuteStreamHandler
+public abstract class AbstractChangeLogGenerator implements ChangeLogGenerator,
+ ExecuteStreamHandler
{
- /**
- * The working directory.
- */
- protected File base;
-
- /**
- * Reference to the enclosing ChangeLog instance - used to obtain
- * any necessary configuration information.
- */
- protected ChangeLog changeLogExecutor;
-
- /**
- * The parser that takes the log output and transforms it into a
- * collection of ChangeLogEntry's.
- */
- protected ChangeLogParser clParser;
-
- /** The connection string from the project */
- private String connection;
-
- /** The log type (range, date, or tag). */
- protected String type;
-
- /**
- * The date range command line argument.
- */
- protected String dateRange;
-
- /** The tag command line argument. */
- protected String tag;
-
- /** Represents when this log starts (for the report). */
- protected String logStart = "";
-
- /** Represents when this log ends (for the report). */
- protected String logEnd = "";
-
- /**
- * The collection of ChangeLogEntry's returned from clParser.
- */
- protected Collection entries;
-
- /**
- * Stderr stream eater.
- */
- protected AsyncStreamReader errorReader;
-
- /**
- * The scm process input stream.
- */
- protected InputStream in;
-
- /**
- * The comment format string used in interrogating the RCS.
- */
- protected String commentFormat;
-
- /** Log */
- private static final Log LOG = LogFactory.getLog(AbstractChangeLogGenerator.class);
-
- /**
- * Initialize the generator from the changelog controller.
- *
- * @param changeLog The invoking controller (useful for logging)
- * @see ChangeLogGenerator#init(ChangeLog)
- */
- public void init(ChangeLog changeLog)
- {
- changeLogExecutor = changeLog;
-
- base = changeLogExecutor.getBasedir();
-
- type = changeLogExecutor.getType();
-
- if (type.equalsIgnoreCase("tag"))
- {
- tag = getScmTagArgument(changeLogExecutor.getMarkerStart(), changeLogExecutor.getMarkerEnd());
- logStart = changeLogExecutor.getMarkerStart();
- logEnd = (changeLogExecutor.getMarkerEnd() == null) ? "" : changeLogExecutor.getMarkerEnd();
- }
- else if (type.equalsIgnoreCase("date"))
- {
- setDateRangeFromAbsoluteDate(changeLogExecutor.getMarkerStart(), changeLogExecutor.getMarkerEnd());
- }
- else // type == "range" (the default)
- {
- // This lets the user 'not' set a limit on the log command. We
- // need this cuz Subversion doesn't currently support date
- // commands on web-based repositories, so it would be nice to
- // let the user still use the changelog plugin.
- if (changeLogExecutor.getRange() != null && changeLogExecutor.getRange().length() != 0)
- {
- setDateRange(changeLogExecutor.getRange());
- }
- }
-
- setConnection(changeLogExecutor.getRepositoryConnection());
-
- // set the comment query string for the RCS.
- setCommentFormat(changeLogExecutor.getCommentFormat());
- }
-
- /**
- * Set the dateRange member based on the number of days obtained
- * from the ChangeLog.
- *
- * @param numDaysString The number of days of log output to
- * generate.
- */
- protected void setDateRange(String numDaysString)
- {
- int days = Integer.parseInt(numDaysString);
-
- Date before = new Date(System.currentTimeMillis() - (long) days * 24 * 60 * 60 * 1000);
- Date to = new Date(System.currentTimeMillis() + (long) 1 * 24 * 60 * 60 * 1000);
-
- dateRange = getScmDateArgument(before, to);
- setLogStart(before);
- setLogEnd(to);
- }
-
- /**
- * Set the dateRange member based on an absolute date.
- * @param startDate The start date for the range.
- * @param endDate The end date for the range, or <code>null</code> to use the present time.
- */
- protected void setDateRangeFromAbsoluteDate(String startDate, String endDate)
- {
- String dateFormat = changeLogExecutor.getDateFormat();
- SimpleDateFormat format = dateFormat == null ? new SimpleDateFormat("yyyy-MM-dd") : new SimpleDateFormat(dateFormat);
-
- Date before;
- try
- {
- before = format.parse(startDate);
- }
- catch (ParseException ex)
- {
- throw new IllegalArgumentException("Unable to parse start date " + startDate + ": " + ex.getLocalizedMessage());
- }
- Date to;
- try
- {
- to = (endDate != null) ? format.parse(endDate) : new Date(System.currentTimeMillis() + (long) 1 * 24 * 60 * 60 * 1000);
- }
- catch (ParseException ex)
- {
- throw new IllegalArgumentException("Unable to parse end date " + endDate + ": " + ex.getLocalizedMessage());
- }
-
- dateRange = getScmDateArgument(before, to);
- setLogStart(before);
- setLogEnd(to);
- }
-
- /**
- * Sets the log start string based on the given date.
- * This uses the date format supplied in the plugin properties.
- *
- * @param start date the log started.
- */
- protected void setLogStart(Date start)
- {
- String dateFormat = changeLogExecutor.getDateFormat();
- SimpleDateFormat format = dateFormat == null ? new SimpleDateFormat("yyyy-MM-dd") : new SimpleDateFormat(dateFormat);
-
- logStart = format.format(start);
- }
-
- /**
- * Sets the log end string based on the given date.
- * This uses the date format supplied in the plugin properties.
- *
- * @param end date the log ended.
- */
- protected void setLogEnd(Date end)
- {
- String dateFormat = changeLogExecutor.getDateFormat();
- SimpleDateFormat format = dateFormat == null ? new SimpleDateFormat("yyyy-MM-dd") : new SimpleDateFormat(dateFormat);
-
- logEnd = format.format(end);
- }
-
- /**
- * Execute scm client driving the given parser.
- *
- * @param parser A {@link ChangeLogParser parser} to process the scm
- * output.
- * @return A collection of {@link ChangeLogEntry entries} parsed from
- * the scm output.
- * @throws IOException When there are issues executing scm.
- * @see ChangeLogGenerator#getEntries(ChangeLogParser)
- */
- public Collection getEntries(ChangeLogParser parser) throws IOException
- {
- if (parser == null)
- {
- throw new NullPointerException("parser cannot be null");
- }
-
- if (base == null)
- {
- throw new NullPointerException("basedir must be set");
- }
-
- if (!base.exists())
- {
- throw new FileNotFoundException("Cannot find base dir " + base.getAbsolutePath());
- }
-
- clParser = parser;
- try
- {
- Execute exe = new Execute(this);
- exe.setCommandline(getScmLogCommand().getCommandline());
- exe.setWorkingDirectory(base);
- logExecute(exe, base);
-
- exe.execute();
-
- // log messages from stderr
- String errors = errorReader.toString().trim();
- if (errors.length() > 0)
- {
- LOG.error(errors);
- }
- }
- catch (IOException ioe)
- {
- handleParserException(ioe);
- }
-
- return entries;
- }
-
- /**
- * Handle ChangeLogParser IOExceptions. The default implementation
- * just throws the exception again.
- *
- * @param ioe The IOException thrown.
- * @throws IOException If the handler doesn't wish to handle the
- * exception (the default behavior).
- */
- protected void handleParserException(IOException ioe) throws IOException
- {
- throw ioe;
- }
-
- /**
- * @see ChangeLogGenerator#getLogStart()
- */
- public String getLogStart()
- {
- return logStart;
- }
-
- /**
- * @see ChangeLogGenerator#getLogEnd()
- */
- public String getLogEnd()
- {
- // TODO: Auto-generated method stub
- return logEnd;
- }
-
- /**
- * Clean up any generated resources for this run.
- *
- * @see ChangeLogGenerator#cleanup()
- */
- public void cleanup()
- {
- }
-
- /**
- * Constructs the appropriate command line to execute the scm's
- * log command. This method must be implemented by subclasses.
- *
- * @return The command line to be executed.
- */
- protected abstract Commandline getScmLogCommand();
-
- /**
- * Construct the command-line argument that is passed to the scm
- * client to specify the appropriate date range.
- *
- * @param before The starting point.
- * @param to The ending point.
- * @return A string that can be used to specify a date to a scm
- * system.
- */
- protected abstract String getScmDateArgument(Date before, Date to);
-
- /**
- * Construct the command-line argument that is passed to the scm
- * client to specify the appropriate tag.
- *
- * @param tagStart The tag name for the start of the log (log shouldn't actually contain the tag).
- * @param tagEnd The tag name for the end of the log (the log can contain this tag), or <code>null</code> to
- * log all changes since <code>tagStart</code>.
- * @return A string that can be used to specify the tag range to a scm system.
- */
- protected abstract String getScmTagArgument(String tagStart, String tagEnd);
-
- /**
- * Stop the process - currently unimplemented
- */
- public void stop()
- {
- }
-
- /**
- * Set the input stream for the scm process.
- * @param os An {@link java.io.OutputStream}
- */
- public void setProcessInputStream(OutputStream os)
- {
- }
-
- /**
- * Set the error stream for reading from scm log. This stream will
- * be read on a separate thread.
- *
- * @param is An {@link java.io.InputStream}
- */
- public void setProcessErrorStream(InputStream is)
- {
- errorReader = new AsyncStreamReader(is);
- }
-
- /**
- * Set the input stream used to read from scm log.
- *
- * @param is A stream of scm log output to be read from
- */
- public void setProcessOutputStream(InputStream is)
- {
- in = is;
- }
-
- /**
- * Start read from the scm log.
- *
- * @throws IOException When there are errors reading from the
- * streams previously provided
- */
- public void start() throws IOException
- {
- errorReader.start();
- entries = clParser.parse(in);
- }
-
- /**
- * Returns the connection.
- * @return String
- */
- public String getConnection()
- {
- return connection;
- }
-
- /**
- * Sets the connection.
- * @param connection The connection to set
- */
- public void setConnection(String connection)
- {
- this.connection = connection;
- }
-
- /**
- * Returns the commentFormat used to interrogate the RCS.
- * @return String
- */
- public String getCommentFormat()
- {
- return commentFormat;
- }
-
- /**
- * Sets the commentFormat.
- * @param commentFormat The commentFormat to set
- */
- public void setCommentFormat(String commentFormat)
- {
- this.commentFormat = commentFormat;
- }
-
- /**
- * Logs the pertinent details to the logging system (info level)
- * @param exe The object to log
- * @param base The working directory
- */
- public static void logExecute(Execute exe, File base)
- {
- String c[] = exe.getCommandline();
- LOG.info("SCM Working Directory: " + base);
- for (int i = 0; i < c.length; i++)
+ /** Log */
+ private static final Log LOG =
+ LogFactory.getLog( AbstractChangeLogGenerator.class );
+
+ /**
+ * The working directory.
+ */
+ protected File base;
+
+ /**
+ * Reference to the enclosing ChangeLog instance - used to obtain
+ * any necessary configuration information.
+ */
+ protected ChangeLog changeLogExecutor;
+
+ /**
+ * The parser that takes the log output and transforms it into a
+ * collection of ChangeLogEntry's.
+ */
+ protected ChangeLogParser clParser;
+
+ /** The connection string from the project */
+ private String connection;
+
+ /** The log type (range, date, or tag). */
+ protected String type;
+
+ /**
+ * The date range command line argument.
+ */
+ protected String dateRange;
+
+ /** The tag command line argument. */
+ protected String tag;
+
+ /** Represents when this log starts (for the report). */
+ protected String logStart = "";
+
+ /** Represents when this log ends (for the report). */
+ protected String logEnd = "";
+
+ /**
+ * The collection of ChangeLogEntry's returned from clParser.
+ */
+ protected Collection entries;
+
+ /**
+ * Stderr stream eater.
+ */
+ protected AsyncStreamReader errorReader;
+
+ /**
+ * The scm process input stream.
+ */
+ protected InputStream in;
+
+ /**
+ * The comment format string used in interrogating the RCS.
+ */
+ protected String commentFormat;
+
+ /**
+ * Initialize the generator from the changelog controller.
+ *
+ * @param changeLog The invoking controller (useful for logging)
+ * @see ChangeLogGenerator#init(ChangeLog)
+ */
+ public void init( ChangeLog changeLog )
{
- String string = c[i];
- LOG.info("SCM Command Line[" + i + "]: " + string);
+ changeLogExecutor = changeLog;
+
+ base = changeLogExecutor.getBasedir();
+
+ type = changeLogExecutor.getType();
+
+ if ( type.equalsIgnoreCase( "tag" ) )
+ {
+ tag = getScmTagArgument( changeLogExecutor.getMarkerStart(),
+ changeLogExecutor.getMarkerEnd() );
+ logStart = changeLogExecutor.getMarkerStart();
+ logEnd =
+ ( changeLogExecutor.getMarkerEnd() == null ) ? ""
+ : changeLogExecutor
+ .getMarkerEnd();
+ }
+ else if ( type.equalsIgnoreCase( "date" ) )
+ {
+ setDateRangeFromAbsoluteDate( changeLogExecutor.getMarkerStart(),
+ changeLogExecutor.getMarkerEnd() );
+ }
+ else // type == "range" (the default)
+ {
+ // This lets the user 'not' set a limit on the log command. We
+ // need this cuz Subversion doesn't currently support date
+ // commands on web-based repositories, so it would be nice to
+ // let the user still use the changelog plugin.
+ if ( ( changeLogExecutor.getRange() != null )
+ && ( changeLogExecutor.getRange().length() != 0 ) )
+ {
+ setDateRange( changeLogExecutor.getRange() );
+ }
+ }
+
+ setConnection( changeLogExecutor.getRepositoryConnection() );
+
+ // set the comment query string for the RCS.
+ setCommentFormat( changeLogExecutor.getCommentFormat() );
}
- }
+ /**
+ * Set the dateRange member based on the number of days obtained
+ * from the ChangeLog.
+ *
+ * @param numDaysString The number of days of log output to
+ * generate.
+ */
+ protected void setDateRange( String numDaysString )
+ {
+ int days = Integer.parseInt( numDaysString );
+
+ Date before =
+ new Date( System.currentTimeMillis()
+ - ( (long) days * 24 * 60 * 60 * 1000 ) );
+ Date to =
+ new Date( System.currentTimeMillis()
+ + ( (long) 1 * 24 * 60 * 60 * 1000 ) );
+
+ dateRange = getScmDateArgument( before, to );
+ setLogStart( before );
+ setLogEnd( to );
+ }
+
+ /**
+ * Set the dateRange member based on an absolute date.
+ * @param startDate The start date for the range.
+ * @param endDate The end date for the range, or <code>null</code> to use the present time.
+ */
+ protected void setDateRangeFromAbsoluteDate( String startDate,
+ String endDate )
+ {
+ String dateFormat = changeLogExecutor.getDateFormat();
+ SimpleDateFormat format =
+ ( dateFormat == null ) ? new SimpleDateFormat( "yyyy-MM-dd" )
+ : new SimpleDateFormat( dateFormat );
+
+ Date before;
+
+ try
+ {
+ before = format.parse( startDate );
+ }
+ catch ( ParseException ex )
+ {
+ throw new IllegalArgumentException( "Unable to parse start date "
+ + startDate + ": " + ex.getLocalizedMessage() );
+ }
+
+ Date to;
+
+ try
+ {
+ to = ( endDate != null ) ? format.parse( endDate )
+ : new Date( System.currentTimeMillis()
+ + ( (long) 1 * 24 * 60 * 60 * 1000 ) );
+ }
+ catch ( ParseException ex )
+ {
+ throw new IllegalArgumentException( "Unable to parse end date "
+ + endDate + ": " + ex.getLocalizedMessage() );
+ }
+
+ dateRange = getScmDateArgument( before, to );
+ setLogStart( before );
+ setLogEnd( to );
+ }
+
+ /**
+ * Sets the log start string based on the given date.
+ * This uses the date format supplied in the plugin properties.
+ *
+ * @param start date the log started.
+ */
+ protected void setLogStart( Date start )
+ {
+ String dateFormat = changeLogExecutor.getDateFormat();
+ SimpleDateFormat format =
+ ( dateFormat == null ) ? new SimpleDateFormat( "yyyy-MM-dd" )
+ : new SimpleDateFormat( dateFormat );
+
+ logStart = format.format( start );
+ }
+
+ /**
+ * Sets the log end string based on the given date.
+ * This uses the date format supplied in the plugin properties.
+ *
+ * @param end date the log ended.
+ */
+ protected void setLogEnd( Date end )
+ {
+ String dateFormat = changeLogExecutor.getDateFormat();
+ SimpleDateFormat format =
+ ( dateFormat == null ) ? new SimpleDateFormat( "yyyy-MM-dd" )
+ : new SimpleDateFormat( dateFormat );
+
+ logEnd = format.format( end );
+ }
+
+ /**
+ * Execute scm client driving the given parser.
+ *
+ * @param parser A {@link ChangeLogParser parser} to process the scm
+ * output.
+ * @return A collection of {@link ChangeLogEntry entries} parsed from
+ * the scm output.
+ * @throws IOException When there are issues executing scm.
+ * @see ChangeLogGenerator#getEntries(ChangeLogParser)
+ */
+ public Collection getEntries( ChangeLogParser parser )
+ throws IOException
+ {
+ if ( parser == null )
+ {
+ throw new NullPointerException( "parser cannot be null" );
+ }
+
+ if ( base == null )
+ {
+ throw new NullPointerException( "basedir must be set" );
+ }
+
+ if ( !base.exists() )
+ {
+ throw new FileNotFoundException( "Cannot find base dir "
+ + base.getAbsolutePath() );
+ }
+
+ clParser = parser;
+
+ try
+ {
+ Execute exe = new Execute( this );
+
+ exe.setCommandline( getScmLogCommand().getCommandline() );
+ exe.setWorkingDirectory( base );
+ logExecute( exe, base );
+
+ exe.execute();
+
+ // log messages from stderr
+ String errors = errorReader.toString().trim();
+
+ if ( errors.length() > 0 )
+ {
+ LOG.error( errors );
+ }
+ }
+ catch ( IOException ioe )
+ {
+ handleParserException( ioe );
+ }
+
+ return entries;
+ }
+
+ /**
+ * Handle ChangeLogParser IOExceptions. The default implementation
+ * just throws the exception again.
+ *
+ * @param ioe The IOException thrown.
+ * @throws IOException If the handler doesn't wish to handle the
+ * exception (the default behavior).
+ */
+ protected void handleParserException( IOException ioe )
+ throws IOException
+ {
+ throw ioe;
+ }
+
+ /**
+ * @see ChangeLogGenerator#getLogStart()
+ */
+ public String getLogStart()
+ {
+ return logStart;
+ }
+
+ /**
+ * @see ChangeLogGenerator#getLogEnd()
+ */
+ public String getLogEnd()
+ {
+ // TODO: Auto-generated method stub
+ return logEnd;
+ }
+
+ /**
+ * Clean up any generated resources for this run.
+ *
+ * @see ChangeLogGenerator#cleanup()
+ */
+ public void cleanup()
+ {
+ }
+
+ /**
+ * Constructs the appropriate command line to execute the scm's
+ * log command. This method must be implemented by subclasses.
+ *
+ * @return The command line to be executed.
+ */
+ protected abstract Commandline getScmLogCommand();
+
+ /**
+ * Construct the command-line argument that is passed to the scm
+ * client to specify the appropriate date range.
+ *
+ * @param before The starting point.
+ * @param to The ending point.
+ * @return A string that can be used to specify a date to a scm
+ * system.
+ */
+ protected abstract String getScmDateArgument( Date before, Date to );
+
+ /**
+ * Construct the command-line argument that is passed to the scm
+ * client to specify the appropriate tag.
+ *
+ * @param tagStart The tag name for the start of the log (log shouldn't actually contain the tag).
+ * @param tagEnd The tag name for the end of the log (the log can contain this tag), or <code>null</code> to
+ * log all changes since <code>tagStart</code>.
+ * @return A string that can be used to specify the tag range to a scm system.
+ */
+ protected abstract String getScmTagArgument( String tagStart, String tagEnd );
+
+ /**
+ * Stop the process - currently unimplemented
+ */
+ public void stop()
+ {
+ }
+
+ /**
+ * Set the input stream for the scm process.
+ * @param os An {@link java.io.OutputStream}
+ */
+ public void setProcessInputStream( OutputStream os )
+ {
+ }
+
+ /**
+ * Set the error stream for reading from scm log. This stream will
+ * be read on a separate thread.
+ *
+ * @param is An {@link java.io.InputStream}
+ */
+ public void setProcessErrorStream( InputStream is )
+ {
+ errorReader = new AsyncStreamReader( is );
+ }
+
+ /**
+ * Set the input stream used to read from scm log.
+ *
+ * @param is A stream of scm log output to be read from
+ */
+ public void setProcessOutputStream( InputStream is )
+ {
+ in = is;
+ }
+
+ /**
+ * Start read from the scm log.
+ *
+ * @throws IOException When there are errors reading from the
+ * streams previously provided
+ */
+ public void start() throws IOException
+ {
+ errorReader.start();
+ entries = clParser.parse( in );
+ }
+
+ /**
+ * Returns the connection.
+ * @return String
+ */
+ public String getConnection()
+ {
+ return connection;
+ }
+
+ /**
+ * Sets the connection.
+ * @param connection The connection to set
+ */
+ public void setConnection( String connection )
+ {
+ this.connection = connection;
+ }
+
+ /**
+ * Returns the commentFormat used to interrogate the RCS.
+ * @return String
+ */
+ public String getCommentFormat()
+ {
+ return commentFormat;
+ }
+
+ /**
+ * Sets the commentFormat.
+ * @param commentFormat The commentFormat to set
+ */
+ public void setCommentFormat( String commentFormat )
+ {
+ this.commentFormat = commentFormat;
+ }
+
+ /**
+ * Logs the pertinent details to the logging system (info level)
+ * @param exe The object to log
+ * @param base The working directory
+ */
+ public static void logExecute( Execute exe, File base )
+ {
+ String[] c = exe.getCommandline();
+
+ LOG.info( "SCM Working Directory: " + base );
+
+ for ( int i = 0; i < c.length; i++ )
+ {
+ String string = c[i];
+
+ LOG.info( "SCM Command Line[" + i + "]: " + string );
+ }
+ }
}
Modified: maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java?rev=370221&r1=370220&r2=370221&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java Wed Jan 18 11:12:42 2006
@@ -25,6 +25,7 @@
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -55,34 +56,52 @@
*/
public class ChangeLog
{
+ private static final Map FACTORIES = new HashMap();
+
+ /** Log */
+ private static final Log LOG = LogFactory.getLog( ChangeLog.class );
+
+ static
+ {
+ FACTORIES.put( "cvs", "org.apache.maven.cvslib.CvsChangeLogFactory" );
+ FACTORIES.put( "svn", "org.apache.maven.svnlib.SvnChangeLogFactory" );
+ FACTORIES.put( "clearcase",
+ "org.apache.maven.clearcaselib.ClearcaseChangeLogFactory" );
+ FACTORIES.put( "perforce",
+ "org.apache.maven.perforcelib.PerforceChangeLogFactory" );
+ FACTORIES.put( "starteam",
+ "org.apache.maven.starteamlib.StarteamChangeLogFactory" );
+ FACTORIES.put( "vss", "org.apache.maven.vsslib.VssChangeLogFactory" );
+ }
+
/** Used to specify whether to build the log from a range, absolute date, or tag. */
private String type;
-
+
/**
* Used to specify the range of log entries to retrieve.
*/
private String range;
-
+
/** Used to specify the absolute date (or list of dates) to start log entries from. */
private String date;
-
+
/** Used to specify the tag (or list of tags) to start log entries from. */
private String tag;
-
+
/** This will contain the date/tag for the start of the current change set. */
private String markerStart;
-
+
/** This will contain the date/tag for the end of the current change set. */
private String markerEnd;
-
- /**
- * Used to specify the date format of log entries to retrieve.
- */
+
+ /**
+ * Used to specify the date format of log entries to retrieve.
+ */
private String dateFormat;
- /**
- * Specifies whether to quote date argument (used by CvsChangeLogGenerator).
- */
+ /**
+ * Specifies whether to quote date argument (used by CvsChangeLogGenerator).
+ */
private boolean quoteDate;
/**
@@ -96,38 +115,23 @@
*/
private String clFactoryClass = null;
- private static final Map FACTORIES = new HashMap();
-
/** the connection string used to access the SCM */
private String connection;
-
+
/** the list of developers on the project */
private List developers;
-
+
/** change log sets parsed (sets of entries) */
private Collection sets;
-
- /** Log */
- private static final Log LOG = LogFactory.getLog(ChangeLog.class);
/**
* Output file for xml document
*/
private File output;
-
+
/** output encoding for the xml document */
private String outputEncoding;
- static
- {
- FACTORIES.put( "cvs", "org.apache.maven.cvslib.CvsChangeLogFactory" );
- FACTORIES.put( "svn", "org.apache.maven.svnlib.SvnChangeLogFactory" );
- FACTORIES.put( "clearcase", "org.apache.maven.clearcaselib.ClearcaseChangeLogFactory" );
- FACTORIES.put( "perforce", "org.apache.maven.perforcelib.PerforceChangeLogFactory" );
- FACTORIES.put( "starteam", "org.apache.maven.starteamlib.StarteamChangeLogFactory" );
- FACTORIES.put( "vss", "org.apache.maven.vsslib.VssChangeLogFactory" );
- }
-
/**
* Comment format string used for interrogating
* the revision control system.
@@ -141,24 +145,24 @@
*
* @param factoryClassName the fully qualified factory class name
*/
- public void setFactory(String factoryClassName)
+ public void setFactory( String factoryClassName )
{
clFactoryClass = factoryClassName;
}
-
+
/**
* Set the type of log to generate (range, date, or tag).
- *
+ *
* @param type one of "range", "date", or "tag".
*/
- public void setType(String type)
+ public void setType( String type )
{
this.type = type;
}
-
+
/**
* Get the type of log to generate (range, date, or tag).
- *
+ *
* @return the basis for the log.
*/
public String getType()
@@ -167,10 +171,10 @@
{
type = "range";
}
+
return type;
}
-
-
+
/**
* Set the range of log entries to process; the interpretation of this
* parameter depends on the generator.
@@ -178,7 +182,7 @@
*
* @param range the range of log entries.
*/
- public void setRange(String range)
+ public void setRange( String range )
{
this.range = range;
}
@@ -193,45 +197,43 @@
{
return range;
}
-
-
+
/**
* Set the date to start the log from.
* This is only used if the type is "date".
* The format is that given by the dateFormat property, if present. Otherwise, the format is "yyyy-MM-dd".
- *
+ *
* @param date the date to use.
*/
- public void setDate(String date)
+ public void setDate( String date )
{
this.date = date;
}
-
+
/**
* Get the date to start the log from.
- *
+ *
* @return the start date.
*/
public String getDate()
{
return date;
}
-
-
+
/**
* Set the tag to start the log from.
* This is only used if the type is "tag".
- *
+ *
* @param tag the tag to use.
*/
- public void setTag(String tag)
+ public void setTag( String tag )
{
this.tag = tag;
}
-
+
/**
* Get the tag to start the log from.
- *
+ *
* @return the tag.
*/
public String getTag()
@@ -239,22 +241,21 @@
return tag;
}
-
/**
* Sets the marker (date or tag) for the start of the current change set.
* (This is only set internally, but also by test code.)
- *
+ *
* @param marker start marker to use.
*/
- public void setMarkerStart(String marker)
+ public void setMarkerStart( String marker )
{
markerStart = marker;
}
-
+
/**
* Returns the marker (date or tag) for the start of the current change set.
* Whether it's a date or tag depends on {@link #getType}.
- *
+ *
* @return the marker (date or tag) for the start of the current change set.
*/
public String getMarkerStart()
@@ -265,18 +266,18 @@
/**
* Sets the marker (date or tag) for the end of the current change set.
* (This is only set internally, but also by test code.)
- *
+ *
* @param marker end marker to use, or <code>null</code> to specify all changes since the start.
*/
- public void setMarkerEnd(String marker)
+ public void setMarkerEnd( String marker )
{
markerEnd = marker;
}
-
+
/**
* Returns the marker (date or tag) for the end of the current change set.
* Whether it's a date or tag depends on {@link #getType}.
- *
+ *
* @return the marker (date or tag) for the end of the current change set, or <code>null</code> if there is no
* end (meaning the change set should show all changes from the start to the present time).
*/
@@ -285,14 +286,13 @@
return markerEnd;
}
-
/**
* Set the date format of log entries to process; the
* interpretation of this parameter depends on the generator.
*
* @param dateFormat the dateFormat of log entries.
*/
- public void setDateFormat(String dateFormat)
+ public void setDateFormat( String dateFormat )
{
this.dateFormat = dateFormat;
}
@@ -312,7 +312,7 @@
* Set the quoteDate property.
* @param newQuoteDate the quoteDate property to set.
*/
- public void setQuoteDate(boolean newQuoteDate)
+ public void setQuoteDate( boolean newQuoteDate )
{
this.quoteDate = newQuoteDate;
}
@@ -331,7 +331,7 @@
* Set the base directory for the change log generator.
* @param base the base directory
*/
- public void setBasedir(File base)
+ public void setBasedir( File base )
{
this.base = base;
}
@@ -350,7 +350,7 @@
* Set the output file for the log.
* @param output the output file
*/
- public void setOutput(File output)
+ public void setOutput( File output )
{
this.output = output;
}
@@ -369,11 +369,11 @@
* @param aString a string containing the project's repository
* connection
*/
- public void setRepositoryConnection(String aString)
+ public void setRepositoryConnection( String aString )
{
connection = aString;
}
-
+
/**
* Execute task.
* @throws FileNotFoundException if the base diretory
@@ -382,34 +382,36 @@
* @throws UnsupportedEncodingException if the underlying platform doesn't
* support ISO-8859-1 encoding
*/
- public void doExecute() throws FileNotFoundException, IOException,
- UnsupportedEncodingException
+ public void doExecute()
+ throws FileNotFoundException, IOException, UnsupportedEncodingException
{
- if (output == null)
+ if ( output == null )
{
- throw new NullPointerException("output must be set");
+ throw new NullPointerException( "output must be set" );
}
generateSets();
replaceAuthorIdWithName();
createDocument();
}
-
+
/**
* Create the change log entries.
* @throws IOException if there is a problem creating the change log
* entries.
*/
- private void generateSets() throws IOException
+ private void generateSets()
+ throws IOException
{
ChangeLogFactory factory = createFactory();
-
+
String markers = "";
- if (getType().equalsIgnoreCase("tag"))
+
+ if ( getType().equalsIgnoreCase( "tag" ) )
{
markers = getTag();
}
- else if (getType().equalsIgnoreCase("date"))
+ else if ( getType().equalsIgnoreCase( "date" ) )
{
markers = getDate();
}
@@ -417,39 +419,49 @@
{
markers = getRange();
}
-
+
try
{
- StringTokenizer tokens = new StringTokenizer(markers, ",");
- sets = new ArrayList(tokens.countTokens());
+ StringTokenizer tokens = new StringTokenizer( markers, "," );
+
+ sets = new ArrayList( tokens.countTokens() );
+
String end = tokens.nextToken();
+
do
{
String start = end;
- end = (tokens.hasMoreTokens()) ? tokens.nextToken() : null;
- setMarkerStart(start);
- setMarkerEnd(end);
+
+ end = ( tokens.hasMoreTokens() ) ? tokens.nextToken() : null;
+ setMarkerStart( start );
+ setMarkerEnd( end );
ChangeLogParser parser = factory.createParser();
- if (getDateFormat() != null)
+
+ if ( getDateFormat() != null )
{
- parser.setDateFormatInFile(getDateFormat());
+ parser.setDateFormatInFile( getDateFormat() );
}
- parser.init(this);
+
+ parser.init( this );
ChangeLogGenerator generator = factory.createGenerator();
- generator.init(this);
-
+
+ generator.init( this );
+
Collection entries;
String logStart;
String logEnd;
+
try
{
- entries = generator.getEntries(parser);
+ entries = generator.getEntries( parser );
logStart = generator.getLogStart();
logEnd = generator.getLogEnd();
- } catch (IOException e) {
- LOG.warn(e.getLocalizedMessage(), e);
+ }
+ catch ( IOException e )
+ {
+ LOG.warn( e.getLocalizedMessage(), e );
throw e;
}
finally
@@ -463,12 +475,15 @@
entries = Collections.EMPTY_LIST;
}
- sets.add(new ChangeLogSet(entries, logStart, logEnd));
- if (LOG.isInfoEnabled()) {
- LOG.info("ChangeSet between " + logStart + " and " + logEnd + ": "
- + entries.size() + " entries");
+ sets.add( new ChangeLogSet( entries, logStart, logEnd ) );
+
+ if ( LOG.isInfoEnabled() )
+ {
+ LOG.info( "ChangeSet between " + logStart + " and "
+ + logEnd + ": " + entries.size() + " entries" );
}
- } while (end != null);
+ }
+ while ( end != null );
}
finally
{
@@ -482,48 +497,54 @@
* @return the new ChangeLogFactory instance
* @throws IOException if there is a problem creating the instance.
*/
- private ChangeLogFactory createFactory() throws IOException
+ private ChangeLogFactory createFactory()
+ throws IOException
{
if ( clFactoryClass == null )
{
- if ( connection == null || connection.length() < 7 || !connection.startsWith( "scm:" ) )
+ if ( ( connection == null ) || ( connection.length() < 7 )
+ || !connection.startsWith( "scm:" ) )
{
LOG.warn( "Connection does not appear valid" );
}
else
{
- clFactoryClass = (String) FACTORIES.get( connection.substring( 4, 7 ) );
+ clFactoryClass =
+ (String) FACTORIES.get( connection.substring( 4, 7 ) );
}
if ( clFactoryClass == null )
{
- LOG.warn( "Could not derive factory from connection: using CVS (valid factories are: " + FACTORIES.keySet() + ")" );
+ LOG.warn(
+ "Could not derive factory from connection: using CVS (valid factories are: "
+ + FACTORIES.keySet() + ")" );
clFactoryClass = "org.apache.maven.cvslib.CvsChangeLogFactory";
}
}
try
{
- Class clazz = Class.forName(clFactoryClass);
+ Class clazz = Class.forName( clFactoryClass );
+
return (ChangeLogFactory) clazz.newInstance();
}
- catch (ClassNotFoundException cnfe)
+ catch ( ClassNotFoundException cnfe )
{
- throw new IOException("Cannot find class " + clFactoryClass
- + " " + cnfe.toString());
+ throw new IOException( "Cannot find class " + clFactoryClass + " "
+ + cnfe.toString() );
}
- catch (IllegalAccessException iae)
+ catch ( IllegalAccessException iae )
{
- throw new IOException("Cannot access class " + clFactoryClass
- + " " + iae.toString());
+ throw new IOException( "Cannot access class " + clFactoryClass
+ + " " + iae.toString() );
}
- catch (InstantiationException ie)
+ catch ( InstantiationException ie )
{
- throw new IOException("Cannot instantiate class " + clFactoryClass
- + " " + ie.toString());
+ throw new IOException( "Cannot instantiate class " + clFactoryClass
+ + " " + ie.toString() );
}
}
-
+
/**
* Set up list of developers mapping id to name.
* @task This should be a facility on the maven project itself
@@ -532,14 +553,15 @@
private Properties getUserList()
{
Properties userList = new Properties();
-
+
Developer developer = null;
- for (Iterator i = getDevelopers().iterator(); i.hasNext();)
+
+ for ( Iterator i = getDevelopers().iterator(); i.hasNext(); )
{
developer = (Developer) i.next();
- userList.put(developer.getId(), developer.getName());
+ userList.put( developer.getId(), developer.getName() );
}
-
+
return userList;
}
@@ -550,21 +572,25 @@
{
Properties userList = getUserList();
ChangeLogEntry entry = null;
-
- for (final Iterator iSets = getChangeSets().iterator() ; iSets.hasNext() ;)
+
+ for ( Iterator iSets = getChangeSets().iterator();
+ iSets.hasNext(); )
{
- final ChangeLogSet set = (ChangeLogSet)iSets.next();
- for (Iterator iEntries = set.getEntries().iterator(); iEntries.hasNext();)
+ final ChangeLogSet set = (ChangeLogSet) iSets.next();
+
+ for ( Iterator iEntries = set.getEntries().iterator();
+ iEntries.hasNext(); )
{
entry = (ChangeLogEntry) iEntries.next();
- if (userList.containsKey(entry.getAuthor()))
+
+ if ( userList.containsKey( entry.getAuthor() ) )
{
- entry.setAuthor(userList.getProperty(entry.getAuthor()));
+ entry.setAuthor( userList.getProperty( entry.getAuthor() ) );
}
}
}
}
-
+
/**
* Create the XML document from the currently available details
* @throws FileNotFoundException when the output file previously provided
@@ -572,64 +598,69 @@
* @throws UnsupportedEncodingException when the platform doesn't support
* ISO-8859-1 encoding
*/
- private void createDocument() throws FileNotFoundException,
- UnsupportedEncodingException
+ private void createDocument()
+ throws FileNotFoundException, UnsupportedEncodingException
{
File dir = output.getParentFile();
- if (dir != null) {
+
+ if ( dir != null )
+ {
dir.mkdirs();
}
- PrintWriter out = new PrintWriter(new OutputStreamWriter(
- new FileOutputStream(output), getOutputEncoding()));
- out.println(toXML());
+
+ PrintWriter out =
+ new PrintWriter( new OutputStreamWriter(
+ new FileOutputStream( output ), getOutputEncoding() ) );
+
+ out.println( toXML() );
out.flush();
out.close();
}
-
+
/**
- * @return an XML document representing this change log and it's entries
+ * @return an XML document representing this change log and it's entries
*/
private String toXML()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("<?xml version=\"1.0\" encoding=\"")
- .append(getOutputEncoding())
- .append("\" ?>\n")
- .append("<changelog>\n");
-
- for (Iterator i = getChangeSets().iterator(); i.hasNext();)
+
+ buffer.append( "<?xml version=\"1.0\" encoding=\"" )
+ .append( getOutputEncoding() ).append( "\" ?>\n" ).append( "<changelog>\n" );
+
+ for ( Iterator i = getChangeSets().iterator(); i.hasNext(); )
{
- buffer.append(((ChangeLogSet) i.next()).toXML());
+ buffer.append( ( (ChangeLogSet) i.next() ).toXML() );
}
- buffer.append("</changelog>\n");
-
+ buffer.append( "</changelog>\n" );
+
return buffer.toString();
}
-
+
/**
* Gets the collection of change sets.
- *
+ *
* @return collection of {@link ChangeLogSet} objects.
*/
public Collection getChangeSets()
{
- if (sets == null)
+ if ( sets == null )
{
sets = Collections.EMPTY_LIST;
}
+
return sets;
}
-
- /**
+
+ /**
* Sets the collection of change sets.
* @param sets New value of property sets.
*/
- public void setChangeSets(Collection sets)
+ public void setChangeSets( Collection sets )
{
this.sets = sets;
}
-
+
/**
* Returns the developers.
* @return List
@@ -643,7 +674,7 @@
* Sets the developers.
* @param developers The developers to set
*/
- public void setDevelopers(List developers)
+ public void setDevelopers( List developers )
{
this.developers = developers;
}
@@ -661,7 +692,7 @@
* Sets the outputEncoding.
* @param outputEncoding The outputEncoding to set
*/
- public void setOutputEncoding(String outputEncoding)
+ public void setOutputEncoding( String outputEncoding )
{
this.outputEncoding = outputEncoding;
}
@@ -679,9 +710,9 @@
* Sets the commentFormat.
* @param commentFormat The commentFormat to set
*/
- public void setCommentFormat(String commentFormat)
+ public void setCommentFormat( String commentFormat )
{
this.commentFormat = commentFormat;
}
-
-} // end of ChangeLog
+}
+ // end of ChangeLog
Modified: maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogEntry.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogEntry.java?rev=370221&r1=370220&r2=370221&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogEntry.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogEntry.java Wed Jan 18 11:12:42 2006
@@ -18,6 +18,7 @@
*/
import java.text.SimpleDateFormat;
+
import java.util.Date;
import java.util.Enumeration;
import java.util.Vector;
@@ -36,76 +37,75 @@
* Escaped <code><</code> entity
*/
public static final String LESS_THAN_ENTITY = "<";
-
+
/**
* Escaped <code>></code> entity
*/
public static final String GREATER_THAN_ENTITY = ">";
-
+
/**
* Escaped <code>&</code> entity
*/
public static final String AMPERSAND_ENTITY = "&";
-
+
/**
* Escaped <code>'</code> entity
*/
public static final String APOSTROPHE_ENTITY = "'";
-
+
/**
* Escaped <code>"</code> entity
*/
public static final String QUOTE_ENTITY = """;
-
+
/**
* Formatter used by the getDateFormatted method.
*/
- private static final SimpleDateFormat DATE_FORMAT =
- new SimpleDateFormat("yyyy-MM-dd");
+ private static final SimpleDateFormat DATE_FORMAT =
+ new SimpleDateFormat( "yyyy-MM-dd" );
/**
* Formatter used by the getTimeFormatted method.
*/
- private static final SimpleDateFormat TIME_FORMAT =
- new SimpleDateFormat("HH:mm:ss");
+ private static final SimpleDateFormat TIME_FORMAT =
+ new SimpleDateFormat( "HH:mm:ss" );
-
/** Date the changes were committed */
private Date date;
-
+
/** User who made changes */
private String author;
-
+
/** comment provided at commit time */
private String comment = "";
-
+
/** ChangeLogFiles committed on the date, by the author, with comment*/
private Vector files = new Vector();
-
+
/**
* Constructor used when attributes aren't available until later
*/
- public ChangeLogEntry()
+ public ChangeLogEntry()
{
}
-
+
/**
* Adds a file to the list for this entry
* @param file a {@link ChangeLogFile}
*/
- public void addFile(ChangeLogFile file)
+ public void addFile( ChangeLogFile file )
{
- files.addElement(file);
+ files.addElement( file );
}
-
- /**
+
+ /**
* Adds a feature to the File attribute of the Entry object.
* @param file the file name committed
* @param revision the revision of the latest change
*/
- public void addFile(String file, String revision)
+ public void addFile( String file, String revision )
{
- files.addElement(new ChangeLogFile(file, revision));
+ files.addElement( new ChangeLogFile( file, revision ) );
}
/**
@@ -118,7 +118,7 @@
/**
* Provide the changelog entry as an XML snippet.
- *
+ *
* @task make sure comment doesn't contain CDATA tags - MAVEN114
* @return a changelog-entry in xml format
*/
@@ -126,37 +126,30 @@
{
StringBuffer buffer = new StringBuffer();
- buffer.append("\t<changelog-entry>\n")
- .append("\t\t<date>")
- .append(getDateFormatted())
- .append("</date>\n")
- .append("\t\t<time>")
- .append(getTimeFormatted())
- .append("</time>\n")
- .append("\t\t<author><![CDATA[")
- .append(author)
- .append("]]></author>\n");
-
- for (Enumeration e = files.elements(); e.hasMoreElements();)
+ buffer.append( "\t<changelog-entry>\n" ).append( "\t\t<date>" )
+ .append( getDateFormatted() ).append( "</date>\n" )
+ .append( "\t\t<time>" ).append( getTimeFormatted() )
+ .append( "</time>\n" ).append( "\t\t<author><![CDATA[" )
+ .append( author ).append( "]]></author>\n" );
+
+ for ( Enumeration e = files.elements(); e.hasMoreElements(); )
{
ChangeLogFile file = (ChangeLogFile) e.nextElement();
- buffer.append("\t\t<file>\n")
- .append("\t\t\t<name>")
- .append(escapeValue(file.getName()))
- .append("</name>\n")
- .append("\t\t\t<revision>")
- .append(file.getRevision())
- .append("</revision>\n");
- buffer.append("\t\t</file>\n");
+
+ buffer.append( "\t\t<file>\n" ).append( "\t\t\t<name>" )
+ .append( escapeValue( file.getName() ) ).append( "</name>\n" )
+ .append( "\t\t\t<revision>" ).append( file.getRevision() )
+ .append( "</revision>\n" );
+ buffer.append( "\t\t</file>\n" );
}
- buffer.append("\t\t<msg><![CDATA[")
- .append(removeCDataEnd(comment))
- .append("]]></msg>\n");
- buffer.append("\t</changelog-entry>\n");
-
+
+ buffer.append( "\t\t<msg><![CDATA[" ).append( removeCDataEnd( comment ) )
+ .append( "]]></msg>\n" );
+ buffer.append( "\t</changelog-entry>\n" );
+
return buffer.toString();
}
-
+
/**
* Getter for property author.
* @return Value of property author.
@@ -165,16 +158,16 @@
{
return author;
}
-
+
/**
* Setter for property author.
* @param author New value of property author.
*/
- public void setAuthor(String author)
+ public void setAuthor( String author )
{
this.author = author;
}
-
+
/**
* Getter for property comment.
* @return Value of property comment.
@@ -183,16 +176,16 @@
{
return comment;
}
-
+
/**
* Setter for property comment.
* @param comment New value of property comment.
*/
- public void setComment(String comment)
+ public void setComment( String comment )
{
this.comment = comment;
}
-
+
/**
* Getter for property date.
* @return Value of property date.
@@ -201,14 +194,14 @@
{
return (Date) date.clone();
}
-
+
/**
* Setter for property date.
* @param date New value of property date.
*/
- public void setDate(Date date)
+ public void setDate( Date date )
{
- this.date = new Date(date.getTime());
+ this.date = new Date( date.getTime() );
}
/**
@@ -216,73 +209,92 @@
*/
public String getDateFormatted()
{
- return DATE_FORMAT.format(getDate());
+ return DATE_FORMAT.format( getDate() );
}
-
+
/**
* @return time in HH:mm:ss format
*/
public String getTimeFormatted()
{
- return TIME_FORMAT.format(getDate());
+ return TIME_FORMAT.format( getDate() );
}
-
+
/**
* remove a <code>]]></code> from comments (replace it with <code>] ] ></code>).
* @param message
* @return
*/
- private String removeCDataEnd(String message)
+ private String removeCDataEnd( String message )
{
// check for invalid sequence ]]>
int endCdata;
- while (message != null && (endCdata = message.indexOf("]]>")) > -1)
+
+ while ( ( message != null )
+ && ( ( endCdata = message.indexOf( "]]>" ) ) > -1 ) )
{
- message = message.substring(0, endCdata) + "] ] >" + message.substring(endCdata + 3, message.length());
+ message =
+ message.substring( 0, endCdata ) + "] ] >"
+ + message.substring( endCdata + 3, message.length() );
}
+
return message;
}
-
- /**
- * <p>Escape the <code>toString</code> of the given object.
- * For use in an attribute value.</p>
- *
- * swiped from jakarta-commons/betwixt -- XMLUtils.java
- *
- * @param value escape <code>value.toString()</code>
- * @return text with characters restricted (for use in attributes) escaped
- */
- public static final String escapeValue(Object value) {
- StringBuffer buffer = new StringBuffer(value.toString());
- for (int i=0, size = buffer.length(); i <size; i++) {
- switch (buffer.charAt(i)) {
- case '<':
- buffer.replace(i, i+1, LESS_THAN_ENTITY);
- size += 3;
- i+=3;
- break;
- case '>':
- buffer.replace(i, i+1, GREATER_THAN_ENTITY);
- size += 3;
- i += 3;
- break;
- case '&':
- buffer.replace(i, i+1, AMPERSAND_ENTITY);
- size += 4;
- i += 4;
- break;
- case '\'':
- buffer.replace(i, i+1, APOSTROPHE_ENTITY);
- size += 4;
- i += 4;
- break;
- case '\"':
- buffer.replace(i, i+1, QUOTE_ENTITY);
- size += 5;
- i += 5;
- break;
- }
- }
- return buffer.toString();
+
+ /**
+ * <p>Escape the <code>toString</code> of the given object.
+ * For use in an attribute value.</p>
+ *
+ * swiped from jakarta-commons/betwixt -- XMLUtils.java
+ *
+ * @param value escape <code>value.toString()</code>
+ * @return text with characters restricted (for use in attributes) escaped
+ */
+ public static final String escapeValue( Object value )
+ {
+ StringBuffer buffer = new StringBuffer( value.toString() );
+
+ for ( int i = 0, size = buffer.length(); i < size; i++ )
+ {
+ switch ( buffer.charAt( i ) )
+ {
+ case '<' :
+ buffer.replace( i, i + 1, LESS_THAN_ENTITY );
+ size += 3;
+ i += 3;
+
+ break;
+
+ case '>' :
+ buffer.replace( i, i + 1, GREATER_THAN_ENTITY );
+ size += 3;
+ i += 3;
+
+ break;
+
+ case '&' :
+ buffer.replace( i, i + 1, AMPERSAND_ENTITY );
+ size += 4;
+ i += 4;
+
+ break;
+
+ case '\'' :
+ buffer.replace( i, i + 1, APOSTROPHE_ENTITY );
+ size += 4;
+ i += 4;
+
+ break;
+
+ case '\"' :
+ buffer.replace( i, i + 1, QUOTE_ENTITY );
+ size += 5;
+ i += 5;
+
+ break;
+ }
+ }
+
+ return buffer.toString();
}
}
Modified: maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogFile.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogFile.java?rev=370221&r1=370220&r2=370221&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogFile.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogFile.java Wed Jan 18 11:12:42 2006
@@ -28,6 +28,7 @@
{
/** the name of the file relative to the project directory. */
private String name;
+
/** the latest revision of the file. */
private String revision;
@@ -35,21 +36,21 @@
* Constructor for the ChangeLogFile object without all details available
* @param name file name
*/
- public ChangeLogFile(String name)
+ public ChangeLogFile( String name )
{
- setName(name);
+ setName( name );
}
-
+
/**
* Constructor for the ChangeLogFile object
*
* @param name file name
* @param rev latest revision of the file
*/
- public ChangeLogFile(String name, String rev)
+ public ChangeLogFile( String name, String rev )
{
- setName(name);
- setRevision(rev);
+ setName( name );
+ setRevision( rev );
}
/**
@@ -74,16 +75,16 @@
* Setter for property name.
* @param name New value of property name.
*/
- public void setName(String name)
+ public void setName( String name )
{
this.name = name;
}
-
+
/**
* Setter for property revision.
* @param revision New value of property revision.
*/
- public void setRevision(String revision)
+ public void setRevision( String revision )
{
this.revision = revision;
}
@@ -92,15 +93,16 @@
* Provide a version of the object as a string for debugging purposes
* @return a {@link String} made up of the properties of the object
*/
- public String toString()
+ public String toString()
{
- StringBuffer buffer = new StringBuffer(getName());
- if (getRevision() != null)
+ StringBuffer buffer = new StringBuffer( getName() );
+
+ if ( getRevision() != null )
{
- buffer.append(", ").append(getRevision());
+ buffer.append( ", " ).append( getRevision() );
}
+
return buffer.toString();
}
-
-} // end of ChangeLogFile
-
+}
+ // end of ChangeLogFile
Modified: maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogGenerator.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogGenerator.java?rev=370221&r1=370220&r2=370221&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogGenerator.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogGenerator.java Wed Jan 18 11:12:42 2006
@@ -18,13 +18,14 @@
*/
import java.io.IOException;
+
import java.util.Collection;
/**
* Instances of <code>ChangeLogGenerator</code> are intended to provide an
- * {@link java.io.InputStream} for a {@link ChangeLogParser} to parse into
+ * {@link java.io.InputStream} for a {@link ChangeLogParser} to parse into
* individual {@link ChangeLogEntry} objects.
- *
+ *
* @author Glenn McAllister
* @author dion
* @version $Id$
@@ -34,12 +35,12 @@
/**
* Initialize the ChangeLogGenerator instance with in the controlling
* {@link ChangeLog} instance. Any configuration required for the generator
- * should be obtained from the <code>changeLog</code>. This method is
+ * should be obtained from the <code>changeLog</code>. This method is
* guaranteed to be called before {@link #getEntries}.
*
* @param changeLog the controlling ChangeLog instance
*/
- void init(ChangeLog changeLog);
+ void init( ChangeLog changeLog );
/**
* Return a Collection of ChangeLogEntry objects. This method should
@@ -57,24 +58,25 @@
* @throws IOException if there is an error while creating the
* ChangeLogEntry objects
*/
- Collection getEntries(ChangeLogParser parser) throws IOException;
+ Collection getEntries( ChangeLogParser parser )
+ throws IOException;
/**
* Return a string indicating the start of the entries.
* This will usually be a date or a tag.
- *
+ *
* @return a string indicating the start of the entries.
*/
String getLogStart();
-
+
/**
* Return a string indicating the end of the entries.
* This will usually be a date or a tag.
- *
+ *
* @return a string indicating the end of the entries.
*/
String getLogEnd();
-
+
/**
* Provides the opportunity for the generator to do any required cleanup.
* This method is guaranteed to be called after the getEntries method even
Modified: maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogParser.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogParser.java?rev=370221&r1=370220&r2=370221&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogParser.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogParser.java Wed Jan 18 11:12:42 2006
@@ -17,8 +17,9 @@
* ====================================================================
*/
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
+
import java.util.Collection;
/**
@@ -39,7 +40,7 @@
*
* @param changeLog the controlling ChangeLog instance
*/
- void init(ChangeLog changeLog);
+ void init( ChangeLog changeLog );
/**
* Returns a {@link java.util.Collection} of ChangeLogEntry objects, parsed
@@ -52,7 +53,8 @@
* @return a Collection of ChangeLogEntry objects
* @throws IOException if there is an error while parsing the input stream
*/
- Collection parse(InputStream in) throws IOException;
+ Collection parse( InputStream in )
+ throws IOException;
/**
* Provides the opportunity for the parser to do any required cleanup.
Modified: maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogSet.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogSet.java?rev=370221&r1=370220&r2=370221&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogSet.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLogSet.java Wed Jan 18 11:12:42 2006
@@ -17,11 +17,9 @@
* ====================================================================
*/
-import java.io.Writer;
import java.util.Collection;
import java.util.Iterator;
-
/**
* Change Log Set - holds details about a set of change log entries.
*
@@ -33,76 +31,68 @@
private final Collection entries;
private final String start;
private final String end;
-
-
+
/**
* Initializes a new instance of this class.
- *
+ *
* @param entries collection of {@link ChangeLogEntry} objects for this set.
* @param start the start date/tag for this set.
* @param end the end date/tag for this set, or <code>null</code> if this set goes to the present time.
*/
- public ChangeLogSet(Collection entries, String start, String end)
+ public ChangeLogSet( Collection entries, String start, String end )
{
this.entries = entries;
this.start = start;
this.end = end;
}
-
/**
* Returns the collection of entries for this set.
- *
+ *
* @return the collection of {@link ChangeLogEntry} objects for this set.
*/
public Collection getEntries()
{
return entries;
}
-
-
+
/**
* Returns the start date/tag for this set.
- *
+ *
* @return the start date/tag for this set.
*/
public String getStart()
{
return start;
}
-
-
+
/**
* Returns the end date/tag for this set.
- *
+ *
* @return the end date/tag for this set, or <code>null</code> if this set goes to the present time.
*/
public String getEnd()
{
return end;
}
-
-
+
/**
* Creates an XML representation of this change log set.
*/
public String toXML()
{
StringBuffer buffer = new StringBuffer();
-
- buffer.append("<changeset start=\"")
- .append(start)
- .append("\" end=\"")
- .append(end)
- .append("\">\n");
-
+
+ buffer.append( "<changeset start=\"" ).append( start )
+ .append( "\" end=\"" ).append( end ).append( "\">\n" );
+
// Write out the entries
- for (Iterator i = getEntries().iterator(); i.hasNext();)
+ for ( Iterator i = getEntries().iterator(); i.hasNext(); )
{
- buffer.append(((ChangeLogEntry) i.next()).toXML());
+ buffer.append( ( (ChangeLogEntry) i.next() ).toXML() );
}
-
- buffer.append("</changeset>\n");
+
+ buffer.append( "</changeset>\n" );
return buffer.toString();
}
Modified: maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogFactory.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogFactory.java?rev=370221&r1=370220&r2=370221&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogFactory.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogFactory.java Wed Jan 18 11:12:42 2006
@@ -21,14 +21,15 @@
import org.apache.maven.changelog.ChangeLogGenerator;
import org.apache.maven.changelog.ChangeLogParser;
+
/**
* Provides Clearcase specific instances of the ChangeLogGenerator and
* ChangeLogParser interfaces.
*
* @author <a href="mailto:aldarion@virgilio.it">Simone Zorzetti</a>
*/
-public class ClearcaseChangeLogFactory implements ChangeLogFactory {
-
+public class ClearcaseChangeLogFactory implements ChangeLogFactory
+{
/* (non-Javadoc)
* @see org.apache.maven.changelog.ChangeLogFactory#createGenerator()
*/
@@ -42,7 +43,6 @@
*/
public ChangeLogParser createParser()
{
- return new ClearcaseChangeLogParser();
+ return new ClearcaseChangeLogParser();
}
-
}
Modified: maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogGenerator.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogGenerator.java?rev=370221&r1=370220&r2=370221&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogGenerator.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogGenerator.java Wed Jan 18 11:12:42 2006
@@ -18,103 +18,108 @@
*/
import java.text.SimpleDateFormat;
+
import java.util.Date;
import java.util.Locale;
// commons imports
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.maven.changelog.AbstractChangeLogGenerator;
// ant imports
import org.apache.tools.ant.types.Commandline;
-import org.apache.maven.changelog.AbstractChangeLogGenerator;
-
/**
* A Clearcase implementation of the {@link org.apache.maven.changelog.ChangeLogGenerator}
* interface realized extending the {@link org.apache.maven.changelog.AbstractChangeLogGenerator}.
- *
+ *
* The command line build by this class uses the <code>lshistory</code> clearcase command
* and formats the output in a way the ClearcaseChangeLogParser can understand. Due to this
* fact this implementations works only if used within a clearcase view.
- *
+ *
* The command looks like this: <p>
- * cleartool lshistory -recurse -nco -since SAMEDATE
+ * cleartool lshistory -recurse -nco -since SAMEDATE
* -fmt "NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%-8.8u\\n"
*
* @author <a href="mailto:aldarion@virgilio.it">Simone Zorzetti</a>
*/
-public class ClearcaseChangeLogGenerator extends AbstractChangeLogGenerator {
-
+public class ClearcaseChangeLogGenerator extends AbstractChangeLogGenerator
+{
/** Log */
- private static final Log LOG = LogFactory.getLog(
- ClearcaseChangeLogGenerator.class);
+ private static final Log LOG =
+ LogFactory.getLog( ClearcaseChangeLogGenerator.class );
/**
* Constructs the appropriate command line to execute the scm's
* log command. For Clearcase it's lshistory.
- *
+ *
* @see org.apache.maven.changelog.AbstractChangeLogGenerator#getScmLogCommand()
* @return The command line to be executed.
*/
protected Commandline getScmLogCommand()
{
Commandline command = new Commandline();
- command.setExecutable("cleartool");
- command.createArgument().setValue("lshistory");
+
+ command.setExecutable( "cleartool" );
+ command.createArgument().setValue( "lshistory" );
StringBuffer format = new StringBuffer();
- format.append("NAME:%En\\n");
- format.append("DATE:%Nd\\n");
- format.append("COMM:%-12.12o - ");
+
+ format.append( "NAME:%En\\n" );
+ format.append( "DATE:%Nd\\n" );
+ format.append( "COMM:%-12.12o - " );
String commentFormat = getCommentFormat();
- if (commentFormat == null)
+
+ if ( commentFormat == null )
{
- format.append("%Sn - %c - Activity: %[activity]p\\n");
+ format.append( "%Sn - %c - Activity: %[activity]p\\n" );
}
else
{
- format.append(commentFormat);
+ format.append( commentFormat );
}
-
- format.append("USER:%-8.8u\\n");
- command.createArgument().setValue("-fmt");
- command.createArgument().setValue(format.toString());
- command.createArgument().setValue("-recurse");
- command.createArgument().setValue("-nco");
- command.createArgument().setValue("-since");
- command.createArgument().setValue(dateRange);
+ format.append( "USER:%-8.8u\\n" );
- return command;
+ command.createArgument().setValue( "-fmt" );
+ command.createArgument().setValue( format.toString() );
+ command.createArgument().setValue( "-recurse" );
+ command.createArgument().setValue( "-nco" );
+ command.createArgument().setValue( "-since" );
+ command.createArgument().setValue( dateRange );
+
+ return command;
}
- /**
+ /**
* Construct the command-line argument that is passed to the scm
* client to specify the appropriate date range.
- *
+ *
* @param before The starting point.
* @param to The ending point.
* @return A string that can be used to specify a date to a scm
* system.
- *
- * @see org.apache.maven.changelog.AbstractChangeLogGenerator#getScmDateArgument(java.util.Date, java.util.Date)
+ *
+ * @see org.apache.maven.changelog.AbstractChangeLogGenerator#getScmDateArgument(java.util.Date, java.util.Date)
*/
- protected String getScmDateArgument(Date before, Date to)
+ protected String getScmDateArgument( Date before, Date to )
{
- SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
- String argument = sdf.format(before);
-
+ SimpleDateFormat sdf =
+ new SimpleDateFormat( "dd-MMM-yyyy", Locale.ENGLISH );
+ String argument = sdf.format( before );
+
return argument;
}
/**
* @see AbstractChangeLogGenerator#getScmTagArgument(String, String)
*/
- protected String getScmTagArgument(String tagStart, String tagEnd)
+ protected String getScmTagArgument( String tagStart, String tagEnd )
{
- throw new UnsupportedOperationException("This plugin currently does not support generating logs from tags with Clearcase.");
+ throw new UnsupportedOperationException(
+ "This plugin currently does not support generating logs from tags with Clearcase." );
}
}