org.eclipse.core.internal.resources
Class Synchronizer

java.lang.Object
  extended by org.eclipse.core.internal.resources.Synchronizer
All Implemented Interfaces:
ISynchronizer

public class Synchronizer
extends java.lang.Object
implements ISynchronizer


Constructor Summary
Synchronizer(Workspace workspace)
           
 
Method Summary
 void accept(org.eclipse.core.runtime.QualifiedName partner, IResource resource, IResourceVisitor visitor, int depth)
          Visits the given resource and its descendents with the specified visitor if sync information for the given sync partner is found on the resource.
 void add(org.eclipse.core.runtime.QualifiedName partner)
          Adds the named synchronization partner to this synchronizer's registry of partners.
 void flushSyncInfo(org.eclipse.core.runtime.QualifiedName partner, IResource root, int depth)
          Discards the named partner's synchronization information associated with the specified resource and its descendents to the specified depth.
 org.eclipse.core.runtime.QualifiedName[] getPartners()
          Returns a list of synchronization partner names currently registered with this synchronizer.
 byte[] getSyncInfo(org.eclipse.core.runtime.QualifiedName partner, IResource resource)
          Returns the named sync partner's synchronization information for the given resource.
 void readPartners(java.io.DataInputStream input)
           
 void remove(org.eclipse.core.runtime.QualifiedName partner)
          Removes the named synchronization partner from this synchronizer's registry.
 void restore(IResource resource, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void savePartners(java.io.DataOutputStream output)
           
 void saveSyncInfo(ResourceInfo info, IPathRequestor requestor, java.io.DataOutputStream output, java.util.List writtenPartners)
           
 void setSyncInfo(org.eclipse.core.runtime.QualifiedName partner, IResource resource, byte[] info)
          Sets the named sync partner's synchronization information for the given resource.
 void snapSyncInfo(ResourceInfo info, IPathRequestor requestor, java.io.DataOutputStream output)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Synchronizer

public Synchronizer(Workspace workspace)
Method Detail

accept

public void accept(org.eclipse.core.runtime.QualifiedName partner,
                   IResource resource,
                   IResourceVisitor visitor,
                   int depth)
            throws org.eclipse.core.runtime.CoreException
Description copied from interface: ISynchronizer
Visits the given resource and its descendents with the specified visitor if sync information for the given sync partner is found on the resource. If sync information for the given sync partner is not found on the resource, still visit the children of the resource if the depth specifies to do so.

Specified by:
accept in interface ISynchronizer
Parameters:
partner - the sync partner name
resource - the parent resource to start the visitation
visitor - the visitor to use when visiting the resources
depth - the depth to which members of this resource should be visited. One of IResource.DEPTH_ZERO, IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE.
Throws:
org.eclipse.core.runtime.CoreException - if this operation fails. Reasons include:
  • The resource does not exist.
  • IResourceStatus.PARTNER_NOT_REGISTERED The sync partner is not registered.
See Also:
ISynchronizer.accept(QualifiedName, IResource, IResourceVisitor, int)

add

public void add(org.eclipse.core.runtime.QualifiedName partner)
Description copied from interface: ISynchronizer
Adds the named synchronization partner to this synchronizer's registry of partners. Once a partner's name has been registered, sync information can be set and retrieve on resources relative to the name. Adding a sync partner multiple times has no effect.

Specified by:
add in interface ISynchronizer
Parameters:
partner - the partner name to register
See Also:
ISynchronizer.add(QualifiedName)

flushSyncInfo

public void flushSyncInfo(org.eclipse.core.runtime.QualifiedName partner,
                          IResource root,
                          int depth)
                   throws org.eclipse.core.runtime.CoreException
Description copied from interface: ISynchronizer
Discards the named partner's synchronization information associated with the specified resource and its descendents to the specified depth.

Specified by:
flushSyncInfo in interface ISynchronizer
Parameters:
partner - the sync partner name
root - the resource
depth - the depth to which members of this resource should be visited. One of IResource.DEPTH_ZERO, IResource.DEPTH_ONE, or IResource.DEPTH_INFINITE.
Throws:
org.eclipse.core.runtime.CoreException - if this operation fails. Reasons include:
  • The resource does not exist.
  • IResourceStatus.PARTNER_NOT_REGISTERED The sync partner is not registered.
See Also:
ISynchronizer.flushSyncInfo(QualifiedName, IResource, int)

getPartners

public org.eclipse.core.runtime.QualifiedName[] getPartners()
Description copied from interface: ISynchronizer
Returns a list of synchronization partner names currently registered with this synchronizer. Returns an empty array if there are no registered sync partners.

Specified by:
getPartners in interface ISynchronizer
Returns:
a list of sync partner names
See Also:
ISynchronizer.getPartners()

getSyncInfo

public byte[] getSyncInfo(org.eclipse.core.runtime.QualifiedName partner,
                          IResource resource)
                   throws org.eclipse.core.runtime.CoreException
Description copied from interface: ISynchronizer
Returns the named sync partner's synchronization information for the given resource. Returns null if no information is found.

Specified by:
getSyncInfo in interface ISynchronizer
Parameters:
partner - the sync partner name
resource - the resource
Returns:
the synchronization information, or null if none
Throws:
org.eclipse.core.runtime.CoreException - if this operation fails. Reasons include:
  • IResourceStatus.PARTNER_NOT_REGISTERED The sync partner is not registered.
See Also:
ISynchronizer.getSyncInfo(QualifiedName, IResource)

readPartners

public void readPartners(java.io.DataInputStream input)
                  throws org.eclipse.core.runtime.CoreException
Throws:
org.eclipse.core.runtime.CoreException
See Also:
savePartners(DataOutputStream)

restore

public void restore(IResource resource,
                    org.eclipse.core.runtime.IProgressMonitor monitor)
             throws org.eclipse.core.runtime.CoreException
Throws:
org.eclipse.core.runtime.CoreException

remove

public void remove(org.eclipse.core.runtime.QualifiedName partner)
Description copied from interface: ISynchronizer
Removes the named synchronization partner from this synchronizer's registry. Does nothing if the partner is not registered. This discards all sync information for the defunct partner. After a partner has been unregistered, sync information for it can no longer be stored on resources.

Specified by:
remove in interface ISynchronizer
Parameters:
partner - the partner name to remove from the registry
See Also:
ISynchronizer.remove(QualifiedName)

savePartners

public void savePartners(java.io.DataOutputStream output)
                  throws java.io.IOException
Throws:
java.io.IOException

saveSyncInfo

public void saveSyncInfo(ResourceInfo info,
                         IPathRequestor requestor,
                         java.io.DataOutputStream output,
                         java.util.List writtenPartners)
                  throws java.io.IOException
Throws:
java.io.IOException

setSyncInfo

public void setSyncInfo(org.eclipse.core.runtime.QualifiedName partner,
                        IResource resource,
                        byte[] info)
                 throws org.eclipse.core.runtime.CoreException
Description copied from interface: ISynchronizer
Sets the named sync partner's synchronization information for the given resource. If the given info is non-null and the resource neither exists nor is a phantom, this method creates a phantom resource to hang on to the info. If the given info is null, any sync info for the resource stored by the given sync partner is discarded; in some cases, this may result in the deletion of a phantom resource if there is no more sync info to maintain for that resource.

Sync information is not stored on the workspace root. Attempts to set information on the root will be ignored.

Specified by:
setSyncInfo in interface ISynchronizer
Parameters:
partner - the sync partner name
resource - the resource
info - the synchronization information, or null
Throws:
org.eclipse.core.runtime.CoreException - if this operation fails. Reasons include:
  • IResourceStatus.PARTNER_NOT_REGISTERED The sync partner is not registered.
See Also:
ISynchronizer.setSyncInfo(QualifiedName, IResource, byte[])

snapSyncInfo

public void snapSyncInfo(ResourceInfo info,
                         IPathRequestor requestor,
                         java.io.DataOutputStream output)
                  throws java.io.IOException
Throws:
java.io.IOException