org.eclipse.osgi_3.7.2.v20120110-1415

  //   Java source line #282	-> byte code offset #449
    //   Java source line #284	-> byte code offset #456
    //   Java source line #285	-> byte code offset #466
    //   Java source line #289	-> byte code offset #467
    //   Java source line #290	-> byte code offset #473
    //   Java source line #291	-> byte code offset #517
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	518	0	this	PluginConverterImpl
    //   0	518	1	generationLocation	File
    //   0	518	2	manifestToWrite	Dictionary<String, String>
    //   0	518	3	compatibilityManifest	boolean
    //   3	497	4	start	long
    //   16	3	6	parentFile	File
    //   394	27	6	e	IOException
    //   52	7	7	message	String
    //   342	33	7	keys	Enumeration<String>
    //   412	7	7	message	String
    //   357	7	8	key	String
    //   426	21	9	localObject	Object
    //   445	1	12	localIOException1	IOException
    //   466	1	13	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   5	391	394	java/io/IOException
    //   5	426	426	finally
    //   435	442	445	java/io/IOException
    //   456	463	466	java/io/IOException
  }
  
  private void generateLocalizationEntry()
  {
    generatedManifest.put("Bundle-Localization", "plugin");
  }
  
  private void generateManifestVersion()
  {
    generatedManifest.put("Manifest-Version", "1.0");
  }
  
  private boolean requireRuntimeCompatibility()
  {
    ArrayList<PluginParser.Prerequisite> requireList = pluginInfo.getRequires();
    for (Iterator<PluginParser.Prerequisite> iter = requireList.iterator(); iter.hasNext();) {
      if (((PluginParser.Prerequisite)iter.next()).getName().equalsIgnoreCase("org.eclipse.core.runtime.compatibility")) {
        return true;
      }
    }
    return false;
  }
  
  private void generateActivator()
  {
    if (!pluginInfo.isFragment()) {
      if (!requireRuntimeCompatibility())
      {
        String pluginClass = pluginInfo.getPluginClass();
        if ((pluginClass != null) && (!pluginClass.trim().equals(""))) {
          generatedManifest.put("Bundle-Activator", pluginClass);
        }
      }
      else
      {
        generatedManifest.put("Bundle-Activator", "org.eclipse.core.internal.compatibility.PluginActivator");
      }
    }
  }
  
  private void generateClasspath()
  {
    String[] classpath = pluginInfo.getLibrariesName();
    if (classpath.length != 0) {
      generatedManifest.put("Bundle-ClassPath", getStringFromArray(classpath, ",\n "));
    }
  }
  
  private void generateHeaders()
  {
    if (TARGET31.compareTo(target) <= 0) {
      generatedManifest.put("Bundle-ManifestVersion", "2");
    }
    generatedManifest.put("Bundle-Name", pluginInfo.getPluginName());
    generatedManifest.put("Bundle-Version", pluginInfo.getVersion());
    generatedManifest.put("Bundle-SymbolicName", getSymbolicNameEntry());
    String provider = pluginInfo.getProviderName();
    if (provider != null) {
      generatedManifest.put("Bundle-Vendor", provider);
    }
    if (pluginInfo.isFragment())
    {
      StringBuffer hostBundle = new StringBuffer();
      hostBundle.append(pluginInfo.getMasterId());
      String versionRange = getVersionRange(pluginInfo.getMasterVersion(), pluginInfo.getMasterMatch());
      if (versionRange != null) {
        hostBundle.append(versionRange);
      }
      generatedManifest.put("Fragment-Host", hostBundle.toString());
    }
  }
  
  private String getSymbolicNameEntry()
  {
    if (!pluginInfo.isSingleton()) {
      return pluginInfo.getUniqueId();
    }
    StringBuffer result = new StringBuffer(pluginInfo.getUniqueId());
    result.append("; ");
    result.append("singleton");
    String assignment = TARGET31.compareTo(target) <= 0 ? ":=" : "=";
    result.append(assignment).append("true");
    return result.toString();
  }
  
  private void generatePluginClass()
  {
    if (requireRuntimeCompatibility())
    {
      String pluginClass = pluginInfo.getPluginClass();
      if (pluginClass != null) {
        generatedManifest.put("Plugin-Class", pluginClass);
      }
    }
  }
  
  private void generateProvidePackage()
  {
    Set<String> exports = getExports();
    if ((exports != null) && (exports.size() != 0)) {
      generatedManifest.put(TARGET31.compareTo(target) <= 0 ? "Export-Package" : "Provide-Package", getStringFromCollection(exports, ",\n "));
    }
  }
  
  private void generateRequireBundle()
  {
    ArrayList<PluginParser.Prerequisite> requiredBundles = pluginInfo.getRequires();
    if (requiredBundles.size() == 0) {
      return;
    }
    StringBuffer bundleRequire = new StringBuffer();
    for (Iterator<PluginParser.Prerequisite> iter = requiredBundles.iterator(); iter.hasNext();)
    {
      PluginParser.Prerequisite element = (PluginParser.Prerequisite)iter.next();
      StringBuffer modImport = new StringBuffer(element.getName());
      String versionRange = getVersionRange(element.getVersion(), element.getMatch());
      if (versionRange != null) {
        modImport.append(versionRange);
      }
      if (element.isExported()) {
        if (TARGET31.compareTo(target) <= 0) {
          modImport.append(';').append("visibility").append(":=").append("reexport");
        } else {
          modImport.append(';').append("reprovide").append("=true");
        }
      }
      if (element.isOptional()) {
        if (TARGET31.compareTo(target) <= 0) {
          modImport.append(';').append("resolution").append(":=").append("optional");
        } else {
          modImport.append(';').append("optional").append("=true");
        }
      }
      bundleRequire.append(modImport.toString());
      if (iter.hasNext()) {
        bundleRequire.append(",\n ");
      }
    }
    generatedManifest.put("Require-Bundle", bundleRequire.toString());
  }
  
  private void generateTimestamp()
  {
    generatedManifest.put("Generated-from", Long.toString(getTimeStamp(pluginManifestLocation, manifestType)) + ";" + "type" + "=" + manifestType);
  }
  
  private void generateEclipseHeaders()
  {
    if (pluginInfo.isFragment()) {
      return;
    }
    String pluginClass = pluginInfo.getPluginClass();
    if ((pluginInfo.hasExtensionExtensionPoints()) || ((pluginClass != null) && (!pluginClass.trim().equals("")))) {
      generatedManifest.put(TARGET32.compareTo(target) <= 0 ? "Eclipse-LazyStart" : "Eclipse-AutoStart", "true");
    }
  }
  
  private Set<String> getExports()
  {
    Map<String, List<String>> libs = pluginInfo.getLibraries();
    if (libs == null) {
      return null;
    }
    if ((devProperties != null) || (DevClassPathHelper.inDevelopmentMode()))
    {
      String[] devClassPath = DevClassPathHelper.getDevClassPath(pluginInfo.getUniqueId(), devProperties);
      
      List<String> allExportClauses = new ArrayList(libs.size());
      Set<Map.Entry<String, List<String>>> libEntries = libs.entrySet();
      for (Iterator<Map.Entry<String, List<String>>> iter = libEntries.iterator(); iter.hasNext();)
      {
        Map.Entry<String, List<String>> element = (Map.Entry)iter.next();
        allExportClauses.addAll((Collection)element.getValue());
      }
      if (devClassPath != null)
      {
        String[] ignoreDotProp = DevClassPathHelper.getDevClassPath("@ignoredot@", devProperties);
        if ((devClassPath.length > 0) && (ignoreDotProp != null) && (ignoreDotProp.length > 0) && ("true".equals(ignoreDotProp[0]))) {
          libs.remove(".");
        }
        for (int i = 0; i < devClassPath.length; i++) {
          libs.put(devClassPath[i], allExportClauses);
        }
      }
    }
    Set<String> result = new TreeSet();
    Set<Map.Entry<String, List<String>>> libEntries = libs.entrySet();
    for (Iterator<Map.Entry<String, List<String>>> iter = libEntries.iterator(); iter.hasNext();)
    {
      Map.Entry<String, List<String>> element = (Map.Entry)iter.next();
      List<String> filter = (List)element.getValue();
      if (filter.size() != 0)
      {
        String libEntryText = ((String)element.getKey()).trim();
        File libraryLocation;
        File libraryLocation;
        if (libEntryText.equals("."))
        {
          libraryLocation = pluginManifestLocation;
        }
        else
        {
          File libEntryAsPath = new File(libEntryText);
          libraryLocation = libEntryAsPath.isAbsolute() ? libEntryAsPath : new File(pluginManifestLocation, libEntryText);
        }
        Set<String> exports = null;
        if (libraryLocation.exists())
        {
          if (libraryLocation.isFile()) {
            exports = filterExport(getExportsFromJAR(libraryLocation), filter);
          } else if (libraryLocation.isDirectory()) {
            exports = filterExport(getExportsFromDir(libraryLocation), filter);
          }
        }
        else
        {
          List<String> expandedLibs = getLibrariesExpandingVariables((String)element.getKey(), false);
          exports = new HashSet();
          for (Iterator<String> iterator = expandedLibs.iterator(); iterator.hasNext();)
          {
            String libName = (String)iterator.next();
            File libFile = new File(pluginManifestLocation, libName);
            if (libFile.isFile()) {
              exports.addAll(filterExport(getExportsFromJAR(libFile), filter));
            }
          }
        }
        if (exports != null) {
          result.addAll(exports);
        }
      }
    }
    return result;
  }
  
  private Set<String> getExportsFromDir(File location)
  {
    return getExportsFromDir(location, "");
  }
  
  private Set<String> getExportsFromDir(File location, String packageName)
  {
    String prefix = packageName.length() > 0 ? packageName + '.' : "";
    String[] files = location.list();
    Set<String> exportedPaths = new HashSet();
    boolean containsFile = false;
    if (files != null) {
      for (int i = 0; i < files.length; i++) {
        if (isValidPackageName(files[i]))
        {
          File pkgFile = new File(location, files[i]);
          if (pkgFile.isDirectory()) {
            exportedPaths.addAll(getExportsFromDir(pkgFile, prefix + files[i]));
          } else {
            containsFile = true;
          }
        }
      }
    }
    if (containsFile) {
      if (packageName.length() > 0) {
        exportedPaths.add(packageName);
      } else {
        exportedPaths.add(".");
      }
    }
    return exportedPaths;
  }
  
  private Set<String> getExportsFromJAR(File jarFile)
  {
    Set<String> names = new HashSet();
    ZipFile file = null;
    try
    {
      file = new ZipFile(jarFile);
    }
    catch (IOException e)
    {
      String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_PLUGIN_LIBRARY_IGNORED, jarFile, pluginInfo.getUniqueId());
      adaptor.getFrameworkLog().log(new FrameworkLogEntry("org.eclipse.osgi", 4, 0, message, 0, e, null));
      return names;
    }
    for (Enumeration<? extends ZipEntry> entriesEnum = file.entries(); entriesEnum.hasMoreElements();)
    {
      ZipEntry entry = (ZipEntry)entriesEnum.nextElement();
      String name = entry.getName();
      if (isValidPackageName(name))
      {
        int lastSlash = name.lastIndexOf("/");
        if (lastSlash != -1)
        {
          if ((lastSlash != name.length() - 1) && (name.lastIndexOf(' ') == -1)) {
            names.add(name.substring(0, lastSlash).replace('/', '.'));
          }
        }
        else {
          names.add(".");
        }
      }
    }
    try
    {
      file.close();
    }
    catch (IOException localIOException1) {}
    return names;
  }
  
  private List<String> getLibrariesExpandingVariables(String libraryPath, boolean filter)
  {
    String var = hasPrefix(libraryPath);
    if (var == null)
    {
      List<String> returnValue = new ArrayList(1);
      returnValue.add(libraryPath);
      return returnValue;
    }
    if (var.equals("ws")) {
      return findWSJars(pluginManifestLocation, libraryPath, filter);
    }
    if (var.equals("os")) {
      return findOSJars(pluginManifestLocation, libraryPath, filter);
    }
    return new ArrayList(0);
  }
  
  private String hasPrefix(String libPath)
  {
    if (libPath.startsWith("$ws$")) {
      return "ws";
    }
    if (libPath.startsWith("$os$")) {
      return "os";
    }
    if (libPath.startsWith("$nl$")) {
      return "nl";
    }
    return null;
  }
  
  private boolean isValidPackageName(String name)
  {
    if ((name.indexOf(' ') > 0) || (name.equalsIgnoreCase("META-INF")) || (name.startsWith("META-INF/"))) {
      return false;
    }
    return true;
  }
  
  private IPluginInfo parsePluginInfo(InputStream pluginLocation)
    throws PluginConversionException
  {
    InputStream input = null;
    try
    {
      input = new BufferedInputStream(pluginLocation);
      return new PluginParser(adaptor, context, target).parsePlugin(input);
    }
    catch (Exception e)
    {
      String message = NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_ERROR_PARSING_PLUGIN_MANIFEST, pluginManifestLocation);
      throw new PluginConversionException(message, e);
    }
    finally
    {
      if (input != null) {
        try
        {
          input.close();
        }
        catch (IOException localIOException2) {}
      }
    }
  }
  
  /* Error */
  public static boolean upToDate(File generationLocation, File pluginLocation, byte manifestType)
  {
    // Byte code:
    //   0: aload_0
    //   1: invokevirtual 889	java/io/File:isFile	()Z
    //   4: ifne +5 -> 9
    //   7: iconst_0
    //   8: ireturn
    //   9: aconst_null
    //   10: astore_3
    //   11: aconst_null
    //   12: astore 4
    //   14: new 516	java/io/BufferedReader
    //   17: dup
    //   18: new 523	java/io/InputStreamReader
    //   21: dup
    //   22: new 519	java/io/FileInputStream
    //   25: dup
    //   26: aload_0
    //   27: invokespecial 897	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   30: invokespecial 900	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;)V
    //   33: invokespecial 877	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   36: astore 4
    //   38: aload 4
    //   40: invokevirtual 878	java/io/BufferedReader:readLine	()Ljava/lang/String;
    //   43: pop
    //   44: aload 4
    //   46: invokevirtual 878	java/io/BufferedReader:readLine	()Ljava/lang/String;
    //   49: astore_3
    //   50: goto +39 -> 89
    //   53: pop
    //   54: aload 4
    //   56: ifnull +12 -> 68
    //   59: aload 4
    //   61: invokevirtual 876	java/io/BufferedReader:close	()V
    //   64: goto +4 -> 68
    //   67: pop
    //   68: iconst_0
    //   69: ireturn
    //   70: astore 5
    //   72: aload 4
    //   74: ifnull +12 -> 86
    //   77: aload 4
    //   79: invokevirtual 876	java/io/BufferedReader:close	()V
    //   82: goto +4 -> 86
    //   85: pop
    //   86: aload 5
    //   88: athrow
    //   89: aload 4
    //   91: ifnull +12 -> 103
    //   94: aload 4
    //   96: invokevirtual 876	java/io/BufferedReader:close	()V
    //   99: goto +4 -> 103
    //   102: pop
    //   103: ldc_w 484
    //   106: astore 5
    //   108: aload_3
    //   109: ifnull +12 -> 121
    //   112: aload_3
    //   113: aload 5
    //   115: invokevirtual 918	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   118: ifne +5 -> 123
    //   121: iconst_0
    //   122: ireturn
    //   123: aload_3
    //   124: aload 5
    //   126: invokevirtual 907	java/lang/String:length	()I
    //   129: invokevirtual 913	java/lang/String:substring	(I)Ljava/lang/String;
    //   132: astore_3
    //   133: ldc 7
    //   135: aload_3
    //   136: invokestatic 1001	org/eclipse/osgi/util/ManifestElement:parseHeader	(Ljava/lang/String;Ljava/lang/String;)[Lorg/eclipse/osgi/util/ManifestElement;
    //   139: iconst_0
    //   140: aaload
    //   141: astore 6
    //   143: goto +6 -> 149
    //   146: pop
    //   147: iconst_0
    //   148: ireturn
    //   149: aload 6
    //   151: invokevirtual 999	org/eclipse/osgi/util/ManifestElement:getValue	()Ljava/lang/String;
    //   154: astore 7
    //   156: aload 7
    //   158: invokevirtual 911	java/lang/String:trim	()Ljava/lang/String;
    //   161: invokestatic 905	java/lang/Long:parseLong	(Ljava/lang/String;)J
    //   164: aload_1
    //   165: iload_2
    //   166: invokestatic 962	org/eclipse/core/runtime/internal/adaptor/PluginConverterImpl:getTimeStamp	(Ljava/io/File;B)J
    //   169: lcmp
    //   170: ifne +5 -> 175
    //   173: iconst_1
    //   174: ireturn
    //   175: iconst_0
    //   176: ireturn
    //   177: pop
    //   178: iconst_0
    //   179: ireturn
    // Line number table:
    //   Java source line #611	-> byte code offset #0
    //   Java source line #612	-> byte code offset #7
    //   Java source line #613	-> byte code offset #9
    //   Java source line #614	-> byte code offset #11
    //   Java source line #616	-> byte code offset #14
    //   Java source line #617	-> byte code offset #38
    //   Java source line #618	-> byte code offset #44
    //   Java source line #619	-> byte code offset #53
    //   Java source line #623	-> byte code offset #54
    //   Java source line #625	-> byte code offset #59
    //   Java source line #626	-> byte code offset #67
    //   Java source line #621	-> byte code offset #68
    //   Java source line #622	-> byte code offset #70
    //   Java source line #623	-> byte code offset #72
    //   Java source line #625	-> byte code offset #77
    //   Java source line #626	-> byte code offset #85
    //   Java source line #629	-> byte code offset #86
    //   Java source line #623	-> byte code offset #89
    //   Java source line #625	-> byte code offset #94
    //   Java source line #626	-> byte code offset #102
    //   Java source line #630	-> byte code offset #103
    //   Java source line #631	-> byte code offset #108
    //   Java source line #632	-> byte code offset #121
    //   Java source line #634	-> byte code offset #123
    //   Java source line #637	-> byte code offset #133
    //   Java source line #638	-> byte code offset #146
    //   Java source line #639	-> byte code offset #147
    //   Java source line #641	-> byte code offset #149
    //   Java source line #643	-> byte code offset #156
    //   Java source line #644	-> byte code offset #177
    //   Java source line #647	-> byte code offset #178
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	180	0	generationLocation	File
    //   0	180	1	pluginLocation	File
    //   0	180	2	manifestType	byte
    //   10	126	3	secondLine	String
    //   12	83	4	reader	java.io.BufferedReader
    //   70	17	5	localObject	Object
    //   106	19	5	tag	String
    //   141	3	6	generatedFrom	ManifestElement
    //   149	1	6	generatedFrom	ManifestElement
    //   154	3	7	timestampStr	String
    //   53	1	10	localIOException1	IOException
    //   67	1	11	localIOException2	IOException
    //   85	1	12	localIOException3	IOException
    //   102	1	13	localIOException4	IOException
    //   146	1	14	localBundleException	org.osgi.framework.BundleException
    //   177	1	15	localNumberFormatException	NumberFormatException
    // Exception table:
    //   from	to	target	type
    //   14	50	53	java/io/IOException
    //   59	64	67	java/io/IOException
    //   14	54	70	finally
    //   77	82	85	java/io/IOException
    //   94	99	102	java/io/IOException
    //   133	143	146	org/osgi/framework/BundleException
    //   156	176	177	java/lang/NumberFormatException
  }
  
  public static long getTimeStamp(File pluginLocation, byte manifestType)
  {
    if ((manifestType & 0x8) != 0) {
      return pluginLocation.lastModified();
    }
    if ((manifestType & 0x2) != 0) {
      return new File(pluginLocation, "plugin.xml").lastModified();
    }
    if ((manifestType & 0x4) != 0) {
      return new File(pluginLocation, "fragment.xml").lastModified();
    }
    if ((manifestType & 0x1) != 0) {
      return new File(pluginLocation, "META-INF/MANIFEST.MF").lastModified();
    }
    return -1L;
  }
  
  private void writeEntry(String key, String value)
    throws IOException
  {
    if ((value != null) && (value.length() > 0))
    {
      out.write(splitOnComma(key + ": " + value));
      out.write(10);
    }
  }
  
  private String splitOnComma(String value)
  {
    if ((value.length() < MAXLINE) || (value.indexOf("\n ") >= 0)) {
      return value;
    }
    String[] values = ManifestElement.getArrayFromList(value);
    if ((values == null) || (values.length == 0)) {
      return value;
    }
    StringBuffer sb = new StringBuffer(value.length() + (values.length - 1) * ",\n ".length());
    for (int i = 0; i < values.length - 1; i++) {
      sb.append(values[i]).append(",\n ");
    }
    sb.append(values[(values.length - 1)]);
    return sb.toString();
  }
  
  private String getStringFromArray(String[] values, String separator)
  {
    if (values == null) {
      return "";
    }
    StringBuffer result = new StringBuffer();
    for (int i = 0; i < values.length; i++)
    {
      if (i > 0) {
        result.append(separator);
      }
      result.append(values[i]);
    }
    return result.toString();
  }
  
  private String getStringFromCollection(Collection<String> collection, String separator)
  {
    StringBuffer result = new StringBuffer();
    boolean first = true;
    for (Iterator<String> i = collection.iterator(); i.hasNext();)
    {
      if (first) {
        first = false;
      } else {
        result.append(separator);
      }
      result.append((String)i.next());
    }
    return result.toString();
  }
  
  public synchronized Dictionary<String, String> convertManifest(File pluginBaseLocation, boolean compatibility, String targetVersion, boolean analyseJars, Dictionary<String, String> devProps)
    throws PluginConversionException
  {
    long start = System.currentTimeMillis();
    if (DEBUG) {
      System.out.println("Convert " + pluginBaseLocation);
    }
    init();
    target = (targetVersion == null ? TARGET32 : new Version(targetVersion));
    devProperties = devProps;
    fillPluginInfo(pluginBaseLocation);
    fillManifest(compatibility, analyseJars);
    if (DEBUG) {
      System.out.println("Time to convert manifest for: " + pluginBaseLocation + ": " + (System.currentTimeMillis() - start) + "ms.");
    }
    return generatedManifest;
  }
  
  public synchronized File convertManifest(File pluginBaseLocation, File bundleManifestLocation, boolean compatibilityManifest, String targetVersion, boolean analyseJars, Dictionary<String, String> devProps)
    throws PluginConversionException
  {
    convertManifest(pluginBaseLocation, compatibilityManifest, targetVersion, analyseJars, devProps);
    if (bundleManifestLocation == null)
    {
      String cacheLocation = FrameworkProperties.getProperty("osgi.manifest.cache");
      bundleManifestLocation = new File(cacheLocation, pluginInfo.getUniqueId() + '_' + pluginInfo.getVersion() + ".MF");
    }
    if (upToDate(bundleManifestLocation, pluginManifestLocation, manifestType)) {
      return bundleManifestLocation;
    }
    writeManifest(bundleManifestLocation, generatedManifest, compatibilityManifest);
    return bundleManifestLocation;
  }
  
  private String getVersionRange(String reqVersion, String matchRule)
  {
    if (reqVersion == null) {
      return null;
    }
    Version minVersion = Version.parseVersion(reqVersion);
    String versionRange;
    String versionRange;
    if (matchRule != null)
    {
      String versionRange;
      if (matchRule.equalsIgnoreCase("perfect"))
      {
        versionRange = new VersionRange(minVersion, true, minVersion, true).toString();
      }
      else
      {
        String versionRange;
        if (matchRule.equalsIgnoreCase("equivalent"))
        {
          versionRange = new VersionRange(minVersion, true, new Version(minVersion.getMajor(), minVersion.getMinor() + 1, 0, ""), false).toString();
        }
        else
        {
          String versionRange;
          if (matchRule.equalsIgnoreCase("compatible"))
          {
            versionRange = new VersionRange(minVersion, true, new Version(minVersion.getMajor() + 1, 0, 0, ""), false).toString();
          }
          else
          {
            String versionRange;
            if (matchRule.equalsIgnoreCase("greaterOrEqual")) {
              versionRange = reqVersion;
            } else {
              versionRange = new VersionRange(minVersion, true, new Version(minVersion.getMajor() + 1, 0, 0, ""), false).toString();
            }
          }
        }
      }
    }
    else
    {
      versionRange = new VersionRange(minVersion, true, new Version(minVersion.getMajor() + 1, 0, 0, ""), false).toString();
    }
    StringBuffer result = new StringBuffer();
    result.append(';').append("bundle-version").append('=');
    result.append('"').append(versionRange).append('"');
    return result.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.PluginConverterImpl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Version;

public class PluginParser$PluginInfo
  implements IPluginInfo
{
  String schemaVersion;
  String pluginId;
  String version;
  String vendor;
  List<String> libraryPaths;
  Map<String, List<String>> libraries;
  ArrayList<PluginParser.Prerequisite> requires;
  private boolean requiresExpanded = false;
  boolean compatibilityFound = false;
  String pluginClass;
  String masterPluginId;
  String masterVersion;
  String masterMatch;
  private Set<String> filters;
  String pluginName;
  boolean singleton;
  boolean fragment;
  private static final String TARGET21_STRING = "2.1";
  boolean hasExtensionExtensionPoints = false;
  final PluginParser this$0;
  
  public PluginParser$PluginInfo(PluginParser paramPluginParser) {}
  
  public boolean isFragment()
  {
    return fragment;
  }
  
  public String toString()
  {
    return "plugin-id: " + pluginId + "  version: " + version + " libraries: " + libraries + " class:" + pluginClass + " master: " + masterPluginId + " master-version: " + masterVersion + " requires: " + requires + " singleton: " + singleton;
  }
  
  public Map<String, List<String>> getLibraries()
  {
    if (libraries == null) {
      return new HashMap(0);
    }
    return libraries;
  }
  
  public ArrayList<PluginParser.Prerequisite> getRequires()
  {
    if ((!PluginParser.TARGET21.equals(this$0.target)) && (schemaVersion == null) && (!requiresExpanded))
    {
      requiresExpanded = true;
      if (requires == null)
      {
        requires = new ArrayList(1);
        requires.add(new PluginParser.Prerequisite(this$0, "org.eclipse.core.runtime", "2.1", false, false, "greaterOrEqual"));
        requires.add(new PluginParser.Prerequisite(this$0, "org.eclipse.core.runtime.compatibility", null, false, false, null));
      }
      else
      {
        for (int i = 0; i < requires.size(); i++)
        {
          PluginParser.Prerequisite analyzed = (PluginParser.Prerequisite)requires.get(i);
          if ("org.eclipse.ui".equals(analyzed.getName()))
          {
            requires.add(i + 1, new PluginParser.Prerequisite(this$0, "org.eclipse.ui.workbench.texteditor", null, true, analyzed.isExported(), null));
            requires.add(i + 1, new PluginParser.Prerequisite(this$0, "org.eclipse.jface.text", null, true, analyzed.isExported(), null));
            requires.add(i + 1, new PluginParser.Prerequisite(this$0, "org.eclipse.ui.editors", null, true, analyzed.isExported(), null));
            requires.add(i + 1, new PluginParser.Prerequisite(this$0, "org.eclipse.ui.views", null, true, analyzed.isExported(), null));
            requires.add(i + 1, new PluginParser.Prerequisite(this$0, "org.eclipse.ui.ide", null, true, analyzed.isExported(), null));
          }
          else if ("org.eclipse.help".equals(analyzed.getName()))
          {
            requires.add(i + 1, new PluginParser.Prerequisite(this$0, "org.eclipse.help.base", null, true, analyzed.isExported(), null));
          }
          else if (("org.eclipse.core.runtime".equals(analyzed.getName())) && (!compatibilityFound))
          {
            requires.add(i + 1, new PluginParser.Prerequisite(this$0, "org.eclipse.core.runtime.compatibility", null, false, analyzed.isExported(), null));
          }
        }
        if (!requires.contains(new PluginParser.Prerequisite(this$0, "org.eclipse.core.runtime.compatibility", null, false, false, null))) {
          requires.add(new PluginParser.Prerequisite(this$0, "org.eclipse.core.runtime.compatibility", null, false, false, null));
        }
        PluginParser.Prerequisite runtimePrereq = new PluginParser.Prerequisite(this$0, "org.eclipse.core.runtime", null, false, false, null);
        requires.remove(runtimePrereq);
        requires.add(new PluginParser.Prerequisite(this$0, "org.eclipse.core.runtime", "2.1", false, false, "greaterOrEqual"));
      }
    }
    if (requires == null) {
      return requires = new ArrayList(0);
    }
    return requires;
  }
  
  public String getMasterId()
  {
    return masterPluginId;
  }
  
  public String getMasterVersion()
  {
    return masterVersion;
  }
  
  public String getMasterMatch()
  {
    return masterMatch;
  }
  
  public String getPluginClass()
  {
    return pluginClass;
  }
  
  public String getUniqueId()
  {
    return pluginId;
  }
  
  public String getVersion()
  {
    return version;
  }
  
  public Set<String> getPackageFilters()
  {
    return filters;
  }
  
  public String[] getLibrariesName()
  {
    if (libraryPaths == null) {
      return new String[0];
    }
    return (String[])libraryPaths.toArray(new String[libraryPaths.size()]);
  }
  
  public String getPluginName()
  {
    return pluginName;
  }
  
  public String getProviderName()
  {
    return vendor;
  }
  
  public boolean isSingleton()
  {
    return singleton;
  }
  
  public boolean hasExtensionExtensionPoints()
  {
    return hasExtensionExtensionPoints;
  }
  
  public String getRoot()
  {
    return isFragment() ? "fragment" : "plugin";
  }
  
  public String validateForm()
  {
    if (pluginId == null) {
      return NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_MISSING_ATTRIBUTE, new String[] { getRoot(), "id", getRoot() });
    }
    if (pluginName == null) {
      return NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_MISSING_ATTRIBUTE, new String[] { getRoot(), "name", getRoot() });
    }
    if (version == null) {
      return NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_MISSING_ATTRIBUTE, new String[] { getRoot(), "version", getRoot() });
    }
    if ((isFragment()) && (masterPluginId == null)) {
      return NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_MISSING_ATTRIBUTE, new String[] { getRoot(), "plugin-id", getRoot() });
    }
    if ((isFragment()) && (masterVersion == null)) {
      return NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_MISSING_ATTRIBUTE, new String[] { getRoot(), "plugin-version", getRoot() });
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.PluginParser.PluginInfo
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

public class PluginParser$Prerequisite
{
  String name;
  String version;
  boolean optional;
  boolean export;
  String match;
  final PluginParser this$0;
  
  public boolean isExported()
  {
    return export;
  }
  
  public String getMatch()
  {
    return match;
  }
  
  public String getName()
  {
    return name;
  }
  
  public boolean isOptional()
  {
    return optional;
  }
  
  public String getVersion()
  {
    return version;
  }
  
  public PluginParser$Prerequisite(PluginParser paramPluginParser, String preqName, String prereqVersion, boolean isOtional, boolean isExported, String prereqMatch)
  {
    name = preqName;
    version = prereqVersion;
    optional = isOtional;
    export = isExported;
    match = prereqMatch;
  }
  
  public String toString()
  {
    return name;
  }
  
  public boolean equals(Object prereq)
  {
    if (!(prereq instanceof Prerequisite)) {
      return false;
    }
    return name.equals(name);
  }
  
  public int hashCode()
  {
    return name.hashCode();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.core.runtime.internal.adaptor.PluginParser.Prerequisite
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.core.runtime.internal.adaptor;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Version;
import org.osgi.util.tracker.ServiceTracker;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;

public class PluginParser
  extends DefaultHandler
  implements IModel
{
  private static ServiceTracker<SAXParserFactory, SAXParserFactory> xmlTracker = null;
  private PluginInfo manifestInfo = new PluginInfo();
  private BundleContext context;
  private FrameworkAdaptor adaptor;
  Version target;
  static final Version TARGET21 = new Version(2, 1, 0);
  
  public class PluginInfo
    implements IPluginInfo
  {
    String schemaVersion;
    String pluginId;
    String version;
    String vendor;
    List<String> libraryPaths;
    Map<String, List<String>> libraries;
    ArrayList<PluginParser.Prerequisite> requires;
    private boolean requiresExpanded = false;
    boolean compatibilityFound = false;
    String pluginClass;
    String masterPluginId;
    String masterVersion;
    String masterMatch;
    private Set<String> filters;
    String pluginName;
    boolean singleton;
    boolean fragment;
    private static final String TARGET21_STRING = "2.1";
    boolean hasExtensionExtensionPoints = false;
    
    public PluginInfo() {}
    
    public boolean isFragment()
    {
      return fragment;
    }
    
    public String toString()
    {
      return "plugin-id: " + pluginId + "  version: " + version + " libraries: " + libraries + " class:" + pluginClass + " master: " + masterPluginId + " master-version: " + masterVersion + " requires: " + requires + " singleton: " + singleton;
    }
    
    public Map<String, List<String>> getLibraries()
    {
      if (libraries == null) {
        return new HashMap(0);
      }
      return libraries;
    }
    
    public ArrayList<PluginParser.Prerequisite> getRequires()
    {
      if ((!PluginParser.TARGET21.equals(target)) && (schemaVersion == null) && (!requiresExpanded))
      {
        requiresExpanded = true;
        if (requires == null)
        {
          requires = new ArrayList(1);
          requires.add(new PluginParser.Prerequisite(PluginParser.this, "org.eclipse.core.runtime", "2.1", false, false, "greaterOrEqual"));
          requires.add(new PluginParser.Prerequisite(PluginParser.this, "org.eclipse.core.runtime.compatibility", null, false, false, null));
        }
        else
        {
          for (int i = 0; i < requires.size(); i++)
          {
            PluginParser.Prerequisite analyzed = (PluginParser.Prerequisite)requires.get(i);
            if ("org.eclipse.ui".equals(analyzed.getName()))
            {
              requires.add(i + 1, new PluginParser.Prerequisite(PluginParser.this, "org.eclipse.ui.workbench.texteditor", null, true, analyzed.isExported(), null));
              requires.add(i + 1, new PluginParser.Prerequisite(PluginParser.this, "org.eclipse.jface.text", null, true, analyzed.isExported(), null));
              requires.add(i + 1, new PluginParser.Prerequisite(PluginParser.this, "org.eclipse.ui.editors", null, true, analyzed.isExported(), null));
              requires.add(i + 1, new PluginParser.Prerequisite(PluginParser.this, "org.eclipse.ui.views", null, true, analyzed.isExported(), null));
              requires.add(i + 1, new PluginParser.Prerequisite(PluginParser.this, "org.eclipse.ui.ide", null, true, analyzed.isExported(), null));
            }
            else if ("org.eclipse.help".equals(analyzed.getName()))
            {
              requires.add(i + 1, new PluginParser.Prerequisite(PluginParser.this, "org.eclipse.help.base", null, true, analyzed.isExported(), null));
            }
            else if (("org.eclipse.core.runtime".equals(analyzed.getName())) && (!compatibilityFound))
            {
              requires.add(i + 1, new PluginParser.Prerequisite(PluginParser.this, "org.eclipse.core.runtime.compatibility", null, false, analyzed.isExported(), null));
            }
          }
          if (!requires.contains(new PluginParser.Prerequisite(PluginParser.this, "org.eclipse.core.runtime.compatibility", null, false, false, null))) {
            requires.add(new PluginParser.Prerequisite(PluginParser.this, "org.eclipse.core.runtime.compatibility", null, false, false, null));
          }
          PluginParser.Prerequisite runtimePrereq = new PluginParser.Prerequisite(PluginParser.this, "org.eclipse.core.runtime", null, false, false, null);
          requires.remove(runtimePrereq);
          requires.add(new PluginParser.Prerequisite(PluginParser.this, "org.eclipse.core.runtime", "2.1", false, false, "greaterOrEqual"));
        }
      }
      if (requires == null) {
        return requires = new ArrayList(0);
      }
      return requires;
    }
    
    public String getMasterId()
    {
      return masterPluginId;
    }
    
    public String getMasterVersion()
    {
      return masterVersion;
    }
    
    public String getMasterMatch()
    {
      return masterMatch;
    }
    
    public String getPluginClass()
    {
      return pluginClass;
    }
    
    public String getUniqueId()
    {
      return pluginId;
    }
    
    public String getVersion()
    {
      return version;
    }
    
    public Set<String> getPackageFilters()
    {
      return filters;
    }
    
    public String[] getLibrariesName()
    {
      if (libraryPaths == null) {
        return new String[0];
      }
      return (String[])libraryPaths.toArray(new String[libraryPaths.size()]);
    }
    
    public String getPluginName()
    {
      return pluginName;
    }
    
    public String getProviderName()
    {
      return vendor;
    }
    
    public boolean isSingleton()
    {
      return singleton;
    }
    
    public boolean hasExtensionExtensionPoints()
    {
      return hasExtensionExtensionPoints;
    }
    
    public String getRoot()
    {
      return isFragment() ? "fragment" : "plugin";
    }
    
    public String validateForm()
    {
      if (pluginId == null) {
        return NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_MISSING_ATTRIBUTE, new String[] { getRoot(), "id", getRoot() });
      }
      if (pluginName == null) {
        return NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_MISSING_ATTRIBUTE, new String[] { getRoot(), "name", getRoot() });
      }
      if (version == null) {
        return NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_MISSING_ATTRIBUTE, new String[] { getRoot(), "version", getRoot() });
      }
      if ((isFragment()) && (masterPluginId == null)) {
        return NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_MISSING_ATTRIBUTE, new String[] { getRoot(), "plugin-id", getRoot() });
      }
      if ((isFragment()) && (masterVersion == null)) {
        return NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONVERTER_MISSING_ATTRI
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

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