Implemented some of the trivial missing JRE APIs.

Suggested by: amitmanjhi


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2528 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/super/com/google/gwt/emul/java/lang/UnsupportedOperationException.java b/user/super/com/google/gwt/emul/java/lang/UnsupportedOperationException.java
index a461072..0904d82 100644
--- a/user/super/com/google/gwt/emul/java/lang/UnsupportedOperationException.java
+++ b/user/super/com/google/gwt/emul/java/lang/UnsupportedOperationException.java
@@ -29,4 +29,11 @@
     super(message);
   }
 
+  public UnsupportedOperationException(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  public UnsupportedOperationException(Throwable cause) {
+    super(cause);
+  }
 }
diff --git a/user/super/com/google/gwt/emul/java/util/ArrayList.java b/user/super/com/google/gwt/emul/java/util/ArrayList.java
index f747fa3..359003c 100644
--- a/user/super/com/google/gwt/emul/java/util/ArrayList.java
+++ b/user/super/com/google/gwt/emul/java/util/ArrayList.java
@@ -219,30 +219,6 @@
     setCapacity(array, size);
   }
 
-  protected int indexOf(Object o, int index) {
-    if (index < 0) {
-      indexOutOfBounds(index, size);
-    }
-    for (; index < size; ++index) {
-      if (Utility.equalsWithNullCheck(o, array[index])) {
-        return index;
-      }
-    }
-    return -1;
-  }
-
-  protected int lastIndexOf(Object o, int index) {
-    if (index >= size) {
-      indexOutOfBounds(index, size);
-    }
-    for (; index >= 0; --index) {
-      if (Utility.equalsWithNullCheck(o, array[index])) {
-        return index;
-      }
-    }
-    return -1;
-  }
-
   @Override
   protected void removeRange(int fromIndex, int endIndex) {
     checkIndex(fromIndex, size);
@@ -255,12 +231,40 @@
   }
 
   /**
-   * This function sets the size of the array, and is used by Vector.
+   * Used by Vector.
    */
-  protected void setSize(int newSize) {
-    if (newSize < 0) {
-      indexOutOfBounds(newSize, size);
+  int capacity() {
+    return array.length;
+  }
+
+  /**
+   * Used by Vector.
+   */
+  int indexOf(Object o, int index) {
+    for (; index < size; ++index) {
+      if (Utility.equalsWithNullCheck(o, array[index])) {
+        return index;
+      }
     }
+    return -1;
+  }
+
+  /**
+   * Used by Vector.
+   */
+  int lastIndexOf(Object o, int index) {
+    for (; index >= 0; --index) {
+      if (Utility.equalsWithNullCheck(o, array[index])) {
+        return index;
+      }
+    }
+    return -1;
+  }
+
+  /**
+   * Used by Vector.
+   */
+  void setSize(int newSize) {
     setCapacity(array, newSize);
     size = newSize;
   }
diff --git a/user/super/com/google/gwt/emul/java/util/EventObject.java b/user/super/com/google/gwt/emul/java/util/EventObject.java
index 2fb1d8a..7dde9d5 100644
--- a/user/super/com/google/gwt/emul/java/util/EventObject.java
+++ b/user/super/com/google/gwt/emul/java/util/EventObject.java
@@ -20,7 +20,7 @@
  */
 public class EventObject {
 
-  private Object source;
+  protected transient Object source;
 
   public EventObject(Object source) {
     this.source = source;
diff --git a/user/super/com/google/gwt/emul/java/util/PriorityQueue.java b/user/super/com/google/gwt/emul/java/util/PriorityQueue.java
index 48962e5..b411175 100644
--- a/user/super/com/google/gwt/emul/java/util/PriorityQueue.java
+++ b/user/super/com/google/gwt/emul/java/util/PriorityQueue.java
@@ -62,6 +62,10 @@
     addAll(c);
   }
 
+  public Comparator<? super E> comparator() {
+    return cmp;
+  }
+
   @Override
   public Iterator<E> iterator() {
     // TODO(jat): perhaps a better way to do this
diff --git a/user/super/com/google/gwt/emul/java/util/TooManyListenersException.java b/user/super/com/google/gwt/emul/java/util/TooManyListenersException.java
index f77164c..1077275 100644
--- a/user/super/com/google/gwt/emul/java/util/TooManyListenersException.java
+++ b/user/super/com/google/gwt/emul/java/util/TooManyListenersException.java
@@ -20,4 +20,11 @@
  * 
  */
 public class TooManyListenersException extends Exception {
+
+  public TooManyListenersException() {
+  }
+
+  public TooManyListenersException(String message) {
+    super(message);
+  }
 }
diff --git a/user/super/com/google/gwt/emul/java/util/Vector.java b/user/super/com/google/gwt/emul/java/util/Vector.java
index 1edcb4f..d0d58dd 100644
--- a/user/super/com/google/gwt/emul/java/util/Vector.java
+++ b/user/super/com/google/gwt/emul/java/util/Vector.java
@@ -39,15 +39,18 @@
     addAll(c);
   }
 
-  /**
-   * There is no speed advantage to pre-allocating array sizes in JavaScript, so
-   * the <code>intialCapacity</code> parameter is ignored. This constructor is
-   * only present for compatibility with JDK 1.5's API.
-   */
   public Vector(int initialCapacity) {
     arrayList = new ArrayList<E>(initialCapacity);
   }
 
+  /**
+   * Capacity increment is ignored.
+   */
+  @SuppressWarnings("unused")
+  public Vector(int initialCapacity, int ignoredCapacityIncrement) {
+    this(initialCapacity);
+  }
+
   @Override
   public boolean add(E o) {
     return arrayList.add(o);
@@ -72,6 +75,10 @@
     add(o);
   }
 
+  public int capacity() {
+    return arrayList.capacity();
+  }
+
   @Override
   public void clear() {
     arrayList.clear();
@@ -88,8 +95,7 @@
 
   @Override
   public boolean containsAll(Collection<?> c) {
-    // TODO(jat): implement
-    throw new UnsupportedOperationException("containsAll not implemented");
+    return arrayList.containsAll(c);
   }
 
   public void copyInto(Object[] objs) {
@@ -105,15 +111,11 @@
   }
 
   public Enumeration<E> elements() {
-    // TODO(jat): implement
-    return null;
+    return Collections.enumeration(arrayList);
   }
 
-  /**
-   * There is no speed advantage to pre-allocating array sizes in JavaScript.
-   * This method is only present for compatibility with the JRE.
-   */
-  public void ensureCapacity(int ignoredCapacity) {
+  public void ensureCapacity(int capacity) {
+   arrayList.ensureCapacity(capacity);
   }
 
   public E firstElement() {
@@ -131,6 +133,9 @@
   }
 
   public int indexOf(Object elem, int index) {
+    if (index < 0) {
+      indexOutOfBounds(index, size());
+    }
     return arrayList.indexOf(elem, index);
   }
 
@@ -162,6 +167,9 @@
   }
 
   public int lastIndexOf(Object o, int index) {
+    if (index >= size()) {
+      indexOutOfBounds(index, size());
+    }
     return arrayList.lastIndexOf(o, index);
   }
 
@@ -172,8 +180,7 @@
 
   @Override
   public boolean removeAll(Collection<?> c) {
-    // TODO(jat): implement
-    throw new UnsupportedOperationException("removeAll not implemented");
+    return arrayList.removeAll(c);
   }
 
   public void removeAllElements() {
@@ -198,6 +205,9 @@
   }
 
   public void setSize(int size) {
+    if (size < 0) {
+      throw new ArrayIndexOutOfBoundsException();
+    }
     arrayList.setSize(size);
   }