org.apache.maven.changelog
Class AbstractChangeLogGenerator

java.lang.Object
  extended byorg.apache.maven.changelog.AbstractChangeLogGenerator
All Implemented Interfaces:
ChangeLogGenerator, org.apache.tools.ant.taskdefs.ExecuteStreamHandler
Direct Known Subclasses:
ClearcaseChangeLogGenerator, CvsChangeLogGenerator, MksChangeLogGenerator, PerforceChangeLogGenerator, StarteamChangeLogGenerator, SvnChangeLogGenerator, VssChangeLogGenerator

public abstract class AbstractChangeLogGenerator
extends Object
implements ChangeLogGenerator, org.apache.tools.ant.taskdefs.ExecuteStreamHandler

An abstract implementation of the ChangeLog interface.

Version:
$Id: AbstractChangeLogGenerator.java 532339 2007-04-25 12:28:56Z ltheussl $
Author:
Glenn McAllister, Jeff Martin, Jason van Zyl, dIon Gillard, Stefan Bodewig, Peter Donald, Pete Kazmier

Field Summary
protected  File base
          The working directory.
protected  ChangeLog changeLogExecutor
          Reference to the enclosing ChangeLog instance - used to obtain any necessary configuration information.
protected  ChangeLogParser clParser
          The parser that takes the log output and transforms it into a collection of ChangeLogEntry's.
protected  String commentFormat
          The comment format string used in interrogating the RCS.
protected  String dateRange
          The date range command line argument.
protected  Collection entries
          The collection of ChangeLogEntry's returned from clParser.
protected  AsyncStreamReader errorReader
          Stderr stream eater.
protected  InputStream in
          The scm process input stream.
protected  String logEnd
          Represents when this log ends (for the report).
protected  String logStart
          Represents when this log starts (for the report).
protected  String tag
          The tag command line argument.
protected  String type
          The log type (range, date, or tag).
 
Constructor Summary
AbstractChangeLogGenerator()
           
 
Method Summary
 void cleanup()
          Clean up any generated resources for this run.
 String getCommentFormat()
          Returns the commentFormat used to interrogate the RCS.
 String getConnection()
          Returns the connection.
 Collection getEntries(ChangeLogParser parser)
          Execute scm client driving the given parser.
 String getLogEnd()
          Return a string indicating the end of the entries.
 String getLogStart()
          Return a string indicating the start of the entries.
protected abstract  String getScmDateArgument(Date before, Date to)
          Construct the command-line argument that is passed to the scm client to specify the appropriate date range.
protected abstract  org.apache.tools.ant.types.Commandline getScmLogCommand()
          Constructs the appropriate command line to execute the scm's log command.
protected abstract  String getScmTagArgument(String tagStart, String tagEnd)
          Construct the command-line argument that is passed to the scm client to specify the appropriate tag.
protected  void handleParserException(IOException ioe)
          Handle ChangeLogParser IOExceptions.
 void init(ChangeLog changeLog)
          Initialize the generator from the changelog controller.
static void logExecute(org.apache.tools.ant.taskdefs.Execute exe, File base)
          Logs the pertinent details to the logging system (info level)
 void setCommentFormat(String commentFormat)
          Sets the commentFormat.
 void setConnection(String connection)
          Sets the connection.
protected  void setDateRange(String numDaysString)
          Set the dateRange member based on the number of days obtained from the ChangeLog.
protected  void setDateRangeFromAbsoluteDate(String startDate, String endDate)
          Set the dateRange member based on an absolute date.
protected  void setLogEnd(Date end)
          Sets the log end string based on the given date.
protected  void setLogStart(Date start)
          Sets the log start string based on the given date.
 void setProcessErrorStream(InputStream is)
          Set the error stream for reading from scm log.
 void setProcessInputStream(OutputStream os)
          Set the input stream for the scm process.
 void setProcessOutputStream(InputStream is)
          Set the input stream used to read from scm log.
 void start()
          Start read from the scm log.
 void stop()
          Stop the process - currently unimplemented
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

base

protected File base
The working directory.


changeLogExecutor

protected ChangeLog changeLogExecutor
Reference to the enclosing ChangeLog instance - used to obtain any necessary configuration information.


clParser

protected ChangeLogParser clParser
The parser that takes the log output and transforms it into a collection of ChangeLogEntry's.


type

protected String type
The log type (range, date, or tag).


dateRange

protected String dateRange
The date range command line argument.


tag

protected String tag
The tag command line argument.


logStart

protected String logStart
Represents when this log starts (for the report).


logEnd

protected String logEnd
Represents when this log ends (for the report).


entries

protected Collection entries
The collection of ChangeLogEntry's returned from clParser.


errorReader

protected AsyncStreamReader errorReader
Stderr stream eater.


in

protected InputStream in
The scm process input stream.


commentFormat

protected String commentFormat
The comment format string used in interrogating the RCS.

Constructor Detail

AbstractChangeLogGenerator

public AbstractChangeLogGenerator()
Method Detail

init

public void init(ChangeLog changeLog)
Initialize the generator from the changelog controller.

Specified by:
init in interface ChangeLogGenerator
Parameters:
changeLog - The invoking controller (useful for logging)
See Also:
ChangeLogGenerator.init(ChangeLog)

setDateRange

protected void setDateRange(String numDaysString)
Set the dateRange member based on the number of days obtained from the ChangeLog.

Parameters:
numDaysString - The number of days of log output to generate.

setDateRangeFromAbsoluteDate

protected void setDateRangeFromAbsoluteDate(String startDate,
                                            String endDate)
Set the dateRange member based on an absolute date.

Parameters:
startDate - The start date for the range.
endDate - The end date for the range, or null to use the present time.

setLogStart

protected void setLogStart(Date start)
Sets the log start string based on the given date. This uses the date format supplied in the plugin properties.

Parameters:
start - date the log started.

setLogEnd

protected void setLogEnd(Date end)
Sets the log end string based on the given date. This uses the date format supplied in the plugin properties.

Parameters:
end - date the log ended.

getEntries

public Collection getEntries(ChangeLogParser parser)
                      throws IOException
Execute scm client driving the given parser.

Specified by:
getEntries in interface ChangeLogGenerator
Parameters:
parser - A parser to process the scm output.
Returns:
A collection of entries parsed from the scm output.
Throws:
IOException - When there are issues executing scm.
See Also:
ChangeLogGenerator.getEntries(ChangeLogParser)

handleParserException

protected void handleParserException(IOException ioe)
                              throws IOException
Handle ChangeLogParser IOExceptions. The default implementation just throws the exception again.

Parameters:
ioe - The IOException thrown.
Throws:
IOException - If the handler doesn't wish to handle the exception (the default behavior).

getLogStart

public String getLogStart()
Description copied from interface: ChangeLogGenerator
Return a string indicating the start of the entries. This will usually be a date or a tag.

Specified by:
getLogStart in interface ChangeLogGenerator
Returns:
a string indicating the start of the entries.
See Also:
ChangeLogGenerator.getLogStart()

getLogEnd

public String getLogEnd()
Description copied from interface: ChangeLogGenerator
Return a string indicating the end of the entries. This will usually be a date or a tag.

Specified by:
getLogEnd in interface ChangeLogGenerator
Returns:
a string indicating the end of the entries.
See Also:
ChangeLogGenerator.getLogEnd()

cleanup

public void cleanup()
Clean up any generated resources for this run.

Specified by:
cleanup in interface ChangeLogGenerator
See Also:
ChangeLogGenerator.cleanup()

getScmLogCommand

protected abstract org.apache.tools.ant.types.Commandline getScmLogCommand()
Constructs the appropriate command line to execute the scm's log command. This method must be implemented by subclasses.

Returns:
The command line to be executed.

getScmDateArgument

protected abstract String getScmDateArgument(Date before,
                                             Date to)
Construct the command-line argument that is passed to the scm client to specify the appropriate date range.

Parameters:
before - The starting point.
to - The ending point.
Returns:
A string that can be used to specify a date to a scm system.

getScmTagArgument

protected abstract String getScmTagArgument(String tagStart,
                                            String tagEnd)
Construct the command-line argument that is passed to the scm client to specify the appropriate tag.

Parameters:
tagStart - The tag name for the start of the log (log shouldn't actually contain the tag).
tagEnd - The tag name for the end of the log (the log can contain this tag), or null to log all changes since tagStart.
Returns:
A string that can be used to specify the tag range to a scm system.

stop

public void stop()
Stop the process - currently unimplemented

Specified by:
stop in interface org.apache.tools.ant.taskdefs.ExecuteStreamHandler

setProcessInputStream

public void setProcessInputStream(OutputStream os)
Set the input stream for the scm process.

Specified by:
setProcessInputStream in interface org.apache.tools.ant.taskdefs.ExecuteStreamHandler
Parameters:
os - An OutputStream

setProcessErrorStream

public void setProcessErrorStream(InputStream is)
Set the error stream for reading from scm log. This stream will be read on a separate thread.

Specified by:
setProcessErrorStream in interface org.apache.tools.ant.taskdefs.ExecuteStreamHandler
Parameters:
is - An InputStream

setProcessOutputStream

public void setProcessOutputStream(InputStream is)
Set the input stream used to read from scm log.

Specified by:
setProcessOutputStream in interface org.apache.tools.ant.taskdefs.ExecuteStreamHandler
Parameters:
is - A stream of scm log output to be read from

start

public void start()
           throws IOException
Start read from the scm log.

Specified by:
start in interface org.apache.tools.ant.taskdefs.ExecuteStreamHandler
Throws:
IOException - When there are errors reading from the streams previously provided

getConnection

public String getConnection()
Returns the connection.

Returns:
String

setConnection

public void setConnection(String connection)
Sets the connection.

Parameters:
connection - The connection to set

getCommentFormat

public String getCommentFormat()
Returns the commentFormat used to interrogate the RCS.

Returns:
String

setCommentFormat

public void setCommentFormat(String commentFormat)
Sets the commentFormat.

Parameters:
commentFormat - The commentFormat to set

logExecute

public static void logExecute(org.apache.tools.ant.taskdefs.Execute exe,
                              File base)
Logs the pertinent details to the logging system (info level)

Parameters:
exe - The object to log
base - The working directory


Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.