org.netbeans.lib.cvsclient.command
Class Command

java.lang.Object
  extended by org.netbeans.lib.cvsclient.command.Command
All Implemented Interfaces:
java.lang.Cloneable, CVSListener
Direct Known Subclasses:
BuildableCommand, HistoryCommand

public abstract class Command
extends java.lang.Object
implements CVSListener, java.lang.Cloneable

All commands must extend this class. A command is essentially a collection of requests that make up what is logically known as a CVS command (from a user's perspective). Commands correspond to operations the user can perform with CVS, for example checkout a module or perform a diff on two file versions.
Commands are automatically added as CVS event listeners. They can act on particular events and perhaps fire new events.


Field Summary
protected  java.lang.String localDirectory
          The local directory from which the command is being run.
 
Constructor Summary
Command()
           
 
Method Summary
 java.lang.Object clone()
          This method just calls the Object.clone() and makes it public.
 void commandTerminated(TerminationEvent e)
          Called when server responses with "ok" or "error", (when the command finishes).
 void execute(ClientServices client, EventManager eventManager)
          Execute this command.
 void fileAdded(FileAddedEvent e)
          Called when a file has been added.
 void fileInfoGenerated(FileInfoEvent e)
          Called when file status information has been received.
 void fileRemoved(FileRemovedEvent e)
          Called when a file is removed.
 void fileToRemove(FileToRemoveEvent e)
          Called when a file is going to be removed.
 void fileUpdated(FileUpdatedEvent e)
          Called when a file has been updated.
abstract  java.lang.String getCVSArguments()
          Returns the arguments of the command in the command-line style.
abstract  java.lang.String getCVSCommand()
          This method returns how the command would looklike when typed on the command line.
 java.lang.String getDisplayName()
          Returns localized name describing command purpose or null.
 GlobalOptions getGlobalOptions()
          Get the global options.
 java.lang.String getLocalDirectory()
          Returns the local path the command is associated with.
 java.lang.String getLocalPath()
          Deprecated. Please use the getLocalDirectory() method instead.
abstract  java.lang.String getOptString()
          Returns a String that defines which options are available for this particular command.
 java.lang.String getRelativeToLocalPathInUnixStyle(java.io.File file)
          Returns the relative path of the specified file (relative to the set local path).
protected static java.lang.String getTrimmedString(java.lang.String s)
          Returns the trimmed version of the specified String s.
 boolean hasFailed()
           
 void messageSent(BinaryMessageEvent e)
          Called when the server wants to send a binary message to be displayed to the user.
 void messageSent(MessageEvent e)
          Called when the server wants to send a message to be displayed to the user.
 void moduleExpanded(ModuleExpansionEvent e)
          This is called when the servers has responded to an expand-modules request.
abstract  void resetCVSCommand()
          Resets all switches in the command to the default behaviour.
abstract  boolean setCVSCommand(char opt, java.lang.String optArg)
          Takes the arguments and sets the command.
 void setDisplayName(java.lang.String name)
          Defines prefered display name or null.
protected  void setLocalDirectory(java.lang.String localDirectory)
          Sets the local directory for the command.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localDirectory

protected java.lang.String localDirectory
The local directory from which the command is being run. This gives us the ability to construct a full pathname for the file which we are processing. The information from the responses alone is not enough.

Constructor Detail

Command

public Command()
Method Detail

execute

public void execute(ClientServices client,
                    EventManager eventManager)
             throws CommandException,
                    CommandAbortedException,
                    AuthenticationException
Execute this command.

Parameters:
client - the client services object that provides any necessary services to this command, including the ability to actually process all the requests
e - the event manager. The command can use this to fire events if necessary - for example, while parsing status responses.
Throws:
CommandException
CommandAbortedException
AuthenticationException

getCVSCommand

public abstract java.lang.String getCVSCommand()
This method returns how the command would looklike when typed on the command line. Each command is responsible for constructing this information.


getCVSArguments

public abstract java.lang.String getCVSArguments()
Returns the arguments of the command in the command-line style. Similar to getCVSCommand() however without the files and command's name.


setCVSCommand

public abstract boolean setCVSCommand(char opt,
                                      java.lang.String optArg)
Takes the arguments and sets the command. To be mainly used for automatic settings (like parsing the .cvsrc file).

Returns:
true if the option (switch) was recognized and set

resetCVSCommand

public abstract void resetCVSCommand()
Resets all switches in the command to the default behaviour. After calling this method, the command should behave defaultly.


getOptString

public abstract java.lang.String getOptString()
Returns a String that defines which options are available for this particular command.


clone

public java.lang.Object clone()
This method just calls the Object.clone() and makes it public.

Overrides:
clone in class java.lang.Object

hasFailed

public boolean hasFailed()

messageSent

public void messageSent(MessageEvent e)
Called when the server wants to send a message to be displayed to the user. The message is only for information purposes and clients can choose to ignore these messages if they wish.

Specified by:
messageSent in interface CVSListener
Parameters:
e - the event

messageSent

public void messageSent(BinaryMessageEvent e)
Description copied from interface: CVSListener
Called when the server wants to send a binary message to be displayed to the user. The message is only for information purposes and clients can choose to ignore these messages if they wish.

Specified by:
messageSent in interface CVSListener
Parameters:
e - the event

fileAdded

public void fileAdded(FileAddedEvent e)
Called when a file has been added.

Specified by:
fileAdded in interface CVSListener
Parameters:
e - the event

fileToRemove

public void fileToRemove(FileToRemoveEvent e)
Called when a file is going to be removed.

Specified by:
fileToRemove in interface CVSListener
Parameters:
e - the event

fileRemoved

public void fileRemoved(FileRemovedEvent e)
Called when a file is removed.

Specified by:
fileRemoved in interface CVSListener
Parameters:
e - the event

fileUpdated

public void fileUpdated(FileUpdatedEvent e)
Called when a file has been updated.

Specified by:
fileUpdated in interface CVSListener
Parameters:
e - the event

fileInfoGenerated

public void fileInfoGenerated(FileInfoEvent e)
Called when file status information has been received.

Specified by:
fileInfoGenerated in interface CVSListener

commandTerminated

public void commandTerminated(TerminationEvent e)
Called when server responses with "ok" or "error", (when the command finishes).

Specified by:
commandTerminated in interface CVSListener

moduleExpanded

public void moduleExpanded(ModuleExpansionEvent e)
This is called when the servers has responded to an expand-modules request.

Specified by:
moduleExpanded in interface CVSListener

getLocalDirectory

public final java.lang.String getLocalDirectory()
Returns the local path the command is associated with.


getLocalPath

public final java.lang.String getLocalPath()
Deprecated. Please use the getLocalDirectory() method instead.

Returns the local path the command is associated with.


getGlobalOptions

public final GlobalOptions getGlobalOptions()
Get the global options.


getRelativeToLocalPathInUnixStyle

public final java.lang.String getRelativeToLocalPathInUnixStyle(java.io.File file)
Returns the relative path of the specified file (relative to the set local path). Backward slashes will be replaced by forward slashes.


setLocalDirectory

protected final void setLocalDirectory(java.lang.String localDirectory)
Sets the local directory for the command.


getTrimmedString

protected static final java.lang.String getTrimmedString(java.lang.String s)
Returns the trimmed version of the specified String s. The returned String is null if the specified String is null or contains only white spaces.


setDisplayName

public void setDisplayName(java.lang.String name)
Defines prefered display name or null. Localized string should highlight command purpose (use verb in gerund). E.g. UpdateCommand used to refresh statuses should be named "Refreshing Status" rather than "cvs -N update", "Updating" or "Status Refresh".


getDisplayName

public java.lang.String getDisplayName()
Returns localized name describing command purpose or null.

See Also:
getCVSCommand()

 

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