allensoft.javacvs.client.ui.command
Class CommandInterpretter

java.lang.Object
  |
  +--allensoft.javacvs.client.ui.command.CommandInterpretter

public class CommandInterpretter
extends java.lang.Object

Interprets commands of the format used by the cvs command line program and executes them using a CVSClient object.


Constructor Summary
CommandInterpretter(CVSClient client)
          Creates a new CommandInterpretter that inetrprets CVS commands and invokes the appropriate methods on the CVSClient.
 
Method Summary
 CVSRequestBatch add(java.lang.String sArguments)
          Performs an add command using the supplied arguments.
 void addCommandInterpretterListener(CommandInterpretterListener l)
           
 CVSRequestBatch checkout(java.lang.String sArguments)
          Performs a checkout command using the supplied arguments.
 CVSRequestBatch commit(java.lang.String sArguments)
          Performs a commit command using the supplied arguments.
 CVSRequestBatch diff(java.lang.String sArguments)
           
protected  void displayAddHelp()
           
protected  void displayCheckoutHelp()
           
protected  void displayCommitHelp()
           
protected  void displayDiffHelp()
           
protected  void displayErrorText(java.lang.String sText)
          Displays error messages.
protected  void displayExportHelp()
           
protected  void displayGlobalOptionsHelp()
          Displays help for global options.
protected  void displayImportDirectoryHelp()
           
protected  void displayKeywordSubstitutionModesHelp()
           
protected  void displayParseException(java.text.ParseException e)
           
protected  void displayRemoveHelp()
           
protected  void displayTagHelp()
           
protected  void displayText(java.lang.String sText)
          Displays normal messages.
protected  void displayUpdateHelp()
           
protected  void displayUsageHelp()
           
 CVSRequestBatch export(java.lang.String sArguments)
           
protected  void fireInterprettingCommand(java.lang.String sCommand)
           
 java.io.File getCurrentDirectory()
          Gets the current directory that commands are interpretted in.
 boolean getDisplayCommandHelp()
           
 RepositoryLocation getRepositoryLocation()
          Gets the repository location used for command such as checkout.
 CVSRequestBatch importDirectory(java.lang.String sArguments)
           
 CVSRequestBatch interpretCommand(java.lang.String sCommand)
          Interprets a command and executes it using the CVSClient specified during construction.
 CVSRequestBatch interpretCommand(java.lang.String[] command)
          Interprets a command from an array of strings.
 CVSRequestBatch remove(java.lang.String sArguments)
           
 void removeCommandListener(CommandInterpretterListener l)
           
 void setCurrentDirectory(java.io.File directory)
          Sets the current directory that commands are interpretted in.
 void setDisplayCommandHelp(boolean b)
           
 void setRepositoryLocation(RepositoryLocation location)
          Sets the repository location used for commands such as checkout.
 CVSRequestBatch tag(java.lang.String sArguments)
           
 CVSRequestBatch update(java.lang.String sArguments)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandInterpretter

public CommandInterpretter(CVSClient client)
Creates a new CommandInterpretter that inetrprets CVS commands and invokes the appropriate methods on the CVSClient.
Method Detail

addCommandInterpretterListener

public void addCommandInterpretterListener(CommandInterpretterListener l)

removeCommandListener

public void removeCommandListener(CommandInterpretterListener l)

getCurrentDirectory

public java.io.File getCurrentDirectory()
Gets the current directory that commands are interpretted in. Files that are specified relatively in commands will be assumed to be relative to this directory. Initially this will be initialized to the user's current directory (from the System property user.dir).

setCurrentDirectory

public void setCurrentDirectory(java.io.File directory)
Sets the current directory that commands are interpretted in.

getRepositoryLocation

public RepositoryLocation getRepositoryLocation()
                                         throws CVSException
Gets the repository location used for command such as checkout. If a repository location has not yet been specified with the setRepositoryLocation method then this method will attempt to use one defined by the system property user.env.cvsroot. It is expected that this system property will be initialised by the JVM (using the -D option) to equal the $CVSROOT environment variable. If this property has not been defined then a CVSException is thrown with a message to indicate that the repository location has not yet been specified.
Throws:
CVSException - if the repository location has not been set with setRepositoryLocation and the system property "user.env.cvsroot" has not been set.

setRepositoryLocation

public void setRepositoryLocation(RepositoryLocation location)
Sets the repository location used for commands such as checkout.

getDisplayCommandHelp

public boolean getDisplayCommandHelp()

setDisplayCommandHelp

public void setDisplayCommandHelp(boolean b)

interpretCommand

public CVSRequestBatch interpretCommand(java.lang.String sCommand)
                                 throws CVSException,
                                        java.io.IOException,
                                        java.text.ParseException
Interprets a command and executes it using the CVSClient specified during construction. For example, a command such as commit -m "This is a commit" MyProject" would cause the directory MyProject to be commited to the repository using the supplied log message.
Returns:
a CVSResponses object detailing the responses from all the servers. If no resonses were received from any servers, for example if the user just requested help for a command with -H, then null is returned.

interpretCommand

public CVSRequestBatch interpretCommand(java.lang.String[] command)
                                 throws CVSException,
                                        java.io.IOException,
                                        java.text.ParseException
Interprets a command from an array of strings. This method is useful when the command has been split up into an array (eg in the main method). It simply concatanates the elements of the array to build a command string and then calls the interpretCommand(String) method.

checkout

public CVSRequestBatch checkout(java.lang.String sArguments)
                         throws CVSException,
                                java.io.IOException,
                                java.text.ParseException
Performs a checkout command using the supplied arguments.

commit

public CVSRequestBatch commit(java.lang.String sArguments)
                       throws CVSException,
                              java.io.IOException,
                              java.text.ParseException
Performs a commit command using the supplied arguments.

update

public CVSRequestBatch update(java.lang.String sArguments)
                       throws CVSException,
                              java.io.IOException,
                              java.text.ParseException

add

public CVSRequestBatch add(java.lang.String sArguments)
                    throws CVSException,
                           java.io.IOException,
                           java.text.ParseException
Performs an add command using the supplied arguments.

remove

public CVSRequestBatch remove(java.lang.String sArguments)
                       throws CVSException,
                              java.io.IOException,
                              java.text.ParseException

importDirectory

public CVSRequestBatch importDirectory(java.lang.String sArguments)
                                throws CVSException,
                                       java.io.IOException,
                                       java.text.ParseException

export

public CVSRequestBatch export(java.lang.String sArguments)
                       throws CVSException,
                              java.io.IOException,
                              java.text.ParseException

diff

public CVSRequestBatch diff(java.lang.String sArguments)
                     throws CVSException,
                            java.io.IOException,
                            java.text.ParseException

tag

public CVSRequestBatch tag(java.lang.String sArguments)
                    throws CVSException,
                           java.io.IOException,
                           java.text.ParseException

fireInterprettingCommand

protected void fireInterprettingCommand(java.lang.String sCommand)

displayGlobalOptionsHelp

protected void displayGlobalOptionsHelp()
Displays help for global options.
Parameters:
e - ParseException that occurred whilst trying to parse the global options or null if not applicable.

displayUsageHelp

protected void displayUsageHelp()

displayKeywordSubstitutionModesHelp

protected void displayKeywordSubstitutionModesHelp()

displayUpdateHelp

protected void displayUpdateHelp()

displayCommitHelp

protected void displayCommitHelp()

displayAddHelp

protected void displayAddHelp()

displayRemoveHelp

protected void displayRemoveHelp()

displayImportDirectoryHelp

protected void displayImportDirectoryHelp()

displayExportHelp

protected void displayExportHelp()

displayCheckoutHelp

protected void displayCheckoutHelp()

displayDiffHelp

protected void displayDiffHelp()

displayTagHelp

protected void displayTagHelp()

displayParseException

protected void displayParseException(java.text.ParseException e)

displayErrorText

protected void displayErrorText(java.lang.String sText)
Displays error messages. By default this sends the error message to System.err.

displayText

protected void displayText(java.lang.String sText)
Displays normal messages. By default this sends the message to System.out.