org.eclipse.osgi_3.8.2.v20130124-134944

  Java source line #465	-> byte code offset #0
    //   Java source line #466	-> byte code offset #7
    //   Java source line #467	-> byte code offset #18
    //   Java source line #468	-> byte code offset #25
    //   Java source line #471	-> byte code offset #36
    //   Java source line #472	-> byte code offset #44
    //   Java source line #474	-> byte code offset #55
    //   Java source line #475	-> byte code offset #59
    //   Java source line #476	-> byte code offset #68
    //   Java source line #477	-> byte code offset #72
    //   Java source line #478	-> byte code offset #76
    //   Java source line #479	-> byte code offset #80
    //   Java source line #478	-> byte code offset #82
    //   Java source line #480	-> byte code offset #86
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	87	0	this	StorageManager
    //   0	87	1	managedFile	String
    //   75	6	2	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   55	75	75	finally
  }
  
  /* Error */
  private void updateTable()
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 511	org/eclipse/osgi/storagemanager/StorageManager:tableFile	Ljava/io/File;
    //   4: invokestatic 572	org/eclipse/osgi/framework/internal/reliablefile/ReliableFile:lastModifiedVersion	(Ljava/io/File;)I
    //   7: istore_1
    //   8: iload_1
    //   9: aload_0
    //   10: getfield 500	org/eclipse/osgi/storagemanager/StorageManager:tableStamp	I
    //   13: if_icmpeq +8 -> 21
    //   16: iload_1
    //   17: iconst_m1
    //   18: if_icmpne +4 -> 22
    //   21: return
    //   22: new 281	java/util/Properties
    //   25: dup
    //   26: invokespecial 561	java/util/Properties:<init>	()V
    //   29: astore_2
    //   30: new 287	org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream
    //   33: dup
    //   34: aload_0
    //   35: getfield 511	org/eclipse/osgi/storagemanager/StorageManager:tableFile	Ljava/io/File;
    //   38: invokespecial 575	org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream:<init>	(Ljava/io/File;)V
    //   41: astore_3
    //   42: aload_2
    //   43: aload_3
    //   44: invokevirtual 562	java/util/Properties:load	(Ljava/io/InputStream;)V
    //   47: goto +16 -> 63
    //   50: astore 4
    //   52: aload_3
    //   53: invokevirtual 534	java/io/InputStream:close	()V
    //   56: goto +4 -> 60
    //   59: pop
    //   60: aload 4
    //   62: athrow
    //   63: aload_3
    //   64: invokevirtual 534	java/io/InputStream:close	()V
    //   67: goto +4 -> 71
    //   70: pop
    //   71: aload_0
    //   72: iload_1
    //   73: putfield 500	org/eclipse/osgi/storagemanager/StorageManager:tableStamp	I
    //   76: aload_2
    //   77: invokevirtual 563	java/util/Properties:keys	()Ljava/util/Enumeration;
    //   80: astore 4
    //   82: goto +140 -> 222
    //   85: aload 4
    //   87: invokeinterface 622 1 0
    //   92: checkcast 271	java/lang/String
    //   95: astore 5
    //   97: aload_2
    //   98: aload 5
    //   100: invokevirtual 569	java/util/Properties:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   103: astore 6
    //   105: aload 6
    //   107: ifnull +115 -> 222
    //   110: aload_0
    //   111: getfield 513	org/eclipse/osgi/storagemanager/StorageManager:table	Ljava/util/Properties;
    //   114: aload 5
    //   116: invokevirtual 566	java/util/Properties:get	(Ljava/lang/Object;)Ljava/lang/Object;
    //   119: checkcast 292	org/eclipse/osgi/storagemanager/StorageManager$Entry
    //   122: astore 7
    //   124: aload 6
    //   126: bipush 44
    //   128: invokevirtual 544	java/lang/String:indexOf	(I)I
    //   131: istore 10
    //   133: iload 10
    //   135: iconst_m1
    //   136: if_icmpeq +33 -> 169
    //   139: aload 6
    //   141: iconst_0
    //   142: iload 10
    //   144: invokevirtual 547	java/lang/String:substring	(II)Ljava/lang/String;
    //   147: invokestatic 541	java/lang/Integer:parseInt	(Ljava/lang/String;)I
    //   150: istore 8
    //   152: aload 6
    //   154: iload 10
    //   156: iconst_1
    //   157: iadd
    //   158: invokevirtual 546	java/lang/String:substring	(I)Ljava/lang/String;
    //   161: invokestatic 541	java/lang/Integer:parseInt	(Ljava/lang/String;)I
    //   164: istore 9
    //   166: goto +13 -> 179
    //   169: aload 6
    //   171: invokestatic 541	java/lang/Integer:parseInt	(Ljava/lang/String;)I
    //   174: istore 8
    //   176: iconst_0
    //   177: istore 9
    //   179: aload 7
    //   181: ifnonnull +32 -> 213
    //   184: aload_0
    //   185: getfield 513	org/eclipse/osgi/storagemanager/StorageManager:table	Ljava/util/Properties;
    //   188: aload 5
    //   190: new 292	org/eclipse/osgi/storagemanager/StorageManager$Entry
    //   193: dup
    //   194: aload_0
    //   195: iload 8
    //   197: iload 8
    //   199: iconst_1
    //   200: iadd
    //   201: iload 9
    //   203: invokespecial 619	org/eclipse/osgi/storagemanager/StorageManager$Entry:<init>	(Lorg/eclipse/osgi/storagemanager/StorageManager;III)V
    //   206: invokevirtual 570	java/util/Properties:put	(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    //   209: pop
    //   210: goto +12 -> 222
    //   213: aload 7
    //   215: iload 8
    //   217: iconst_1
    //   218: iadd
    //   219: invokevirtual 618	org/eclipse/osgi/storagemanager/StorageManager$Entry:setWriteId	(I)V
    //   222: aload 4
    //   224: invokeinterface 621 1 0
    //   229: ifne -144 -> 85
    //   232: return
    // Line number table:
    //   Java source line #484	-> byte code offset #0
    //   Java source line #485	-> byte code offset #8
    //   Java source line #486	-> byte code offset #21
    //   Java source line #487	-> byte code offset #22
    //   Java source line #488	-> byte code offset #30
    //   Java source line #490	-> byte code offset #42
    //   Java source line #491	-> byte code offset #47
    //   Java source line #493	-> byte code offset #52
    //   Java source line #494	-> byte code offset #56
    //   Java source line #497	-> byte code offset #60
    //   Java source line #493	-> byte code offset #63
    //   Java source line #494	-> byte code offset #67
    //   Java source line #498	-> byte code offset #71
    //   Java source line #499	-> byte code offset #76
    //   Java source line #500	-> byte code offset #85
    //   Java source line #501	-> byte code offset #97
    //   Java source line #502	-> byte code offset #105
    //   Java source line #503	-> byte code offset #110
    //   Java source line #507	-> byte code offset #124
    //   Java source line #508	-> byte code offset #133
    //   Java source line #509	-> byte code offset #139
    //   Java source line #510	-> byte code offset #152
    //   Java source line #511	-> byte code offset #166
    //   Java source line #512	-> byte code offset #169
    //   Java source line #513	-> byte code offset #176
    //   Java source line #515	-> byte code offset #179
    //   Java source line #516	-> byte code offset #184
    //   Java source line #517	-> byte code offset #210
    //   Java source line #518	-> byte code offset #213
    //   Java source line #499	-> byte code offset #222
    //   Java source line #523	-> byte code offset #232
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	233	0	this	StorageManager
    //   7	66	1	stamp	int
    //   29	69	2	diskTable	Properties
    //   41	23	3	input	InputStream
    //   50	11	4	localObject1	Object
    //   80	143	4	e	Object
    //   95	94	5	file	String
    //   103	67	6	value	String
    //   122	92	7	entry	Entry
    //   150	3	8	id	int
    //   174	42	8	id	int
    //   164	3	9	fileType	int
    //   177	25	9	fileType	int
    //   131	24	10	idx	int
    //   59	1	14	localIOException1	IOException
    //   70	1	15	localIOException2	IOException
    // Exception table:
    //   from	to	target	type
    //   42	50	50	finally
    //   52	56	59	java/io/IOException
    //   63	67	70	java/io/IOException
  }
  
  private void save()
    throws IOException
  {
    if (readOnly) {
      return;
    }
    updateTable();
    
    Properties props = new Properties();
    for (Enumeration<Object> e = table.keys(); e.hasMoreElements();)
    {
      String file = (String)e.nextElement();
      entry = (Entry)table.get(file);
      String value;
      String value;
      if (entry.getFileType() != 0) {
        value = 
          Integer.toString(entry.getWriteId() - 1) + ',' + Integer.toString(entry.getFileType());
      } else {
        value = Integer.toString(entry.getWriteId() - 1);
      }
      props.put(file, value);
    }
    ReliableFileOutputStream fileStream = new ReliableFileOutputStream(tableFile);
    boolean error = true;
    try
    {
      props.store(fileStream, "safe table");
      fileStream.close();
      error = false;
    }
    finally
    {
      if (error) {
        fileStream.abort();
      }
    }
    if (saveCleanup) {
      try
      {
        cleanup(false);
      }
      catch (IOException ex)
      {
        System.out.println("Unexpected IOException is thrown inside cleanupWithLock. Please look below for stacktrace");
        ex.printStackTrace(System.out);
      }
    }
    tableStamp = ReliableFile.lastModifiedVersion(tableFile);
  }
  
  private boolean update(String managedFile, String source)
    throws IOException
  {
    Entry entry = (Entry)table.get(managedFile);
    if (entry == null) {
      add(managedFile);
    }
    int newId = entry.getWriteId();
    
    boolean success = move(getAbsolutePath(source), getAbsolutePath(managedFile) + '.' + newId);
    if (!success)
    {
      newId = findOldestGeneration(managedFile) + 1;
      success = move(getAbsolutePath(source), getAbsolutePath(managedFile) + '.' + newId);
    }
    if (!success) {
      return false;
    }
    entry.setReadId(newId);
    entry.setWriteId(newId + 1);
    return true;
  }
  
  private void cleanup(boolean doLock)
    throws IOException
  {
    if (readOnly) {
      return;
    }
    if ((doLock) && (!lock(true))) {
      throw new IOException(EclipseAdaptorMsg.fileManager_cannotLock);
    }
    try
    {
      String[] files = managerRoot.list();
      String[] files;
      if (files != null)
      {
        int i;
        for (int i = 0; i < files.length; i++) {
          if ((files[i].endsWith(".instance")) && ((instanceFile == null) || (!files[i].equalsIgnoreCase(instanceFile.getName()))))
          {
            Locker tmpLocker = BasicLocation.createLocker(new File(managerRoot, files[i]), lockMode);
            if (tmpLocker.lock())
            {
              tmpLocker.release();
              new File(managerRoot, files[i]).delete();
            }
            else
            {
              tmpLocker.release();
              return;
            }
          }
        }
      }
      updateTable();
      Collection<Map.Entry<Object, Object>> managedFiles = table.entrySet();
      for (Iterator<Map.Entry<Object, Object>> iter = managedFiles.iterator(); iter.hasNext();)
      {
        Map.Entry<Object, Object> fileEntry = (Map.Entry)iter.next();
        String fileName = (String)fileEntry.getKey();
        Entry info = (Entry)fileEntry.getValue();
        if (info.getFileType() == 1)
        {
          ReliableFile.cleanupGenerations(new File(base, fileName));
        }
        else
        {
          String readId = Integer.toString(info.getWriteId() - 1);
          deleteCopies(fileName, readId);
        }
      }
      if (tempCleanup)
      {
        files = base.list();
        if (files != null) {
          for (int i = 0; i < files.length; i++) {
            if (files[i].endsWith(".tmp")) {
              new File(base, files[i]).delete();
            }
          }
        }
      }
    }
    finally
    {
      if (doLock) {
        release();
      }
    }
    if (doLock) {
      release();
    }
  }
  
  private void deleteCopies(String fileName, String exceptionNumber)
  {
    String notToDelete = fileName + '.' + exceptionNumber;
    String[] files = base.list();
    if (files == null) {
      return;
    }
    for (int i = 0; i < files.length; i++) {
      if ((files[i].startsWith(fileName + '.')) && (!files[i].equals(notToDelete))) {
        new File(base, files[i]).delete();
      }
    }
  }
  
  public void close()
  {
    if (!open) {
      return;
    }
    open = false;
    if (readOnly) {
      return;
    }
    try
    {
      cleanup(true);
    }
    catch (IOException localIOException) {}
    if (instanceLocker != null) {
      instanceLocker.release();
    }
    if (instanceFile != null) {
      instanceFile.delete();
    }
  }
  
  public void open(boolean wait)
    throws IOException
  {
    if (!readOnly)
    {
      managerRoot.mkdirs();
      if (!managerRoot.exists()) {
        throw new IOException(EclipseAdaptorMsg.fileManager_cannotLock);
      }
      if (openCleanup) {
        cleanup(true);
      }
      locked = lock(wait);
      if ((!locked) && (wait)) {
        throw new IOException(EclipseAdaptorMsg.fileManager_cannotLock);
      }
    }
    try
    {
      initializeInstanceFile();
      updateTable();
      open = true;
    }
    finally
    {
      release();
    }
  }
  
  public File createTempFile(String file)
    throws IOException
  {
    if (readOnly) {
      throw new IOException(EclipseAdaptorMsg.fileManager_illegalInReadOnlyMode);
    }
    File tmpFile = File.createTempFile(file, ".tmp", base);
    
    return tmpFile;
  }
  
  public InputStream getInputStream(String managedFile)
    throws IOException
  {
    return getInputStream(managedFile, 0);
  }
  
  public InputStream[] getInputStreamSet(String[] managedFiles)
    throws IOException
  {
    InputStream[] streams = new InputStream[managedFiles.length];
    for (int i = 0; i < streams.length; i++) {
      streams[i] = getInputStream(managedFiles[i], 1);
    }
    return streams;
  }
  
  private InputStream getInputStream(String managedFiles, int openMask)
    throws IOException
  {
    if (useReliableFiles)
    {
      int id = getId(managedFiles);
      if (id == -1) {
        return null;
      }
      return new ReliableFileInputStream(new File(getBase(), managedFiles), id, openMask);
    }
    File lookup = lookup(managedFiles, false);
    if (lookup == null) {
      return null;
    }
    return new FileInputStream(lookup);
  }
  
  public ManagedOutputStream getOutputStream(String managedFile)
    throws IOException
  {
    if (useReliableFiles)
    {
      ReliableFileOutputStream out = new ReliableFileOutputStream(new File(getBase(), managedFile));
      return new ManagedOutputStream(out, this, managedFile, null);
    }
    File tmpFile = createTempFile(managedFile);
    return new ManagedOutputStream(new FileOutputStream(tmpFile), this, managedFile, tmpFile);
  }
  
  public ManagedOutputStream[] getOutputStreamSet(String[] managedFiles)
    throws IOException
  {
    int count = managedFiles.length;
    ManagedOutputStream[] streams = new ManagedOutputStream[count];
    int idx = 0;
    try
    {
      for (; idx < count; idx++)
      {
        ManagedOutputStream newStream = getOutputStream(managedFiles[idx]);
        newStream.setStreamSet(streams);
        streams[idx] = newStream;
      }
    }
    catch (IOException e)
    {
      for (int jdx = 0; jdx < idx; jdx++) {
        streams[jdx].abort();
      }
      throw e;
    }
    return streams;
  }
  
  void abortOutputStream(ManagedOutputStream out)
  {
    ManagedOutputStream[] set = out.getStreamSet();
    if (set == null) {
      set = new ManagedOutputStream[] { out };
    }
    synchronized (set)
    {
      for (int idx = 0; idx < set.length; idx++)
      {
        out = set[idx];
        if (out.getOutputFile() == null)
        {
          ReliableFileOutputStream rfos = (ReliableFileOutputStream)out.getOutputStream();
          rfos.abort();
        }
        else
        {
          if (out.getState() == 0) {
            try
            {
              out.getOutputStream().close();
            }
            catch (IOException localIOException) {}
          }
          out.getOutputFile().delete();
        }
        out.setState(1);
      }
    }
  }
  
  void closeOutputStream(ManagedOutputStream smos)
    throws IOException
  {
    if (smos.getState() != 0) {
      return;
    }
    ManagedOutputStream[] streamSet = smos.getStreamSet();
    if (smos.getOutputFile() == null)
    {
      ReliableFileOutputStream rfos = (ReliableFileOutputStream)smos.getOutputStream();
      
      File file = rfos.closeIntermediateFile();
      smos.setState(1);
      String target = smos.getTarget();
      if (streamSet == null)
      {
        add(target, 1);
        update(new String[] { smos.getTarget() }, new String[] { file.getName() });
        ReliableFile.fileUpdated(new File(getBase(), smos.getTarget()));
      }
    }
    else
    {
      OutputStream out = smos.getOutputStream();
      out.flush();
      try
      {
        ((FileOutputStream)out).getFD().sync();
      }
      catch (SyncFailedException localSyncFailedException) {}
      out.close();
      smos.setState(1);
      String target = smos.getTarget();
      if (streamSet == null)
      {
        add(target, 0);
        update(new String[] { target }, new String[] { smos.getOutputFile().getName() });
      }
    }
    if (streamSet != null) {
      synchronized (streamSet)
      {
        for (int idx = 0; idx < streamSet.length; idx++) {
          if (streamSet[idx].getState() == 0) {
            return;
          }
        }
        String[] targets = new String[streamSet.length];
        String[] sources = new String[streamSet.length];
        for (int idx = 0; idx < streamSet.length; idx++)
        {
          smos = streamSet[idx];
          targets[idx] = smos.getTarget();
          File outputFile = smos.getOutputFile();
          if (outputFile == null)
          {
            add(smos.getTarget(), 1);
            ReliableFileOutputStream rfos = (ReliableFileOutputStream)smos.getOutputStream();
            File file = rfos.closeIntermediateFile();
            sources[idx] = file.getName();
            ReliableFile.fileUpdated(new File(getBase(), smos.getTarget()));
          }
          else
          {
            add(smos.getTarget(), 0);
            sources[idx] = outputFile.getName();
          }
        }
        update(targets, sources);
      }
    }
  }
}

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

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
import java.util.StringTokenizer;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.internal.core.Msg;
import org.eclipse.osgi.framework.internal.core.Tokenizer;
import org.osgi.framework.BundleException;

public class ManifestElement
{
  private final String mainValue;
  private final String[] valueComponents;
  private Hashtable<String, Object> attributes;
  private Hashtable<String, Object> directives;
  
  private ManifestElement(String value, String[] valueComponents)
  {
    mainValue = value;
    this.valueComponents = valueComponents;
  }
  
  public String getValue()
  {
    return mainValue;
  }
  
  public String[] getValueComponents()
  {
    return valueComponents;
  }
  
  public String getAttribute(String key)
  {
    return getTableValue(attributes, key);
  }
  
  public String[] getAttributes(String key)
  {
    return getTableValues(attributes, key);
  }
  
  public Enumeration<String> getKeys()
  {
    return getTableKeys(attributes);
  }
  
  private void addAttribute(String key, String value)
  {
    attributes = addTableValue(attributes, key, value);
  }
  
  public String getDirective(String key)
  {
    return getTableValue(directives, key);
  }
  
  public String[] getDirectives(String key)
  {
    return getTableValues(directives, key);
  }
  
  public Enumeration<String> getDirectiveKeys()
  {
    return getTableKeys(directives);
  }
  
  private void addDirective(String key, String value)
  {
    directives = addTableValue(directives, key, value);
  }
  
  private String getTableValue(Hashtable<String, Object> table, String key)
  {
    if (table == null) {
      return null;
    }
    Object result = table.get(key);
    if (result == null) {
      return null;
    }
    if ((result instanceof String)) {
      return (String)result;
    }
    List<String> valueList = (List)result;
    
    return (String)valueList.get(valueList.size() - 1);
  }
  
  private String[] getTableValues(Hashtable<String, Object> table, String key)
  {
    if (table == null) {
      return null;
    }
    Object result = table.get(key);
    if (result == null) {
      return null;
    }
    if ((result instanceof String)) {
      return new String[] { (String)result };
    }
    List<String> valueList = (List)result;
    return (String[])valueList.toArray(new String[valueList.size()]);
  }
  
  private Enumeration<String> getTableKeys(Hashtable<String, Object> table)
  {
    if (table == null) {
      return null;
    }
    return table.keys();
  }
  
  private Hashtable<String, Object> addTableValue(Hashtable<String, Object> table, String key, String value)
  {
    if (table == null) {
      table = new Hashtable(7);
    }
    Object curValue = table.get(key);
    if (curValue != null)
    {
      List<String> newList;
      List<String> newList;
      if ((curValue instanceof List))
      {
        newList = (List)curValue;
      }
      else
      {
        newList = new ArrayList(5);
        newList.add((String)curValue);
      }
      newList.add(value);
      table.put(key, newList);
    }
    else
    {
      table.put(key, value);
    }
    return table;
  }
  
  public static ManifestElement[] parseHeader(String header, String value)
    throws BundleException
  {
    if (value == null) {
      return null;
    }
    List<ManifestElement> headerElements = new ArrayList(10);
    Tokenizer tokenizer = new Tokenizer(value);
    char c;
    do
    {
      String next = tokenizer.getString(";,");
      if (next == null) {
        throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), 3);
      }
      List<String> headerValues = new ArrayList();
      StringBuffer headerValue = new StringBuffer(next);
      headerValues.add(next);
      if (Debug.DEBUG_MANIFEST) {
        Debug.print("parseHeader: " + next);
      }
      boolean directive = false;
      c = tokenizer.getChar();
      while (c == ';')
      {
        next = tokenizer.getString(";,=:");
        if (next == null) {
          throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), 3);
        }
        c = tokenizer.getChar();
        while (c == ':')
        {
          c = tokenizer.getChar();
          if (c != '=')
          {
            String restOfNext = tokenizer.getToken(";,=:");
            if (restOfNext == null) {
              throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), 3);
            }
            next = next + ":" + c + restOfNext;
            c = tokenizer.getChar();
          }
          else
          {
            directive = true;
          }
        }
        if ((c == ';') || (c == ',') || (c == 0))
        {
          headerValues.add(next);
          headerValue.append(";").append(next);
          if (Debug.DEBUG_MANIFEST) {
            Debug.print(";" + next);
          }
        }
      }
      ManifestElement manifestElement = new ManifestElement(headerValue.toString(), (String[])headerValues.toArray(new String[headerValues.size()]));
      while ((c == '=') || (c == ':'))
      {
        while (c == ':')
        {
          c = tokenizer.getChar();
          if (c != '=')
          {
            String restOfNext = tokenizer.getToken("=:");
            if (restOfNext == null) {
              throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), 3);
            }
            next = next + ":" + c + restOfNext;
            c = tokenizer.getChar();
          }
          else
          {
            directive = true;
          }
        }
        String preserveEscapes = null;
        if ((!directive) && (next.indexOf("List") > 0))
        {
          Tokenizer listTokenizer = new Tokenizer(next);
          String attrKey = listTokenizer.getToken(":");
          if ((attrKey != null) && (listTokenizer.getChar() == ':') && ("List".equals(listTokenizer.getToken("<")))) {
            preserveEscapes = "\\,";
          }
        }
        String val = tokenizer.getString(";,", preserveEscapes);
        if (val == null) {
          throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), 3);
        }
        if (Debug.DEBUG_MANIFEST) {
          Debug.print(";" + next + "=" + val);
        }
        try
        {
          if (directive) {
            manifestElement.addDirective(next, val);
          } else {
            manifestElement.addAttribute(next, val);
          }
          directive = false;
        }
        catch (Exception e)
        {
          throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), 3, e);
        }
        c = tokenizer.getChar();
        if (c == ';')
        {
          next = tokenizer.getToken("=:");
          if (next == null) {
            throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), 3);
          }
          c = tokenizer.getChar();
        }
      }
      headerElements.add(manifestElement);
      if (Debug.DEBUG_MANIFEST) {
        Debug.println("");
      }
    } while (c == ',');
    if (c != 0) {
      throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), 3);
    }
    int size = headerElements.size();
    if (size == 0) {
      return null;
    }
    ManifestElement[] result = (ManifestElement[])headerElements.toArray(new ManifestElement[size]);
    return result;
  }
  
  public static String[] getArrayFromList(String stringList)
  {
    String[] result = getArrayFromList(stringList, ",");
    return result.length == 0 ? null : result;
  }
  
  public static String[] getArrayFromList(String stringList, String separator)
  {
    if ((stringList == null) || (stringList.trim().length() == 0)) {
      return new String[0];
    }
    List<String> list = new ArrayList();
    StringTokenizer tokens = new StringTokenizer(stringList, separator);
    while (tokens.hasMoreTokens())
    {
      String token = tokens.nextToken().trim();
      if (token.length() != 0) {
        list.add(token);
      }
    }
    return (String[])list.toArray(new String[list.size()]);
  }
  
  /* Error */
  public static java.util.Map<String, String> parseBundleManifest(java.io.InputStream manifest, java.util.Map<String, String> headers)
    throws java.io.IOException, BundleException
  {
    // Byte code:
    //   0: aload_1
    //   1: ifnonnull +11 -> 12
    //   4: new 167	java/util/HashMap
    //   7: dup
    //   8: invokespecial 333	java/util/HashMap:<init>	()V
    //   11: astore_1
    //   12: new 157	java/io/BufferedReader
    //   15: dup
    //   16: new 159	java/io/InputStreamReader
    //   19: dup
    //   20: aload_0
    //   21: ldc_w 154
    //   24: invokespecial 314	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;Ljava/lang/String;)V
    //   27: invokespecial 311	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   30: astore_2
    //   31: goto +20 -> 51
    //   34: pop
    //   35: new 157	java/io/BufferedReader
    //   38: dup
    //   39: new 159	java/io/InputStreamReader
    //   42: dup
    //   43: aload_0
    //   44: invokespecial 313	java/io/InputStreamReader:<init>	(Ljava/io/InputStream;)V
    //   47: invokespecial 311	java/io/BufferedReader:<init>	(Ljava/io/Reader;)V
    //   50: astore_2
    //   51: aconst_null
    //   52: astore_3
    //   53: new 164	java/lang/StringBuffer
    //   56: dup
    //   57: sipush 256
    //   60: invokespecial 325	java/lang/StringBuffer:<init>	(I)V
    //   63: astore 4
    //   65: iconst_1
    //   66: istore 5
    //   68: aload_2
    //   69: invokevirtual 312	java/io/BufferedReader:readLine	()Ljava/lang/String;
    //   72: astore 6
    //   74: aload 6
    //   76: ifnull +11 -> 87
    //   79: aload 6
    //   81: invokevirtual 316	java/lang/String:length	()I
    //   84: ifne +27 -> 111
    //   87: iload 5
    //   89: ifne +175 -> 264
    //   92: aload_1
    //   93: aload_3
    //   94: aload 4
    //   96: invokevirtual 327	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   99: invokevirtual 320	java/lang/String:trim	()Ljava/lang/String;
    //   102: invokeinterface 371 3 0
    //   107: pop
    //   108: goto +156 -> 264
    //   111: aload 6
    //   113: iconst_0
    //   114: invokevirtual 317	java/lang/String:charAt	(I)C
    //   117: bipush 32
    //   119: if_icmpne +40 -> 159
    //   122: iload 5
    //   124: ifeq +20 -> 144
    //   127: new 177	org/osgi/framework/BundleException
    //   130: dup
    //   131: getstatic 305	org/eclipse/osgi/framework/internal/core/Msg:MANIFEST_INVALID_SPACE	Ljava/lang/String;
    //   134: aload 6
    //   136: invokestatic 361	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   139: iconst_3
    //   140: invokespecial 363	org/osgi/framework/BundleException:<init>	(Ljava/lang/String;I)V
    //   143: athrow
    //   144: aload 4
    //   146: aload 6
    //   148: iconst_1
    //   149: invokevirtual 321	java/lang/String:substring	(I)Ljava/lang/String;
    //   152: invokevirtual 330	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   155: pop
    //   156: goto -88 -> 68
    //   159: iload 5
    //   161: ifne +25 -> 186
    //   164: aload_1
    //   165: aload_3
    //   166: aload 4
    //   168: invokevirtual 327	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   171: invokevirtual 320	java/lang/String:trim	()Ljava/lang/String;
    //   174: invokeinterface 371 3 0
    //   179: pop
    //   180: aload 4
    //   182: iconst_0
    //   183: invokevirtual 326	java/lang/StringBuffer:setLength	(I)V
    //   186: aload 6
    //   188: bipush 58
    //   190: invokevirtual 318	java/lang/String:indexOf	(I)I
    //   193: istore 7
    //   195: iload 7
    //   197: iconst_m1
    //   198: if_icmpne +20 -> 218
    //   201: new 177	org/osgi/framework/BundleException
    //   204: dup
    //   205: getstatic 304	org/eclipse/osgi/framework/internal/core/Msg:MANIFEST_INVALID_LINE_NOCOLON	Ljava/lang/String;
    //   208: aload 6
    //   210: invokestatic 361	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   213: iconst_3
    //   214: invokespecial 363	org/osgi/framework/BundleException:<init>	(Ljava/lang/String;I)V
    //   217: athrow
    //   218: aload 6
    //   220: iconst_0
    //   221: iload 7
    //   223: invokevirtual 322	java/lang/String:substring	(II)Ljava/lang/String;
    //   226: invokevirtual 320	java/lang/String:trim	()Ljava/lang/String;
    //   229: astore_3
    //   230: aload 4
    //   232: aload 6
    //   234: iload 7
    //   236: iconst_1
    //   237: iadd
    //   238: invokevirtual 321	java/lang/String:substring	(I)Ljava/lang/String;
    //   241: invokevirtual 330	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   244: pop
    //   245: iconst_0
    //   246: istore 5
    //   248: goto -180 -> 68
    //   251: astore 8
    //   253: aload_2
    //   254: invokevirtual 310	java/io/BufferedReader:close	()V
    //   257: goto +4 -> 261
    //   260: pop
    //   261: aload 8
    //   263: athrow
    //   264: aload_2
    //   265: invokevirtual 310	java/io/BufferedReader:close	()V
    //   268: goto +4 -> 272
    //   271: pop
    //   272: aload_1
    //   273: areturn
    // Line number table:
    //   Java source line #502	-> byte code offset #0
    //   Java source line #503	-> byte code offset #4
    //   Java source line #506	-> byte code offset #12
    //   Java source line #507	-> byte code offset #31
    //   Java source line #508	-> byte code offset #35
    //   Java source line #511	-> byte code offset #51
    //   Java source line #512	-> byte code offset #53
    //   Java source line #513	-> byte code offset #65
    //   Java source line #516	-> byte code offset #68
    //   Java source line #523	-> byte code offset #74
    //   Java source line #525	-> byte code offset #87
    //   Java source line #527	-> byte code offset #92
    //   Java source line #529	-> byte code offset #108
    //   Java source line #532	-> byte code offset #111
    //   Java source line #534	-> byte code offset #122
    //   Java source line #536	-> byte code offset #127
    //   Java source line #538	-> byte code offset #144
    //   Java source line #539	-> byte code offset #156
    //   Java source line #542	-> byte code offset #159
    //   Java source line #543	-> byte code offset #164
    //   Java source line #544	-> byte code offset #180
    //   Java source line #547	-> byte code offset #186
    //   Java source line #548	-> byte code offset #195
    //   Java source line #550	-> byte code offset #201
    //   Java source line #552	-> byte code offset #218
    //   Java source line #553	-> byte code offset #230
    //   Java source line #554	-> byte code offset #245
    //   Java source line #515	-> byte code offset #248
    //   Java source line #556	-> byte code offset #251
    //   Java source line #558	-> byte code offset #253
    //   Java source line #559	-> byte code offset #257
    //   Java source line #562	-> byte code offset #261
    //   Java source line #558	-> byte code offset #264
    //   Java source line #559	-> byte code offset #268
    //   Java source line #563	-> byte code offset #272
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	274	0	manifest	java.io.InputStream
    //   0	274	1	headers	java.util.Map<String, String>
    //   30	2	2	br	java.io.BufferedReader
    //   50	215	2	br	java.io.BufferedReader
    //   52	178	3	header	String
    //   63	168	4	value	StringBuffer
    //   66	181	5	firstLine	boolean
    //   72	161	6	line	String
    //   193	42	7	colon	int
    //   251	11	8	localObject	Object
    //   34	1	10	localUnsupportedEncodingException	java.io.UnsupportedEncodingException
    //   260	1	11	localIOException1	java.io.IOException
    //   271	1	12	localIOException2	java.io.IOException
    // Exception table:
    //   from	to	target	type
    //   12	31	34	java/io/UnsupportedEncodingException
    //   51	251	251	finally
    //   253	257	260	java/io/IOException
    //   264	268	271	java/io/IOException
  }
  
  public String toString()
  {
    Enumeration<String> attrKeys = getKeys();
    Enumeration<String> directiveKeys = getDirectiveKeys();
    if ((attrKeys == null) && (directiveKeys == null)) {
      return mainValue;
    }
    StringBuffer result = new StringBuffer(mainValue);
    if (attrKeys != null) {
      while (attrKeys.hasMoreElements())
      {
        String key = (String)attrKeys.nextElement();
        addValues(false, key, getAttributes(key), result);
      }
    }
    if (directiveKeys != null) {
      while (directiveKeys.hasMoreElements())
      {
        String key = (String)directiveKeys.nextElement();
        addValues(true, key, getDirectives(key), result);
      }
    }
    return result.toString();
  }
  
  private void addValues(boolean directive, String key, String[] values, StringBuffer result)
  {
    if (values == null) {
      return;
    }
    for (int i = 0; i < values.length; i++)
    {
      result.append(';').append(key);
      if (directive) {
        result.append(':');
      }
      result.append("=\"").append(values[i]).append('"');
    }
  }
}

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

import java.security.PrivilegedAction;

class NLS$1
  implements PrivilegedAction<Object>
{
  private final String val$baseName;
  
  NLS$1(String paramString, Class paramClass) {}
  
  public Object run()
  {
    NLS.load(val$baseName, val$clazz);
    return null;
  }
}

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

import java.io.PrintStream;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Properties;
import org.eclipse.osgi.framework.debug.Debug;

class NLS$MessagesProperties
  extends Properties
{
  private static final int MOD_EXPECTED = 9;
  private static final int MOD_MASK = 25;
  private static final long serialVersionUID = 1L;
  private final String bundleName;
  private final Map<Object, Object> fields;
  private final boolean isAccessible;
  
  public NLS$MessagesProperties(Map<Object, Object> fieldMap, String bundleName, boolean isAccessible)
  {
    fields = fieldMap;
    this.bundleName = bundleName;
    this.isAccessible = isAccessible;
  }
  
  public synchronized Object put(Object key, Object value)
  {
    Object fieldObject = fields.put(key, NLS.ASSIGNED);
    if (fieldObject == NLS.ASSIGNED) {
      return null;
    }
    if (fieldObject == null)
    {
      String msg = "NLS unused message: " + key + " in: " + bundleName;
      if (Debug.DEBUG_MESSAGE_BUNDLES) {
        System.out.println(msg);
      }
      NLS.log(2, msg, null);
      return null;
    }
    Field field = (Field)fieldObject;
    if ((field.getModifiers() & 0x19) != 9) {
      return null;
    }
    try
    {
      if (!isAccessible) {
        field.setAccessible(true);
      }
      field.set(null, new String(((String)value).toCharArray()));
    }
    catch (Exception e)
    {
      NLS.log(4, "Exception setting field value.", e);
    }
    return null;
  }
}

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

import java.io.PrintStream;
import java.lang.reflect.Field;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;

public abstract class NLS
{
  private static final Object[] EMPTY_ARGS = new Object[0];
  private static final String EXTENSION = ".properties";
  private static String[] nlSuffixes;
  private static final String PROP_WARNINGS = "osgi.nls.warnings";
  private static final String IGNORE = "ignore";
  private static final boolean ignoreWarnings = "ignore".equals(FrameworkProperties.getProperty("osgi.nls.warnings"));
  private static FrameworkLog frameworkLog;
  static final int SEVERITY_ERROR = 4;
  static final int SEVERITY_WARNING = 2;
  static final Object ASSIGNED = new Object();
  
  public static String bind(String message, Object binding)
  {
    return internalBind(message, null, String.valueOf(binding), null);
  }
  
  public static String bind(String message, Object binding1, Object binding2)
  {
    return internalBind(message, null, String.valueOf(binding1), String.valueOf(binding2));
  }
  
  public static String bind(String message, Object[] bindings)
  {
    return internalBind(message, bindings, null, null);
  }
  
  public static void initializeMessages(S
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 85 86 87

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