org.eclipse.team.cvs.core_3.3.400.I20110510-0800

yOfException;
  }
  
  public void run()
  {
    try
    {
      Socket newSocket = this$0.internalCreateSocket(val$host, val$port);
      synchronized (val$socket)
      {
        if (Thread.interrupted()) {
          newSocket.close();
        } else {
          val$socket[0] = newSocket;
        }
      }
    }
    catch (UnknownHostException e)
    {
      val$exception[0] = e;
    }
    catch (IOException e)
    {
      val$exception[0] = e;
    }
  }
}

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

import java.io.IOException;
import java.io.InterruptedIOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.internal.ccvs.core.CVSMessages;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.Policy;

public class ResponsiveSocketFactory
{
  private static final String JAVA_NET_PROXY = "java.net.Proxy";
  private static final int DEFAULT_TIMEOUT = 60;
  private IProgressMonitor monitor;
  private final int timeout;
  private static Class proxyClass;
  private static boolean hasProxyClass = true;
  
  public ResponsiveSocketFactory(IProgressMonitor monitor, int timeout)
  {
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    this.monitor = monitor;
    this.timeout = timeout;
  }
  
  public Socket createSocket(String host, int port)
    throws IOException, UnknownHostException
  {
    Socket socket = null;
    socket = createSocket(host, port, timeout / 1000, monitor);
    
    monitor = new NullProgressMonitor();
    
    socket.setSoTimeout(timeout);
    return socket;
  }
  
  private Socket createSocket(String host, int port, int timeout, IProgressMonitor monitor)
    throws UnknownHostException, IOException
  {
    Socket[] socket = new Socket[1];
    Exception[] exception = new Exception[1];
    Thread thread = new Thread(new Runnable()
    {
      private final String val$host;
      private final int val$port;
      private final Socket[] val$socket;
      private final Exception[] val$exception;
      
      public void run()
      {
        try
        {
          Socket newSocket = internalCreateSocket(val$host, val$port);
          synchronized (val$socket)
          {
            if (Thread.interrupted()) {
              newSocket.close();
            } else {
              val$socket[0] = newSocket;
            }
          }
        }
        catch (UnknownHostException e)
        {
          val$exception[0] = e;
        }
        catch (IOException e)
        {
          val$exception[0] = e;
        }
      }
    });
    thread.start();
    if (timeout == 0) {
      timeout = 60;
    }
    for (int i = 0; i < timeout; i++)
    {
      try
      {
        thread.join(1000L);
      }
      catch (InterruptedException localInterruptedException) {}
      synchronized (socket)
      {
        if (monitor.isCanceled())
        {
          if (thread.isAlive()) {
            thread.interrupt();
          }
          if (socket[0] != null) {
            socket[0].close();
          }
          Policy.checkCanceled(monitor);
        }
      }
    }
    synchronized (socket)
    {
      if (thread.isAlive()) {
        thread.interrupt();
      }
    }
    if (exception[0] != null)
    {
      if ((exception[0] instanceof UnknownHostException)) {
        throw ((UnknownHostException)exception[0]);
      }
      throw ((IOException)exception[0]);
    }
    if (socket[0] == null) {
      throw new InterruptedIOException(NLS.bind(CVSMessages.Util_timeout, new String[] { host }));
    }
    return socket[0];
  }
  
  Socket internalCreateSocket(String host, int port)
    throws UnknownHostException, IOException
  {
    Class proxyClass = getProxyClass();
    if (proxyClass != null) {
      try
      {
        Field field = proxyClass.getField("NO_PROXY");
        Object noProxyObject = field.get(null);
        Constructor constructor = tmp28_25.getConstructor(new Class[] { proxyClass });
        Object o = constructor.newInstance(new Object[] { noProxyObject });
        if ((o instanceof Socket))
        {
          Socket socket = (Socket)o;
          socket.connect(new InetSocketAddress(host, port), timeout * 1000);
          return socket;
        }
      }
      catch (SecurityException e)
      {
        CVSProviderPlugin.log(4, NLS.bind("An internal error occurred while connecting to {0}", host), e);
      }
      catch (NoSuchFieldException e)
      {
        CVSProviderPlugin.log(4, NLS.bind("An internal error occurred while connecting to {0}", host), e);
      }
      catch (IllegalArgumentException e)
      {
        CVSProviderPlugin.log(4, NLS.bind("An internal error occurred while connecting to {0}", host), e);
      }
      catch (IllegalAccessException e)
      {
        CVSProviderPlugin.log(4, NLS.bind("An internal error occurred while connecting to {0}", host), e);
      }
      catch (NoSuchMethodException e)
      {
        CVSProviderPlugin.log(4, NLS.bind("An internal error occurred while connecting to {0}", host), e);
      }
      catch (InstantiationException e)
      {
        CVSProviderPlugin.log(4, NLS.bind("An internal error occurred while connecting to {0}", host), e);
      }
      catch (InvocationTargetException e)
      {
        CVSProviderPlugin.log(4, NLS.bind("An internal error occurred while connecting to {0}", host), e);
      }
    }
    return new Socket(host, port);
  }
  
  private synchronized Class getProxyClass()
  {
    if ((hasProxyClass) && (proxyClass == null)) {
      try
      {
        proxyClass = Class.forName("java.net.Proxy");
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        hasProxyClass = false;
      }
    }
    return proxyClass;
  }
}

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

public class StringMatcher$CharacterClass
{
  final boolean isNegated;
  final String text;
  
  StringMatcher$CharacterClass(boolean isNegated, String text)
  {
    this.isNegated = isNegated;
    this.text = text;
  }
  
  boolean listed(char c)
  {
    for (int i = 0; i < text.length();) {
      if ((i + 2 < text.length()) && (text.charAt(i + 1) == '-'))
      {
        if ((c >= text.charAt(i)) && (c <= text.charAt(i + 2))) {
          return true;
        }
        i += 3;
      }
      else
      {
        if (c == text.charAt(i)) {
          return true;
        }
        i++;
      }
    }
    return false;
  }
  
  boolean match(char c)
  {
    return listed(c) ^ isNegated;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.util.StringMatcher.CharacterClass
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ccvs.core.util;

public class StringMatcher$Position
{
  int start;
  int end;
  
  public StringMatcher$Position(int start, int end)
  {
    this.start = start;
    this.end = end;
  }
  
  public int getStart()
  {
    return start;
  }
  
  public int getEnd()
  {
    return end;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.util.StringMatcher.Position
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ccvs.core.util;

import java.util.HashMap;
import java.util.Vector;

public class StringMatcher
{
  protected String fPattern;
  protected int fLength;
  protected boolean fIgnoreWildCards;
  protected boolean fIgnoreCase;
  protected boolean fHasLeadingStar;
  protected boolean fHasTrailingStar;
  protected String[] fSegments;
  protected HashMap[] fCharacterClassMaps;
  
  protected static class CharacterClass
  {
    final boolean isNegated;
    final String text;
    
    CharacterClass(boolean isNegated, String text)
    {
      this.isNegated = isNegated;
      this.text = text;
    }
    
    boolean listed(char c)
    {
      for (int i = 0; i < text.length();) {
        if ((i + 2 < text.length()) && (text.charAt(i + 1) == '-'))
        {
          if ((c >= text.charAt(i)) && (c <= text.charAt(i + 2))) {
            return true;
          }
          i += 3;
        }
        else
        {
          if (c == text.charAt(i)) {
            return true;
          }
          i++;
        }
      }
      return false;
    }
    
    boolean match(char c)
    {
      return listed(c) ^ isNegated;
    }
  }
  
  protected int fBound = 0;
  protected static final char fSingleWildCard = '\000';
  
  public static class Position
  {
    int start;
    int end;
    
    public Position(int start, int end)
    {
      this.start = start;
      this.end = end;
    }
    
    public int getStart()
    {
      return start;
    }
    
    public int getEnd()
    {
      return end;
    }
  }
  
  public Position find(String text, int start, int end)
  {
    if ((fPattern == null) || (text == null)) {
      throw new IllegalArgumentException();
    }
    int tlen = text.length();
    if (start < 0) {
      start = 0;
    }
    if (end > tlen) {
      end = tlen;
    }
    if ((end < 0) || (start >= end)) {
      return null;
    }
    if (fLength == 0) {
      return new Position(start, start);
    }
    if (fIgnoreWildCards)
    {
      int x = posIn(text, start, end);
      if (x < 0) {
        return null;
      }
      return new Position(x, x + fLength);
    }
    int segCount = fSegments.length;
    if (segCount == 0) {
      return new Position(start, end);
    }
    int curPos = start;
    int matchStart = -1;
    for (int i = 0; (i < segCount) && (curPos < end); i++)
    {
      String current = fSegments[i];
      int nextMatch = regExpPosIn(text, curPos, end, current, fCharacterClassMaps[i]);
      if (nextMatch < 0) {
        return null;
      }
      if (i == 0) {
        matchStart = nextMatch;
      }
      curPos = nextMatch + current.length();
    }
    if (i < segCount) {
      return null;
    }
    return new Position(matchStart, curPos);
  }
  
  public StringMatcher(String aPattern, boolean ignoreCase, boolean ignoreWildCards)
  {
    fIgnoreCase = ignoreCase;
    fIgnoreWildCards = ignoreWildCards;
    fLength = aPattern.length();
    if (fIgnoreCase) {
      fPattern = aPattern.toUpperCase();
    } else {
      fPattern = aPattern;
    }
    if (fIgnoreWildCards) {
      parseNoWildCards();
    } else {
      parseWildCards();
    }
  }
  
  public boolean match(String text, int start, int end)
  {
    if (text == null) {
      throw new IllegalArgumentException();
    }
    if (start > end) {
      return false;
    }
    if (fIgnoreWildCards) {
      return (end - start == fLength) && (fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength));
    }
    int segCount = fSegments.length;
    if ((segCount == 0) && ((fHasLeadingStar) || (fHasTrailingStar))) {
      return true;
    }
    if (start == end) {
      return fLength == 0;
    }
    if (fLength == 0) {
      return start == end;
    }
    int tlen = text.length();
    if (start < 0) {
      start = 0;
    }
    if (end > tlen) {
      end = tlen;
    }
    int tCurPos = start;
    int bound = end - fBound;
    if (bound < 0) {
      return false;
    }
    int i = 0;
    String current = fSegments[i];
    HashMap curCharClassMap = fCharacterClassMaps[i];
    int segLength = current.length();
    if (!fHasLeadingStar)
    {
      if (!regExpRegionMatches(text, start, current, 0, segLength, curCharClassMap)) {
        return false;
      }
      i++;
      tCurPos += segLength;
    }
    if ((fSegments.length == 1) && (!fHasLeadingStar) && (!fHasTrailingStar)) {
      return tCurPos == end;
    }
    while (i < segCount)
    {
      current = fSegments[i];
      curCharClassMap = fCharacterClassMaps[i];
      
      int k = current.indexOf(0);
      int currentMatch;
      if (k < 0)
      {
        int currentMatch = textPosIn(text, tCurPos, end, current);
        if (currentMatch < 0) {
          return false;
        }
      }
      else
      {
        currentMatch = regExpPosIn(text, tCurPos, end, current, curCharClassMap);
        if (currentMatch < 0) {
          return false;
        }
      }
      tCurPos = currentMatch + current.length();
      i++;
    }
    if ((!fHasTrailingStar) && (tCurPos != end))
    {
      int clen = current.length();
      return regExpRegionMatches(text, end - clen, current, 0, clen, curCharClassMap);
    }
    return i == segCount;
  }
  
  public boolean match(String text)
  {
    return match(text, 0, text.length());
  }
  
  private void parseNoWildCards()
  {
    fSegments = new String[1];
    fSegments[0] = fPattern;
    fBound = fLength;
  }
  
  private void parseWildCards()
  {
    if (fPattern.startsWith("*")) {
      fHasLeadingStar = true;
    }
    Vector temp = new Vector();
    HashMap segmentCCs = null;
    Vector allCCs = new Vector();
    
    int pos = 0;
    StringBuffer buf = new StringBuffer();
    while (pos < fLength)
    {
      char c = fPattern.charAt(pos++);
      fHasTrailingStar = false;
      switch (c)
      {
      case '\\': 
        if (pos >= fLength)
        {
          buf.append(c);
        }
        else
        {
          c = fPattern.charAt(pos++);
          buf.append(c);
        }
        break;
      case '*': 
        fHasTrailingStar = true;
        if (buf.length() > 0)
        {
          temp.addElement(buf.toString());
          allCCs.addElement(segmentCCs);
          fBound += buf.length();
          buf.setLength(0);
          segmentCCs = null;
        }
        break;
      case '[': 
        if (segmentCCs == null) {
          segmentCCs = new HashMap();
        }
        if (pos >= fLength)
        {
          buf.append(c);
        }
        else
        {
          boolean negated = fPattern.charAt(pos) == '!';
          int beginPos = negated ? pos + 1 : pos;
          int endPos = fPattern.indexOf(']', beginPos + 1);
          if (endPos == -1)
          {
            buf.append(c);
          }
          else
          {
            CharacterClass cc = new CharacterClass(negated, fPattern.substring(beginPos, endPos));
            segmentCCs.put(new Integer(buf.length()), cc);
            pos = endPos + 1;
          }
        }
        break;
      case '?': 
        buf.append('\000');
        break;
      default: 
        buf.append(c);
      }
    }
    if (buf.length() > 0)
    {
      temp.addElement(buf.toString());
      allCCs.addElement(segmentCCs);
      fBound += buf.length();
    }
    fSegments = new String[temp.size()];
    temp.copyInto(fSegments);
    fCharacterClassMaps = new HashMap[allCCs.size()];
    allCCs.copyInto(fCharacterClassMaps);
  }
  
  protected int posIn(String text, int start, int end)
  {
    return textPosIn(text, start, end, fPattern);
  }
  
  protected int regExpPosIn(String text, int start, int end, String p, HashMap ccMap)
  {
    int plen = p.length();
    
    int max = end - plen;
    for (int i = start; i <= max; i++) {
      if (regExpRegionMatches(text, i, p, 0, plen, ccMap)) {
        return i;
      }
    }
    return -1;
  }
  
  protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen, HashMap ccMap)
  {
    for (int ppos = 0; plen-- > 0; ppos++)
    {
      char tchar = text.charAt(tStart++);
      char pchar = p.charAt(pStart++);
      if (!fIgnoreWildCards) {
        if (pchar == 0)
        {
          if (ccMap == null) {
            continue;
          }
          CharacterClass cc = (CharacterClass)ccMap.get(new Integer(ppos));
          if ((cc == null) || (cc.match(tchar))) {
            continue;
          }
          return false;
        }
      }
      if (pchar != tchar) {
        if (fIgnoreCase)
        {
          char tc = Character.toUpperCase(tchar);
          if (tc == pchar) {}
        }
        else
        {
          return false;
        }
      }
    }
    return true;
  }
  
  protected int textPosIn(String text, int start, int end, String p)
  {
    int plen = p.length();
    int max = end - plen;
    if (!fIgnoreCase)
    {
      int i = text.indexOf(p, start);
      if ((i == -1) || (i > max)) {
        return -1;
      }
      return i;
    }
    for (int i = start; i <= max; i++) {
      if (text.regionMatches(true, i, p, 0, plen)) {
        return i;
      }
    }
    return -1;
  }
}

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

import java.io.PrintStream;
import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.syncinfo.DeferredResourceChangeHandler;

class SyncFileChangeListener$1
  implements IResourceDeltaVisitor
{
  final SyncFileChangeListener this$0;
  private final Set val$changedContainers;
  private final Set val$externalDeletions;
  
  SyncFileChangeListener$1(SyncFileChangeListener paramSyncFileChangeListener, Set paramSet1, Set paramSet2)
  {
    this$0 = paramSyncFileChangeListener;val$changedContainers = paramSet1;val$externalDeletions = paramSet2;
  }
  
  public boolean visit(IResourceDelta delta)
  {
    IResource resource = delta.getResource();
    if (resource.getType() == 8) {
      return true;
    }
    if (resource.getType() == 4)
    {
      if (!resource.isAccessible()) {
        return false;
      }
      this$0.setProjectOpening((delta.getFlags() & 0x4000) != 0);
    }
    String name = resource.getName();
    int kind = delta.getKind();
    if ((kind == 4) && 
      ((delta.getFlags() & this$0.INTERESTING_CHANGES) == 0)) {
      return true;
    }
    if (name.equals("CVS"))
    {
      this$0.handleCVSDir((IContainer)resource, kind);
      if (this$0.isProjectOpening()) {
        return false;
      }
    }
    else if (this$0.isProjectOpening())
    {
      return true;
    }
    if (this$0.isMetaFile(resource))
    {
      IResource[] toBeNotified = this$0.handleChangedMetaFile(resource);
      if ((toBeNotified.length > 0) && (this$0.isModifiedBy3rdParty(resource)))
      {
        for (int i = 0; i < toBeNotified.length; i++) {
          val$changedContainers.add(toBeNotified[i]);
        }
        if (Policy.DEBUG_METAFILE_CHANGES) {
          System.out.println("[cvs] metafile changed by 3rd party: " + resource.getFullPath());
        }
        return false;
      }
    }
    else if ((this$0.isIgnoreFile(resource)) && (this$0.isModifiedBy3rdParty(resource)))
    {
      SyncFileChangeListener.deferredHandler.ignoreFileChanged((IFile)resource);
    }
    else if (this$0.isExternalDeletion(resource, kind))
    {
      val$externalDeletions.add(resource);
    }
    else if ((kind == 1) && (SyncFileChangeListener.access$0(this$0, resource)))
    {
      SyncFileChangeListener.deferredHandler.recreated(resource);
    }
    return true;
  }
}

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

import java.io.PrintStream;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSMessages;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
import org.eclipse.team.internal.ccvs.core.syncinfo.DeferredResourceChangeHandler;

public class SyncFileChangeListener
  implements IResourceChangeListener
{
  protected int INTERESTING_CHANGES = 323840;
  protected boolean isProjectOpening = false;
  protected static DeferredResourceChangeHandler deferredHandler = new DeferredResourceChangeHandler();
  
  public static DeferredResourceChangeHandler getDeferredHandler()
  {
    return deferredHandler;
  }
  
  public void resourceChanged(IResourceChangeEvent event)
  {
    try
    {
      Set changedContainers = new HashSet();
      Set externalDeletions = new HashSet();
      
      setProjectOpening(false);
      
      event.getDelta().accept(new IResourceDeltaVisitor()
      {
        private final Set val$changedContainers;
        private final Set val$externalDeletions;
        
        public boolean visit(IResourceDelta delta)
        {
          IResource resource = delta.getResource();
          if (resource.getType() == 8) {
            return true;
          }
          if (resource.getType() == 4)
          {
            if (!resource.isAccessible()) {
              return false;
            }
            setProjectOpening((delta.getFlags() & 0x4000) != 0);
          }
          String name = resource.getName();
          int kind = delta.getKind();
          if ((kind == 4) && 
            ((delta.getFlags() & INTERESTING_CHANGES) == 0)) {
            return true;
          }
          if (name.equals("CVS"))
          {
            handleCVSDir((IContainer)resource, kind);
            if (isProjectOpening()) {
              return false;
            }
          }
          else if (isProjectOpening())
          {
            return true;
          }
          if (isMetaFile(resource))
          {
            IResource[] toBeNotified = handleChangedMetaFile(resource);
            if ((toBeNotified.length > 0) && (isModifiedBy3rdParty(resource)))
            {
              for (int i = 0; i < toBeNotified.length; i++) {
                val$changedContainers.add(toBeNotified[i]);
              }
              if (Policy.DEBUG_METAFILE_CHANGES) {
                System.out.println("[cvs] metafile changed by 3rd party: " + resource.getFullPath());
              }
              return false;
            }
          }
          else if ((isIgnoreFile(resource)) && (isModifiedBy3rdParty(resource)))
          {
            SyncFileChangeListener.deferredHandler.ignoreFileChanged((IFile)resource);
          }
          else if (isExternalDeletion(resource, kind))
          {
            val$externalDeletions.add(resource);
          }
          else if ((kind == 1) && (SyncFileChangeListener.this.isRecreation(resource)))
          {
            SyncFileChangeListener.deferredHandler.recreated(resource);
          }
          return true;
        }
      }, 2);
      if ((!changedContainers.isEmpty()) || (!externalDeletions.isEmpty())) {
        EclipseSynchronizer.getInstance().syncFilesChangedExternally(
          (IContainer[])changedContainers.toArray(new IContainer[changedContainers.size()]), 
          (IFile[])externalDeletions.toArray(new IFile[externalDeletions.size()]));
      }
    }
    catch (CoreException e)
    {
      CVSProviderPlugin.log(e);
    }
  }
  
  protected boolean isExternalDeletion(IResource resource, int kind)
  {
    if (kind != 2) {
      return false;
    }
    if (resource.getType() != 1) {
      return false;
    }
    ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)resource);
    try
    {
      return (!file.isManaged()) && (file.getParent().isCVSFolder()) && (file.getParent().exists());
    }
    catch (CVSException e)
    {
      CVSProviderPlugin.log(e);
    }
    return false;
  }
  
  protected boolean isModifiedBy3rdParty(IResource resource)
  {
    if (!resource.exists()) {
      return true;
    }
    long modStamp = resource.getModificationStamp();
    Long whenWeWrote;
    try
    {
      whenWeWrote = (Long)resource.getSessionProperty(SyncFileWriter.MODSTAMP_KEY);
    }
    catch (CoreException e)
    {
      Long whenWeWrote;
      CVSProviderPlugin.log(e);
      whenWeWrote = null;
    }
    return (whenWeWrote == null) || (whenWeWrote.longValue() != modStamp);
  }
  
  protected void handleCVSDir(IContainer cvsDir, int kind)
  {
    if (((kind & 0x1F) != 0) && 
      (kind == 1))
    {
      IFile rootFile = cvsDir.getFile(new Path("Root"));
      IFile repositoryFile = cvsDir.getFile(new Path("Repository"));
      if ((rootFile.exists()) && (repositoryFile.exists()) && (!cvsDir.isTeamPrivateMember())) {
        try
        {
          cvsDir.setTeamPrivateMember(true);
          if (Policy.DEBUG_METAFILE_CHANGES) {
            System.out.println("[cvs] found a new CVS meta folder, marking as team-private: " + cvsDir.getFullPath());
          }
        }
        catch (CoreException e)
        {
          CVSProviderPlugin.log(CVSException.wrapException(cvsDir, CVSMessages.SyncFileChangeListener_errorSettingTeamPrivateFlag, e));
        }
      }
    }
  }
  
  protected boolean isIgnoreFile(IResource resource)
  {
    return (resource.getType() == 1) && (resource.getName().equals(".cvsignore"));
  }
  
  private boolean isRecreation(IResource resource)
  {
    return EclipseSynchronizer.getInstance().wasPhantom(resource);
  }
  
  protected boolean isMetaFile(IResource resource)
  {
    IContainer parent = resource.getParent();
    
    return (resource.getType() == 1) && (parent != null) && (parent.getName().equals("CVS")) && ((parent.isTeamPrivateMember()) || (!parent.exists()));
  }
  
  protected IContainer[] handleChangedMetaFile(IResource resource)
  {
    IContainer changedContainer = resource.getParent().getParent();
    if (changedContainer.exists()) {
      return new IContainer[] { changedContainer };
    }
    return new IContainer[0];
  }
  
  public boolean isProjectOpening()
  {
    return isProjectOpening;
  }
  
  public void setProjectOpening(boolean isProjectOpening)
  {
    this.isProjectOpening = isProjectOpening;
  }
}

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

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

class SyncFileWriter$1
  implements IWorkspaceRunnable
{
  private final IFolder val$cvsSubDir;
  
  SyncFileWriter$1(IFolder paramIFolder)
  {
    val$cvsSubDir = paramIFolder;
  }
  
  public void run(IProgressMonitor monitor)
    throws CoreException
  {
    if (!val$cvsSubDir.exists())
    {
      if (SyncFileWriter.existsInFileSystem(val$cvsSubDir))
      {
        val$cvsSubDir.refreshLocal(2, null);
        val$cvsSubDir.setTeamPrivateMember(true);
      }
      else
      {
        val$cvsSubDir.create(2048, true, null);
      }
    }
    else if (!val$cvsSubDir.isTeamPrivateMember()) {
      val$cvsSubDir.setTeamPrivateMember(true);
    }
  }
}

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

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.internal.ccvs.core.CVSException;

class SyncFileWriter$2
  implements IWorkspaceRunnable
{
  private final String[] val$contents;
  private final IFile val$file;
  
  SyncFileWriter$2(String[] paramArrayOfString, IFile paramIFile)
  {
    val$contents = paramArrayOfString;val$file = paramIFile;
  }
  
  public void run(IProgressMonitor monitor)
    throws CoreException
  {
    try
    {
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      SyncFileWriter.access$0(os, val$contents);
      if (!val$file.exists()) {
        val$file.create(new ByteArrayInputStream(os.toByteArray()), 1, null);
      } else {
        val$file.setContents(new ByteArrayInputStream(os.toByteArray()), 1, null);
      }
      val$file.setSessionProperty(SyncFileWriter.MODSTAMP_KEY, new Long(val$file.getModificationStamp()));
    }
    catch (CVSException e)
    {
      throw new CoreException(e.getStatus());
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.util.SyncFileWriter.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ccvs.core.util;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResourceRuleFactory;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourceAttributes;
import org.eclipse.core.resources.ResourcesPlugin;
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.Path;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSMessages;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSStatus;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
import org.eclipse.team.internal.ccvs.core.syncinfo.BaserevInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.NotifyInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;

public class SyncFileWriter
{
  public static final String CVS_DIRNAME = "CVS";
  public static final String REPOSITORY = "Repository";
  public static final String ROOT = "Root";
  public static final String STATIC = "Entries.Static";
  public static final String TAG = "Tag";
  public static final String ENTRIES = "Entries";
  public static final String ENTRIES_LOG = "Entries.Log";
  public static final String NOTIFY = "Notify";
  public static final String BASE_DIRNAME = "Base";
  public static final String BASEREV = "Baserev";
  public static final String IGNORE_FILE = ".cvsignore";
  private static final String FOLDER_TAG = "D";
  private static final String ADD_TAG = "A ";
  private static final String REMOVE_TAG = "R ";
  public static final QualifiedName MODSTAMP_KEY = new QualifiedName("org.eclipse.team.cvs.core", "meta-file-modtime");
  
  public static byte[][] readAllResourceSync(IContainer parent)
    throws CVSException
  {
    IFolder cvsSubDir = getCVSSubdirectory(parent);
    if (!folderExists(cvsSubDir)) {
      return null;
    }
    if (Policy.DEBUG_METAFILE_CHANGES) {
      System.out.println("Reading Entries file for " + parent.getFullPath());
    }
    String[] entries = readLines(cvsSubDir.getFile("Entries"));
    if (entries == null) {
      return null;
    }
    Map infos = new TreeMap();
    for (int i = 0; i < entries.length; i++)
    {
      String line = entries[i];
      if ((!"D".equals(line)) && (!"".equals(line))) {
        try
        {
          ResourceSyncInfo info = new ResourceSyncInfo(line, null);
          infos.put(info.getName(), info);
        }
        catch (CVSException e)
        {
          CVSProviderPlugin.log(new CVSStatus(4, NLS.bind(CVSMessages.SyncFileWriter_0, new String[] { parent.getFullPath().toString() }), e));
        }
      }
    }
    String[] entriesLog = readLines(cvsSubDir.getFile("Entries.Log"));
    if (entriesLog != null) {
      for (int i = 0; i < entriesLog.length; i++)
      {
        String line = entriesLog[i];
        if (line.startsWith("A "))
        {
          line = line.substring("A ".length());
          ResourceSyncInfo info = new ResourceSyncInfo(line, null);
          infos.put(info.getName(), info);
        }
        else if (line.startsWith("R "))
        {
          line = line.substring("R ".length());
          ResourceSyncInfo info = new ResourceSyncInfo(line, null);
          infos.remove(info.getName());
        }
      }
    }
    byte[][] result = new byte[infos.size()][];
    int i = 0;
    for (Iterator iter = infos.values().iterator(); iter.hasNext();)
    {
      ResourceSyncInfo info = (ResourceSyncInfo)iter.next();
      result[(i++)] = info.getBytes();
    }
    return result;
  }
  
  private static boolean folderExists(IFolder cvsSubDir)
    throws CVSException
  {
    try
    {
      URI uri = cvsSubDir.getLocationURI();
      if (uri != null)
      {
        IFileStore store = EFS.getStore(uri);
        if (store != null) {
          return store.fetchInfo().exists();
        }
      }
    }
    catch (CoreException e)
    {
      throw CVSException.wrapException(e);
    }
    return false;
  }
  
  public static void writeAllResourceSync(IContainer parent, byte[][] infos)
    throws CVSException
  {
    try
    {
      if (Policy.DEBUG_METAFILE_CHANGES) {
        System.out.println("Writing Entries file for folder " + parent.getFullPath());
      }
      IFolder cvsSubDir = createCVSSubdirectory(parent);
      
      String[] entries = new String[infos.length];
      for (int i = 0; i < infos.length; i++)
      {
        byte[] info = infos[i];
        entries[i] = new String(info);
      }
      writeLines(cvsSubDir.getFile("Entries"), entries);
      
      cvsSubDir.getFile("Entries.Log").delete(0, null);
    }
    catch (CoreException e)
    {
      throw CVSException.wrapException(e);
    }
  }
  
  public static FolderSyncInfo readFolderSync(IContainer folder)
    throws CVSException
  {
    IFolder cvsSubDir = getCVSSubdirectory(folder);
    if (!folderExists(cvsSubDir)) {
      return null;
    }
    if (Policy.DEBUG_METAFILE_CHANGES) {
      System.out.println("Reading Root/Repository files for " + folder.getFullPath());
    }
    if ((!cvsSubDir.isTeamPrivateMember()) && (cvsSubDir.exists())) {
      try
      {
        cvsSubDir.setTeamPrivateMember(true);
      }
      catch (CoreException e)
      {
        CVSProviderPlugin.log(e);
      }
    }
    String root = readFirstLine(cvsSubDir.getFile("Root"));
    if (root == null) {
      return null;
    }
    String repository = readFirstLine(cvsSubDir.getFile("Repository"));
    if (repository == null) {
      return null;
    }
    String tag = readFirstLine(cvsSubDir.getFile("Tag"));
    if ((Policy.DEBUG_METAFILE_CHANGES) && (tag != null)) {
      System.out.println("Reading Tag file for " + folder.getFullPath());
    }
    CVSTag cvsTag = tag != null ? new CVSEntryLineTag(tag) : null;
    
    String staticDir = readFirstLine(cvsSubDir.getFile("Entries.Static"));
    if ((Policy.DEBUG_METAFILE_CHANGES) && (staticDir != null)) {
      System.out.println("Reading Static file for " + folder.getFullPath());
    }
    boolean isStatic = staticDir != null;
    
    return new FolderSyncInfo(repository, root, cvsTag, isStatic);
  }
  
  public static void writeFolderSync(IContainer folder, FolderSyncInfo info)
    throws CVSException
  {
    try
    {
      if (Policy.DEBUG_METAFILE_CHANGES) {
        System.out.println("Writing Root/Respository files for " + folder.getFullPath());
      }
      IFolder cvsSubDir = createCVSSubdirectory(folder);
      
      writeLines(cvsSubDir.getFile("Root"), new String[] { info.getRoot() });
      
      writeLines(cvsSubDir.getFile("Repository"), new String[] { info.getRepository() });
      
      IFile tagFile = cvsSubDir.getFile("Tag");
      if (info.getTag() != null)
      {
        if (Policy.DEBUG_METAFILE_CHANGES) {
          System.out.println("Writing Tag file for " + folder.getFullPath());
        }
        writeLines(tagFile, new String[] { info.getTag().toEntryLineFormat(false) });
      }
      else if (tagFile.exists())
      {
        if (Policy.DEBUG_METAFILE_CHANGES) {
          System.out.println("Deleting Tag file for " + folder.getFullPath());
        }
        tagFile.delete(0, null);
      }
      IFile staticFile = cvsSubDir.getFile("Entries.Static");
      if (info.getIsStatic())
      {
        if (Policy.DEBUG_METAFILE_CHANGES) {
          System.out.println("Writing Static file for " + folder.getFullPath());
        }
        writeLines(staticFile, new String[] { "" });
      }
      else if (staticFile.exists())
      {
        if (Policy.DEBUG_METAFILE_CHANGES) {
          System.out.println("Deleting Static file for " + folder.getFullPath());
        }
        staticFile.delete(0, null);
      }
    }
    catch (CoreException e)
    {
      throw CVSException.wrapException(e);
    }
  }
  
  public static String[] readCVSIgnoreEntries(IContainer folder)
    throws CVSException
  {
    IFile ignoreFile = folder.getFile(new Path(".cvsignore"));
    if (ignoreFile != null)
    {
      String[] lines = readLines(ignoreFile);
      if (lines == null) {
        return null;
      }
      ArrayList entries = new ArrayList();
      for (int ln = 0; ln < lines.length; ln++)
      {
        String line = lines[ln];
        int pos = 0;
        while (pos < line.length()) {
          if ((line.charAt(pos) == ' ') || (line.charAt(pos) == '\t'))
          {
            pos++;
          }
          else
          {
            int start = pos;
            while ((pos < line.length()) && (line.charAt(pos) != ' ') && (line.charAt(pos) != '\t')) {
              pos++;
            }
            entries.add(line.substring(start, pos));
          }
        }
      }
      return (String[])entries.toArray(new String[entries.size()]);
    }
    return null;
  }
  
  public static void writeCVSIgnoreEntries(IContainer folder, String[] patterns)
    throws CVSException
  {
    IFile ignoreFile = folder.getFile(new Path(".cvsignore"));
    writeLines(ignoreFile, patterns);
  }
  
  public static void deleteFolderSync(IContainer folder)
    throws CVSException
  {
    try
    {
      if (Policy.DEBUG_METAFILE_CHANGES) {
        Sys
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 27 28 29 30 31 32 33 34 35 36

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-2019. Infinite Loop Ltd