org.eclipse.osgi_3.7.2.v20120110-1415

   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(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
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.osgi.framework.eventmgr;

public abstract interface EventDispatcher<K, V, E>
{
  public abstract void dispatchEvent(K paramK, V paramV, int paramInt, E paramE);
}

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

import java.util.Map.Entry;
import java.util.Set;

/**
 * @deprecated
 */
public class EventListeners<K, V>
{
  private final CopyOnWriteIdentityMap<K, V> list = new CopyOnWriteIdentityMap();
  
  public EventListeners() {}
  
  public EventListeners(int capacity)
  {
    this();
  }
  
  public void addListener(K listener, V listenerObject)
  {
    list.put(listener, listenerObject);
  }
  
  public void removeListener(V listener)
  {
    list.remove(listener);
  }
  
  public void removeAllListeners()
  {
    list.clear();
  }
  
  Set<Map.Entry<K, V>> entrySet()
  {
    return list.entrySet();
  }
}

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

import java.security.PrivilegedAction;

class EventManager$1
  implements PrivilegedAction<EventManager.EventThread<K, V, E>>
{
  final EventManager this$0;
  
  EventManager$1(EventManager paramEventManager) {}
  
  public EventManager.EventThread<K, V, E> run()
  {
    EventManager.EventThread<K, V, E> t = new EventManager.EventThread(this$0.threadGroup, this$0.threadName);
    return t;
  }
}

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

import java.util.Map.Entry;
import java.util.Set;

class EventManager$EventThread$Queued<K, V, E>
{
  final Set<Map.Entry<K, V>> listeners;
  final EventDispatcher<K, V, E> dispatcher;
  final int action;
  final E object;
  Queued<K, V, E> next;
  
  EventManager$EventThread$Queued(Set<Map.Entry<K, V>> l, EventDispatcher<K, V, E> d, int a, E o)
  {
    listeners = l;
    dispatcher = d;
    action = a;
    object = o;
    next = null;
  }
}

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

import java.util.Map.Entry;
import java.util.Set;

class EventManager$EventThread<K, V, E>
  extends Thread
{
  private static int nextThreadNumber;
  private Queued<K, V, E> head;
  private Queued<K, V, E> tail;
  private volatile boolean running;
  
  private static class Queued<K, V, E>
  {
    final Set<Map.Entry<K, V>> listeners;
    final EventDispatcher<K, V, E> dispatcher;
    final int action;
    final E object;
    Queued<K, V, E> next;
    
    Queued(Set<Map.Entry<K, V>> l, EventDispatcher<K, V, E> d, int a, E o)
    {
      listeners = l;
      dispatcher = d;
      action = a;
      object = o;
      next = null;
    }
  }
  
  EventManager$EventThread(ThreadGroup threadGroup, String threadName)
  {
    super(threadGroup, threadName == null ? getNextName() : threadName);
    running = true;
    head = null;
    tail = null;
    
    setDaemon(true);
  }
  
  private static synchronized String getNextName()
  {
    return "EventManagerThread-" + nextThreadNumber++;
  }
  
  EventManager$EventThread(String threadName)
  {
    this(null, threadName);
  }
  
  EventManager$EventThread()
  {
    this(null, null);
  }
  
  void close()
  {
    running = false;
    interrupt();
  }
  
  /* Error */
  public void run()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 131	org/eclipse/osgi/framework/eventmgr/EventManager$EventThread:getNextEvent	()Lorg/eclipse/osgi/framework/eventmgr/EventManager$EventThread$Queued;
    //   4: astore_1
    //   5: aload_1
    //   6: ifnonnull +4 -> 10
    //   9: return
    //   10: aload_1
    //   11: getfield 116	org/eclipse/osgi/framework/eventmgr/EventManager$EventThread$Queued:listeners	Ljava/util/Set;
    //   14: aload_1
    //   15: getfield 117	org/eclipse/osgi/framework/eventmgr/EventManager$EventThread$Queued:dispatcher	Lorg/eclipse/osgi/framework/eventmgr/EventDispatcher;
    //   18: aload_1
    //   19: getfield 114	org/eclipse/osgi/framework/eventmgr/EventManager$EventThread$Queued:action	I
    //   22: aload_1
    //   23: getfield 115	org/eclipse/osgi/framework/eventmgr/EventManager$EventThread$Queued:object	Ljava/lang/Object;
    //   26: invokestatic 126	org/eclipse/osgi/framework/eventmgr/EventManager:dispatchEvent	(Ljava/util/Set;Lorg/eclipse/osgi/framework/eventmgr/EventDispatcher;ILjava/lang/Object;)V
    //   29: aconst_null
    //   30: astore_1
    //   31: goto -31 -> 0
    //   34: astore_1
    //   35: aload_1
    //   36: athrow
    //   37: astore_1
    //   38: aload_1
    //   39: athrow
    // Line number table:
    //   Java source line #336	-> byte code offset #0
    //   Java source line #337	-> byte code offset #5
    //   Java source line #338	-> byte code offset #9
    //   Java source line #340	-> byte code offset #10
    //   Java source line #344	-> byte code offset #29
    //   Java source line #335	-> byte code offset #31
    //   Java source line #346	-> byte code offset #34
    //   Java source line #350	-> byte code offset #35
    //   Java source line #351	-> byte code offset #37
    //   Java source line #355	-> byte code offset #38
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	40	0	this	EventThread<K, V, E>
    //   4	27	1	item	Queued<K, V, E>
    //   34	2	1	e	RuntimeException
    //   37	2	1	e	Error
    // Exception table:
    //   from	to	target	type
    //   0	9	34	java/lang/RuntimeException
    //   10	34	34	java/lang/RuntimeException
    //   0	9	37	java/lang/Error
    //   10	34	37	java/lang/Error
  }
  
  synchronized void postEvent(Set<Map.Entry<K, V>> l, EventDispatcher<K, V, E> d, int a, E o)
  {
    if (!isAlive()) {
      throw new IllegalStateException();
    }
    Queued<K, V, E> item = new Queued(l, d, a, o);
    if (head == null)
    {
      head = item;
      tail = item;
    }
    else
    {
      tail.next = item;
      tail = item;
    }
    notify();
  }
  
  private synchronized Queued<K, V, E> getNextEvent()
  {
    while ((running) && (head == null)) {
      try
      {
        wait();
      }
      catch (InterruptedException localInterruptedException) {}
    }
    if (!running) {
      return null;
    }
    Queued<K, V, E> item = head;
    head = next;
    if (head == null) {
      tail = null;
    }
    return item;
  }
}

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

import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;

public class EventManager
{
  static final boolean DEBUG = false;
  private EventThread<?, ?, ?> thread;
  private boolean closed;
  protected final String threadName;
  protected final ThreadGroup threadGroup;
  
  public EventManager()
  {
    this(null, null);
  }
  
  public EventManager(String threadName)
  {
    this(threadName, null);
  }
  
  public EventManager(String threadName, ThreadGroup threadGroup)
  {
    thread = null;
    closed = false;
    this.threadName = threadName;
    this.threadGroup = threadGroup;
  }
  
  public synchronized void close()
  {
    if (closed) {
      return;
    }
    if (thread != null)
    {
      thread.close();
      thread = null;
    }
    closed = true;
  }
  
  synchronized <K, V, E> EventThread<K, V, E> getEventThread()
  {
    if (closed) {
      throw new IllegalStateException();
    }
    if (thread == null)
    {
      thread = ((EventThread)AccessController.doPrivileged(new PrivilegedAction()
      {
        public EventManager.EventThread<K, V, E> run()
        {
          EventManager.EventThread<K, V, E> t = new EventManager.EventThread(threadGroup, threadName);
          return t;
        }
      }));
      thread.start();
    }
    EventThread<K, V, E> result = thread;
    return result;
  }
  
  static <K, V, E> void dispatchEvent(Set<Map.Entry<K, V>> listeners, EventDispatcher<K, V, E> dispatcher, int eventAction, E eventObject)
  {
    for (Iterator localIterator = listeners.iterator(); localIterator.hasNext();)
    {
      Map.Entry<K, V> listener = (Map.Entry)localIterator.next();
      K eventListener = listener.getKey();
      V listenerObject = listener.getValue();
      try
      {
        dispatcher.dispatchEvent(eventListener, listenerObject, eventAction, eventObject);
      }
      catch (Throwable localThrowable) {}
    }
  }
  
  static class EventThread<K, V, E>
    extends Thread
  {
    private static int nextThreadNumber;
    private Queued<K, V, E> head;
    private Queued<K, V, E> tail;
    private volatile boolean running;
    
    private static class Queued<K, V, E>
    {
      final Set<Map.Entry<K, V>> listeners;
      final EventDispatcher<K, V, E> dispatcher;
      final int action;
      final E object;
      Queued<K, V, E> next;
      
      Queued(Set<Map.Entry<K, V>> l, EventDispatcher<K, V, E> d, int a, E o)
      {
        listeners = l;
        dispatcher = d;
        action = a;
        object = o;
        next = null;
      }
    }
    
    EventThread(ThreadGroup threadGroup, String threadName)
    {
      super(threadName == null ? getNextName() : threadName);
      running = true;
      head = null;
      tail = null;
      
      setDaemon(true);
    }
    
    private static synchronized String getNextName()
    {
      return "EventManagerThread-" + nextThreadNumber++;
    }
    
    EventThread(String threadName)
    {
      this(null, threadName);
    }
    
    EventThread()
    {
      this(null, null);
    }
    
    void close()
    {
      running = false;
      interrupt();
    }
    
    /* Error */
    public void run()
    {
      // Byte code:
      //   0: aload_0
      //   1: invokespecial 131	org/eclipse/osgi/framework/eventmgr/EventManager$EventThread:getNextEvent	()Lorg/eclipse/osgi/framework/eventmgr/EventManager$EventThread$Queued;
      //   4: astore_1
      //   5: aload_1
      //   6: ifnonnull +4 -> 10
      //   9: return
      //   10: aload_1
      //   11: getfield 116	org/eclipse/osgi/framework/eventmgr/EventManager$EventThread$Queued:listeners	Ljava/util/Set;
      //   14: aload_1
      //   15: getfield 117	org/eclipse/osgi/framework/eventmgr/EventManager$EventThread$Queued:dispatcher	Lorg/eclipse/osgi/framework/eventmgr/EventDispatcher;
      //   18: aload_1
      //   19: getfield 114	org/eclipse/osgi/framework/eventmgr/EventManager$EventThread$Queued:action	I
      //   22: aload_1
      //   23: getfield 115	org/eclipse/osgi/framework/eventmgr/EventManager$EventThread$Queued:object	Ljava/lang/Object;
      //   26: invokestatic 126	org/eclipse/osgi/framework/eventmgr/EventManager:dispatchEvent	(Ljava/util/Set;Lorg/eclipse/osgi/framework/eventmgr/EventDispatcher;ILjava/lang/Object;)V
      //   29: aconst_null
      //   30: astore_1
      //   31: goto -31 -> 0
      //   34: astore_1
      //   35: aload_1
      //   36: athrow
      //   37: astore_1
      //   38: aload_1
      //   39: athrow
      // Line number table:
      //   Java source line #336	-> byte code offset #0
      //   Java source
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-2019. Infinite Loop Ltd