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

   //   159: goto +10 -> 169
    //   162: astore 11
    //   164: aload 11
    //   166: invokestatic 942	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:log	(Ljava/lang/Throwable;)V
    //   169: aload 6
    //   171: ifnull +18 -> 189
    //   174: aload 6
    //   176: invokevirtual 837	java/io/FileOutputStream:close	()V
    //   179: goto +10 -> 189
    //   182: astore 11
    //   184: aload 11
    //   186: invokestatic 942	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:log	(Ljava/lang/Throwable;)V
    //   189: aload 5
    //   191: areturn
    // Line number table:
    //   Java source line #745	-> byte code offset #0
    //   Java source line #747	-> byte code offset #3
    //   Java source line #749	-> byte code offset #6
    //   Java source line #750	-> byte code offset #13
    //   Java source line #751	-> byte code offset #27
    //   Java source line #752	-> byte code offset #34
    //   Java source line #753	-> byte code offset #42
    //   Java source line #755	-> byte code offset #48
    //   Java source line #756	-> byte code offset #59
    //   Java source line #757	-> byte code offset #66
    //   Java source line #758	-> byte code offset #69
    //   Java source line #759	-> byte code offset #78
    //   Java source line #760	-> byte code offset #83
    //   Java source line #757	-> byte code offset #93
    //   Java source line #763	-> byte code offset #104
    //   Java source line #764	-> byte code offset #106
    //   Java source line #766	-> byte code offset #111
    //   Java source line #767	-> byte code offset #119
    //   Java source line #768	-> byte code offset #121
    //   Java source line #771	-> byte code offset #126
    //   Java source line #773	-> byte code offset #131
    //   Java source line #774	-> byte code offset #139
    //   Java source line #775	-> byte code offset #141
    //   Java source line #778	-> byte code offset #146
    //   Java source line #764	-> byte code offset #149
    //   Java source line #766	-> byte code offset #154
    //   Java source line #767	-> byte code offset #162
    //   Java source line #768	-> byte code offset #164
    //   Java source line #771	-> byte code offset #169
    //   Java source line #773	-> byte code offset #174
    //   Java source line #774	-> byte code offset #182
    //   Java source line #775	-> byte code offset #184
    //   Java source line #779	-> byte code offset #189
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	192	0	this	BundleComponent
    //   0	192	1	zip	ZipFile
    //   0	192	2	entry	ZipEntry
    //   0	192	3	parent	File
    //   1	154	4	inputStream	InputStream
    //   25	28	5	file	File
    //   149	1	5	file	File
    //   189	1	5	file	File
    //   4	171	6	outputStream	java.io.FileOutputStream
    //   32	11	7	lparent	File
    //   64	22	8	bytes	byte[]
    //   76	13	9	read	int
    //   104	43	10	localObject	Object
    //   119	3	11	e	IOException
    //   139	3	11	e	IOException
    //   162	3	11	e	IOException
    //   182	3	11	e	IOException
    // Exception table:
    //   from	to	target	type
    //   6	104	104	finally
    //   111	116	119	java/io/IOException
    //   131	136	139	java/io/IOException
    //   154	159	162	java/io/IOException
    //   174	179	182	java/io/IOException
  }
  
  protected Map loadManifest(File bundleLocation)
    throws IOException
  {
    ZipFile jarFile = null;
    InputStream manifestStream = null;
    String extension = new Path(bundleLocation.getName()).getFileExtension();
    try
    {
      if ((extension != null) && (extension.equals("jar")) && (bundleLocation.isFile()))
      {
        jarFile = new ZipFile(bundleLocation, 1);
        ZipEntry manifestEntry = jarFile.getEntry("META-INF/MANIFEST.MF");
        if (manifestEntry != null) {
          manifestStream = jarFile.getInputStream(manifestEntry);
        }
      }
      else
      {
        File file = new File(bundleLocation, "META-INF/MANIFEST.MF");
        if (file.exists()) {
          manifestStream = new FileInputStream(file);
        }
      }
      if (manifestStream == null) {
        return null;
      }
      return ManifestElement.parseBundleManifest(manifestStream, new Hashtable(10));
    }
    catch (BundleException e)
    {
      ApiPlugin.log(e);
    }
    finally
    {
      closingZipFileAndStream(manifestStream, jarFile);
    }
    return null;
  }
  
  protected Manifest readManifest(File bundleLocation)
    throws IOException
  {
    ZipFile jarFile = null;
    InputStream manifestStream = null;
    try
    {
      String extension = new Path(bundleLocation.getName()).getFileExtension();
      if ((extension != null) && (extension.equals("jar")) && (bundleLocation.isFile()))
      {
        jarFile = new ZipFile(bundleLocation, 1);
        ZipEntry manifestEntry = jarFile.getEntry("META-INF/MANIFEST.MF");
        if (manifestEntry != null) {
          manifestStream = jarFile.getInputStream(manifestEntry);
        }
      }
      else
      {
        File file = new File(bundleLocation, "META-INF/MANIFEST.MF");
        if (file.exists()) {
          manifestStream = new FileInputStream(file);
        }
      }
      if (manifestStream == null) {
        return null;
      }
      return new Manifest(manifestStream);
    }
    finally
    {
      closingZipFileAndStream(manifestStream, jarFile);
    }
  }
  
  void closingZipFileAndStream(InputStream stream, ZipFile jarFile)
  {
    try
    {
      if (stream != null) {
        stream.close();
      }
    }
    catch (IOException e)
    {
      ApiPlugin.log(e);
    }
    try
    {
      if (jarFile != null) {
        jarFile.close();
      }
    }
    catch (IOException e)
    {
      ApiPlugin.log(e);
    }
  }
  
  protected String readFileContents(String xmlFileName, File bundleLocation)
  {
    ZipFile jarFile = null;
    InputStream stream = null;
    try
    {
      String extension = new Path(bundleLocation.getName()).getFileExtension();
      if ((extension != null) && (extension.equals("jar")) && (bundleLocation.isFile()))
      {
        jarFile = new ZipFile(bundleLocation, 1);
        ZipEntry manifestEntry = jarFile.getEntry(xmlFileName);
        if (manifestEntry != null) {
          stream = jarFile.getInputStream(manifestEntry);
        }
      }
      else
      {
        File file = new File(bundleLocation, xmlFileName);
        if (file.exists()) {
          stream = new FileInputStream(file);
        }
      }
      if (stream == null) {
        return null;
      }
      return new String(Util.getInputStreamAsCharArray(stream, -1, "UTF-8"));
    }
    catch (IOException e)
    {
      ApiPlugin.log(e);
    }
    finally
    {
      closingZipFileAndStream(stream, jarFile);
    }
    return null;
  }
  
  protected String loadApiDescription(File bundleLocation)
    throws IOException
  {
    ZipFile jarFile = null;
    InputStream stream = null;
    String contents = null;
    try
    {
      String extension = new Path(bundleLocation.getName()).getFileExtension();
      if ((extension != null) && (extension.equals("jar")) && (bundleLocation.isFile()))
      {
        jarFile = new ZipFile(bundleLocation, 1);
        ZipEntry manifestEntry = jarFile.getEntry(".api_description");
        if (manifestEntry != null) {
          stream = jarFile.getInputStream(manifestEntry);
        }
      }
      else
      {
        File file = new File(bundleLocation, ".api_description");
        if (file.exists()) {
          stream = new FileInputStream(file);
        }
      }
      if (stream == null) {
        return null;
      }
      char[] charArray = Util.getInputStreamAsCharArray(stream, -1, "UTF-8");
      contents = new String(charArray);
    }
    finally
    {
      closingZipFileAndStream(stream, jarFile);
    }
    closingZipFileAndStream(stream, jarFile);
    
    return contents;
  }
  
  protected URL getFileInBundle(File bundleLocation, String filePath)
    throws MalformedURLException
  {
    String extension = new Path(bundleLocation.getName()).getFileExtension();
    StringBuffer urlSt = new StringBuffer();
    if ((extension != null) && (extension.equals("jar")) && (bundleLocation.isFile()))
    {
      urlSt.append("jar:file:");
      urlSt.append(bundleLocation.getAbsolutePath());
      urlSt.append("!/");
      urlSt.append(filePath);
    }
    else
    {
      urlSt.append("file:");
      urlSt.append(bundleLocation.getAbsolutePath());
      urlSt.append(File.separatorChar);
      urlSt.append(filePath);
    }
    return new URL(urlSt.toString());
  }
  
  public synchronized String[] getExecutionEnvironments()
    throws CoreException
  {
    if (fBundleDescription == null) {
      baselineDisposed(getBaseline());
    }
    return fBundleDescription.getExecutionEnvironments();
  }
  
  public final String getSymbolicName()
  {
    init();
    return fSymbolicName;
  }
  
  public synchronized IRequiredComponentDescription[] getRequiredComponents()
    throws CoreException
  {
    if (fBundleDescription == null) {
      baselineDisposed(getBaseline());
    }
    BundleSpecification[] requiredBundles = fBundleDescription.getRequiredBundles();
    IRequiredComponentDescription[] req = new IRequiredComponentDescription[requiredBundles.length];
    for (int i = 0; i < requiredBundles.length; i++)
    {
      BundleSpecification bundle = requiredBundles[i];
      req[i] = new RequiredComponentDescription(bundle.getName(), 
        new BundleVersionRange(bundle.getVersionRange()), 
        bundle.isOptional(), 
        bundle.isExported());
    }
    return req;
  }
  
  public synchronized String getVersion()
  {
    init();
    
    StringBuffer buffer = new StringBuffer();
    buffer.append(fVersion.getMajor()).append('.').append(fVersion.getMinor()).append('.').append(fVersion.getMicro());
    return String.valueOf(buffer);
  }
  
  public synchronized BundleDescription getBundleDescription()
    throws CoreException
  {
    init();
    if (fBundleDescription == null) {
      baselineDisposed(getBaseline());
    }
    return fBundleDescription;
  }
  
  public String toString()
  {
    if (fBundleDescription != null)
    {
      try
      {
        StringBuffer buffer = new StringBuffer();
        buffer.append(fBundleDescription.toString());
        buffer.append(" - ");
        buffer.append("[fragment: ").append(isFragment()).append("] ");
        buffer.append("[host: ").append(fBundleDescription.getFragments().length > 0).append("] ");
        buffer.append("[system bundle: ").append(isSystemComponent()).append("] ");
        buffer.append("[source bundle: ").append(isSourceComponent()).append("] ");
        buffer.append("[dev bundle: ").append(fWorkspaceBinary).append("]");
        return buffer.toString();
      }
      catch (CoreException localCoreException) {}
    }
    else
    {
      StringBuffer buffer = new StringBuffer();
      buffer.append("Un-initialized Bundle Component");
      buffer.append("[location: ").append(fLocation).append("]");
      buffer.append("[dev bundle: ").append(fWorkspaceBinary).append("]");
      return buffer.toString();
    }
    return super.toString();
  }
  
  public String getLocation()
  {
    return fLocation;
  }
  
  public boolean isSystemComponent()
  {
    return false;
  }
  
  public synchronized boolean isSourceComponent()
    throws CoreException
  {
    getManifest();
    if (fManifest == null) {
      baselineDisposed(getBaseline());
    }
    ManifestElement[] sourceBundle = (ManifestElement[])null;
    try
    {
      sourceBundle = ManifestElement.parseHeader("Eclipse-SourceBundle", (String)fManifest.get("Eclipse-SourceBundle"));
    }
    catch (BundleException localBundleException) {}
    if (sourceBundle != null) {
      return true;
    }
    String pluginXMLContents = readFileContents("plugin.xml", new File(getLocation()));
    if ((pluginXMLContents != null) && 
      (containsSourceExtensionPoint(pluginXMLContents))) {
      return true;
    }
    pluginXMLContents = readFileContents("fragment.xml", new File(getLocation()));
    if ((pluginXMLContents != null) && 
      (containsSourceExtensionPoint(pluginXMLContents))) {
      return true;
    }
    return false;
  }
  
  private boolean containsSourceExtensionPoint(String pluginXMLContents)
  {
    SAXParserFactory factory = null;
    try
    {
      factory = SAXParserFactory.newInstance();
    }
    catch (FactoryConfigurationError localFactoryConfigurationError)
    {
      return false;
    }
    SAXParser saxParser = null;
    try
    {
      saxParser = factory.newSAXParser();
    }
    catch (ParserConfigurationException localParserConfigurationException) {}catch (SAXException localSAXException1) {}
    if (saxParser == null) {
      return false;
    }
    InputSource inputSource = new InputSource(new BufferedReader(new StringReader(pluginXMLContents)));
    try
    {
      SourceDefaultHandler defaultHandler = new SourceDefaultHandler();
      saxParser.parse(inputSource, defaultHandler);
      return defaultHandler.isSource();
    }
    catch (SAXException localSAXException2) {}catch (IOException localIOException) {}
    return false;
  }
  
  public synchronized boolean isFragment()
    throws CoreException
  {
    init();
    if (fBundleDescription == null) {
      baselineDisposed(getBaseline());
    }
    return fBundleDescription.getHost() != null;
  }
  
  public synchronized IApiComponent getHost()
    throws CoreException
  {
    init();
    if (fBundleDescription == null) {
      baselineDisposed(getBaseline());
    }
    HostSpecification host = fBundleDescription.getHost();
    if (host != null) {
      return getBaseline().getApiComponent(host.getName());
    }
    return null;
  }
  
  public synchronized boolean hasFragments()
    throws CoreException
  {
    return getBundleDescription().getFragments().length != 0;
  }
  
  protected void setHasApiDescription(boolean hasApiDescription)
  {
    fHasApiDescription = hasApiDescription;
  }
  
  public boolean hasApiDescription()
  {
    try
    {
      getApiDescription();
    }
    catch (CoreException localCoreException) {}
    return fHasApiDescription;
  }
  
  public String[] getLowestEEs()
    throws CoreException
  {
    if (lowestEEs != null) {
      return lowestEEs;
    }
    String[] temp = (String[])null;
    String[] executionEnvironments = getExecutionEnvironments();
    int length = executionEnvironments.length;
    switch (length)
    {
    case 0: 
      return null;
    case 1: 
      temp = new String[] { executionEnvironments[0] };
      break;
    default: 
      int values = 0;
      for (int i = 0; i < length; i++) {
        values |= ProfileModifiers.getValue(executionEnvironments[i]);
      }
      if (ProfileModifiers.isJRE(values)) {
        if (ProfileModifiers.isJRE_1_1(values)) {
          temp = new String[] { "JRE-1.1" };
        } else if (ProfileModifiers.isJ2SE_1_2(values)) {
          temp = new String[] { "J2SE-1.2" };
        } else if (ProfileModifiers.isJ2SE_1_3(values)) {
          temp = new String[] { "J2SE-1.3" };
        } else if (ProfileModifiers.isJ2SE_1_4(values)) {
          temp = new String[] { "J2SE-1.4" };
        } else if (ProfileModifiers.isJ2SE_1_5(values)) {
          temp = new String[] { "J2SE-1.5" };
        } else if (ProfileModifiers.isJAVASE_1_6(values)) {
          temp = new String[] { "JavaSE-1.6" };
        } else {
          temp = new String[] { "JavaSE-1.7" };
        }
      }
      if (ProfileModifiers.isCDC_Foundation(values)) {
        if (ProfileModifiers.isCDC_1_0_FOUNDATION_1_0(values))
        {
          if (temp != null) {
            temp = new String[] { temp[0], "CDC-1.0/Foundation-1.0" };
          } else {
            temp = new String[] { "CDC-1.0/Foundation-1.0" };
          }
        }
        else if (temp != null) {
          temp = new String[] { temp[0], "CDC-1.1/Foundation-1.1" };
        } else {
          temp = new String[] { "CDC-1.1/Foundation-1.1" };
        }
      }
      if (ProfileModifiers.isOSGi(values)) {
        if (ProfileModifiers.isOSGI_MINIMUM_1_0(values))
        {
          if (temp != null)
          {
            int tempLength = temp.length;
            System.arraycopy(temp, 0, temp = new String[tempLength + 1], 0, tempLength);
            temp[tempLength] = "OSGi/Minimum-1.0";
          }
          else
          {
            temp = new String[] { "OSGi/Minimum-1.0" };
          }
        }
        else if (ProfileModifiers.isOSGI_MINIMUM_1_1(values))
        {
          if (temp != null)
          {
            int tempLength = temp.length;
            System.arraycopy(temp, 0, temp = new String[tempLength + 1], 0, tempLength);
            temp[tempLength] = "OSGi/Minimum-1.1";
          }
          else
          {
            temp = new String[] { "OSGi/Minimum-1.1" };
          }
        }
        else if (temp != null)
        {
          int tempLength = temp.length;
          System.arraycopy(temp, 0, temp = new String[tempLength + 1], 0, tempLength);
          temp[tempLength] = "OSGi/Minimum-1.2";
        }
        else
        {
          temp = new String[] { "OSGi/Minimum-1.2" };
        }
      }
      break;
    }
    lowestEEs = temp;
    return temp;
  }
  
  public synchronized ResolverError[] getErrors()
    throws CoreException
  {
    init();
    ApiBaseline baseline = (ApiBaseline)getBaseline();
    if (fBundleDescription == null) {
      baselineDisposed(baseline);
    }
    if (baseline != null)
    {
      ResolverError[] resolverErrors = baseline.getState().getResolverErrors(fBundleDescription);
      if (resolverErrors.length == 0) {
        return null;
      }
      return resolverErrors;
    }
    return null;
  }
  
  protected void baselineDisposed(IApiBaseline baseline)
    throws CoreException
  {
    throw new CoreException(
      new Status(
      4, 
      "org.eclipse.pde.api.tools", 
      123, 
      NLS.bind(Messages.BundleApiComponent_baseline_disposed, baseline.getName()), 
      null));
  }
}

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

import org.eclipse.core.runtime.CoreException;
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.descriptors.IElementDescriptor;
import org.eclipse.pde.api.tools.internal.provisional.model.ApiTypeContainerVisitor;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
import org.eclipse.pde.api.tools.internal.search.IReferenceCollection;
import org.eclipse.pde.api.tools.internal.search.UseScanReferences;

public abstract class Component
  extends AbstractApiTypeContainer
  implements IApiComponent
{
  private IApiDescription fApiDescription = null;
  private IApiFilterStore fFilterStore = null;
  private IReferenceCollection fReferences;
  
  public Component(IApiBaseline baseline)
  {
    super(baseline, 1, null);
  }
  
  public void accept(ApiTypeContainerVisitor visitor)
    throws CoreException
  {
    if (visitor.visit(this)) {
      super.accept(visitor);
    }
    visitor.end(this);
  }
  
  public IApiComponent getHost()
    throws CoreException
  {
    return null;
  }
  
  public IApiBaseline getBaseline()
  {
    return (IApiBaseline)getAncestor(4);
  }
  
  /* Error */
  public void dispose()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokevirtual 106	org/eclipse/pde/api/tools/internal/model/Component:close	()V
    //   4: goto +45 -> 49
    //   7: astore_1
    //   8: aload_1
    //   9: invokestatic 113	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:log	(Ljava/lang/Throwable;)V
    //   12: aload_0
    //   13: dup
    //   14: astore_3
    //   15: monitorenter
    //   16: aload_0
    //   17: aconst_null
    //   18: putfield 99	org/eclipse/pde/api/tools/internal/model/Component:fApiDescription	Lorg/eclipse/pde/api/tools/internal/provisional/IApiDescription;
    //   21: aload_3
    //   22: monitorexit
    //   23: goto +43 -> 66
    //   26: aload_3
    //   27: monitorexit
    //   28: athrow
    //   29: astore_2
    //   30: aload_0
    //   31: dup
    //   32: astore_3
    //   33: monitorenter
    //   34: aload_0
    //   35: aconst_null
    //   36: putfield 99	org/eclipse/pde/api/tools/internal/model/Component:fApiDescription	Lorg/eclipse/pde/api/tools/internal/provisional/IApiDescription;
    //   39: aload_3
    //   40: monitorexit
    //   41: goto +6 -> 47
    //   44: aload_3
    //   45: monitorexit
    //   46: athrow
    //   47: aload_2
    //   48: athrow
    //   49: aload_0
    //   50: dup
    //   51: astore_3
    //   52: monitorenter
    //   53: aload_0
    //   54: aconst_null
    //   55: putfield 99	org/eclipse/pde/api/tools/internal/model/Component:fApiDescription	Lorg/eclipse/pde/api/tools/internal/provisional/IApiDescription;
    //   58: aload_3
    //   59: monitorexit
    //   60: goto +6 -> 66
    //   63: aload_3
    //   64: monitorexit
    //   65: athrow
    //   66: return
    // Line number table:
    //   Java source line #86	-> byte code offset #0
    //   Java source line #87	-> byte code offset #7
    //   Java source line #88	-> byte code offset #8
    //   Java source line #91	-> byte code offset #12
    //   Java source line #92	-> byte code offset #16
    //   Java source line #91	-> byte code offset #21
    //   Java source line #90	-> byte code offset #29
    //   Java source line #91	-> byte code offset #30
    //   Java source line #92	-> byte code offset #34
    //   Java source line #91	-> byte code offset #39
    //   Java source line #94	-> byte code offset #47
    //   Java source line #91	-> byte code offset #49
    //   Java source line #92	-> byte code offset #53
    //   Java source line #91	-> byte code offset #58
    //   Java source line #95	-> byte code offset #66
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	67	0	this	Component
    //   7	2	1	e	CoreException
    //   29	19	2	localObject1	Object
    //   14	13	3	Ljava/lang/Object;	Object
    //   32	13	3	Ljava/lang/Object;	Object
    //   51	13	3	Ljava/lang/Object;	Object
    // Exception table:
    //   from	to	target	type
    //   0	4	7	org/eclipse/core/runtime/CoreException
    //   16	23	26	finally
    //   26	28	26	finally
    //   0	12	29	finally
    //   34	41	44	finally
    //   44	46	44	finally
    //   53	60	63	finally
    //   63	65	63	finally
  }
  
  public IApiComponent getApiComponent()
  {
    return this;
  }
  
  public synchronized IApiDescription getApiDescription()
    throws CoreException
  {
    if (fApiDescription == null) {
      fApiDescription = createApiDescription();
    }
    return fApiDescription;
  }
  
  protected synchronized boolean isApiDescriptionInitialized()
  {
    return fApiDescription != null;
  }
  
  protected synchronized boolean hasApiFilterStore()
  {
    return fFilterStore != null;
  }
  
  public synchronized IApiTypeContainer[] getApiTypeContainers()
    throws CoreException
  {
    return super.getApiTypeContainers();
  }
  
  public synchronized IApiTypeContainer[] getApiTypeContainers(String id)
    throws CoreException
  {
    if (hasFragments()) {
      return super.getApiTypeContainers(id);
    }
    return super.getApiTypeContainers();
  }
  
  protected abstract IApiDescription createApiDescription()
    throws CoreException;
  
  public IApiFilterStore getFilterStore()
    throws CoreException
  {
    if (fFilterStore == null) {
      fFilterStore = createApiFilterStore();
    }
    return fFilterStore;
  }
  
  public IElementDescriptor getHandle()
  {
    return Factory.componentDescriptor(getSymbolicName(), getVersion());
  }
  
  public int getContainerType()
  {
    return 4;
  }
  
  protected abstract IApiFilterStore createApiFilterStore()
    throws CoreException;
  
  public IReferenceCollection getExternalDependencies()
  {
    if (fReferences == null) {
      fReferences = new UseScanReferences();
    }
    return fReferences;
  }
}

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

import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiElement;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;

public class CompositeApiTypeContainer
  extends AbstractApiTypeContainer
{
  private List fContainers;
  
  public CompositeApiTypeContainer(IApiElement parent, List containers)
  {
    super(parent, 3, "Composite Class File Container");
    fContainers = containers;
  }
  
  protected List createApiTypeContainers()
    throws CoreException
  {
    return fContainers;
  }
  
  public String toString()
  {
    StringBuffer buff = new StringBuffer();
    buff.append("Composite Class File Container:\n");
    if (fContainers == null)
    {
      buff.append("\t<EMPTY>");
    }
    else
    {
      IApiTypeContainer container = null;
      for (Iterator iter = fContainers.iterator(); iter.hasNext();)
      {
        container = (IApiTypeContainer)iter.next();
        buff.append("\t" + container.toString());
      }
    }
    return buff.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.CompositeApiTypeContainer
 * 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.FileFilter;

class DirectoryApiTypeContainer$1
  implements FileFilter
{
  final DirectoryApiTypeContainer this$0;
  
  DirectoryApiTypeContainer$1(DirectoryApiTypeContainer paramDirectoryApiTypeContainer)
  {
    this$0 = paramDirectoryApiTypeContainer;
  }
  
  public boolean accept(File file)
  {
    return (file.isFile()) && (file.getName().endsWith(".class"));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.DirectoryApiTypeContainer.1
 * 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.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.util.Util;

class DirectoryApiTypeContainer$LocalApiTypeRoot
  extends AbstractApiTypeRoot
  implements Comparable
{
  String fLocation = null;
  
  public DirectoryApiTypeContainer$LocalApiTypeRoot(DirectoryApiTypeContainer directory, String location, String typeName)
  {
    super(directory, typeName);
    fLocation = location;
  }
  
  public String getTypeName()
  {
    return getName();
  }
  
  public int compareTo(Object o)
  {
    return getName().compareTo(((LocalApiTypeRoot)o).getName());
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof LocalApiTypeRoot)) {
      return ((LocalApiTypeRoot)obj).getName().equals(getName());
    }
    return false;
  }
  
  public int hashCode()
  {
    return getName().hashCode();
  }
  
  public byte[] getContents()
    throws CoreException
  {
    InputStream stream = null;
    try
    {
      stream = new FileInputStream(new File(fLocation));
    }
    catch (FileNotFoundException e)
    {
      abort("File not found", 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);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.DirectoryApiTypeContainer.LocalApiTypeRoot
 * 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.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
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.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.IApiTypeContainer;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeRoot;
import org.eclipse.pde.api.tools.internal.util.Util;

public class DirectoryApiTypeContainer
  extends ApiElement
  implements IApiTypeContainer
{
  private Map fPackages;
  private String[] fPackageNames;
  
  static class LocalApiTypeRoot
    extends AbstractApiTypeRoot
    implements Comparable
  {
    String fLocation = null;
    
    public LocalApiTypeRoot(DirectoryApiTypeContainer directory, String location, String typeName)
    {
      super(typeName);
      fLocation = location;
    }
    
    public String getTypeName()
    {
      return getName();
    }
    
    public int compareTo(Object o)
    {
      return getName().compareTo(((LocalApiTypeRoot)o).getName());
    }
    
    public boolean equals(Object obj)
    {
      if ((obj instanceof LocalApiTypeRoot)) {
        return ((LocalApiTypeRoot)obj).getName().equals(getName());
      }
      return false;
    }
    
    public int hashCode()
    {
      return getName().hashCode();
    }
    
    public byte[] getContents()
      throws CoreException
    {
      InputStream stream = null;
      try
      {
        stream = new FileInputStream(new File(fLocation));
      }
      catch (FileNotFoundException e)
      {
        abort("File not found", 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);
        }
      }
    }
  }
  
  public DirectoryApiTypeContainer(IApiElement parent, String location)
  {
    super(parent, 3, location);
  }
  
  public void accept(ApiTypeContainerVisitor visitor)
    throws CoreException
  {
    if (visitor.visit(this))
    {
      init();
      String[] packageNames = getPackageNames();
      for (int i = 0; i < packageNames.length; i++)
      {
        String pkg = packageNames[i];
        if (visitor.visitPackage(pkg))
        {
          String location = (String)fPackages.get(pkg);
          if (location == null) {
            continue;
          }
          File dir = new File(location);
          if (!dir.exists()) {
            continue;
          }
          File[] files = dir.listFiles(new FileFilter()
          {
            public boolean accept(File file)
            {
              return (file.isFile()) && (file.getName().endsWith(".class"));
            }
          });
          if (files != null)
          {
            List classFiles = new ArrayList();
            for (int j = 0; j < files.length; j++)
            {
              String name = files[j].getName();
              String typeName = name.substring(0, name.length() - 6);
              if (pkg.length() > 0) {
                typeName = pkg + "." + typeName;
              }
              classFiles.add(new LocalApiTypeRoot(this, files[j].getAbsolutePath(), typeName));
            }
            Collections.sort(classFiles);
            Iterator cfIterator = classFiles.iterator();
            while (cfIterator.hasNext())
            {
              IApiTypeRoot classFile = (IApiTypeRoot)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("Directory Class File Container: " + getName());
    return buff.toString();
  }
  
  public synchronized void close()
    throws CoreException
  {
    fPackages = null;
    fPackageNames = null;
  }
  
  public IApiTypeRoot findTypeRoot(String qualifiedName)
    throws CoreException
  {
    init();
    int index = qualifiedName.lastIndexOf('.');
    String cfName = qualifiedName;
    String pkg = "";
    if (index > 0)
    {
      pkg = qualifiedName.substring(0, index);
      cfName = qualifiedName.substring(index + 1);
    }
    String location = (String)fPackages.get(pkg);
    if (location != null)
    {
      File file = new File(location, cfName + ".class");
      if (file.exists()) {
        return new LocalApiTypeRoot(this, file.getAbsolutePath(), qualifiedName);
      }
    }
    return null;
  }
  
  public String[] getPackageNames()
    throws CoreException
  {
    init();
    if (fPackageNames == null)
    {
      List names = new ArrayList(fPackages.keySet());
      String[] result = new String[names.size()];
      names.toArray(result);
      Arrays.sort(result);
      fPackageNames = result;
    }
    return fPackageNames;
  }
  
  private synchronized void init()
  {
    if (fPackages == null)
    {
      fPackages = new HashMap();
      processDirectory("", new File(getName()));
    }
  }
  
  private void processDirectory(String packageName, File dir)
  {
    File[] files = dir.listFiles();
    if (files != null)
    {
      boolean hasClassFiles = false;
      List dirs = new ArrayList();
      for (int i = 0; i < files.length; i++)
      {
        File file = files[i];
        if (file.isDirectory())
        {
          dirs.add(file.getAbsoluteFile());
        }
        else if ((!hasClassFiles) && 
          (file.getName().endsWith(".class")))
        {
          fPackages.put(packageName, dir.getAbsolutePath());
          hasClassFiles = true;
        }
      }
      Iterator iterator = dirs.iterator();
      while (iterator.hasNext())
      {
        File child = (File)iterator.next();
        String nextName = null;
        if (packageName.length() == 0) {
          nextName = child.getName();
        } else {
          nextName = packageName + "." + child.getName();
        }
        processDirectory(nextName, child);
      }
    }
  }
  
  public IApiTypeRoot findTypeRoot(String qualifiedName, String id)
    throws CoreException
  {
    return findTypeRoot(qualifiedName);
  }
  
  public int getContainerType()
  {
    return 2;
  }
}

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

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.pde.api.tools.internal.model.Messages";
  public static String adding_component__0;
  public static String ApiType_0;
  public static String ApiType_1;
  public static String ApiType_2;
  public static String ApiType_3;
  public static String ApiScope_0;
  public static String BundleApiComponent_baseline_disposed;
  public static String BundleComponent_failed_to_lookup_fragment;
  public static String configuring_baseline;
  public static String resolving_target_definition;
  
  static
  {
    NLS.initializeMessages("org.eclipse.pde.api.tools.internal.model.Messages", Messages.class);
  }
}

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

public class MethodKey
{
  private String fSelector;
  private String fSig;
  private String fTypename;
  private boolean fConsiderTypename = false;
  
  public MethodKey(String typename, String name, String sig, boolean considertypename)
  {
    fTypename = typename;
    fSelector = name;
    fSig = sig;
    fConsiderTypename = considertypename;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj instanceof MethodKey))
    {
      MethodKey key = (MethodKey)obj;
      
      return (fSelector.equals(fSelector)) && (signaturesEqual(fSig, fSig)) && ((!fConsiderTypename) || (fTypename.equals(fTypename)));
    }
    return false;
  }
  
  public int hashCode()
  {
    return (fConsiderTypename ? fTypename.hashCode() : 0) + fSelector.hashCode() + (fSig == null ? 0 : fSig.hashCode());
  }
  
  boolean signaturesEqual(String sig1, String sig2)
  {
    if (sig1 != null) {
      return sig1.equals(sig2);
    }
    return sig2 == null;
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer();
    buf.append("Method Key: [enclosing type - ").append(fTypename).append("] ");
    buf.append("[method name - ").append(fSelector).append("] ");
    buf.append("[signature - ").append(fSig).append("] ");
    return buf.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.internal.model.MethodKey
 * 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.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.api.tools.internal.ApiDescriptionManager;
import org.eclipse.pde.api.tools.internal.ApiFilterStore;
import org.eclipse.pde.api.tools.internal.CoreMessages;
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.model.IApiBaseline;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiTypeContainer;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.eclipse.pde.core.build.IBuild;
import org.eclipse.pde.core.build.IBuildEntry;
import org.eclipse.pde.core.build.IBuildModel;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.core.plugin.PluginRegistry;
import org.osgi.framework.BundleException;

public class ProjectComponent
  extends BundleComponent
{
  public static final String ENTRY_CUSTOM = "custom";
  public static final String EXTRA_PREFIX = "extra.";
  private sta
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