org.eclipse.team.core_3.6.0.I20110525-0800

rce[] internalGetOutOfSyncDescendants(IContainer resource)
  {
    Set allChildren = (Set)parents.get(resource.getFullPath());
    if (allChildren == null) {
      return new IResource[0];
    }
    return (IResource[])allChildren.toArray(new IResource[allChildren.size()]);
  }
  
  private synchronized IResource[] internalMembers(IWorkspaceRoot root)
  {
    Set possibleChildren = parents.keySet();
    Set children = new HashSet();
    for (Iterator it = possibleChildren.iterator(); it.hasNext();)
    {
      Object next = it.next();
      IResource element = root.findMember((IPath)next);
      if (element != null) {
        children.add(element.getProject());
      }
    }
    return (IResource[])children.toArray(new IResource[children.size()]);
  }
  
  public synchronized IResource[] members(IResource resource)
  {
    if (resource.getType() == 1) {
      return new IResource[0];
    }
    IContainer parent = (IContainer)resource;
    if (parent.getType() == 8) {
      return internalMembers((IWorkspaceRoot)parent);
    }
    Set children = new HashSet();
    IPath path = parent.getFullPath();
    Set possibleChildren = (Set)parents.get(path);
    if (possibleChildren != null) {
      for (Iterator it = possibleChildren.iterator(); it.hasNext();)
      {
        Object next = it.next();
        IResource element = (IResource)next;
        IPath childPath = element.getFullPath();
        IResource modelObject = null;
        if (childPath.segmentCount() == path.segmentCount() + 1)
        {
          modelObject = element;
        }
        else if (childPath.segmentCount() > path.segmentCount())
        {
          IContainer childFolder = parent.getFolder(new Path(null, childPath.segment(path.segmentCount())));
          modelObject = childFolder;
        }
        if (modelObject != null) {
          children.add(modelObject);
        }
      }
    }
    return (IResource[])children.toArray(new IResource[children.size()]);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.synchronize.SyncInfoTree
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.variants;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.core.Policy;
import org.eclipse.team.internal.core.TeamPlugin;

public abstract class AbstractResourceVariantTree
  implements IResourceVariantTree
{
  public IResource[] refresh(IResource[] resources, int depth, IProgressMonitor monitor)
    throws TeamException
  {
    List changedResources = new ArrayList();
    monitor.beginTask(null, 100 * resources.length);
    for (int i = 0; i < resources.length; i++)
    {
      IResource resource = resources[i];
      IResource[] changed = refresh(resource, depth, Policy.subMonitorFor(monitor, 100));
      changedResources.addAll(Arrays.asList(changed));
    }
    monitor.done();
    return (IResource[])changedResources.toArray(new IResource[changedResources.size()]);
  }
  
  /* Error */
  protected IResource[] refresh(IResource resource, int depth, IProgressMonitor monitor)
    throws TeamException
  {
    // Byte code:
    //   0: aconst_null
    //   1: checkcast 105	[Lorg/eclipse/core/resources/IResource;
    //   4: astore 4
    //   6: aload_3
    //   7: aconst_null
    //   8: bipush 100
    //   10: invokeinterface 264 3 0
    //   15: aload_3
    //   16: getstatic 216	org/eclipse/team/internal/core/Messages:SynchronizationCacheRefreshOperation_0	Ljava/lang/String;
    //   19: iconst_1
    //   20: anewarray 107	java/lang/String
    //   23: dup
    //   24: iconst_0
    //   25: aload_1
    //   26: invokeinterface 258 1 0
    //   31: invokeinterface 260 1 0
    //   36: invokeinterface 259 1 0
    //   41: aastore
    //   42: invokestatic 225	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   45: invokeinterface 263 2 0
    //   50: aload_0
    //   51: aload_1
    //   52: iload_2
    //   53: aload_3
    //   54: bipush 70
    //   56: invokestatic 238	org/eclipse/team/internal/core/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   59: invokevirtual 231	org/eclipse/team/core/variants/AbstractResourceVariantTree:fetchVariant	(Lorg/eclipse/core/resources/IResource;ILorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/team/core/variants/IResourceVariant;
    //   62: astore 5
    //   64: aload_3
    //   65: bipush 30
    //   67: invokestatic 237	org/eclipse/team/internal/core/Policy:infiniteSubMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   70: astore 6
    //   72: aload 6
    //   74: aconst_null
    //   75: bipush 64
    //   77: invokeinterface 264 3 0
    //   82: aload_0
    //   83: aload_1
    //   84: aload 5
    //   86: iload_2
    //   87: aload 6
    //   89: bipush 64
    //   91: invokestatic 238	org/eclipse/team/internal/core/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   94: invokevirtual 234	org/eclipse/team/core/variants/AbstractResourceVariantTree:collectChanges	(Lorg/eclipse/core/resources/IResource;Lorg/eclipse/team/core/variants/IResourceVariant;ILorg/eclipse/core/runtime/IProgressMonitor;)[Lorg/eclipse/core/resources/IResource;
    //   97: astore 4
    //   99: goto +15 -> 114
    //   102: astore 7
    //   104: aload 6
    //   106: invokeinterface 261 1 0
    //   111: aload 7
    //   113: athrow
    //   114: aload 6
    //   116: invokeinterface 261 1 0
    //   121: goto +14 -> 135
    //   124: astore 8
    //   126: aload_3
    //   127: invokeinterface 261 1 0
    //   132: aload 8
    //   134: athrow
    //   135: aload_3
    //   136: invokeinterface 261 1 0
    //   141: aload 4
    //   143: ifnonnull +8 -> 151
    //   146: iconst_0
    //   147: anewarray 118	org/eclipse/core/resources/IResource
    //   150: areturn
    //   151: aload 4
    //   153: areturn
    // Line number table:
    //   Java source line #78	-> byte code offset #0
    //   Java source line #79	-> byte code offset #6
    //   Java source line #81	-> byte code offset #15
    //   Java source line #84	-> byte code offset #50
    //   Java source line #87	-> byte code offset #64
    //   Java source line #89	-> byte code offset #72
    //   Java source line #90	-> byte code offset #82
    //   Java source line #91	-> byte code offset #102
    //   Java source line #92	-> byte code offset #104
    //   Java source line #93	-> byte code offset #111
    //   Java source line #92	-> byte code offset #114
    //   Java source line #94	-> byte code offset #124
    //   Java source line #95	-> byte code offset #126
    //   Java source line #96	-> byte code offset #132
    //   Java source line #95	-> byte code offset #135
    //   Java source line #97	-> byte code offset #141
    //   Java source line #98	-> byte code offset #151
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	154	0	this	AbstractResourceVariantTree
    //   0	154	1	resource	IResource
    //   0	154	2	depth	int
    //   0	154	3	monitor	IProgressMonitor
    //   4	148	4	changedResources	IResource[]
    //   62	23	5	tree	IResourceVariant
    //   70	45	6	sub	IProgressMonitor
    //   102	10	7	localObject1	Object
    //   124	9	8	localObject2	Object
    // Exception table:
    //   from	to	target	type
    //   72	102	102	finally
    //   15	124	124	finally
  }
  
  protected IResource[] collectChanges(IResource local, IResourceVariant remote, int depth, IProgressMonitor monitor)
    throws TeamException
  {
    List changedResources = new ArrayList();
    collectChanges(local, remote, changedResources, depth, monitor);
    return (IResource[])changedResources.toArray(new IResource[changedResources.size()]);
  }
  
  protected abstract IResourceVariant[] fetchMembers(IResourceVariant paramIResourceVariant, IProgressMonitor paramIProgressMonitor)
    throws TeamException;
  
  protected abstract IResourceVariant fetchVariant(IResource paramIResource, int paramInt, IProgressMonitor paramIProgressMonitor)
    throws TeamException;
  
  protected IResource[] collectedMembers(IResource local, IResource[] members)
    throws TeamException
  {
    return new IResource[0];
  }
  
  protected abstract boolean setVariant(IResource paramIResource, IResourceVariant paramIResourceVariant)
    throws TeamException;
  
  private void collectChanges(IResource local, IResourceVariant remote, Collection changedResources, int depth, IProgressMonitor monitor)
    throws TeamException
  {
    boolean changed = setVariant(local, remote);
    if (changed) {
      changedResources.add(local);
    }
    if (depth == 0) {
      return;
    }
    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 == 2 ? 2 : 0, 
        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
  {
    Map mergedResources = new HashMap();
    IResourceVariant[] remoteChildren;
    IResourceVariant[] remoteChildren;
    if (remote == null) {
      remoteChildren = new IResourceVariant[0];
    } else {
      remoteChildren = fetchMembers(remote, progress);
    }
    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++)
        {
          IResource localChild = localChildren[i];
          String name = localChild.getName();
          localSet.put(name, localChild);
          allSet.add(name);
        }
      }
      if (remoteChildren.length > 0)
      {
        remoteSet = new HashMap(10);
        for (int i = 0; i < remoteChildren.length; i++)
        {
          IResourceVariant remoteChild = remoteChildren[i];
          String name = remoteChild.getName();
          remoteSet.put(name, remoteChild);
          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)
        {
          Assert.isTrue(remoteChild != null);
          boolean isContainer = remoteChild.isContainer();
          localChild = getResourceChild(local, keyChildName, isContainer);
        }
        if (localChild == null) {
          TeamPlugin.log(4, NLS.bind("File {0} cannot be the parent of remote resource {1}", 
            new Object[] { local.getFullPath(), keyChildName }), null);
        } else {
          mergedResources.put(localChild, remoteChild);
        }
      }
    }
    return mergedResources;
  }
  
  private IResource getResourceChild(IResource parent, String childName, boolean isContainer)
  {
    if (parent.getType() == 1) {
      return null;
    }
    if (isContainer) {
      return ((IContainer)parent).getFolder(new Path(null, childName));
    }
    return ((IContainer)parent).getFile(new Path(null, childName));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.variants.AbstractResourceVariantTree
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.variants;

import java.io.IOException;
import java.io.InputStream;
import org.eclipse.core.resources.IEncodedStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.core.Messages;
import org.eclipse.team.internal.core.TeamPlugin;

class CachedResourceVariant$ResourceVariantStorage
  implements IEncodedStorage
{
  final CachedResourceVariant this$0;
  
  CachedResourceVariant$ResourceVariantStorage(CachedResourceVariant paramCachedResourceVariant)
  {
    this$0 = paramCachedResourceVariant;
  }
  
  public InputStream getContents()
    throws CoreException
  {
    if (!this$0.isContentsCached()) {
      throw new TeamException(NLS.bind(Messages.CachedResourceVariant_0, new String[] { this$0.getCachePath() }));
    }
    return this$0.getCachedContents();
  }
  
  public IPath getFullPath()
  {
    return this$0.getDisplayPath();
  }
  
  public String getName()
  {
    return this$0.getName();
  }
  
  public boolean isReadOnly()
  {
    return true;
  }
  
  public Object getAdapter(Class adapter)
  {
    return this$0.getAdapter(adapter);
  }
  
  public String getCharset()
    throws CoreException
  {
    InputStream contents = getContents();
    try
    {
      String charSet = TeamPlugin.getCharset(getName(), contents);
      return charSet;
    }
    catch (IOException e)
    {
      throw new TeamException(new Status(4, "org.eclipse.team.core", 381, NLS.bind(Messages.CachedResourceVariant_1, new String[] { getFullPath().toString() }), e));
    }
    finally
    {
      try
      {
        contents.close();
      }
      catch (IOException localIOException2) {}
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.variants.CachedResourceVariant.ResourceVariantStorage
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.variants;

import java.io.IOException;
import java.io.InputStream;
import org.eclipse.core.resources.IEncodedStorage;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.core.Messages;
import org.eclipse.team.internal.core.ResourceVariantCache;
import org.eclipse.team.internal.core.ResourceVariantCacheEntry;
import org.eclipse.team.internal.core.TeamPlugin;

public abstract class CachedResourceVariant
  extends PlatformObject
  implements IResourceVariant
{
  private IStorage storage;
  
  class ResourceVariantStorage
    implements IEncodedStorage
  {
    ResourceVariantStorage() {}
    
    public InputStream getContents()
      throws CoreException
    {
      if (!isContentsCached()) {
        throw new TeamException(NLS.bind(Messages.CachedResourceVariant_0, new String[] { getCachePath() }));
      }
      return getCachedContents();
    }
    
    public IPath getFullPath()
    {
      return getDisplayPath();
    }
    
    public String getName()
    {
      return CachedResourceVariant.this.getName();
    }
    
    public boolean isReadOnly()
    {
      return true;
    }
    
    public Object getAdapter(Class adapter)
    {
      return CachedResourceVariant.this.getAdapter(adapter);
    }
    
    public String getCharset()
      throws CoreException
    {
      InputStream contents = getContents();
      try
      {
        String charSet = TeamPlugin.getCharset(getName(), contents);
        return charSet;
      }
      catch (IOException e)
      {
        throw new TeamException(new Status(4, "org.eclipse.team.core", 381, NLS.bind(Messages.CachedResourceVariant_1, new String[] { getFullPath().toString() }), e));
      }
      finally
      {
        try
        {
          contents.close();
        }
        catch (IOException localIOException2) {}
      }
    }
  }
  
  public IStorage getStorage(IProgressMonitor monitor)
    throws TeamException
  {
    if (isContainer()) {
      return null;
    }
    ensureContentsCached(monitor);
    if (storage == null) {
      storage = new ResourceVariantStorage();
    }
    return storage;
  }
  
  private void ensureContentsCached(IProgressMonitor monitor)
    throws TeamException
  {
    if (!isContentsCached()) {
      fetchContents(monitor);
    }
  }
  
  protected abstract void fetchContents(IProgressMonitor paramIProgressMonitor)
    throws TeamException;
  
  protected void setContents(InputStream stream, IProgressMonitor monitor)
    throws TeamException
  {
    Assert.isTrue(!isContainer());
    if (!isHandleCached()) {
      cacheHandle();
    }
    getCacheEntry().setContents(stream, monitor);
  }
  
  private ResourceVariantCacheEntry getCacheEntry()
  {
    return getCache().getCacheEntry(getCachePath());
  }
  
  public boolean isContentsCached()
  {
    if ((isContainer()) || (!isHandleCached())) {
      return false;
    }
    ResourceVariantCacheEntry entry = getCache().getCacheEntry(getCachePath());
    return entry.getState() == 1;
  }
  
  protected InputStream getCachedContents()
    throws TeamException
  {
    if ((isContainer()) || (!isContentsCached())) {
      return null;
    }
    return getCache().getCacheEntry(getCachePath()).getContents();
  }
  
  protected boolean isHandleCached()
  {
    return getCache().hasEntry(getCachePath());
  }
  
  protected abstract String getCachePath();
  
  public long getSize()
  {
    if ((isContainer()) || (!isContentsCached())) {
      return 0L;
    }
    ResourceVariantCacheEntry entry = getCacheEntry();
    if ((entry == null) || (entry.getState() != 1)) {
      return 0L;
    }
    return entry.getSize();
  }
  
  private ResourceVariantCache getCache()
  {
    ResourceVariantCache.enableCaching(getCacheId());
    return ResourceVariantCache.getCache(getCacheId());
  }
  
  protected abstract String getCacheId();
  
  protected CachedResourceVariant getCachedHandle()
  {
    ResourceVariantCacheEntry entry = getCacheEntry();
    if (entry == null) {
      return null;
    }
    return entry.getResourceVariant();
  }
  
  protected void cacheHandle()
  {
    getCache().add(getCachePath(), this);
  }
  
  public IPath getDisplayPath()
  {
    return new Path(null, getCachePath());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.variants.CachedResourceVariant
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.variants;

import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;

public abstract interface IResourceVariant
{
  public abstract String getName();
  
  public abstract boolean isContainer();
  
  public abstract IStorage getStorage(IProgressMonitor paramIProgressMonitor)
    throws TeamException;
  
  public abstract String getContentIdentifier();
  
  public abstract byte[] asBytes();
  
  public abstract boolean equals(Object paramObject);
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.variants.IResourceVariant
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.variants;

import org.eclipse.core.resources.IResource;

public abstract interface IResourceVariantComparator
{
  public abstract boolean compare(IResource paramIResource, IResourceVariant paramIResourceVariant);
  
  public abstract boolean compare(IResourceVariant paramIResourceVariant1, IResourceVariant paramIResourceVariant2);
  
  public abstract boolean isThreeWay();
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.variants.IResourceVariantComparator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.variants;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;

public abstract interface IResourceVariantTree
{
  public abstract IResource[] roots();
  
  public abstract IResource[] members(IResource paramIResource)
    throws TeamException;
  
  public abstract IResourceVariant getResourceVariant(IResource paramIResource)
    throws TeamException;
  
  public abstract boolean hasResourceVariant(IResource paramIResource)
    throws TeamException;
  
  public abstract IResource[] refresh(IResource[] paramArrayOfIResource, int paramInt, IProgressMonitor paramIProgressMonitor)
    throws TeamException;
  
  public abstract void flushVariants(IResource paramIResource, int paramInt)
    throws TeamException;
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.variants.IResourceVariantTree
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.variants;

import org.eclipse.core.resources.IResource;

public abstract interface ISynchronizerChangeListener
{
  public abstract void syncStateChanged(IResource[] paramArrayOfIResource);
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.variants.ISynchronizerChangeListener
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.variants;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ISynchronizer;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.team.core.TeamException;

public class PersistantResourceVariantByteStore
  extends ResourceVariantByteStore
{
  private static final byte[] NO_REMOTE = new byte[0];
  private QualifiedName syncName;
  
  public PersistantResourceVariantByteStore(QualifiedName name)
  {
    syncName = name;
    getSynchronizer().add(syncName);
  }
  
  public void dispose()
  {
    getSynchronizer().remove(getSyncName());
  }
  
  public QualifiedName getSyncName()
  {
    return syncName;
  }
  
  public byte[] getBytes(IResource resource)
    throws TeamException
  {
    byte[] syncBytes = internalGetSyncBytes(resource);
    if ((syncBytes != null) && (equals(syncBytes, NO_REMOTE))) {
      return null;
    }
    return syncBytes;
  }
  
  public boolean setBytes(IResource resource, byte[] bytes)
    throws TeamException
  {
    Assert.isNotNull(bytes);
    byte[] oldBytes = internalGetSyncBytes(resource);
    if ((oldBytes != null) && (equals(oldBytes, bytes))) {
      return false;
    }
    try
    {
      getSynchronizer().setSyncInfo(getSyncName(), resource, bytes);
      return true;
    }
    catch (CoreException e)
    {
      throw TeamException.asTeamException(e);
    }
  }
  
  public boolean flushBytes(IResource resource, int depth)
    throws TeamException
  {
    if ((resource.exists()) || (resource.isPhantom())) {
      try
      {
        if ((depth != 0) || (internalGetSyncBytes(resource) != null))
        {
          getSynchronizer().flushSyncInfo(getSyncName(), resource, depth);
          return true;
        }
      }
      catch (CoreException e)
      {
        throw TeamException.asTeamException(e);
      }
    }
    return false;
  }
  
  public boolean isVariantKnown(IResource resource)
    throws TeamException
  {
    return internalGetSyncBytes(resource) != null;
  }
  
  public boolean deleteBytes(IResource resource)
    throws TeamException
  {
    return setBytes(resource, NO_REMOTE);
  }
  
  public IResource[] members(IResource resource)
    throws TeamException
  {
    if (resource.getType() == 1) {
      return new IResource[0];
    }
    try
    {
      IResource[] members = ((IContainer)resource).members(true);
      List filteredMembers = new ArrayList(members.length);
      for (int i = 0; i < members.length; i++)
      {
        IResource member = members[i];
        if (getBytes(member) != null) {
          filteredMembers.add(member);
        }
      }
      return (IResource[])filteredMembers.toArray(new IResource[filteredMembers.size()]);
    }
    catch (CoreException e)
    {
      throw TeamException.asTeamException(e);
    }
  }
  
  private ISynchronizer getSynchronizer()
  {
    return ResourcesPlugin.getWorkspace().getSynchronizer();
  }
  
  private byte[] internalGetSyncBytes(IResource resource)
    throws TeamException
  {
    try
    {
      return getSynchronizer().getSyncInfo(getSyncName(), resource);
    }
    catch (CoreException e)
    {
      throw TeamException.asTeamException(e);
    }
  }
  
  public void run(IResource root, IWorkspaceRunnable runnable, IProgressMonitor monitor)
    throws TeamException
  {
    try
    {
      ResourcesPlugin.getWorkspace().run(runnable, root, 0, monitor);
    }
    catch (CoreException e)
    {
      throw TeamException.asTeamException(e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.variants.PersistantResourceVariantByteStore
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.variants;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;

public abstract class ResourceVariantByteStore
{
  public abstract void dispose();
  
  public abstract byte[] getBytes(IResource paramIResource)
    throws TeamException;
  
  public abstract boolean setBytes(IResource paramIResource, byte[] paramArrayOfByte)
    throws TeamException;
  
  public abstract boolean flushBytes(IResource paramIResource, int paramInt)
    throws TeamException;
  
  public abstract boolean deleteBytes(IResource paramIResource)
    throws TeamException;
  
  public abstract IResource[] members(IResource paramIResource)
    throws TeamException;
  
  protected boolean equals(byte[] syncBytes1, byte[] syncBytes2)
  {
    if (syncBytes1 == null) {
      return syncBytes2 == null;
    }
    if (syncBytes2 == null) {
      return false;
    }
    if (syncBytes1.length != syncBytes2.length) {
      return false;
    }
    for (int i = 0; i < syncBytes1.length; i++) {
      if (syncBytes1[i] != syncBytes2[i]) {
        return false;
      }
    }
    return true;
  }
  
  public void run(IResource root, IWorkspaceRunnable runnable, IProgressMonitor monitor)
    throws TeamException
  {
    try
    {
      runnable.run(monitor);
    }
    catch (CoreException e)
    {
      throw TeamException.asTeamException(e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.variants.ResourceVariantByteStore
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.variants;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;

class ResourceVariantTree$1
  implements IWorkspaceRunnable
{
  final ResourceVariantTree this$0;
  private final IResource[][] val$resources;
  private final IResource val$local;
  private final IResourceVariant val$remote;
  private final int val$depth;
  
  ResourceVariantTree$1(ResourceVariantTree paramResourceVariantTree, IResource[][] paramArrayOfIResource, IResource paramIResource, IResourceVariant paramIResourceVariant, int paramInt)
  {
    this$0 = paramResourceVariantTree;val$resources = paramArrayOfIResource;val$local = paramIResource;val$remote = paramIResourceVariant;val$depth = paramInt;
  }
  
  public void run(IProgressMonitor monitor)
    throws CoreException
  {
    val$resources[0] = ResourceVariantTree.access$0(this$0, val$local, val$remote, val$depth, monitor);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.variants.ResourceVariantTree.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.variants;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;

public abstract class ResourceVariantTree
  extends AbstractResourceVariantTree
{
  private ResourceVariantByteStore store;
  
  protected ResourceVariantTree(ResourceVariantByteStore store)
  {
    this.store = store;
  }
  
  public IResource[] members(IResource resource)
    throws TeamException
  {
    return getByteStore().members(resource);
  }
  
  public boolean hasResourceVariant(IResource resource)
    throws TeamException
  {
    return getByteStore().getBytes(resource) != null;
  }
  
  public void flushVariants(IResource resource, int depth)
    throws TeamException
  {
    getByteStore().flushBytes(resource, depth);
  }
  
  protected boolean setVariant(IResource local, IResourceVariant remote)
    throws TeamException
  {
    ResourceVariantByteStore cache = getByteStore();
    byte[] newRemoteBytes = getBytes(local, remote);
    boolean changed;
    boolean changed;
    if (newRemoteBytes == null) {
      changed = cache.deleteBytes(local);
    } else {
      changed = cache.setBytes(local, newRemoteBytes);
    }
    return changed;
  }
  
  protected ResourceVariantByteStore getByteStore()
  {
    return store;
  }
  
  protected byte[] getBytes(IResource local, IResourceVariant remote)
    throws TeamException
  {
    if (remote == null) {
      return null;
    }
    return remote.asBytes();
  }
  
  protected IResource[] collectChanges(IResource local, IResourceVariant remote, int depth, IProgressMonitor monitor)
    throws TeamException
  {
    IResource[][] resources = new IResource[1][];
    getByteStore().run(local, new IWorkspaceRunnable()
    {
      private final IResource[][] val$resources;
      private final IResource val$local;
      private final IResourceVariant val$remote;
      private final int val$depth;
      
      public void run(IProgressMonitor monitor)
        throws CoreException
      {
        val$resources[0] = ResourceVariantTree.this.collectChanges(val$local, val$remote, val$depth, monitor);
      }
    }, monitor);
    return resources[0];
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.core.variants.ResourceVariantTree
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.core.variants;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.TeamStatus;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.core.subscribers.SubscriberChangeEvent;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.internal.core.Messages;
import org.eclipse.team.internal.core.Policy;

public abstract class ResourceVariantTreeSubscriber
  extends Subscriber
{
  public SyncInfo getSyncInfo(IResource resource)
    throws TeamException
  {
    if (!isSupervised(resource)) {
      return null;
    }
    IResourceVariant remoteResource = getRemoteTree().getResourceVariant(resource);
    IResourceVariant baseResource;
    IResourceVariant baseResource;
    if (getResourceComparator().isThreeWay()) {
      baseResource = getBaseTree().getResourceVariant(resource);
    } else {
      baseResource = null;
    }
    return getSyncInfo(resource, baseResource, remoteResource);
  }
  
  protected SyncInfo getSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote)
    throws TeamException
  {
    SyncInfo info = new SyncInfo(local, base, remote, getResourceComparator());
    info.init();
    return info;
  }
  
  public IResource[] members(IResource resource)
    throws TeamException
  {
    if (resource.getType() == 1) {
      return new IResource[0];
    }
    try
    {
      Set allMembers = new HashSet();
      try
      {
        allMembers.addAll(Arrays.asList(((IContainer)resource).members()));
      }
      catch (CoreException e)
      {
        if (e.getStatus().getCode() != 368) {
          throw e;
        }
      }
      allMembers.addAll(Arrays.asList(internalMembers(getRemoteTree(), resource)));
      if (getResourceComparator().isThreeWay()) {
        allMembers.addAll(Arrays.asList(internalMembers(getBaseTree(), resource)));
      }
      for (Iterator iterator = allMembers.iterator(); iterator.hasNext();)
      {
        IResource member = (IResource)iterator.next();
        if ((!member.exists()) && (!getRemoteTree().hasResourceVariant(member))) {
          iterator.remove();
        } else if (!isSupervised(member)) {
          iterator.remove();
        }
      }
      return (IResource[])allMembers.toArray(new IResource[allMembers.size()]);
    }
    catch (CoreException e)
    {
      throw TeamException.asTeamException(e);
    }
  }
  
  /* Error */
  public void refresh(IResource[] resources, int depth, IProgressMonitor monitor)
    throws TeamException
  {
    // Byte code:
    //   0: aload_3
    //   1: invokestatic 263	org/eclipse/team/internal/core/Policy:monitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   4: astore_3
    //   5: new 111	java/util/ArrayList
    //   8: dup
    //   9: invokespecial 240	java/util/ArrayList:<init>	()V
    //   12: astore 4
    //   14: aload_3
    //   15: aconst_null
    //   16: sipush 1000
    //   19: aload_1
    //   20: arraylength
    //   21: imul
    //   22: invokeinterface 284 3 0
    //   27: iconst_0
    //   28: istore 5
    //   30: goto +63 -> 93
    //   33: aload_1
    //   34: iload 5
    //   36: aaload
    //   37: astore 6
    //   39: aload 6
    //   41: invokeinterface 280 1 0
    //   46: invokeinterface 277 1 0
    //   51: ifeq +39 -> 90
    //   54: aload_0
    //   55: aload 6
    //   57: iload_2
    //   58: aload_3
    //   59: sipush 1000
    //   62: invokestatic 264	org/eclipse/team/internal/core/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   65: invokespecial 261	org/eclipse/team/core/variants/ResourceVariantTreeSubscriber:refresh	(Lorg/eclipse/core/resources/IResource;ILorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/core/runtime/IStatus;
    //   68: astore 7
    //   70: aload 7
    //   72: invokeinterface 286 1 0
    //   77: ifne +13 -> 90
    //   80: aload 4
    //   82: aload 7
    //   84: invokeinterface 270 2 0
    //   89: pop
    //   90: iinc 5 1
    //   93: iload 5
    //   95: aload_1
    //   96: arraylength
    //   97: if_icmplt -64 -> 33
    //   100: goto +14 -> 114
    //   103: astore 8
    //   105: aload_3
    //   106: invokeinterface 283 1 0
    //   111: aload 8
    //   113: athrow
    //   114: aload_3
    //   115: invokeinterface 283 1 0
    //   120: aload 4
    //   122: invokeinterface 269 1 0
    //   127: ifne +87 -> 214
    //   130: aload_1
    //   131: arraylength
    //   132: aload 4
    //   134: invokeinterface 268 1 0
    //   139: isub
    //   140: istore 5
    //   142: new 127	org/eclipse/team/core/TeamException
    //   145: dup
    //   146: new 124	org/eclipse/core/runtime/MultiStatus
    //   149: dup
    //   150: ldc 1
    //   152: iconst_0
    //   153: aload 4
    //   155: aload 4
    //   157: invokeinterface 268 1 0
    //   162: anewarray 123	org/eclipse/core/runtime/IStatus
    //   165: invokeinterface 271 2 0
    //   170: checkcast 107	[Lorg/eclipse/core/runtime/IStatus;
    //   173: getstatic 237	org/eclipse/team/internal/core/Messages:ResourceVariantTreeSubscriber_1	Ljava/lang/String;
    //   176: iconst_3
    //   177: anewarray 109	java/lang/Object
    //   180: dup
    //   181: iconst_0
    //   182: aload_0
    //   183: invokevirtual 254	org/eclipse/team/core/variants/ResourceVariantTreeSubscriber:getName	()Ljava/lang/String;
    //   186: aastore
    //   187: dup
    //   188: iconst_1
    //   189: iload 5
    //   191: invokestatic 239	java/lang/Integer:toString	(I)Ljava/lang/String;
    //   194: aastore
    //   195: dup
    //   196: iconst_2
    //   197: aload_1
    //   198: arraylength
    //   199: invokestatic 239	java/lang/Integer:toString	(I)Ljava/lang/String;
    //   202: aastore
    //   203: invokestatic 245	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   206: aconst_null
    //   207: invokespecial 244	org/eclipse/core/runtime/MultiStatus:<init>	(Ljava/lang/String;I[Lorg/eclipse/core/runtime/IStatus;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   210: invokespecial 247	org/eclipse/team/core/TeamException:<init>	(Lorg/eclipse/core/runtime/IStatus;)V
    //   213: athrow
    //   214: return
    // Line number table:
    //   Java source line #119	-> byte code offset #0
    //   Java source line #120	-> byte code offset #5
    //   Java source line #122	-> byte code offset #14
    //   Java source line #123	-> byte code offset #27
    //   Java source line #124	-> byte code offset #33
    //   Java source line #125	-> byte code offset #39
    //   Java source line #126	-> byte code offset #54
    //   Java source line #127	-> byte code offset #70
    //   Java source line #128	-> byte code offset #80
    //   Java source line #123	-> byte code offset #90
    //   Java source line #132	-> byte code offset #103
    //   Java source line #133	-> byte code offset #105
    //   Java source line #134	-> byte code offset #111
    //   Java source line #133	-> byte code offset #114
    //   Java source line #135	-> byte code offset #120
    //   Java source line #136	-> byte code offset #130
    //   Java source line #137	-> byte code offset #142
    //   Java source line #138	-> byte code offset #153
    //   Java source line #139	-> byte code offset #173
    //   Java source line #137	-> byte code offset #210
    //   Java source line #141	-> byte code offset #214
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	215	0	this	ResourceVariantTreeSubscriber
    //   0	215	1	resources	IResource[]
    //   0	215	2	depth	int
    //   0	215	3	monitor	IProgressMonitor
    //   12	144	4	errors	java.util.List
    //   28	66	5	i	int
    //   140	50	5	numSuccess	int
    //   37	19	6	resource	IResource
    //   68	15	7	status	IStatus
    //   103	9	8	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   14	103	103	finally
  }
  
  protected abstract IResourceVariantTree getBase
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd