net.sourceforge.cruisecontrol.sourcecontrols.accurev
Class AccurevCommandline

java.lang.Object
  extended bynet.sourceforge.cruisecontrol.util.Commandline
      extended bynet.sourceforge.cruisecontrol.util.EnvCommandline
          extended bynet.sourceforge.cruisecontrol.sourcecontrols.accurev.AccurevCommandline
All Implemented Interfaces:
AccurevInputParser, java.lang.Cloneable, Runner

public class AccurevCommandline
extends EnvCommandline
implements AccurevInputParser, Runner

Allows to build and execute a valid accurev command line.

Author:
Nicola Orru', Jason Chown

Nested Class Summary
 
Nested classes inherited from class net.sourceforge.cruisecontrol.util.Commandline
Commandline.Argument, Commandline.Marker
 
Constructor Summary
AccurevCommandline(AccurevCommand command)
          Creates a new AccurevCommandline.
 
Method Summary
 void addArgument(java.lang.String argument)
          Adds an argument to the command line
 void addOption(java.lang.String option, java.lang.String optionArgument)
          Adds an option with an argument (eg.
 void assertSuccess()
          Throws a CruiseControlException if the last command was not executed successfully.
protected  java.lang.String[] buildCommandLine()
           
 boolean execute(AccurevInputParser inputParser)
          Runs accurev and parses the output
 AccurevCommand getCommand()
          Returns the accurev subcommand to be run by this command line object (eg. keep, synctime, update).
 int getReturnCode()
          Gets the last "accurev" exec's return code.
 boolean isSuccess()
          Returns the run status
 boolean isVerbose()
          Returns the verbose flag
 boolean parseStream(java.io.InputStream iStream)
          Default stream parser.
 void run()
          Runs accurev and returns a reference to this.
 void selectModified()
          Selects all modified files in keep (as in -m)
 void setComment(java.lang.String comment)
          Sets the transaction comment (-c comment)
 void setDepot(java.lang.String depot)
          Sets the Accurev depot to work in (-d depot)
 void setFileList(java.lang.String filelistName)
          Selects the files to use reading them from the filelist (as in -l filelistName)
 void setFormatExpanded(char format)
          Selects a format for hist as in (-f)
 void setInfoOnly()
          Switches the -i option on
 void setInputParser(AccurevInputParser inputParser)
          Sets the input parser, which is the object that handles Accurev's output as its input.
 void setRunner(Runner runner)
          Sets the runner
 void setStream(java.lang.String stream)
          Sets the Accurev stream to work in (-s stream)
 void setTransactionRange(Timespec time)
          Selects a transaction range for hist as in (-t), single timespec
 void setTransactionRange(Timespec begin, Timespec end)
          Selects a transaction range for hist as in (-t), timespec span (a-b, a-, -b)
 void setVerbose(boolean verbose)
          Enables/disables verbose logging
 void setWorkspaceLocalPath(java.io.File workspace)
          Selects the workspace to use, specifying its path in the local filesystem.
 void setWorkspaceLocalPath(java.lang.String workspace)
          Selects the workspace to use, specifying its path in the local filesystem.
 
Methods inherited from class net.sourceforge.cruisecontrol.util.EnvCommandline
execute, getVariable, setVariable
 
Methods inherited from class net.sourceforge.cruisecontrol.util.Commandline
addArguments, clear, clearArgs, clone, createArgument, createArgument, createArgument, createArguments, createMarker, executeAndWait, getArguments, getCommandline, getExecutable, getWorkingDir, getWorkingDirectory, quoteArgument, setExecutable, setWorkingDir, setWorkingDirectory, size, toString, toString, toString, toStringNoQuoting, translateCommandline, useSafeQuoting
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AccurevCommandline

public AccurevCommandline(AccurevCommand command)
Creates a new AccurevCommandline.

Parameters:
command -
Method Detail

setStream

public void setStream(java.lang.String stream)
Sets the Accurev stream to work in (-s stream)

Parameters:
stream - the stream name

setDepot

public void setDepot(java.lang.String depot)
Sets the Accurev depot to work in (-d depot)

Parameters:
depot - the depot name

setComment

public void setComment(java.lang.String comment)
Sets the transaction comment (-c comment)

Parameters:
comment - the comment text. Quotes and escapes are not required.

setInfoOnly

public void setInfoOnly()
Switches the -i option on


setTransactionRange

public void setTransactionRange(Timespec time)
Selects a transaction range for hist as in (-t), single timespec

Parameters:
time - a timespec (can be a DateTimespec, a KeywordTimespec

setTransactionRange

public void setTransactionRange(Timespec begin,
                                Timespec end)
Selects a transaction range for hist as in (-t), timespec span (a-b, a-, -b)


setFormatExpanded

public void setFormatExpanded(char format)
                       throws CruiseControlException
Selects a format for hist as in (-f)

Throws:
CruiseControlException

addArgument

public void addArgument(java.lang.String argument)
Adds an argument to the command line

Parameters:
argument - the argument to add (eg "-i"). Quotes and escape codes are not required.

setInputParser

public void setInputParser(AccurevInputParser inputParser)
Sets the input parser, which is the object that handles Accurev's output as its input.


addOption

public void addOption(java.lang.String option,
                      java.lang.String optionArgument)
Adds an option with an argument (eg. -s my_stream)

Parameters:
option - the option flag (eg. "-s")
optionArgument - the option argument ("eg. my_stream"). No need for quotes or escape characters.

selectModified

public void selectModified()
Selects all modified files in keep (as in -m)


setFileList

public void setFileList(java.lang.String filelistName)
Selects the files to use reading them from the filelist (as in -l filelistName)

Parameters:
filelistName - the path of the file containing the list of files to process

setWorkspaceLocalPath

public void setWorkspaceLocalPath(java.io.File workspace)
                           throws CruiseControlException
Selects the workspace to use, specifying its path in the local filesystem.

Parameters:
workspace - the workspace path
Throws:
CruiseControlException - if the path does not exist

setWorkspaceLocalPath

public void setWorkspaceLocalPath(java.lang.String workspace)
                           throws CruiseControlException
Selects the workspace to use, specifying its path in the local filesystem.

Parameters:
workspace - the workspace path
Throws:
CruiseControlException - if the path does not exist

run

public void run()
Runs accurev and returns a reference to this.


execute

public boolean execute(AccurevInputParser inputParser)
Runs accurev and parses the output

Specified by:
execute in interface Runner
Parameters:
inputParser -
Returns:
true if there are no parsing errors.

buildCommandLine

protected java.lang.String[] buildCommandLine()

parseStream

public boolean parseStream(java.io.InputStream iStream)
                    throws CruiseControlException
Default stream parser. It scans Accurev output and detects basic errors.

Specified by:
parseStream in interface AccurevInputParser
Parameters:
iStream - accurev's STDOUT
Returns:
true if no errors were found in Accurev's output.
Throws:
CruiseControlException - if fatal errors are found

getReturnCode

public int getReturnCode()
Gets the last "accurev" exec's return code.

Specified by:
getReturnCode in interface Runner
Returns:
the return code from the command line. Usually 0 is SUCCESS.

getCommand

public AccurevCommand getCommand()
Returns the accurev subcommand to be run by this command line object (eg. keep, synctime, update). The subcommand can be selected by the AccurevCommandline(AccurevCommand command) constructor.

Returns:
the command

setVerbose

public void setVerbose(boolean verbose)
Enables/disables verbose logging

Parameters:
verbose - if true, verbose logging is enabled.

isVerbose

public boolean isVerbose()
Returns the verbose flag

Returns:
true if verbose logging is enabled

isSuccess

public boolean isSuccess()
Returns the run status

Returns:
true if the last command executed successfully (that is, returnCode == success and the parser didn't detect errors). It returns false if the command has not been run yet.

assertSuccess

public void assertSuccess()
                   throws CruiseControlException
Throws a CruiseControlException if the last command was not executed successfully.

Throws:
CruiseControlException - if the command was not executed successfully

setRunner

public void setRunner(Runner runner)
Sets the runner

Parameters:
runner - the object that is in charge for provide some input to the parser