com.mucommander.command
Class Command

java.lang.Object
  extended by com.mucommander.command.Command

public class Command
extends java.lang.Object

Compiled shell commands.

A command is composed of three elements:

The basic command syntax is fairly simple:

It is important to remember that " characters are not removed from the resulting tokens.

It's also possible to include keywords in a command:

Once a Command instance has been retrieved, execution tokens can be retrieved through the getTokens(AbstractFile) method. This will return a tokenized version of the command and replace any keyword by the corresponding file value . It's also possible to skip keyword replacement through the getTokens() method.

A command's executable tokens are typically meant to be used with ProcessRunner.execute(String[],AbstractFile) in order to generate instances of AbstractProcess.

Author:
Nicolas Rinaudo
See Also:
CommandManager, ProcessRunner, AbstractProcess

Field Summary
static int INVISIBLE_COMMAND
          Describres invisible commands.
static int NORMAL_COMMAND
          Describes normal commands.
static int SYSTEM_COMMAND
          Describes system commands.
 
Constructor Summary
Command(java.lang.String alias, java.lang.String command)
          Creates a new command.
Command(java.lang.String alias, java.lang.String command, int type)
          Creates a new command.
Command(java.lang.String alias, java.lang.String command, int type, java.lang.String displayName)
          Creates a new command.
 
Method Summary
 boolean equals(java.lang.Object object)
           
 java.lang.String getAlias()
          Returns this command's alias.
 java.lang.String getCommand()
          Returns the original, un-tokenised command.
 java.lang.String getDisplayName()
          Returns the command's display name.
 java.lang.String[] getTokens()
          Returns this command's tokens without performing keyword substitution.
 java.lang.String[] getTokens(AbstractFile file)
          Returns this command's tokens, replacing keywords by the corresponding values from the specified file.
 java.lang.String[] getTokens(AbstractFile[] files)
          Returns this command's tokens, replacing keywords by the corresponding values from the specified files.
 java.lang.String[] getTokens(FileSet files)
          Returns this command's tokens, replacing keywords by the corresponding values from the specified fileset.
static java.lang.String[] getTokens(java.lang.String command)
          Returns the specified command's tokens without performing keyword substitution.
static java.lang.String[] getTokens(java.lang.String command, AbstractFile file)
          Returns the specified command's tokens after replacing keywords by the corresponding values from the specified file.
static java.lang.String[] getTokens(java.lang.String command, AbstractFile[] files)
          Returns the specified command's tokens after replacing keywords by the corresponding values from the specified files.
static java.lang.String[] getTokens(java.lang.String command, FileSet files)
          Returns the specified command's tokens after replacing keywords by the corresponding values from the specified fileset.
 int getType()
          Returns the command's type.
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NORMAL_COMMAND

public static final int NORMAL_COMMAND
Describes normal commands.

See Also:
Constant Field Values

SYSTEM_COMMAND

public static final int SYSTEM_COMMAND
Describes system commands.

See Also:
Constant Field Values

INVISIBLE_COMMAND

public static final int INVISIBLE_COMMAND
Describres invisible commands.

See Also:
Constant Field Values
Constructor Detail

Command

public Command(java.lang.String alias,
               java.lang.String command,
               int type,
               java.lang.String displayName)
Creates a new command.

Parameters:
alias - alias of the command.
command - command that will be executed.
type - type of the command.
displayName - name of the command as seen by users (if null, defaults to alias).

Command

public Command(java.lang.String alias,
               java.lang.String command)
Creates a new command.

This is a convenience constructor and is strictly equivalent to calling Command(alias, command, NORMAL_COMMAND, null).

Parameters:
alias - alias of the command.
command - command that will be executed.

Command

public Command(java.lang.String alias,
               java.lang.String command,
               int type)
Creates a new command.

This is a convenience constructor and is strictly equivalent to calling Command(alias, command, type, null).

Parameters:
alias - alias of the command.
command - command that will be executed.
type - type of the command.
Method Detail

getTokens

public java.lang.String[] getTokens()
Returns this command's tokens without performing keyword substitution.

Returns:
this command's tokens without performing keyword substitution.

getTokens

public java.lang.String[] getTokens(AbstractFile file)
Returns this command's tokens, replacing keywords by the corresponding values from the specified file.

Parameters:
file - file from which to retrieve keyword substitution values.
Returns:
this command's tokens, replacing keywords by the corresponding values from the specified file.

getTokens

public java.lang.String[] getTokens(FileSet files)
Returns this command's tokens, replacing keywords by the corresponding values from the specified fileset.

Parameters:
files - files from which to retrieve keyword substitution values.
Returns:
this command's tokens, replacing keywords by the corresponding values from the specified fileset.

getTokens

public java.lang.String[] getTokens(AbstractFile[] files)
Returns this command's tokens, replacing keywords by the corresponding values from the specified files.

Parameters:
files - files from which to retrieve keyword substitution values.
Returns:
this command's tokens, replacing keywords by the corresponding values from the specified files.

getTokens

public static java.lang.String[] getTokens(java.lang.String command)
Returns the specified command's tokens without performing keyword substitution.

Parameters:
command - command to tokenize.
Returns:
the specified command's tokens without performing keyword substitution.

getTokens

public static java.lang.String[] getTokens(java.lang.String command,
                                           AbstractFile file)
Returns the specified command's tokens after replacing keywords by the corresponding values from the specified file.

Parameters:
command - command to tokenize.
file - file from which to retrieve keyword substitution values.
Returns:
the specified command's tokens after replacing keywords by the corresponding values from the specified file.

getTokens

public static java.lang.String[] getTokens(java.lang.String command,
                                           FileSet files)
Returns the specified command's tokens after replacing keywords by the corresponding values from the specified fileset.

Parameters:
command - command to tokenize.
files - file from which to retrieve keyword substitution values.
Returns:
the specified command's tokens after replacing keywords by the corresponding values from the specified fileset.

getTokens

public static java.lang.String[] getTokens(java.lang.String command,
                                           AbstractFile[] files)
Returns the specified command's tokens after replacing keywords by the corresponding values from the specified files.

Parameters:
command - command to tokenize.
files - file from which to retrieve keyword substitution values.
Returns:
the specified command's tokens after replacing keywords by the corresponding values from the specified files.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

getCommand

public java.lang.String getCommand()
Returns the original, un-tokenised command.

Returns:
the original, un-tokenised command.

getAlias

public java.lang.String getAlias()
Returns this command's alias.

Returns:
this command's alias.

getType

public int getType()
Returns the command's type.

Returns:
the command's type.

getDisplayName

public java.lang.String getDisplayName()
Returns the command's display name.

If it hasn't been set, returns this command's alias.

Returns:
the command's display name.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard