Groovy Documentation

java.gate.versioning.cmdline
Class AbstractRepository

java.lang.Object
  java.gate.versioning.cmdline.AbstractRepository
All Implemented Interfaces:
Repository

class AbstractRepository

Abstract repository implementation. The public API of this class is documented on the Repository interface. Implementors control the behaviour of the methods here by overriding parameterisation methods like #getCommandName, or simply by providing their own replacement implementations of the Repository methods.

see:
gate.versioning.cmdline.Repository
see:
gate.versioning.cmdline.CvsRepository
see:
gate.versioning.cmdline.SvnRepository


Nested Class Summary
class AbstractRepository.StreamGobbler

This class is used to consume streams in new threads without blocking.

 
Field Summary
protected static boolean DEBUG

Debugging messages.

protected String commandOutput

Output from repository command execution.

protected String nl

Shorthand for newlines.

protected String root

The root or URL of the repository.

protected String stderrOutput

Stderr from repository command execution.

protected String stdoutOutput

Stdout from repository command execution.

protected File workingDir

The current working directory.

 
Constructor Summary
AbstractRepository()

Construction.

 
Method Summary
boolean add(String fileName)

Add to the repository.

protected String[] buildCommandArray(String fileName, String subCommand, String subCommandFlag)

Calls { java.lang.String, boolean) buildCommandArray/4} with the no root parameter set false.

protected String[] buildCommandArray(String fileName, String subCommand, String subCommandFlag, boolean noRoot)

Build an array to pass to runtime.exec.

boolean checkin(String fileName)

Commit changes.

boolean checkin(String fileName, String message)

Commit changes.

boolean checkout(String fileName)

Check out a file, directory or module.

boolean delete(String fileName)

Delete from the repository.

String diff(String fileName)

Get the difference with the repository version.

String getCommandName()

Name of the repository command to execute.

String getCommandOutput()

Get a string containing the stdout and stderr from the command execution.

String getCommandStderr()

Get a string containing the stderr from the command execution.

String getCommandStdout()

Get a string containing the stdout from the command execution.

protected List getPostCommand(String fileName, boolean noRoot)

Specifies what (if anything) should follow the subcommand.

protected List getPreCommand()

Specifies what (if anything) should precede the subcommand.

static Repository getRepository(String root)

Return a class that supports the given root specifier.

String getRoot()

The root / URL of the repository

void init()

Validate parameters.

protected boolean runCommand(String[] command)

Run a command, wait for termination and report status

protected boolean runCommand(String[] command, boolean allowExitOne)

Run a command, wait for termination and report status.

void setRoot(String root)

The root / URL of the repository

void setWorkingDir(File workingDir)

The working directory for repository actions

String status(String fileName)

Status.

boolean update(String fileName)

Update.

 
Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll
 

Field Detail

DEBUG

protected static boolean DEBUG
Debugging messages.


commandOutput

protected String commandOutput
Output from repository command execution.


nl

protected String nl
Shorthand for newlines.


root

protected String root
The root or URL of the repository.


stderrOutput

protected String stderrOutput
Stderr from repository command execution.


stdoutOutput

protected String stdoutOutput
Stdout from repository command execution.


workingDir

protected File workingDir
The current working directory.


 
Constructor Detail

AbstractRepository

public AbstractRepository()
Construction.


 
Method Detail

add

public boolean add(String fileName)
Add to the repository.
param:
fileName the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
return:
boolean representing success or failure.


buildCommandArray

protected String[] buildCommandArray(String fileName, String subCommand, String subCommandFlag)
Calls #buildCommandArray(java.lang.String, java.lang.String, java.lang.String, boolean) buildCommandArray/4 with the no root parameter set false.


buildCommandArray

protected String[] buildCommandArray(String fileName, String subCommand, String subCommandFlag, boolean noRoot)
Build an array to pass to runtime.exec. Behaviour modified by #getCommandName, #getPreCommand and #getPostCommand.
param:
fileName the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
param:
subCommand the repository command, e.g. "co".
param:
subCommandFlag a flag for the command (e.g. "-d"), or null.
param:
noRoot when true indicates that the root isn't necessary for this command.


checkin

public boolean checkin(String fileName)
Commit changes. A default message is used.
param:
fileName the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
return:
boolean representing success or failure.


checkin

public boolean checkin(String fileName, String message)
Commit changes.
param:
fileName the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
param:
message a commit message.
return:
boolean representing success or failure.


checkout

public boolean checkout(String fileName)
Check out a file, directory or module.
param:
fileName the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
return:
boolean representing success or failure.


delete

public boolean delete(String fileName)
Delete from the repository.
param:
fileName the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
return:
boolean representing success or failure.


diff

public String diff(String fileName)
Get the difference with the repository version.
param:
fileName the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
return:
a string containing the difference, or "" for no difference, or null for error.


getCommandName

public String getCommandName()
Name of the repository command to execute.


getCommandOutput

public String getCommandOutput()
Get a string containing the stdout and stderr from the command execution.


getCommandStderr

public String getCommandStderr()
Get a string containing the stderr from the command execution.


getCommandStdout

public String getCommandStdout()
Get a string containing the stdout from the command execution.


getPostCommand

protected List getPostCommand(String fileName, boolean noRoot)
Specifies what (if anything) should follow the subcommand.


getPreCommand

protected List getPreCommand()
Specifies what (if anything) should precede the subcommand.


getRepository

public static Repository getRepository(String root)
Return a class that supports the given root specifier. The type of the class is a guess based on characteristics of the string (e.g. URLs are for SVN).
param:
root root specifier for the desired Repository implementor.
return:
a non-initialised Repository object


getRoot

public String getRoot()
The root / URL of the repository


init

public void init()
Validate parameters.


runCommand

protected boolean runCommand(String[] command)
Run a command, wait for termination and report status


runCommand

protected boolean runCommand(String[] command, boolean allowExitOne)
Run a command, wait for termination and report status.
param:
allowExitOne accept a command return value of 1 as success (e.g. for cvs diff).


setRoot

public void setRoot(String root)
The root / URL of the repository


setWorkingDir

public void setWorkingDir(File workingDir)
The working directory for repository actions


status

public String status(String fileName)
Status.
param:
fileName the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
return:
String giving status ouput.


update

public boolean update(String fileName)
Update.
param:
fileName the file or directory to work on (should be relative to the repository's working directory, and use "/" as a path separator).
return:
boolean representing success or failure.


 

Groovy Documentation