org.eclipse.osgi_3.7.2.v20120110-1415

+ " (probably access denied)");
      }
    }
  }
  
  public boolean getDoInput()
  {
    return true;
  }
  
  public boolean getDoOutput()
  {
    return false;
  }
  
  public InputStream getInputStream()
    throws IOException
  {
    if (!connected) {
      connect();
    }
    return new ReferenceInputStream(reference);
  }
  
  private String getInstallPath()
  {
    String installURL = FrameworkProperties.getProperty("osgi.install.area");
    if (installURL == null) {
      return null;
    }
    if (!installURL.startsWith("file:")) {
      return null;
    }
    return installURL.substring(5);
  }
  
  private static File makeAbsolute(String base, File relative)
  {
    if (relative.isAbsolute()) {
      return relative;
    }
    return new File(new FilePath(base + relative.getPath()).toString());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.protocol.reference.ReferenceURLConnection
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.internal.reliablefile;

import java.util.zip.Checksum;

class ReliableFile$CacheInfo
{
  int filetype;
  Checksum checksum;
  long timeStamp;
  final ReliableFile this$0;
  
  ReliableFile$CacheInfo(ReliableFile paramReliableFile, int filetype, Checksum checksum, long timeStamp)
  {
    this.filetype = filetype;
    this.checksum = checksum;
    this.timeStamp = timeStamp;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.reliablefile.ReliableFile.CacheInfo
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.internal.reliablefile;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;

public class ReliableFile
{
  public static final int OPEN_BEST_AVAILABLE = 0;
  public static final int OPEN_FAIL_ON_PRIMARY = 1;
  public static final int GENERATION_LATEST = 0;
  public static final int GENERATIONS_INFINITE = 0;
  public static final String tmpExt = ".tmp";
  public static final String PROP_MAX_BUFFER = "osgi.reliableFile.maxInputStreamBuffer";
  public static final String PROP_MAX_GENERATIONS = "osgi.ReliableFile.maxGenerations";
  public static final String PROP_OSGI_LOCKING = "osgi.locking";
  private static final int FILETYPE_VALID = 0;
  private static final int FILETYPE_CORRUPT = 1;
  private static final int FILETYPE_NOSIGNATURE = 2;
  private static final byte[] identifier1 = { 46, 99, 114, 99 };
  private static final byte[] identifier2 = { 46, 118, 49, 10 };
  private static final int BUF_SIZE = 4096;
  private static final int maxInputStreamBuffer;
  private static final int defaultMaxGenerations;
  private static final boolean fileSharing;
  private static File lastGenerationFile = null;
  private static int[] lastGenerations = null;
  private static final Object lastGenerationLock = new Object();
  private File referenceFile;
  
  static
  {
    String prop = FrameworkProperties.getProperty("osgi.reliableFile.maxInputStreamBuffer");
    int tmpMaxInput = 131072;
    if (prop != null) {
      try
      {
        tmpMaxInput = Integer.parseInt(prop);
      }
      catch (NumberFormatException localNumberFormatException1) {}
    }
    maxInputStreamBuffer = tmpMaxInput;
    
    int tmpDefaultMax = 2;
    prop = FrameworkProperties.getProperty("osgi.ReliableFile.maxGenerations");
    if (prop != null) {
      try
      {
        tmpDefaultMax = Integer.parseInt(prop);
      }
      catch (NumberFormatException localNumberFormatException2) {}
    }
    defaultMaxGenerations = tmpDefaultMax;
    
    prop = FrameworkProperties.getProperty("osgi.locking");
    boolean tmpFileSharing = true;
    if ((prop != null) && 
      (prop.equals("none"))) {
      tmpFileSharing = false;
    }
    fileSharing = tmpFileSharing;
  }
  
  private static Hashtable<File, CacheInfo> cacheFiles = new Hashtable(20);
  private File inputFile = null;
  private File outputFile = null;
  private Checksum appendChecksum = null;
  
  static ReliableFile getReliableFile(String name)
    throws IOException
  {
    return getReliableFile(new File(name));
  }
  
  static ReliableFile getReliableFile(File file)
    throws IOException
  {
    if (file.isDirectory()) {
      throw new FileNotFoundException("file is a directory");
    }
    return new ReliableFile(file);
  }
  
  private ReliableFile(File file)
  {
    referenceFile = file;
  }
  
  private static int[] getFileGenerations(File file)
  {
    if (!fileSharing) {
      synchronized (lastGenerationLock)
      {
        if (lastGenerationFile != null) {
          if (file.equals(lastGenerationFile)) {
            return lastGenerations;
          }
        }
      }
    }
    int[] generations = (int[])null;
    try
    {
      String name = file.getName();
      String prefix = name + '.';
      int prefixLen = prefix.length();
      File parent = new File(file.getParent());
      String[] files = parent.list();
      if (files == null) {
        return null;
      }
      String[] files;
      File parent;
      int prefixLen;
      String prefix;
      String name;
      List<Integer> list = new ArrayList(defaultMaxGenerations);
      if (file.exists()) {
        list.add(new Integer(0));
      }
      for (int i = 0; i < files.length; i++) {
        if (files[i].startsWith(prefix)) {
          try
          {
            int id = Integer.parseInt(files[i].substring(prefixLen));
            list.add(new Integer(id));
          }
          catch (NumberFormatException localNumberFormatException) {}
        }
      }
      if (list.size() == 0) {
        return null;
      }
      List<Integer> list;
      String[] files;
      File parent;
      int prefixLen;
      String prefix;
      String name;
      Object[] array = list.toArray();
      Arrays.sort(array);
      generations = new int[array.length];
      int i = 0;
      for (int j = array.length - 1; i < array.length; j--)
      {
        generations[i] = ((Integer)array[j]).intValue();i++;
      }
      return generations;
    }
    finally
    {
      if (!fileSharing) {
        synchronized (lastGenerationLock)
        {
          lastGenerationFile = file;
          lastGenerations = generations;
        }
      }
    }
  }
  
  InputStream getInputStream(int generation, int openMask)
    throws IOException
  {
    if (inputFile != null) {
      throw new IOException("Input stream already open");
    }
    int[] generations = getFileGenerations(referenceFile);
    if (generations == null) {
      throw new FileNotFoundException("File not found");
    }
    String name = referenceFile.getName();
    File parent = new File(referenceFile.getParent());
    
    boolean failOnPrimary = (openMask & 0x1) != 0;
    if ((failOnPrimary) && (generation == 0)) {
      generation = generations[0];
    }
    File textFile = null;
    InputStream textIS = null;
    for (int idx = 0; idx < generations.length; idx++) {
      if ((generation == 0) || (
        (generations[idx] <= generation) && ((!failOnPrimary) || (generations[idx] == generation))))
      {
        File file;
        File file;
        if (generations[idx] != 0) {
          file = new File(parent, name + '.' + generations[idx]);
        } else {
          file = referenceFile;
        }
        InputStream is = null;
        synchronized (cacheFiles)
        {
          CacheInfo info = (CacheInfo)cacheFiles.get(file);
          long timeStamp = file.lastModified();
          if ((info == null) || (timeStamp != timeStamp)) {
            try
            {
              is = new FileInputStream(file);
              if (is.available() < maxInputStreamBuffer) {
                is = new BufferedInputStream(is);
              }
              Checksum cksum = getChecksumCalculator();
              int filetype = getStreamType(is, cksum);
              info = new CacheInfo(filetype, cksum, timeStamp);
              cacheFiles.put(file, info);
            }
            catch (IOException localIOException) {}
          }
        }
        CacheInfo info;
        if (failOnPrimary)
        {
          if ((info != null) && (filetype == 0))
          {
            inputFile = file;
            if (is != null) {
              return is;
            }
            return new FileInputStream(file);
          }
          throw new IOException("ReliableFile is corrupt");
        }
        if (info != null) {
          switch (filetype)
          {
          case 0: 
            inputFile = file;
            if (is != null) {
              return is;
            }
            return new FileInputStream(file);
          case 2: 
            if (textFile == null)
            {
              textFile = file;
              textIS = is;
            }
            break;
          }
        }
      }
    }
    if (textFile != null)
    {
      inputFile = textFile;
      if (textIS != null) {
        return textIS;
      }
      return new FileInputStream(textFile);
    }
    throw new IOException("ReliableFile is corrupt");
  }
  
  OutputStream getOutputStream(boolean append, int appendGeneration)
    throws IOException
  {
    if (outputFile != null) {
      throw new IOException("Output stream is already open");
    }
    String name = referenceFile.getName();
    File parent = new File(referenceFile.getParent());
    File tmpFile = File.createTempFile(name, ".tmp", parent);
    if (!append)
    {
      OutputStream os = new FileOutputStream(tmpFile);
      outputFile = tmpFile;
      return os;
    }
    try
    {
      is = getInputStream(appendGeneration, 0);
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      InputStream is;
      OutputStream os = new FileOutputStream(tmpFile);
      outputFile = tmpFile;
      return os;
    }
    try
    {
      InputStream is;
      CacheInfo info = (CacheInfo)cacheFiles.get(inputFile);
      appendChecksum = checksum;
      OutputStream os = new FileOutputStream(tmpFile);
      if (filetype == 2) {
        cp(is, os, 0);
      } else {
        cp(is, os, 16);
      }
      outputFile = tmpFile;
      return os;
    }
    finally
    {
      closeInputFile();
    }
  }
  
  void closeOutputFile(Checksum checksum)
    throws IOException
  {
    if (outputFile == null) {
      throw new IOException("Output stream is not open");
    }
    int[] generations = getFileGenerations(referenceFile);
    String name = referenceFile.getName();
    File parent = new File(referenceFile.getParent());
    File newFile;
    File newFile;
    if (generations == null) {
      newFile = new File(parent, name + ".1");
    } else {
      newFile = new File(parent, name + '.' + (generations[0] + 1));
    }
    mv(outputFile, newFile);
    outputFile = null;
    appendChecksum = null;
    CacheInfo info = new CacheInfo(0, checksum, newFile.lastModified());
    cacheFiles.put(newFile, info);
    cleanup(generations, true);
    lastGenerationFile = null;
    lastGenerations = null;
  }
  
  void abortOutputFile()
  {
    if (outputFile == null) {
      return;
    }
    outputFile.delete();
    outputFile = null;
    appendChecksum = null;
  }
  
  File getOutputFile()
  {
    return outputFile;
  }
  
  void closeInputFile()
  {
    inputFile = null;
  }
  
  private void cleanup(int[] generations, boolean generationAdded)
  {
    if (generations == null) {
      return;
    }
    String name = referenceFile.getName();
    File parent = new File(referenceFile.getParent());
    int generationCount = generations.length;
    if (generations[(generationCount - 1)] == 0) {
      generationCount--;
    }
    int rmCount = generationCount - defaultMaxGenerations;
    if (generationAdded) {
      rmCount++;
    }
    if (rmCount < 1) {
      return;
    }
    synchronized (cacheFiles)
    {
      int idx = 0;
      for (int count = generationCount - rmCount; idx < count; idx++)
      {
        File file = new File(parent, name + '.' + generations[idx]);
        CacheInfo info = (CacheInfo)cacheFiles.get(file);
        if ((info != null) && 
          (filetype == 1)) {
          rmCount--;
        }
      }
      for (int idx = generationCount - 1; rmCount > 0; rmCount--)
      {
        File rmFile = new File(parent, name + '.' + generations[idx]);
        rmFile.delete();
        cacheFiles.remove(rmFile);idx--;
      }
    }
  }
  
  private static void mv(File from, File to)
    throws IOException
  {
    if (!from.renameTo(to)) {
      throw new IOException("rename failed");
    }
  }
  
  /* Error */
  private static void cp(InputStream in, OutputStream out, int truncateSize)
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: invokevirtual 434	java/io/InputStream:available	()I
    //   4: istore_3
    //   5: iload_2
    //   6: iload_3
    //   7: if_icmple +8 -> 15
    //   10: iconst_0
    //   11: istore_3
    //   12: goto +7 -> 19
    //   15: iload_3
    //   16: iload_2
    //   17: isub
    //   18: istore_3
    //   19: iload_3
    //   20: ifle +98 -> 118
    //   23: iload_3
    //   24: sipush 4096
    //   27: if_icmple +11 -> 38
    //   30: sipush 4096
    //   33: istore 4
    //   35: goto +6 -> 41
    //   38: iload_3
    //   39: istore 4
    //   41: iload 4
    //   43: newarray <illegal type>
    //   45: astore 5
    //   47: iconst_0
    //   48: istore 6
    //   50: goto +34 -> 84
    //   53: iload 6
    //   55: iload 7
    //   57: iadd
    //   58: iload_3
    //   59: if_icmplt +9 -> 68
    //   62: iload_3
    //   63: iload 6
    //   65: isub
    //   66: istore 7
    //   68: aload_1
    //   69: aload 5
    //   71: iconst_0
    //   72: iload 7
    //   74: invokevirtual 443	java/io/OutputStream:write	([BII)V
    //   77: iload 6
    //   79: iload 7
    //   81: iadd
    //   82: istore 6
    //   84: aload_0
    //   85: aload 5
    //   87: iconst_0
    //   88: iload_3
    //   89: invokevirtual 440	java/io/InputStream:read	([BII)I
    //   92: dup
    //   93: istore 7
    //   95: ifgt -42 -> 53
    //   98: goto +20 -> 118
    //   101: astore 8
    //   103: aload_0
    //   104: invokevirtual 435	java/io/InputStream:close	()V
    //   107: goto +4 -> 111
    //   110: pop
    //   111: aload_1
    //   112: invokevirtual 441	java/io/OutputStream:close	()V
    //   115: aload 8
    //   117: athrow
    //   118: aload_0
    //   119: invokevirtual 435	java/io/InputStream:close	()V
    //   122: goto +4 -> 126
    //   125: pop
    //   126: aload_1
    //   127: invokevirtual 441	java/io/OutputStream:close	()V
    //   130: return
    // Line number table:
    //   Java source line #480	-> byte code offset #0
    //   Java source line #481	-> byte code offset #5
    //   Java source line #482	-> byte code offset #10
    //   Java source line #484	-> byte code offset #15
    //   Java source line #485	-> byte code offset #19
    //   Java source line #487	-> byte code offset #23
    //   Java source line #488	-> byte code offset #30
    //   Java source line #490	-> byte code offset #38
    //   Java source line #493	-> byte code offset #41
    //   Java source line #494	-> byte code offset #47
    //   Java source line #496	-> byte code offset #50
    //   Java source line #497	-> byte code offset #53
    //   Java source line #498	-> byte code offset #62
    //   Java source line #499	-> byte code offset #68
    //   Java source line #500	-> byte code offset #77
    //   Java source line #496	-> byte code offset #84
    //   Java source line #503	-> byte code offset #101
    //   Java source line #505	-> byte code offset #103
    //   Java source line #506	-> byte code offset #110
    //   Java source line #508	-> byte code offset #111
    //   Java source line #509	-> byte code offset #115
    //   Java source line #505	-> byte code offset #118
    //   Java source line #506	-> byte code offset #125
    //   Java source line #508	-> byte code offset #126
    //   Java source line #510	-> byte code offset #130
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	131	0	in	InputStream
    //   0	131	1	out	OutputStream
    //   0	131	2	truncateSize	int
    //   4	85	3	length	int
    //   33	3	4	bufferSize	int
    //   39	3	4	bufferSize	int
    //   45	41	5	buffer	byte[]
    //   48	35	6	size	int
    //   53	27	7	count	int
    //   93	3	7	count	int
    //   101	15	8	localObject	Object
    //   110	1	11	localIOException1	IOException
    //   125	1	12	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   0	101	101	finally
    //   103	107	110	java/io/IOException
    //   118	122	125	java/io/IOException
  }
  
  public static boolean exists(File file)
  {
    String prefix = file.getName() + '.';
    File parent = new File(file.getParent());
    int prefixLen = prefix.length();
    String[] files = parent.list();
    if (files == null) {
      return false;
    }
    for (int i = 0; i < files.length; i++) {
      if (files[i].startsWith(prefix)) {
        try
        {
          Integer.parseInt(files[i].substring(prefixLen));
          return true;
        }
        catch (NumberFormatException localNumberFormatException) {}
      }
    }
    return file.exists();
  }
  
  public static long lastModified(File file)
  {
    int[] generations = getFileGenerations(file);
    if (generations == null) {
      return 0L;
    }
    if (generations[0] == 0) {
      return file.lastModified();
    }
    String name = file.getName();
    File parent = new File(file.getParent());
    File newFile = new File(parent, name + '.' + generations[0]);
    return newFile.lastModified();
  }
  
  public long lastModified()
  {
    if (inputFile != null) {
      return inputFile.lastModified();
    }
    return 0L;
  }
  
  public static int lastModifiedVersion(File file)
  {
    int[] generations = getFileGenerations(file);
    if (generations == null) {
      return -1;
    }
    return generations[0];
  }
  
  public static boolean delete(File deleteFile)
  {
    int[] generations = getFileGenerations(deleteFile);
    if (generations == null) {
      return false;
    }
    String name = deleteFile.getName();
    File parent = new File(deleteFile.getParent());
    synchronized (cacheFiles)
    {
      for (int idx = 0; idx < generations.length; idx++) {
        if (generations[idx] != 0)
        {
          File file = new File(parent, name + '.' + generations[idx]);
          if (file.exists()) {
            file.delete();
          }
          cacheFiles.remove(file);
        }
      }
    }
    return true;
  }
  
  public static String[] getBaseFiles(File directory)
    throws IOException
  {
    if (!directory.isDirectory()) {
      throw new IOException("Not a valid directory");
    }
    String[] files = directory.list();
    Set<String> list = new HashSet(files.length / 2);
    for (int idx = 0; idx < files.length; idx++)
    {
      String file = files[idx];
      int pos = file.lastIndexOf('.');
      if (pos != -1)
      {
        String ext = file.substring(pos + 1);
        int generation = 0;
        try
        {
          generation = Integer.parseInt(ext);
        }
        catch (NumberFormatException localNumberFormatException) {}
        if (generation != 0)
        {
          String base = file.substring(0, pos);
          list.add(base);
        }
      }
    }
    files = new String[list.size()];
    int idx = 0;
    for (Iterator<String> iter = list.iterator(); iter.hasNext();) {
      files[(idx++)] = ((String)iter.next());
    }
    return files;
  }
  
  public static void cleanupGenerations(File base)
  {
    ReliableFile rf = new ReliableFile(base);
    int[] generations = getFileGenerations(base);
    rf.cleanup(generations, false);
    lastGenerationFile = null;
    lastGenerations = null;
  }
  
  public static void fileUpdated(File file)
  {
    lastGenerationFile = null;
    lastGenerations = null;
  }
  
  void writeChecksumSignature(OutputStream out, Checksum checksum)
    throws IOException
  {
    out.write(identifier1);
    out.write(intToHex((int)checksum.getValue()));
    out.write(identifier2);
  }
  
  int getSignatureSize()
    throws IOException
  {
    if (inputFile != null)
    {
      CacheInfo info = (CacheInfo)cacheFiles.get(inputFile);
      if (info != null) {
        switch (filetype)
        {
        case 0: 
        case 1: 
          return 16;
        case 2: 
          return 0;
        }
      }
    }
    throw new IOException("ReliableFile signature size is unknown");
  }
  
  Checksum getFileChecksum()
    throws IOException
  {
    if (appendChecksum == null) {
      throw new IOException("Checksum is invalid!");
    }
    return appendChecksum;
  }
  
  Checksum getChecksumCalculator()
  {
    return new CRC32();
  }
  
  private int getStreamType(InputStream is, Checksum crc)
    throws IOException
  {
    boolean markSupported = is.markSupported();
    if (markSupported) {
      is.mark(is.available());
    }
    try
    {
      int len = is.available();
      if (len < 16)
      {
        if (crc != null)
        {
          byte[] data = new byte[16];
          int num = is.read(data);
          if (num > 0) {
            crc.update(data, 0, num);
          }
        }
        return 2;
      }
      int len;
      len -= 16;
      
      int pos = 0;
      byte[] data = new byte['?'];
      while (pos < len)
      {
        int read = data.length;
        if (pos + read > len) {
          read = len - pos;
        }
        int num = is.read(data, 0, read);
        if (num == -1) {
          throw new IOException("Unable to read entire file.");
        }
        crc.update(data, 0, num);
        pos += num;
      }
      int num = is.read(data);
      if (num != 16) {
        throw new IOException("Unable to read entire file.");
      }
      int num;
      byte[] data;
      int pos;
      int len;
      for (int i = 0; i < 4; i++) {
        if (identifier1[i] != data[i])
        {
          crc.update(data, 0, 16);
          return 2;
        }
      }
      int i = 0;
      int j;
      int i;
      byte[] data;
      for (int j = 12; i < 4; j++)
      {
        if (identifier2[i] != data[j])
        {
          crc.update(data, 0, 16);
          return 2;
        }
        int num;
        int pos;
        int len;
        i++;
      }
      long crccmp;
      try
      {
        crccmp = Long.valueOf(new String(data, 4, 8, "UTF-8"), 16).longValue();
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException)
      {
        long crccmp;
        crccmp = Long.valueOf(new String(data, 4, 8), 16).longValue();
      }
      if (crccmp == crc.getValue()) {
        return 0;
      }
      long crccmp;
      int j;
      int i;
      int num;
      byte[] data;
      int pos;
      int len;
      return 1;
    }
    finally
    {
      if (markSupported) {
        is.reset();
      }
    }
  }
  
  private static byte[] intToHex(int l)
  {
    byte[] buffer = new byte[8];
    int count = 8;
    do
    {
      int ch = l & 0xF;
      if (ch > 9) {
        ch = ch - 10 + 97;
      } else {
        ch += 48;
      }
      buffer[(--count)] = ((byte)ch);
      l >>= 4;
    } while (count > 0);
    return buffer;
  }
  
  private class CacheInfo
  {
    int filetype;
    Checksum checksum;
    long timeStamp;
    
    CacheInfo(int filetype, Checksum checksum, long timeStamp)
    {
      this.filetype = filetype;
      this.checksum = checksum;
      this.timeStamp = timeStamp;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.reliablefile.ReliableFile
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.internal.reliablefile;

import java.io.File;
import java.io.FilterInputStream;
import java.io.IOException;

public class ReliableFileInputStream
  extends FilterInputStream
{
  private ReliableFile reliable;
  private int sigSize;
  private int readPos;
  private int length;
  
  public ReliableFileInputStream(String name)
    throws IOException
  {
    this(ReliableFile.getReliableFile(name), 0, 0);
  }
  
  public ReliableFileInputStream(File file)
    throws IOException
  {
    this(ReliableFile.getReliableFile(file), 0, 0);
  }
  
  public ReliableFileInputStream(File file, int generation, int openMask)
    throws IOException
  {
    this(ReliableFile.getReliableFile(file), generation, openMask);
  }
  
  private ReliableFileInputStream(ReliableFile reliable, int generation, int openMask)
    throws IOException
  {
    super(reliable.getInputStream(generation, openMask));
    
    this.reliable = reliable;
    sigSize = reliable.getSignatureSize();
    readPos = 0;
    length = super.available();
    if (sigSize > length) {
      length = 0;
    } else {
      length -= sigSize;
    }
  }
  
  /* Error */
  public synchronized void close()
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 80	org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream:reliable	Lorg/eclipse/osgi/framework/internal/reliablefile/ReliableFile;
    //   4: ifnull +37 -> 41
    //   7: aload_0
    //   8: invokespecial 83	java/io/FilterInputStream:close	()V
    //   11: goto +18 -> 29
    //   14: astore_1
    //   15: aload_0
    //   16: getfield 80	org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream:reliable	Lorg/eclipse/osgi/framework/internal/reliablefile/ReliableFile;
    //   19: invokevirtual 89	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:closeInputFile	()V
    //   22: aload_0
    //   23: aconst_null
    //   24: putfield 80	org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream:reliable	Lorg/eclipse/osgi/framework/internal/reliablefile/ReliableFile;
    //   27: aload_1
    //   28: athrow
    //   29: aload_0
    //   30: getfield 80	org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream:reliable	Lorg/eclipse/osgi/framework/internal/reliablefile/ReliableFile;
    //   33: invokevirtual 89	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:closeInputFile	()V
    //   36: aload_0
    //   37: aconst_null
    //   38: putfield 80	org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream:reliable	Lorg/eclipse/osgi/framework/internal/reliablefile/ReliableFile;
    //   41: return
    // Line number table:
    //   Java source line #111	-> byte code offset #0
    //   Java source line #113	-> byte code offset #7
    //   Java source line #114	-> byte code offset #14
    //   Java source line #115	-> byte code offset #15
    //   Java source line #116	-> byte code offset #22
    //   Java source line #117	-> byte code offset #27
    //   Java source line #115	-> byte code offset #29
    //   Java source line #116	-> byte code offset #36
    //   Java source line #119	-> byte code offset #41
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	42	0	this	ReliableFileInputStream
    //   14	14	1	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   7	14	14	finally
  }
  
  public synchronized int read(byte[] b, int off, int len)
    throws IOException
  {
    if (readPos >= length) {
      return -1;
    }
    int num = super.read(b, off, len);
    if (num != -1)
    {
      if (num + readPos > length) {
        num = length - readPos;
      }
      readPos += num;
    }
    return num;
  }
  
  public synchronized int read(byte[] b)
    throws IOException
  {
    return read(b, 0, b.length);
  }
  
  public synchronized int read()
    throws IOException
  {
    if (readPos >= length) {
      return -1;
    }
    int num = super.read();
    if (num != -1) {
      readPos += 1;
    }
    return num;
  }
  
  public synchronized int available()
    throws IOException
  {
    if (readPos < length) {
      return length - readPos;
    }
    return 0;
  }
  
  public synchronized long skip(long n)
    throws IOException
  {
    long len = super.skip(n);
    if (readPos + len > length) {
      len = length - readPos;
    }
    readPos = ((int)(readPos + len));
    return len;
  }
  
  public boolean markSupported()
  {
    return false;
  }
  
  public void mark(int readlimit) {}
  
  public void reset()
    throws IOException
  {
    throw new IOException("reset not supported.");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.reliablefile.ReliableFileInputStream
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.internal.reliablefile;

import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.Checksum;

public class ReliableFileOutputStream
  extends FilterOutputStream
{
  private ReliableFile reliable;
  private Checksum crc;
  private boolean outputOpen = false;
  
  public ReliableFileOutputStream(File file)
    throws IOException
  {
    this(ReliableFile.getReliableFile(file), false);
  }
  
  public ReliableFileOutputStream(File file, boolean append)
    throws IOException
  {
    this(ReliableFile.getReliableFile(file), append);
  }
  
  public ReliableFileOutputStream(String name)
    throws IOException
  {
    this(ReliableFile.getReliableFile(name), false);
  }
  
  public ReliableFileOutputStream(String name, boolean append)
    throws IOException
  {
    this(ReliableFile.getReliableFile(name), append);
  }
  
  private ReliableFileOutputStream(ReliableFile reliable, boolean append)
    throws IOException
  {
    super(reliable.getOutputStream(append, 0));
    
    this.reliable = reliable;
    outputOpen = true;
    if (append) {
      crc = reliable.getFileChecksum();
    } else {
      crc = reliable.getChecksumCalculator();
    }
  }
  
  public synchronized void close()
    throws IOException
  {
    closeIntermediateFile();
    reliable.closeOutputFile(crc);
    
    reliable = null;
  }
  
  public File closeIntermediateFile()
    throws IOException
  {
    if (reliable == null) {
      throw new IOException("ReliableFile stream not open");
    }
    if (outputOpen)
    {
      reliable.writeChecksumSignature(out, crc);
      out.flush();
      try
      {
        ((FileOutputStream)out).getFD().sync();
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
      out.close();
      outputOpen = false;
    }
    return reliable.getOutputFile();
  }
  
  public void write(byte[] b)
    throws IOException
  {
    write(b, 0, b.length);
  }
  
  public void write(byte[] b, int off, int len)
    throws IOException
  {
    out.write(b, off, len);
    crc.update(b, off, len);
  }
  
  public void write(int b)
    throws IOException
  {
    out.write(b);
    crc.update((byte)b);
  }
  
  public void abort()
  {
    if (reliable == null) {
      return;
    }
    if (outputOpen)
    {
      try
      {
        out.close();
      }
      catch (IOException localIOException) {}
      outputOpen = false;
    }
    reliable.abortOutputFile();
    reliable = null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.internal.reliablefile.ReliableFileOutputStream
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.log;

import java.io.File;
import java.io.IOException;
import java.io.Writer;
import org.osgi.framework.FrameworkEvent;

public abstract interface FrameworkLog
{
  public static final String SERVICE_PERFORMANCE = "performance";
  
  public abstract void log(FrameworkEvent paramFrameworkEvent);
  
  public abstract void log(FrameworkLogEntry paramFrameworkLogEntry);
  
  public abstract void setWriter(Writer paramWriter, boolean paramBoolean);
  
  public abstract void setFile(File paramFile, boolean paramBoolean)
    throws IOException;
  
  public abstract File getFile();
  
  public abstract void setConsoleLog(boolean paramBoolean);
  
  public abstract void close();
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.log.FrameworkLog
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.log;

public class FrameworkLogEntry
{
  public static final int OK = 0;
  public static final int INFO = 1;
  public static final int WARNING = 2;
  public static final int ERROR = 4;
  public static final int CANCEL = 8;
  private final String entry;
  private final String message;
  private final int stackCode;
  private final Throwable throwable;
  private final FrameworkLogEntry[] children;
  private final int severity;
  private final int bundleCode;
  private final Object context;
  
  public FrameworkLogEntry(String entry, String message, int stackCode, Throwable throwable, FrameworkLogEntry[] children)
  {
    this(null, entry, 0, 0, message, stackCode, throwable, children);
  }
  
  public FrameworkLogEntry(String entry, int severity, int bundleCode, String message, int stackCode, Throwable throwable, FrameworkLogEntry[] children)
  {
    this(null, entry, severity, bundleCode, message, stackCode, throwable, children);
  }
  
  public FrameworkLogEntry(Object context, String entry, int severity, int bundleCode, String message, int stackCode, Throwable throwable, FrameworkLogEntry[] children)
  {
    this.context = context;
    this.entry = entry;
    this.message = message;
    this.stackCode = stackCode;
    this.throwable = throwable;
    this.children = children;
    this.severity = severity;
    this.bundleCode = bundleCode;
  }
  
  public FrameworkLogEntry[] getChildren()
  {
    return children;
  }
  
  public String getEntry()
  {
    return entry;
  }
  
  public String getMessage()
  {
    return message;
  }
  
  public int getStackCode()
  {
    return stackCode;
  }
  
  public Throwable getThrowable()
  {
    return throwable;
  }
  
  public int getSeverity()
  {
    return severity;
  }
  
  public int getBundleCode()
  {
    return bundleCode;
  }
  
  public Object getContext()
  {
    return context;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.log.FrameworkLogEntry
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.util;

import java.util.Enumeration;

class Headers$ArrayEnumeration<E>
  implements Enumeration<E>
{
  private E[] array;
  int cur = 0;
  
  public Headers$ArrayEnumeration(E[] array, int size)
  {
    Object[] a = new Object[size];
    this.array = a;
    System.arraycopy(array, 0, this.array, 0, this.array.length);
  }
  
  public boolean hasMoreElements()
  {
    return cur < array.length;
  }
  
  public E nextElement()
  {
    return (E)array[(cur++)];
  }
}

/* Location:
 * Qualified Name:     org.eclipse.osgi.framework.util.Headers.ArrayEnumeration
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.osgi.framework.internal.core.Msg;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleException;

public class Headers<K, V>
  extends Dictionary<K, V>
  implements Map<K, V>
{
  private boolean readOnly = false;
  private K[] headers;
  private V[] values;
  private int size = 0;
  
  public Headers(int initialCapacity)
  {
    Object[] k = new Object[initialCapacity];
    headers = k;
    
    Object[] v = new Object[initialCapacity];
    values = v;
  }
  
  public Headers(Dictionary<? extends K, ? extends V> values)
  {
    this(values.size());
    
    Enumeration<? extends K> keys = values.keys();
    while (keys.hasMoreElements())
    {
      K key = keys.nextElement();
      set(key, values.get(key));
    }
  }
  
  public synchronized Enumeration<K> keys()
  {
    return new ArrayEnumeration(headers, size);
  }
  
  public synchronized Enumeration<V> elements()
  {
    return new ArrayEnumeration(values, size);
  }
  
  private int getIndex(Object key)
  {
    boolean stringKey = key instanceof String;
    for (int i = 0; i < size; i++) {
      if ((stringKey) && ((headers[i] instanceof String)))
      {
        if (((String)headers[i]).equalsIgnoreCase((String)key)) {
          return i;
        }
      }
      else if (headers[i].equals(key)) {
        return i;
      }
    }
    return -1;
  }
  
  private V remove(int remove)
  {
    V removed = values[remove];
    for (int i = remove; i < size; i++) {
      if (i == headers.length - 1)
      {
        headers[i] = null;
        values[i] = null;
      }
      else
      {
        headers[i] = headers[(i + 1)];
        values[i] = values[(i + 1)];
      }
    }
    if (remove < size) {
      size -= 1;
    }
    return removed;
  }
  
  private void add(K header, V value)
  {
    if (size == headers.length)
    {
      Object[] nh = new Object[headers.length + 10];
      Object[] newHeaders = nh;
      
      Object[] nv = new Object[values.length + 10];
      Object[] newValues = nv;
      System.arraycopy(headers, 0, newHeaders, 0, headers.length);
      System.arraycopy(values, 0, newValues, 0, values.length);
      headers = newHeaders;
      values = newValues;
    }
    headers[size] = header;
    values[size] = value;
    size += 1;
  }
  
  public synchronized V get(Object key)
  {
    int i = -1;
    if ((i = getIndex(key)) != -1) {
      return (V)values[i];
    }
    return null;
  }
  
  public synchronized V set(K key, V value, boolean replace)
  {
    if (readOnly) {
      throw new UnsupportedOperationException();
    }
    if ((key instanceof String))
    {
      K k = ((String)key).intern();
      key = k;
    }
    int i = getIndex(key);
    if (value == null)
    {
      if (i != -1) {
        return (V)remove(i);
      }
    }
    else
    {
      if (i != -1)
      {
        if (!replace) {
          throw new IllegalArgumentException(NLS.bind(Msg.HEADER_DUPLICATE_KEY_EXCEPTION, key));
        }
        V oldVal = values[i];
        values[i] = value;
        return oldVal;
      }
      add(key, value);
    }
    return null;
  }
  
  public synchronized V set(K key, V value)
  {
    return (V)set(key, value, false);
  }
  
  public synchronized void setReadOnly()
  {
    readOnly = true;
  }
  
  public synchronized int size()
  {
    return size;
  }
  
  public synchronized boolean isEmpty()
  {
    return size == 0;
  }
  
  public synchronized V put(K key, V value)
  {
    if (readOnly) {
      throw new UnsupportedOperationException();
    }
    return (V)set(key, value, true);
  }
  
  public V remove(Object key)
  {
    throw new UnsupportedOperationException();
  }
  
  public String toString()
  {
    return values.toString();
  }
  
  public static Headers<String, String> parseManifest(InputStream in)
    throws BundleException
  {
    Headers<String, String> headers = new Headers(10);
    try
    {
      ManifestElement.parseBundleManifest(in, headers);
    }
    catch (IOException e)
    {
      throw new BundleException(Msg.MANIFEST_IOEXCEPTION, 3, e);
    }
    headers.setReadOnly();
    return headers;
  }
  
  private static class ArrayEnumeration<E>
    implements Enumeration<E>
  {
    private E[] array;
    i
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-2017. Infinite Loop Ltd