Class SyncInfo
- All Implemented Interfaces:
IAdaptable
IResourceVariantComparator
is used to decide which
comparison type to use.
For two-way comparisons, a SyncInfo
node has a change type. This
will be one of IN-SYNC
, ADDITION
,
DELETION
or CHANGE
determined in the following
manner.
- A resource is considered an
ADDITION
if it exists locally and there is no remote. - A resource is considered an
DELETION
if it does not exists locally and there is remote. - A resource is considered a
CHANGE
if both the local and remote exist but the comparator indicates that they differ. The comparator may be comparing contents or timestamps or some other resource state. - A resource is considered
IN_SYNC
in all other cases.
For three-way comparisons, the sync info node has a direction as well as a
change type. The direction is one of INCOMING
,
OUTGOING
or CONFLICTING
. The comparison of the
local and remote resources with a base resource is used to determine
the direction of the change.
- Differences between the base and local resources are classified as outgoing changes; if there is a difference, the local resource is considered the outgoing resource.
- Differences between the base and remote resources are classified as incoming changes; if there is a difference, the remote resource is considered the incoming resource.
- If there are both incoming and outgoing changes, the resource is considered a conflicting change.
- Since:
- 3.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Sync constant (value 1) indicating that one side was added.static final int
Sync constant (value 32) indicating that both the local and remote resources have changed relative to the base but their content changes do not conflict (e.g. source file changes on different lines).static final int
Sync constant (value 3) indicating that one side was changed.static final int
Bit mask for extracting the change type.static final int
Sync constant (value 12) indicating a change to both the remote and local resources.static final int
Sync constant (value 2) indicating that one side was deleted.static final int
Bit mask for extracting the synchronization direction.static final int
Sync constant (value 0) indicating element is in sync.static final int
Sync constant (value 8) indicating a change to the remote resource.static final int
Sync constant (value 64) indicating that both the local and remote resources have changed relative to the base and their content changes conflict (e.g. local and remote resource have changes on same lines).static final int
Sync constant (value 4) indicating a change to the local resource.static final int
Sync constant (value 16) indication that both the local and remote resources have changed relative to the base but their contents are the same. -
Constructor Summary
ConstructorDescriptionSyncInfo
(IResource local, IResourceVariant base, IResourceVariant remote, IResourceVariantComparator comparator) Construct a sync info object. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
Method that is invoked from theinit()
method to calculate the sync kind for this instance ofSyncInfo
.boolean
<T> T
getAdapter
(Class<T> adapter) Returns an object which is an instance of the given class associated with this object.getBase()
Returns the remote resource handle for the base resource, ornull
if the base resource does not exist.static int
getChange
(int kind) Helper method to return the change portion of the given kind.Returns the comparator that is used to determine the kind of this sync node.static int
getDirection
(int kind) Helper method to return the direction portion of the given kind.int
getKind()
Returns the kind of synchronization for this node.getLocal()
Returns the state of the local resource.getLocalAuthor
(IProgressMonitor monitor) Returns the author of the revision corresponding to the local resource ornull
if it doesn't have one.Returns the content identifier for the local resource ornull
if it doesn't have one.Returns the handle for the remote resource, ornull
if the remote resource does not exist.int
hashCode()
final void
init()
Method that is invoked after instance creation to initialize the sync kind.static boolean
isInSync
(int kind) Helper method that returns whether the given kind represents an in-sync resource.static String
kindToString
(int kind) A helper method that returns a displayable (i.e. externalized) string describing the provided sync kind.toString()
-
Field Details
-
IN_SYNC
public static final int IN_SYNCSync constant (value 0) indicating element is in sync.- See Also:
-
ADDITION
public static final int ADDITIONSync constant (value 1) indicating that one side was added.- See Also:
-
DELETION
public static final int DELETIONSync constant (value 2) indicating that one side was deleted.- See Also:
-
CHANGE
public static final int CHANGESync constant (value 3) indicating that one side was changed.- See Also:
-
CHANGE_MASK
public static final int CHANGE_MASKBit mask for extracting the change type.- See Also:
-
OUTGOING
public static final int OUTGOINGSync constant (value 4) indicating a change to the local resource.- See Also:
-
INCOMING
public static final int INCOMINGSync constant (value 8) indicating a change to the remote resource.- See Also:
-
CONFLICTING
public static final int CONFLICTINGSync constant (value 12) indicating a change to both the remote and local resources.- See Also:
-
DIRECTION_MASK
public static final int DIRECTION_MASKBit mask for extracting the synchronization direction.- See Also:
-
PSEUDO_CONFLICT
public static final int PSEUDO_CONFLICTSync constant (value 16) indication that both the local and remote resources have changed relative to the base but their contents are the same.- See Also:
-
AUTOMERGE_CONFLICT
public static final int AUTOMERGE_CONFLICTSync constant (value 32) indicating that both the local and remote resources have changed relative to the base but their content changes do not conflict (e.g. source file changes on different lines). These conflicts could be merged automatically.- See Also:
-
MANUAL_CONFLICT
public static final int MANUAL_CONFLICTSync constant (value 64) indicating that both the local and remote resources have changed relative to the base and their content changes conflict (e.g. local and remote resource have changes on same lines). These conflicts can only be correctly resolved by the user.- See Also:
-
-
Constructor Details
-
SyncInfo
public SyncInfo(IResource local, IResourceVariant base, IResourceVariant remote, IResourceVariantComparator comparator) Construct a sync info object.- Parameters:
local
- the local resource. Must be non-null but may not exist.base
- the base resource variant ornull
remote
- the remote resource variant ornull
comparator
- the comparator used to determine if resources differ
-
-
Method Details
-
getLocal
Returns the state of the local resource. Note that the resource may or may not exist.- Returns:
- a resource
-
getLocalContentIdentifier
Returns the content identifier for the local resource ornull
if it doesn't have one. For example, in CVS this would be the revision number.- Returns:
- String that could be displayed to the user to identify this resource.
-
getLocalAuthor
Returns the author of the revision corresponding to the local resource ornull
if it doesn't have one. For example if the local file is shared in CVS this would be the revision author.- Parameters:
monitor
- the progress monitor- Returns:
- the author of the revision associated with the local file or
null
- Since:
- 3.6
-
getBase
Returns the remote resource handle for the base resource, ornull
if the base resource does not exist.[Note: The type of the common resource may be different from the types of the local and remote resources. ]
- Returns:
- a remote base resource handle, or
null
-
getRemote
Returns the handle for the remote resource, ornull
if the remote resource does not exist.[Note: The type of the remote resource may be different from the types of the local and common resources. ]
- Returns:
- a remote resource handle, or
null
-
getComparator
Returns the comparator that is used to determine the kind of this sync node.- Returns:
- the comparator that is used to determine the kind of this sync node.
-
getKind
public int getKind()Returns the kind of synchronization for this node.- Returns:
- the kind of synchronization for this node.
-
isInSync
public static boolean isInSync(int kind) Helper method that returns whether the given kind represents an in-sync resource.- Parameters:
kind
- the kind of aSyncInfo
- Returns:
- whether the kind is
IN_SYNC
.
-
getDirection
public static int getDirection(int kind) Helper method to return the direction portion of the given kind. The resulting value can be compared directly with the direction constants.- Parameters:
kind
- the kind of aSyncInfo
- Returns:
- the direction portion of the kind
-
getChange
public static int getChange(int kind) Helper method to return the change portion of the given kind. The resulting value can be compared directly with the change type constants.- Parameters:
kind
- the kind of aSyncInfo
- Returns:
- the change portion of the kind
-
equals
-
hashCode
public int hashCode() -
getAdapter
Description copied from interface:IAdaptable
Returns an object which is an instance of the given class associated with this object. Returnsnull
if no such object can be found.Clients may implement this method but should generally call
Adapters.adapt(Object, Class, boolean)
rather than invoking it directly.- Specified by:
getAdapter
in interfaceIAdaptable
- Type Parameters:
T
- the class type- Parameters:
adapter
- the adapter class to look up- Returns:
- a object of the given class, or
null
if this object does not have an adapter for the given class
-
toString
-
kindToString
A helper method that returns a displayable (i.e. externalized) string describing the provided sync kind.- Parameters:
kind
- the sync kind obtained from aSyncInfo
- Returns:
- a displayable string that describes the kind
-
init
Method that is invoked after instance creation to initialize the sync kind. This method should only be invoked by the creator of theSyncInfo
instance. It is not done from the constructor in order to allow subclasses to calculate the sync kind from any additional state variables they may have.- Throws:
TeamException
- if there were problems calculating the sync state.
-
calculateKind
Method that is invoked from theinit()
method to calculate the sync kind for this instance ofSyncInfo
. The result is assigned to an instance variable and is available usinggetKind()
. Subclasses should not invoke this method but may override it in order to customize the sync kind calculation algorithm.- Returns:
- the sync kind of this
SyncInfo
- Throws:
TeamException
- if there were problems calculating the sync state.
-