|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.microsoft.tfs.core.clients.versioncontrol.path.ServerPath
public abstract class ServerPath
TFS version control repository path utility functions.
Field Summary | |
---|---|
static java.util.Comparator<java.lang.String> |
BOTTOM_UP_COMPARATOR
Compares well-formed server path strings in a bottom-up fashion (children sort before their parents). |
static int |
MAXIMUM_COMPONENT_LENGTH
Longest allowable TFS directory component part |
static char |
PREFERRED_SEPARATOR_CHARACTER
The preferred separator character. |
static java.lang.String |
ROOT
All server paths begin with this string. |
static java.lang.String |
ROOT_NAME_ONLY
Occasionally code must format a path using the root without the slash. |
static char[] |
SEPARATOR_CHARACTERS
Allowed path separator characters in repository paths. |
static java.util.Comparator<java.lang.String> |
TOP_DOWN_COMPARATOR
Compares well-formed server path strings in a top-down fashion (parents sort before their children). |
Constructor Summary | |
---|---|
ServerPath()
|
Method Summary | |
---|---|
static java.lang.String |
canonicalize(java.lang.String serverPath)
Returns a new version of the given repository path that is fully rooted and canonicalized. |
static void |
checkForIllegalDollarInPath(java.lang.String path)
This method throws an InvalidPathException 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 |
checkServerItem(java.util.concurrent.atomic.AtomicReference<java.lang.String> item,
java.lang.String parameterName,
boolean allowNull,
boolean allowWildcards,
boolean allow8Dot3Paths,
boolean checkReservedCharacters)
|
static ItemValidationError |
checkServerItem(java.util.concurrent.atomic.AtomicReference<java.lang.String> item,
java.lang.String parameterName,
boolean allowNull,
boolean allowWildcards,
boolean allow8Dot3Paths,
boolean checkReservedCharacters,
int maxServerPathLength)
|
static java.lang.String |
combine(java.lang.String parent,
java.lang.String relative)
Combines the two given paths into one path string, using Team Foundation Server's preferred path separator character. |
static int |
compareBottomUp(java.lang.String pathA,
java.lang.String pathB)
Compares two server paths (ordinal character comparison) placing parents after their children. |
static int |
compareTopDown(java.lang.String pathA,
java.lang.String pathB)
Compares two server paths (ordinal character comparison) placing children after their parents. |
static boolean |
equals(java.lang.String path1,
java.lang.String path2)
Compares two repository paths. |
static boolean |
equals(java.lang.String path1,
java.lang.String path2,
boolean ignoreCase)
Compares two repository paths, optionally ignoring case. |
static java.lang.String |
getCommonParent(java.lang.String path1,
java.lang.String path2)
Given two canonical server paths, return the farthest item from $/ that parents both items. |
static java.lang.String |
getFileName(java.lang.String serverPath)
Gets just the file part of the given server path, which is all of the string after the last path component. |
static java.lang.String |
getFirstNode(java.lang.StringBuilder path)
Takes a repository path as a StringBuilder and parses out the top
node in the path and returns it as the parent. |
static int |
getFolderDepth(java.lang.String serverPath)
Returns the depth of the item described by path, where the root folder is depth 0, team projects are at depth 1, and so on. |
static int |
getFolderDepth(java.lang.String serverPath,
int maxDepth)
Returns the depth of the item described by path, where the root folder is depth 0, team projects are at depth 1, "$/Proj/a" is 2, and so on. |
static java.lang.String[] |
getHierarchy(java.lang.String serverPath)
Returns the hierarchy leading up to this path. |
static java.lang.String |
getParent(java.lang.String serverPath)
Gets just the folder part of the given server path, which is all of the string up to the last component (the file part). |
static java.lang.String |
getTeamProject(java.lang.String serverPath)
For a passed server path, calculate the project path. |
static java.lang.String |
getTeamProjectName(java.lang.String serverPath)
Returns the name of the team project that the item resides in. |
static java.lang.String[] |
getTeamProjects(java.lang.String[] serverPaths)
Perform getTeamProject for an array of serverPaths and return an array of unique team projects that those serverPaths are in. |
static int |
hashCode(java.lang.String path)
Computes a hashCode from the specified server path. |
static boolean |
isCanonicalizedPath(java.lang.String serverItem,
boolean allowSemicolon)
Returns true if the path is canonicalized. |
static boolean |
isChild(java.lang.String parentPath,
java.lang.String possibleChild)
Tests the given paths for a parent-child relationship. |
static boolean |
isDirectChild(java.lang.String serverFolderPath,
java.lang.String serverPossibleChild)
Tests whether one path is a direct child of another path (which would be the parent). |
static boolean |
isRootFolder(java.lang.String path)
|
static boolean |
isSeparator(char c)
Tests whether the given character is a valid repository path separator character (as defined by SEPARATOR_CHARACTERS ). |
static boolean |
isServerPath(java.lang.String path)
Tests whether the path supplied is a server path (not local path). |
static boolean |
isTeamProject(java.lang.String serverFolder)
Return whether the passed server item is a team project ($/proja, $/projb, not $/proja/b nor $/). |
static boolean |
isValidPathCharacter(char c)
Tests whether the given character is valid in a repository path component (file/folder name). |
static boolean |
isWildcard(java.lang.String serverPath)
Tests whether the given server path contains wildcard characters in its final path element. |
static java.lang.String |
makeLocal(java.lang.String serverPath,
java.lang.String relativeToServerPath,
java.lang.String localRoot)
Maps a server path to a local path, given a parent server path of the path to be mapped, and a local path that corresponds to the parent. |
static java.lang.String |
makeRelative(java.lang.String serverPath,
java.lang.String relativeTo)
Returns a new string describing the first given path made relative to the second given path. |
static boolean |
matchesWildcard(java.lang.String firstItemPath,
java.lang.String secondItemFolderPath,
java.lang.String secondItemWildcardPattern,
boolean recursive)
Matches one item against a wildcard tuple (item path and wildcard pattern to apply to that item path), optionally allowing recursive matches. |
static java.lang.String[] |
split(java.lang.String serverPath)
Splits the given server path into its components. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ROOT_NAME_ONLY
"$"
public static final java.lang.String ROOT
"$/"
public static final char[] SEPARATOR_CHARACTERS
public static final char PREFERRED_SEPARATOR_CHARACTER
47
public static final int MAXIMUM_COMPONENT_LENGTH
256
public static final java.util.Comparator<java.lang.String> TOP_DOWN_COMPARATOR
public static final java.util.Comparator<java.lang.String> BOTTOM_UP_COMPARATOR
Constructor Detail |
---|
public ServerPath()
Method Detail |
---|
public static final boolean equals(java.lang.String path1, java.lang.String path2)
path1
- the first repository path (must not be null
)path2
- the second repository path (must not be null
)
public static final int hashCode(java.lang.String path)
path
- the server path to compute a hash code for.
public static final boolean equals(java.lang.String path1, java.lang.String path2, boolean ignoreCase)
path1
- the first repository path (must not be null
)path2
- the second repository path (must not be null
)ignoreCase
- true if we should ignore case
public static ItemValidationError checkServerItem(java.util.concurrent.atomic.AtomicReference<java.lang.String> item, java.lang.String parameterName, boolean allowNull, boolean allowWildcards, boolean allow8Dot3Paths, boolean checkReservedCharacters)
public static ItemValidationError checkServerItem(java.util.concurrent.atomic.AtomicReference<java.lang.String> item, java.lang.String parameterName, boolean allowNull, boolean allowWildcards, boolean allow8Dot3Paths, boolean checkReservedCharacters, int maxServerPathLength)
item
- parameterName
- allowNull
- allowWildcards
- allow8Dot3Paths
- checkReservedCharacters
-
public static final boolean isRootFolder(java.lang.String path)
path
- the path to test (may be null
)
ROOT
,
false
if it is notpublic static final boolean isChild(java.lang.String parentPath, java.lang.String possibleChild) throws ServerPathFormatException
Tests the given paths for a parent-child relationship. A path is a child of another if the object it describes would reside below the object described by the parent path in the TFS repository. Case is ignored.
A possible child that is equivalent to the parent path (both refer to the same object) is considered a child. This is compatible with Visual Studio's implementation.
parentPath
- the server path to the parent item (must not be null
)possibleChild
- the server path of the possible child item (must not be
null
)
ServerPathFormatException
public static final boolean matchesWildcard(java.lang.String firstItemPath, java.lang.String secondItemFolderPath, java.lang.String secondItemWildcardPattern, boolean recursive) throws ServerPathFormatException
Matches one item against a wildcard tuple (item path and wildcard pattern to apply to that item path), optionally allowing recursive matches.
Character case is ignored during wildcard matching.
firstItemPath
- the item to test against the wildcard pattern. This is a full path
(must not be null
)secondItemFolderPath
- a path where the wildcard pattern will be applied to find the item
described by firstItemPath. If this parameter is a child of
firstItemPath, there wildcard pattern will never match. If this
parameter is a direct parent of firstItemPath, the wildcard can
match. If this parameter is a grandparent (or greater), the
pattern can only match if the recursive parameter is true. Not
null.secondItemWildcardPattern
- the wildcard pattern to apply to secondItemFolderPath. If null,
wildcards are not evaluated and the first item path is tested
whether it equals or is a child of the second item folder path
(depending on the recursive value).recursive
- if true, the wildcard pattern will apply to secondItemFolderPath
and all its possible children. If false, the wildcard pattern will
only match direct children of secondItemFolderPath.
ServerPathFormatException
- if one of the supplied paths is not a valid server path.public static final java.lang.String canonicalize(java.lang.String serverPath) throws ServerPathFormatException
serverPath
- the repository path string to clean up.
ServerPathFormatException
- when the path cannot be cleaned up.public static boolean isCanonicalizedPath(java.lang.String serverItem, boolean allowSemicolon)
public static java.lang.String makeRelative(java.lang.String serverPath, java.lang.String relativeTo)
Returns a new string describing the first given path made relative to the second given path.
Character case is ignored during string comparison, so strings with mismatched-in-case common elements will still succeed in being made relative.
Paths are not normalized (for ending separators, case, etc.). It is the caller's responsibility to make sure the relativeTo path can be matched.
serverPath
- the path to the server item to describe (must not be
null
)relativeTo
- the path that the first parameter will be described relative to
(must not be null
)
public static java.lang.String makeLocal(java.lang.String serverPath, java.lang.String relativeToServerPath, java.lang.String localRoot)
Maps a server path to a local path, given a parent server path of the path to be mapped, and a local path that corresponds to the parent.
Character case is ignored during string comparison, so strings with mismatched-in-case common elements will still succeed in being made relative.
Paths are not normalized (for ending separators, case, etc.). It is the caller's responsibility to make sure the relativeToServerPath path can be matched.
serverPath
- the server path to convert to a local path (must not be
null
)relativeToServerPath
- the parent server path (must not be null
and must be
a parent of serverPath
)localRoot
- the local path that corresponds to
relativeToServerPath
(must not be null
)
null
)public static final boolean isValidPathCharacter(char c)
c
- the character to test.
public static final boolean isSeparator(char c)
SEPARATOR_CHARACTERS
).
c
- the character to test.
public static final boolean isServerPath(java.lang.String path)
path
- the path to test (must not be null
)
public static final int compareTopDown(java.lang.String pathA, java.lang.String pathB)
If sorting paths for display to the user, better to use a
Collator
-based comparison instead of this one.
pathA
- the first path to compare (must not be null
)pathB
- the second path to compare (must not be null
)
public static final int compareBottomUp(java.lang.String pathA, java.lang.String pathB)
If sorting paths for display to the user, better to use a
Collator
-based comparison instead of this one.
pathA
- the first path to compare (must not be null
)pathB
- the second path to compare (must not be null
)
public static final java.lang.String getFirstNode(java.lang.StringBuilder path)
StringBuilder
and parses out the top
node in the path and returns it as the parent. The remaining path is then
shortened to only include the rest of the path, minus the top node.
path
- the path to find the top node in (must not be null
)
public static boolean isWildcard(java.lang.String serverPath)
serverPath
- the server path to test for wildcards (in last element only). Not
null.
public static java.lang.String getParent(java.lang.String serverPath)
serverPath
- the server path of which to return the folder part (must not be
null
)
public static java.lang.String getFileName(java.lang.String serverPath)
serverPath
- the server path from which to parse the file part (must not be
null
)
public static boolean isDirectChild(java.lang.String serverFolderPath, java.lang.String serverPossibleChild)
serverFolderPath
- the server path to the parent folder (must not be
null
)serverPossibleChild
- the server path of the possible child item (must not be
null
)
public static java.lang.String getTeamProject(java.lang.String serverPath)
serverPath
- String path of a server item (for example
"$/TeamProject/MyPath/MyItem.java").
public static java.lang.String[] getTeamProjects(java.lang.String[] serverPaths)
getTeamProject(String)
public static java.lang.String getTeamProjectName(java.lang.String serverPath)
serverPath
- String path of a server item (for example
"$/TeamProject/MyPath/MyItem.java").
public static boolean isTeamProject(java.lang.String serverFolder)
serverFolder
- a fully qualified server folder item (must not be
null
)
true
if the item is a team project (is an element
directly under the server root folder), false
otherwisepublic static int getFolderDepth(java.lang.String serverPath)
serverPath
- the server path to test (must not be null
)
public static int getFolderDepth(java.lang.String serverPath, int maxDepth)
serverPath
- the server path to test (must not be null
)maxDepth
- the maximum depth to search.
public static java.lang.String combine(java.lang.String parent, java.lang.String relative)
parent
- the first (left-side) path component (must not be
null
or empty).relative
- the second (right-side) path component (must not be
null
)public static java.lang.String[] split(java.lang.String serverPath)
serverPath
- The server path to split (must not be null
)
public static java.lang.String[] getHierarchy(java.lang.String serverPath)
serverPath
- The server path to obtain the hierarchy for (must not be
null
)
public static java.lang.String getCommonParent(java.lang.String path1, java.lang.String path2)
IllegalArgumentException
is
thrown.
path1
- a server path starting with $/ (must not be null
or
empty)path2
- a server path starting with $/ (must not be null
or
empty)
public static void checkForIllegalDollarInPath(java.lang.String path)
path
- the path to check (path must already be canonicalized)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |