org.eclipse.birt.core_3.7.2.v20120213

16:41:30.979 INFO  jd.cli.Main - Decompiling org.eclipse.birt.core_3.7.2.v20120213.jar
package org.eclipse.birt.core.archive;

public class ArchiveLockManager$ManagerHolder
{
  public static IArchiveLockManager instance = new DocArchiveLockManager();
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.archive.ArchiveLockManager.ManagerHolder
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.archive;

public class ArchiveLockManager
{
  protected static class ManagerHolder
  {
    public static IArchiveLockManager instance = new DocArchiveLockManager();
  }
  
  public static IArchiveLockManager getInstance()
  {
    return ManagerHolder.instance;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.archive.ArchiveLockManager
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.archive;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.ZipOutputStream;
import org.eclipse.birt.core.archive.compound.ArchiveReader;
import org.eclipse.birt.core.archive.compound.ArchiveWriter;
import org.eclipse.birt.core.archive.compound.IArchiveFile;
import org.eclipse.birt.core.i18n.CoreMessages;

public class ArchiveUtil
{
  protected static Logger logger = Logger.getLogger(ArchiveUtil.class.getName());
  public static String UNIX_SEPERATOR = "/";
  static final String READER_COUNT_FILE_NAME = "/.reader.count";
  
  public static String generateFullPath(String rootPath, String relativePath)
  {
    relativePath = convertToSystemString(relativePath);
    if (rootPath != null)
    {
      if (!rootPath.endsWith(File.separator)) {
        rootPath = rootPath + File.separator;
      }
      if (relativePath.startsWith(File.separator)) {
        relativePath = relativePath.substring(1);
      }
      return rootPath + relativePath;
    }
    return relativePath;
  }
  
  public static String generateRelativePath(String rootPath, String fullPath)
  {
    String relativePath = null;
    if ((rootPath != null) && (fullPath.startsWith(rootPath))) {
      relativePath = fullPath.substring(rootPath.length());
    } else {
      relativePath = fullPath;
    }
    relativePath = convertToUnixString(relativePath);
    if (!relativePath.startsWith(UNIX_SEPERATOR)) {
      relativePath = UNIX_SEPERATOR + relativePath;
    }
    return relativePath;
  }
  
  private static String convertToUnixString(String path)
  {
    if (path == null) {
      return null;
    }
    return path.replace(File.separator.charAt(0), UNIX_SEPERATOR
      .charAt(0));
  }
  
  private static String convertToSystemString(String path)
  {
    if (path == null) {
      return null;
    }
    return path.replace(UNIX_SEPERATOR.charAt(0), File.separator
      .charAt(0));
  }
  
  public static synchronized String generateUniqueFileFolderName(String originalName)
  {
    SimpleDateFormat df = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
    String dateTimeString = df.format(new Date());
    
    StringBuffer folderName = new StringBuffer(originalName);
    folderName.append('_');
    folderName.append(dateTimeString);
    
    Random generator = new Random();
    File folder = new File(folderName.toString());
    while (folder.exists())
    {
      folderName.append(generator.nextInt());
      folder = new File(folderName.toString());
    }
    return folderName.toString();
  }
  
  public static void createParentFolder(File fd)
  {
    if ((fd != null) && (fd.getParentFile() != null) && 
      (!fd.getParentFile().exists())) {
      fd.getParentFile().mkdirs();
    }
  }
  
  public static void deleteAllFiles(File dirOrFile)
  {
    if (!dirOrFile.exists()) {
      return;
    }
    if (dirOrFile.isFile())
    {
      dirOrFile.delete();
    }
    else
    {
      if ((dirOrFile.listFiles() != null) && 
        (dirOrFile.listFiles().length > 0))
      {
        File[] fileList = dirOrFile.listFiles();
        for (int i = 0; i < fileList.length; i++) {
          deleteAllFiles(fileList[i]);
        }
      }
      dirOrFile.delete();
    }
  }
  
  public static void zipFolderToStream(String tempFolderPath, OutputStream ostream)
  {
    ZipOutputStream zipOutput = new ZipOutputStream(ostream);
    File rootDir = new File(tempFolderPath);
    File[] files = rootDir.listFiles();
    try
    {
      zipFiles(zipOutput, files, tempFolderPath);
      zipOutput.close();
    }
    catch (FileNotFoundException e)
    {
      logger.log(Level.WARNING, e.getMessage());
    }
    catch (IOException e)
    {
      logger.log(Level.WARNING, e.getMessage());
    }
  }
  
  /* Error */
  private static void zipFiles(ZipOutputStream zipOut, File[] files, String tempFolderPath)
    throws FileNotFoundException, IOException
  {
    // Byte code:
    //   0: aload_1
    //   1: ifnonnull +4 -> 5
    //   4: return
    //   5: iconst_0
    //   6: istore_3
    //   7: goto +158 -> 165
    //   10: aload_1
    //   11: iload_3
    //   12: aaload
    //   13: astore 4
    //   15: aload 4
    //   17: invokevirtual 387	java/io/File:isDirectory	()Z
    //   20: ifeq +20 -> 40
    //   23: aload 4
    //   25: invokevirtual 391	java/io/File:listFiles	()[Ljava/io/File;
    //   28: astore 5
    //   30: aload_0
    //   31: aload 5
    //   33: aload_2
    //   34: invokestatic 451	org/eclipse/birt/core/archive/ArchiveUtil:zipFiles	(Ljava/util/zip/ZipOutputStream;[Ljava/io/File;Ljava/lang/String;)V
    //   37: goto +125 -> 162
    //   40: new 192	java/io/BufferedInputStream
    //   43: dup
    //   44: new 195	java/io/FileInputStream
    //   47: dup
    //   48: aload 4
    //   50: invokespecial 396	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   53: invokespecial 380	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   56: astore 5
    //   58: aload_2
    //   59: aload 4
    //   61: invokevirtual 394	java/io/File:getPath	()Ljava/lang/String;
    //   64: invokestatic 453	org/eclipse/birt/core/archive/ArchiveUtil:generateRelativePath	(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //   67: astore 6
    //   69: new 214	java/util/zip/ZipEntry
    //   72: dup
    //   73: aload 6
    //   75: invokespecial 434	java/util/zip/ZipEntry:<init>	(Ljava/lang/String;)V
    //   78: astore 7
    //   80: aload 7
    //   82: aload 4
    //   84: invokevirtual 384	java/io/File:lastModified	()J
    //   87: invokevirtual 432	java/util/zip/ZipEntry:setTime	(J)V
    //   90: aload_0
    //   91: aload 7
    //   93: invokevirtual 444	java/util/zip/ZipOutputStream:putNextEntry	(Ljava/util/zip/ZipEntry;)V
    //   96: sipush 5120
    //   99: newarray <illegal type>
    //   101: astore 9
    //   103: goto +12 -> 115
    //   106: aload_0
    //   107: aload 9
    //   109: iconst_0
    //   110: iload 8
    //   112: invokevirtual 442	java/util/zip/ZipOutputStream:write	([BII)V
    //   115: aload 5
    //   117: aload 9
    //   119: invokevirtual 379	java/io/BufferedInputStream:read	([B)I
    //   122: dup
    //   123: istore 8
    //   125: ifgt -19 -> 106
    //   128: goto +12 -> 140
    //   131: astore 10
    //   133: aload_0
    //   134: invokevirtual 441	java/util/zip/ZipOutputStream:closeEntry	()V
    //   137: aload 10
    //   139: athrow
    //   140: aload_0
    //   141: invokevirtual 441	java/util/zip/ZipOutputStream:closeEntry	()V
    //   144: goto +13 -> 157
    //   147: astore 11
    //   149: aload 5
    //   151: invokevirtual 378	java/io/BufferedInputStream:close	()V
    //   154: aload 11
    //   156: athrow
    //   157: aload 5
    //   159: invokevirtual 378	java/io/BufferedInputStream:close	()V
    //   162: iinc 3 1
    //   165: iload_3
    //   166: aload_1
    //   167: arraylength
    //   168: if_icmplt -158 -> 10
    //   171: return
    // Line number table:
    //   Java source line #243	-> byte code offset #0
    //   Java source line #244	-> byte code offset #4
    //   Java source line #246	-> byte code offset #5
    //   Java source line #248	-> byte code offset #10
    //   Java source line #249	-> byte code offset #15
    //   Java source line #252	-> byte code offset #23
    //   Java source line #253	-> byte code offset #30
    //   Java source line #259	-> byte code offset #40
    //   Java source line #258	-> byte code offset #56
    //   Java source line #262	-> byte code offset #58
    //   Java source line #263	-> byte code offset #59
    //   Java source line #262	-> byte code offset #64
    //   Java source line #264	-> byte code offset #69
    //   Java source line #267	-> byte code offset #80
    //   Java source line #268	-> byte code offset #90
    //   Java source line #271	-> byte code offset #96
    //   Java source line #272	-> byte code offset #103
    //   Java source line #274	-> byte code offset #106
    //   Java source line #272	-> byte code offset #115
    //   Java source line #278	-> byte code offset #131
    //   Java source line #279	-> byte code offset #133
    //   Java source line #280	-> byte code offset #137
    //   Java source line #279	-> byte code offset #140
    //   Java source line #283	-> byte code offset #147
    //   Java source line #284	-> byte code offset #149
    //   Java source line #285	-> byte code offset #154
    //   Java source line #284	-> byte code offset #157
    //   Java source line #246	-> byte code offset #162
    //   Java source line #288	-> byte code offset #171
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	172	0	zipOut	ZipOutputStream
    //   0	172	1	files	File[]
    //   0	172	2	tempFolderPath	String
    //   6	160	3	i	int
    //   13	70	4	file	File
    //   28	4	5	dirFiles	File[]
    //   56	102	5	in	java.io.BufferedInputStream
    //   67	7	6	relativePath	String
    //   78	14	7	entry	java.util.zip.ZipEntry
    //   106	5	8	len	int
    //   123	3	8	len	int
    //   101	17	9	buf	byte[]
    //   131	7	10	localObject1	Object
    //   147	8	11	localObject2	Object
    // Exception table:
    //   from	to	target	type
    //   80	131	131	finally
    //   58	147	147	finally
  }
  
  /* Error */
  public static void unzipArchive(File zipArchive, String tempFolderPath)
  {
    // Byte code:
    //   0: new 216	java/util/zip/ZipFile
    //   3: dup
    //   4: aload_0
    //   5: invokespecial 437	java/util/zip/ZipFile:<init>	(Ljava/io/File;)V
    //   8: astore_2
    //   9: aload_2
    //   10: invokevirtual 438	java/util/zip/ZipFile:entries	()Ljava/util/Enumeration;
    //   13: astore_3
    //   14: goto +229 -> 243
    //   17: aload_3
    //   18: invokeinterface 473 1 0
    //   23: checkcast 214	java/util/zip/ZipEntry
    //   26: astore 4
    //   28: aload 4
    //   30: invokevirtual 431	java/util/zip/ZipEntry:isDirectory	()Z
    //   33: ifeq +34 -> 67
    //   36: aload_1
    //   37: aload 4
    //   39: invokevirtual 433	java/util/zip/ZipEntry:getName	()Ljava/lang/String;
    //   42: invokestatic 452	org/eclipse/birt/core/archive/ArchiveUtil:generateFullPath	(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //   45: astore 5
    //   47: new 194	java/io/File
    //   50: dup
    //   51: aload 5
    //   53: invokespecial 395	java/io/File:<init>	(Ljava/lang/String;)V
    //   56: astore 6
    //   58: aload 6
    //   60: invokevirtual 389	java/io/File:mkdirs	()Z
    //   63: pop
    //   64: goto +179 -> 243
    //   67: aconst_null
    //   68: astore 5
    //   70: aload_2
    //   71: aload 4
    //   73: invokevirtual 439	java/util/zip/ZipFile:getInputStream	(Ljava/util/zip/ZipEntry;)Ljava/io/InputStream;
    //   76: astore 5
    //   78: new 194	java/io/File
    //   81: dup
    //   82: aload_1
    //   83: aload 4
    //   85: invokevirtual 433	java/util/zip/ZipEntry:getName	()Ljava/lang/String;
    //   88: invokestatic 452	org/eclipse/birt/core/archive/ArchiveUtil:generateFullPath	(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    //   91: invokespecial 395	java/io/File:<init>	(Ljava/lang/String;)V
    //   94: astore 6
    //   96: new 194	java/io/File
    //   99: dup
    //   100: aload 6
    //   102: invokevirtual 393	java/io/File:getParent	()Ljava/lang/String;
    //   105: invokespecial 395	java/io/File:<init>	(Ljava/lang/String;)V
    //   108: astore 7
    //   110: aload 7
    //   112: invokevirtual 386	java/io/File:exists	()Z
    //   115: ifeq +25 -> 140
    //   118: getstatic 374	org/eclipse/birt/core/archive/ArchiveUtil:$assertionsDisabled	Z
    //   121: ifne +25 -> 146
    //   124: aload 7
    //   126: invokevirtual 387	java/io/File:isDirectory	()Z
    //   129: ifne +17 -> 146
    //   132: new 200	java/lang/AssertionError
    //   135: dup
    //   136: invokespecial 403	java/lang/AssertionError:<init>	()V
    //   139: athrow
    //   140: aload 7
    //   142: invokevirtual 389	java/io/File:mkdirs	()Z
    //   145: pop
    //   146: new 193	java/io/BufferedOutputStream
    //   149: dup
    //   150: new 197	java/io/FileOutputStream
    //   153: dup
    //   154: aload 6
    //   156: invokespecial 398	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   159: invokespecial 383	java/io/BufferedOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   162: astore 8
    //   164: sipush 5120
    //   167: newarray <illegal type>
    //   169: astore 10
    //   171: goto +13 -> 184
    //   174: aload 8
    //   176: aload 10
    //   178: iconst_0
    //   179: iload 9
    //   181: invokevirtual 382	java/io/BufferedOutputStream:write	([BII)V
    //   184: aload 5
    //   186: aload 10
    //   188: invokevirtual 402	java/io/InputStream:read	([B)I
    //   191: dup
    //   192: istore 9
    //   194: ifgt -20 -> 174
    //   197: goto +13 -> 210
    //   200: astore 11
    //   202: aload 8
    //   204: invokevirtual 381	java/io/BufferedOutputStream:close	()V
    //   207: aload 11
    //   209: athrow
    //   210: aload 8
    //   212: invokevirtual 381	java/io/BufferedOutputStream:close	()V
    //   215: goto +18 -> 233
    //   218: astore 12
    //   220: aload 5
    //   222: ifnull +8 -> 230
    //   225: aload 5
    //   227: invokevirtual 401	java/io/InputStream:close	()V
    //   230: aload 12
    //   232: athrow
    //   233: aload 5
    //   235: ifnull +8 -> 243
    //   238: aload 5
    //   240: invokevirtual 401	java/io/InputStream:close	()V
    //   243: aload_3
    //   244: invokeinterface 472 1 0
    //   249: ifne -232 -> 17
    //   252: aload_2
    //   253: invokevirtual 436	java/util/zip/ZipFile:close	()V
    //   256: goto +34 -> 290
    //   259: astore_2
    //   260: getstatic 377	org/eclipse/birt/core/archive/ArchiveUtil:logger	Ljava/util/logging/Logger;
    //   263: getstatic 373	java/util/logging/Level:WARNING	Ljava/util/logging/Level;
    //   266: aload_2
    //   267: invokevirtual 435	java/util/zip/ZipException:getMessage	()Ljava/lang/String;
    //   270: invokevirtual 429	java/util/logging/Logger:log	(Ljava/util/logging/Level;Ljava/lang/String;)V
    //   273: goto +17 -> 290
    //   276: astore_2
    //   277: getstatic 377	org/eclipse/birt/core/archive/ArchiveUtil:logger	Ljava/util/logging/Logger;
    //   280: getstatic 373	java/util/logging/Level:WARNING	Ljava/util/logging/Level;
    //   283: aload_2
    //   284: invokevirtual 399	java/io/IOException:getMessage	()Ljava/lang/String;
    //   287: invokevirtual 429	java/util/logging/Logger:log	(Ljava/util/logging/Level;Ljava/lang/String;)V
    //   290: return
    // Line number table:
    //   Java source line #294	-> byte code offset #0
    //   Java source line #296	-> byte code offset #9
    //   Java source line #297	-> byte code offset #14
    //   Java source line #299	-> byte code offset #17
    //   Java source line #300	-> byte code offset #28
    //   Java source line #303	-> byte code offset #36
    //   Java source line #304	-> byte code offset #39
    //   Java source line #303	-> byte code offset #42
    //   Java source line #307	-> byte code offset #47
    //   Java source line #308	-> byte code offset #58
    //   Java source line #312	-> byte code offset #67
    //   Java source line #315	-> byte code offset #70
    //   Java source line #316	-> byte code offset #78
    //   Java source line #317	-> byte code offset #83
    //   Java source line #316	-> byte code offset #88
    //   Java source line #319	-> byte code offset #96
    //   Java source line #320	-> byte code offset #110
    //   Java source line #322	-> byte code offset #118
    //   Java source line #326	-> byte code offset #140
    //   Java source line #329	-> byte code offset #146
    //   Java source line #330	-> byte code offset #150
    //   Java source line #329	-> byte code offset #159
    //   Java source line #332	-> byte code offset #164
    //   Java source line #335	-> byte code offset #171
    //   Java source line #337	-> byte code offset #174
    //   Java source line #335	-> byte code offset #184
    //   Java source line #341	-> byte code offset #200
    //   Java source line #342	-> byte code offset #202
    //   Java source line #343	-> byte code offset #207
    //   Java source line #342	-> byte code offset #210
    //   Java source line #346	-> byte code offset #218
    //   Java source line #347	-> byte code offset #220
    //   Java source line #349	-> byte code offset #225
    //   Java source line #351	-> byte code offset #230
    //   Java source line #347	-> byte code offset #233
    //   Java source line #349	-> byte code offset #238
    //   Java source line #297	-> byte code offset #243
    //   Java source line #354	-> byte code offset #252
    //   Java source line #357	-> byte code offset #259
    //   Java source line #359	-> byte code offset #260
    //   Java source line #361	-> byte code offset #276
    //   Java source line #363	-> byte code offset #277
    //   Java source line #365	-> byte code offset #290
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	291	0	zipArchive	File
    //   0	291	1	tempFolderPath	String
    //   8	245	2	zipFile	java.util.zip.ZipFile
    //   259	8	2	e	java.util.zip.ZipException
    //   276	8	2	e	IOException
    //   13	231	3	entries	java.util.Enumeration
    //   26	58	4	entry	java.util.zip.ZipEntry
    //   45	7	5	dirName	String
    //   68	171	5	in	java.io.InputStream
    //   56	3	6	dir	File
    //   94	61	6	file	File
    //   108	33	7	dir	File
    //   162	49	8	out	java.io.BufferedOutputStream
    //   174	6	9	len	int
    //   192	3	9	len	int
    //   210	1	9	len	int
    //   169	18	10	buf	byte[]
    //   200	8	11	localObject1	Object
    //   218	13	12	localObject2	Object
    // Exception table:
    //   from	to	target	type
    //   171	200	200	finally
    //   70	218	218	finally
    //   0	256	259	java/util/zip/ZipException
    //   0	256	276	java/io/IOException
  }
  
  public static void copy(IArchiveFile inArchive, IArchiveFile outArchive)
    throws IOException
  {
    if ((inArchive == null) || (outArchive == null)) {
      throw new IOException(
        CoreMessages.getString("error.NullSource"));
    }
    copy(new ArchiveReader(inArchive), new ArchiveWriter(outArchive));
  }
  
  /* Error */
  public static void copy(IDocArchiveReader reader, IDocArchiveWriter writer)
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: invokeinterface 476 1 0
    //   6: astore_2
    //   7: iconst_0
    //   8: istore_3
    //   9: goto +81 -> 90
    //   12: aload_2
    //   13: iload_3
    //   14: invokeinterface 475 2 0
    //   19: checkcast 203	java/lang/String
    //   22: astore 4
    //   24: aload_0
    //   25: aload 4
    //   27: invokeinterface 477 2 0
    //   32: astore 5
    //   34: aload_1
    //   35: aload 4
    //   37: invokeinterface 478 2 0
    //   42: astore 6
    //   44: aload 5
    //   46: aload 6
    //   48: invokestatic 450	org/eclipse/birt/core/archive/ArchiveUtil:copyStream	(Lorg/eclipse/birt/core/archive/RAInputStream;Lorg/eclipse/birt/core/archive/RAOutputStream;)V
    //   51: goto +13 -> 64
    //   54: astore 7
    //   56: aload 6
    //   58: invokevirtual 467	org/eclipse/birt/core/archive/RAOutputStream:close	()V
    //   61: aload 7
    //   63: athrow
    //   64: aload 6
    //   66: invokevirtual 467	org/eclipse/birt/core/archive/RAOutputStream:close	()V
    //   69: goto +13 -> 82
    //   72: astore 8
    //   74: aload 5
    //   76: invokevirtual 465	org/eclipse/birt/core/archive/RAInputStream:close	()V
    //   79: aload 8
    //   81: athrow
    //   82: aload 5
    //   84: invokevirtual 465	org/eclipse/birt/core/archive/RAInputStream:close	()V
    //   87: iinc 3 1
    //   90: iload_3
    //   91: aload_2
    //   92: invokeinterface 474 1 0
    //   97: if_icmplt -85 -> 12
    //   100: return
    // Line number table:
    //   Java source line #382	-> byte code offset #0
    //   Java source line #383	-> byte code offset #7
    //   Java source line #385	-> byte code offset #12
    //   Java source line #386	-> byte code offset #24
    //   Java source line #389	-> byte code offset #34
    //   Java source line #390	-> byte code offset #35
    //   Java source line #389	-> byte code offset #42
    //   Java source line #393	-> byte code offset #44
    //   Java source line #396	-> byte code offset #54
    //   Java source line #397	-> byte code offset #56
    //   Java source line #398	-> byte code offset #61
    //   Java source line #397	-> byte code offset #64
    //   Java source line #401	-> byte code offset #72
    //   Java source line #402	-> byte code offset #74
    //   Java source line #403	-> byte code offset #79
    //   Java source line #402	-> byte code offset #82
    //   Java source line #383	-> byte code offset #87
    //   Java source line #405	-> byte code offset #100
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	101	0	reader	IDocArchiveReader
    //   0	101	1	writer	IDocArchiveWriter
    //   6	86	2	streamList	java.util.List
    //   8	83	3	i	int
    //   22	14	4	streamPath	String
    //   32	51	5	in	RAInputStream
    //   42	23	6	out	RAOutputStream
    //   54	8	7	localObject1	Object
    //   72	8	8	localObject2	Object
    // Exception table:
    //   from	to	target	type
    //   44	54	54	finally
    //   34	72	72	finally
  }
  
  private static void copyStream(RAInputStream in, RAOutputStream out)
    throws IOException
  {
    byte[] buf = new byte['?'];
    int readSize = in.read(buf);
    while (readSize != -1)
    {
      out.write(buf, 0, readSize);
      readSize = in.read(buf);
    }
  }
  
  public static void archive(String folder, String file)
    throws IOException
  {
    archive(folder, null, file);
  }
  
  static final String[] SKIP_FILES = { "/.reader.count" };
  
  /* Error */
  public static void archive(String folderName, IStreamSorter sorter, String fileName)
    throws IOException
  {
    // Byte code:
    //   0: new 194	java/io/File
    //   3: dup
    //   4: aload_0
    //   5: invokespecial 395	java/io/File:<init>	(Ljava/lang/String;)V
    //   8: invokevirtual 392	java/io/File:getCanonicalPath	()Ljava/lang/String;
    //   11: astore_0
    //   12: new 220	org/eclipse/birt/core/archive/FolderArchiveReader
    //   15: dup
    //   16: aload_0
    //   17: invokespecial 464	org/eclipse/birt/core/archive/FolderArchiveReader:<init>	(Ljava/lang/String;)V
    //   20: astore_3
    //   21: aload_3
    //   22: invokevirtual 463	org/eclipse/birt/core/archive/FolderArchiveReader:open	()V
    //   25: new 194	java/io/File
    //   28: dup
    //   29: aload_2
    //   30: invokespecial 395	java/io/File:<init>	(Ljava/lang/String;)V
    //   33: invokestatic 445	org/eclipse/birt/core/archive/ArchiveUtil:deleteAllFiles	(Ljava/io/File;)V
    //   36: new 219	org/eclipse/birt/core/archive/FileArchiveWriter
    //   39: dup
    //   40: aload_2
    //   41: invokespecial 461	org/eclipse/birt/core/archive/FileArchiveWriter:<init>	(Ljava/lang/String;)V
    //   44: astore 4
    //   46: aload 4
    //   48: invokevirtual 460	org/eclipse/birt/core/archive/FileArchiveWriter:initialize	()V
    //   51: aload_3
    //   52: aload 4
    //   54: invokestatic 449	org/eclipse/birt/core/archive/ArchiveUtil:copy	(Lorg/eclipse/birt/core/archive/IDocArchiveReader;Lorg/eclipse/birt/core/archive/IDocArchiveWriter;)V
    //   57: goto +13 -> 70
    //   60: astore 5
    //   62: aload 4
    //   64: invokevirtual 459	org/eclipse/birt/core/archive/FileArchiveWriter:finish	()V
    //   67: aload 5
    //   69: athrow
    //   70: aload 4
    //   72: invokevirtual 459	org/eclipse/birt/core/archive/FileArchiveWriter:finish	()V
    //   75: goto +12 -> 87
    //   78: astore 6
    //   80: aload_3
    //   81: invokevirtual 462	org/eclipse/birt/core/archive/FolderArchiveReader:close	()V
    //   84: aload 6
    //   86: athrow
    //   87: aload_3
    //   88: invokevirtual 462	org/eclipse/birt/core/archive/FolderArchiveReader:close	()V
    //   91: return
    // Line number table:
    //   Java source line #442	-> byte code offset #0
    //   Java source line #443	-> byte code offset #12
    //   Java source line #446	-> byte code offset #21
    //   Java source line #447	-> byte code offset #25
    //   Java source line #448	-> byte code offset #36
    //   Java source line #451	-> byte code offset #46
    //   Java source line #452	-> byte code offset #51
    //   Java source line #455	-> byte code offset #60
    //   Java source line #456	-> byte code offset #62
    //   Java source line #457	-> byte code offset #67
    //   Java source line #456	-> byte code offset #70
    //   Java source line #460	-> byte code offset #78
    //   Java source line #461	-> byte code offset #80
    //   Java source line #462	-> byte code offset #84
    //   Java source line #461	-> byte code offset #87
    //   Java source line #463	-> byte code offset #91
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	92	0	folderName	String
    //   0	92	1	sorter	IStreamSorter
    //   0	92	2	fileName	String
    //   20	68	3	reader	FolderArchiveReader
    //   44	27	4	writer	FileArchiveWriter
    //   60	8	5	localObject1	Object
    //   78	7	6	localObject2	Object
    // Exception table:
    //   from	to	target	type
    //   46	60	60	finally
    //   21	78	78	finally
  }
  
  static boolean needSkip(String file)
  {
    for (int i = 0; i < SKIP_FILES.length; i++) {
      if (SKIP_FILES[i].equals(file)) {
        return true;
      }
    }
    return false;
  }
  
  public static void listAllFiles(File dir, ArrayList fileList)
  {
    if ((dir.exists()) && (dir.isDirectory()))
    {
      File[] files = dir.listFiles();
      if (files == null) {
        return;
      }
      for (int i = 0; i < files.length; i++)
      {
        File file = files[i];
        if (file.isFile()) {
          fileList.add(file);
        } else if (file.isDirectory()) {
          listAllFiles(file, fileList);
        }
      }
    }
  }
  
  /* Error */
  public static void expand(String file, String folder)
    throws IOException
  {
    // Byte code:
    //   0: new 218	org/eclipse/birt/core/archive/FileArchiveReader
    //   3: dup
    //   4: aload_0
    //   5: invokespecial 457	org/eclipse/birt/core/archive/FileArchiveReader:<init>	(Ljava/lang/String;)V
    //   8: astore_2
    //   9: aload_2
    //   10: invokevirtual 456	org/eclipse/birt/core/archive/FileArchiveReader:open	()V
    //   13: aload_2
    //   14: aload_1
    //   15: invokevirtual 458	org/eclipse/birt/core/archive/FileArchiveReader:expandFileArchive	(Ljava/lang/String;)V
    //   18: goto +10 -> 28
    //   21: astore_3
    //   22: aload_2
    //   23: invokevirtual 455	org/eclipse/birt/core/archive/FileArchiveReader:close	()V
    //   26: aload_3
    //   27: athrow
    //   28: aload_2
    //   29: invokevirtual 455	org/eclipse/birt/core/archive/FileArchiveReader:close	()V
    //   32: return
    // Line number table:
    //   Java source line #520	-> byte code offset #0
    //   Java source line #523	-> byte code offset #9
    //   Java source line #524	-> byte code offset #13
    //   Java source line #527	-> byte code offset #21
    //   Java source line #528	-> byte code offset #22
    //   Java source line #529	-> byte code offset #26
    //   Java source line #528	-> byte code offset #28
    //   Java source line #530	-> byte code offset #32
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	33	0	file	String
    //   0	33	1	folder	String
    //   8	21	2	reader	FileArchiveReader
    //   21	6	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   9	21	21	finally
  }
  
  public static final int bytesToInteger(byte[] b)
  {
    assert (b.length >= 4);
    return ((b[0] & 0xFF) << 24) + ((b[1] & 0xFF) << 16) + (
      (b[2] & 0xFF) << 8) + ((b[3] & 0xFF) << 0);
  }
  
  public static final int bytesToInteger(byte[] b, int off)
  {
    assert (b.length - off >= 4);
    return ((b[(off++)] & 0xFF) << 24) + ((b[(off++)] & 0xFF) << 16) + (
      (b[(off++)] & 0xFF) << 8) + ((b[off] & 0xFF) << 0);
  }
  
  public static final long bytesToLong(byte[] b)
  {
    assert (b.length >= 8);
    return ((b[0] & 0xFF) << 56) + ((b[1] & 0xFF) << 48) + (
      (b[2] & 0xFF) << 40) + ((b[3] & 0xFF) << 32) + (
      (b[4] & 0xFF) << 24) + ((b[5] & 0xFF) << 16) + (
      (b[6] & 0xFF) << 8) + ((b[7] & 0xFF) << 0);
  }
  
  public static final long bytesToLong(byte[] b, int off)
  {
    assert (b.length - off >= 8);
    return ((b[(off++)] & 0xFF) << 56) + ((b[(off++)] & 0xFF) << 48) + (
      (b[(off++)] & 0xFF) << 40) + (
      (b[(off++)] & 0xFF) << 32) + (
      (b[(off++)] & 0xFF) << 24) + (
      (b[(off++)] & 0xFF) << 16) + ((b[(off++)] & 0xFF) << 8) + (
      (b[off] & 0xFF) << 0);
  }
  
  public static final void integerToBytes(int v, byte[] b)
  {
    assert (b.length >= 4);
    b[0] = ((byte)(v >>> 24 & 0xFF));
    b[1] = ((byte)(v >>> 16 & 0xFF));
    b[2] = ((byte)(v >>> 8 & 0xFF));
    b[3] = ((byte)(v >>> 0 & 0xFF));
  }
  
  public static final void integerToBytes(int v, byte[] b, int off)
  {
    assert (b.length - off >= 4);
    b[(off++)] = ((byte)(v >>> 24 & 0xFF));
    b[(off++)] = ((byte)(v >>> 16 & 0xFF));
    b[(off++)] = ((byte)(v >>> 8 & 0xFF));
    b[off] = ((byte)(v >>> 0 & 0xFF));
  }
  
  public static final void longToBytes(long v, byte[] b)
  {
    assert (b.length >= 8);
    b[0] = ((byte)(int)(v >>> 56 & 0xFF));
    b[1] = ((byte)(int)(v >>> 48 & 0xFF));
    b[2] = ((byte)(int)(v >>> 40 & 0xFF));
    b[3] = ((byte)(int)(v >>> 32 & 0xFF));
    b[4] = ((byte)(int)(v >>> 24 & 0xFF));
    b[5] = ((byte)(int)(v >>> 16 & 0xFF));
    b[6] = ((byte)(int)(v >>> 8 & 0xFF));
    b[7] = ((byte)(int)(v >>> 0 & 0xFF));
  }
  
  public static final void longToBytes(long v, byte[] b, int off)
  {
    assert (b.length - off >= 8);
    b[(off++)] = ((byte)(int)(v >>> 56 & 0xFF));
    b[(off++)] = ((byte)(int)(v >>> 48 & 0xFF));
    b[(off++)] = ((byte)(int)(v >>> 40 & 0xFF));
    b[(off++)] = ((byte)(int)(v >>> 32 & 0xFF));
    b[(off++)] = ((byte)(int)(v >>> 24 & 0xFF));
    b[(off++)] = ((byte)(int)(v >>> 16 & 0xFF));
    b[(off++)] = ((byte)(int)(v >>> 8 & 0xFF));
    b[off] = ((byte)(int)(v >>> 0 & 0xFF));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.archive.ArchiveUtil
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.archive;

import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

class DocArchiveLockManager$Channel
{
  RandomAccessFile file;
  FileChannel channel;
  int refCount;
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.archive.DocArchiveLockManager.Channel
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.archive;

import java.nio.channels.FileLock;

class DocArchiveLockManager$Lock
{
  String name;
  FileLock lock;
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.archive.DocArchiveLockManager.Lock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.archive;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

class DocArchiveLockManager
  implements IArchiveLockManager
{
  protected static Logger log = Logger.getLogger(DocArchiveLockManager.class
    .getName());
  protected HashMap channels = new HashMap();
  
  protected synchronized FileChannel getChannel(String name)
    throws IOException
  {
    Channel channel = (Channel)channels.get(name);
    if (channel == null)
    {
      channel = new Channel(null);
      file = new RandomAccessFile(name, "rw");
      channel = file.getChannel();
      channels.put(name, channel);
    }
    refCount += 1;
    return channel;
  }
  
  protected synchronized void releaseChannel(String name)
  {
    Channel channel = (Channel)channels.get(name);
    if (channel != null)
    {
      refCount -= 1;
      if (refCount == 0)
      {
        channels.remove(name);
        try
        {
          file.close();
          new File(name).delete();
        }
        catch (IOException ex)
        {
          log.log(Level.FINE, "failed to close the file", ex);
        }
      }
    }
  }
  
  /* Error */
  public Object lock(String name)
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_1
    //   2: invokevirtual 154	org/eclipse/birt/core/archive/DocArchiveLockManager:getChannel	(Ljava/lang/String;)Ljava/nio/channels/FileChannel;
    //   5: astore_2
    //   6: aload_2
    //   7: dup
    //   8: astore_3
    //   9: monitorenter
    //   10: aload_2
    //   11: invokevirtual 144	java/nio/channels/FileChannel:lock	()Ljava/nio/channels/FileLock;
    //   14: astore 4
    //   16: new 69	org/eclipse/birt/core/archive/DocArchiveLockManager$Lock
    //   19: dup
    //   20: aconst_null
    //   21: invokespecial 156	org/eclipse/birt/core/archive/DocArchiveLockManager$Lock:<init>	(Lorg/eclipse/birt/core/archive/DocArchiveLockManager$Lock;)V
    //   24: astore 5
    //   26: aload 5
    //   28: aload_1
    //   29: putfield 133	org/eclipse/birt/core/archive/DocArchiveLockManager$Lock:name	Ljava/lang/String;
    //   32: aload 5
    //   34: aload 4
    //   36: putfield 134	org/eclipse/birt/core/archive/DocArchiveLockManager$Lock:lock	Ljava/nio/channels/FileLock;
    //   39: aload 5
    //   41: aload_3
    //   42: monitorexit
    //   43: areturn
    //   44: pop
    //   45: aload_2
    //   46: invokevirtual 143	java/lang/Object:wait	()V
    //   49: goto +4 -> 53
    //   52: pop
    //   53: aload_3
    //   54: monitorexit
    //   55: goto -49 -> 6
    //   58: aload_3
    //   59: monitorexit
    //   60: athrow
    //   61: astore_3
    //   62: aload_0
    //   63: aload_1
    //   64: invokevirtual 153	org/eclipse/birt/core/archive/DocArchiveLockManager:releaseChannel	(Ljava/lang/String;)V
    //   67: aload_3
    //   68: athrow
    // Line number table:
    //   Java source line #103	-> byte code offset #0
    //   Java source line #108	-> byte code offset #6
    //   Java source line #112	-> byte code offset #10
    //   Java source line #113	-> byte code offset #16
    //   Java source line #114	-> byte code offset #26
    //   Java source line #115	-> byte code offset #32
    //   Java source line #116	-> byte code offset #39
    //   Java source line #118	-> byte code offset #44
    //   Java source line #124	-> byte code offset #45
    //   Java source line #126	-> byte code offset #52
    //   Java source line #108	-> byte code offset #53
    //   Java source line #133	-> byte code offset #61
    //   Java source line #135	-> byte code offset #62
    //   Java source line #136	-> byte code offset #67
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	69	0	this	DocArchiveLockManager
    //   0	69	1	name	String
    //   5	41	2	channel	FileChannel
    //   61	7	3	ex	IOException
    //   14	21	4	fLock	FileLock
    //   24	16	5	lock	Lock
    //   44	1	7	localOverlappingFileLockException	java.nio.channels.OverlappingFileLockException
    //   52	1	8	localInterruptedException	InterruptedException
    // Exception table:
    //   from	to	target	type
    //   10	41	44	java/nio/channels/OverlappingFileLockException
    //   45	49	52	java/lang/InterruptedException
    //   10	43	58	finally
    //   44	55	58	finally
    //   58	60	58	finally
    //   6	43	61	java/io/IOException
    //   44	61	61	java/io/IOException
  }
  
  public void unlock(Object lockObj)
  {
    if ((lockObj instanceof Lock))
    {
      Lock lock = (Lock)lockObj;
      FileLock fLock = lock;
      FileChannel channel = fLock.channel();
      try
      {
        fLock.release();
      }
      catch (Exception ex)
      {
        log.log(Level.FINE, "exception occus while release the lock", 
          ex);
      }
      synchronized (channel)
      {
        channel.notify();
      }
      releaseChannel(name);
    }
  }
  
  private static class Channel
  {
    RandomAccessFile file;
    FileChannel channel;
    int refCount;
  }
  
  private static class Lock
  {
    String name;
    FileLock lock;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.core.archive.DocArchiveLockManager
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.core.archive;

import java.io.IOException;
import org.eclipse.birt.core.archive.compound.ArchiveReader;

public class FileArchiveReader
  extends ArchiveReader
{
  public FileArchiveReader(String fileName)
    throws IOException
  {
    super(fileName);
  }
  
  /* Error */
  public void expandFileArchive(String folderArchiveName)
    throws IOException
  {
    // Byte code:
    //   0: new 22	java/io/File
    //   3: dup
    //   4: aload_1
    //   5: invokespecial 45	java/io/File:<init>	(Ljava/lang/String;)V
    //   8: astore_2
    //   9: aload_2
    //   10: invokevirtual 44	java/io/File:getCanonicalPath	()Ljava/lang/String;
    //   13: astore_1
    //   14: aload_2
    //   15: invokestatic 46	org/eclipse/birt/core/archive/ArchiveUtil:deleteAllFiles	(Ljava/io/File;)V
    //   18: aload_2
    //   19: invokevirtual 43	java/io/File:mkdirs	()Z
    //   22: pop
    //   23: new 26	org/eclipse/birt/core/archive/FolderArchiveWriter
    //   26: dup
    //   27: aload_1
    //   28: invokespecial 50	org/eclipse/birt/core/archive/FolderArchiveWriter:<init>	(Ljava/lang/String;)V
    //   31: astore_3
    //   32: aload_3
    //   33: invokevirtual 49	org/eclipse/birt/core/archive/FolderArchiveWriter:initialize	()V
    //   36: aload_0
    //   37: aload_3
    //   38: invokestatic 47	org/eclipse/birt/core/archive/ArchiveUtil:copy	(Lorg/eclipse/birt/core/archive/IDocArchiveReader;Lorg/eclipse/birt/core/archive/IDocArchiveWriter;)V
    //   41: goto +12 -> 53
    //   44: astore 4
    //   46: aload_3
    //   47: invokevirtual 48	org/eclipse/birt/core/archive/FolderArchiveWriter:finish	()V
    //   50: aload 4
    //   52: athrow
    //   53: aload_3
    //   54: invokevirtual 48	org/eclipse/birt/core/archive/FolderArchiveWriter:finish	()V
    //   57: return
    // Line number table:
    //   Java source line #49	-> byte code offset #0
    //   Java source line #50	-> byte code offset #9
    //   Java source line #52	-> byte code offset #14
    //   Java source line #54	-> byte code offset #18
    //   Java source line #56	-> byte code offset #23
    //   Java source line #59	-> byte code offset #32
    //   Java source line #60	-> byte code offset #36
    //   Java source line #63	-> byte code offset #44
    //
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

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