com.microsoft.tfs.core.externaltools
Class ExternalToolset

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

public final class ExternalToolset
extends java.lang.Object

An ordered collection of ExternalToolAssociations, with some handy methods to find the association that's most appropriate for a given file or directory name. Searches are linear from the start of the list; if an ExternalToolset contains multiple ExternalToolAssociations that have overlapping extensions, the first in the set will match when the set is searched for an extension.

Since:
TEE-SDK-10.1
Thread-safety:
thread-safe

Field Summary
static java.lang.String DIRECTORY_EXTENSION
          The extension string to use to make a tool association for directories.
static java.lang.String WILDCARD_EXTENSION
          The extension string to use to make a fall-back tool association, which matches all file extensions as long as a more specific extension does not exist in the set.
 
Constructor Summary
ExternalToolset()
          Creates an empty ExternalToolset.
 
Method Summary
 void addAssociation(ExternalToolAssociation association)
           
 void clear()
           
 ExternalTool findTool(java.io.File file)
          Finds the appropriate ExternalToolAssociation in this ExternalToolset to handle the given File, which can be a directory or a file.
 ExternalTool findTool(java.lang.String path)
          Finds the appropriate ExternalTool in this ExternalToolset to handle the given path, which can be a file or a directory.
 ExternalTool findToolForDirectory()
          Finds the right ExternalTool for any directory.
 ExternalTool findToolForExtension(java.lang.String extension)
          Finds the right ExternalTool using only the file extension.
 ExternalToolAssociation get(int index)
           
 ExternalToolAssociation getDirectoryAssociation()
           
 ExternalToolAssociation[] getFileAssociations()
           
 boolean isEmpty()
           
static ExternalToolset loadFromMemento(Memento memento)
          Loads toolset state from the given Memento, which can have any name.
 boolean remove(ExternalToolAssociation association)
           
 ExternalToolAssociation remove(int index)
           
 void saveToMemento(Memento memento)
          Saves this toolset's state to the given Memento, which should have a name (of the caller's choice) but no other data.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECTORY_EXTENSION

public static final java.lang.String DIRECTORY_EXTENSION
The extension string to use to make a tool association for directories.

Constant Field Value:
"/"
See Also:
Constant Field Values

WILDCARD_EXTENSION

public static final java.lang.String WILDCARD_EXTENSION
The extension string to use to make a fall-back tool association, which matches all file extensions as long as a more specific extension does not exist in the set.

Constant Field Value:
"*"
See Also:
Constant Field Values
Constructor Detail

ExternalToolset

public ExternalToolset()
Creates an empty ExternalToolset.

Method Detail

findTool

public ExternalTool findTool(java.io.File file)
Finds the appropriate ExternalToolAssociation in this ExternalToolset to handle the given File, which can be a directory or a file.

Parameters:
file - the File (file or directory) to get the tool for (must not be null)
Returns:
the appropriate ExternalToolAssociation or null if none was appropriate

findTool

public ExternalTool findTool(java.lang.String path)
Finds the appropriate ExternalTool in this ExternalToolset to handle the given path, which can be a file or a directory. It can be relative or absolute.

Parameters:
path - the name of the file or directory (relative or absolute) to get the tool for (must not be null)
Returns:
the appropriate ExternalTool or null if none was appropriate

findToolForDirectory

public ExternalTool findToolForDirectory()
Finds the right ExternalTool for any directory.

Returns:
the appropriate ExternalTool, or null if no directory tool is configured

findToolForExtension

public ExternalTool findToolForExtension(java.lang.String extension)
Finds the right ExternalTool using only the file extension. Do not call this with the special DIRECTORY_EXTENSION.

Parameters:
extension - the file extension (not the full path, not DIRECTORY_EXTENSION) (must not be null)
Returns:
the appropriate ExternalTool or null if no appropriate tool is found (no extension match and no wildcard configured)

addAssociation

public void addAssociation(ExternalToolAssociation association)

clear

public final void clear()

get

public ExternalToolAssociation get(int index)

isEmpty

public final boolean isEmpty()

remove

public ExternalToolAssociation remove(int index)

remove

public boolean remove(ExternalToolAssociation association)

size

public final int size()

getFileAssociations

public ExternalToolAssociation[] getFileAssociations()
Returns:
the ExternalToolAssociations for files

getDirectoryAssociation

public ExternalToolAssociation getDirectoryAssociation()
Returns:
the ExternalToolAssociation for directories, if there is one, otherwise null

saveToMemento

public void saveToMemento(Memento memento)
Saves this toolset'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 toolset's state to (must not be null)

loadFromMemento

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

Parameters:
memento - the Memento to load state from. If null, an empty ExternalToolset is returned.


© 2015 Microsoft. All rights reserved.