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

   11: invokespecial 1648	java/io/FileWriter:<init>	(Ljava/io/File;)V
    //   14: invokespecial 1621	java/io/BufferedWriter:<init>	(Ljava/io/Writer;)V
    //   17: astore_2
    //   18: aload_2
    //   19: aload_1
    //   20: invokevirtual 1622	java/io/BufferedWriter:write	(Ljava/lang/String;)V
    //   23: aload_2
    //   24: invokevirtual 1620	java/io/BufferedWriter:flush	()V
    //   27: goto +18 -> 45
    //   30: astore_3
    //   31: aload_2
    //   32: ifnull +11 -> 43
    //   35: aload_2
    //   36: invokevirtual 1619	java/io/BufferedWriter:close	()V
    //   39: goto +4 -> 43
    //   42: pop
    //   43: aload_3
    //   44: athrow
    //   45: aload_2
    //   46: ifnull +11 -> 57
    //   49: aload_2
    //   50: invokevirtual 1619	java/io/BufferedWriter:close	()V
    //   53: goto +4 -> 57
    //   56: pop
    //   57: return
    // Line number table:
    //   Java source line #1574	-> byte code offset #0
    //   Java source line #1576	-> byte code offset #2
    //   Java source line #1577	-> byte code offset #18
    //   Java source line #1578	-> byte code offset #23
    //   Java source line #1579	-> byte code offset #30
    //   Java source line #1580	-> byte code offset #31
    //   Java source line #1582	-> byte code offset #35
    //   Java source line #1583	-> byte code offset #42
    //   Java source line #1587	-> byte code offset #43
    //   Java source line #1580	-> byte code offset #45
    //   Java source line #1582	-> byte code offset #49
    //   Java source line #1583	-> byte code offset #56
    //   Java source line #1588	-> byte code offset #57
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	58	0	file	File
    //   0	58	1	contents	String
    //   1	49	2	writer	java.io.BufferedWriter
    //   30	14	3	localObject	Object
    //   42	1	4	localIOException1	IOException
    //   56	1	5	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   2	30	30	finally
    //   35	39	42	java/io/IOException
    //   49	53	56	java/io/IOException
  }
  
  /* Error */
  public static String getFileContentAsString(File file)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_1
    //   2: aconst_null
    //   3: astore_2
    //   4: new 983	java/io/FileInputStream
    //   7: dup
    //   8: aload_0
    //   9: invokespecial 1643	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   12: astore_2
    //   13: aload_2
    //   14: iconst_m1
    //   15: ldc_w 927
    //   18: invokestatic 1802	org/eclipse/pde/api/tools/internal/util/Util:getInputStreamAsCharArray	(Ljava/io/InputStream;ILjava/lang/String;)[C
    //   21: astore_3
    //   22: new 1005	java/lang/String
    //   25: dup
    //   26: aload_3
    //   27: invokespecial 1678	java/lang/String:<init>	([C)V
    //   30: astore_1
    //   31: goto +40 -> 71
    //   34: astore_3
    //   35: aload_3
    //   36: invokestatic 1769	org/eclipse/pde/api/tools/internal/provisional/ApiPlugin:log	(Ljava/lang/Throwable;)V
    //   39: aload_2
    //   40: ifnull +43 -> 83
    //   43: aload_2
    //   44: invokevirtual 1642	java/io/FileInputStream:close	()V
    //   47: goto +36 -> 83
    //   50: pop
    //   51: goto +32 -> 83
    //   54: astore 4
    //   56: aload_2
    //   57: ifnull +11 -> 68
    //   60: aload_2
    //   61: invokevirtual 1642	java/io/FileInputStream:close	()V
    //   64: goto +4 -> 68
    //   67: pop
    //   68: aload 4
    //   70: athrow
    //   71: aload_2
    //   72: ifnull +11 -> 83
    //   75: aload_2
    //   76: invokevirtual 1642	java/io/FileInputStream:close	()V
    //   79: goto +4 -> 83
    //   82: pop
    //   83: aload_1
    //   84: areturn
    // Line number table:
    //   Java source line #1596	-> byte code offset #0
    //   Java source line #1597	-> byte code offset #2
    //   Java source line #1599	-> byte code offset #4
    //   Java source line #1600	-> byte code offset #13
    //   Java source line #1601	-> byte code offset #22
    //   Java source line #1603	-> byte code offset #34
    //   Java source line #1604	-> byte code offset #35
    //   Java source line #1606	-> byte code offset #39
    //   Java source line #1608	-> byte code offset #43
    //   Java source line #1609	-> byte code offset #50
    //   Java source line #1605	-> byte code offset #54
    //   Java source line #1606	-> byte code offset #56
    //   Java source line #1608	-> byte code offset #60
    //   Java source line #1609	-> byte code offset #67
    //   Java source line #1613	-> byte code offset #68
    //   Java source line #1606	-> byte code offset #71
    //   Java source line #1608	-> byte code offset #75
    //   Java source line #1609	-> byte code offset #82
    //   Java source line #1614	-> byte code offset #83
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	85	0	file	File
    //   1	83	1	contents	String
    //   3	73	2	stream	java.io.FileInputStream
    //   21	6	3	array	char[]
    //   34	2	3	ioe	IOException
    //   54	15	4	localObject	Object
    //   50	1	6	localIOException1	IOException
    //   67	1	7	localIOException2	IOException
    //   82	1	8	localIOException3	IOException
    // Exception table:
    //   from	to	target	type
    //   4	31	34	java/io/IOException
    //   43	47	50	java/io/IOException
    //   4	39	54	finally
    //   60	64	67	java/io/IOException
    //   75	79	82	java/io/IOException
  }
  
  public static InputStream getInputStreamFromString(String string)
  {
    try
    {
      return new ByteArrayInputStream(string.getBytes("UTF-8"));
    }
    catch (UnsupportedEncodingException uee)
    {
      ApiPlugin.log(uee);
    }
    return null;
  }
  
  public static String serializeDocument(org.w3c.dom.Document document)
    throws CoreException
  {
    try
    {
      ByteArrayOutputStream s = new ByteArrayOutputStream();
      TransformerFactory factory = TransformerFactory.newInstance();
      Transformer transformer = factory.newTransformer();
      transformer.setOutputProperty("method", "xml");
      transformer.setOutputProperty("indent", "yes");
      transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
      DOMSource source = new DOMSource(document);
      StreamResult outputTarget = new StreamResult(s);
      transformer.transform(source, outputTarget);
      return s.toString("UTF-8");
    }
    catch (TransformerException e)
    {
      abort("Unable to serialize XML document.", e);
    }
    catch (IOException e)
    {
      abort("Unable to serialize XML document.", e);
    }
    return null;
  }
  
  /* Error */
  public static void unzip(String zipPath, String destDirPath)
    throws IOException
  {
    // Byte code:
    //   0: new 983	java/io/FileInputStream
    //   3: dup
    //   4: aload_0
    //   5: invokespecial 1644	java/io/FileInputStream:<init>	(Ljava/lang/String;)V
    //   8: astore_2
    //   9: sipush 8192
    //   12: newarray <illegal type>
    //   14: astore_3
    //   15: new 982	java/io/File
    //   18: dup
    //   19: aload_1
    //   20: invokespecial 1636	java/io/File:<init>	(Ljava/lang/String;)V
    //   23: astore 4
    //   25: new 1033	java/util/zip/ZipInputStream
    //   28: dup
    //   29: new 977	java/io/BufferedInputStream
    //   32: dup
    //   33: aload_2
    //   34: invokespecial 1613	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   37: invokespecial 1736	java/util/zip/ZipInputStream:<init>	(Ljava/io/InputStream;)V
    //   40: astore 5
    //   42: aconst_null
    //   43: astore 6
    //   45: goto +146 -> 191
    //   48: aload 7
    //   50: invokevirtual 1729	java/util/zip/ZipEntry:isDirectory	()Z
    //   53: ifeq +24 -> 77
    //   56: new 982	java/io/File
    //   59: dup
    //   60: aload 4
    //   62: aload 7
    //   64: invokevirtual 1730	java/util/zip/ZipEntry:getName	()Ljava/lang/String;
    //   67: invokespecial 1638	java/io/File:<init>	(Ljava/io/File;Ljava/lang/String;)V
    //   70: invokevirtual 1630	java/io/File:mkdirs	()Z
    //   73: pop
    //   74: goto +117 -> 191
    //   77: aload 7
    //   79: invokevirtual 1730	java/util/zip/ZipEntry:getName	()Ljava/lang/String;
    //   82: astore 8
    //   84: aload 8
    //   86: ldc_w 824
    //   89: invokevirtual 1685	java/lang/String:lastIndexOf	(Ljava/lang/String;)I
    //   92: istore 9
    //   94: ldc 1
    //   96: astore 10
    //   98: iload 9
    //   100: iflt +13 -> 113
    //   103: aload 8
    //   105: iconst_0
    //   106: iload 9
    //   108: invokevirtual 1684	java/lang/String:substring	(II)Ljava/lang/String;
    //   111: astore 10
    //   113: new 982	java/io/File
    //   116: dup
    //   117: aload 4
    //   119: aload 10
    //   121: invokespecial 1638	java/io/File:<init>	(Ljava/io/File;Ljava/lang/String;)V
    //   124: invokevirtual 1630	java/io/File:mkdirs	()Z
    //   127: pop
    //   128: new 982	java/io/File
    //   131: dup
    //   132: aload 4
    //   134: aload 8
    //   136: invokespecial 1638	java/io/File:<init>	(Ljava/io/File;Ljava/lang/String;)V
    //   139: astore 11
    //   141: new 978	java/io/BufferedOutputStream
    //   144: dup
    //   145: new 985	java/io/FileOutputStream
    //   148: dup
    //   149: aload 11
    //   151: invokespecial 1647	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   154: invokespecial 1618	java/io/BufferedOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   157: astore 6
    //   159: iconst_0
    //   160: istore 12
    //   162: goto +12 -> 174
    //   165: aload 6
    //   167: aload_3
    //   168: iconst_0
    //   169: iload 12
    //   171: invokevirtual 1617	java/io/BufferedOutputStream:write	([BII)V
    //   174: aload 5
    //   176: aload_3
    //   177: invokevirtual 1735	java/util/zip/ZipInputStream:read	([B)I
    //   180: dup
    //   181: istore 12
    //   183: ifge -18 -> 165
    //   186: aload 6
    //   188: invokevirtual 1614	java/io/BufferedOutputStream:close	()V
    //   191: aload 5
    //   193: invokevirtual 1737	java/util/zip/ZipInputStream:getNextEntry	()Ljava/util/zip/ZipEntry;
    //   196: dup
    //   197: astore 7
    //   199: ifnonnull -151 -> 48
    //   202: goto +52 -> 254
    //   205: pop
    //   206: aload 6
    //   208: ifnull +12 -> 220
    //   211: aload 6
    //   213: invokevirtual 1614	java/io/BufferedOutputStream:close	()V
    //   216: goto +4 -> 220
    //   219: pop
    //   220: aload_2
    //   221: invokevirtual 1650	java/io/InputStream:close	()V
    //   224: aload 5
    //   226: invokevirtual 1734	java/util/zip/ZipInputStream:close	()V
    //   229: goto +38 -> 267
    //   232: pop
    //   233: goto +34 -> 267
    //   236: astore 13
    //   238: aload_2
    //   239: invokevirtual 1650	java/io/InputStream:close	()V
    //   242: aload 5
    //   244: invokevirtual 1734	java/util/zip/ZipInputStream:close	()V
    //   247: goto +4 -> 251
    //   250: pop
    //   251: aload 13
    //   253: athrow
    //   254: aload_2
    //   255: invokevirtual 1650	java/io/InputStream:close	()V
    //   258: aload 5
    //   260: invokevirtual 1734	java/util/zip/ZipInputStream:close	()V
    //   263: goto +4 -> 267
    //   266: pop
    //   267: return
    // Line number table:
    //   Java source line #1663	-> byte code offset #0
    //   Java source line #1664	-> byte code offset #9
    //   Java source line #1665	-> byte code offset #15
    //   Java source line #1666	-> byte code offset #25
    //   Java source line #1667	-> byte code offset #42
    //   Java source line #1670	-> byte code offset #45
    //   Java source line #1672	-> byte code offset #48
    //   Java source line #1673	-> byte code offset #56
    //   Java source line #1674	-> byte code offset #74
    //   Java source line #1677	-> byte code offset #77
    //   Java source line #1678	-> byte code offset #84
    //   Java source line #1679	-> byte code offset #94
    //   Java source line #1680	-> byte code offset #98
    //   Java source line #1681	-> byte code offset #103
    //   Java source line #1684	-> byte code offset #113
    //   Java source line #1686	-> byte code offset #128
    //   Java source line #1687	-> byte code offset #141
    //   Java source line #1688	-> byte code offset #159
    //   Java source line #1689	-> byte code offset #162
    //   Java source line #1690	-> byte code offset #165
    //   Java source line #1689	-> byte code offset #174
    //   Java source line #1692	-> byte code offset #186
    //   Java source line #1670	-> byte code offset #191
    //   Java source line #1694	-> byte code offset #205
    //   Java source line #1695	-> byte code offset #206
    //   Java source line #1697	-> byte code offset #211
    //   Java source line #1698	-> byte code offset #219
    //   Java source line #1703	-> byte code offset #220
    //   Java source line #1704	-> byte code offset #224
    //   Java source line #1705	-> byte code offset #232
    //   Java source line #1701	-> byte code offset #236
    //   Java source line #1703	-> byte code offset #238
    //   Java source line #1704	-> byte code offset #242
    //   Java source line #1705	-> byte code offset #250
    //   Java source line #1707	-> byte code offset #251
    //   Java source line #1703	-> byte code offset #254
    //   Java source line #1704	-> byte code offset #258
    //   Java source line #1705	-> byte code offset #266
    //   Java source line #1708	-> byte code offset #267
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	268	0	zipPath	String
    //   0	268	1	destDirPath	String
    //   8	247	2	zipIn	InputStream
    //   14	163	3	buf	byte[]
    //   23	110	4	destDir	File
    //   40	219	5	zis	java.util.zip.ZipInputStream
    //   43	169	6	outputStream	BufferedOutputStream
    //   48	30	7	zEntry	java.util.zip.ZipEntry
    //   197	3	7	zEntry	java.util.zip.ZipEntry
    //   82	53	8	filePath	String
    //   92	15	9	lastSeparator	int
    //   96	24	10	fileDir	String
    //   139	11	11	outFile	File
    //   160	22	12	n	int
    //   236	16	13	localObject	Object
    //   205	1	15	localIOException1	IOException
    //   219	1	16	localIOException2	IOException
    //   232	1	17	localIOException3	IOException
    //   250	1	18	localIOException4	IOException
    //   266	1	19	localIOException5	IOException
    // Exception table:
    //   from	to	target	type
    //   45	202	205	java/io/IOException
    //   211	216	219	java/io/IOException
    //   220	229	232	java/io/IOException
    //   45	220	236	finally
    //   238	247	250	java/io/IOException
    //   254	263	266	java/io/IOException
  }
  
  public static void guntar(String zipPath, String destDirPath)
    throws TarException, IOException
  {
    TarFile tarFile = new TarFile(zipPath);
    Enumeration entries = tarFile.entries();
    byte[] buf = new byte['?'];
    TarEntry zEntry;
    for (; entries.hasMoreElements(); (zEntry = (TarEntry)entries.nextElement()) != null)
    {
      continue;
      TarEntry zEntry;
      if (zEntry.getFileType() == 53)
      {
        new File(destDirPath, zEntry.getName()).mkdirs();
      }
      else
      {
        String filePath = zEntry.getName();
        int lastSeparator = filePath.lastIndexOf("/");
        String fileDir = "";
        if (lastSeparator >= 0) {
          fileDir = filePath.substring(0, lastSeparator);
        }
        new File(destDirPath, fileDir).mkdirs();
        
        File outFile = new File(destDirPath, filePath);
        BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outFile));
        int n = 0;
        InputStream inputStream = tarFile.getInputStream(zEntry);
        BufferedInputStream stream = new BufferedInputStream(inputStream);
        while ((n = stream.read(buf)) >= 0) {
          outputStream.write(buf, 0, n);
        }
        outputStream.close();
        stream.close();
      }
    }
  }
  
  /* Error */
  public static File getEEDescriptionFile()
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_0
    //   2: aconst_null
    //   3: astore_1
    //   4: ldc_w 947
    //   7: ldc_w 822
    //   10: invokestatic 1806	org/eclipse/pde/api/tools/internal/util/Util:createTempFile	(Ljava/lang/String;Ljava/lang/String;)Ljava/io/File;
    //   13: astore_0
    //   14: new 991	java/io/PrintWriter
    //   17: dup
    //   18: new 979	java/io/BufferedWriter
    //   21: dup
    //   22: new 986	java/io/FileWriter
    //   25: dup
    //   26: aload_0
    //   27: invokespecial 1648	java/io/FileWriter:<init>	(Ljava/io/File;)V
    //   30: invokespecial 1621	java/io/BufferedWriter:<init>	(Ljava/io/Writer;)V
    //   33: invokespecial 1660	java/io/PrintWriter:<init>	(Ljava/io/Writer;)V
    //   36: astore_1
    //   37: aload_1
    //   38: ldc_w 820
    //   41: invokevirtual 1661	java/io/PrintWriter:print	(Ljava/lang/String;)V
    //   44: aload_1
    //   45: ldc_w 952
    //   48: invokestatic 1699	java/lang/System:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   51: invokevirtual 1662	java/io/PrintWriter:println	(Ljava/lang/String;)V
    //   54: aload_1
    //   55: ldc_w 815
    //   58: invokevirtual 1661	java/io/PrintWriter:print	(Ljava/lang/String;)V
    //   61: aload_1
    //   62: invokestatic 1791	org/eclipse/pde/api/tools/internal/util/Util:getJavaClassLibsAsString	()Ljava/lang/String;
    //   65: invokevirtual 1662	java/io/PrintWriter:println	(Ljava/lang/String;)V
    //   68: aload_1
    //   69: ldc_w 818
    //   72: invokevirtual 1662	java/io/PrintWriter:println	(Ljava/lang/String;)V
    //   75: aload_1
    //   76: ldc_w 817
    //   79: invokevirtual 1662	java/io/PrintWriter:println	(Ljava/lang/String;)V
    //   82: aload_1
    //   83: invokevirtual 1659	java/io/PrintWriter:flush	()V
    //   86: goto +26 -> 112
    //   89: pop
    //   90: aload_1
    //   91: ifnull +29 -> 120
    //   94: aload_1
    //   95: invokevirtual 1658	java/io/PrintWriter:close	()V
    //   98: goto +22 -> 120
    //   101: astore_2
    //   102: aload_1
    //   103: ifnull +7 -> 110
    //   106: aload_1
    //   107: invokevirtual 1658	java/io/PrintWriter:close	()V
    //   110: aload_2
    //   111: athrow
    //   112: aload_1
    //   113: ifnull +7 -> 120
    //   116: aload_1
    //   117: invokevirtual 1658	java/io/PrintWriter:close	()V
    //   120: aload_0
    //   121: areturn
    // Line number table:
    //   Java source line #1755	-> byte code offset #0
    //   Java source line #1756	-> byte code offset #2
    //   Java source line #1758	-> byte code offset #4
    //   Java source line #1759	-> byte code offset #14
    //   Java source line #1760	-> byte code offset #37
    //   Java source line #1761	-> byte code offset #44
    //   Java source line #1762	-> byte code offset #54
    //   Java source line #1763	-> byte code offset #61
    //   Java source line #1764	-> byte code offset #68
    //   Java source line #1765	-> byte code offset #75
    //   Java source line #1766	-> byte code offset #82
    //   Java source line #1767	-> byte code offset #89
    //   Java source line #1770	-> byte code offset #90
    //   Java source line #1771	-> byte code offset #94
    //   Java source line #1769	-> byte code offset #101
    //   Java source line #1770	-> byte code offset #102
    //   Java source line #1771	-> byte code offset #106
    //   Java source line #1773	-> byte code offset #110
    //   Java source line #1770	-> byte code offset #112
    //   Java source line #1771	-> byte code offset #116
    //   Java source line #1774	-> byte code offset #120
    // Local variable table:
    //   start	length	slot	name	signature
    //   1	120	0	fakeEEFile	File
    //   3	114	1	writer	java.io.PrintWriter
    //   101	10	2	localObject	Object
    //   89	1	3	localIOException	IOException
    // Exception table:
    //   from	to	target	type
    //   4	86	89	java/io/IOException
    //   4	90	101	finally
  }
  
  public static File createTempFile(String prefix, String suffix)
    throws IOException
  {
    File file = File.createTempFile(prefix, suffix);
    file.deleteOnExit();
    FileManager.getManager().recordTempFileRoot(file.getCanonicalPath());
    return file;
  }
  
  public static String getJavaClassLibsAsString()
  {
    String[] libs = getJavaClassLibs();
    StringBuffer buffer = new StringBuffer();
    int i = 0;
    for (int max = libs.length; i < max; i++)
    {
      if (i > 0) {
        buffer.append(File.pathSeparatorChar);
      }
      buffer.append(libs[i]);
    }
    return String.valueOf(buffer);
  }
  
  public static String[] getJavaClassLibs()
  {
    String bootclasspathProperty = System.getProperty("sun.boot.class.path");
    if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0))
    {
      bootclasspathProperty = System.getProperty("vm.boot.class.path");
      if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0)) {
        bootclasspathProperty = System.getProperty("org.apache.harmony.boot.class.path");
      }
    }
    String[] jars = (String[])null;
    if ((bootclasspathProperty != null) && (bootclasspathProperty.length() != 0))
    {
      StringTokenizer tokenizer = new StringTokenizer(bootclasspathProperty, File.pathSeparator);
      int size = tokenizer.countTokens();
      jars = new String[size];
      int i = 0;
      while (tokenizer.hasMoreTokens())
      {
        String fileName = toNativePath(tokenizer.nextToken());
        if (new File(fileName).exists())
        {
          jars[i] = fileName;
          i++;
        }
      }
      if (size != i) {
        System.arraycopy(jars, 0, jars = new String[i], 0, i);
      }
    }
    else
    {
      String jreDir = System.getProperty("java.home");
      String osName = System.getProperty("os.name");
      if (jreDir == null) {
        return new String[0];
      }
      if (osName.startsWith("Mac")) {
        return new String[] {
          toNativePath(jreDir + "/../Classes/classes.jar") };
      }
      String vmName = System.getProperty("java.vm.name");
      if ("J9".equals(vmName)) {
        return new String[] {
          toNativePath(jreDir + "/lib/jclMax/classes.zip") };
      }
      String[] jarsNames = (String[])null;
      ArrayList paths = new ArrayList();
      if ("DRLVM".equals(vmName))
      {
        FilenameFilter jarFilter = new FilenameFilter()
        {
          public boolean accept(File dir, String name)
          {
            return name.endsWith(".jar") & !name.endsWith("-src.jar");
          }
        };
        jarsNames = new File(jreDir + "/lib/boot/").list(jarFilter);
        addJarEntries(jreDir + "/lib/boot/", jarsNames, paths);
      }
      else
      {
        jarsNames = new String[] {
          "/lib/vm.jar", 
          "/lib/rt.jar", 
          "/lib/core.jar", 
          "/lib/security.jar", 
          "/lib/xml.jar", 
          "/lib/graphics.jar" };
        
        addJarEntries(jreDir, jarsNames, paths);
      }
      jars = new String[paths.size()];
      paths.toArray(jars);
    }
    return jars;
  }
  
  public static String toNativePath(String path)
  {
    String nativePath = path.replace('\\', File.separatorChar).replace('/', File.separatorChar);
    return 
      (nativePath.endsWith("/")) || (nativePath.endsWith("\\")) ? 
      nativePath.substring(0, nativePath.length() - 1) : 
      nativePath;
  }
  
  private static void addJarEntries(String jreDir, String[] jarNames, ArrayList paths)
  {
    int i = 0;
    for (int max = jarNames.length; i < max; i++)
    {
      String currentName = jreDir + jarNames[i];
      File f = new File(currentName);
      if (f.exists()) {
        paths.add(toNativePath(currentName));
      }
    }
  }
  
  public static boolean delete(File file)
  {
    if (!file.exists()) {
      return true;
    }
    if (file.isDirectory()) {
      flushDirectoryContent(file);
    }
    file.delete();
    if (isFileDeleted(file)) {
      return true;
    }
    return waitUntilFileDeleted(file);
  }
  
  public static void flushDirectoryContent(File dir)
  {
    File[] files = dir.listFiles();
    if (files == null) {
      return;
    }
    int i = 0;
    for (int max = files.length; i < max; i++) {
      delete(files[i]);
    }
  }
  
  private static boolean waitUntilFileDeleted(File file)
  {
    int count = 0;
    int delay = 10;
    int maxRetry = DELETE_MAX_WAIT / delay;
    int time = 0;
    while (count < maxRetry) {
      try
      {
        count++;
        Thread.sleep(delay);
        time += delay;
        if (time > DELETE_MAX_TIME) {
          DELETE_MAX_TIME = time;
        }
        if (DELETE_DEBUG) {
          System.out.print('.');
        }
        if ((file.exists()) && 
          (file.delete())) {
          return true;
        }
        if (isFileDeleted(file)) {
          return true;
        }
        if ((count >= 10) && (delay <= 100))
        {
          count = 1;
          delay *= 10;
          maxRetry = DELETE_MAX_WAIT / delay;
          if (DELETE_MAX_WAIT % delay != 0) {
            maxRetry++;
          }
        }
      }
      catch (InterruptedException localInterruptedException)
      {
        break;
      }
    }
    System.err.println();
    System.err.println("\t!!! ERROR: " + file + " was never deleted even after having waited " + DELETE_MAX_TIME + "ms!!!");
    System.err.println();
    return false;
  }
  
  public static boolean isFileDeleted(File file)
  {
    return (!file.exists()) && (getParentChildFile(file) == null);
  }
  
  private static File getParentChildFile(File file)
  {
    File parent = file.getParentFile();
    if ((parent == null) || (!parent.exists())) {
      return null;
    }
    File[] files = parent.listFiles();
    int length = files == null ? 0 : files.length;
    if (length > 0) {
      for (int i = 0; i < length; i++)
      {
        if (files[i] == file) {
          return files[i];
        }
        if (files[i].equals(file)) {
          return files[i];
        }
        if (files[i].getPath().equals(file.getPath())) {
          return files[i];
        }
      }
    }
    return null;
  }
  
  public static Set convertAsSet(String[] values)
  {
    Set set = new HashSet();
    if ((values != null) && (values.length != 0))
    {
      int i = 0;
      for (int max = values.length; i < max; i++) {
        set.add(values[i]);
      }
    }
    return set;
  }
  
  public static String getDeltaComponentVersionsId(IApiComponent component)
  {
    StringBuffer buffer = new StringBuffer(component.getSymbolicName());
    String version = component.getVersion();
    if (version != null)
    {
      buffer.append('(');
      try
      {
        Version version2 = new Version(version);
        buffer
          .append(version2.getMajor())
          .append('.')
          .append(version2.getMinor())
          .append('.')
          .append(version2.getMicro());
      }
      catch (IllegalArgumentException localIllegalArgumentException)
      {
        buffer.append(version);
      }
      buffer.append(')');
    }
    return String.valueOf(buffer);
  }
  
  public static String getComponentVersionsId(IApiComponent component)
  {
    StringBuffer buffer = new StringBuffer(component.getSymbolicName());
    String version = component.getVersion();
    if (version != null)
    {
      buffer.append('_');
      try
      {
        Version version2 = new Version(version);
        buffer
          .append(version2.getMajor())
          .append('.')
          .append(version2.getMinor())
          .append('.')
          .append(version2.getMicro());
      }
      catch (IllegalArgumentException localIllegalArgumentException)
      {
        buffer.append(version);
      }
    }
    return String.valueOf(buffer);
  }
  
  public static String getDescriptorName(IApiType descriptor)
  {
    String typeName = descriptor.getName();
    int index = typeName.lastIndexOf('$');
    if (index != -1) {
      return typeName.replace('$', '.');
    }
    return typeName;
  }
  
  public static String getDeltaArgumentString(IDelta delta)
  {
    String[] arguments = delta.getArguments();
    switch (delta.getFlags())
    {
    case 46: 
    case 48: 
      return arguments[0];
    case 8: 
    case 12: 
    case 16: 
    case 25: 
    case 27: 
    case 28: 
      return arguments[1];
    case 22: 
      switch (delta.getElementType())
      {
      case 5: 
      case 7: 
      case 9: 
        return arguments[1];
      }
      return arguments[0];
    }
    return "";
  }
  
  public static String getApiElementType(int type)
  {
    switch (type)
    {
    case 3: 
      return "API_TYPE_CONTAINER";
    case 7: 
      return "API_TYPE_ROOT";
    case 4: 
      return "BASELINE";
    case 1: 
      return "COMPONENT";
    case 5: 
      return "FIELD";
    case 6: 
      return "METHOD";
    case 2: 
      return "TYPE";
    }
    return "UNKNOWN";
  }
  
  public static boolean isConstructor(String referenceMemberName)
  {
    return Arrays.equals(ConstantPool.Init, referenceMemberName.toCharArray());
  }
  
  public static boolean isManifest(IPath path)
  {
    return MANIFEST_PROJECT_RELATIVE_PATH.equals(path);
  }
  
  public static void touchCorrespondingResource(IProject project, IResource resource, String typeName)
  {
    if ((typeName != null) && (typeName != "!global!")) {
      if (isManifest(resource.getProjectRelativePath())) {
        try
        {
          IJavaProject javaProject = JavaCore.create(project);
          IType findType = javaProject.findType(typeName);
          if (findType == null) {
            return;
          }
          ICompilationUnit compilationUnit = findType.getCompilationUnit();
          if (compilationUnit == null) {
            return;
          }
          IResource cuResource = compilationUnit.getResource();
          if (cuResource == null) {
            return;
          }
          cuResource.touch(null);
        }
        catch (JavaModelException e)
        {
          ApiPlugin.log(e);
        }
        catch (CoreException e)
        {
          ApiPlugin.log(e);
        }
      } else {
        try
        {
          resource.touch(null);
        }
        catch (CoreException e)
        {
          ApiPlugin.log(e);
        }
      }
    }
  }
  
  public static String getTypeNameFromMarker(IMarker marker)
  {
    return marker.getAttribute("problemTypeName", null);
  }
  
  public static IApiComponent[] getReexportedComponents(IApiComponent component)
  {
    try
    {
      IRequiredComponentDescription[] requiredComponents = component.getRequiredComponents();
      int length = requiredComponents.length;
      if (length != 0)
      {
        List reexportedComponents = null;
        IApiBaseline baseline = component.getBaseline();
        for (int i = 0; i < length; i++)
        {
          IRequiredComponentDescription description = requiredComponents[i];
          if (description.isExported())
          {
            String id = description.getId();
            IApiComponent reexportedComponent = baseline.getApiComponent(id);
            if (reexportedComponent != null)
            {
              if (reexportedComponents == null) {
                reexportedComponents = new ArrayList();
              }
              reexportedComponents.add(reexportedComponent);
            }
          }
        }
        if ((reexportedComponents == null) || (reexportedComponents.size() == 0)) {
          return null;
        }
        return (IApiComponent[])reexportedComponents.toArray(new IApiComponent[reexportedComponents.size()]);
      }
    }
    catch (CoreException e)
    {
      ApiPlugin.log(e);
    }
    return null;
  }
  
  public static IResource getResource(IProject project, IType type)
  {
    try
    {
      if (type != null)
      {
        ICompilationUnit unit = type.getCompilationUnit();
        if (unit != null)
        {
          IResource resource = unit.getCorrespondingResource();
          if ((resource != null) && (resource.exists())) {
            return resource;
          }
        }
      }
    }
    catch (JavaModelException e)
    {
      ApiPlugin.log(e);
    }
    return getManifestFile(project);
  }
  
  public static final Comparator componentsorter = new Comparator()
  {
    public int compare(Object o1, Object o2)
    {
      if (((o1 instanceof IApiComponent)) && ((o2 instanceof IApiComponent))) {
        return ((IApiComponent)o1).getSymbolicName().compareTo(((IApiComponent)o2).getSymbolicName());
      }
      if (((o1 instanceof SkippedComponent)) && ((o2 instanceof SkippedComponent))) {
        return ((SkippedComponent)o1).getComponentId().compareTo(((SkippedComponent)o2).getComponentId());
      }
      if (((o1 instanceof String)) && ((o2 instanceof String))) {
        return ((String)o1).compareTo((String)o2);
      }
      return -1;
    }
  };
  
  /* Error */
  public static FilteredElements initializeRegexFilterList(String location, IApiBaseline baseline, boolean debug)
  {
    // Byte code:
    //   0: new 1090	org/eclipse/pde/api/tools/internal/util/FilteredElements
    //   3: dup
    //   4: invokespecial 1775	org/eclipse/pde/api/tools/internal/util/FilteredElements:<init>	()V
    //   7: astore_3
    //   8: aload_0
    //   9: ifnull +294 -> 303
    //   12: new 982	java/io/File
    //   15: dup
    //   16: aload_0
    //   17: invokespecial 1636	java/io/File:<init>	(Ljava/lang/String;)V
    //   20: astore 4
    //   22: aload 4
    //   24: invokevirtual 1628	java/io/File:exists	()Z
    //   27: ifeq +276 -> 303
    //   30: aconst_null
    //   31: astore 5
    //   33: aconst_null
    //   34: checkcast 972	[C
    //   37: astore 6
    //   39: new 977	java/io/BufferedInputStream
    //   42: dup
    //   43: new 983	java/io/FileInputStream
    //   46: dup
    //   47: aload 4
    //   49: invokespecial 1643	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   52: invokespecial 1613	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   55: astore 5
    //   57: aload 5
    //   59: iconst_m1
    //   60: ldc 9
    //   62: invokestatic 1802	org/eclipse/pde/api/tools/internal/util/Util:getInputStreamAsCharArray	(Ljava/io/InputStream;ILjava/lang/String;)[C
    //   65: astore 6
    //   67: goto +58 -> 125
    //   70: pop
    //   71: aload 5
    //   73: ifnull +66 -> 139
    //   76: aload 5
    //   78: invokevirtual 1650	java/io/InputStream:close	()V
    //   81: goto +58 -> 139
    //   84: pop
    //   85: goto +54 -> 139
    //   88: pop
    //   89: aload 5
    //   91: ifnull +48 -> 139
    //   94: aload 5
    //   96: invokevirtual 1650	java/io/InputStream:close	()V
    //   99: goto +40 -> 139
    //   102: pop
    //   103: goto +36 -> 139
    //   106: astore 7
    //   108: aload 5
    //   110: ifnull +12 -> 122
    //   113: aload 5
    //   115: invokevirtual 1650	java/io/InputStream:close	()V
    //   118: goto +4 -> 122
    //   121: pop
    //   122: aload 7
    //   124: athrow
    //   125: aload 5
    //   127: ifnull +12 -> 139
    //   130: aload 5
    //   132: invokevirtual 1650	java/io/InputStream:close	()V
    //   135: goto +4 -> 139
    //   138: pop
    //   139: aload 6
    //   141: ifnull +162 -> 303
    //   144: new 989	java/io/LineNumberReader
    //   147: dup
    //   148: new 992	java/io/StringReader
    //   151: dup
    //   152: new 1005	java/lang/String
    //   155: dup
    //   156: aload 6
    //   158: invokespecial 1678	java/lang/String:<init>	([C)V
    //   161: invokespecial 1663	java/io/StringReader:<init>	(Ljava/lang/String;)V
    //   164: invokespecial 1653	java/io/LineNumberReader:<init>	(Ljava/io/Reader;)V
    //   167: astore 7
    //   169: aconst_null
    //   170: astore 8
    //   172: goto +68 -> 240
    //   175: aload 8
    //   177: invokevirtual 1681	java/lang/String:trim	()Ljava/lang/String;
    //   180: astore 8
    //   182: aload 8
    //   184: ldc_w 813
    //   187: invokevirtual 1688	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   190: ifne +50 -> 240
    //   193: aload 8
    //   195: invokevirtual 1674	java/lang/String:length	()I
    //   198: ifne +6 -> 204
    //   201: goto +39 -> 240
    //   204: aload 8
    //   206: ldc 11
    //   208: invokevirtual 1688	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   211: ifeq +23 -> 234
    //   214: aload_1
    //   215: ifnull +25 -> 240
    //   218: aload 8
    //   220: aload_3
    //   221: aload_1
    //   222: invokeinterface 1885 1 0
    //   227: iload_2
    //   228: invokestatic 1812	org/eclipse/pde/api/tools/internal/util/Util:collectRegexIds	(Ljava/lang/String;Lorg/eclipse/pde/api/tools/internal/util/FilteredElements;[Lorg/eclipse/pde/api/tools/internal/provisional/model/IApiComponent;Z)V
    //   231: goto +9 -> 240
    //   234: aload_3
    //   235: aload 8
    //   237: invokevirtual 1776	org/eclipse/pde/api/tools/internal/util/FilteredElements:addExactMatch	(Ljava/lang/String;)V
    //   240: aload 7
    //   242: invokevirtual 1654	java/io/LineNumberReader:readLine	()Ljava/lang/String;
    //   245: dup
    //   246: astore 8
    //   248: ifnonnull -73 -> 175
    //   251: goto +43 -> 294
    //   254: pop
    //   255: aload 7
    //   257: invokevirtual 1652	java/io/LineNumberReader:close	()V
    //   260: goto +43 -> 303
    //   263: pop
    //   264: goto +39 -> 303
    //   267: pop
    //   268: aload 7
    //   270: invokevirtual 1652	java/io/LineNumberReader:close	()V
    //   273: goto +30 -> 303
    //   276: pop
    //   277: goto +26 -> 303
    //   280: astore 9
    //   282: aload 7
    //   284: invokevirtual 1652	java/io/LineNumberReader:close	()V
    //   287: goto +4 -> 291
    //   290: pop
    //   291: aload 9
    //   293: athrow
    //   294: aload 7
    //   296: invokevirtual 1652	java/io/LineNumberReader:close	()V
    //   299: goto +4 -> 303
    //   302: pop
    //   303: aload_3
    //   304: areturn
    // Line number table:
    //   Java source line #2274	-> byte code offset #0
    //   Java source line #2275	-> byte code offset #8
    //   Java source line #2276	-> byte code offset #12
    //   Java source line #2277	-> byte code offset #22
    //   Java source line #2278	-> byte code offset #30
    //   Java source line #2279	-> byte code offset #33
    //   Java source line #2281	-> byte code offset #39
    //   Java source line #2282	-> byte code offset #57
    //   Java source line #2284	-> byte code offset #70
    //   Java source line #2287	-> byte code offset #71
    //   Java source line #2289	-> byte code offset #76
    //   Java source line #2290	-> byte code offset #84
    //   Java source line #2285	-> byte code offset #88
    //   Java source line #2287	-> byte code offset #89
    //   Java source line #2289	-> byte code offset #94
    //   Java source line #2290	-> byte code offset #102
    //   Java source line #2286	-> byte code offset #106
    //   Java source line #2287	-> byte code offset #108
    //   Java source line #2289	-> byte code offset #113
    //   Java source line #2290	-> byte code offset #121
    //   Java source line #2292	-> byte code offset #122
    //   Java source line #2287	-> byte code offset #125
    //   Java source line #2289	-> byte code offset #130
    //   Java source line #2290	-> byte code offset #138
    //   Java source line #2293	-> byte code offset #139
    //   Java source line #2294	-> byte code offset #144
    //   Java source line #2295	-> byte code offset #169
    //   Java source line #2297	-> byte code offset #172
    //   Java source line #2298	-> byte code offset #175
    //   Java source line #2299	-> byte code offset #182
    //   Java source line #2300	-> byte code offset #201
    //   Java source line #2302	-> byte code offset #204
    //   Java source line #2303	-> byte code offset #214
    //   Java source line #2304	-> byte code offset #218
    //   Java source line #2307	-> byte code offset #234
    //   Java source li
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