com.microsoft.tfs.core.externaltools
Class ExternalTool

java.lang.Object
  extended by com.microsoft.tfs.core.externaltools.ExternalTool

public final class ExternalTool
extends java.lang.Object

Describes an external program and its required arguments. On Mac OS X, automatically resolves commands that are application bundles to the correct executable program.

The argument strings given to the constructors should contain some substitution strings, like "%1", "%2", etc. Derived classes declare which substitutions are forbidden and required for their kind of tool. No validation is done during construction. See ExternalToolValidator.

The command and argument strings are always compared case-sensitive (for equals(Object), etc.) even if the current platform doesn't work that way.

See Also:
ExternalToolValidator, WindowsStyleArgumentTokenizer
Since:
TEE-SDK-10.1
Thread-safety:
immutable

Constructor Summary
ExternalTool(java.lang.String commandAndArguments)
          Creates an external tool that runs the given command with the given arguments.
 
Method Summary
 boolean equals(java.lang.Object o)
          
 java.lang.String[] getArguments()
          Gets the arguments as individual strings, unquoted and unescaped from the original arguments given during construction.
 java.lang.String getCommand()
          Gets the command (executable) portion of the external command.
 java.lang.String getOriginalCommand()
          Gets the command (executable) portion of the external command.
 java.lang.String getOriginalCommandAndArguments()
          Gets the original command and arguments string, before they were tokenized and unquoted.
 int hashCode()
          
static ExternalTool loadFromMemento(Memento memento)
          Loads tool state from the given Memento, which can have any name.
 void saveToMemento(Memento memento)
          Saves this tool's state to the given Memento, which should have a name (of the caller's choice) but no other data.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExternalTool

public ExternalTool(java.lang.String commandAndArguments)
             throws ExternalToolException
Creates an external tool that runs the given command with the given arguments. Parses the command and arguments from the given string using Windows style tokenizer (@see WindowsStyleArgumentTokenizer). The command is the first token parsed, and every other token is a new argument.

Parameters:
commandAndArguments - a string containing the command that runs this external tool and all its arguments (with special substitutions ("%1", etc.) embedded) (must not be null or empty)
Throws:
ExternalToolException - if the arguments could not be tokenized (for example, invalid quoting)
Method Detail

getOriginalCommand

public final java.lang.String getOriginalCommand()
Gets the command (executable) portion of the external command. Does not resolve app bundles (eg, on OS X) and is thus suitable for display but not for execution.

Returns:
the user-specified path of the command to execute

getCommand

public final java.lang.String getCommand()
Gets the command (executable) portion of the external command. Mutates the command for OS X. If the command ends in ".app", we assume it to be an app bundle (which is actually a directory on OS X) and append the portion to the executable file.

Returns:
the path to the command to execute

getArguments

public final java.lang.String[] getArguments()
Gets the arguments as individual strings, unquoted and unescaped from the original arguments given during construction.

Returns:
the arguments as individual strings

getOriginalCommandAndArguments

public final java.lang.String getOriginalCommandAndArguments()
Gets the original command and arguments string, before they were tokenized and unquoted.

Returns:
the original command and arguments string, before tokenization.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

saveToMemento

public void saveToMemento(Memento memento)
Saves this tool's state to the given Memento, which should have a name (of the caller's choice) but no other data.

Parameters:
memento - the Memento to save this tool's state to (must not be null)

loadFromMemento

public static ExternalTool loadFromMemento(Memento memento)
Loads tool state from the given Memento, which can have any name.

Parameters:
memento - the Memento to load state from (must not be null)


© 2015 Microsoft. All rights reserved.