commons-collections-3.2.1

16:34:41.081 INFO  jd.cli.Main - Decompiling commons-collections-3.2.1.jar
package org.apache.commons.collections;

import java.util.ArrayList;
import java.util.EmptyStackException;

public class ArrayStack
  extends ArrayList
  implements Buffer
{
  private static final long serialVersionUID = 2130079159931574599L;
  
  public ArrayStack() {}
  
  public ArrayStack(int initialSize)
  {
    super(initialSize);
  }
  
  public boolean empty()
  {
    return isEmpty();
  }
  
  public Object peek()
    throws EmptyStackException
  {
    int n = size();
    if (n <= 0) {
      throw new EmptyStackException();
    }
    return get(n - 1);
  }
  
  public Object peek(int n)
    throws EmptyStackException
  {
    int m = size() - n - 1;
    if (m < 0) {
      throw new EmptyStackException();
    }
    return get(m);
  }
  
  public Object pop()
    throws EmptyStackException
  {
    int n = size();
    if (n <= 0) {
      throw new EmptyStackException();
    }
    return remove(n - 1);
  }
  
  public Object push(Object item)
  {
    add(item);
    return item;
  }
  
  public int search(Object object)
  {
    int i = size() - 1;
    int n = 1;
    while (i >= 0)
    {
      Object current = get(i);
      if (((object == null) && (current == null)) || ((object != null) && (object.equals(current)))) {
        return n;
      }
      i--;
      n++;
    }
    return -1;
  }
  
  public Object get()
  {
    int size = size();
    if (size == 0) {
      throw new BufferUnderflowException();
    }
    return get(size - 1);
  }
  
  public Object remove()
  {
    int size = size();
    if (size == 0) {
      throw new BufferUnderflowException();
    }
    return remove(size - 1);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.ArrayStack
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import java.util.Set;
import org.apache.commons.collections.Bag;
import org.apache.commons.collections.collection.AbstractCollectionDecorator;

public abstract class AbstractBagDecorator
  extends AbstractCollectionDecorator
  implements Bag
{
  protected AbstractBagDecorator() {}
  
  protected AbstractBagDecorator(Bag bag)
  {
    super(bag);
  }
  
  protected Bag getBag()
  {
    return (Bag)getCollection();
  }
  
  public int getCount(Object object)
  {
    return getBag().getCount(object);
  }
  
  public boolean add(Object object, int count)
  {
    return getBag().add(object, count);
  }
  
  public boolean remove(Object object, int count)
  {
    return getBag().remove(object, count);
  }
  
  public Set uniqueSet()
  {
    return getBag().uniqueSet();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.AbstractBagDecorator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

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

class AbstractMapBag$BagIterator
  implements Iterator
{
  private AbstractMapBag parent;
  private Iterator entryIterator;
  private Map.Entry current;
  private int itemCount;
  private final int mods;
  private boolean canRemove;
  
  public AbstractMapBag$BagIterator(AbstractMapBag parent)
  {
    this.parent = parent;
    entryIterator = AbstractMapBag.access$000(parent).entrySet().iterator();
    current = null;
    mods = AbstractMapBag.access$100(parent);
    canRemove = false;
  }
  
  public boolean hasNext()
  {
    return (itemCount > 0) || (entryIterator.hasNext());
  }
  
  public Object next()
  {
    if (AbstractMapBag.access$100(parent) != mods) {
      throw new ConcurrentModificationException();
    }
    if (itemCount == 0)
    {
      current = ((Map.Entry)entryIterator.next());
      itemCount = current.getValue()).value;
    }
    canRemove = true;
    itemCount -= 1;
    return current.getKey();
  }
  
  public void remove()
  {
    if (AbstractMapBag.access$100(parent) != mods) {
      throw new ConcurrentModificationException();
    }
    if (!canRemove) {
      throw new IllegalStateException();
    }
    AbstractMapBag.MutableInteger mut = (AbstractMapBag.MutableInteger)current.getValue();
    if (value > 1) {
      value -= 1;
    } else {
      entryIterator.remove();
    }
    AbstractMapBag.access$210(parent);
    canRemove = false;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.AbstractMapBag.BagIterator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

public class AbstractMapBag$MutableInteger
{
  protected int value;
  
  AbstractMapBag$MutableInteger(int value)
  {
    this.value = value;
  }
  
  public boolean equals(Object obj)
  {
    if (!(obj instanceof MutableInteger)) {
      return false;
    }
    return value == value;
  }
  
  public int hashCode()
  {
    return value;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.AbstractMapBag.MutableInteger
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.Array;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.collections.Bag;
import org.apache.commons.collections.set.UnmodifiableSet;

public abstract class AbstractMapBag
  implements Bag
{
  private transient Map map;
  private int size;
  private transient int modCount;
  private transient Set uniqueSet;
  
  protected AbstractMapBag() {}
  
  protected AbstractMapBag(Map map)
  {
    this.map = map;
  }
  
  protected Map getMap()
  {
    return map;
  }
  
  public int size()
  {
    return size;
  }
  
  public boolean isEmpty()
  {
    return map.isEmpty();
  }
  
  public int getCount(Object object)
  {
    MutableInteger count = (MutableInteger)map.get(object);
    if (count != null) {
      return value;
    }
    return 0;
  }
  
  public boolean contains(Object object)
  {
    return map.containsKey(object);
  }
  
  public boolean containsAll(Collection coll)
  {
    if ((coll instanceof Bag)) {
      return containsAll((Bag)coll);
    }
    return containsAll(new HashBag(coll));
  }
  
  boolean containsAll(Bag other)
  {
    boolean result = true;
    Iterator it = other.uniqueSet().iterator();
    while (it.hasNext())
    {
      Object current = it.next();
      boolean contains = getCount(current) >= other.getCount(current);
      result = (result) && (contains);
    }
    return result;
  }
  
  public Iterator iterator()
  {
    return new BagIterator(this);
  }
  
  static class BagIterator
    implements Iterator
  {
    private AbstractMapBag parent;
    private Iterator entryIterator;
    private Map.Entry current;
    private int itemCount;
    private final int mods;
    private boolean canRemove;
    
    public BagIterator(AbstractMapBag parent)
    {
      this.parent = parent;
      entryIterator = map.entrySet().iterator();
      current = null;
      mods = modCount;
      canRemove = false;
    }
    
    public boolean hasNext()
    {
      return (itemCount > 0) || (entryIterator.hasNext());
    }
    
    public Object next()
    {
      if (parent.modCount != mods) {
        throw new ConcurrentModificationException();
      }
      if (itemCount == 0)
      {
        current = ((Map.Entry)entryIterator.next());
        itemCount = current.getValue()).value;
      }
      canRemove = true;
      itemCount -= 1;
      return current.getKey();
    }
    
    public void remove()
    {
      if (parent.modCount != mods) {
        throw new ConcurrentModificationException();
      }
      if (!canRemove) {
        throw new IllegalStateException();
      }
      AbstractMapBag.MutableInteger mut = (AbstractMapBag.MutableInteger)current.getValue();
      if (value > 1) {
        value -= 1;
      } else {
        entryIterator.remove();
      }
      AbstractMapBag.access$210(parent);
      canRemove = false;
    }
  }
  
  public boolean add(Object object)
  {
    return add(object, 1);
  }
  
  public boolean add(Object object, int nCopies)
  {
    modCount += 1;
    if (nCopies > 0)
    {
      MutableInteger mut = (MutableInteger)map.get(object);
      size += nCopies;
      if (mut == null)
      {
        map.put(object, new MutableInteger(nCopies));
        return true;
      }
      value += nCopies;
      return false;
    }
    return false;
  }
  
  public boolean addAll(Collection coll)
  {
    boolean changed = false;
    Iterator i = coll.iterator();
    while (i.hasNext())
    {
      boolean added = add(i.next());
      changed = (changed) || (added);
    }
    return changed;
  }
  
  public void clear()
  {
    modCount += 1;
    map.clear();
    size = 0;
  }
  
  public boolean remove(Object object)
  {
    MutableInteger mut = (MutableInteger)map.get(object);
    if (mut == null) {
      return false;
    }
    modCount += 1;
    map.remove(object);
    size -= value;
    return true;
  }
  
  public boolean remove(Object object, int nCopies)
  {
    MutableInteger mut = (MutableInteger)map.get(object);
    if (mut == null) {
      return false;
    }
    if (nCopies <= 0) {
      return false;
    }
    modCount += 1;
    if (nCopies < value)
    {
      value -= nCopies;
      size -= nCopies;
    }
    else
    {
      map.remove(object);
      size -= value;
    }
    return true;
  }
  
  public boolean removeAll(Collection coll)
  {
    boolean result = false;
    if (coll != null)
    {
      Iterator i = coll.iterator();
      while (i.hasNext())
      {
        boolean changed = remove(i.next(), 1);
        result = (result) || (changed);
      }
    }
    return result;
  }
  
  public boolean retainAll(Collection coll)
  {
    if ((coll instanceof Bag)) {
      return retainAll((Bag)coll);
    }
    return retainAll(new HashBag(coll));
  }
  
  boolean retainAll(Bag other)
  {
    boolean result = false;
    Bag excess = new HashBag();
    Iterator i = uniqueSet().iterator();
    while (i.hasNext())
    {
      Object current = i.next();
      int myCount = getCount(current);
      int otherCount = other.getCount(current);
      if ((1 <= otherCount) && (otherCount <= myCount)) {
        excess.add(current, myCount - otherCount);
      } else {
        excess.add(current, myCount);
      }
    }
    if (!excess.isEmpty()) {
      result = removeAll(excess);
    }
    return result;
  }
  
  protected static class MutableInteger
  {
    protected int value;
    
    MutableInteger(int value)
    {
      this.value = value;
    }
    
    public boolean equals(Object obj)
    {
      if (!(obj instanceof MutableInteger)) {
        return false;
      }
      return value == value;
    }
    
    public int hashCode()
    {
      return value;
    }
  }
  
  public Object[] toArray()
  {
    Object[] result = new Object[size()];
    int i = 0;
    Iterator it = map.keySet().iterator();
    while (it.hasNext())
    {
      Object current = it.next();
      for (int index = getCount(current); index > 0; index--) {
        result[(i++)] = current;
      }
    }
    return result;
  }
  
  public Object[] toArray(Object[] array)
  {
    int size = size();
    if (array.length < size) {
      array = (Object[])Array.newInstance(array.getClass().getComponentType(), size);
    }
    int i = 0;
    Iterator it = map.keySet().iterator();
    while (it.hasNext())
    {
      Object current = it.next();
      for (int index = getCount(current); index > 0; index--) {
        array[(i++)] = current;
      }
    }
    if (array.length > size) {
      array[size] = null;
    }
    return array;
  }
  
  public Set uniqueSet()
  {
    if (uniqueSet == null) {
      uniqueSet = UnmodifiableSet.decorate(map.keySet());
    }
    return uniqueSet;
  }
  
  protected void doWriteObject(ObjectOutputStream out)
    throws IOException
  {
    out.writeInt(map.size());
    for (Iterator it = map.entrySet().iterator(); it.hasNext();)
    {
      Map.Entry entry = (Map.Entry)it.next();
      out.writeObject(entry.getKey());
      out.writeInt(getValuevalue);
    }
  }
  
  protected void doReadObject(Map map, ObjectInputStream in)
    throws IOException, ClassNotFoundException
  {
    this.map = map;
    int entrySize = in.readInt();
    for (int i = 0; i < entrySize; i++)
    {
      Object obj = in.readObject();
      int count = in.readInt();
      map.put(obj, new MutableInteger(count));
      size += count;
    }
  }
  
  public boolean equals(Object object)
  {
    if (object == this) {
      return true;
    }
    if (!(object instanceof Bag)) {
      return false;
    }
    Bag other = (Bag)object;
    if (other.size() != size()) {
      return false;
    }
    for (Iterator it = map.keySet().iterator(); it.hasNext();)
    {
      Object element = it.next();
      if (other.getCount(element) != getCount(element)) {
        return false;
      }
    }
    return true;
  }
  
  public int hashCode()
  {
    int total = 0;
    for (Iterator it = map.entrySet().iterator(); it.hasNext();)
    {
      Map.Entry entry = (Map.Entry)it.next();
      Object element = entry.getKey();
      MutableInteger count = (MutableInteger)entry.getValue();
      total += ((element == null ? 0 : element.hashCode()) ^ value);
    }
    return total;
  }
  
  public String toString()
  {
    if (size() == 0) {
      return "[]";
    }
    StringBuffer buf = new StringBuffer();
    buf.append('[');
    Iterator it = uniqueSet().iterator();
    while (it.hasNext())
    {
      Object current = it.next();
      int count = getCount(current);
      buf.append(count);
      buf.append(':');
      buf.append(current);
      if (it.hasNext()) {
        buf.append(',');
      }
    }
    buf.append(']');
    return buf.toString();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.AbstractMapBag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import java.util.Comparator;
import org.apache.commons.collections.SortedBag;

public abstract class AbstractSortedBagDecorator
  extends AbstractBagDecorator
  implements SortedBag
{
  protected AbstractSortedBagDecorator() {}
  
  protected AbstractSortedBagDecorator(SortedBag bag)
  {
    super(bag);
  }
  
  protected SortedBag getSortedBag()
  {
    return (SortedBag)getCollection();
  }
  
  public Object first()
  {
    return getSortedBag().first();
  }
  
  public Object last()
  {
    return getSortedBag().last();
  }
  
  public Comparator comparator()
  {
    return getSortedBag().comparator();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.AbstractSortedBagDecorator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import org.apache.commons.collections.Bag;

public class HashBag
  extends AbstractMapBag
  implements Bag, Serializable
{
  private static final long serialVersionUID = -6561115435802554013L;
  
  public HashBag()
  {
    super(new HashMap());
  }
  
  public HashBag(Collection coll)
  {
    this();
    addAll(coll);
  }
  
  private void writeObject(ObjectOutputStream out)
    throws IOException
  {
    out.defaultWriteObject();
    super.doWriteObject(out);
  }
  
  private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
  {
    in.defaultReadObject();
    super.doReadObject(new HashMap(), in);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.HashBag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import java.util.Set;
import org.apache.commons.collections.Bag;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.collection.PredicatedCollection;

public class PredicatedBag
  extends PredicatedCollection
  implements Bag
{
  private static final long serialVersionUID = -2575833140344736876L;
  
  public static Bag decorate(Bag bag, Predicate predicate)
  {
    return new PredicatedBag(bag, predicate);
  }
  
  protected PredicatedBag(Bag bag, Predicate predicate)
  {
    super(bag, predicate);
  }
  
  protected Bag getBag()
  {
    return (Bag)getCollection();
  }
  
  public boolean add(Object object, int count)
  {
    validate(object);
    return getBag().add(object, count);
  }
  
  public boolean remove(Object object, int count)
  {
    return getBag().remove(object, count);
  }
  
  public Set uniqueSet()
  {
    return getBag().uniqueSet();
  }
  
  public int getCount(Object object)
  {
    return getBag().getCount(object);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.PredicatedBag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import java.util.Comparator;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.SortedBag;

public class PredicatedSortedBag
  extends PredicatedBag
  implements SortedBag
{
  private static final long serialVersionUID = 3448581314086406616L;
  
  public static SortedBag decorate(SortedBag bag, Predicate predicate)
  {
    return new PredicatedSortedBag(bag, predicate);
  }
  
  protected PredicatedSortedBag(SortedBag bag, Predicate predicate)
  {
    super(bag, predicate);
  }
  
  protected SortedBag getSortedBag()
  {
    return (SortedBag)getCollection();
  }
  
  public Object first()
  {
    return getSortedBag().first();
  }
  
  public Object last()
  {
    return getSortedBag().last();
  }
  
  public Comparator comparator()
  {
    return getSortedBag().comparator();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.PredicatedSortedBag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import java.util.Set;
import org.apache.commons.collections.set.SynchronizedSet;

class SynchronizedBag$SynchronizedBagSet
  extends SynchronizedSet
{
  private final SynchronizedBag this$0;
  
  SynchronizedBag$SynchronizedBagSet(SynchronizedBag paramSynchronizedBag, Set set, Object lock)
  {
    super(set, lock);this$0 = paramSynchronizedBag;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.SynchronizedBag.SynchronizedBagSet
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import java.util.Set;
import org.apache.commons.collections.Bag;
import org.apache.commons.collections.collection.SynchronizedCollection;
import org.apache.commons.collections.set.SynchronizedSet;

public class SynchronizedBag
  extends SynchronizedCollection
  implements Bag
{
  private static final long serialVersionUID = 8084674570753837109L;
  
  public static Bag decorate(Bag bag)
  {
    return new SynchronizedBag(bag);
  }
  
  protected SynchronizedBag(Bag bag)
  {
    super(bag);
  }
  
  protected SynchronizedBag(Bag bag, Object lock)
  {
    super(bag, lock);
  }
  
  protected Bag getBag()
  {
    return (Bag)collection;
  }
  
  /* Error */
  public boolean add(Object object, int count)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 7	org/apache/commons/collections/bag/SynchronizedBag:lock	Ljava/lang/Object;
    //   4: dup
    //   5: astore_3
    //   6: monitorenter
    //   7: aload_0
    //   8: invokevirtual 8	org/apache/commons/collections/bag/SynchronizedBag:getBag	()Lorg/apache/commons/collections/Bag;
    //   11: aload_1
    //   12: iload_2
    //   13: invokeinterface 9 3 0
    //   18: aload_3
    //   19: monitorexit
    //   20: ireturn
    //   21: astore 4
    //   23: aload_3
    //   24: monitorexit
    //   25: aload 4
    //   27: athrow
    // Line number table:
    //   Java source line #89	-> byte code offset #0
    //   Java source line #90	-> byte code offset #7
    //   Java source line #91	-> byte code offset #21
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	28	0	this	SynchronizedBag
    //   0	28	1	object	Object
    //   0	28	2	count	int
    //   5	19	3	Ljava/lang/Object;	Object
    //   21	5	4	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   7	20	21	finally
    //   21	25	21	finally
  }
  
  /* Error */
  public boolean remove(Object object, int count)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 7	org/apache/commons/collections/bag/SynchronizedBag:lock	Ljava/lang/Object;
    //   4: dup
    //   5: astore_3
    //   6: monitorenter
    //   7: aload_0
    //   8: invokevirtual 8	org/apache/commons/collections/bag/SynchronizedBag:getBag	()Lorg/apache/commons/collections/Bag;
    //   11: aload_1
    //   12: iload_2
    //   13: invokeinterface 10 3 0
    //   18: aload_3
    //   19: monitorexit
    //   20: ireturn
    //   21: astore 4
    //   23: aload_3
    //   24: monitorexit
    //   25: aload 4
    //   27: athrow
    // Line number table:
    //   Java source line #95	-> byte code offset #0
    //   Java source line #96	-> byte code offset #7
    //   Java source line #97	-> byte code offset #21
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	28	0	this	SynchronizedBag
    //   0	28	1	object	Object
    //   0	28	2	count	int
    //   5	19	3	Ljava/lang/Object;	Object
    //   21	5	4	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   7	20	21	finally
    //   21	25	21	finally
  }
  
  public Set uniqueSet()
  {
    synchronized (lock)
    {
      Set set = getBag().uniqueSet();
      return new SynchronizedBagSet(set, lock);
    }
  }
  
  /* Error */
  public int getCount(Object object)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 7	org/apache/commons/collections/bag/SynchronizedBag:lock	Ljava/lang/Object;
    //   4: dup
    //   5: astore_2
    //   6: monitorenter
    //   7: aload_0
    //   8: invokevirtual 8	org/apache/commons/collections/bag/SynchronizedBag:getBag	()Lorg/apache/commons/collections/Bag;
    //   11: aload_1
    //   12: invokeinterface 14 2 0
    //   17: aload_2
    //   18: monitorexit
    //   19: ireturn
    //   20: astore_3
    //   21: aload_2
    //   22: monitorexit
    //   23: aload_3
    //   24: athrow
    // Line number table:
    //   Java source line #108	-> byte code offset #0
    //   Java source line #109	-> byte code offset #7
    //   Java source line #110	-> byte code offset #20
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	25	0	this	SynchronizedBag
    //   0	25	1	object	Object
    //   5	17	2	Ljava/lang/Object;	Object
    //   20	4	3	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   7	19	20	finally
    //   20	23	20	finally
  }
  
  class SynchronizedBagSet
    extends SynchronizedSet
  {
    SynchronizedBagSet(Set set, Object lock)
    {
      super(lock);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.SynchronizedBag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import org.apache.commons.collections.Bag;
import org.apache.commons.collections.SortedBag;

public class SynchronizedSortedBag
  extends SynchronizedBag
  implements SortedBag
{
  private static final long serialVersionUID = 722374056718497858L;
  
  public static SortedBag decorate(SortedBag bag)
  {
    return new SynchronizedSortedBag(bag);
  }
  
  protected SynchronizedSortedBag(SortedBag bag)
  {
    super(bag);
  }
  
  protected SynchronizedSortedBag(Bag bag, Object lock)
  {
    super(bag, lock);
  }
  
  protected SortedBag getSortedBag()
  {
    return (SortedBag)collection;
  }
  
  /* Error */
  public synchronized Object first()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 7	org/apache/commons/collections/bag/SynchronizedSortedBag:lock	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: invokevirtual 8	org/apache/commons/collections/bag/SynchronizedSortedBag:getSortedBag	()Lorg/apache/commons/collections/SortedBag;
    //   11: invokeinterface 9 1 0
    //   16: aload_1
    //   17: monitorexit
    //   18: areturn
    //   19: astore_2
    //   20: aload_1
    //   21: monitorexit
    //   22: aload_2
    //   23: athrow
    // Line number table:
    //   Java source line #88	-> byte code offset #0
    //   Java source line #89	-> byte code offset #7
    //   Java source line #90	-> byte code offset #19
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	24	0	this	SynchronizedSortedBag
    //   5	16	1	Ljava/lang/Object;	Object
    //   19	4	2	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   7	18	19	finally
    //   19	22	19	finally
  }
  
  /* Error */
  public synchronized Object last()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 7	org/apache/commons/collections/bag/SynchronizedSortedBag:lock	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: invokevirtual 8	org/apache/commons/collections/bag/SynchronizedSortedBag:getSortedBag	()Lorg/apache/commons/collections/SortedBag;
    //   11: invokeinterface 10 1 0
    //   16: aload_1
    //   17: monitorexit
    //   18: areturn
    //   19: astore_2
    //   20: aload_1
    //   21: monitorexit
    //   22: aload_2
    //   23: athrow
    // Line number table:
    //   Java source line #94	-> byte code offset #0
    //   Java source line #95	-> byte code offset #7
    //   Java source line #96	-> byte code offset #19
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	24	0	this	SynchronizedSortedBag
    //   5	16	1	Ljava/lang/Object;	Object
    //   19	4	2	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   7	18	19	finally
    //   19	22	19	finally
  }
  
  /* Error */
  public synchronized java.util.Comparator comparator()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 7	org/apache/commons/collections/bag/SynchronizedSortedBag:lock	Ljava/lang/Object;
    //   4: dup
    //   5: astore_1
    //   6: monitorenter
    //   7: aload_0
    //   8: invokevirtual 8	org/apache/commons/collections/bag/SynchronizedSortedBag:getSortedBag	()Lorg/apache/commons/collections/SortedBag;
    //   11: invokeinterface 11 1 0
    //   16: aload_1
    //   17: monitorexit
    //   18: areturn
    //   19: astore_2
    //   20: aload_1
    //   21: monitorexit
    //   22: aload_2
    //   23: athrow
    // Line number table:
    //   Java source line #100	-> byte code offset #0
    //   Java source line #101	-> byte code offset #7
    //   Java source line #102	-> byte code offset #19
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	24	0	this	SynchronizedSortedBag
    //   5	16	1	Ljava/lang/Object;	Object
    //   19	4	2	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   7	18	19	finally
    //   19	22	19	finally
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.SynchronizedSortedBag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import java.util.Set;
import org.apache.commons.collections.Bag;
import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.collection.TransformedCollection;
import org.apache.commons.collections.set.TransformedSet;

public class TransformedBag
  extends TransformedCollection
  implements Bag
{
  private static final long serialVersionUID = 5421170911299074185L;
  
  public static Bag decorate(Bag bag, Transformer transformer)
  {
    return new TransformedBag(bag, transformer);
  }
  
  protected TransformedBag(Bag bag, Transformer transformer)
  {
    super(bag, transformer);
  }
  
  protected Bag getBag()
  {
    return (Bag)collection;
  }
  
  public int getCount(Object object)
  {
    return getBag().getCount(object);
  }
  
  public boolean remove(Object object, int nCopies)
  {
    return getBag().remove(object, nCopies);
  }
  
  public boolean add(Object object, int nCopies)
  {
    object = transform(object);
    return getBag().add(object, nCopies);
  }
  
  public Set uniqueSet()
  {
    Set set = getBag().uniqueSet();
    return TransformedSet.decorate(set, transformer);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.TransformedBag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import java.util.Comparator;
import org.apache.commons.collections.SortedBag;
import org.apache.commons.collections.Transformer;

public class TransformedSortedBag
  extends TransformedBag
  implements SortedBag
{
  private static final long serialVersionUID = -251737742649401930L;
  
  public static SortedBag decorate(SortedBag bag, Transformer transformer)
  {
    return new TransformedSortedBag(bag, transformer);
  }
  
  protected TransformedSortedBag(SortedBag bag, Transformer transformer)
  {
    super(bag, transformer);
  }
  
  protected SortedBag getSortedBag()
  {
    return (SortedBag)collection;
  }
  
  public Object first()
  {
    return getSortedBag().first();
  }
  
  public Object last()
  {
    return getSortedBag().last();
  }
  
  public Comparator comparator()
  {
    return getSortedBag().comparator();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.TransformedSortedBag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Collection;
import java.util.Comparator;
import java.util.SortedMap;
import java.util.TreeMap;
import org.apache.commons.collections.SortedBag;

public class TreeBag
  extends AbstractMapBag
  implements SortedBag, Serializable
{
  private static final long serialVersionUID = -7740146511091606676L;
  
  public TreeBag()
  {
    super(new TreeMap());
  }
  
  public TreeBag(Comparator comparator)
  {
    super(new TreeMap(comparator));
  }
  
  public TreeBag(Collection coll)
  {
    this();
    addAll(coll);
  }
  
  public Object first()
  {
    return ((SortedMap)getMap()).firstKey();
  }
  
  public Object last()
  {
    return ((SortedMap)getMap()).lastKey();
  }
  
  public Comparator comparator()
  {
    return ((SortedMap)getMap()).comparator();
  }
  
  private void writeObject(ObjectOutputStream out)
    throws IOException
  {
    out.defaultWriteObject();
    out.writeObject(comparator());
    super.doWriteObject(out);
  }
  
  private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
  {
    in.defaultReadObject();
    Comparator comp = (Comparator)in.readObject();
    super.doReadObject(new TreeMap(comp), in);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.TreeBag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import org.apache.commons.collections.Bag;
import org.apache.commons.collections.functors.InstanceofPredicate;

public class TypedBag
{
  public static Bag decorate(Bag bag, Class type)
  {
    return new PredicatedBag(bag, InstanceofPredicate.getInstance(type));
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.TypedBag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import org.apache.commons.collections.SortedBag;
import org.apache.commons.collections.functors.InstanceofPredicate;

public class TypedSortedBag
{
  public static SortedBag decorate(SortedBag bag, Class type)
  {
    return new PredicatedSortedBag(bag, InstanceofPredicate.getInstance(type));
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.TypedSortedBag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import org.apache.commons.collections.Bag;
import org.apache.commons.collections.Unmodifiable;
import org.apache.commons.collections.iterators.UnmodifiableIterator;
import org.apache.commons.collections.set.UnmodifiableSet;

public final class UnmodifiableBag
  extends AbstractBagDecorator
  implements Unmodifiable, Serializable
{
  private static final long serialVersionUID = -1873799975157099624L;
  
  public static Bag decorate(Bag bag)
  {
    if ((bag instanceof Unmodifiable)) {
      return bag;
    }
    return new UnmodifiableBag(bag);
  }
  
  private UnmodifiableBag(Bag bag)
  {
    super(bag);
  }
  
  private void writeObject(ObjectOutputStream out)
    throws IOException
  {
    out.defaultWriteObject();
    out.writeObject(collection);
  }
  
  private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
  {
    in.defaultReadObject();
    collection = ((Collection)in.readObject());
  }
  
  public Iterator iterator()
  {
    return UnmodifiableIterator.decorate(getCollection().iterator());
  }
  
  public boolean add(Object object)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean addAll(Collection coll)
  {
    throw new UnsupportedOperationException();
  }
  
  public void clear()
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean remove(Object object)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean removeAll(Collection coll)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean retainAll(Collection coll)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean add(Object object, int count)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean remove(Object object, int count)
  {
    throw new UnsupportedOperationException();
  }
  
  public Set uniqueSet()
  {
    Set set = getBag().uniqueSet();
    return UnmodifiableSet.decorate(set);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.UnmodifiableBag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.bag;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import org.apache.commons.collections.Bag;
import org.apache.commons.collections.SortedBag;
import org.apache.commons.collections.Unmodifiable;
import org.apache.commons.collections.iterators.UnmodifiableIterator;
import org.apache.commons.collections.set.UnmodifiableSet;

public final class UnmodifiableSortedBag
  extends AbstractSortedBagDecorator
  implements Unmodifiable, Serializable
{
  private static final long serialVersionUID = -3190437252665717841L;
  
  public static SortedBag decorate(SortedBag bag)
  {
    if ((bag instanceof Unmodifiable)) {
      return bag;
    }
    return new UnmodifiableSortedBag(bag);
  }
  
  private UnmodifiableSortedBag(SortedBag bag)
  {
    super(bag);
  }
  
  private void writeObject(ObjectOutputStream out)
    throws IOException
  {
    out.defaultWriteObject();
    out.writeObject(collection);
  }
  
  private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
  {
    in.defaultReadObject();
    collection = ((Collection)in.readObject());
  }
  
  public Iterator iterator()
  {
    return UnmodifiableIterator.decorate(getCollection().iterator());
  }
  
  public boolean add(Object object)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean addAll(Collection coll)
  {
    throw new UnsupportedOperationException();
  }
  
  public void clear()
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean remove(Object object)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean removeAll(Collection coll)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean retainAll(Collection coll)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean add(Object object, int count)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean remove(Object object, int count)
  {
    throw new UnsupportedOperationException();
  }
  
  public Set uniqueSet()
  {
    Set set = getBag().uniqueSet();
    return UnmodifiableSet.decorate(set);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.bag.UnmodifiableSortedBag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections;

import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

public abstract interface Bag
  extends Collection
{
  public abstract int getCount(Object paramObject);
  
  public abstract boolean add(Object paramObject);
  
  public abstract boolean add(Object paramObject, int paramInt);
  
  public abstract boolean remove(Object paramObject);
  
  public abstract boolean remove(Object paramObject, int paramInt);
  
  public abstract Set uniqueSet();
  
  public abstract int size();
  
  public abstract boolean containsAll(Collection paramCollection);
  
  public abstract boolean removeAll(Collection paramCollection);
  
  public abstract boolean retainAll(Collection paramCollection);
  
  public abstract Iterator iterator();
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.Bag
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections;

import org.apache.commons.collections.bag.HashBag;
import org.apache.commons.collections.bag.PredicatedBag;
import org.apache.commons.collections.bag.PredicatedSortedBag;
import org.apache.commons.collections.bag.SynchronizedBag;
import org.apache.commons.collections.bag.SynchronizedSortedBag;
import org.apache.commons.collections.bag.TransformedBag;
import org.apache.commons.collections.bag.TransformedSortedBag;
import org.apache.commons.collections.bag.TreeBag;
import org.apache.commons.collections.bag.TypedBag;
import org.apache.commons.collections.bag.TypedSortedBag;
import org.apache.commons.collections.bag.UnmodifiableBag;
import org.apache.commons.collections.bag.UnmodifiableSortedBag;

public class BagUtils
{
  public static final Bag EMPTY_BAG = UnmodifiableBag.decorate(new HashBag());
  public static final Bag EMPTY_SORTED_BAG = UnmodifiableSortedBag.decorate(new TreeBag());
  
  public static Bag synchronizedBag(Bag bag)
  {
    return SynchronizedBag.decorate(bag);
  }
  
  public static Bag unmodifiableBag(Bag bag)
  {
    return UnmodifiableBag.decorate(bag);
  }
  
  public static Bag predicatedBag(Bag bag, Predicate predicate)
  {
    return PredicatedBag.decorate(bag, predicate);
  }
  
  public static Bag typedBag(Bag bag, Class type)
  {
    return TypedBag.decorate(bag, type);
  }
  
  public static Bag transformedBag(Bag bag, Transformer transformer)
  {
    return TransformedBag.decorate(bag, transformer);
  }
  
  public static SortedBag synchronizedSortedBag(SortedBag bag)
  {
    return Synchro
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

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