allensoft.javacvs.client
Class CVSRequest

java.lang.Object
  |
  +--allensoft.javacvs.client.CVSCommunicationsObject
        |
        +--allensoft.javacvs.client.CVSRequest
Direct Known Subclasses:
CheckoutRequest, ExpandModulesRequest, ExportRequest, GetWrapperRCSOptionsRequest, ImportRequest, MultiFileCVSRequest, SingleFileCVSRequest, ValidRequestsRequest

public abstract class CVSRequest
extends CVSCommunicationsObject

The base class for all requests to a CVS server. A request is perofrmed by a CVSClient object using the CVSClient.performRequest method. Sub classes of this class can use the helper methods sendXXX to send specific commands and data to the server. These methods forward the request to the client to actually send it over the current server connection.


Constructor Summary
protected CVSRequest()
           
 
Method Summary
protected  boolean canSendIsModified()
          Determines if this request can send Is-modified commands to the server instead of Modified commands.
protected  CVSResponse createResponse()
          Creates the response object used to receive the response for this request from the server.
protected  void fireStatusUpdate(java.lang.String sText)
           
 CVSClient getClient()
          Gets the client that this request is running on.
abstract  java.io.File getCurrentDirectory()
          Gets the directory that all file paths are specified relative to when executing this request.
 java.lang.String getDescription()
           
 java.lang.Exception getException()
          Gets the exception that occurred when this request was executed.
abstract  RepositoryLocation getRepositoryLocation()
          Gets the repository location that the client must connect to in order to perform this request.
protected  CVSRequest getRequest()
          Required for the implementation of CVSCommunicationsObject.
protected  java.lang.String getResourceString(java.lang.String sSubKey)
           
 CVSResponse getResponse()
          Gets the response from the server for this request.
protected  boolean getSendQuestionableCommands()
           
 boolean hasCompletedSuccessfully()
          Checks if this request has completed successfully or not.
protected  CVSResponse performRequest()
          This is the main method for the request and is responsible for sending this request to the server.
protected  void sendRequest()
          Sends this request to the server.
protected  boolean validateRequest()
          Validates this request.
 void waitForSuccessfulCompletion()
          Causes the calling thread to wait until this request has completed successfully.
 
Methods inherited from class allensoft.javacvs.client.CVSCommunicationsObject
expandModules, flush, getFileFromRelativePath, getRelativePath, getRelativePath, getRelativePath, getWrapperRCSOptions, performSubRequest, receiveFile, receiveFile, receiveLine, sendArgument, sendArgument, sendArgument, sendArgument, sendCheckinProg, sendCurrentDirectory, sendDateOption, sendDirectory, sendDirectory, sendEntry, sendFileDetails, sendFileDetails, sendFileDetails, sendGlobalOption, sendKopt, sendLine, sendModified, sendOptions, sendStaticDirectory, sendSticky, sendText, sendUnchanged, sendUpdateProg, sendWorkingDirectoryDetails, sendWorkingDirectoryDetails, sendWorkingDirectoryDetails, validRequests
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CVSRequest

protected CVSRequest()
Method Detail

canSendIsModified

protected boolean canSendIsModified()
Determines if this request can send Is-modified commands to the server instead of Modified commands. The Is-modified command just tells the server that a file has been modified, wheras the Modified command send the contents of the file as well. Please see the client protocol specification for more details. The default is to return false here so that Modified commands are sent instead of Is-modified.

getRequest

protected final CVSRequest getRequest()
Required for the implementation of CVSCommunicationsObject.

getClient

public final CVSClient getClient()
Gets the client that this request is running on.
Overrides:
getClient in class CVSCommunicationsObject

getRepositoryLocation

public abstract RepositoryLocation getRepositoryLocation()
Gets the repository location that the client must connect to in order to perform this request.

getCurrentDirectory

public abstract java.io.File getCurrentDirectory()
Gets the directory that all file paths are specified relative to when executing this request.
Overrides:
getCurrentDirectory in class CVSCommunicationsObject

getDescription

public java.lang.String getDescription()

getSendQuestionableCommands

protected boolean getSendQuestionableCommands()

validateRequest

protected boolean validateRequest()
                           throws CVSException,
                                  java.io.IOException
Validates this request. This is called before sending the request or attempting to make a connection to the server. It can be overridden to validate the settings in this request to ensure it is valid before attempting to connect and send this reqesuest. If this request is invalid then a CVSException is thrown describing why the request is invalid.
Returns:
true if the request needs to be sent (i.e. there is something to be done or false if the request does not need to be sent.

hasCompletedSuccessfully

public boolean hasCompletedSuccessfully()
Checks if this request has completed successfully or not.

waitForSuccessfulCompletion

public void waitForSuccessfulCompletion()
Causes the calling thread to wait until this request has completed successfully.

getResponse

public CVSResponse getResponse()
Gets the response from the server for this request.
Returns:
the response or null if the request has not yet been performed, didn't complete successfully, or the server didn't return a response.

getException

public java.lang.Exception getException()
Gets the exception that occurred when this request was executed.
Returns:
the exception that ocurred or null if there was no exception (e.g. because this request has not yet been performed or it completed successfully).

performRequest

protected CVSResponse performRequest()
                              throws java.io.IOException,
                                     CVSException
This is the main method for the request and is responsible for sending this request to the server. The default implementation is to call sendRequest and createResponse and then call the receiveResponse method on the response object. If the request is aborted then null will be returned for the response.

sendRequest

protected void sendRequest()
                    throws java.io.IOException,
                           CVSException
Sends this request to the server.

createResponse

protected CVSResponse createResponse()
Creates the response object used to receive the response for this request from the server.
Returns:
the response object for this request or null if no response is expected.

getResourceString

protected java.lang.String getResourceString(java.lang.String sSubKey)

fireStatusUpdate

protected void fireStatusUpdate(java.lang.String sText)