allensoft.javacvs.client
Class CVSResponse

java.lang.Object
  |
  +--allensoft.javacvs.client.CVSCommunicationsObject
        |
        +--allensoft.javacvs.client.CVSResponse
Direct Known Subclasses:
DiffResponse, ExpandModulesResponse, GetWrapperRCSOptionsResponse, LogResponse, ModuleExpansionResponse, StatusResponse, ValidRequestsResponse

public class CVSResponse
extends CVSCommunicationsObject

The base class for all responses from the server. Sub-classes usually override the processXXXXResponse methods to extract data from a response they are interested in.


Inner Class Summary
static class CVSResponse.Message
          Defines a message that was received from the server that should be displayed to the user.
 
Constructor Summary
CVSResponse(CVSRequest request)
           
CVSResponse(CVSRequest request, boolean bCreateCVSClientFiles)
          Creates a new CVSResponse.
 
Method Summary
protected  void checkedIn(FileEntry entry)
          Called when a Checked-in response is received for the supplied file entry.
protected  void endOfResponse()
           
 CVSClient getClient()
          Gets the client object that is used to communicate with the server.
protected  java.io.File getCurrentDirectory()
          Gets the current directory for this communications object.
 java.lang.String getErrorCode()
          Gets the error code from an "error" resonse from the server.
 java.lang.String getErrorMessage()
          Gets the error message from an "error" resonse from the server.
protected  java.io.File getFileFromPathNameResponse(java.lang.String s)
          Gets the local file from the supplied path name that is returned with most server responses.
 CVSResponse.Message getMessage(int nIndex)
           
 int getMessageCount()
          Gets the number of messages that were received from the server that should be displayed to the user.
 CVSRequest getRequest()
          Gets the request that this response is for.
 boolean hadError()
          Checks if this reply had an error (i.e.
protected  void processCheckedInResponse(java.lang.String s)
           
protected  void processChecksumResponse(java.lang.String s)
           
protected  void processClearStaticDirectoryResponse(java.lang.String s)
           
protected  void processClearStickyResponse(java.lang.String s)
           
protected  void processCopyFileResponse(java.lang.String s)
           
protected  void processCreatedResponse(java.lang.String s)
           
protected  void processErrorResponse(java.lang.String s)
           
protected  void processMergedResponse(java.lang.String s)
           
protected  void processModeResponse(java.lang.String s)
           
protected  void processModTimeResponse(java.lang.String s)
           
protected  void processModuleExpansionResponse(java.lang.String s)
           
protected  void processNewEntryResponse(java.lang.String s)
           
protected  void processNotifiedResponse(java.lang.String s)
           
protected  void processOkResponse(java.lang.String s)
           
protected  void processPatchedResponse(java.lang.String s)
           
protected  void processRcsDiffResponse(java.lang.String s)
           
protected  void processRemovedResponse(java.lang.String s)
           
protected  void processRemoveEntryResponse(java.lang.String s)
           
protected  void processSetCheckinProgResponse(java.lang.String s)
           
protected  void processSetStaticDirectoryResponse(java.lang.String s)
           
protected  void processSetStickyResponse(java.lang.String s)
           
protected  void processSetUpdateProgResponse(java.lang.String s)
           
protected  void processStderrMessageResponse(java.lang.String s)
           
protected  void processStdoutBinaryMessageResponse(java.lang.String s)
           
protected  void processStdoutMessageResponse(java.lang.String s)
           
protected  void processTemplateResponse(java.lang.String s)
           
protected  void processUnrecognizedResponse(java.lang.String s)
           
protected  void processUpdatedResponse(java.lang.String s)
           
protected  void processUpdateExistingResponse(java.lang.String s)
           
protected  void processValidRequestsResponse(java.lang.String s)
           
protected  void processWrapperRcsOptionResponse(java.lang.String s)
           
protected  void receiveResponse()
          Receives the entire response from the server.
protected  FileEntry updateFileEntryDetails(java.io.File file, java.lang.String sEntry)
          Updates the file entry specified by the supplied file using the entry details from a server response.
protected  void updateFileFromResponse(java.lang.String s)
          Updates a file from a server response.
 
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

CVSResponse

public CVSResponse(CVSRequest request,
                   boolean bCreateCVSClientFiles)
Creates a new CVSResponse.
Parameters:
request - the request that this response will be to
bCreateCVSClientFiles - if true then the client files in the CVS directories will be created/updated as responses are received from the server. If false then the files won't be created or modified.

CVSResponse

public CVSResponse(CVSRequest request)
Method Detail

getClient

public CVSClient getClient()
Description copied from class: CVSCommunicationsObject
Gets the client object that is used to communicate with the server.
Overrides:
getClient in class CVSCommunicationsObject

getCurrentDirectory

protected java.io.File getCurrentDirectory()
Description copied from class: CVSCommunicationsObject
Gets the current directory for this communications object.
Overrides:
getCurrentDirectory in class CVSCommunicationsObject

getRequest

public CVSRequest getRequest()
Gets the request that this response is for.

hadError

public boolean hadError()
Checks if this reply had an error (i.e. The server sent an "error" response back). If it did have an error the getErrorCode and getErrorMessage can be used to retreive the error.

getErrorCode

public java.lang.String getErrorCode()
Gets the error code from an "error" resonse from the server.
Returns:
null if no "error" resonse was received or if the server did not provide the error code.

getErrorMessage

public java.lang.String getErrorMessage()
Gets the error message from an "error" resonse from the server.
Returns:
null if no "error" resonse was received or if the server did not provide the error message.

getMessageCount

public int getMessageCount()
Gets the number of messages that were received from the server that should be displayed to the user.

getMessage

public CVSResponse.Message getMessage(int nIndex)

receiveResponse

protected void receiveResponse()
                        throws java.io.IOException,
                               CVSException
Receives the entire response from the server. Normally, sub classes wouldn't override this method but would override the processXXXXResponse methods that this method calls when it receives particualr responses.

getFileFromPathNameResponse

protected java.io.File getFileFromPathNameResponse(java.lang.String s)
                                            throws CVSException,
                                                   java.io.IOException
Gets the local file from the supplied path name that is returned with most server responses. If the directory does not exist it is created as this is what the protocol defines.
Parameters:
s - the first line of the path response
Returns:
a file object that represents the file on the client.

updateFileEntryDetails

protected FileEntry updateFileEntryDetails(java.io.File file,
                                           java.lang.String sEntry)
                                    throws CVSException,
                                           java.io.IOException
Updates the file entry specified by the supplied file using the entry details from a server response.

processErrorResponse

protected void processErrorResponse(java.lang.String s)

processOkResponse

protected void processOkResponse(java.lang.String s)

processValidRequestsResponse

protected void processValidRequestsResponse(java.lang.String s)
                                     throws java.io.IOException,
                                            CVSException

processCheckedInResponse

protected void processCheckedInResponse(java.lang.String s)
                                 throws java.io.IOException,
                                        CVSException

checkedIn

protected void checkedIn(FileEntry entry)
Called when a Checked-in response is received for the supplied file entry.

processNewEntryResponse

protected void processNewEntryResponse(java.lang.String s)
                                throws java.io.IOException,
                                       CVSException

updateFileFromResponse

protected void updateFileFromResponse(java.lang.String s)
                               throws java.io.IOException,
                                      CVSException
Updates a file from a server response. The server response is expected to be a path name (see CVS protocol spec.), followed by an entry line, followed by a permissions line, followed by a file transmission. The contents of the file are updated accordingly and its permissions are set. The entry for the file is also updated to indicate the revision, ststus etc. If the file exists the file is first received to a temporary file rather than directly overwriting the file as there may be problems during file transmission and the file would be left in an unknown state. Once received to a temporary file, the contents are then copied over the actual file. The modification time and permissions are only set for the file is native support is enabled on the host platform (see allensoft.io.UnixFileSupport and allensoft.io.BasicFileSupport).
Parameters:
s - the first line of the server response for the path name of the file to be updated.

processUpdatedResponse

protected void processUpdatedResponse(java.lang.String s)
                               throws java.io.IOException,
                                      CVSException

processCreatedResponse

protected void processCreatedResponse(java.lang.String s)
                               throws java.io.IOException,
                                      CVSException

processUpdateExistingResponse

protected void processUpdateExistingResponse(java.lang.String s)
                                      throws java.io.IOException,
                                             CVSException

processMergedResponse

protected void processMergedResponse(java.lang.String s)
                              throws java.io.IOException,
                                     CVSException

processRcsDiffResponse

protected void processRcsDiffResponse(java.lang.String s)
                               throws java.io.IOException,
                                      CVSException

processPatchedResponse

protected void processPatchedResponse(java.lang.String s)
                               throws java.io.IOException,
                                      CVSException

processModeResponse

protected void processModeResponse(java.lang.String s)
                            throws java.io.IOException,
                                   CVSException

processModTimeResponse

protected void processModTimeResponse(java.lang.String s)
                               throws java.io.IOException,
                                      CVSException

processChecksumResponse

protected void processChecksumResponse(java.lang.String s)
                                throws java.io.IOException,
                                       CVSException

processCopyFileResponse

protected void processCopyFileResponse(java.lang.String s)
                                throws java.io.IOException,
                                       CVSException

processRemovedResponse

protected void processRemovedResponse(java.lang.String s)
                               throws java.io.IOException,
                                      CVSException

processRemoveEntryResponse

protected void processRemoveEntryResponse(java.lang.String s)
                                   throws java.io.IOException,
                                          CVSException

processSetStaticDirectoryResponse

protected void processSetStaticDirectoryResponse(java.lang.String s)
                                          throws java.io.IOException,
                                                 CVSException

processClearStaticDirectoryResponse

protected void processClearStaticDirectoryResponse(java.lang.String s)
                                            throws java.io.IOException,
                                                   CVSException

processSetStickyResponse

protected void processSetStickyResponse(java.lang.String s)
                                 throws java.io.IOException,
                                        CVSException

processClearStickyResponse

protected void processClearStickyResponse(java.lang.String s)
                                   throws java.io.IOException,
                                          CVSException

processTemplateResponse

protected void processTemplateResponse(java.lang.String s)
                                throws java.io.IOException,
                                       CVSException

processSetCheckinProgResponse

protected void processSetCheckinProgResponse(java.lang.String s)
                                      throws java.io.IOException,
                                             CVSException

processSetUpdateProgResponse

protected void processSetUpdateProgResponse(java.lang.String s)
                                     throws java.io.IOException,
                                            CVSException

processNotifiedResponse

protected void processNotifiedResponse(java.lang.String s)
                                throws java.io.IOException,
                                       CVSException

processModuleExpansionResponse

protected void processModuleExpansionResponse(java.lang.String s)
                                       throws java.io.IOException,
                                              CVSException

processWrapperRcsOptionResponse

protected void processWrapperRcsOptionResponse(java.lang.String s)
                                        throws java.io.IOException,
                                               CVSException

processStdoutMessageResponse

protected void processStdoutMessageResponse(java.lang.String s)
                                     throws java.io.IOException,
                                            CVSException

processStdoutBinaryMessageResponse

protected void processStdoutBinaryMessageResponse(java.lang.String s)
                                           throws java.io.IOException,
                                                  CVSException

processStderrMessageResponse

protected void processStderrMessageResponse(java.lang.String s)
                                     throws java.io.IOException,
                                            CVSException

processUnrecognizedResponse

protected void processUnrecognizedResponse(java.lang.String s)

endOfResponse

protected void endOfResponse()