diff options
Diffstat (limited to 'bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants')
15 files changed, 231 insertions, 231 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java index 4fa33e87e..c78c3e953 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/AbstractResourceVariantTree.java @@ -23,12 +23,12 @@ import org.eclipse.team.internal.core.*; * An implementation of <code>IResourceVariantTree</code> that provides the logic for * refreshing the tree and collecting the results so they can be cached locally. * This class does not perform the caching but relies on subclasses to do that by - * overriding the <code>setVariant</code> method. The subclass + * overriding the <code>setVariant</code> method. The subclass * {@link ResourceVariantTree} does provide caching. - * + * * @see IResourceVariantTree * @see ResourceVariantTree - * + * * @since 3.0 */ public abstract class AbstractResourceVariantTree implements IResourceVariantTree { @@ -37,7 +37,7 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre * Refreshes the resource variant tree for the specified resources and possibly their descendants, * depending on the depth. The default implementation of this method invokes * <code>refresh(IResource, int, IProgressMonitor)</code> for each resource. - * Subclasses may override but should either invoke the above mentioned refresh or + * Subclasses may override but should either invoke the above mentioned refresh or * <code>collectChanges</code> in order to reconcile the resource variant tree. * @param resources the resources whose variants should be refreshed * @param depth the depth of the refresh (one of <code>IResource.DEPTH_ZERO</code>, @@ -78,18 +78,18 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre IResource[] changedResources = null; monitor.beginTask(null, 100); try { - monitor.setTaskName(NLS.bind(Messages.SynchronizationCacheRefreshOperation_0, new String[] { resource.getFullPath().makeRelative().toString() })); - + monitor.setTaskName(NLS.bind(Messages.SynchronizationCacheRefreshOperation_0, new String[] { resource.getFullPath().makeRelative().toString() })); + // build the remote tree only if an initial tree hasn't been provided IResourceVariant tree = fetchVariant(resource, depth, Policy.subMonitorFor(monitor, 70)); - - // update the known remote handles + + // update the known remote handles IProgressMonitor sub = Policy.infiniteSubMonitorFor(monitor, 30); try { sub.beginTask(null, 64); changedResources = collectChanges(resource, tree, depth, Policy.subMonitorFor(sub, 64)); } finally { - sub.done(); + sub.done(); } } finally { monitor.done(); @@ -117,7 +117,7 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre /** * Fetch the members of the given resource variant handle. This method may * return members that were fetched when <code>fetchVariant</code> was called or - * may fetch the children directly (i.e. this method may contact the server). + * may fetch the children directly (i.e. this method may contact the server). * @param variant the resource variant * @param progress a progress monitor * @return the members of the resource variant. @@ -127,9 +127,9 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre /** * Fetch the resource variant corresponding to the given resource. The depth * parameter indicates the depth of the refresh operation and also indicates the - * depth to which the resource variant's descendants will be traversed. + * depth to which the resource variant's descendants will be traversed. * This method may pre-fetch the descendants to the provided depth - * or may just return the variant handle corresponding to the given + * or may just return the variant handle corresponding to the given * local resource, in which case * the descendant variants will be fetched by <code>fetchMembers(IResourceVariant, IProgressMonitor)</code>. * @param resource the local resource @@ -142,7 +142,7 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre /** * Method that is invoked during collection to let subclasses know which members - * were collected for the given resource. Implementors should purge any cached + * were collected for the given resource. Implementors should purge any cached * state for children of the local resource that are no longer members. Any such resources * should be returned to allow clients to clear any state they maintain for those resources. * @param local the local resource @@ -170,40 +170,40 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre changedResources.add(local); } if (depth == IResource.DEPTH_ZERO) return; - Map children = mergedMembers(local, remote, monitor); + Map children = mergedMembers(local, remote, monitor); for (Iterator it = children.keySet().iterator(); it.hasNext();) { IResource localChild = (IResource) it.next(); IResourceVariant remoteChild = (IResourceVariant)children.get(localChild); collectChanges(localChild, remoteChild, changedResources, - depth == IResource.DEPTH_INFINITE ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO, + depth == IResource.DEPTH_INFINITE ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO, monitor); } - + IResource[] cleared = collectedMembers(local, (IResource[]) children.keySet().toArray(new IResource[children.keySet().size()])); changedResources.addAll(Arrays.asList(cleared)); monitor.worked(1); } private Map mergedMembers(IResource local, IResourceVariant remote, IProgressMonitor progress) throws TeamException { - + // {IResource -> IResourceVariant} Map mergedResources = new HashMap(); - + IResourceVariant[] remoteChildren; if (remote == null) { remoteChildren = new IResourceVariant[0]; } else { remoteChildren = fetchMembers(remote, progress); } - - - IResource[] localChildren = members(local); - + + + IResource[] localChildren = members(local); + if (remoteChildren.length > 0 || localChildren.length > 0) { Set allSet = new HashSet(20); Map localSet = null; Map remoteSet = null; - + if (localChildren.length > 0) { localSet = new HashMap(10); for (int i = 0; i < localChildren.length; i++) { @@ -213,7 +213,7 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre allSet.add(name); } } - + if (remoteChildren.length > 0) { remoteSet = new HashMap(10); for (int i = 0; i < remoteChildren.length; i++) { @@ -223,23 +223,23 @@ public abstract class AbstractResourceVariantTree implements IResourceVariantTre allSet.add(name); } } - + Iterator e = allSet.iterator(); while (e.hasNext()) { String keyChildName = (String) e.next(); - + Policy.checkCanceled(progress); - + IResource localChild = localSet != null ? (IResource) localSet.get(keyChildName) : null; - + IResourceVariant remoteChild = remoteSet != null ? (IResourceVariant) remoteSet.get(keyChildName) : null; - + if (localChild == null) { // there has to be a remote resource available if we got this far Assert.isTrue(remoteChild != null); - boolean isContainer = remoteChild.isContainer(); + boolean isContainer = remoteChild.isContainer(); localChild = getResourceChild(local /* parent */, keyChildName, isContainer); } if (localChild == null) { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/CachedResourceVariant.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/CachedResourceVariant.java index a451da8e9..f5fd05872 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/CachedResourceVariant.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/CachedResourceVariant.java @@ -37,20 +37,20 @@ import org.eclipse.team.internal.core.*; * cache additional resource variant properties such as author, comment, etc. * </p> * <p> - * The <code>IStorage</code> instance returned by this class will be + * The <code>IStorage</code> instance returned by this class will be * an {@link org.eclipse.core.resources.IEncodedStorage}. * <p> * The cache in which the resource variants reside will occasionally clear * cached entries if they have not been accessed for a certain amount of time. * </p> - * + * * @since 3.0 */ public abstract class CachedResourceVariant extends PlatformObject implements IResourceVariant { - + // holds the storage instance for this resource variant private IStorage storage; - + /* * Internal class which provides access to the cached contents * of this resource variant @@ -60,7 +60,7 @@ public abstract class CachedResourceVariant extends PlatformObject implements IR if (!isContentsCached()) { // The cache may have been cleared if someone held // on to the storage too long - throw new TeamException(NLS.bind(Messages.CachedResourceVariant_0, new String[] { getCachePath() })); + throw new TeamException(NLS.bind(Messages.CachedResourceVariant_0, new String[] { getCachePath() })); } return getCachedContents(); } @@ -82,7 +82,7 @@ public abstract class CachedResourceVariant extends PlatformObject implements IR String charSet = TeamPlugin.getCharset(getName(), contents); return charSet; } catch (IOException e) { - throw new TeamException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.FAILED_DESCRIBING_CONTENTS, NLS.bind(Messages.CachedResourceVariant_1, new String[] { getFullPath().toString() }), e)); + throw new TeamException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.FAILED_DESCRIBING_CONTENTS, NLS.bind(Messages.CachedResourceVariant_1, new String[] { getFullPath().toString() }), e)); } finally { try { contents.close(); @@ -92,7 +92,7 @@ public abstract class CachedResourceVariant extends PlatformObject implements IR } } } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.IResourceVariant#getStorage(org.eclipse.core.runtime.IProgressMonitor) */ @@ -104,16 +104,16 @@ public abstract class CachedResourceVariant extends PlatformObject implements IR } return storage; } - + private void ensureContentsCached(IProgressMonitor monitor) throws TeamException { // Ensure that the contents are cached from the server if (!isContentsCached()) { fetchContents(monitor); } } - + /** - * Method that is invoked when the contents of the resource variant need to + * Method that is invoked when the contents of the resource variant need to * be fetched. This method will only be invoked for files (i.e. * <code>isContainer()</code> returns <code>false</code>. * Subclasses should override this method and invoke <code>setContents</code> @@ -124,7 +124,7 @@ public abstract class CachedResourceVariant extends PlatformObject implements IR /** * This method should be invoked by subclasses from within their <code>fetchContents</code> - * method in order to cache the contents for this resource variant. + * method in order to cache the contents for this resource variant. * <p> * This method is not intended to be overridden by clients. * @param stream the stream containing the contents of the resource variant @@ -137,11 +137,11 @@ public abstract class CachedResourceVariant extends PlatformObject implements IR if (!isHandleCached()) cacheHandle(); getCacheEntry().setContents(stream, monitor); } - + private ResourceVariantCacheEntry getCacheEntry() { return getCache().getCacheEntry(this.getCachePath()); } - + /** * Return whether there are already contents cached for this resource variant. * This method will return <code>false</code> even if the contents are currently @@ -159,7 +159,7 @@ public abstract class CachedResourceVariant extends PlatformObject implements IR ResourceVariantCacheEntry entry = getCache().getCacheEntry(getCachePath()); return entry.getState() == ResourceVariantCacheEntry.READY; } - + /** * Return the cached contents for this resource variant or <code>null</code> * if the contents have not been cached. @@ -173,17 +173,17 @@ public abstract class CachedResourceVariant extends PlatformObject implements IR if (isContainer() || !isContentsCached()) return null; return getCache().getCacheEntry(getCachePath()).getContents(); } - + /** * Return <code>true</code> if the cache contains an entry for this resource * variant. It is possible that another instance of this variant is cached. - * To get the cached instance, call <code>getCachedHandle()</code>. Note that + * To get the cached instance, call <code>getCachedHandle()</code>. Note that * cached contents can be retrieved from any handle to a resource variant whose * cache path (as returned by <code>getCachePath()</code>) match but other * state information may only be accessible from the cached copy. - * + * * @return whether the variant is cached - * @nooverride This method is not intended to be overridden by clients. + * @nooverride This method is not intended to be overridden by clients. */ protected boolean isHandleCached() { return (getCache().hasEntry(getCachePath())); @@ -201,7 +201,7 @@ public abstract class CachedResourceVariant extends PlatformObject implements IR * @return the full path of the remote resource variant */ protected abstract String getCachePath(); - + /** * Return the size (in bytes) of the contents of this resource variant. * The method will return 0 if the contents have not yet been cached @@ -217,7 +217,7 @@ public abstract class CachedResourceVariant extends PlatformObject implements IR } return entry.getSize(); } - + /* * Return the cache that is used to cache this resource variant and its contents. * @return Returns the cache. @@ -226,7 +226,7 @@ public abstract class CachedResourceVariant extends PlatformObject implements IR ResourceVariantCache.enableCaching(getCacheId()); return ResourceVariantCache.getCache(getCacheId()); } - + /** * Return the ID that uniquely identifies the cache in which this resource variant * is to be cache. The ID of the plugin that provides the resource variant subclass @@ -241,44 +241,44 @@ public abstract class CachedResourceVariant extends PlatformObject implements IR * one. If there isn't one, then <code>null</code> is returned. * If there is no cached handle and one is desired, then <code>cacheHandle()</code> * should be called. - * + * * @return a cached copy of this resource variant or <code>null</code> - * @nooverride This method is not intended to be overridden by clients. + * @nooverride This method is not intended to be overridden by clients. */ protected CachedResourceVariant getCachedHandle() { ResourceVariantCacheEntry entry = getCacheEntry(); if (entry == null) return null; return entry.getResourceVariant(); } - + /** * Cache this handle in the cache, replacing any previously cached handle. - * Note that caching this handle will replace any state associated with a + * Note that caching this handle will replace any state associated with a * previously cached handle, if there is one, but the contents will remain. * The reason for this is the assumption that the cache path for a resource * variant (as returned by <code>getCachePath()</code> identifies an immutable * resource version (or revision). The ability to replace the handle itself * is provided so that additional state may be cached before or after the contents * are fetched. - * + * * @nooverride This method is not intended to be overridden by clients. */ protected void cacheHandle() { getCache().add(getCachePath(), this); } - + /** * Return the full path of this resource that should be displayed to the - * user. This path is also used as the path of the <code>IStorage</code> that + * user. This path is also used as the path of the <code>IStorage</code> that * is returned by this instance. * Subclasses may override. * @return the full path of this resource that should be displayed to the * user - * + * * @since 3.1 */ public IPath getDisplayPath() { return new Path(null, getCachePath()); } - + } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariant.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariant.java index 4ff2014b3..9685f54eb 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariant.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariant.java @@ -16,35 +16,35 @@ import org.eclipse.team.core.TeamException; /** * This interface is used by <code>SyncInfo</code> instances - * to provide access to the base and remote resources that correspond to + * to provide access to the base and remote resources that correspond to * a local resource. - * + * * @see org.eclipse.team.core.synchronize.SyncInfo * @since 3.0 */ public interface IResourceVariant { - + /** * Answers the name of the remote resource. The name may be * displayed to the user. - * + * * @return name of the resource variant. */ public String getName(); - + /** * Answers if the remote resource may have children. - * - * @return <code>true</code> if the remote resource may have children and + * + * @return <code>true</code> if the remote resource may have children and * <code>false</code> otherwise. */ public boolean isContainer(); - + /** * Return an instance of IStorage or <code>null</code> if the remote resource * does not have contents (i.e. is a folder). Since the <code>ISorage#getContents()</code> * method does not accept an <code>IProgressMonitor</code>, this method must ensure that the contents - * access by the resulting <code>IStorage</code> is cached locally (hence the <code>IProgressMonitor</code> + * access by the resulting <code>IStorage</code> is cached locally (hence the <code>IProgressMonitor</code> * argument to this method). Implementations of this method should * ensure that the resulting <code>IStorage</code> is accessing locally cached contents and is not * contacting the server. @@ -52,21 +52,21 @@ public interface IResourceVariant { * The returned storage object may be an instance of (@link org.eclipse.core.resources.IEncodedStorage} * in which case clients can determine the character encoding of the contents. * @param monitor a progress monitor - * - * @return an <code>IStorage</code> that provides access to the contents of + * + * @return an <code>IStorage</code> that provides access to the contents of * the remote resource or <code>null</code> if the remote resource is a container. - * @throws TeamException + * @throws TeamException */ public IStorage getStorage(IProgressMonitor monitor) throws TeamException; - + /** * Return a content identifier that is used to differentiate versions * or revisions of the same resource. - * + * * @return a String that identifies the version of the subscriber resource */ public String getContentIdentifier(); - + /** * Return an array of bytes that can be used to uniquely identify this * resource variant when compared to other resource variants and could @@ -74,7 +74,7 @@ public interface IResourceVariant { * @return the bytes that uniquely identify this resource variant */ public byte[] asBytes(); - + /** * Returns whether the remote resource is equal to the provided object. * @param object the object to be compared diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantComparator.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantComparator.java index c7845f07a..46533428b 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantComparator.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantComparator.java @@ -13,36 +13,36 @@ package org.eclipse.team.core.variants; import org.eclipse.core.resources.IResource; /** - * An <code>IResourceVariantComparator</code> is provided by a <code>Subscriber</code> + * An <code>IResourceVariantComparator</code> is provided by a <code>Subscriber</code> * and used by a <code>SyncInfo</code> to calculate the sync * state of the workspace resources. Subscribers should provide a criteria * best suited for their environment. For example, an FTP subscriber could choose to use file * size or file timestamps as comparison criteria whereas a CVS workspace subscriber would * use file revision numbers. - * + * * @see org.eclipse.team.core.synchronize.SyncInfo * @see org.eclipse.team.core.subscribers.Subscriber * @since 3.0 */ public interface IResourceVariantComparator { - + /** * Returns <code>true</code> if the local resource * matches the remote resource based on this criteria and <code>false</code> * otherwise. Comparing should be fast and based on cached information. - * + * * @param local the local resource to be compared * @param remote the remote resources to be compared * @return <code>true</code> if local and remote are equal based on this criteria and <code>false</code> * otherwise. */ public boolean compare(IResource local, IResourceVariant remote); - + /** * Returns <code>true</code> if the base resource * matches the remote resource based on this criteria and <code>false</code> * otherwise. Comparing should be fast and based on cached information. - * + * * @param base the base resource to be compared * @param remote the remote resources to be compared * @return <code>true</code> if base and remote are equal based on this criteria and <code>false</code> diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantTree.java index dd837b223..4c46c4d04 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantTree.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/IResourceVariantTree.java @@ -16,7 +16,7 @@ import org.eclipse.team.core.TeamException; /** * A handle that provides access to locally cached resource variants that * represent a resource line-up such as a project version or branch. - * + * * @see AbstractResourceVariantTree * @see ResourceVariantTree * @since 3.0 @@ -26,14 +26,14 @@ import org.eclipse.team.core.TeamException; * {@link ResourceVariantTree}. */ public interface IResourceVariantTree { - + /** * Returns the list of root resources for which this tree may have resource * variants. * @return the list of root resources. */ public abstract IResource[] roots(); - + /** * Returns the members of the local resource that have resource variants in this tree. * The members may or may not exist locally. The resource variants corresponding to the @@ -43,7 +43,7 @@ public interface IResourceVariantTree { * @throws TeamException */ public abstract IResource[] members(IResource resource) throws TeamException; - + /** * Return the resource variant corresponding to the local resource. Return * <code>null</code> if there is no variant for the resource. @@ -52,7 +52,7 @@ public interface IResourceVariantTree { * @throws TeamException */ public abstract IResourceVariant getResourceVariant(IResource resource) throws TeamException; - + /** * Return whether the local resource has a variant in this tree. * @param resource the local resource @@ -60,9 +60,9 @@ public interface IResourceVariantTree { * @throws TeamException */ public boolean hasResourceVariant(IResource resource) throws TeamException; - + /** - * Refreshes the resource variant tree for the specified resources and possibly + * Refreshes the resource variant tree for the specified resources and possibly * their descendants, depending on the depth. * @param resources the resources whose variants should be refreshed * @param depth the depth of the refresh (one of <code>IResource.DEPTH_ZERO</code>, @@ -73,7 +73,7 @@ public interface IResourceVariantTree { * @throws TeamException */ public IResource[] refresh( - IResource[] resources, + IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException; @@ -83,7 +83,7 @@ public interface IResourceVariantTree { * @param resource the resource * @param depth the flush depth (one of <code>IResource.DEPTH_ZERO</code>, * <code>IResource.DEPTH_ONE</code>, or <code>IResource.DEPTH_INFINITE</code>) - * @throws TeamException + * @throws TeamException */ public void flushVariants(IResource resource, int depth) throws TeamException; } diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ISynchronizerChangeListener.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ISynchronizerChangeListener.java index 218256247..559c7ffcc 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ISynchronizerChangeListener.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ISynchronizerChangeListener.java @@ -19,7 +19,7 @@ import org.eclipse.core.resources.IResource; * @since 3.0 */ public interface ISynchronizerChangeListener { - + /** * Notification of synchronization state changes for the given resources. * Clients must query the <code>ThreeWaySynchronizer</code> that generated diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java index 3ef3b4c12..9f38007aa 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/PersistantResourceVariantByteStore.java @@ -21,16 +21,16 @@ import org.eclipse.team.core.TeamException; * A <code>ResourceVariantByteStore</code> that caches the variant bytes using * the <code>org.eclipse.core.resources.ISynchronizer</code> so that the tree is * cached across workbench invocations. - * + * * @since 3.0 * @noextend This class is not intended to be subclassed by clients. */ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore { private static final byte[] NO_REMOTE = new byte[0]; - + private QualifiedName syncName; - + /** * Create a persistent tree that uses the given qualified name * as the key in the <code>org.eclipse.core.resources.ISynchronizer</code>. @@ -42,7 +42,7 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore syncName = name; getSynchronizer().add(syncName); } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.ResourceVariantByteStore#dispose() */ @@ -69,7 +69,7 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore } return syncBytes; } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.ResourceVariantByteStore#setBytes(org.eclipse.core.resources.IResource, byte[]) */ @@ -101,7 +101,7 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore } return false; } - + /** * Return whether the resource variant state for this resource is known. * This is used to differentiate the case where a resource variant has never been fetched @@ -114,9 +114,9 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore public boolean isVariantKnown(IResource resource) throws TeamException { return internalGetSyncBytes(resource) != null; } - + /** - * This method should be invoked by a client to indicate that it is known that + * This method should be invoked by a client to indicate that it is known that * there is no remote resource associated with the local resource. After this method * is invoked, <code>isVariantKnown(resource)</code> will return <code>true</code> and * <code>getBytes(resource)</code> will return <code>null</code>. @@ -132,7 +132,7 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore public IResource[] members(IResource resource) throws TeamException { if(resource.getType() == IResource.FILE) { return new IResource[0]; - } + } try { // Filter and return only resources that have sync bytes in the cache. IResource[] members = ((IContainer)resource).members(true /* include phantoms */); @@ -152,7 +152,7 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore private ISynchronizer getSynchronizer() { return ResourcesPlugin.getWorkspace().getSynchronizer(); } - + private byte[] internalGetSyncBytes(IResource resource) throws TeamException { try { return getSynchronizer().getSyncInfo(getSyncName(), resource); @@ -160,7 +160,7 @@ public class PersistantResourceVariantByteStore extends ResourceVariantByteStore throw TeamException.asTeamException(e); } } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.ResourceVariantByteStore#run(org.eclipse.core.resources.IWorkspaceRunnable, org.eclipse.core.runtime.IProgressMonitor) */ diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantByteStore.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantByteStore.java index 49796a8bc..f94840b45 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantByteStore.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantByteStore.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -23,12 +23,12 @@ import org.eclipse.team.core.TeamException; * responsibility of the client of this API to cache enough bytes to meaningfully identify * a resource variant (and possibly create an {@link IResourceVariant} handle from them). * <p> - * The bytes for a resource variant are accessed using the local <code>IResource</code> handle - * that corresponds to the resource variant (using the <code>getBytes</code> method). + * The bytes for a resource variant are accessed using the local <code>IResource</code> handle + * that corresponds to the resource variant (using the <code>getBytes</code> method). * The potential children of a resource variant are also accessed - * by using the local handle that corresponds to the resource variant + * by using the local handle that corresponds to the resource variant * (using the <code>members</code> method). - * + * * @since 3.0 */ public abstract class ResourceVariantByteStore { @@ -37,7 +37,7 @@ public abstract class ResourceVariantByteStore { * Dispose of any cached sync bytes when this cache is no longer needed. */ public abstract void dispose(); - + /** * Return the bytes for the variant corresponding the given local resource. * A return value of <code>null</code> means that no bytes have been stored @@ -49,12 +49,12 @@ public abstract class ResourceVariantByteStore { * @throws TeamException */ public abstract byte[] getBytes(IResource resource) throws TeamException; - + /** - * Set the bytes for the variant corresponding the given local resource. - * The bytes should never be <code>null</code>. If it is known that the remote - * does not exist, <code>deleteBytes(IResource)</code> should be used instead. - * If the sync bytes for the remote are stale and should be removed, + * Set the bytes for the variant corresponding the given local resource. + * The bytes should never be <code>null</code>. If it is known that the remote + * does not exist, <code>deleteBytes(IResource)</code> should be used instead. + * If the sync bytes for the remote are stale and should be removed, * <code>flushBytes(IResouce, int)</code> should be called. * @param resource the local resource * @param bytes the bytes that represent the resource's variant @@ -62,11 +62,11 @@ public abstract class ResourceVariantByteStore { * @throws TeamException */ public abstract boolean setBytes(IResource resource, byte[] bytes) throws TeamException; - + /** - * Remove the bytes from the tree for the resource variants corresponding to the + * Remove the bytes from the tree for the resource variants corresponding to the * given local resource and its descendants to the given depth. - * After the bytes are removed, <code>getBytes(resource)</code> will + * After the bytes are removed, <code>getBytes(resource)</code> will * return <code>null</code> for the affected resources. * @param resource the local resource * @param depth the depth of the operation (one of <code>IResource.DEPTH_ZERO</code>, @@ -75,9 +75,9 @@ public abstract class ResourceVariantByteStore { * @throws TeamException */ public abstract boolean flushBytes(IResource resource, int depth) throws TeamException; - + /** - * Method called to indicate that it is known that there is no variant associated + * Method called to indicate that it is known that there is no variant associated * with the local resource. Subclasses may handle this information in different ways. * The <code>flush(IResource, int)</code> method should be used in the cases * where a client wishes to remove bytes for other reason. @@ -85,14 +85,14 @@ public abstract class ResourceVariantByteStore { * @return <code>true</code> if this changes the bytes for the variant */ public abstract boolean deleteBytes(IResource resource) throws TeamException; - + /** * Return the children of the given resource that have resource variants in this tree. * @param resource the parent resource * @return the members who have resource variants in this tree. */ public abstract IResource[] members(IResource resource) throws TeamException; - + /** * Helper method to compare two byte arrays for equality * @param syncBytes1 the first byte array or <code>null</code> @@ -121,7 +121,7 @@ public abstract class ResourceVariantByteStore { * @param runnable the action to perform * @param monitor a progress monitor. * @exception TeamException if the operation failed. - * @exception OperationCanceledException if the operation is canceled. + * @exception OperationCanceledException if the operation is canceled. */ public void run(IResource root, IWorkspaceRunnable runnable, IProgressMonitor monitor) throws TeamException { try { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java index 82389438b..12cf6faeb 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTree.java @@ -19,14 +19,14 @@ import org.eclipse.team.core.TeamException; /** * Provides caching for a {@link AbstractResourceVariantTree} using a * {@link ResourceVariantByteStore}. - * + * * @see IResourceVariantTree * @see AbstractResourceVariantTree * @see ResourceVariantByteStore * @since 3.0 */ public abstract class ResourceVariantTree extends AbstractResourceVariantTree { - + private ResourceVariantByteStore store; /** @@ -37,28 +37,28 @@ public abstract class ResourceVariantTree extends AbstractResourceVariantTree { protected ResourceVariantTree(ResourceVariantByteStore store) { this.store = store; } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.IResourceVariantTree#members(org.eclipse.core.resources.IResource) */ public IResource[] members(IResource resource) throws TeamException { return getByteStore().members(resource); } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.IResourceVariantTree#hasResourceVariant(org.eclipse.core.resources.IResource) */ public boolean hasResourceVariant(IResource resource) throws TeamException { return getByteStore().getBytes(resource) != null; } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.IResourceVariantTree#flushVariants(org.eclipse.core.resources.IResource, int) */ public void flushVariants(IResource resource, int depth) throws TeamException { getByteStore().flushBytes(resource, depth); } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#setVariant(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant) */ @@ -73,22 +73,22 @@ public abstract class ResourceVariantTree extends AbstractResourceVariantTree { } return changed; } - + /** * Get the byte store that is used to cache the serialization bytes * for the resource variants of this tree. A byte store is used * to reduce the memory footprint of the tree. * <p> * This method is not intended to be overridden by subclasses. - * + * * @return the resource variant tree that is being refreshed. */ protected ResourceVariantByteStore getByteStore() { return store; } - + /** - * Get the bytes to be stored in the <code>ResourceVariantByteStore</code> + * Get the bytes to be stored in the <code>ResourceVariantByteStore</code> * from the given resource variant. By default, the <code>IResourceVariant#asBytes()</code> * method is used to get the bytes. * @param local the local resource @@ -99,7 +99,7 @@ public abstract class ResourceVariantTree extends AbstractResourceVariantTree { if (remote == null) return null; return remote.asBytes(); } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#collectChanges(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant, int, org.eclipse.core.runtime.IProgressMonitor) */ diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java index 91220d35c..7c7c64e35 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ResourceVariantTreeSubscriber.java @@ -26,7 +26,7 @@ import org.eclipse.team.internal.core.*; * A specialization of Subscriber that uses <code>IResourceVariantTree</code> objects * to manage the base (for three-way) and remote trees. Refreshing and obtaining the subscriber * members and resource variants is delegated to the resource variant trees. - * + * * @since 3.0 */ public abstract class ResourceVariantTreeSubscriber extends Subscriber { @@ -67,7 +67,7 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber { public IResource[] members(IResource resource) throws TeamException { if(resource.getType() == IResource.FILE) { return new IResource[0]; - } + } try { Set allMembers = new HashSet(); try { @@ -121,7 +121,7 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber { } } finally { monitor.done(); - } + } if (!errors.isEmpty()) { int numSuccess = resources.length - errors.size() - cancels.size(); if (!cancels.isEmpty()) { @@ -141,16 +141,16 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber { } }); } - throw new TeamException(new MultiStatus(TeamPlugin.ID, 0, - (IStatus[]) errors.toArray(new IStatus[errors.size()]), - NLS.bind(Messages.ResourceVariantTreeSubscriber_1, (new Object[] {getName(), Integer.toString(numSuccess), Integer.toString(resources.length)})), null)); + throw new TeamException(new MultiStatus(TeamPlugin.ID, 0, + (IStatus[]) errors.toArray(new IStatus[errors.size()]), + NLS.bind(Messages.ResourceVariantTreeSubscriber_1, (new Object[] {getName(), Integer.toString(numSuccess), Integer.toString(resources.length)})), null)); } if (!cancels.isEmpty()) { throw new OperationCanceledException( ((IStatus) cancels.get(0)).getMessage()); } } - + /** * Return the base resource variant tree. */ @@ -160,7 +160,7 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber { * Return the remote resource variant tree. */ protected abstract IResourceVariantTree getRemoteTree(); - + private IStatus refresh(IResource resource, int depth, IProgressMonitor monitor) { monitor = Policy.monitorFor(monitor); try { @@ -176,7 +176,7 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber { fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, changedResources)); return Status.OK_STATUS; } catch (TeamException e) { - return new TeamStatus(IStatus.ERROR, TeamPlugin.ID, 0, NLS.bind(Messages.ResourceVariantTreeSubscriber_2, new String[] { resource.getFullPath().toString(), e.getMessage() }), e, resource); + return new TeamStatus(IStatus.ERROR, TeamPlugin.ID, 0, NLS.bind(Messages.ResourceVariantTreeSubscriber_2, new String[] { resource.getFullPath().toString(), e.getMessage() }), e, resource); } catch (OperationCanceledException e) { return new TeamStatus(IStatus.CANCEL, TeamPlugin.ID, 0, NLS.bind( Messages.ResourceVariantTreeSubscriber_4, @@ -184,9 +184,9 @@ public abstract class ResourceVariantTreeSubscriber extends Subscriber { resource); } finally { monitor.done(); - } + } } - + private IResource[] internalMembers(IResourceVariantTree tree, IResource resource) throws TeamException, CoreException { // Filter and return only phantoms associated with the remote synchronizer. IResource[] members; diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/SessionResourceVariantByteStore.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/SessionResourceVariantByteStore.java index 48d32f574..ddc2bae32 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/SessionResourceVariantByteStore.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/SessionResourceVariantByteStore.java @@ -20,7 +20,7 @@ import org.eclipse.team.core.TeamException; /** * A <code>ResourceVariantByteStore</code> that caches the variant bytes in * memory and does not persist them over workbench invocations. - * + * * @since 3.0 * @noextend This class is not intended to be subclassed by clients. */ @@ -28,7 +28,7 @@ public class SessionResourceVariantByteStore extends ResourceVariantByteStore { private static final byte[] NO_REMOTE = new byte[0]; private Map membersCache = new HashMap(); - + private Map syncBytesCache = new HashMap(); /* (non-Javadoc) @@ -37,7 +37,7 @@ public class SessionResourceVariantByteStore extends ResourceVariantByteStore { public boolean deleteBytes(IResource resource) throws TeamException { return flushBytes(resource, IResource.DEPTH_ZERO); } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.ResourceVariantByteStore#dispose() */ @@ -106,11 +106,11 @@ public class SessionResourceVariantByteStore extends ResourceVariantByteStore { internalSetSyncInfo(resource, bytes); return true; } - + private Map getSyncBytesCache() { return syncBytesCache; } - + private void internalAddToParent(IResource resource) { IContainer parent = resource.getParent(); if (parent == null) return; @@ -121,7 +121,7 @@ public class SessionResourceVariantByteStore extends ResourceVariantByteStore { } members.add(resource); } - + private byte[] internalGetSyncBytes(IResource resource) { return (byte[])getSyncBytesCache().get(resource); } @@ -136,7 +136,7 @@ public class SessionResourceVariantByteStore extends ResourceVariantByteStore { } } } - + private void internalSetSyncInfo(IResource resource, byte[] bytes) { getSyncBytesCache().put(resource, bytes); internalAddToParent(resource); diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java index 1a9992001..87279ebc9 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayRemoteTree.java @@ -20,9 +20,9 @@ import org.eclipse.team.core.TeamException; * A resource variant tree that caches and obtains its bytes from the remote slot * in a three-way synchronizer. Clients must subclass to provide remote resource * variant refresh functionality. - * + * * @see ThreeWaySubscriber - * + * * @since 3.0 */ public abstract class ThreeWayRemoteTree extends ResourceVariantTree { @@ -30,7 +30,7 @@ public abstract class ThreeWayRemoteTree extends ResourceVariantTree { private ThreeWaySubscriber subscriber; /* - * A resource variant byte store that accesses the remote bytes + * A resource variant byte store that accesses the remote bytes * from a three-way synchronizer. Both access and modification * are supported. */ @@ -66,7 +66,7 @@ public abstract class ThreeWayRemoteTree extends ResourceVariantTree { return synchronizer; } } - + /** * Create a remote resource variant tree that stores and obtains * it's bytes from the remote slot of the synchronizer of the @@ -77,14 +77,14 @@ public abstract class ThreeWayRemoteTree extends ResourceVariantTree { super(new RemoteResourceVariantByteStore(subscriber.getSynchronizer())); this.subscriber = subscriber; } - + /* (non-Javadoc) * @see org.eclipse.team.internal.core.subscribers.caches.IResourceVariantTree#roots() */ public IResource[] roots() { return getSubscriber().roots(); } - + /* (non-Javadoc) * @see org.eclipse.team.internal.core.subscribers.caches.IResourceVariantTree#getResourceVariant(org.eclipse.core.resources.IResource) */ @@ -99,7 +99,7 @@ public abstract class ThreeWayRemoteTree extends ResourceVariantTree { protected ThreeWaySubscriber getSubscriber() { return subscriber; } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.AbstractResourceVariantTree#collectChanges(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant, int, org.eclipse.core.runtime.IProgressMonitor) */ diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java index 3324fabeb..0382fcfea 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWayResourceComparator.java @@ -20,13 +20,13 @@ import org.eclipse.team.internal.core.TeamPlugin; * is determined using the local modification state and the remote state * is determined by comparing the base bytes to the remote bytes obtained * from the synchronizer. - * + * * @since 3.0 */ public class ThreeWayResourceComparator implements IResourceVariantComparator { - + private ThreeWaySynchronizer synchronizer; - + /** * Create a three-way resource comparator that uses the <code>ThreeWaySynchronizer</code> * to compare a local resource to a resource variant. @@ -35,7 +35,7 @@ public class ThreeWayResourceComparator implements IResourceVariantComparator { public ThreeWayResourceComparator(ThreeWaySynchronizer synchronizer) { this.synchronizer = synchronizer; } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.IResourceVariantComparator#compare(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant) */ @@ -67,22 +67,22 @@ public class ThreeWayResourceComparator implements IResourceVariantComparator { byte[] bytes2 = getBytes(remote); return equals(bytes1, bytes2); } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.IResourceVariantComparator#isThreeWay() */ public boolean isThreeWay() { return true; } - + private ThreeWaySynchronizer getSynchronizer() { return synchronizer; } - + private byte[] getBytes(IResourceVariant remote) { return remote.asBytes(); } - + private boolean equals(byte[] syncBytes, byte[] oldBytes) { if (syncBytes.length != oldBytes.length) return false; for (int i = 0; i < oldBytes.length; i++) { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySubscriber.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySubscriber.java index 0058eced7..87d200e39 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySubscriber.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySubscriber.java @@ -26,20 +26,20 @@ import org.eclipse.team.internal.core.subscribers.ThreeWayBaseTree; * provide a subclass of <code>ThreeWayRemoteTree</code> and a method * to create resource variant handles from the bytes cached in the * <code>ThreeWaySynchronizer</code>. - * + * * @see ThreeWaySynchronizer * @see ThreeWayRemoteTree * @see CachedResourceVariant - * + * * @since 3.0 */ public abstract class ThreeWaySubscriber extends ResourceVariantTreeSubscriber implements ISynchronizerChangeListener { - + private ThreeWayResourceComparator comparator; private ThreeWayBaseTree baseTree; private ThreeWayRemoteTree remoteTree; private ThreeWaySynchronizer synchronizer; - + /** * Create a three-way subscriber that uses the given synchronizer * to manage the synchronization state of local resources @@ -51,14 +51,14 @@ public abstract class ThreeWaySubscriber extends ResourceVariantTreeSubscriber i baseTree = new ThreeWayBaseTree(this); getSynchronizer().addListener(this); } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.ResourceVariantTreeSubscriber#getBaseTree() */ protected final IResourceVariantTree getBaseTree() { return baseTree; } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.ResourceVariantTreeSubscriber#getRemoteTree() */ @@ -78,14 +78,14 @@ public abstract class ThreeWaySubscriber extends ResourceVariantTreeSubscriber i } return comparator; } - + /* (non-Javadoc) * @see org.eclipse.team.core.variants.ISynchronizerChangeListener#syncStateChanged(org.eclipse.core.resources.IResource[]) */ public void syncStateChanged(IResource[] resources) { fireTeamResourceChange(SubscriberChangeEvent.asSyncChangedDeltas(this, resources)); } - + /** * Returns <code>false</code> for resources that are not children * of a subscriber root, are ignored by the subscriber's synchronizer @@ -99,7 +99,7 @@ public abstract class ThreeWaySubscriber extends ResourceVariantTreeSubscriber i if (Team.isIgnoredHint(resource)) return false; return true; } - + /** * Return the three-way synchronizer of this subscriber. * @return the three-way synchronizer of this subscriber. @@ -107,9 +107,9 @@ public abstract class ThreeWaySubscriber extends ResourceVariantTreeSubscriber i public ThreeWaySynchronizer getSynchronizer() { return synchronizer; } - + /** - * Create the resource variant for the given local resource from the + * Create the resource variant for the given local resource from the * given bytes. The bytes are those that were previously returned * from a call to <code>IResourceVariant#asBytes()</code>. * @param resource the local resource @@ -118,7 +118,7 @@ public abstract class ThreeWaySubscriber extends ResourceVariantTreeSubscriber i * @throws TeamException */ public abstract IResourceVariant getResourceVariant(IResource resource, byte[] bytes) throws TeamException; - + /** * Create the three-way remote tree which provides access to the * remote bytes in the three-way synchronizer. This method is invoked @@ -127,7 +127,7 @@ public abstract class ThreeWaySubscriber extends ResourceVariantTreeSubscriber i * @return the remote tree */ protected abstract ThreeWayRemoteTree createRemoteTree(); - + /** * Convenience method that can be used by subclasses to notify listeners * when a root is added or removed from the subscriber. The added @@ -144,7 +144,7 @@ public abstract class ThreeWaySubscriber extends ResourceVariantTreeSubscriber i rootRemoved(resource); } } - + private void rootAdded(IResource resource) { SubscriberChangeEvent delta = new SubscriberChangeEvent(this, ISubscriberChangeEvent.ROOT_ADDED, resource); fireTeamResourceChange(new SubscriberChangeEvent[] { delta }); @@ -159,7 +159,7 @@ public abstract class ThreeWaySubscriber extends ResourceVariantTreeSubscriber i SubscriberChangeEvent delta = new SubscriberChangeEvent(this, ISubscriberChangeEvent.ROOT_REMOVED, resource); fireTeamResourceChange(new SubscriberChangeEvent[] { delta }); } - + private boolean isChildOfRoot(IResource resource) { IResource[] roots = roots(); IPath fullPath = resource.getFullPath(); diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java index 8d1cf448f..8bf860306 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/variants/ThreeWaySynchronizer.java @@ -23,7 +23,7 @@ import org.eclipse.team.internal.core.subscribers.BatchingLock.IFlushOperation; import org.eclipse.team.internal.core.subscribers.BatchingLock.ThreadInfo; /** - * This class manages the synchronization between local resources and their + * This class manages the synchronization between local resources and their * corresponding resource variants. It provides the following: * <ul> * <li>Three way synchronization (set base, set remote, ignored) @@ -31,16 +31,16 @@ import org.eclipse.team.internal.core.subscribers.BatchingLock.ThreadInfo; * <li>Change events and event batching (run) * <li>Thread-safety * </ul> - * + * * @since 3.0 */ public class ThreeWaySynchronizer { - + private IFlushOperation flushOperation = new IFlushOperation() { /** * Callback which is invoked when the batching resource lock is released * or when a flush is requested (see beginBatching(IResource)). - * + * * @see BatchingLock#flush(IProgressMonitor) */ public void flush(ThreadInfo info, IProgressMonitor monitor) @@ -52,22 +52,22 @@ public class ThreeWaySynchronizer { }; private static final byte[] IGNORED_BYTES = "i".getBytes(); //$NON-NLS-1$ - + private ILock lock = Job.getJobManager().newLock(); private BatchingLock batchingLock = new BatchingLock(); private ResourceVariantByteStore cache; private Set listeners = new HashSet(); - + /** * Create a three-way synchronizer that uses a persistent - * byte store with the given qualified name as its unique + * byte store with the given qualified name as its unique * identifier. * @param name the unique identifier for the persistent store */ public ThreeWaySynchronizer(QualifiedName name) { this(new PersistantResourceVariantByteStore(name)); } - + /** * Create a three-way synchronizer that uses the given byte store * as its underlying byte cache. @@ -80,14 +80,14 @@ public class ThreeWaySynchronizer { /** * Adds a listener to this synchronizer. Listeners will be notified * when the synchronization state of a resource changes. Listeners - * are not notified when files are modified locally. Clients can + * are not notified when files are modified locally. Clients can * make use of the <code>IResource</code> delta mechanism if they * need to know about local modifications. * Has no effect if an identical listener is already registered. * <p> - * Team resource change listeners are informed about state changes + * Team resource change listeners are informed about state changes * that affect the resources supervised by this subscriber.</p> - * + * * @param listener a synchronizer change listener */ public void addListener(ISynchronizerChangeListener listener) { @@ -99,21 +99,21 @@ public class ThreeWaySynchronizer { /** * Removes a listener previously registered with this synchronizer. * Has no effect if an identical listener is not registered. - * + * * @param listener a synchronizer change listener - */ + */ public void removeListener(ISynchronizerChangeListener listener) { synchronized (listeners) { listeners.remove(listener); } } - + /** - * Return the base bytes that are cached for the given resource + * Return the base bytes that are cached for the given resource * or <code>null</code> if no base is cached. The returned bytes - * should uniquely identify the resource variant that is the base + * should uniquely identify the resource variant that is the base * for the given local resource. - * + * * @param resource the resource * @return the base bytes cached with the resource or <code>null</code> * @throws TeamException @@ -133,13 +133,13 @@ public class ThreeWaySynchronizer { /** * Set the base bytes for the given resource. The provided bytes - * should encode enough information to uniquely identify - * (and possibly recreate) the resource variant that is the base + * should encode enough information to uniquely identify + * (and possibly recreate) the resource variant that is the base * for the given local resource. In essence, setting the base * bytes is equivalent to marking the file as in-sync. As such, - * setting the base bytes will also set the remote bytes and mark + * setting the base bytes will also set the remote bytes and mark * the file as clean (i.e. having no outgoing changes). - * + * * @param resource the resource * @param baseBytes the base bytes that identify the base resource variant * @throws TeamException @@ -183,13 +183,13 @@ public class ThreeWaySynchronizer { (getLocalTimestamp(resource) != resource.getModificationStamp()) || (getBaseBytes(resource) != null && !resource.exists())); } - + /** - * Return the remote bytes that are cached for the given resource + * Return the remote bytes that are cached for the given resource * or <code>null</code> if no remote is cached. The returned bytes - * should uniquely identify the resource variant that is the remote + * should uniquely identify the resource variant that is the remote * for the given local resource. - * + * * @param resource the resource * @return the remote bytes cached with the resource or <code>null</code> * @throws TeamException @@ -206,15 +206,15 @@ public class ThreeWaySynchronizer { endOperation(); } } - + /** * Set the remote bytes for the given resource. The provided bytes - * should encode enough information to uniquely identify - * (and possibly recreate) the resource variant that is the remote + * should encode enough information to uniquely identify + * (and possibly recreate) the resource variant that is the remote * for the given local resource. If the remote for a resource - * no longer exists, <code>removeRemoteBytes(IResource)</code> + * no longer exists, <code>removeRemoteBytes(IResource)</code> * should be called. - * + * * @param resource the resource * @param remoteBytes the base bytes that identify the remote resource variant * @return <code>true</code> if the remote bytes changed as a result of the set @@ -273,7 +273,7 @@ public class ThreeWaySynchronizer { batchingLock.resourceChanged(resource); return true; } - return false; + return false; } finally { endOperation(); } @@ -281,17 +281,17 @@ public class ThreeWaySynchronizer { if (rule != null) endBatching(rule, null); } } - + /** * Return whether the given resource has sync bytes in the synchronizer. * @param resource the local resource * @return whether there are sync bytes cached for the local resources. - * @throws TeamException + * @throws TeamException */ public boolean hasSyncBytes(IResource resource) throws TeamException { return internalGetSyncBytes(resource) != null; } - + /** * Returns whether the resource has been marked as ignored * using <code>setIgnored(IResource)</code>. @@ -303,7 +303,7 @@ public class ThreeWaySynchronizer { byte[] bytes = cache.getBytes(resource); return (bytes != null && equals(bytes, IGNORED_BYTES)); } - + /** * Mark the resource as being ignored. Ignored resources * are not returned by the <code>members</code> method, @@ -317,7 +317,7 @@ public class ThreeWaySynchronizer { } /** - * Return the members of the local resource that either have sync bytes + * Return the members of the local resource that either have sync bytes * or exist locally and are not ignored. * @param resource the local resource * @return the children of the local resource that have cached sync bytes @@ -363,7 +363,7 @@ public class ThreeWaySynchronizer { beginOperation(); if (cache.flushBytes(resource, depth)) { batchingLock.resourceChanged(resource); - } + } } finally { endOperation(); } @@ -414,7 +414,7 @@ public class ThreeWaySynchronizer { }); } } - + /* * Return the cached sync bytes for the given resource. * The value <code>null</code> is returned if there is no @@ -425,26 +425,26 @@ public class ThreeWaySynchronizer { if (bytes != null && equals(bytes, IGNORED_BYTES)) return null; return bytes; } - + /* * Set the cached sync bytes */ private boolean internalSetSyncBytes(IResource resource, byte[] syncBytes) throws TeamException { return cache.setBytes(resource, syncBytes); } - + private byte[] getSlot(byte[] syncBytes, int i) { return SyncByteConverter.getSlot(syncBytes, i, false); } - + private byte[] setSlot(byte[] syncBytes, int i, byte[] insertBytes) throws TeamException { return SyncByteConverter.setSlot(syncBytes, i, insertBytes); } - + private byte[] toBytes(String[] slots) { return SyncByteConverter.toBytes(slots); } - + private long getLocalTimestamp(IResource resource) throws TeamException { try { beginOperation(); @@ -457,7 +457,7 @@ public class ThreeWaySynchronizer { endOperation(); } } - + private boolean equals(byte[] syncBytes, byte[] oldBytes) { if (syncBytes.length != oldBytes.length) return false; for (int i = 0; i < oldBytes.length; i++) { @@ -465,20 +465,20 @@ public class ThreeWaySynchronizer { } return true; } - + /* * Begin an access to the internal data structures of the synchronizer */ private void beginOperation() { // Do not try to acquire the lock if the resources tree is locked // The reason for this is that during the resource delta phase (i.e. when the tree is locked) - // the workspace lock is held. If we obtain our lock, there is + // the workspace lock is held. If we obtain our lock, there is // a chance of deadlock. It is OK if we don't as we are still protected // by scheduling rules and the workspace lock. if (ResourcesPlugin.getWorkspace().isTreeLocked()) return; lock.acquire(); } - + /* * End an access to the internal data structures of the synchronizer */ @@ -487,9 +487,9 @@ public class ThreeWaySynchronizer { if (ResourcesPlugin.getWorkspace().isTreeLocked()) return; lock.release(); } - + /* - * Begins a batch of operations in order to batch event changes. + * Begins a batch of operations in order to batch event changes. * The provided scheduling rule indicates the resources * that the resources affected by the operation while the returned scheduling rule * is the rule obtained by the lock. It may differ from the provided rule. @@ -497,7 +497,7 @@ public class ThreeWaySynchronizer { private ISchedulingRule beginBatching(ISchedulingRule resourceRule, IProgressMonitor monitor) { return batchingLock.acquire(resourceRule, flushOperation /* IFlushOperation */, monitor); } - + /* * Ends a batch of operations. The provided rule must be the one that was returned * by the corresponding call to beginBatching. |