org.eclipse.osgi_3.8.2.v20130124-134944

e code offset #25
    //   Java source line #50	-> byte code offset #30
    //   Java source line #59	-> byte code offset #35
    //   Java source line #63	-> byte code offset #56
    //   Java source line #64	-> byte code offset #62
    //   Java source line #65	-> byte code offset #66
    //   Java source line #66	-> byte code offset #67
    //   Java source line #68	-> byte code offset #78
    //   Java source line #72	-> byte code offset #85
    //   Java source line #73	-> byte code offset #99
    //   Java source line #74	-> byte code offset #108
    //   Java source line #75	-> byte code offset #128
    //   Java source line #77	-> byte code offset #142
    //   Java source line #78	-> byte code offset #148
    //   Java source line #79	-> byte code offset #152
    //   Java source line #80	-> byte code offset #174
    //   Java source line #82	-> byte code offset #175
    //   Java source line #84	-> byte code offset #200
    //   Java source line #86	-> byte code offset #205
    //   Java source line #87	-> byte code offset #213
    //   Java source line #88	-> byte code offset #221
    //   Java source line #89	-> byte code offset #226
    //   Java source line #90	-> byte code offset #230
    //   Java source line #89	-> byte code offset #233
    //   Java source line #91	-> byte code offset #237
    //   Java source line #92	-> byte code offset #241
    //   Java source line #93	-> byte code offset #252
    //   Java source line #94	-> byte code offset #253
    //   Java source line #95	-> byte code offset #261
    //   Java source line #98	-> byte code offset #268
    //   Java source line #99	-> byte code offset #293
    //   Java source line #98	-> byte code offset #316
    //   Java source line #101	-> byte code offset #326
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	327	0	this	FrameworkDebugOptions
    //   61	104	1	debugOptionsFilename	String
    //   147	54	2	optionsFile	URL
    //   98	35	3	userDir	String
    //   204	30	3	input	java.io.InputStream
    //   252	10	3	e	java.io.IOException
    //   292	11	3	key	Object
    //   224	7	4	localObject1	Object
    //   280	37	4	localIterator	Iterator
    //   240	1	9	localFileNotFoundException	java.io.FileNotFoundException
    // Exception table:
    //   from	to	target	type
    //   205	224	224	finally
    //   200	237	240	java/io/FileNotFoundException
    //   200	237	252	java/io/IOException
  }
  
  public void start(BundleContext bc)
  {
    context = bc;
    listenerTracker = new ServiceTracker(bc, DebugOptionsListener.class.getName(), this);
    listenerTracker.open();
  }
  
  public void stop(BundleContext bc)
  {
    listenerTracker.close();
    listenerTracker = null;
    context = null;
  }
  
  public static FrameworkDebugOptions getDefault()
  {
    if (singleton == null) {
      singleton = new FrameworkDebugOptions();
    }
    return singleton;
  }
  
  private static URL buildURL(String spec, boolean trailingSlash)
  {
    if (spec == null) {
      return null;
    }
    boolean isFile = spec.startsWith("file:");
    try
    {
      if (isFile) {
        return adjustTrailingSlash(new File(spec.substring(5)).toURL(), trailingSlash);
      }
      return new URL(spec);
    }
    catch (MalformedURLException localMalformedURLException1)
    {
      if (isFile) {
        return null;
      }
      try
      {
        return adjustTrailingSlash(new File(spec).toURL(), trailingSlash);
      }
      catch (MalformedURLException localMalformedURLException2) {}
    }
    return null;
  }
  
  private static URL adjustTrailingSlash(URL url, boolean trailingSlash)
    throws MalformedURLException
  {
    String file = url.getFile();
    if (trailingSlash == file.endsWith("/")) {
      return url;
    }
    file = trailingSlash ? file + "/" : file.substring(0, file.length() - 1);
    return new URL(url.getProtocol(), url.getHost(), file);
  }
  
  public boolean getBooleanOption(String option, boolean defaultValue)
  {
    String optionValue = getOption(option);
    return optionValue != null ? optionValue.equalsIgnoreCase("true") : defaultValue;
  }
  
  public String getOption(String option)
  {
    return getOption(option, null);
  }
  
  public String getOption(String option, String defaultValue)
  {
    synchronized (lock)
    {
      if (options != null) {
        return options.getProperty(option, defaultValue);
      }
    }
    return defaultValue;
  }
  
  public int getIntegerOption(String option, int defaultValue)
  {
    String value = getOption(option);
    try
    {
      return value == null ? defaultValue : Integer.parseInt(value);
    }
    catch (NumberFormatException localNumberFormatException) {}
    return defaultValue;
  }
  
  public Map<String, String> getOptions()
  {
    Map<String, String> snapShot = new HashMap();
    synchronized (lock)
    {
      if (options != null) {
        snapShot.putAll(options);
      } else if (disabledOptions != null) {
        snapShot.putAll(disabledOptions);
      }
    }
    return snapShot;
  }
  
  String[] getAllOptions()
  {
    String[] optionsArray = null;
    synchronized (lock)
    {
      if (options != null)
      {
        optionsArray = new String[options.size()];
        Iterator<Map.Entry<Object, Object>> entrySetIterator = options.entrySet().iterator();
        int i = 0;
        while (entrySetIterator.hasNext())
        {
          Map.Entry<Object, Object> entry = (Map.Entry)entrySetIterator.next();
          optionsArray[i] = ((String)entry.getKey() + "=" + (String)entry.getValue());
          i++;
        }
      }
    }
    if (optionsArray == null) {
      optionsArray = new String[1];
    }
    return optionsArray;
  }
  
  public void removeOption(String option)
  {
    if (option == null) {
      return;
    }
    String fireChangedEvent = null;
    synchronized (lock)
    {
      if ((options != null) && (options.remove(option) != null)) {
        fireChangedEvent = getSymbolicName(option);
      }
    }
    if (fireChangedEvent != null) {
      optionsChanged(fireChangedEvent);
    }
  }
  
  public void setOption(String option, String value)
  {
    if ((option == null) || (value == null)) {
      throw new IllegalArgumentException("The option and value must not be null.");
    }
    String fireChangedEvent = null;
    value = value != null ? value.trim() : null;
    synchronized (lock)
    {
      if (options != null)
      {
        String currentValue = options.getProperty(option);
        if (currentValue != null)
        {
          if (!currentValue.equals(value)) {
            fireChangedEvent = getSymbolicName(option);
          }
        }
        else if (value != null) {
          fireChangedEvent = getSymbolicName(option);
        }
        if (fireChangedEvent != null) {
          options.put(option, value);
        }
      }
    }
    if (fireChangedEvent != null) {
      optionsChanged(fireChangedEvent);
    }
  }
  
  private String getSymbolicName(String option)
  {
    int firstSlashIndex = option.indexOf("/");
    if (firstSlashIndex > 0) {
      return option.substring(0, firstSlashIndex);
    }
    return null;
  }
  
  public void setOptions(Map<String, String> ops)
  {
    if (ops == null) {
      throw new IllegalArgumentException("The options must not be null.");
    }
    Properties newOptions = new Properties();
    for (Iterator<Map.Entry<String, String>> entries = ops.entrySet().iterator(); entries.hasNext();)
    {
      Map.Entry<String, String> entry = (Map.Entry)entries.next();
      if ((!(entry.getKey() instanceof String)) || (!(entry.getValue() instanceof String))) {
        throw new IllegalArgumentException("Option keys and values must be of type String: " + (String)entry.getKey() + "=" + (String)entry.getValue());
      }
      newOptions.put(entry.getKey(), ((String)entry.getValue()).trim());
    }
    Set<String> fireChangesTo = null;
    synchronized (lock)
    {
      if (options == null)
      {
        disabledOptions = newOptions;
        
        return;
      }
      fireChangesTo = new HashSet();
      for (Iterator<Object> keys = options.keySet().iterator(); keys.hasNext();)
      {
        String key = (String)keys.next();
        if (!newOptions.containsKey(key))
        {
          String symbolicName = getSymbolicName(key);
          if (symbolicName != null) {
            fireChangesTo.add(symbolicName);
          }
        }
      }
      for (Iterator<Map.Entry<Object, Object>> newEntries = newOptions.entrySet().iterator(); newEntries.hasNext();)
      {
        Map.Entry<Object, Object> entry = (Map.Entry)newEntries.next();
        String existingValue = (String)options.get(entry.getKey());
        if (!entry.getValue().equals(existingValue))
        {
          String symbolicName = getSymbolicName((String)entry.getKey());
          if (symbolicName != null) {
            fireChangesTo.add(symbolicName);
          }
        }
      }
      options = newOptions;
    }
    if (fireChangesTo != null) {
      for (Iterator<String> iChanges = fireChangesTo.iterator(); iChanges.hasNext();) {
        optionsChanged((String)iChanges.next());
      }
    }
  }
  
  public boolean isDebugEnabled()
  {
    synchronized (lock)
    {
      return options != null;
    }
  }
  
  public void setDebugEnabled(boolean enabled)
  {
    boolean fireChangedEvent = false;
    synchronized (lock)
    {
      if (enabled)
      {
        if (options != null) {
          return;
        }
        EclipseDebugTrace.newSession = true;
        
        FrameworkProperties.setProperty("osgi.debug", "");
        if (disabledOptions != null)
        {
          options = disabledOptions;
          disabledOptions = null;
          
          fireChangedEvent = true;
        }
        else
        {
          options = new Properties();
        }
      }
      else
      {
        if (options == null) {
          return;
        }
        FrameworkProperties.clearProperty("osgi.debug");
        if (options.size() > 0)
        {
          disabledOptions = options;
          
          fireChangedEvent = true;
        }
        options = null;
      }
    }
    if (fireChangedEvent) {
      optionsChanged("*");
    }
  }
  
  public final DebugTrace newDebugTrace(String bundleSymbolicName)
  {
    return newDebugTrace(bundleSymbolicName, null);
  }
  
  public final DebugTrace newDebugTrace(String bundleSymbolicName, Class<?> traceEntryClass)
  {
    DebugTrace debugTrace = null;
    synchronized (debugTraceCache)
    {
      debugTrace = (DebugTrace)debugTraceCache.get(bundleSymbolicName);
      if (debugTrace == null)
      {
        debugTrace = new EclipseDebugTrace(bundleSymbolicName, singleton, traceEntryClass);
        debugTraceCache.put(bundleSymbolicName, debugTrace);
      }
    }
    return debugTrace;
  }
  
  public final File getFile()
  {
    return outFile;
  }
  
  public synchronized void setFile(File traceFile)
  {
    outFile = traceFile;
    FrameworkProperties.setProperty("osgi.tracefile", outFile.getAbsolutePath());
    
    EclipseDebugTrace.newSession = true;
  }
  
  boolean isVerbose()
  {
    return verboseDebug;
  }
  
  public synchronized void setVerbose(boolean verbose)
  {
    verboseDebug = verbose;
    
    EclipseDebugTrace.newSession = true;
  }
  
  /* Error */
  private void optionsChanged(String bundleSymbolicName)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 448	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:context	Lorg/osgi/framework/BundleContext;
    //   4: astore_2
    //   5: aload_2
    //   6: ifnonnull +4 -> 10
    //   9: return
    //   10: aconst_null
    //   11: astore_3
    //   12: aload_2
    //   13: getstatic 442	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:class$0	Ljava/lang/Class;
    //   16: dup
    //   17: ifnonnull +28 -> 45
    //   20: pop
    //   21: ldc 8
    //   23: invokestatic 463	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   26: dup
    //   27: putstatic 442	org/eclipse/osgi/framework/debug/FrameworkDebugOptions:class$0	Ljava/lang/Class;
    //   30: goto +15 -> 45
    //   33: new 239	java/lang/NoClassDefFoundError
    //   36: dup_x1
    //   37: swap
    //   38: invokevirtual 483	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   41: invokespecial 466	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   44: athrow
    //   45: invokevirtual 462	java/lang/Class:getName	()Ljava/lang/String;
    //   48: new 243	java/lang/StringBuffer
    //   51: dup
    //   52: ldc_w 220
    //   55: invokespecial 481	java/lang/StringBuffer:<init>	(Ljava/lang/String;)V
    //   58: aload_1
    //   59: invokevirtual 482	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   62: ldc_w 221
    //   65: invokevirtual 482	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   68: invokevirtual 480	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   71: invokeinterface 536 3 0
    //   76: astore_3
    //   77: goto +4 -> 81
    //   80: pop
    //   81: aload_3
    //   82: ifnonnull +4 -> 86
    //   85: return
    //   86: iconst_0
    //   87: istore 4
    //   89: goto +82 -> 171
    //   92: aload_2
    //   93: aload_3
    //   94: iload 4
    //   96: aaload
    //   97: invokeinterface 535 2 0
    //   102: checkcast 259	org/eclipse/osgi/service/debug/DebugOptionsListener
    //   105: astore 5
    //   107: aload 5
    //   109: ifnonnull +6 -> 115
    //   112: goto +56 -> 168
    //   115: aload 5
    //   117: aload_0
    //   118: invokeinterface 533 2 0
    //   123: goto +34 -> 157
    //   126: pop
    //   127: aload_2
    //   128: aload_3
    //   129: iload 4
    //   131: aaload
    //   132: invokeinterface 534 2 0
    //   137: pop
    //   138: goto +30 -> 168
    //   141: astore 6
    //   143: aload_2
    //   144: aload_3
    //   145: iload 4
    //   147: aaload
    //   148: invokeinterface 534 2 0
    //   153: pop
    //   154: aload 6
    //   156: athrow
    //   157: aload_2
    //   158: aload_3
    //   159: iload 4
    //   161: aaload
    //   162: invokeinterface 534 2 0
    //   167: pop
    //   168: iinc 4 1
    //   171: iload 4
    //   173: aload_3
    //   174: arraylength
    //   175: if_icmplt -83 -> 92
    //   178: return
    // Line number table:
    //   Java source line #468	-> byte code offset #0
    //   Java source line #469	-> byte code offset #5
    //   Java source line #470	-> byte code offset #9
    //   Java source line #473	-> byte code offset #10
    //   Java source line #475	-> byte code offset #12
    //   Java source line #476	-> byte code offset #77
    //   Java source line #479	-> byte code offset #81
    //   Java source line #480	-> byte code offset #85
    //   Java source line #481	-> byte code offset #86
    //   Java source line #482	-> byte code offset #92
    //   Java source line #483	-> byte code offset #107
    //   Java source line #484	-> byte code offset #112
    //   Java source line #486	-> byte code offset #115
    //   Java source line #487	-> byte code offset #123
    //   Java source line #490	-> byte code offset #127
    //   Java source line #489	-> byte code offset #141
    //   Java source line #490	-> byte code offset #143
    //   Java source line #491	-> byte code offset #154
    //   Java source line #490	-> byte code offset #157
    //   Java source line #481	-> byte code offset #168
    //   Java source line #493	-> byte code offset #178
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	179	0	this	FrameworkDebugOptions
    //   0	179	1	bundleSymbolicName	String
    //   4	154	2	bc	BundleContext
    //   11	163	3	listenerRefs	ServiceReference[]
    //   87	85	4	i	int
    //   105	11	5	service	DebugOptionsListener
    //   141	14	6	localObject	Object
    //   33	1	7	localClassNotFoundException	ClassNotFoundException
    //   80	1	8	localInvalidSyntaxException	org.osgi.framework.InvalidSyntaxException
    //   126	1	9	localThrowable	Throwable
    // Exception table:
    //   from	to	target	type
    //   21	26	33	java/lang/ClassNotFoundException
    //   12	77	80	org/osgi/framework/InvalidSyntaxException
    //   115	123	126	java/lang/Throwable
    //   115	127	141	finally
  }
  
  public DebugOptionsListener addingService(ServiceReference<DebugOptionsListener> reference)
  {
    DebugOptionsListener listener = (DebugOptionsListener)context.getService(reference);
    listener.optionsChanged(this);
    return listener;
  }
  
  public void modifiedService(ServiceReference<DebugOptionsListener> reference, DebugOptionsListener service) {}
  
  public void removedService(ServiceReference<DebugOptionsListener> reference, DebugOptionsListener service)
  {
    context.ungetService(reference);
  }
}

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

public class FrameworkDebugTraceEntry
{
  public static final String DEFAULT_OPTION_PATH = "/debug";
  private final String threadName;
  private final long timestamp;
  private final String optionPath;
  private final String bundleSymbolicName;
  private final String className;
  private final String methodName;
  private final int lineNumber;
  private String message;
  private final Throwable throwable;
  
  public FrameworkDebugTraceEntry(String bundleSymbolicName, String optionPath, String message, String traceClass)
  {
    this(bundleSymbolicName, optionPath, message, null, traceClass);
  }
  
  public FrameworkDebugTraceEntry(String bundleSymbolicName, String optionPath, String message, Throwable error, String traceClass)
  {
    threadName = Thread.currentThread().getName();
    if (optionPath == null) {
      this.optionPath = "/debug";
    } else {
      this.optionPath = optionPath;
    }
    timestamp = System.currentTimeMillis();
    this.bundleSymbolicName = bundleSymbolicName;
    this.message = message;
    throwable = error;
    
    String determineClassName = null;
    String determineMethodName = null;
    int determineLineNumber = 0;
    
    StackTraceElement[] stackElements = new Exception().getStackTrace();
    int i = 0;
    while (i < stackElements.length)
    {
      String fullClassName = stackElements[i].getClassName();
      if ((!fullClassName.equals(Thread.class.getName())) && (!fullClassName.equals(FrameworkDebugTraceEntry.class.getName())) && (!fullClassName.equals(EclipseDebugTrace.class.getName()))) {
        if ((traceClass == null) || (!fullClassName.equals(traceClass)))
        {
          determineClassName = stackElements[i].getClassName();
          determineMethodName = stackElements[i].getMethodName();
          determineLineNumber = stackElements[i].getLineNumber();
          break;
        }
      }
      i++;
    }
    className = determineClassName;
    methodName = determineMethodName;
    lineNumber = determineLineNumber;
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer(threadName);
    buffer.append(" ");
    buffer.append(timestamp);
    buffer.append(" ");
    buffer.append(bundleSymbolicName);
    buffer.append(" ");
    buffer.append(optionPath);
    buffer.append(" ");
    buffer.append(className);
    buffer.append(" ");
    buffer.append(methodName);
    buffer.append(" ");
    buffer.append(lineNumber);
    if (message != null)
    {
      buffer.append(": ");
      buffer.append(message);
    }
    if (throwable != null) {
      buffer.append(throwable);
    }
    return buffer.toString();
  }
  
  public final String getThreadName()
  {
    return threadName;
  }
  
  public final long getTimestamp()
  {
    return timestamp;
  }
  
  public final String getBundleSymbolicName()
  {
    return bundleSymbolicName;
  }
  
  public final String getMessage()
  {
    return message;
  }
  
  public final Throwable getThrowable()
  {
    return throwable;
  }
  
  public final String getClassName()
  {
    return className;
  }
  
  public final String getMethodName()
  {
    return methodName;
  }
  
  public final String getOptionPath()
  {
    return optionPath;
  }
  
  public final int getLineNumber()
  {
    return lineNumber;
  }
  
  void setMessage(String newMessage)
  {
    message = newMessage;
  }
}

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

import java.util.Map.Entry;

final class CopyOnWriteIdentityMap$Entry<K, V>
  implements Map.Entry<K, V>
{
  final K key;
  final V value;
  
  CopyOnWriteIdentityMap$Entry(K key, V value)
  {
    this.key = key;
    this.value = value;
  }
  
  public K getKey()
  {
    return (K)key;
  }
  
  public V getValue()
  {
    return (V)value;
  }
  
  public V setValue(V value)
  {
    throw new UnsupportedOperationException();
  }
  
  public String toString()
  {
    return key + "=" + value;
  }
  
  public int hashCode()
  {
    return System.identityHashCode(key) ^ System.identityHashCode(value);
  }
  
  public boolean equals(Object obj)
  {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof Map.Entry)) {
      return false;
    }
    Map.Entry<?, ?> e = (Map.Entry)obj;
    return (key == e.getKey()) && (value == e.getValue());
  }
}

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

import java.util.Map.Entry;

final class CopyOnWriteIdentityMap$Snapshot$EntryIterator
  extends CopyOnWriteIdentityMap.Snapshot<K, V>.SnapshotIterator<Map.Entry<K, V>>
{
  final CopyOnWriteIdentityMap.Snapshot this$1;
  
  CopyOnWriteIdentityMap$Snapshot$EntryIterator(CopyOnWriteIdentityMap.Snapshot paramSnapshot)
  {
    super(paramSnapshot);
  }
  
  public Map.Entry<K, V> next()
  {
    return nextEntry();
  }
}

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

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map.Entry;

final class CopyOnWriteIdentityMap$Snapshot$EntrySet
  extends AbstractSet<Map.Entry<K, V>>
{
  final CopyOnWriteIdentityMap.Snapshot this$1;
  
  CopyOnWriteIdentityMap$Snapshot$EntrySet(CopyOnWriteIdentityMap.Snapshot paramSnapshot) {}
  
  public Iterator<Map.Entry<K, V>> iterator()
  {
    return new CopyOnWriteIdentityMap.Snapshot.EntryIterator(this$1);
  }
  
  public int size()
  {
    return this$1.entries().length;
  }
  
  public boolean remove(Object o)
  {
    if (o == null) {
      throw new IllegalArgumentException();
    }
    synchronized (this$1)
    {
      int size = this$1.entries.length;
      for (int i = 0; i < size; i++) {
        if (this$1.entries[i].equals(o))
        {
          this$1.removeEntry(i);
          return true;
        }
      }
    }
    return false;
  }
  
  public void clear()
  {
    this$1.clearEntries();
  }
}

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

final class CopyOnWriteIdentityMap$Snapshot$KeyIterator
  extends CopyOnWriteIdentityMap.Snapshot<K, V>.SnapshotIterator<K>
{
  final CopyOnWriteIdentityMap.Snapshot this$1;
  
  CopyOnWriteIdentityMap$Snapshot$KeyIterator(CopyOnWriteIdentityMap.Snapshot paramSnapshot)
  {
    super(paramSnapshot);
  }
  
  public K next()
  {
    return (K)nextEntrykey;
  }
}

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

import java.util.AbstractSet;
import java.util.Iterator;

final class CopyOnWriteIdentityMap$Snapshot$KeySet
  extends AbstractSet<K>
{
  final CopyOnWriteIdentityMap.Snapshot this$1;
  
  CopyOnWriteIdentityMap$Snapshot$KeySet(CopyOnWriteIdentityMap.Snapshot paramSnapshot) {}
  
  public Iterator<K> iterator()
  {
    return new CopyOnWriteIdentityMap.Snapshot.KeyIterator(this$1);
  }
  
  public int size()
  {
    return this$1.entries().length;
  }
  
  public boolean remove(Object o)
  {
    if (o == null) {
      throw new IllegalArgumentException();
    }
    synchronized (this$1)
    {
      int size = this$1.entries.length;
      for (int i = 0; i < size; i++) {
        if (this$1.entries[i].key == o)
        {
          this$1.removeEntry(i);
          return true;
        }
      }
    }
    return false;
  }
  
  public void clear()
  {
    this$1.clearEntries();
  }
}

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

import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.NoSuchElementException;

abstract class CopyOnWriteIdentityMap$Snapshot$SnapshotIterator<E>
  implements Iterator<E>
{
  private int length;
  private int cursor;
  final CopyOnWriteIdentityMap.Snapshot this$1;
  
  CopyOnWriteIdentityMap$Snapshot$SnapshotIterator(CopyOnWriteIdentityMap.Snapshot paramSnapshot)
  {
    length = paramSnapshot.entries().length;
    cursor = 0;
  }
  
  public final boolean hasNext()
  {
    return cursor < length;
  }
  
  protected final CopyOnWriteIdentityMap.Entry<K, V> nextEntry()
  {
    CopyOnWriteIdentityMap.Entry[] e = this$1.entries();
    if (length != e.length) {
      throw new ConcurrentModificationException();
    }
    if (cursor == length) {
      throw new NoSuchElementException();
    }
    return e[(cursor++)];
  }
  
  public final void remove()
  {
    if (length != this$1.entries().length) {
      throw new ConcurrentModificationException();
    }
    if (cursor == 0) {
      throw new IllegalStateException();
    }
    cursor -= 1;
    this$1.removeEntry(cursor);
    length = this$1.entries().length;
  }
}

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

import java.util.AbstractCollection;
import java.util.Iterator;

final class CopyOnWriteIdentityMap$Snapshot$ValueCollection
  extends AbstractCollection<V>
{
  final CopyOnWriteIdentityMap.Snapshot this$1;
  
  CopyOnWriteIdentityMap$Snapshot$ValueCollection(CopyOnWriteIdentityMap.Snapshot paramSnapshot) {}
  
  public Iterator<V> iterator()
  {
    return new CopyOnWriteIdentityMap.Snapshot.ValueIterator(this$1);
  }
  
  public int size()
  {
    return this$1.entries().length;
  }
  
  public boolean remove(Object o)
  {
    if (o == null) {
      throw new IllegalArgumentException();
    }
    synchronized (this$1)
    {
      int size = this$1.entries.length;
      for (int i = 0; i < size; i++) {
        if (this$1.entries[i].value == o)
        {
          this$1.removeEntry(i);
          return true;
        }
      }
    }
    return false;
  }
  
  public void clear()
  {
    this$1.clearEntries();
  }
}

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

final class CopyOnWriteIdentityMap$Snapshot$ValueIterator
  extends CopyOnWriteIdentityMap.Snapshot<K, V>.SnapshotIterator<V>
{
  final CopyOnWriteIdentityMap.Snapshot this$1;
  
  CopyOnWriteIdentityMap$Snapshot$ValueIterator(CopyOnWriteIdentityMap.Snapshot paramSnapshot)
  {
    super(paramSnapshot);
  }
  
  public V next()
  {
    return (V)nextEntryvalue;
  }
}

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

import java.util.AbstractCollection;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Set;

final class CopyOnWriteIdentityMap$Snapshot<K, V>
{
  volatile CopyOnWriteIdentityMap.Entry<K, V>[] entries;
  
  CopyOnWriteIdentityMap$Snapshot(CopyOnWriteIdentityMap.Entry<K, V>[] e)
  {
    entries = e;
  }
  
  CopyOnWriteIdentityMap.Entry<K, V>[] entries()
  {
    return entries;
  }
  
  synchronized void removeEntry(int i)
  {
    entries = CopyOnWriteIdentityMap.removeEntry(entries, i);
  }
  
  synchronized void clearEntries()
  {
    entries = CopyOnWriteIdentityMap.empty();
  }
  
  Set<Map.Entry<K, V>> entrySet()
  {
    return new EntrySet();
  }
  
  Set<K> keySet()
  {
    return new KeySet();
  }
  
  Collection<V> values()
  {
    return new ValueCollection();
  }
  
  private final class EntrySet
    extends AbstractSet<Map.Entry<K, V>>
  {
    EntrySet() {}
    
    public Iterator<Map.Entry<K, V>> iterator()
    {
      return new CopyOnWriteIdentityMap.Snapshot.EntryIterator(CopyOnWriteIdentityMap.Snapshot.this);
    }
    
    public int size()
    {
      return entries().length;
    }
    
    public boolean remove(Object o)
    {
      if (o == null) {
        throw new IllegalArgumentException();
      }
      synchronized (CopyOnWriteIdentityMap.Snapshot.this)
      {
        int size = entries.length;
        for (int i = 0; i < size; i++) {
          if (entries[i].equals(o))
          {
            removeEntry(i);
            return true;
          }
        }
      }
      return false;
    }
    
    public void clear()
    {
      clearEntries();
    }
  }
  
  private final class EntryIterator
    extends CopyOnWriteIdentityMap.Snapshot<K, V>.SnapshotIterator<Map.Entry<K, V>>
  {
    EntryIterator()
    {
      super();
    }
    
    public Map.Entry<K, V> next()
    {
      return nextEntry();
    }
  }
  
  private final class KeySet
    extends AbstractSet<K>
  {
    KeySet() {}
    
    public Iterator<K> iterator()
    {
      return new CopyOnWriteIdentityMap.Snapshot.KeyIterator(CopyOnWriteIdentityMap.Snapshot.this);
    }
    
    public int size()
    {
      return entries().length;
    }
    
    public boolean remove(Object o)
    {
      if (o == null) {
        throw new IllegalArgumentException();
      }
      synchronized (CopyOnWriteIdentityMap.Snapshot.this)
      {
        int size = entries.length;
        for (int i = 0; i < size; i++) {
          if (entries[i].key == o)
          {
            removeEntry(i);
            return true;
          }
        }
      }
      return false;
    }
    
    public void clear()
    {
      clearEntries();
    }
  }
  
  private final class KeyIterator
    extends CopyOnWriteIdentityMap.Snapshot<K, V>.SnapshotIterator<K>
  {
    KeyIterator()
    {
      super();
    }
    
    public K next()
    {
      return (K)nextEntrykey;
    }
  }
  
  private final class ValueCollection
    extends AbstractCollection<V>
  {
    ValueCollection() {}
    
    public Iterator<V> iterator()
    {
      return new CopyOnWriteIdentityMap.Snapshot.ValueIterator(CopyOnWriteIdentityMap.Snapshot.this);
    }
    
    public int size()
    {
      return entries().length;
    }
    
    public boolean remove(Object o)
    {
      if (o == null) {
        throw new IllegalArgumentException();
      }
      synchronized (CopyOnWriteIdentityMap.Snapshot.this)
      {
        int size = entries.length;
        for (int i = 0; i < size; i++) {
          if (entries[i].value == o)
          {
            removeEntry(i);
            return true;
          }
        }
      }
      return false;
    }
    
    public void clear()
    {
      clearEntries();
    }
  }
  
  private final class ValueIterator
    extends CopyOnWriteIdentityMap.Snapshot<K, V>.SnapshotIterator<V>
  {
    ValueIterator()
    {
      super();
    }
    
    public V next()
    {
      return (V)nextEntryvalue;
    }
  }
  
  private abstract class SnapshotIterator<E>
    implements Iterator<E>
  {
    private int length;
    private int cursor;
    
    SnapshotIterator()
    {
      length = entries().length;
      cursor = 0;
    }
    
    public final boolean hasNext()
    {
      return cursor < length;
    }
    
    protected final CopyOnWriteIdentityMap.Entry<K, V> nextEntry()
    {
      CopyOnWriteIdentityMap.Entry[] e = entries();
      if (length != e.length) {
        throw new ConcurrentModificationException();
      }
      if (cursor == length) {
        throw new NoSuchElementException();
      }
      return e[(cursor++)];
    }
    
    public final void remove()
    {
      if (length != entries().length) {
        throw new ConcurrentModificationException();
      }
      if (cursor == 0) {
        throw new IllegalStateException();
      }
      cursor -= 1;
      removeEntry(cursor);
      length = entries().length;
    }
  }
}

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

import java.util.AbstractCollection;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Set;

public class CopyOnWriteIdentityMap<K, V>
  implements Map<K, V>
{
  private static final Entry[] emptyArray = new Entry[0];
  private volatile Entry<K, V>[] entries;
  
  public CopyOnWriteIdentityMap()
  {
    entries = empty();
  }
  
  public CopyOnWriteIdentityMap(CopyOnWriteIdentityMap<? extends K, ? extends V> source)
  {
    Entry[] toCopy = source.entries();
    entries = toCopy;
  }
  
  public synchronized V put(K key, V value)
  {
    if (key == null) {
      throw new IllegalArgumentException();
    }
    int size = entries.length;
    for (int i = 0; i < size; i++) {
      if (entries[i].key == key)
      {
        V v = entries[i].value;
        if (v == value) {
          return v;
        }
        Entry[] newEntries = new Entry[size];
        System.arraycopy(entries, 0, newEntries, 0, size);
        newEntries[i] = new Entry(key, value);
        entries = newEntries;
        return v;
      }
    }
    Entry[] newEntries = new Entry[size + 1];
    if (size > 0) {
      System.arraycopy(entries, 0, newEntries, 0, size);
    }
    newEntries[size] = new Entry(key, value);
    entries = newEntries;
    return null;
  }
  
  public void putAll(Map<? extends K, ? extends V> source)
  {
    int sourceSize = source.size();
    if (sourceSize == 0) {
      return;
    }
    if ((source instanceof CopyOnWriteIdentityMap))
    {
      putAll(((CopyOnWriteIdentityMap)source).entries());
      return;
    }
    Entry[] toCopy = new Entry[sourceSize];
    Iterator<? extends Map.Entry<? extends K, ? extends V>> iter = source.entrySet().iterator();
    for (int i = 0; i < sourceSize; i++)
    {
      Map.Entry<? extends K, ? extends V> mapEntry = (Map.Entry)iter.next();
      toCopy[i] = new Entry(mapEntry.getKey(), mapEntry.getValue());
    }
    putAll(toCopy);
  }
  
  public <L extends K> void putAll(L[] keys)
  {
    int sourceSize = keys.length;
    if (sourceSize == 0) {
      return;
    }
    Entry[] toCopy = new Entry[sourceSize];
    for (int i = 0; i < sourceSize; i++) {
      toCopy[i] = new Entry(keys[i], null);
    }
    putAll(toCopy);
  }
  
  private synchronized void putAll(Entry<? extends K, ? extends V>[] toCopy)
  {
    int sourceSize = toCopy.length;
    int size = entries.length;
    
    Entry[] newEntries = new Entry[size + sourceSize];
    System.arraycopy(entries, 0, newEntries, 0, size);
    for (int n = 0; n < sourceSize; n++)
    {
      Entry<K, V> copy = toCopy[n];
      for (int i = 0; i < size; i++) {
        if (key == key)
        {
          newEntries[i] = copy;
          break;
        }
      }
      newEntries[size] = copy;
      size++;
    }
    if (size == newEntries.length)
    {
      entries = newEntries;
      return;
    }
    Entry[] e = new Entry[size];
    System.arraycopy(newEntries, 0, e, 0, size);
    entries = e;
  }
  
  public synchronized V remove(Object key)
  {
    if (key == null) {
      throw new IllegalArgumentException();
    }
    int size = entries.length;
    for (int i = 0; i < size; i++) {
      if (entries[i].key == key)
      {
        V v = entries[i].value;
        entries = removeEntry(entries, i);
        return v;
      }
    }
    return null;
  }
  
  static <K, V> Entry<K, V>[] removeEntry(Entry<K, V>[] entries, int i)
  {
    int size = entries.length;
    if (size == 1) {
      return empty();
    }
    Entry[] newEntries = new Entry[size - 1];
    if (i > 0) {
      System.arraycopy(entries, 0, newEntries, 0, i);
    }
    int next = size - 1 - i;
    if (next > 0) {
      System.arraycopy(entries, i + 1, newEntries, i, next);
    }
    return newEntries;
  }
  
  public synchronized void clear()
  {
    entries = empty();
  }
  
  private Entry<K, V>[] entries()
  {
    return entries;
  }
  
  static <K, V> Entry<K, V>[] empty()
  {
    return emptyArray;
  }
  
  public boolean isEmpty()
  {
    return size() == 0;
  }
  
  public int size()
  {
    return entries().length;
  }
  
  public V get(Object key)
  {
    if (key == null) {
      throw new IllegalArgumentException();
    }
    Entry[] e = entries();
    for (int i = 0; i < e.length; i++) {
      if (key == key) {
        return (V)value;
      }
    }
    return null;
  }
  
  public boolean containsKey(Object key)
  {
    if (key == null) {
      throw new IllegalArgumentException();
    }
    Entry[] e = entries();
    for (int i = 0; i < e.length; i++) {
      if (key == key) {
        return true;
      }
    }
    return false;
  }
  
  public boolean containsValue(Object value)
  {
    Entry[] e = entries();
    for (int i = 0; i < e.length; i++) {
      if (value == value) {
        return true;
      }
    }
    return false;
  }
  
  public Set<Map.Entry<K, V>> entrySet()
  {
    return new Snapshot(entries()).entrySet();
  }
  
  public Set<K> keySet()
  {
    return new Snapshot(entries()).keySet();
  }
  
  public Collection<V> values()
  {
    return new Snapshot(entries()).values();
  }
  
  private static final class Entry<K, V>
    implements Map.Entry<K, V>
  {
    final K key;
    final V value;
    
    Entry(K key, V value)
    {
      this.key = key;
      this.value = value;
    }
    
    public K getKey()
    {
      return (K)key;
    }
    
    public V getValue()
    {
      return (V)value;
    }
    
    public V setValue(V value)
    {
      throw new UnsupportedOperationException();
    }
    
    public String toString()
    {
      return key + "=" + value;
    }
    
    public int hashCode()
    {
      return System.identityHashCode(key) ^ System.identityHashCode(value);
    }
    
    public boolean equals(Object obj)
    {
      if (obj == this) {
        return true;
      }
      if (!(obj instanceof Map.Entry)) {
        return false;
      }
      Map.Entry<?, ?> e = (Map.Entry)obj;
      return (key == e.getKey()) && (value == e.getValue());
    }
  }
  
  private static final class Snapshot<K, V>
  {
    volatile CopyOnWriteIdentityMap.Entry<K, V>[] entries;
    
    Snapshot(Cop
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