com.microsoft.tfs.core.clients.versioncontrol.path
Class ItemPath

java.lang.Object
  extended by com.microsoft.tfs.core.clients.versioncontrol.path.ItemPath

public abstract class ItemPath
extends java.lang.Object

Contains static utility methods that apply to both LocalPath and ServerPath strings.

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

Constructor Summary
ItemPath()
           
 
Method Summary
static java.lang.String canonicalize(java.lang.String localOrServerPath)
          Canonicalizes a local or server path.
static void checkForIllegalDollarInPath(java.lang.String serverOrLocalPath)
          This method throws an InputValidationException if there is a dollar sign ('$') that follows a path separator since no part of a path is allowed to start with a dollar sign.
static ItemValidationError checkItem(java.util.concurrent.atomic.AtomicReference<java.lang.String> item, java.lang.String parameterName, boolean allowNull, boolean allowWildcards, boolean allow8Dot3Paths, boolean checkReservedCharacters)
          Validates the item as a server or local path.
static ItemValidationError checkItem(java.util.concurrent.atomic.AtomicReference<java.lang.String> item, java.lang.String parameterName, boolean allowNull, boolean allowWildcards, boolean allow8Dot3Paths, boolean checkReservedCharacters, int maxServerPathLength)
          Validates the item as a server or local path.
static boolean equals(java.lang.String serverOrLocalPath1, java.lang.String serverOrLocalPath2)
           
static int hashcode(java.lang.String serverOrLocalPath)
           
static boolean isWildcard(java.lang.String localOrServerPath)
          Tests whether the given local or server path contains wildcard characters in its final path element.
static boolean isWildcard(java.lang.String localOrServerPath, int index, int count)
           
static boolean matchesWildcardFile(java.lang.String fileName, int fileIndex, java.lang.String wildcardPattern, int wildcardIndex)
          Tests a file name (not full path) against a wildcard pattern for a match.
static boolean matchesWildcardFile(java.lang.String fileName, java.lang.String wildcardPattern)
          Compare a string against a wildcard and return true if it matches, false if not.
static java.lang.String smartNativeToTFS(java.lang.String localOrServerPath)
          Accepts a local path or server path for conversion to TFS path conventions.
static java.lang.String smartTFSToNative(java.lang.String localOrServerPath)
          Accepts a local path or server path for conversion from TFS path conventions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ItemPath

public ItemPath()
Method Detail

canonicalize

public static java.lang.String canonicalize(java.lang.String localOrServerPath)
Canonicalizes a local or server path. A path should be canonicalized before being converted to a TFS path via tfsToNative().

Parameters:
localOrServerPath - the local or server path to canonicalize.
Returns:
the canonical version of the input string, null if the input string was null or an empty string if the niput string was empty.

checkItem

public static ItemValidationError checkItem(java.util.concurrent.atomic.AtomicReference<java.lang.String> item,
                                            java.lang.String parameterName,
                                            boolean allowNull,
                                            boolean allowWildcards,
                                            boolean allow8Dot3Paths,
                                            boolean checkReservedCharacters)
Validates the item as a server or local path.


checkItem

public static ItemValidationError checkItem(java.util.concurrent.atomic.AtomicReference<java.lang.String> item,
                                            java.lang.String parameterName,
                                            boolean allowNull,
                                            boolean allowWildcards,
                                            boolean allow8Dot3Paths,
                                            boolean checkReservedCharacters,
                                            int maxServerPathLength)
Validates the item as a server or local path.


smartNativeToTFS

public static java.lang.String smartNativeToTFS(java.lang.String localOrServerPath)
Accepts a local path or server path for conversion to TFS path conventions. Since only local paths need converted (server paths are always the same convention), this method detects whether the path passed in is local or server. If the path is local, it is converted. If the path is server, it is returned unaltered.

Parameters:
localOrServerPath - the local or server path to convert to TFS path format.
Returns:
the converted string.

smartTFSToNative

public static java.lang.String smartTFSToNative(java.lang.String localOrServerPath)
Accepts a local path or server path for conversion from TFS path conventions. Since only local paths need converted (server paths are always the same convention), this method detects whether the path passed in is local or server. If the path is local, it is converted. If the path is server, it is returned unaltered.

Parameters:
localOrServerPath - the local or server path to convert from TFS path format to native path format.
Returns:
the converted string.

isWildcard

public static boolean isWildcard(java.lang.String localOrServerPath,
                                 int index,
                                 int count)
Parameters:
localOrServerPath -
index -
count -
Returns:

isWildcard

public static boolean isWildcard(java.lang.String localOrServerPath)
Tests whether the given local or server path contains wildcard characters in its final path element. Wildcards in initial path elements (intermediate directories) are ignored.

Parameters:
localOrServerPath - the local or server path to test for wildcards (in last element only). If null or empty, result is always false.
Returns:
true if the last path element contains wildcards, false otherwise.

matchesWildcardFile

public static boolean matchesWildcardFile(java.lang.String fileName,
                                          java.lang.String wildcardPattern)
Compare a string against a wildcard and return true if it matches, false if not. This does a case insensitive compare with the Ordinal culture.

Parameters:
fileName - String to match against the pattern.
wildcardPattern - Pattern (using * and ? for wildcards) to match against
Returns:
true if the wildcard matches, false if it does not

matchesWildcardFile

public static boolean matchesWildcardFile(java.lang.String fileName,
                                          int fileIndex,
                                          java.lang.String wildcardPattern,
                                          int wildcardIndex)
Tests a file name (not full path) against a wildcard pattern for a match. This is useful for the file part of local and server paths. Character case is ignored during wildcard matching.

Parameters:
fileName - the file name (not a full path) to test against the wildcard pattern (must not be null)
wildcardPattern - the wildcard pattern to use (must not be null)
Returns:
true if the wildcard pattern matches the given file name, false if it does not.

checkForIllegalDollarInPath

public static void checkForIllegalDollarInPath(java.lang.String serverOrLocalPath)
                                        throws InputValidationException
This method throws an InputValidationException if there is a dollar sign ('$') that follows a path separator since no part of a path is allowed to start with a dollar sign.

Parameters:
serverOrLocalPath - the path to check (path must already be canonicalized) (may be null)
Throws:
InputValidationException

equals

public static boolean equals(java.lang.String serverOrLocalPath1,
                             java.lang.String serverOrLocalPath2)

hashcode

public static int hashcode(java.lang.String serverOrLocalPath)


© 2015 Microsoft. All rights reserved.