org.netbeans.lib.cvsclient.command
Class BasicCommand

java.lang.Object
  extended by org.netbeans.lib.cvsclient.command.Command
      extended by org.netbeans.lib.cvsclient.command.BuildableCommand
          extended by org.netbeans.lib.cvsclient.command.BasicCommand
All Implemented Interfaces:
java.lang.Cloneable, CVSListener
Direct Known Subclasses:
AnnotateCommand, CheckoutCommand, CommitCommand, DiffCommand, EditCommand, EditorsCommand, LogCommand, RannotateCommand, RemoveCommand, RlogCommand, StatusCommand, TagCommand, UneditCommand, UpdateCommand, WatchCommand, WatchersCommand

public abstract class BasicCommand
extends BuildableCommand

A class that provides common functionality for many of the CVS command that send similar sequences of requests.


Field Summary
protected  ClientServices clientServices
          The client services that are provided to this command.
protected  java.io.File[] files
          The files and/or directories to operate on.
protected  java.util.List requests
          The requests that are sent and processed.
 
Fields inherited from class org.netbeans.lib.cvsclient.command.BuildableCommand
builder
 
Fields inherited from class org.netbeans.lib.cvsclient.command.Command
localDirectory
 
Constructor Summary
BasicCommand()
           
 
Method Summary
protected  void addArgumentRequest(boolean value, java.lang.String argument)
          If the specified value is true, add a ArgumentRequest for the specified argument.
protected  void addArgumentRequests()
          Add the argument requests.
protected  void addDirectoryRequest(java.io.File directory)
          Adds a DirectoryRequest (and maybe a StickyRequest) to the request list.
protected  void addRequest(Request request)
          Adds the specified request to the request list.
protected  void addRequestForFile(java.io.File file, Entry entry)
          This method is called for each explicit file and for files within a directory.
protected  void addRequestForWorkingDirectory(ClientServices clientServices)
          Adds the request for the current working directory.
protected  void addRequestsForDirectory(java.io.File directory)
          Adds the appropriate requests for a given directory.
protected  void addRequestsForFile(java.io.File file)
          Add the appropriate requests for a single file.
protected  void appendFileArguments(java.lang.StringBuffer buffer)
          Appends the file's names to the specified buffer.
protected  boolean assumeLocalPathWhenUnspecified()
          The result from this command is used only when the getFiles() returns null or empty array.
protected  boolean doesCheckFileTime()
          Should return true if unchanged files should not be sent to server.
 void execute(ClientServices client, EventManager em)
          Execute a command.
 java.io.File getFileEndingWith(java.lang.String ending)
           
 java.io.File[] getFiles()
          Get the files and/or directories specified for this command to operate on.
 boolean getRecursive()
          Deprecated. use isRecursive instead
 java.io.File getXthFile(int index)
          Get a single file from the "files" list.
 boolean isRecursive()
          Gets the value of the recursive option.
protected  void sendEntryAndModifiedRequests(Entry entry, java.io.File file)
          Send an Entry followed by a Modified or Unchanged request based on whether the file has been untouched on the local machine.
 void setFiles(java.io.File[] theFiles)
          Set the files and/or directories on which to execute the command.
 void setRecursive(boolean recursive)
          Sets the value of the recursive option.
 
Methods inherited from class org.netbeans.lib.cvsclient.command.BuildableCommand
commandTerminated, createBuilder, isBuilderSet, messageSent, messageSent, setBuilder
 
Methods inherited from class org.netbeans.lib.cvsclient.command.Command
clone, fileAdded, fileInfoGenerated, fileRemoved, fileToRemove, fileUpdated, getCVSArguments, getCVSCommand, getDisplayName, getGlobalOptions, getLocalDirectory, getLocalPath, getOptString, getRelativeToLocalPathInUnixStyle, getTrimmedString, hasFailed, moduleExpanded, resetCVSCommand, setCVSCommand, setDisplayName, setLocalDirectory
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requests

protected java.util.List requests
The requests that are sent and processed.


clientServices

protected ClientServices clientServices
The client services that are provided to this command.


files

protected java.io.File[] files
The files and/or directories to operate on.

Constructor Detail

BasicCommand

public BasicCommand()
Method Detail

getRecursive

public boolean getRecursive()
Deprecated. use isRecursive instead

Gets the value of the recursive option.

Returns:
true if recursive, false if not

isRecursive

public boolean isRecursive()
Gets the value of the recursive option.

Returns:
true if recursive, false if not

setRecursive

public void setRecursive(boolean recursive)
Sets the value of the recursive option.

Parameters:
recursive - true if the command should recurse, false otherwise

setFiles

public void setFiles(java.io.File[] theFiles)
Set the files and/or directories on which to execute the command. The way these are processed is:

Parameters:
theFiles - the files to operate on. May be null to indicate that the local directory specified in the client should be used. Full, absolute canonical pathnames must be supplied.

getFiles

public java.io.File[] getFiles()
Get the files and/or directories specified for this command to operate on.

Returns:
the array of Files

getXthFile

public java.io.File getXthFile(int index)
Get a single file from the "files" list. returns only files, not directories. This method is used from within the builders, because for single file requests, the cvs server doesn't return us enough information to identify what file has been returned. Thus we sort the "files" array (files come before directories. Then the response froms erver comes in the same order and the files can be found this way.

Parameters:
index - the index of the file in the list.

getFileEndingWith

public java.io.File getFileEndingWith(java.lang.String ending)
Parameters:
ending - - the ending part of the file's pathname.. path separator is cvs's default '/'

doesCheckFileTime

protected boolean doesCheckFileTime()
Should return true if unchanged files should not be sent to server. If false is returned, all files will be sent to server This method is used by sendEntryAndModifiedRequests.


sendEntryAndModifiedRequests

protected void sendEntryAndModifiedRequests(Entry entry,
                                            java.io.File file)
Send an Entry followed by a Modified or Unchanged request based on whether the file has been untouched on the local machine.

Parameters:
entry - the entry for the file
file - the file in question

addRequestsForDirectory

protected void addRequestsForDirectory(java.io.File directory)
                                throws java.io.IOException,
                                       CommandAbortedException
Adds the appropriate requests for a given directory. Sends a directory request followed by as many Entry and Modified requests as required

Parameters:
directory - the directory to send requests for
Throws:
java.io.IOException - if an error occurs constructing the requests
CommandAbortedException

addRequestForFile

protected void addRequestForFile(java.io.File file,
                                 Entry entry)
This method is called for each explicit file and for files within a directory.


addRequestsForFile

protected void addRequestsForFile(java.io.File file)
                           throws java.io.IOException
Add the appropriate requests for a single file. A directory request is sent, followed by an Entry and Modified request

Parameters:
file - the file to send requests for
Throws:
java.io.IOException - if an error occurs constructing the requests

addDirectoryRequest

protected final void addDirectoryRequest(java.io.File directory)
Adds a DirectoryRequest (and maybe a StickyRequest) to the request list.


addArgumentRequests

protected void addArgumentRequests()
Add the argument requests. The argument requests are created using the original set of files/directories passed in. Subclasses of this class should call this method at the appropriate point in their execute() method. Note that arguments are appended to the list.


execute

public void execute(ClientServices client,
                    EventManager em)
             throws CommandException,
                    AuthenticationException
Execute a command. This implementation sends a Root request, followed by as many Directory and Entry requests as is required by the recurse setting and the file arguments that have been set. Subclasses should call this first, and tag on the end of the requests list any further requests and, finally, the actually request that does the command (e.g.
update
,
status
etc.)

Overrides:
execute in class BuildableCommand
Parameters:
client - the client services object that provides any necessary services to this command, including the ability to actually process all the requests
Throws:
CommandException - if an error occurs executing the command
AuthenticationException

assumeLocalPathWhenUnspecified

protected boolean assumeLocalPathWhenUnspecified()
The result from this command is used only when the getFiles() returns null or empty array. in such a case and when this method returns true, it is assumed the localpath should be taken as the 'default' file for the building of requests. Generally assumed to be true. Can be overriden by subclasses. However make sure you know what you are doing. :)


addRequest

protected final void addRequest(Request request)
Adds the specified request to the request list.


addRequestForWorkingDirectory

protected final void addRequestForWorkingDirectory(ClientServices clientServices)
                                            throws java.io.IOException
Adds the request for the current working directory.

Throws:
java.io.IOException

addArgumentRequest

protected final void addArgumentRequest(boolean value,
                                        java.lang.String argument)
If the specified value is true, add a ArgumentRequest for the specified argument.


appendFileArguments

protected final void appendFileArguments(java.lang.StringBuffer buffer)
Appends the file's names to the specified buffer.


 

Built on August 7 2008.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.