Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java')
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java168
1 files changed, 84 insertions, 84 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java
index a9c4eeb3b..8f43e3432 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/synchronize/SyncInfo.java
@@ -19,20 +19,20 @@ import org.eclipse.team.core.variants.IResourceVariantComparator;
import org.eclipse.team.internal.core.Messages;
/**
- * Describes the synchronization of a <b>local</b> resource
+ * Describes the synchronization of a <b>local</b> resource
* relative to a <b>remote</b> resource variant. There are two
- * types of comparison: two-way and three-way.
- * The {@link IResourceVariantComparator} is used to decide which
- * comparison type to use.
+ * types of comparison: two-way and three-way.
+ * The {@link IResourceVariantComparator} is used to decide which
+ * comparison type to use.
* </p>
* <p>
* For two-way comparisons, a <code>SyncInfo</code> node has a change
- * type. This will be one of <code>IN-SYNC</code>, <code>ADDITION</code>,
+ * type. This will be one of <code>IN-SYNC</code>, <code>ADDITION</code>,
* <code>DELETION</code> or <code>CHANGE</code> determined in the following manner.
* <ul>
* <li>A resource is considered an <code>ADDITION</code> if it exists locally and there is no remote.
* <li>A resource is considered an <code>DELETION</code> if it does not exists locally and there is remote.
- * <li>A resource is considered a <code>CHANGE</code> if both the local and remote exist but the
+ * <li>A resource is considered a <code>CHANGE</code> 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.
* <li>A resource is considered <code>IN_SYNC</code> in all other cases.
@@ -51,7 +51,7 @@ import org.eclipse.team.internal.core.Messages;
* are classified as <b>incoming changes</b>; if there is
* a difference, the remote resource is considered the
* <b>incoming resource</b>.
- * <li>If there are both incoming and outgoing changes, the resource
+ * <li>If there are both incoming and outgoing changes, the resource
* is considered a <b>conflicting change</b>.
* </ul>
* Again, the comparison of resources is done using the variant comparator provided
@@ -60,26 +60,26 @@ import org.eclipse.team.internal.core.Messages;
* @since 3.0
*/
public class SyncInfo implements IAdaptable {
-
+
/*====================================================================
- * Constants defining synchronization types:
+ * Constants defining synchronization types:
*====================================================================*/
/**
* Sync constant (value 0) indicating element is in sync.
*/
public static final int IN_SYNC = 0;
-
+
/**
* Sync constant (value 1) indicating that one side was added.
*/
public static final int ADDITION = 1;
-
+
/**
* Sync constant (value 2) indicating that one side was deleted.
*/
public static final int DELETION = 2;
-
+
/**
* Sync constant (value 3) indicating that one side was changed.
*/
@@ -89,55 +89,55 @@ public class SyncInfo implements IAdaptable {
* Bit mask for extracting the change type.
*/
public static final int CHANGE_MASK = CHANGE;
-
+
/*====================================================================
- * Constants defining synchronization direction:
+ * Constants defining synchronization direction:
*====================================================================*/
-
+
/**
* Sync constant (value 4) indicating a change to the local resource.
*/
public static final int OUTGOING = 4;
-
+
/**
* Sync constant (value 8) indicating a change to the remote resource.
*/
public static final int INCOMING = 8;
-
+
/**
* Sync constant (value 12) indicating a change to both the remote and local resources.
*/
public static final int CONFLICTING = 12;
-
+
/**
- * Bit mask for extracting the synchronization direction.
+ * Bit mask for extracting the synchronization direction.
*/
public static final int DIRECTION_MASK = CONFLICTING;
-
+
/*====================================================================
* Constants defining synchronization conflict types:
*====================================================================*/
-
+
/**
- * Sync constant (value 16) indication that both the local and remote resources have changed
- * relative to the base but their contents are the same.
+ * Sync constant (value 16) indication that both the local and remote resources have changed
+ * relative to the base but their contents are the same.
*/
public static final int PSEUDO_CONFLICT = 16;
-
+
/**
- * 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
+ * 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). These conflicts could be merged automatically.
*/
public static final int AUTOMERGE_CONFLICT = 32;
-
+
/**
- * 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
+ * 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). These conflicts can only be correctly resolved by the user.
*/
public static final int MANUAL_CONFLICT = 64;
-
+
/*====================================================================
* Members:
*====================================================================*/
@@ -145,9 +145,9 @@ public class SyncInfo implements IAdaptable {
private IResourceVariant base;
private IResourceVariant remote;
private IResourceVariantComparator comparator;
-
+
private int syncKind;
-
+
/**
* Construct a sync info object.
* @param local the local resource. Must be non-null but may not exist.
@@ -163,7 +163,7 @@ public class SyncInfo implements IAdaptable {
this.remote = remote;
this.comparator = comparator;
}
-
+
/**
* Returns the state of the local resource. Note that the
* resource may or may not exist.
@@ -173,12 +173,12 @@ public class SyncInfo implements IAdaptable {
public IResource getLocal() {
return local;
}
-
+
/**
* Returns the content identifier for the local resource or <code>null</code> if
- * it doesn't have one. For example, in CVS this would be the revision number.
- *
- * @return String that could be displayed to the user to identify this resource.
+ * it doesn't have one. For example, in CVS this would be the revision number.
+ *
+ * @return String that could be displayed to the user to identify this resource.
*/
public String getLocalContentIdentifier() {
return null;
@@ -188,7 +188,7 @@ public class SyncInfo implements IAdaptable {
* Returns the author of the revision corresponding to the local resource or <code>null</code>
* if it doesn't have one. For example if the local file is shared in CVS this would be the
* revision author.
- *
+ *
* @param monitor the progress monitor
* @return the author of the revision associated with the local file or <code>null</code>
* @since 3.6
@@ -210,7 +210,7 @@ public class SyncInfo implements IAdaptable {
public IResourceVariant getBase() {
return base;
}
-
+
/**
* Returns the handle for the remote resource,
* or <code>null</code> if the remote resource does not exist.
@@ -224,63 +224,63 @@ public class SyncInfo implements IAdaptable {
public IResourceVariant getRemote() {
return remote;
}
-
+
/**
* Returns the comparator that is used to determine the
* kind of this sync node.
- *
+ *
* @return the comparator that is used to determine the
* kind of this sync node.
*/
public IResourceVariantComparator getComparator() {
return comparator;
}
-
+
/**
* Returns the kind of synchronization for this node.
- *
+ *
* @return the kind of synchronization for this node.
*/
public int getKind() {
return syncKind;
}
-
+
/**
* Helper method that returns whether the given kind represents
* an in-sync resource.
- *
+ *
* @param kind the kind of a <code>SyncInfo</code>
* @return whether the kind is <code>IN_SYNC</code>.
*/
static public boolean isInSync(int kind) {
return kind == IN_SYNC;
}
-
+
/**
- * Helper method to return the direction portion
+ * Helper method to return the direction portion
* of the given kind. The resulting value
* can be compared directly with the direction constants.
- *
+ *
* @param kind the kind of a <code>SyncInfo</code>
* @return the direction portion of the kind
*/
static public int getDirection(int kind) {
return kind & DIRECTION_MASK;
}
-
+
/**
- * Helper method to return the change portion
+ * Helper method to return the change portion
* of the given kind. The resulting value
* can be compared directly with the change
* type constants.
- *
+ *
* @param kind the kind of a <code>SyncInfo</code>
* @return the change portion of the kind
*/
static public int getChange(int kind) {
return kind & CHANGE_MASK;
}
-
+
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@@ -291,19 +291,19 @@ public class SyncInfo implements IAdaptable {
}
return false;
}
-
+
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return getLocal().hashCode();
}
-
- private boolean equalNodes(SyncInfo node1, SyncInfo node2) {
+
+ private boolean equalNodes(SyncInfo node1, SyncInfo node2) {
if(node1 == null || node2 == null) {
return false;
}
-
+
// First, ensure the local resources are equals
IResource local1 = null;
if (node1.getLocal() != null)
@@ -312,7 +312,7 @@ public class SyncInfo implements IAdaptable {
if (node2.getLocal() != null)
local2 = node2.getLocal();
if (!equalObjects(local1, local2)) return false;
-
+
// Next, ensure the base resources are equal
IResourceVariant base1 = null;
if (node1.getBase() != null)
@@ -330,16 +330,16 @@ public class SyncInfo implements IAdaptable {
if (node2.getRemote() != null)
remote2 = node2.getRemote();
if (!equalObjects(remote1, remote2)) return false;
-
+
return true;
}
-
+
private boolean equalObjects(Object o1, Object o2) {
if (o1 == null && o2 == null) return true;
if (o1 == null || o2 == null) return false;
return o1.equals(o2);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
@@ -349,77 +349,77 @@ public class SyncInfo implements IAdaptable {
}
return null;
}
-
+
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
return getLocal().getName() + " " + kindToString(getKind()); //$NON-NLS-1$
}
-
+
/**
* A helper method that returns a displayable (i.e. externalized)
* string describing the provided sync kind.
- *
+ *
* @param kind the sync kind obtained from a <code>SyncInfo</code>
* @return a displayable string that describes the kind
*/
public static String kindToString(int kind) {
String label = ""; //$NON-NLS-1$
if(kind==IN_SYNC) {
- label = Messages.RemoteSyncElement_insync;
+ label = Messages.RemoteSyncElement_insync;
} else {
switch(kind & DIRECTION_MASK) {
- case CONFLICTING: label = Messages.RemoteSyncElement_conflicting; break;
- case OUTGOING: label = Messages.RemoteSyncElement_outgoing; break;
- case INCOMING: label = Messages.RemoteSyncElement_incoming; break;
- }
+ case CONFLICTING: label = Messages.RemoteSyncElement_conflicting; break;
+ case OUTGOING: label = Messages.RemoteSyncElement_outgoing; break;
+ case INCOMING: label = Messages.RemoteSyncElement_incoming; break;
+ }
switch(kind & CHANGE_MASK) {
- case CHANGE: label = NLS.bind(Messages.concatStrings, new String[] { label, Messages.RemoteSyncElement_change }); break; //
- case ADDITION: label = NLS.bind(Messages.concatStrings, new String[] { label, Messages.RemoteSyncElement_addition }); break; //
- case DELETION: label = NLS.bind(Messages.concatStrings, new String[] { label, Messages.RemoteSyncElement_deletion }); break; //
+ case CHANGE: label = NLS.bind(Messages.concatStrings, new String[] { label, Messages.RemoteSyncElement_change }); break; //
+ case ADDITION: label = NLS.bind(Messages.concatStrings, new String[] { label, Messages.RemoteSyncElement_addition }); break; //
+ case DELETION: label = NLS.bind(Messages.concatStrings, new String[] { label, Messages.RemoteSyncElement_deletion }); break; //
}
- if((kind & MANUAL_CONFLICT) != 0) {
- label = NLS.bind(Messages.concatStrings, new String[] { label, Messages.RemoteSyncElement_manual }); //
+ if((kind & MANUAL_CONFLICT) != 0) {
+ label = NLS.bind(Messages.concatStrings, new String[] { label, Messages.RemoteSyncElement_manual }); //
}
- if((kind & AUTOMERGE_CONFLICT) != 0) {
- label = NLS.bind(Messages.concatStrings, new String[] { label, Messages.RemoteSyncElement_auto }); //
+ if((kind & AUTOMERGE_CONFLICT) != 0) {
+ label = NLS.bind(Messages.concatStrings, new String[] { label, Messages.RemoteSyncElement_auto }); //
}
}
- return NLS.bind(Messages.RemoteSyncElement_delimit, new String[] { label });
+ return NLS.bind(Messages.RemoteSyncElement_delimit, new String[] { label });
}
-
+
/**
* Method that is invoked after instance creation to initialize the sync kind.
* This method should only be invoked by the creator of the <code>SyncInfo</code>
* 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.
*/
public final void init() throws TeamException {
syncKind = calculateKind();
}
-
+
/**
* Method that is invoked from the <code>init()</code> method to calculate
* the sync kind for this instance of <code>SyncInfo</code>. The result is
* assigned to an instance variable and is available using <code>getKind()</code>.
* Subclasses should not invoke this method but may override it in order to customize
* the sync kind calculation algorithm.
- *
+ *
* @return the sync kind of this <code>SyncInfo</code>
* @throws TeamException if there were problems calculating the sync state.
*/
protected int calculateKind() throws TeamException {
int description = IN_SYNC;
-
+
boolean localExists = local.exists();
-
+
if (comparator.isThreeWay()) {
if (base == null) {
if (remote == null) {
- if (!localExists) {
+ if (!localExists) {
description = IN_SYNC;
} else {
description = OUTGOING | ADDITION;
@@ -441,7 +441,7 @@ public class SyncInfo implements IAdaptable {
} else {
if (comparator.compare(base, remote))
description = OUTGOING | DELETION;
- else
+ else
description = CONFLICTING | CHANGE;
}
} else {

Back to the top