com.microsoft.tfs.core.clients.versioncontrol.specs
Class VersionedFileSpec

java.lang.Object
  extended by com.microsoft.tfs.core.clients.versioncontrol.specs.VersionedFileSpec

public final class VersionedFileSpec
extends java.lang.Object

Describes a version control item (by path) at one or more versions (possibly a range of versions). This class is generally used to parse user-entered text from the command line.

Since:
TEE-SDK-10.1
Thread-safety:
immutable

Constructor Summary
VersionedFileSpec(java.lang.String item, DeletionVersionSpec deletionSpec, VersionSpec[] versions)
          Creates a VersionedFileSpec.
 
Method Summary
static java.lang.String formatForPath(java.lang.String repositoryOrLocalPath, VersionSpec spec)
          Returns a string representation of a VersionSpec that will contain the given repository or local path plus version information that this AVersionSpec contains.
static java.lang.String formatForPath(java.lang.String repositoryOrLocalPath, VersionSpec specFrom, VersionSpec specTo)
          Returns a string representation of a VersionSpec range that will contain the given repository or local path plus version information that these AVersionSpecs contain.
static java.lang.String formatPathWithDeletionIfNecessary(java.lang.String path, int deletionID)
          Takes a path and deletion ID, and if the deletion ID is 0, returns the path with the deletion appended (after a separator).
 DeletionVersionSpec getDeletionVersionSpec()
          Gets the deletion ID specified by this versioned file spec.
 java.lang.String getExactUserString()
          Gets the string the user typed to create this spec.
 java.lang.String getItem()
           
 VersionSpec[] getVersions()
          Gets the versions specified by this versioned file spec.
static VersionedFileSpec parse(java.lang.String spec, java.lang.String user, boolean allowVersionRange)
          Parses the given information into this AVersionedFileSpec object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersionedFileSpec

public VersionedFileSpec(java.lang.String item,
                         DeletionVersionSpec deletionSpec,
                         VersionSpec[] versions)
Creates a VersionedFileSpec.

Parameters:
item - the item (must not be null or empty)
deletionSpec - the deletion spec (may be null)
versions - the versions (must not be null)
Method Detail

parse

public static VersionedFileSpec parse(java.lang.String spec,
                                      java.lang.String user,
                                      boolean allowVersionRange)
                               throws VersionSpecParseException,
                                      LabelSpecParseException
Parses the given information into this AVersionedFileSpec object. If a deletion specifier is encountered, zero or one other version specifier is allowed (an exception will be thrown if more than one is found).

Parameters:
spec - the versioned file spec string (like "filename.ext;C1" or "filename.ext;X4;C1") (must not be null or empty)
user - the current user (must not be null or empty).
allowVersionRange - whether to allow ranges in the version specifications.
Throws:
VersionSpecParseException - if an error occured parsing the version spec string.
LabelSpecParseException - if an error occured parsing the label spec string.

getItem

public java.lang.String getItem()

getVersions

public VersionSpec[] getVersions()
Gets the versions specified by this versioned file spec.

Returns:
the versions specified by this versioned file spec.

getDeletionVersionSpec

public DeletionVersionSpec getDeletionVersionSpec()
Gets the deletion ID specified by this versioned file spec. The default deletion ID is 0 (which will be ignored by the server).

Returns:
the deletion ID specified by this versioned file spec.

formatForPath

public static final java.lang.String formatForPath(java.lang.String repositoryOrLocalPath,
                                                   VersionSpec spec)
Returns a string representation of a VersionSpec that will contain the given repository or local path plus version information that this AVersionSpec contains.

Parameters:
repositoryOrLocalPath - a repository path or local path to include in the returned string.
spec - an AVersionSpec.
Returns:
a string for the given path plus version information from the given spec instance.

formatForPath

public static final java.lang.String formatForPath(java.lang.String repositoryOrLocalPath,
                                                   VersionSpec specFrom,
                                                   VersionSpec specTo)
Returns a string representation of a VersionSpec range that will contain the given repository or local path plus version information that these AVersionSpecs contain.

Parameters:
repositoryOrLocalPath - a repository path or local path to include in the returned string.
specFrom - the first AVersionSpec.
specTo - the second AVersionSpec.
Returns:
a string for the given path plus version information from the version spec instances.

getExactUserString

public java.lang.String getExactUserString()
Gets the string the user typed to create this spec. null if this spec was not created by user input.

Returns:
the string the user typed to create this spec, null if this spec was not created by user input.

formatPathWithDeletionIfNecessary

public static java.lang.String formatPathWithDeletionIfNecessary(java.lang.String path,
                                                                 int deletionID)
Takes a path and deletion ID, and if the deletion ID is 0, returns the path with the deletion appended (after a separator).

Parameters:
path - the path to format (must not be null)
deletionID - the deletion ID to append to the path after a separator, if the deletion ID is not 0
Returns:
the original path with the deletion ID appended if the ID was not 0


© 2015 Microsoft. All rights reserved.