org.eclipse.pde.api.tools_1.0.301.v20111129-2053

tic boolean DEBUG = Util.DEBUG;
  
  public static void setDebug(boolean debugValue)
  {
    DEBUG = (debugValue) || (Util.DEBUG);
  }
  
  private IJavaProject fProject = null;
  private IPluginModelBase fModel = null;
  private Map fPathToOutputContainers = null;
  private Map fOutputLocationToContainer = null;
  
  public ProjectComponent(IApiBaseline baseline, String location, IPluginModelBase model, long bundleid)
    throws CoreException
  {
    super(baseline, location, bundleid);
    IPath path = new Path(location);
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.lastSegment());
    fProject = JavaCore.create(project);
    fModel = model;
    setName(fModel.getResourceString(super.getName()));
  }
  
  protected boolean isBinary()
  {
    return false;
  }
  
  protected BundleDescription getBundleDescription(Dictionary manifest, String location, long id)
    throws BundleException
  {
    try
    {
      return getModel().getBundleDescription();
    }
    catch (CoreException ce)
    {
      throw new BundleException(ce.getMessage());
    }
  }
  
  IPluginModelBase getModel()
    throws CoreException
  {
    if (fModel == null)
    {
      fModel = PluginRegistry.findModel(fProject.getProject());
      if (fModel == null) {
        abort(NLS.bind(CoreMessages.ProjectComponent_could_not_locate_model, fProject.getElementName()), null);
      }
    }
    return fModel;
  }
  
  protected boolean isApiEnabled()
  {
    return Util.isApiProject(fProject);
  }
  
  /* Error */
  public void dispose()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokevirtual 456	org/eclipse/pde/api/tools/internal/model/ProjectComponent:hasApiFilterStore	()Z
    //   4: ifeq +12 -> 16
    //   7: aload_0
    //   8: invokevirtual 461	org/eclipse/pde/api/tools/internal/model/ProjectComponent:getFilterStore	()Lorg/eclipse/pde/api/tools/internal/provisional/IApiFilterStore;
    //   11: invokeinterface 514 1 0
    //   16: aload_0
    //   17: aconst_null
    //   18: putfield 426	org/eclipse/pde/api/tools/internal/model/ProjectComponent:fModel	Lorg/eclipse/pde/core/plugin/IPluginModelBase;
    //   21: aload_0
    //   22: getfield 423	org/eclipse/pde/api/tools/internal/model/ProjectComponent:fOutputLocationToContainer	Ljava/util/Map;
    //   25: ifnull +17 -> 42
    //   28: aload_0
    //   29: getfield 423	org/eclipse/pde/api/tools/internal/model/ProjectComponent:fOutputLocationToContainer	Ljava/util/Map;
    //   32: invokeinterface 482 1 0
    //   37: aload_0
    //   38: aconst_null
    //   39: putfield 423	org/eclipse/pde/api/tools/internal/model/ProjectComponent:fOutputLocationToContainer	Ljava/util/Map;
    //   42: aload_0
    //   43: getfield 424	org/eclipse/pde/api/tools/internal/model/ProjectComponent:fPathToOutputContainers	Ljava/util/Map;
    //   46: ifnull +39 -> 85
    //   49: aload_0
    //   50: getfield 424	org/eclipse/pde/api/tools/internal/model/ProjectComponent:fPathToOutputContainers	Ljava/util/Map;
    //   53: invokeinterface 482 1 0
    //   58: aload_0
    //   59: aconst_null
    //   60: putfield 424	org/eclipse/pde/api/tools/internal/model/ProjectComponent:fPathToOutputContainers	Ljava/util/Map;
    //   63: goto +22 -> 85
    //   66: astore_1
    //   67: aload_1
    //   68: invokestatic 471	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:log	(Ljava/lang/Throwable;)V
    //   71: aload_0
    //   72: invokespecial 450	org/eclipse/pde/api/tools/internal/model/BundleComponent:dispose	()V
    //   75: goto +14 -> 89
    //   78: astore_2
    //   79: aload_0
    //   80: invokespecial 450	org/eclipse/pde/api/tools/internal/model/BundleComponent:dispose	()V
    //   83: aload_2
    //   84: athrow
    //   85: aload_0
    //   86: invokespecial 450	org/eclipse/pde/api/tools/internal/model/BundleComponent:dispose	()V
    //   89: return
    // Line number table:
    //   Java source line #168	-> byte code offset #0
    //   Java source line #169	-> byte code offset #7
    //   Java source line #171	-> byte code offset #16
    //   Java source line #172	-> byte code offset #21
    //   Java source line #173	-> byte code offset #28
    //   Java source line #174	-> byte code offset #37
    //   Java source line #176	-> byte code offset #42
    //   Java source line #177	-> byte code offset #49
    //   Java source line #178	-> byte code offset #58
    //   Java source line #181	-> byte code offset #66
    //   Java source line #182	-> byte code offset #67
    //   Java source line #185	-> byte code offset #71
    //   Java source line #184	-> byte code offset #78
    //   Java source line #185	-> byte code offset #79
    //   Java source line #186	-> byte code offset #83
    //   Java source line #185	-> byte code offset #85
    //   Java source line #187	-> byte code offset #89
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	90	0	this	ProjectComponent
    //   66	2	1	ce	CoreException
    //   78	6	2	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	63	66	org/eclipse/core/runtime/CoreException
    //   0	71	78	finally
  }
  
  protected IApiDescription createLocalApiDescription()
    throws CoreException
  {
    long time = System.currentTimeMillis();
    if (Util.isApiProject(getJavaProject())) {
      setHasApiDescription(true);
    }
    IApiDescription apiDesc = ApiDescriptionManager.getManager().getApiDescription(this, getBundleDescription());
    if (DEBUG) {
      System.out.println("Time to create api description for: [" + fProject.getElementName() + "] " + (System.currentTimeMillis() - time) + "ms");
    }
    return apiDesc;
  }
  
  protected IApiFilterStore createApiFilterStore()
    throws CoreException
  {
    long time = System.currentTimeMillis();
    IApiFilterStore store = new ApiFilterStore(getJavaProject());
    if (DEBUG) {
      System.out.println("Time to create api filter store for: [" + fProject.getElementName() + "] " + (System.currentTimeMillis() - time) + "ms");
    }
    return store;
  }
  
  protected synchronized List createApiTypeContainers()
    throws CoreException
  {
    fPathToOutputContainers = new HashMap(4);
    fOutputLocationToContainer = new HashMap(4);
    if ((fProject.exists()) && (fProject.getProject().isOpen()))
    {
      IPluginModelBase model = PluginRegistry.findModel(fProject.getProject());
      if (model != null)
      {
        IBuildModel buildModel = PluginRegistry.createBuildModel(model);
        if (buildModel != null)
        {
          IBuild build = buildModel.getBuild();
          IBuildEntry entry = build.getEntry("custom");
          if (entry != null)
          {
            String[] tokens = entry.getTokens();
            if ((tokens.length == 1) && (tokens[0].equals("true")))
            {
              IClasspathEntry[] classpathEntries = fProject.getRawClasspath();
              List containers = new ArrayList();
              for (int i = 0; i < classpathEntries.length; i++)
              {
                IClasspathEntry classpathEntry = classpathEntries[i];
                switch (classpathEntry.getEntryKind())
                {
                case 3: 
                  String containerPath = classpathEntry.getPath().removeFirstSegments(1).toString();
                  IApiTypeContainer container = getApiTypeContainer(containerPath, this);
                  if ((container != null) && (!containers.contains(container))) {
                    containers.add(container);
                  }
                  break;
                case 4: 
                  classpathEntry = JavaCore.getResolvedClasspathEntry(classpathEntry);
                case 1: 
                  IPath path = classpathEntry.getPath();
                  if (Util.isArchive(path.lastSegment()))
                  {
                    IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
                    if (resource != null) {
                      containers.add(new ArchiveApiTypeContainer(this, resource.getLocation().toOSString()));
                    } else {
                      containers.add(new ArchiveApiTypeContainer(this, path.toOSString()));
                    }
                  }
                  break;
                }
              }
              if (!containers.isEmpty())
              {
                IApiTypeContainer cfc = null;
                if (containers.size() == 1) {
                  cfc = (IApiTypeContainer)containers.get(0);
                } else {
                  cfc = new CompositeApiTypeContainer(this, containers);
                }
                fPathToOutputContainers.put(".", cfc);
              }
            }
          }
          else
          {
            IBuildEntry[] entries = build.getBuildEntries();
            int length = entries.length;
            for (int i = 0; i < length; i++)
            {
              IBuildEntry buildEntry = entries[i];
              String name = buildEntry.getName();
              if (name.startsWith("source.")) {
                retrieveContainers(name, "source.", buildEntry);
              } else if (name.startsWith("extra.")) {
                retrieveContainers(name, "extra.", buildEntry);
              }
            }
          }
        }
      }
      return super.createApiTypeContainers();
    }
    return Collections.EMPTY_LIST;
  }
  
  private void retrieveContainers(String name, String prefix, IBuildEntry buildEntry)
    throws CoreException
  {
    String jar = name.substring(prefix.length());
    String[] tokens = buildEntry.getTokens();
    if (tokens.length == 1)
    {
      IApiTypeContainer container = getApiTypeContainer(tokens[0], this);
      if (container != null)
      {
        IApiTypeContainer existingContainer = (IApiTypeContainer)fPathToOutputContainers.get(jar);
        if (existingContainer != null)
        {
          List allContainers = new ArrayList();
          allContainers.add(existingContainer);
          allContainers.add(container);
          IApiTypeContainer apiTypeContainer = new CompositeApiTypeContainer(this, allContainers);
          fPathToOutputContainers.put(jar, apiTypeContainer);
        }
        else
        {
          fPathToOutputContainers.put(jar, container);
        }
      }
    }
    else
    {
      List containers = new ArrayList();
      for (int j = 0; j < tokens.length; j++)
      {
        String currentToken = tokens[j];
        IApiTypeContainer container = getApiTypeContainer(currentToken, this);
        if ((container != null) && (!containers.contains(container))) {
          containers.add(container);
        }
      }
      if (!containers.isEmpty())
      {
        IApiTypeContainer existingContainer = (IApiTypeContainer)fPathToOutputContainers.get(jar);
        if (existingContainer != null) {
          containers.add(existingContainer);
        }
        IApiTypeContainer cfc = null;
        if (containers.size() == 1) {
          cfc = (IApiTypeContainer)containers.get(0);
        } else {
          cfc = new CompositeApiTypeContainer(this, containers);
        }
        fPathToOutputContainers.put(jar, cfc);
      }
    }
  }
  
  protected IApiTypeContainer createApiTypeContainer(String path)
    throws IOException, CoreException
  {
    if (fPathToOutputContainers == null) {
      baselineDisposed(getBaseline());
    }
    IApiTypeContainer container = (IApiTypeContainer)fPathToOutputContainers.get(path);
    if (container == null) {
      container = findApiTypeContainer(path);
    }
    return container;
  }
  
  private IApiTypeContainer findApiTypeContainer(String location)
  {
    IResource res = fProject.getProject().findMember(new Path(location));
    if (res != null)
    {
      if (res.getType() == 1) {
        return new ArchiveApiTypeContainer(this, res.getLocation().toOSString());
      }
      return new DirectoryApiTypeContainer(this, res.getLocation().toOSString());
    }
    return null;
  }
  
  private IApiTypeContainer getApiTypeContainer(String location, IApiComponent component)
    throws CoreException
  {
    if (fOutputLocationToContainer == null) {
      baselineDisposed(getBaseline());
    }
    IResource res = fProject.getProject().findMember(new Path(location));
    if (res != null)
    {
      IPackageFragmentRoot root = fProject.getPackageFragmentRoot(res);
      if (root.exists()) {
        if (root.getKind() == 2)
        {
          if (res.getType() == 2)
          {
            IPath location2 = res.getLocation();
            IApiTypeContainer cfc = (IApiTypeContainer)fOutputLocationToContainer.get(location2);
            if (cfc == null)
            {
              cfc = new ProjectTypeContainer(component, (IContainer)res);
              fOutputLocationToContainer.put(location2, cfc);
            }
            return cfc;
          }
        }
        else
        {
          IClasspathEntry entry = root.getRawClasspathEntry();
          IPath outputLocation = entry.getOutputLocation();
          if (outputLocation == null) {
            outputLocation = fProject.getOutputLocation();
          }
          IApiTypeContainer cfc = (IApiTypeContainer)fOutputLocationToContainer.get(outputLocation);
          if (cfc == null)
          {
            IPath projectFullPath = fProject.getProject().getFullPath();
            IContainer container = null;
            if (projectFullPath.equals(outputLocation)) {
              container = fProject.getProject();
            } else {
              container = fProject.getProject().getWorkspace().getRoot().getFolder(outputLocation);
            }
            cfc = new ProjectTypeContainer(component, container);
            fOutputLocationToContainer.put(outputLocation, cfc);
          }
          return cfc;
        }
      }
    }
    return null;
  }
  
  public IJavaProject getJavaProject()
  {
    return fProject;
  }
  
  public IApiTypeContainer getTypeContainer(IPackageFragmentRoot root)
    throws CoreException
  {
    if (root.getKind() == 1)
    {
      getApiTypeContainers();
      IResource resource = root.getResource();
      if (resource != null)
      {
        String location = resource.getProjectRelativePath().toString();
        return getApiTypeContainer(location, this);
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.ProjectComponent
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import java.util.List;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;

class ProjectTypeContainer$ContainerVisitor
  implements IResourceProxyVisitor
{
  List collector;
  int segmentcount;
  final ProjectTypeContainer this$0;
  
  public ProjectTypeContainer$ContainerVisitor(ProjectTypeContainer paramProjectTypeContainer, List collector, IContainer root)
  {
    this$0 = paramProjectTypeContainer;this.collector = null;segmentcount = 0;
    this.collector = collector;
    segmentcount = root.getFullPath().segmentCount();
  }
  
  public boolean visit(IResourceProxy proxy)
    throws CoreException
  {
    if (proxy.getType() == 2)
    {
      String path = proxy.requestFullPath().removeFirstSegments(segmentcount).toString();
      return collector.add(path.replace('/', '.'));
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.ProjectTypeContainer.ContainerVisitor
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.pde.api.tools.internal.provisional.model.ApiTypeContainerVisitor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;

public class ProjectTypeContainer
  extends ApiElement
  implements IApiTypeContainer
{
  private IContainer fRoot;
  
  class ContainerVisitor
    implements IResourceProxyVisitor
  {
    List collector = null;
    int segmentcount = 0;
    
    public ContainerVisitor(List collector, IContainer root)
    {
      this.collector = collector;
      segmentcount = root.getFullPath().segmentCount();
    }
    
    public boolean visit(IResourceProxy proxy)
      throws CoreException
    {
      if (proxy.getType() == 2)
      {
        String path = proxy.requestFullPath().removeFirstSegments(segmentcount).toString();
        return collector.add(path.replace('/', '.'));
      }
      return false;
    }
  }
  
  private String[] fPackageNames = null;
  
  public ProjectTypeContainer(IApiElement parent, IContainer container)
  {
    super(parent, 3, container.getName());
    fRoot = container;
  }
  
  public void accept(ApiTypeContainerVisitor visitor)
    throws CoreException
  {
    if (visitor.visit(this)) {
      doVisit(fRoot, "", visitor);
    }
    visitor.end(this);
  }
  
  public void close()
    throws CoreException
  {
    fPackageNames = null;
  }
  
  public String toString()
  {
    StringBuffer buff = new StringBuffer();
    buff.append("Project Class File Container: " + getName());
    return buff.toString();
  }
  
  private void doVisit(IContainer container, String pkgName, ApiTypeContainerVisitor visitor)
    throws CoreException
  {
    IResource[] members = container.members();
    List dirs = new ArrayList();
    boolean visitPkg = visitor.visitPackage(pkgName);
    for (int i = 0; i < members.length; i++)
    {
      IResource file = members[i];
      switch (file.getType())
      {
      case 2: 
        dirs.add(file);
        break;
      case 1: 
        if ((visitPkg) && (file.getName().endsWith(".class")))
        {
          String name = file.getName();
          String typeName = name.substring(0, name.length() - 6);
          if (pkgName.length() > 0)
          {
            StringBuffer buf = new StringBuffer(pkgName);
            buf.append('.');
            buf.append(typeName);
            typeName = buf.toString();
          }
          ResourceApiTypeRoot cf = new ResourceApiTypeRoot(this, (IFile)file, typeName);
          visitor.visit(pkgName, cf);
          visitor.end(pkgName, cf);
        }
        break;
      }
    }
    visitor.endVisitPackage(pkgName);
    Iterator iterator = dirs.iterator();
    while (iterator.hasNext())
    {
      IContainer child = (IContainer)iterator.next();
      String nextName = null;
      if (pkgName.length() == 0)
      {
        nextName = child.getName();
      }
      else
      {
        StringBuffer buffer = new StringBuffer(pkgName);
        buffer.append('.');
        buffer.append(child.getName());
        nextName = buffer.toString();
      }
      doVisit(child, nextName, visitor);
    }
  }
  
  public IApiTypeRoot findTypeRoot(String qualifiedName)
    throws CoreException
  {
    int index = qualifiedName.lastIndexOf('.');
    String cfName = qualifiedName;
    String pkg = "";
    if (index > 0)
    {
      pkg = qualifiedName.substring(0, index);
      cfName = qualifiedName.substring(index + 1);
    }
    IFolder folder = fRoot.getFolder(new Path(pkg.replace('.', '/')));
    if (folder.exists())
    {
      IFile file = folder.getFile(cfName + ".class");
      if (file.exists()) {
        return new ResourceApiTypeRoot(this, file, qualifiedName);
      }
    }
    return null;
  }
  
  public String[] getPackageNames()
    throws CoreException
  {
    if (fPackageNames == null)
    {
      List names = new ArrayList();
      collectPackageNames(names, "", fRoot);
      fPackageNames = ((String[])names.toArray(new String[names.size()]));
      Arrays.sort(fPackageNames);
    }
    return fPackageNames;
  }
  
  private void collectPackageNames(List names, String packageName, IContainer dir)
    throws CoreException
  {
    dir.accept(new ContainerVisitor(names, dir), 0);
  }
  
  public IApiTypeRoot findTypeRoot(String qualifiedName, String id)
    throws CoreException
  {
    return findTypeRoot(qualifiedName);
  }
  
  public int getContainerType()
  {
    return 3;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.ProjectTypeContainer
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import java.io.IOException;
import java.io.InputStream;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;
import org.eclipse.pde.api.tools.internal.util.Util;

public class ResourceApiTypeRoot
  extends AbstractApiTypeRoot
{
  private IFile fFile;
  
  public ResourceApiTypeRoot(IApiElement parent, IFile file, String typeName)
  {
    super(parent, typeName);
    fFile = file;
  }
  
  public byte[] getContents()
    throws CoreException
  {
    InputStream stream = fFile.getContents();
    try
    {
      return Util.getInputStreamAsByteArray(stream, -1);
    }
    catch (IOException ioe)
    {
      abort("Unable to read class file: " + getTypeName(), ioe);
      return null;
    }
    finally
    {
      try
      {
        stream.close();
      }
      catch (IOException e)
      {
        ApiPlugin.log(e);
      }
    }
  }
  
  public String getTypeName()
  {
    return getName();
  }
  
  public String toString()
  {
    return getTypeName();
  }
  
  public int hashCode()
  {
    return getName().hashCode();
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof IApiTypeRoot))
    {
      IApiTypeRoot file = (IApiTypeRoot)obj;
      return getName().equals(file.getTypeName());
    }
    return super.equals(obj);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.ResourceApiTypeRoot
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.launching.LibraryLocation;
import org.eclipse.pde.api.tools.internal.ApiBaselineManager;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
import org.eclipse.pde.api.tools.internal.provisional.ProfileModifiers;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.osgi.framework.Bundle;

public class StubApiComponent
  extends SystemLibraryApiComponent
{
  private static final String STUB_PATH = "/org/eclipse/pde/api/tools/internal/api_stubs/";
  private static Map AllSystemLibraryApiComponents;
  
  public static IApiComponent getStubApiComponent(int eeValue)
  {
    if (AllSystemLibraryApiComponents == null) {
      AllSystemLibraryApiComponents = new HashMap();
    }
    String name = ProfileModifiers.getName(eeValue);
    IApiComponent component = (IApiComponent)AllSystemLibraryApiComponents.get(name);
    if (component == null)
    {
      File stubFile = getFileFor(eeValue, name);
      if (stubFile == null) {
        return null;
      }
      component = new StubApiComponent(ApiBaselineManager.getManager().getWorkspaceBaseline(), stubFile.getAbsolutePath(), name);
      AllSystemLibraryApiComponents.put(name, component);
    }
    return component;
  }
  
  private static File getFileFor(int eeValue, String name)
  {
    try
    {
      String lname = name;
      switch (eeValue)
      {
      case 1: 
      case 2: 
      case 512: 
      case 1024: 
      case 2048: 
        lname = lname.replace('/', '_');
      }
      String stubName = lname + ".zip";
      URL stub = null;
      if (Platform.isRunning())
      {
        stub = ApiPlugin.getDefault().getBundle().getResource("/org/eclipse/pde/api/tools/internal/api_stubs/" + stubName);
        if (stub == null) {
          return null;
        }
        stub = FileLocator.toFileURL(stub);
      }
      else
      {
        stub = ApiPlugin.class.getResource("/org/eclipse/pde/api/tools/internal/api_stubs/" + stubName);
        if (stub == null) {
          return null;
        }
      }
      File stubFile = new File(stub.getFile());
      if (!stubFile.exists()) {
        return null;
      }
      return stubFile;
    }
    catch (IOException localIOException) {}
    return null;
  }
  
  public static String[] getInstalledMetadata()
  {
    List allEEs = new ArrayList();
    int[] allEEsValues = ProfileModifiers.getAllIds();
    String name = null;
    File stubFile = null;
    int eeValue = -1;
    for (int i = 0; i < allEEsValues.length; i++)
    {
      eeValue = allEEsValues[i];
      name = ProfileModifiers.getName(eeValue);
      switch (eeValue)
      {
      case 1: 
      case 2: 
      case 512: 
      case 1024: 
      case 2048: 
        name = name.replace('/', '_');
      }
      stubFile = getFileFor(eeValue, name);
      if (stubFile != null) {
        allEEs.add(ProfileModifiers.getName(eeValue));
      }
    }
    String[] result = new String[allEEs.size()];
    allEEs.toArray(result);
    Arrays.sort(result);
    return result;
  }
  
  private StubApiComponent(IApiBaseline baseline, String fileName, String profileName)
  {
    super(baseline);
    IPath path = new Path(fileName);
    fLibraries = new LibraryLocation[] { new LibraryLocation(path, null, null) };
    fExecEnv = new String[] { profileName };
    fVersion = fExecEnv[0];
    setName(fExecEnv[0]);
    fLocation = path.toOSString();
  }
  
  protected IApiDescription createApiDescription()
    throws CoreException
  {
    return null;
  }
  
  protected IApiFilterStore createApiFilterStore()
  {
    return null;
  }
  
  protected List createApiTypeContainers()
    throws CoreException
  {
    List libs = new ArrayList(fLibraries.length);
    for (int i = 0; i < fLibraries.length; i++)
    {
      LibraryLocation lib = fLibraries[i];
      libs.add(new StubArchiveApiTypeContainer(this, lib.getSystemLibraryPath().toOSString()));
    }
    return libs;
  }
  
  public boolean isSystemComponent()
  {
    return false;
  }
  
  public static void disposeAllCaches()
  {
    if (AllSystemLibraryApiComponents != null) {
      for (Iterator iterator = AllSystemLibraryApiComponents.values().iterator(); iterator.hasNext();)
      {
        IApiComponent apiComponent = (IApiComponent)iterator.next();
        apiComponent.dispose();
      }
    }
  }
  
  public static boolean isInstalled(int eeValue)
  {
    String name = ProfileModifiers.getName(eeValue);
    switch (eeValue)
    {
    case 1: 
    case 2: 
    case 512: 
    case 1024: 
    case 2048: 
      name = name.replace('/', '_');
    }
    File stubFile = getFileFor(eeValue, name);
    return stubFile != null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.StubApiComponent
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
import org.eclipse.pde.api.tools.internal.util.Util;

class StubArchiveApiTypeContainer$ArchiveApiTypeRoot
  extends AbstractApiTypeRoot
  implements Comparable
{
  private String fTypeName;
  
  public IApiType getStructure()
    throws CoreException
  {
    return TypeStructureBuilder.buildStubTypeStructure(getContents(), getApiComponent(), this);
  }
  
  public StubArchiveApiTypeContainer$ArchiveApiTypeRoot(StubArchiveApiTypeContainer container, String entryName)
  {
    super(container, entryName);
  }
  
  public String getTypeName()
  {
    if (fTypeName == null) {
      fTypeName = getName().replace('/', '.').substring(0, getName().length() - ".class".length());
    }
    return fTypeName;
  }
  
  public int compareTo(Object o)
  {
    return getTypeName().compareTo(((ArchiveApiTypeRoot)o).getTypeName());
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof ArchiveApiTypeRoot))
    {
      ArchiveApiTypeRoot classFile = (ArchiveApiTypeRoot)obj;
      return getName().equals(classFile.getName());
    }
    return false;
  }
  
  public int hashCode()
  {
    return getName().hashCode();
  }
  
  public byte[] getContents()
    throws CoreException
  {
    StubArchiveApiTypeContainer archive = (StubArchiveApiTypeContainer)getParent();
    ZipFile zipFile = archive.open();
    ZipEntry entry = zipFile.getEntry(getName());
    InputStream stream = null;
    if (entry != null)
    {
      try
      {
        stream = zipFile.getInputStream(entry);
      }
      catch (IOException e)
      {
        abort("Failed to open class file: " + getTypeName() + " in archive: " + fLocation, e);
        return null;
      }
      try
      {
        return Util.getInputStreamAsByteArray(stream, -1);
      }
      catch (IOException ioe)
      {
        abort("Unable to read class file: " + getTypeName(), ioe);
        return null;
      }
      finally
      {
        try
        {
          stream.close();
        }
        catch (IOException e)
        {
          ApiPlugin.log(e);
        }
      }
    }
    abort("Class file not found: " + getTypeName() + " in archive: " + fLocation, null);
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.StubArchiveApiTypeContainer.ArchiveApiTypeRoot
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
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 java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.model.ApiTypeContainerVisitor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiType;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;
import org.eclipse.pde.api.tools.internal.util.Util;

public class StubArchiveApiTypeContainer
  extends ApiElement
  implements IApiTypeContainer
{
  String fLocation;
  private Map fPackages;
  private String[] fPackageNames;
  
  static class ArchiveApiTypeRoot
    extends AbstractApiTypeRoot
    implements Comparable
  {
    private String fTypeName;
    
    public IApiType getStructure()
      throws CoreException
    {
      return TypeStructureBuilder.buildStubTypeStructure(getContents(), getApiComponent(), this);
    }
    
    public ArchiveApiTypeRoot(StubArchiveApiTypeContainer container, String entryName)
    {
      super(entryName);
    }
    
    public String getTypeName()
    {
      if (fTypeName == null) {
        fTypeName = getName().replace('/', '.').substring(0, getName().length() - ".class".length());
      }
      return fTypeName;
    }
    
    public int compareTo(Object o)
    {
      return getTypeName().compareTo(((ArchiveApiTypeRoot)o).getTypeName());
    }
    
    public boolean equals(Object obj)
    {
      if ((obj instanceof ArchiveApiTypeRoot))
      {
        ArchiveApiTypeRoot classFile = (ArchiveApiTypeRoot)obj;
        return getName().equals(classFile.getName());
      }
      return false;
    }
    
    public int hashCode()
    {
      return getName().hashCode();
    }
    
    public byte[] getContents()
      throws CoreException
    {
      StubArchiveApiTypeContainer archive = (StubArchiveApiTypeContainer)getParent();
      ZipFile zipFile = archive.open();
      ZipEntry entry = zipFile.getEntry(getName());
      InputStream stream = null;
      if (entry != null)
      {
        try
        {
          stream = zipFile.getInputStream(entry);
        }
        catch (IOException e)
        {
          abort("Failed to open class file: " + getTypeName() + " in archive: " + fLocation, e);
          return null;
        }
        try
        {
          return Util.getInputStreamAsByteArray(stream, -1);
        }
        catch (IOException ioe)
        {
          abort("Unable to read class file: " + getTypeName(), ioe);
          return null;
        }
        finally
        {
          try
          {
            stream.close();
          }
          catch (IOException e)
          {
            ApiPlugin.log(e);
          }
        }
      }
      abort("Class file not found: " + getTypeName() + " in archive: " + fLocation, null);
      return null;
    }
  }
  
  private ZipFile fZipFile = null;
  
  public StubArchiveApiTypeContainer(IApiElement parent, String path)
  {
    super(parent, 3, path);
    fLocation = path;
  }
  
  public void accept(ApiTypeContainerVisitor visitor)
    throws CoreException
  {
    if (visitor.visit(this))
    {
      init();
      List packages = new ArrayList(fPackages.keySet());
      Collections.sort(packages);
      Iterator iterator = packages.iterator();
      while (iterator.hasNext())
      {
        String pkg = (String)iterator.next();
        if (visitor.visitPackage(pkg))
        {
          List types = new ArrayList((Set)fPackages.get(pkg));
          Iterator cfIterator = types.iterator();
          List classFiles = new ArrayList(types.size());
          while (cfIterator.hasNext())
          {
            String entryName = (String)cfIterator.next();
            classFiles.add(new ArchiveApiTypeRoot(this, entryName));
          }
          Collections.sort(classFiles);
          cfIterator = classFiles.iterator();
          while (cfIterator.hasNext())
          {
            ArchiveApiTypeRoot classFile = (ArchiveApiTypeRoot)cfIterator.next();
            visitor.visit(pkg, classFile);
            visitor.end(pkg, classFile);
          }
        }
        visitor.endVisitPackage(pkg);
      }
    }
    visitor.end(this);
  }
  
  public String toString()
  {
    StringBuffer buff = new StringBuffer();
    buff.append("Archive Class File Container: " + getName());
    return buff.toString();
  }
  
  public synchronized void close()
    throws CoreException
  {
    if (fZipFile != null) {
      try
      {
        fZipFile.close();
        fZipFile = null;
      }
      catch (IOException e)
      {
        abort("Failed to close class file archive", e);
      }
    }
  }
  
  public IApiTypeRoot findTypeRoot(String qualifiedName)
    throws CoreException
  {
    init();
    int index = qualifiedName.lastIndexOf('.');
    String packageName = "";
    if (index >= 0) {
      packageName = qualifiedName.substring(0, index);
    }
    Set classFileNames = (Set)fPackages.get(packageName);
    if (classFileNames != null)
    {
      String fileName = qualifiedName.replace('.', '/');
      if (classFileNames.contains(fileName)) {
        return new ArchiveApiTypeRoot(this, fileName);
      }
    }
    return null;
  }
  
  public String[] getPackageNames()
    throws CoreException
  {
    init();
    synchronized (this)
    {
      if (fPackageNames == null)
      {
        Set names = fPackages.keySet();
        String[] result = new String[names.size()];
        names.toArray(result);
        Arrays.sort(result);
        fPackageNames = result;
      }
      return fPackageNames;
    }
  }
  
  private synchronized void init()
    throws CoreException
  {
    ZipFile zipFile = open();
    if (fPackages == null)
    {
      fPackages = new HashMap();
      Enumeration entries = zipFile.entries();
      while (entries.hasMoreElements())
      {
        ZipEntry entry = (ZipEntry)entries.nextElement();
        String name = entry.getName();
        String pkg = "";
        int index = name.lastIndexOf('/');
        if (index >= 0) {
          pkg = name.substring(0, index).replace('/', '.');
        }
        Set fileNames = (Set)fPackages.get(pkg);
        if (fileNames == null)
        {
          fileNames = new HashSet();
          fPackages.put(pkg, fileNames);
        }
        fileNames.add(name);
      }
    }
  }
  
  synchronized ZipFile open()
    throws CoreException
  {
    if (fZipFile == null) {
      try
      {
        fZipFile = new ZipFile(fLocation);
      }
      catch (IOException e)
      {
        abort("Failed to open archive: " + fLocation, e);
      }
    }
    return fZipFile;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof StubArchiveApiTypeContainer)) {
      return fLocation.equals(fLocation);
    }
    return false;
  }
  
  public int hashCode()
  {
    return fLocation.hashCode();
  }
  
  public IApiTypeRoot findTypeRoot(String qualifiedName, String id)
    throws CoreException
  {
    return findTypeRoot(qualifiedName);
  }
  
  public int getContainerType()
  {
    return 1;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.StubArchiveApiTypeContainer
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.internal.model;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.launching.LibraryLocation;
import org.eclipse.jdt.launching.environments.ExecutionEnvironmentDescription;
import org.eclipse.osgi.service.resolver.ResolverError;
import org.eclipse.pde.api.tools.internal.ApiDescription;
import org.eclipse.pde.api.tools.internal.provisional.Factory;
import org.eclipse.pde.api.tools.internal.provisional.IApiDescription;
import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
import org.eclipse.pde.api.tools.internal.provisional.IRequiredComponentDescription;
import org.eclipse.pde.api.tools.internal.provisional.descriptors.IPackageDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;

public class SystemLibraryApiComponent
  extends Component
{
  protected String[] fExecEnv;
  protected LibraryLocation[] fLibraries;
  protected String fLocation;
  protected String[] fSystemPackages;
  protected String fVersion;
  
  protected SystemLibraryApiComponent(IApiBaseline baseline)
  {
    super(baseline);
  }
  
  public SystemLibra
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

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