com.microsoft.tfs.core.clients.versioncontrol.conflicts.resolutions
Class ConflictResolution

java.lang.Object
  extended by com.microsoft.tfs.core.clients.versioncontrol.conflicts.resolutions.ConflictResolution
Direct Known Subclasses:
AutomergeWritableConflictResolution, CoreConflictResolution, ExternalConflictResolution

public abstract class ConflictResolution
extends java.lang.Object

Base class for conflict resolution. These objects are generally produced by ConflictDescription objects. This is an abstract base class. Example: ConflictResolution[] resolutionOptions = conflictDescription.getResolutions(); ConflictResolutionStatus status = resolutionOptions[0].resolveConflict(); if(status == ConflictResolutionStatus.Success) Console.out.println("Conflict resolved"); ... or use a callback mechanism, as some conflict resolutions may be long-running: resolutionOptions[0].addListener(new ConflictResolutionStatusListener() { public void StatusChanged(ConflictResolution r, ConflictResolutionStatus status) { if(status == ConflictResolutionStatus.Success) Console.out.println("Conflict resolved"); } }); resolutionOptions[0].resolveConflict();

Since:
TEE-SDK-10.1

Field Summary
static java.lang.String DefaultErrorMessage
           
 
Constructor Summary
protected ConflictResolution(ConflictDescription conflictDescription, java.lang.String description, java.lang.String helpText, ConflictResolutionOptions options)
          Base class constructor, should only be called by subclasses.
 
Method Summary
 void addStatusListener(ConflictResolutionStatusListener listener)
          Add a status listener for this conflict resolution.
 void cancel()
          Cancel the conflict resolution.
 ConflictDescription getConflictDescription()
          Gets the ConflictDescription which will be resolved by this resolver.
 Conflict[] getConflicts()
          Queries the conflict resolver for any new conflicts which arised during the resolution of this conflict.
 java.lang.String getDescription()
          Gets the description of this type of resolution (eg "check out and auto merge")
 java.lang.String getErrorMessage()
          Gets all error messages that occured while resolving this conflict.
 java.lang.String getHelpText()
          Gets the help text for this type of resolution (extended information suitable for displaying in a tooltip.)
 ConflictResolutionStatus getStatus()
          Gets the current resolution status
 boolean needsEncodingSelection()
          Determines whether conflict resolution requires an explicit encoding selection.
 boolean needsNewPath()
          Determines whether conflict resolution requires a name selection.
abstract  ConflictResolution newForConflictDescription(ConflictDescription description)
           
 void removeStatusListener(ConflictResolutionStatusListener listener)
          Removes a status listener for this conflict resolution.
 ConflictResolutionStatus resolveConflict()
          Resolve the conflict.
abstract  void setEncoding(FileEncoding encoding)
          Sets the file encoding of the resultant merged file.
protected  void setErrorMessage(java.lang.String message)
          Adds an error message that occurred while resolving.
abstract  void setNewPath(java.lang.String newPath)
          Sets the server name of the resultant merged file.
protected  void setStatus(ConflictResolutionStatus status)
          Subclasses may set the status of the resolution.
protected abstract  ConflictResolutionStatus work()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DefaultErrorMessage

public static final java.lang.String DefaultErrorMessage
Constructor Detail

ConflictResolution

protected ConflictResolution(ConflictDescription conflictDescription,
                             java.lang.String description,
                             java.lang.String helpText,
                             ConflictResolutionOptions options)
Base class constructor, should only be called by subclasses. Provides a ConflictDescription and a description of this resolution type.

Parameters:
conflictDescription - the ConflictDescription which contains the conflict which this class will resolve.
description - a description of this resolution
helpText - informative help text for this resolution. may be null
Method Detail

resolveConflict

public final ConflictResolutionStatus resolveConflict()
Resolve the conflict.

Returns:
A ConflictResolutionStatus containing the status of the resolution (Failed, Success, Running, etc)

work

protected abstract ConflictResolutionStatus work()
                                          throws java.lang.Exception
Throws:
java.lang.Exception

newForConflictDescription

public abstract ConflictResolution newForConflictDescription(ConflictDescription description)

cancel

public void cancel()
Cancel the conflict resolution. Only makes sense for asynchronous resolutions (ie, ExternalConflictResolution)


setStatus

protected final void setStatus(ConflictResolutionStatus status)
Subclasses may set the status of the resolution.

Parameters:
status - ConflictResolutionStatus describing current resolution state

getConflicts

public Conflict[] getConflicts()
Queries the conflict resolver for any new conflicts which arised during the resolution of this conflict. (Typically only used by automerge writable conflicts.)

Returns:
A list of new conflicts or null

getConflictDescription

public ConflictDescription getConflictDescription()
Gets the ConflictDescription which will be resolved by this resolver.

Returns:
A ConflictDescription to resolve

getDescription

public java.lang.String getDescription()
Gets the description of this type of resolution (eg "check out and auto merge")

Returns:
a String containing a textual representation of what will be done to resolve this conflict

getHelpText

public java.lang.String getHelpText()
Gets the help text for this type of resolution (extended information suitable for displaying in a tooltip.)

Returns:
a String containing a very detailed message to assist the user. May be null

needsNewPath

public boolean needsNewPath()
Determines whether conflict resolution requires a name selection. This will be true for automerges and external merges involving some renames.

Returns:
true if the user must choose a name, false otherwise

setNewPath

public abstract void setNewPath(java.lang.String newPath)
Sets the server name of the resultant merged file. This should be called only if needsNewPath() returns true.

Parameters:
newPath - The new (server) file path

needsEncodingSelection

public boolean needsEncodingSelection()
Determines whether conflict resolution requires an explicit encoding selection. This will be true when their file encoding != your file encoding.

Returns:
true if the user must choose an encoding, false otherwise.

setEncoding

public abstract void setEncoding(FileEncoding encoding)
Sets the file encoding of the resultant merged file. This should be called only if needsEncodingSelection() returns true.

Parameters:
encoding - The new FileEncoding

getStatus

public final ConflictResolutionStatus getStatus()
Gets the current resolution status

Returns:
a ConflictResolutionStatus describing the resolution state

setErrorMessage

protected void setErrorMessage(java.lang.String message)
Adds an error message that occurred while resolving.

Parameters:
message - A String representing a resolution error

getErrorMessage

public java.lang.String getErrorMessage()
Gets all error messages that occured while resolving this conflict.

Returns:
A String array containing all error messages.

addStatusListener

public void addStatusListener(ConflictResolutionStatusListener listener)
Add a status listener for this conflict resolution. This listener will be notified every time the conflict goes through a status change (eg, NotStarted, Running, Success, Failure, etc...)

Parameters:
listener - A ConflictResolutionStatusListener which will be notified of status changes

removeStatusListener

public void removeStatusListener(ConflictResolutionStatusListener listener)
Removes a status listener for this conflict resolution.

Parameters:
listener - A ConflictResolutionStatusListener which should no longer be notified of status changes


© 2015 Microsoft. All rights reserved.