public class SyncInfo extends Object implements 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.
ADDITION
if it exists locally and there is no remote.
DELETION
if it does not exists locally and there is remote.
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.
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.
Modifier and Type | Field and Description |
---|---|
static int |
ADDITION
Sync constant (value 1) indicating that one side was added.
|
static int |
AUTOMERGE_CONFLICT
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 int |
CHANGE
Sync constant (value 3) indicating that one side was changed.
|
static int |
CHANGE_MASK
Bit mask for extracting the change type.
|
static int |
CONFLICTING
Sync constant (value 12) indicating a change to both the remote and local resources.
|
static int |
DELETION
Sync constant (value 2) indicating that one side was deleted.
|
static int |
DIRECTION_MASK
Bit mask for extracting the synchronization direction.
|
static int |
IN_SYNC
Sync constant (value 0) indicating element is in sync.
|
static int |
INCOMING
Sync constant (value 8) indicating a change to the remote resource.
|
static int |
MANUAL_CONFLICT
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 int |
OUTGOING
Sync constant (value 4) indicating a change to the local resource.
|
static int |
PSEUDO_CONFLICT
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 and Description |
---|
SyncInfo(IResource local,
IResourceVariant base,
IResourceVariant remote,
IResourceVariantComparator comparator)
Construct a sync info object.
|
Modifier and Type | Method and Description |
---|---|
protected int |
calculateKind()
Method that is invoked from the
init() method to calculate
the sync kind for this instance of SyncInfo . |
boolean |
equals(Object other) |
Object |
getAdapter(Class adapter)
Returns an object which is an instance of the given class
associated with this object.
|
IResourceVariant |
getBase()
Returns the remote resource handle for the base resource,
or
null if the base resource does not exist. |
static int |
getChange(int kind)
Helper method to return the change portion
of the given kind.
|
IResourceVariantComparator |
getComparator()
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.
|
IResource |
getLocal()
Returns the state of the local resource.
|
String |
getLocalAuthor(IProgressMonitor monitor)
Returns the author of the revision corresponding to the local resource or
null
if it doesn't have one. |
String |
getLocalContentIdentifier()
Returns the content identifier for the local resource or
null if
it doesn't have one. |
IResourceVariant |
getRemote()
Returns the handle for the remote resource,
or
null if the remote resource does not exist. |
int |
hashCode() |
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.
|
String |
toString() |
public static final int IN_SYNC
public static final int ADDITION
public static final int DELETION
public static final int CHANGE
public static final int CHANGE_MASK
public static final int OUTGOING
public static final int INCOMING
public static final int CONFLICTING
public static final int DIRECTION_MASK
public static final int PSEUDO_CONFLICT
public static final int AUTOMERGE_CONFLICT
public static final int MANUAL_CONFLICT
public SyncInfo(IResource local, IResourceVariant base, IResourceVariant remote, IResourceVariantComparator comparator)
local
- the local resource. Must be non-null but may not exist.base
- the base resource variant or null
remote
- the remote resource variant or null
comparator
- the comparator used to determine if resources differpublic IResource getLocal()
public String getLocalContentIdentifier()
null
if
it doesn't have one. For example, in CVS this would be the revision number.public String getLocalAuthor(IProgressMonitor monitor)
null
if it doesn't have one. For example if the local file is shared in CVS this would be the
revision author.monitor
- the progress monitornull
public IResourceVariant getBase()
null
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. ]
null
public IResourceVariant getRemote()
null
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. ]
null
public IResourceVariantComparator getComparator()
public int getKind()
public static boolean isInSync(int kind)
kind
- the kind of a SyncInfo
IN_SYNC
.public static int getDirection(int kind)
kind
- the kind of a SyncInfo
public static int getChange(int kind)
kind
- the kind of a SyncInfo
public Object getAdapter(Class adapter)
IAdaptable
null
if
no such object can be found.getAdapter
in interface IAdaptable
adapter
- the adapter class to look upnull
if this object does not
have an adapter for the given classpublic static String kindToString(int kind)
kind
- the sync kind obtained from a SyncInfo
public final void init() throws TeamException
SyncInfo
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.TeamException
- if there were problems calculating the sync state.protected int calculateKind() throws TeamException
init()
method to calculate
the sync kind for this instance of SyncInfo
. The result is
assigned to an instance variable and is available using getKind()
.
Subclasses should not invoke this method but may override it in order to customize
the sync kind calculation algorithm.SyncInfo
TeamException
- if there were problems calculating the sync state.
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.