Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.team.core.synchronize
Class SyncInfo

    java.lang.Object
      org.eclipse.team.core.synchronize.SyncInfo

All Implemented Interfaces:
  IAdaptable

public class SyncInfo
extends Object
implements IAdaptable

Describes the synchronization of a local resource relative to a remote resource variant. There are two types of comparison: two-way and three-way. The `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. Again, the comparison of resources is done using the variant comparator provided when the sync info was created.

  Since:
    3.0

  Field Summary
  `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 Summary
  `SyncInfo(IResource local, IResourceVariant base, IResourceVariant remote, IResourceVariantComparator comparator)` Construct a sync info object.

  Method Summary
  `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` | `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()`

  Methods inherited from class java.lang.Object
  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  Field Detail

  ### IN_SYNC

      public static final int IN_SYNC

    Sync constant (value 0) indicating element is in sync.

    See Also:
      Constant Field Values

  ### ADDITION

      public static final int ADDITION

    Sync constant (value 1) indicating that one side was added.

    See Also:
      Constant Field Values

  ### DELETION

      public static final int DELETION

    Sync constant (value 2) indicating that one side was deleted.

    See Also:
      Constant Field Values

  ### CHANGE

      public static final int CHANGE

    Sync constant (value 3) indicating that one side was changed.

    See Also:
      Constant Field Values

  ### CHANGE_MASK

      public static final int CHANGE_MASK

    Bit mask for extracting the change type.

    See Also:
      Constant Field Values

  ### OUTGOING

      public static final int OUTGOING

    Sync constant (value 4) indicating a change to the local resource.

    See Also:
      Constant Field Values

  ### INCOMING

      public static final int INCOMING

    Sync constant (value 8) indicating a change to the remote resource.

    See Also:
      Constant Field Values

  ### CONFLICTING

      public static final int CONFLICTING

    Sync constant (value 12) indicating a change to both the remote and local resources.

    See Also:
      Constant Field Values

  ### DIRECTION_MASK

      public static final int DIRECTION_MASK

    Bit mask for extracting the synchronization direction.

    See Also:
      Constant Field Values

  ### PSEUDO_CONFLICT

      public static final 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.

    See Also:
      Constant Field Values

  ### AUTOMERGE_CONFLICT

      public static final 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). These conflicts could be merged automatically.

    See Also:
      Constant Field Values

  ### MANUAL_CONFLICT

      public static final 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). These conflicts can only be correctly resolved by the user.

    See Also:
      Constant Field Values

  Constructor Detail

  ### 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 or `null`
    `remote` - the remote resource variant or `null`
    `comparator` - the comparator used to determine if resources differ

  Method Detail

  ### getLocal

      public IResource getLocal()

    Returns the state of the local resource. Note that the resource may or may not exist.

    Returns:
      a resource

  ### getLocalContentIdentifier

      public String getLocalContentIdentifier()

    Returns the content identifier for the local resource or `null` 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.

  ### getBase

      public IResourceVariant getBase()

    Returns the remote resource handle for the base resource, or `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. ]

    Returns:
      a remote resource handle, or `null`

  ### getRemote

      public IResourceVariant getRemote()

    Returns the handle for the remote resource, or `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. ]

    Returns:
      a remote resource handle, or `null`

  ### getComparator

      public IResourceVariantComparator 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 a `SyncInfo`
    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 a `SyncInfo`
    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 a `SyncInfo`
    Returns:
      the change portion of the kind

  ### equals

      public boolean equals(Object other)

  ### hashCode

      public int hashCode()

  ### getAdapter

      public Object getAdapter(Class adapter)

    Description copied from interface: `IAdaptable`
    Returns an object which is an instance of the given class associated with this object. Returns `null` if no such object can be found.

    Specified by:
      `getAdapter` in interface `IAdaptable`
    Parameters:
      `adapter` - the adapter class to look up
    Returns:
      a object castable to the given class, or `null` if this object does not have an adapter for the given class

  ### toString

      public String toString()

  ### kindToString

      public static String kindToString(int kind)

    A helper method that returns a displayable (i.e. externalized) string describing the provided sync kind.

    Parameters:
      `kind` - the sync kind obtained from a `SyncInfo`
    Returns:
      a displayable string that descibes the kind

  ### init

      public final void init()
                      throws TeamException

    Method that is invoked after instance creation to initialize the sync kind. This method should only be invoked by the creator of the `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.

    Throws:
      `TeamException` - if there were problems calculating the sync state.

  ### calculateKind

      protected int calculateKind()
                           throws TeamException

    Method that is invoked from the `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.

    Returns:
      the sync kind of this `SyncInfo`
    Throws:
      `TeamException` - if there were problems calculating the sync state.

  Overview | Package | Class | Use | Tree | Deprecated | Index | Help
  | Eclipse Platform Release 3.0
  PREV CLASS NEXT CLASS | FRAMES NO FRAMES
  SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

  Guidelines for using Eclipse APIs.

  Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.