aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/util
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/util')
-rw-r--r--libjava/java/util/AbstractCollection.java339
-rw-r--r--libjava/java/util/AbstractList.java558
-rw-r--r--libjava/java/util/Arrays.java1757
-rw-r--r--libjava/java/util/BitSet.java177
-rw-r--r--libjava/java/util/Calendar.java274
-rw-r--r--libjava/java/util/Collection.java37
-rw-r--r--libjava/java/util/Comparator.java24
-rw-r--r--libjava/java/util/ConcurrentModificationException.java33
-rw-r--r--libjava/java/util/Date.java483
-rw-r--r--libjava/java/util/Dictionary.java34
-rw-r--r--libjava/java/util/EmptyStackException.java27
-rw-r--r--libjava/java/util/Enumeration.java24
-rw-r--r--libjava/java/util/EventListener.java24
-rw-r--r--libjava/java/util/EventObject.java42
-rw-r--r--libjava/java/util/GregorianCalendar.java266
-rw-r--r--libjava/java/util/Hashtable.java392
-rw-r--r--libjava/java/util/Iterator.java25
-rw-r--r--libjava/java/util/List.java47
-rw-r--r--libjava/java/util/ListIterator.java31
-rw-r--r--libjava/java/util/ListResourceBundle.java52
-rw-r--r--libjava/java/util/Locale.java148
-rw-r--r--libjava/java/util/MissingResourceException.java43
-rw-r--r--libjava/java/util/NoSuchElementException.java32
-rw-r--r--libjava/java/util/Observable.java98
-rw-r--r--libjava/java/util/Observer.java24
-rw-r--r--libjava/java/util/Properties.java391
-rw-r--r--libjava/java/util/PropertyResourceBundle.java47
-rw-r--r--libjava/java/util/Random.java148
-rw-r--r--libjava/java/util/ResourceBundle.java218
-rw-r--r--libjava/java/util/SimpleTimeZone.java208
-rw-r--r--libjava/java/util/Stack.java74
-rw-r--r--libjava/java/util/StringTokenizer.java185
-rw-r--r--libjava/java/util/TimeZone.java187
-rw-r--r--libjava/java/util/TooManyListenersException.java32
-rw-r--r--libjava/java/util/Vector.java461
-rw-r--r--libjava/java/util/jar/JarEntry.java39
-rw-r--r--libjava/java/util/jar/JarFile.java56
-rw-r--r--libjava/java/util/jar/JarInputStream.java32
-rw-r--r--libjava/java/util/natGregorianCalendar.cc114
-rw-r--r--libjava/java/util/zip/Adler32.java101
-rw-r--r--libjava/java/util/zip/CRC32.java70
-rw-r--r--libjava/java/util/zip/CheckedInputStream.java80
-rw-r--r--libjava/java/util/zip/CheckedOutputStream.java54
-rw-r--r--libjava/java/util/zip/Checksum.java31
-rw-r--r--libjava/java/util/zip/DataFormatException.java33
-rw-r--r--libjava/java/util/zip/Deflater.java129
-rw-r--r--libjava/java/util/zip/DeflaterOutputStream.java87
-rw-r--r--libjava/java/util/zip/GZIPInputStream.java154
-rw-r--r--libjava/java/util/zip/GZIPOutputStream.java93
-rw-r--r--libjava/java/util/zip/Inflater.java98
-rw-r--r--libjava/java/util/zip/InflaterInputStream.java109
-rw-r--r--libjava/java/util/zip/ZipConstants.java18
-rw-r--r--libjava/java/util/zip/ZipEntry.java177
-rw-r--r--libjava/java/util/zip/ZipException.java33
-rw-r--r--libjava/java/util/zip/ZipFile.java193
-rw-r--r--libjava/java/util/zip/ZipInputStream.java229
-rw-r--r--libjava/java/util/zip/ZipOutputStream.java276
-rw-r--r--libjava/java/util/zip/natDeflater.cc214
-rw-r--r--libjava/java/util/zip/natInflater.cc206
59 files changed, 0 insertions, 9568 deletions
diff --git a/libjava/java/util/AbstractCollection.java b/libjava/java/util/AbstractCollection.java
deleted file mode 100644
index 800204441de..00000000000
--- a/libjava/java/util/AbstractCollection.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/* AbstractCollection.java -- Abstract implementation of most of Collection
- Copyright (C) 1998 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-As a special exception, if you link this library with other files to
-produce an executable, this library does not by itself cause the
-resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why the
-executable file might be covered by the GNU General Public License. */
-
-
-package java.util;
-
-import java.lang.reflect.Array;
-
-/**
- * A basic implementation of most of the methods in the Collection interface to
- * make it easier to create a collection. To create an unmodifiable Collection,
- * just subclass AbstractCollection and provide implementations of the
- * iterator() and size() methods. The Iterator returned by iterator() need only
- * provide implementations of hasNext() and next() (that is, it may throw an
- * UnsupportedOperationException if remove() is called). To create a modifiable
- * Collection, you must in addition provide an implementation of the
- * add(Object) method and the Iterator returned by iterator() must provide an
- * implementation of remove(). Other methods should be overridden if the
- * backing data structure allows for a more efficient implementation. The
- * precise implementation used by AbstractCollection is documented, so that
- * subclasses can tell which methods could be implemented more efficiently.
- */
-public abstract class AbstractCollection implements Collection {
-
- /**
- * Return an Iterator over this collection. The iterator must provide the
- * hasNext and next methods and should in addition provide remove if the
- * collection is modifiable.
- */
- public abstract Iterator iterator();
-
- /**
- * Return the number of elements in this collection.
- */
- public abstract int size();
-
- /**
- * Add an object to the collection. This implementation always throws an
- * UnsupportedOperationException - it should be overridden if the collection
- * is to be modifiable.
- *
- * @param o the object to add
- * @return true if the add operation caused the Collection to change
- * @exception UnsupportedOperationException if the add operation is not
- * supported on this collection
- */
- public boolean add(Object o) {
- throw new java.lang.UnsupportedOperationException();
- }
-
- /**
- * Add all the elements of a given collection to this collection. This
- * implementation obtains an Iterator over the given collection and iterates
- * over it, adding each element with the add(Object) method (thus this method
- * will fail with an UnsupportedOperationException if the add method does).
- *
- * @param c the collection to add the elements of to this collection
- * @return true if the add operation caused the Collection to change
- * @exception UnsupportedOperationException if the add operation is not
- * supported on this collection
- */
- public boolean addAll(Collection c) {
- Iterator i = c.iterator();
- boolean modified = false;
- while (i.hasNext()) {
- modified |= add(i.next());
- }
- return modified;
- }
-
- /**
- * Remove all elements from the collection. This implementation obtains an
- * iterator over the collection and calls next and remove on it repeatedly
- * (thus this method will fail with an UnsupportedOperationException if the
- * Iterator's remove method does) until there are no more elements to remove.
- * Many implementations will have a faster way of doing this.
- *
- * @exception UnsupportedOperationException if the Iterator returned by
- * iterator does not provide an implementation of remove
- */
- public void clear() {
- Iterator i = iterator();
- while (i.hasNext()) {
- i.next();
- i.remove();
- }
- }
-
- /**
- * Test whether this collection contains a given object. That is, if the
- * collection has an element e such that (o == null ? e == null :
- * o.equals(e)). This implementation obtains an iterator over the collection
- * and iterates over it, testing each element for equality with the given
- * object. If it is equal, true is returned. Otherwise false is returned when
- * the end of the collection is reached.
- *
- * @param o the object to remove from this collection
- * @return true if this collection contains an object equal to o
- */
- public boolean contains(Object o) {
- Iterator i = iterator();
-
- // This looks crazily inefficient, but it takes the test o==null outside
- // the loop, saving time, and also saves needing to store the result of
- // i.next() each time.
- if (o == null) {
- while (i.hasNext()) {
- if (i.next() == null) {
- return true;
- }
- }
- } else {
- while (i.hasNext()) {
- if (o.equals(i.next())) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Tests whether this collection contains all the elements in a given
- * collection. This implementation iterates over the given collection,
- * testing whether each element is contained in this collection. If any one
- * is not, false is returned. Otherwise true is returned.
- *
- * @param c the collection to test against
- * @return true if this collection contains all the elements in the given
- * collection
- */
- public boolean containsAll(Collection c) {
- Iterator i = c.iterator();
- while (i.hasNext()) {
- if (!contains(i.next())) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Test whether this collection is empty. This implementation returns
- * size() == 0.
- *
- * @return true if this collection is empty.
- */
- public boolean isEmpty() {
- return size() == 0;
- }
-
- /**
- * Remove a single instance of an object from this collection. That is,
- * remove one element e such that (o == null ? e == null : o.equals(e)), if
- * such an element exists. This implementation obtains an iterator over the
- * collection and iterates over it, testing each element for equality with
- * the given object. If it is equal, it is removed by the iterator's remove
- * method (thus this method will fail with an UnsupportedOperationException
- * if the Iterator's remove method does). After the first element has been
- * removed, true is returned; if the end of the collection is reached, false
- * is returned.
- *
- * @param o the object to remove from this collection
- * @return true if the remove operation caused the Collection to change, or
- * equivalently if the collection did contain o.
- * @exception UnsupportedOperationException if this collection's Iterator
- * does not support the remove method
- */
- public boolean remove(Object o) {
- Iterator i = iterator();
-
- // This looks crazily inefficient, but it takes the test o==null outside
- // the loop, saving time, and also saves needing to store the result of
- // i.next() each time.
- if (o == null) {
- while (i.hasNext()) {
- if (i.next() == null) {
- i.remove();
- return true;
- }
- }
- } else {
- while (i.hasNext()) {
- if (o.equals(i.next())) {
- i.remove();
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Remove from this collection all its elements that are contained in a given
- * collection. This implementation iterates over this collection, and for
- * each element tests if it is contained in the given collection. If so, it
- * is removed by the Iterator's remove method (thus this method will fail
- * with an UnsupportedOperationException if the Iterator's remove method
- * does).
- *
- * @param c the collection to remove the elements of
- * @return true if the remove operation caused the Collection to change
- * @exception UnsupportedOperationException if this collection's Iterator
- * does not support the remove method
- */
- public boolean removeAll(Collection c) {
- Iterator i = iterator();
- boolean changed = false;
- while (i.hasNext()) {
- if (c.contains(i.next())) {
- i.remove();
- changed = true;
- }
- }
- return changed;
- }
-
- /**
- * Remove from this collection all its elements that are not contained in a
- * given collection. This implementation iterates over this collection, and
- * for each element tests if it is contained in the given collection. If not,
- * it is removed by the Iterator's remove method (thus this method will fail
- * with an UnsupportedOperationException if the Iterator's remove method
- * does).
- *
- * @param c the collection to retain the elements of
- * @return true if the remove operation caused the Collection to change
- * @exception UnsupportedOperationException if this collection's Iterator
- * does not support the remove method
- */
- public boolean retainAll(Collection c) {
- Iterator i = iterator();
- boolean changed = false;
- while (i.hasNext()) {
- if (!c.contains(i.next())) {
- i.remove();
- changed = true;
- }
- }
- return changed;
- }
-
- /**
- * Return an array containing the elements of this collection. This
- * implementation creates an Object array of size size() and then iterates
- * over the collection, setting each element of the array from the value
- * returned by the iterator.
- *
- * @return an array containing the elements of this collection
- */
- public Object[] toArray() {
- Object[] a = new Object[size()];
- Iterator i = iterator();
- for (int pos = 0; pos < a.length; pos++) {
- a[pos] = i.next();
- }
- return a;
- }
-
- /**
- * Copy the collection into a given array if it will fit, or into a
- * dynamically created array of the same run-time type as the given array if
- * not. If there is space remaining in the array, the first element after the
- * end of the collection is set to null (this is only useful if the
- * collection is known to contain no null elements, however). This
- * implementation first tests whether the given array is large enough to hold
- * all the elements of the collection. If not, the reflection API is used to
- * allocate a new array of the same run-time type. Next an iterator is
- * obtained over the collection and the elements are placed in the array as
- * they are returned by the iterator. Finally the first spare element, if
- * any, of the array is set to null, and the created array is returned.
- *
- * @param a the array to copy into, or of the correct run-time type
- * @return the array that was produced
- * @exception ClassCastException if the type of the array precludes holding
- * one of the elements of the Collection
- */
- public Object[] toArray(Object[] a) {
- final int n = size();
- if (a.length < n) {
- a = (Object[])Array.newInstance(a.getClass().getComponentType(), n);
- }
- Iterator i = iterator();
- for (int pos = 0; pos < n; pos++) {
- a[pos] = i.next();
- }
- if (a.length > n) {
- a[n] = null;
- }
- return a;
- }
-
- /**
- * Creates a String representation of the Collection. The string returned is
- * of the form "[a, b, ...]" where a and b etc are the results of calling
- * toString on the elements of the collection. This implementation obtains an
- * Iterator over the Collection and adds each element to a StringBuffer as it
- * is returned by the iterator.
- *
- * @return a String representation of the Collection
- */
- public String toString() {
- StringBuffer s = new StringBuffer();
- s.append('[');
- Iterator i = iterator();
- boolean more = i.hasNext();
- while(more) {
- s.append(i.next());
- if (more = i.hasNext()) {
- s.append(", ");
- }
- }
- s.append(']');
- return s.toString();
- }
-}
diff --git a/libjava/java/util/AbstractList.java b/libjava/java/util/AbstractList.java
deleted file mode 100644
index da76a8b3104..00000000000
--- a/libjava/java/util/AbstractList.java
+++ /dev/null
@@ -1,558 +0,0 @@
-/* AbstractList.java -- Abstract implementation of most of List
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-As a special exception, if you link this library with other files to
-produce an executable, this library does not by itself cause the
-resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why the
-executable file might be covered by the GNU General Public License. */
-
-
-// TO DO:
-// ~ Doc comments for almost everything.
-// ~ Better general commenting
-
-package java.util;
-
-/**
- * A basic implementation of most of the methods in the List interface to make
- * it easier to create a List based on a random-access data structure. To
- * create an unmodifiable list, it is only necessary to override the size() and
- * get(int) methods (this contrasts with all other abstract collection classes
- * which require an iterator to be provided). To make the list modifiable, the
- * set(int, Object) method should also be overridden, and to make the list
- * resizable, the add(int, Object) and remove(int) methods should be overridden
- * too. Other methods should be overridden if the backing data structure allows
- * for a more efficient implementation. The precise implementation used by
- * AbstractList is documented, so that subclasses can tell which methods could
- * be implemented more efficiently.
- */
-public abstract class AbstractList extends AbstractCollection implements List {
-
- /**
- * A count of the number of structural modifications that have been made to
- * the list (that is, insertions and removals).
- */
- protected transient int modCount = 0;
-
- public abstract Object get(int index);
-
- public void add(int index, Object o) {
- throw new UnsupportedOperationException();
- }
-
- public boolean add(Object o) {
- add(size(), o);
- return true;
- }
-
- public boolean addAll(int index, Collection c) {
- Iterator i = c.iterator();
- if (i.hasNext()) {
- do {
- add(index++, i.next());
- } while (i.hasNext());
- return true;
- } else {
- return false;
- }
- }
-
- public void clear() {
- removeRange(0, size());
- }
-
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- } else if (!(o instanceof List)) {
- return false;
- } else {
- Iterator i1 = iterator();
- Iterator i2 = ((List)o).iterator();
- while (i1.hasNext()) {
- if (!i2.hasNext()) {
- return false;
- } else {
- Object e = i1.next();
- if (e == null ? i2.next() != null : !e.equals(i2.next())) {
- return false;
- }
- }
- }
- if (i2.hasNext()) {
- return false;
- } else {
- return true;
- }
- }
- }
-
- public int hashCode() {
- int hashCode = 1;
- Iterator i = iterator();
- while (i.hasNext()) {
- Object obj = i.next();
- hashCode = 31 * hashCode + (obj == null ? 0 : obj.hashCode());
- }
- return hashCode;
- }
-
- public int indexOf(Object o) {
- int index = 0;
- ListIterator i = listIterator();
- if (o == null) {
- while (i.hasNext()) {
- if (i.next() == null) {
- return index;
- }
- index++;
- }
- } else {
- while (i.hasNext()) {
- if (o.equals(i.next())) {
- return index;
- }
- index++;
- }
- }
- return -1;
- }
-
- public Iterator iterator() {
- return new Iterator() {
- private int knownMod = modCount;
- private int position = 0;
- boolean removed = true;
-
- private void checkMod() {
- if (knownMod != modCount) {
- throw new ConcurrentModificationException();
- }
- }
-
- public boolean hasNext() {
- checkMod();
- return position < size();
- }
-
- public Object next() {
- checkMod();
- removed = false;
- try {
- return get(position++);
- } catch (IndexOutOfBoundsException e) {
- throw new NoSuchElementException();
- }
- }
-
- public void remove() {
- checkMod();
- if (removed) {
- throw new IllegalStateException();
- }
- AbstractList.this.remove(--position);
- knownMod = modCount;
- removed = true;
- }
- };
- }
-
- public int lastIndexOf(Object o) {
- int index = size();
- ListIterator i = listIterator(index);
- if (o == null) {
- while (i.hasPrevious()) {
- index--;
- if (i.previous() == null) {
- return index;
- }
- }
- } else {
- while (i.hasPrevious()) {
- index--;
- if (o.equals(i.previous())) {
- return index;
- }
- }
- }
- return -1;
- }
-
- public ListIterator listIterator() {
- return listIterator(0);
- }
-
- public ListIterator listIterator(final int index) {
-
- if (index < 0 || index > size()) {
- throw new IndexOutOfBoundsException();
- }
-
- return new ListIterator() {
- private int knownMod = modCount;
- private int position = index;
- private int lastReturned = -1;
-
- private void checkMod() {
- if (knownMod != modCount) {
- throw new ConcurrentModificationException();
- }
- }
-
- public boolean hasNext() {
- checkMod();
- return position < size();
- }
-
- public boolean hasPrevious() {
- checkMod();
- return position > 0;
- }
-
- public Object next() {
- checkMod();
- if (hasNext()) {
- lastReturned = position++;
- return get(lastReturned);
- } else {
- throw new NoSuchElementException();
- }
- }
-
- public Object previous() {
- checkMod();
- if (hasPrevious()) {
- lastReturned = --position;
- return get(lastReturned);
- } else {
- throw new NoSuchElementException();
- }
- }
-
- public int nextIndex() {
- checkMod();
- return position;
- }
-
- public int previousIndex() {
- checkMod();
- return position - 1;
- }
-
- public void remove() {
- checkMod();
- if (lastReturned < 0) {
- throw new IllegalStateException();
- }
- AbstractList.this.remove(lastReturned);
- knownMod = modCount;
- position = lastReturned;
- lastReturned = -1;
- }
-
- public void set(Object o) {
- checkMod();
- if (lastReturned < 0) {
- throw new IllegalStateException();
- }
- AbstractList.this.set(lastReturned, o);
- }
-
- public void add(Object o) {
- checkMod();
- AbstractList.this.add(position++, o);
- lastReturned = -1;
- knownMod = modCount;
- }
- };
- }
-
- public Object remove(int index) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Remove a subsection of the list. This is called by the clear and
- * removeRange methods of the class which implements subList, which are
- * difficult for subclasses to override directly. Therefore, this method
- * should be overridden instead by the more efficient implementation, if one
- * exists.
- * <p>
- * This implementation first checks for illegal or out of range arguments. It
- * then obtains a ListIterator over the list using listIterator(fromIndex).
- * It then calls next() and remove() on this iterator repeatedly, toIndex -
- * fromIndex times.
- *
- * @param fromIndex the index, inclusive, to remove from.
- * @param toIndex the index, exclusive, to remove to.
- * @exception UnsupportedOperationException if this list does not support
- * the removeRange operation.
- * @exception IndexOutOfBoundsException if fromIndex > toIndex || fromIndex <
- * 0 || toIndex > size().
- */
- protected void removeRange(int fromIndex, int toIndex) {
- if (fromIndex > toIndex) {
- throw new IllegalArgumentException();
- } else if (fromIndex < 0 || toIndex > size()) {
- throw new IndexOutOfBoundsException();
- } else {
- ListIterator i = listIterator(fromIndex);
- for (int index = fromIndex; index < toIndex; index++) {
- i.next();
- i.remove();
- }
- }
- }
-
- public Object set(int index, Object o) {
- throw new UnsupportedOperationException();
- }
-
- public List subList(final int fromIndex, final int toIndex) {
- if (fromIndex > toIndex)
- throw new IllegalArgumentException();
- if (fromIndex < 0 || toIndex > size())
- throw new IndexOutOfBoundsException();
- return new SubList(this, fromIndex, toIndex);
- }
-
- static class SubList extends AbstractList {
-
- private AbstractList backingList;
- private int offset;
- private int size;
-
- public SubList(AbstractList backing, int fromIndex, int toIndex) {
- backingList = backing;
- upMod();
- offset = fromIndex;
- size = toIndex - fromIndex;
- }
-
- // Note that within this class two fields called modCount are inherited -
- // one from the superclass, and one from the outer class.
- // The code uses both these two fields and *no other* to provide fail-fast
- // behaviour. For correct operation, the two fields should contain equal
- // values. Therefore, if this.modCount != backingList.modCount, there
- // has been a concurrent modification. This is all achieved purely by using
- // the modCount field, precisely according to the docs of AbstractList.
- // See the methods upMod and checkMod.
-
- /**
- * This method checks the two modCount fields to ensure that there has
- * not been a concurrent modification. It throws an exception if there
- * has been, and otherwise returns normally.
- * Note that since this method is private, it will be inlined.
- *
- * @exception ConcurrentModificationException if there has been a
- * concurrent modification.
- */
- private void checkMod() {
- if (this.modCount != backingList.modCount) {
- throw new ConcurrentModificationException();
- }
- }
-
- /**
- * This method is called after every method that causes a structural
- * modification to the backing list. It updates the local modCount field
- * to match that of the backing list.
- * Note that since this method is private, it will be inlined.
- */
- private void upMod() {
- this.modCount = backingList.modCount;
- }
-
- /**
- * This method checks that a value is between 0 and size (inclusive). If
- * it is not, an exception is thrown.
- * Note that since this method is private, it will be inlined.
- *
- * @exception IndexOutOfBoundsException if the value is out of range.
- */
- private void checkBoundsInclusive(int index) {
- if (index < 0 || index > size) {
- throw new IndexOutOfBoundsException();
- }
- }
-
- /**
- * This method checks that a value is between 0 (inclusive) and size
- * (exclusive). If it is not, an exception is thrown.
- * Note that since this method is private, it will be inlined.
- *
- * @exception IndexOutOfBoundsException if the value is out of range.
- */
- private void checkBoundsExclusive(int index) {
- if (index < 0 || index >= size) {
- throw new IndexOutOfBoundsException();
- }
- }
-
- public int size() {
- checkMod();
- return size;
- }
-
- public Iterator iterator() {
- return listIterator();
- }
-
- public ListIterator listIterator(final int index) {
-
- checkMod();
- checkBoundsInclusive(index);
-
- return new ListIterator() {
- ListIterator i = backingList.listIterator(index + offset);
- int position = index;
-
- public boolean hasNext() {
- checkMod();
- return position < size;
- }
-
- public boolean hasPrevious() {
- checkMod();
- return position > 0;
- }
-
- public Object next() {
- if (position < size) {
- Object o = i.next();
- position++;
- return o;
- } else {
- throw new NoSuchElementException();
- }
- }
-
- public Object previous() {
- if (position > 0) {
- Object o = i.previous();
- position--;
- return o;
- } else {
- throw new NoSuchElementException();
- }
- }
-
- public int nextIndex() {
- return offset + i.nextIndex();
- }
-
- public int previousIndex() {
- return offset + i.previousIndex();
- }
-
- public void remove() {
- i.remove();
- upMod();
- size--;
- position = nextIndex();
- }
-
- public void set(Object o) {
- i.set(o);
- }
-
- public void add(Object o) {
- i.add(o);
- upMod();
- size++;
- position++;
- }
-
- // Here is the reason why the various modCount fields are mostly
- // ignored in this wrapper listIterator.
- // IF the backing listIterator is failfast, then the following holds:
- // Using any other method on this list will call a corresponding
- // method on the backing list *after* the backing listIterator
- // is created, which will in turn cause a ConcurrentModException
- // when this listIterator comes to use the backing one. So it is
- // implicitly failfast.
- // If the backing listIterator is NOT failfast, then the whole of
- // this list isn't failfast, because the modCount field of the
- // backing list is not valid. It would still be *possible* to
- // make the iterator failfast wrt modifications of the sublist
- // only, but somewhat pointless when the list can be changed under
- // us.
- // Either way, no explicit handling of modCount is needed.
- // However upMod() must be called in add and remove, and size
- // must also be updated in these two methods, since they do not go
- // through the corresponding methods of the subList.
-
- };
- }
-
- public Object set(int index, Object o) {
- checkMod();
- checkBoundsExclusive(index);
- o = backingList.set(index + offset, o);
- upMod();
- return o;
- }
-
- public Object get(int index) {
- checkMod();
- checkBoundsExclusive(index);
- return backingList.get(index + offset);
- }
-
- public void add(int index, Object o) {
- checkMod();
- checkBoundsInclusive(index);
- backingList.add(index + offset, o);
- upMod();
- size++;
- }
-
- public Object remove(int index) {
- checkMod();
- checkBoundsExclusive(index);
- Object o = backingList.remove(index + offset);
- upMod();
- size--;
- return o;
- }
-
- public void removeRange(int fromIndex, int toIndex) {
- checkMod();
- checkBoundsExclusive(fromIndex);
- checkBoundsInclusive(toIndex);
-
- // this call will catch the toIndex < fromIndex condition
- backingList.removeRange(offset + fromIndex, offset + toIndex);
- upMod();
- size -= toIndex - fromIndex;
- }
-
- public boolean addAll(int index, Collection c) {
- checkMod();
- checkBoundsInclusive(index);
- int s = backingList.size();
- boolean result = backingList.addAll(offset + index, c);
- upMod();
- size += backingList.size() - s;
- return result;
- }
- }
-}
diff --git a/libjava/java/util/Arrays.java b/libjava/java/util/Arrays.java
deleted file mode 100644
index fc51d3886ea..00000000000
--- a/libjava/java/util/Arrays.java
+++ /dev/null
@@ -1,1757 +0,0 @@
-/* Arrays.java -- Utility class with methods to operate on arrays
- Copyright (C) 1998, 1999 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-As a special exception, if you link this library with other files to
-produce an executable, this library does not by itself cause the
-resulting executable to be covered by the GNU General Public License.
-This exception does not however invalidate any other reasons why the
-executable file might be covered by the GNU General Public License. */
-
-
-// TO DO:
-// ~ Fix the behaviour of sort and binarySearch as applied to float and double
-// arrays containing NaN values. See the JDC, bug ID 4143272.
-
-package java.util;
-
-/**
- * This class contains various static utility methods performing operations on
- * arrays, and a method to provide a List "view" of an array to facilitate
- * using arrays with Collection-based APIs.
- */
-public class Arrays {
-
- /**
- * This class is non-instantiable.
- */
- private Arrays() {
- }
-
- private static Comparator defaultComparator = new Comparator() {
- public int compare(Object o1, Object o2) {
- return ((Comparable)o1).compareTo(o2);
- }
- };
-
- /**
- * Perform a binary search of a byte array for a key. The array must be
- * sorted (as by the sort() method) - if it is not, the behaviour of this
- * method is undefined, and may be an infinite loop. If the array contains
- * the key more than once, any one of them may be found. Note: although the
- * specification allows for an infinite loop if the array is unsorted, it
- * will not happen in this implementation.
- *
- * @param a the array to search (must be sorted)
- * @param key the value to search for
- * @returns the index at which the key was found, or -n-1 if it was not
- * found, where n is the index of the first value higher than key or
- * a.length if there is no such value.
- */
- public static int binarySearch(byte[] a, byte key) {
- int low = 0;
- int hi = a.length - 1;
- int mid = 0;
- while (low <= hi) {
- mid = (low + hi) >> 1;
- final byte d = a[mid];
- if (d == key) {
- return mid;
- } else if (d > key) {
- hi = mid - 1;
- } else {
- low = ++mid; // This gets the insertion point right on the last loop
- }
- }
- return -mid - 1;
- }
-
- /**
- * Perform a binary search of a char array for a key. The array must be
- * sorted (as by the sort() method) - if it is not, the behaviour of this
- * method is undefined, and may be an infinite loop. If the array contains
- * the key more than once, any one of them may be found. Note: although the
- * specification allows for an infinite loop if the array is unsorted, it
- * will not happen in this implementation.
- *
- * @param a the array to search (must be sorted)
- * @param key the value to search for
- * @returns the index at which the key was found, or -n-1 if it was not
- * found, where n is the index of the first value higher than key or
- * a.length if there is no such value.
- */
- public static int binarySearch(char[] a, char key) {
- int low = 0;
- int hi = a.length - 1;
- int mid = 0;
- while (low <= hi) {
- mid = (low + hi) >> 1;
- final char d = a[mid];
- if (d == key) {
- return mid;
- } else if (d > key) {
- hi = mid - 1;
- } else {
- low = ++mid; // This gets the insertion point right on the last loop
- }
- }
- return -mid - 1;
- }
-
- /**
- * Perform a binary search of a double array for a key. The array must be
- * sorted (as by the sort() method) - if it is not, the behaviour of this
- * method is undefined, and may be an infinite loop. If the array contains
- * the key more than once, any one of them may be found. Note: although the
- * specification allows for an infinite loop if the array is unsorted, it
- * will not happen in this implementation.
- *
- * @param a the array to search (must be sorted)
- * @param key the value to search for
- * @returns the index at which the key was found, or -n-1 if it was not
- * found, where n is the index of the first value higher than key or
- * a.length if there is no such value.
- */
- public static int binarySearch(double[] a, double key) {
- int low = 0;
- int hi = a.length - 1;
- int mid = 0;
- while (low <= hi) {
- mid = (low + hi) >> 1;
- final double d = a[mid];
- if (d == key) {
- return mid;
- } else if (d > key) {
- hi = mid - 1;
- } else {
- low = ++mid; // This gets the insertion point right on the last loop
- }
- }
- return -mid - 1;
- }
-
- /**
- * Perform a binary search of a float array for a key. The array must be
- * sorted (as by the sort() method) - if it is not, the behaviour of this
- * method is undefined, and may be an infinite loop. If the array contains
- * the key more than once, any one of them may be found. Note: although the
- * specification allows for an infinite loop if the array is unsorted, it
- * will not happen in this implementation.
- *
- * @param a the array to search (must be sorted)
- * @param key the value to search for
- * @returns the index at which the key was found, or -n-1 if it was not
- * found, where n is the index of the first value higher than key or
- * a.length if there is no such value.
- */
- public static int binarySearch(float[] a, float key) {
- int low = 0;
- int hi = a.length - 1;
- int mid = 0;
- while (low <= hi) {
- mid = (low + hi) >> 1;
- final float d = a[mid];
- if (d == key) {
- return mid;
- } else if (d > key) {
- hi = mid - 1;
- } else {
- low = ++mid; // This gets the insertion point right on the last loop
- }
- }
- return -mid - 1;
- }
-
- /**
- * Perform a binary search of an int array for a key. The array must be
- * sorted (as by the sort() method) - if it is not, the behaviour of this
- * method is undefined, and may be an infinite loop. If the array contains
- * the key more than once, any one of them may be found. Note: although the
- * specification allows for an infinite loop if the array is unsorted, it
- * will not happen in this implementation.
- *
- * @param a the array to search (must be sorted)
- * @param key the value to search for
- * @returns the index at which the key was found, or -n-1 if it was not
- * found, where n is the index of the first value higher than key or
- * a.length if there is no such value.
- */
- public static int binarySearch(int[] a, int key) {
- int low = 0;
- int hi = a.length - 1;
- int mid = 0;
- while (low <= hi) {
- mid = (low + hi) >> 1;
- final int d = a[mid];
- if (d == key) {
- return mid;
- } else if (d > key) {
- hi = mid - 1;
- } else {
- low = ++mid; // This gets the insertion point right on the last loop
- }
- }
- return -mid - 1;
- }
-
- /**
- * Perform a binary search of a long array for a key. The array must be
- * sorted (as by the sort() method) - if it is not, the behaviour of this
- * method is undefined, and may be an infinite loop. If the array contains
- * the key more than once, any one of them may be found. Note: although the
- * specification allows for an infinite loop if the array is unsorted, it
- * will not happen in this implementation.
- *
- * @param a the array to search (must be sorted)
- * @param key the value to search for
- * @returns the index at which the key was found, or -n-1 if it was not
- * found, where n is the index of the first value higher than key or
- * a.length if there is no such value.
- */
- public static int binarySearch(long[] a, long key) {
- int low = 0;
- int hi = a.length - 1;
- int mid = 0;
- while (low <= hi) {
- mid = (low + hi) >> 1;
- final long d = a[mid];
- if (d == key) {
- return mid;
- } else if (d > key) {
- hi = mid - 1;
- } else {
- low = ++mid; // This gets the insertion point right on the last loop
- }
- }
- return -mid - 1;
- }
-
- /**
- * Perform a binary search of a short array for a key. The array must be
- * sorted (as by the sort() method) - if it is not, the behaviour of this
- * method is undefined, and may be an infinite loop. If the array contains
- * the key more than once, any one of them may be found. Note: although the
- * specification allows for an infinite loop if the array is unsorted, it
- * will not happen in this implementation.
- *
- * @param a the array to search (must be sorted)
- * @param key the value to search for
- * @returns the index at which the key was found, or -n-1 if it was not
- * found, where n is the index of the first value higher than key or
- * a.length if there is no such value.
- */
- public static int binarySearch(short[] a, short key) {
- int low = 0;
- int hi = a.length - 1;
- int mid = 0;
- while (low <= hi) {
- mid = (low + hi) >> 1;
- final short d = a[mid];
- if (d == key) {
- return mid;
- } else if (d > key) {
- hi = mid - 1;
- } else {
- low = ++mid; // This gets the insertion point right on the last loop
- }
- }
- return -mid - 1;
- }
-
- /**
- * This method does the work for the Object binary search methods.
- * @exception NullPointerException if the specified comparator is null.
- * @exception ClassCastException if the objects are not comparable by c.
- */
- private static int objectSearch(Object[] a, Object key, final Comparator c) {
- int low = 0;
- int hi = a.length - 1;
- int mid = 0;
- while (low <= hi) {
- mid = (low + hi) >> 1;
- final int d = c.compare(key, a[mid]);
- if (d == 0) {
- return mid;
- } else if (d < 0) {
- hi = mid - 1;
- } else {
- low = ++mid; // This gets the insertion point right on the last loop
- }
- }
- return -mid - 1;
- }
-
- /**
- * Perform a binary search of an Object array for a key, using the natural
- * ordering of the elements. The array must be sorted (as by the sort()
- * method) - if it is not, the behaviour of this method is undefined, and may
- * be an infinite loop. Further, the key must be comparable with every item
- * in the array. If the array contains the key more than once, any one of
- * them may be found. Note: although the specification allows for an infinite
- * loop if the array is unsorted, it will not happen in this (JCL)
- * implementation.
- *
- * @param a the array to search (must be sorted)
- * @param key the value to search for
- * @returns the index at which the key was found, or -n-1 if it was not
- * found, where n is the index of the first value higher than key or
- * a.length if there is no such value.
- * @exception ClassCastException if key could not be compared with one of the
- * elements of a
- * @exception NullPointerException if a null element has compareTo called
- */
- public static int binarySearch(Object[] a, Object key) {
- return objectSearch(a, key, defaultComparator);
- }
-
- /**
- * Perform a binary search of an Object array for a key, using a supplied
- * Comparator. The array must be sorted (as by the sort() method with the
- * same Comparator) - if it is not, the behaviour of this method is
- * undefined, and may be an infinite loop. Further, the key must be
- * comparable with every item in the array. If the array contains the key
- * more than once, any one of them may be found. Note: although the
- * specification allows for an infinite loop if the array is unsorted, it
- * will not happen in this (JCL) implementation.
- *
- * @param a the array to search (must be sorted)
- * @param key the value to search for
- * @param c the comparator by which the array is sorted
- * @returns the index at which the key was found, or -n-1 if it was not
- * found, where n is the index of the first value higher than key or
- * a.length if there is no such value.
- * @exception ClassCastException if key could not be compared with one of the
- * elements of a
- */
- public static int binarySearch(Object[] a, Object key, Comparator c) {
- return objectSearch(a, key, c);
- }
-
- /**
- * Compare two byte arrays for equality.
- *
- * @param a1 the first array to compare
- * @param a2 the second array to compare
- * @returns true if a1 and a2 are both null, or if a2 is of the same length
- * as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
- */
- public static boolean equals(byte[] a1, byte[] a2) {
-
- // Quick test which saves comparing elements of the same array, and also
- // catches the case that both are null.
- if (a1 == a2) {
- return true;
- }
- try {
-
- // If they're the same length, test each element
- if (a1.length == a2.length) {
- for (int i = 0; i < a1.length; i++) {
- if (a1[i] != a2[i]) {
- return false;
- }
- }
- return true;
- }
-
- // If a1 == null or a2 == null but not both then we will get a NullPointer
- } catch (NullPointerException e) {
- }
-
- return false;
- }
-
- /**
- * Compare two char arrays for equality.
- *
- * @param a1 the first array to compare
- * @param a2 the second array to compare
- * @returns true if a1 and a2 are both null, or if a2 is of the same length
- * as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
- */
- public static boolean equals(char[] a1, char[] a2) {
-
- // Quick test which saves comparing elements of the same array, and also
- // catches the case that both are null.
- if (a1 == a2) {
- return true;
- }
- try {
-
- // If they're the same length, test each element
- if (a1.length == a2.length) {
- for (int i = 0; i < a1.length; i++) {
- if (a1[i] != a2[i]) {
- return false;
- }
- }
- return true;
- }
-
- // If a1 == null or a2 == null but not both then we will get a NullPointer
- } catch (NullPointerException e) {
- }
-
- return false;
- }
-
- /**
- * Compare two double arrays for equality.
- *
- * @param a1 the first array to compare
- * @param a2 the second array to compare
- * @returns true if a1 and a2 are both null, or if a2 is of the same length
- * as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
- */
- public static boolean equals(double[] a1, double[] a2) {
-
- // Quick test which saves comparing elements of the same array, and also
- // catches the case that both are null.
- if (a1 == a2) {
- return true;
- }
- try {
-
- // If they're the same length, test each element
- if (a1.length == a2.length) {
- for (int i = 0; i < a1.length; i++) {
- if (a1[i] != a2[i]) {
- return false;
- }
- }
- return true;
- }
-
- // If a1 == null or a2 == null but not both then we will get a NullPointer
- } catch (NullPointerException e) {
- }
-
- return false;
- }
-
- /**
- * Compare two float arrays for equality.
- *
- * @param a1 the first array to compare
- * @param a2 the second array to compare
- * @returns true if a1 and a2 are both null, or if a2 is of the same length
- * as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
- */
- public static boolean equals(float[] a1, float[] a2) {
-
- // Quick test which saves comparing elements of the same array, and also
- // catches the case that both are null.
- if (a1 == a2) {
- return true;
- }
- try {
-
- // If they're the same length, test each element
- if (a1.length == a2.length) {
- for (int i = 0; i < a1.length; i++) {
- if (a1[i] != a2[i]) {
- return false;
- }
- }
- return true;
- }
-
- // If a1 == null or a2 == null but not both then we will get a NullPointer
- } catch (NullPointerException e) {
- }
-
- return false;
- }
-
- /**
- * Compare two long arrays for equality.
- *
- * @param a1 the first array to compare
- * @param a2 the second array to compare
- * @returns true if a1 and a2 are both null, or if a2 is of the same length
- * as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
- */
- public static boolean equals(long[] a1, long[] a2) {
-
- // Quick test which saves comparing elements of the same array, and also
- // catches the case that both are null.
- if (a1 == a2) {
- return true;
- }
- try {
-
- // If they're the same length, test each element
- if (a1.length == a2.length) {
- for (int i = 0; i < a1.length; i++) {
- if (a1[i] != a2[i]) {
- return false;
- }
- }
- return true;
- }
-
- // If a1 == null or a2 == null but not both then we will get a NullPointer
- } catch (NullPointerException e) {
- }
-
- return false;
- }
-
- /**
- * Compare two short arrays for equality.
- *
- * @param a1 the first array to compare
- * @param a2 the second array to compare
- * @returns true if a1 and a2 are both null, or if a2 is of the same length
- * as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
- */
- public static boolean equals(short[] a1, short[] a2) {
-
- // Quick test which saves comparing elements of the same array, and also
- // catches the case that both are null.
- if (a1 == a2) {
- return true;
- }
- try {
-
- // If they're the same length, test each element
- if (a1.length == a2.length) {
- for (int i = 0; i < a1.length; i++) {
- if (a1[i] != a2[i]) {
- return false;
- }
- }
- return true;
- }
-
- // If a1 == null or a2 == null but not both then we will get a NullPointer
- } catch (NullPointerException e) {
- }
-
- return false;
- }
-
- /**
- * Compare two boolean arrays for equality.
- *
- * @param a1 the first array to compare
- * @param a2 the second array to compare
- * @returns true if a1 and a2 are both null, or if a2 is of the same length
- * as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
- */
- public static boolean equals(boolean[] a1, boolean[] a2) {
-
- // Quick test which saves comparing elements of the same array, and also
- // catches the case that both are null.
- if (a1 == a2) {
- return true;
- }
- try {
-
- // If they're the same length, test each element
- if (a1.length == a2.length) {
- for (int i = 0; i < a1.length; i++) {
- if (a1[i] != a2[i]) {
- return false;
- }
- }
- return true;
- }
-
- // If a1 == null or a2 == null but not both then we will get a NullPointer
- } catch (NullPointerException e) {
- }
-
- return false;
- }
-
- /**
- * Compare two int arrays for equality.
- *
- * @param a1 the first array to compare
- * @param a2 the second array to compare
- * @returns true if a1 and a2 are both null, or if a2 is of the same length
- * as a1, and for each 0 <= i < a1.length, a1[i] == a2[i]
- */
- public static boolean equals(int[] a1, int[] a2) {
-
- // Quick test which saves comparing elements of the same array, and also
- // catches the case that both are null.
- if (a1 == a2) {
- return true;
- }
- try {
-
- // If they're the same length, test each element
- if (a1.length == a2.length) {
- for (int i = 0; i < a1.length; i++) {
- if (a1[i] != a2[i]) {
- return false;
- }
- }
- return true;
- }
-
- // If a1 == null or a2 == null but not both then we will get a NullPointer
- } catch (NullPointerException e) {
- }
-
- return false;
- }
-
- /**
- * Compare two Object arrays for equality.
- *
- * @param a1 the first array to compare
- * @param a2 the second array to compare
- * @returns true if a1 and a2 are both null, or if a1 is of the same length
- * as a2, and for each 0 <= i < a.length, a1[i] == null ? a2[i] == null :
- * a1[i].equals(a2[i]).
- */
- public static boolean equals(Object[] a1, Object[] a2) {
-
- // Quick test which saves comparing elements of the same array, and also
- // catches the case that both are null.
- if (a1 == a2) {
- return true;
- }
- try {
-
- // If they're the same length, test each element
- if (a1.length == a2.length) {
- for (int i = 0; i < a1.length; i++) {
- if (!(a1[i] == null ? a2[i] == null : a1[i].equals(a2[i]))) {
- return false;
- }
- }
- return true;
- }
-
- // If a1 == null or a2 == null but not both then we will get a NullPointer
- } catch (NullPointerException e) {
- }
-
- return false;
- }
-
- /**
- * Fill an array with a boolean value.
- *
- * @param a the array to fill
- * @param val the value to fill it with
- */
- public static void fill(boolean[] a, boolean val) {
- // This implementation is slightly inefficient timewise, but the extra
- // effort over inlining it is O(1) and small, and I refuse to repeat code
- // if it can be helped.
- fill(a, 0, a.length, val);
- }
-
- /**
- * Fill a range of an array with a boolean value.
- *
- * @param a the array to fill
- * @param fromIndex the index to fill from, inclusive
- * @param toIndex the index to fill to, exclusive
- * @param val the value to fill with
- */
- public static void fill(boolean[] a, int fromIndex, int toIndex,
- boolean val) {
- for (int i = fromIndex; i < toIndex; i++) {
- a[i] = val;
- }
- }
-
- /**
- * Fill an array with a byte value.
- *
- * @param a the array to fill
- * @param val the value to fill it with
- */
- public static void fill(byte[] a, byte val) {
- // This implementation is slightly inefficient timewise, but the extra
- // effort over inlining it is O(1) and small, and I refuse to repeat code
- // if it can be helped.
- fill(a, 0, a.length, val);
- }
-
- /**
- * Fill a range of an array with a byte value.
- *
- * @param a the array to fill
- * @param fromIndex the index to fill from, inclusive
- * @param toIndex the index to fill to, exclusive
- * @param val the value to fill with
- */
- public static void fill(byte[] a, int fromIndex, int toIndex, byte val) {
- for (int i = fromIndex; i < toIndex; i++) {
- a[i] = val;
- }
- }
-
- /**
- * Fill an array with a char value.
- *
- * @param a the array to fill
- * @param val the value to fill it with
- */
- public static void fill(char[] a, char val) {
- // This implementation is slightly inefficient timewise, but the extra
- // effort over inlining it is O(1) and small, and I refuse to repeat code
- // if it can be helped.
- fill(a, 0, a.length, val);
- }
-
- /**
- * Fill a range of an array with a char value.
- *
- * @param a the array to fill
- * @param fromIndex the index to fill from, inclusive
- * @param toIndex the index to fill to, exclusive
- * @param val the value to fill with
- */
- public static void fill(char[] a, int fromIndex, int toIndex, char val) {
- for (int i = fromIndex; i < toIndex; i++) {
- a[i] = val;
- }
- }
-
- /**
- * Fill an array with a double value.
- *
- * @param a the array to fill
- * @param val the value to fill it with
- */
- public static void fill(double[] a, double val) {
- // This implementation is slightly inefficient timewise, but the extra
- // effort over inlining it is O(1) and small, and I refuse to repeat code
- // if it can be helped.
- fill(a, 0, a.length, val);
- }
-
- /**
- * Fill a range of an array with a double value.
- *
- * @param a the array to fill
- * @param fromIndex the index to fill from, inclusive
- * @param toIndex the index to fill to, exclusive
- * @param val the value to fill with
- */
- public static void fill(double[] a, int fromIndex, int toIndex, double val) {
- for (int i = fromIndex; i < toIndex; i++) {
- a[i] = val;
- }
- }
-
- /**
- * Fill an array with a float value.
- *
- * @param a the array to fill
- * @param val the value to fill it with
- */
- public static void fill(float[] a, float val) {
- // This implementation is slightly inefficient timewise, but the extra
- // effort over inlining it is O(1) and small, and I refuse to repeat code
- // if it can be helped.
- fill(a, 0, a.length, val);
- }
-
- /**
- * Fill a range of an array with a float value.
- *
- * @param a the array to fill
- * @param fromIndex the index to fill from, inclusive
- * @param toIndex the index to fill to, exclusive
- * @param val the value to fill with
- */
- public static void fill(float[] a, int fromIndex, int toIndex, float val) {
- for (int i = fromIndex; i < toIndex; i++) {
- a[i] = val;
- }
- }
-
- /**
- * Fill an array with an int value.
- *
- * @param a the array to fill
- * @param val the value to fill it with
- */
- public static void fill(int[] a, int val) {
- // This implementation is slightly inefficient timewise, but the extra
- // effort over inlining it is O(1) and small, and I refuse to repeat code
- // if it can be helped.
- fill(a, 0, a.length, val);
- }
-
- /**
- * Fill a range of an array with an int value.
- *
- * @param a the array to fill
- * @param fromIndex the index to fill from, inclusive
- * @param toIndex the index to fill to, exclusive
- * @param val the value to fill with
- */
- public static void fill(int[] a, int fromIndex, int toIndex, int val) {
- for (int i = fromIndex; i < toIndex; i++) {
- a[i] = val;
- }
- }
-
- /**
- * Fill an array with a long value.
- *
- * @param a the array to fill
- * @param val the value to fill it with
- */
- public static void fill(long[] a, long val) {
- // This implementation is slightly inefficient timewise, but the extra
- // effort over inlining it is O(1) and small, and I refuse to repeat code
- // if it can be helped.
- fill(a, 0, a.length, val);
- }
-
- /**
- * Fill a range of an array with a long value.
- *
- * @param a the array to fill
- * @param fromIndex the index to fill from, inclusive
- * @param toIndex the index to fill to, exclusive
- * @param val the value to fill with
- */
- public static void fill(long[] a, int fromIndex, int toIndex, long val) {
- for (int i = fromIndex; i < toIndex; i++) {
- a[i] = val;
- }
- }
-
- /**
- * Fill an array with a short value.
- *
- * @param a the array to fill
- * @param val the value to fill it with
- */
- public static void fill(short[] a, short val) {
- // This implementation is slightly inefficient timewise, but the extra
- // effort over inlining it is O(1) and small, and I refuse to repeat code
- // if it can be helped.
- fill(a, 0, a.length, val);
- }
-
- /**
- * Fill a range of an array with a short value.
- *
- * @param a the array to fill
- * @param fromIndex the index to fill from, inclusive
- * @param toIndex the index to fill to, exclusive
- * @param val the value to fill with
- */
- public static void fill(short[] a, int fromIndex, int toIndex, short val) {
- for (int i = fromIndex; i < toIndex; i++) {
- a[i] = val;
- }
- }
-
- /**
- * Fill an array with an Object value.
- *
- * @param a the array to fill
- * @param val the value to fill it with
- * @exception ClassCastException if val is not an instance of the element
- * type of a.
- */
- public static void fill(Object[] a, Object val) {
- // This implementation is slightly inefficient timewise, but the extra
- // effort over inlining it is O(1) and small, and I refuse to repeat code
- // if it can be helped.
- fill(a, 0, a.length, val);
- }
-
- /**
- * Fill a range of an array with an Object value.
- *
- * @param a the array to fill
- * @param fromIndex the index to fill from, inclusive
- * @param toIndex the index to fill to, exclusive
- * @param val the value to fill with
- * @exception ClassCastException if val is not an instance of the element
- * type of a.
- */
- public static void fill(Object[] a, int fromIndex, int toIndex, Object val) {
- for (int i = fromIndex; i < toIndex; i++) {
- a[i] = val;
- }
- }
-
- // Thanks to Paul Fisher <rao@gnu.org> for finding this quicksort algorithm
- // as specified by Sun and porting it to Java.
-
- /**
- * Sort a byte array into ascending order. The sort algorithm is an optimised
- * quicksort, as described in Jon L. Bentley and M. Douglas McIlroy's
- * "Engineering a Sort Function", Software-Practice and Experience, Vol.
- * 23(11) P. 1249-1265 (November 1993). This algorithm gives nlog(n)
- * performance on many arrays that would take quadratic time with a standard
- * quicksort.
- *
- * @param a the array to sort
- */
- public static void sort(byte[] a) {
- qsort(a, 0, a.length);
- }
-
- private static short cmp(byte i, byte j) {
- return (short)(i-j);
- }
-
- private static int med3(int a, int b, int c, byte[] d) {
- return cmp(d[a], d[b]) < 0 ?
- (cmp(d[b], d[c]) < 0 ? b : cmp(d[a], d[c]) < 0 ? c : a)
- : (cmp(d[b], d[c]) > 0 ? b : cmp(d[a], d[c]) > 0 ? c : a);
- }
-
- private static void swap(int i, int j, byte[] a) {
- byte c = a[i];
- a[i] = a[j];
- a[j] = c;
- }
-
- private static void qsort(byte[] a, int start, int n) {
- // use an insertion sort on small arrays
- if (n < 7) {
- for (int i = start + 1; i < start + n; i++)
- for (int j = i; j > 0 && cmp(a[j-1], a[j]) > 0; j--)
- swap(j, j-1, a);
- return;
- }
-
- int pm = n/2; // small arrays, middle element
- if (n > 7) {
- int pl = start;
- int pn = start + n-1;
-
- if (n > 40) { // big arrays, pseudomedian of 9
- int s = n/8;
- pl = med3(pl, pl+s, pl+2*s, a);
- pm = med3(pm-s, pm, pm+s, a);
- pn = med3(pn-2*s, pn-s, pn, a);
- }
- pm = med3(pl, pm, pn, a); // mid-size, med of 3
- }
-
- int pa, pb, pc, pd, pv;
- short r;
-
- pv = start; swap(pv, pm, a);
- pa = pb = start;
- pc = pd = start + n-1;
-
- for (;;) {
- while (pb <= pc && (r = cmp(a[pb], a[pv])) <= 0) {
- if (r == 0) { swap(pa, pb, a); pa++; }
- pb++;
- }
- while (pc >= pb && (r = cmp(a[pc], a[pv])) >= 0) {
- if (r == 0) { swap(pc, pd, a); pd--; }
- pc--;
- }
- if (pb > pc) break;
- swap(pb, pc, a);
- pb++;
- pc--;
- }
- int pn = start + n;
- int s;
- s = Math.min(pa-start, pb-pa); vecswap(start, pb-s, s, a);
- s = Math.min(pd-pc, pn-pd-1); vecswap(pb, pn-s, s, a);
- if ((s = pb-pa) > 1) qsort(a, start, s);
- if ((s = pd-pc) > 1) qsort(a, pn-s, s);
- }
-
- private static void vecswap(int i, int j, int n, byte[] a) {
- for (; n > 0; i++, j++, n--)
- swap(i, j, a);
- }
-
- /**
- * Sort a char array into ascending order. The sort algorithm is an optimised
- * quicksort, as described in Jon L. Bentley and M. Douglas McIlroy's
- * "Engineering a Sort Function", Software-Practice and Experience, Vol.
- * 23(11) P. 1249-1265 (November 1993). This algorithm gives nlog(n)
- * performance on many arrays that would take quadratic time with a standard
- * quicksort.
- *
- * @param a the array to sort
- */
- public static void sort(char[] a) {
- qsort(a, 0, a.length);
- }
-
- private static int cmp(char i, char j) {
- return i-j;
- }
-
- private static int med3(int a, int b, int c, char[] d) {
- return cmp(d[a], d[b]) < 0 ?
- (cmp(d[b], d[c]) < 0 ? b : cmp(d[a], d[c]) < 0 ? c : a)
- : (cmp(d[b], d[c]) > 0 ? b : cmp(d[a], d[c]) > 0 ? c : a);
- }
-
- private static void swap(int i, int j, char[] a) {
- char c = a[i];
- a[i] = a[j];
- a[j] = c;
- }
-
- private static void qsort(char[] a, int start, int n) {
- // use an insertion sort on small arrays
- if (n < 7) {
- for (int i = start + 1; i < start + n; i++)
- for (int j = i; j > 0 && cmp(a[j-1], a[j]) > 0; j--)
- swap(j, j-1, a);
- return;
- }
-
- int pm = n/2; // small arrays, middle element
- if (n > 7) {
- int pl = start;
- int pn = start + n-1;
-
- if (n > 40) { // big arrays, pseudomedian of 9
- int s = n/8;
- pl = med3(pl, pl+s, pl+2*s, a);
- pm = med3(pm-s, pm, pm+s, a);
- pn = med3(pn-2*s, pn-s, pn, a);
- }
- pm = med3(pl, pm, pn, a); // mid-size, med of 3
- }
-
- int pa, pb, pc, pd, pv;
- int r;
-
- pv = start; swap(pv, pm, a);
- pa = pb = start;
- pc = pd = start + n-1;
-
- for (;;) {
- while (pb <= pc && (r = cmp(a[pb], a[pv])) <= 0) {
- if (r == 0) { swap(pa, pb, a); pa++; }
- pb++;
- }
- while (pc >= pb && (r = cmp(a[pc], a[pv])) >= 0) {
- if (r == 0) { swap(pc, pd, a); pd--; }
- pc--;
- }
- if (pb > pc) break;
- swap(pb, pc, a);
- pb++;
- pc--;
- }
- int pn = start + n;
- int s;
- s = Math.min(pa-start, pb-pa); vecswap(start, pb-s, s, a);
- s = Math.min(pd-pc, pn-pd-1); vecswap(pb, pn-s, s, a);
- if ((s = pb-pa) > 1) qsort(a, start, s);
- if ((s = pd-pc) > 1) qsort(a, pn-s, s);
- }
-
- private static void vecswap(int i, int j, int n, char[] a) {
- for (; n > 0; i++, j++, n--)
- swap(i, j, a);
- }
-
- /**
- * Sort a double array into ascending order. The sort algorithm is an
- * optimised quicksort, as described in Jon L. Bentley and M. Douglas
- * McIlroy's "Engineering a Sort Function", Software-Practice and Experience,
- * Vol. 23(11) P. 1249-1265 (November 1993). This algorithm gives nlog(n)
- * performance on many arrays that would take quadratic time with a standard
- * quicksort. Note that this implementation, like Sun's, has undefined
- * behaviour if the array contains any NaN values.
- *
- * @param a the array to sort
- */
- public static void sort(double[] a) {
- qsort(a, 0, a.length);
- }
-
- private static double cmp(double i, double j) {
- return i-j;
- }
-
- private static int med3(int a, int b, int c, double[] d) {
- return cmp(d[a], d[b]) < 0 ?
- (cmp(d[b], d[c]) < 0 ? b : cmp(d[a], d[c]) < 0 ? c : a)
- : (cmp(d[b], d[c]) > 0 ? b : cmp(d[a], d[c]) > 0 ? c : a);
- }
-
- private static void swap(int i, int j, double[] a) {
- double c = a[i];
- a[i] = a[j];
- a[j] = c;
- }
-
- private static void qsort(double[] a, int start, int n) {
- // use an insertion sort on small arrays
- if (n < 7) {
- for (int i = start + 1; i < start + n; i++)
- for (int j = i; j > 0 && cmp(a[j-1], a[j]) > 0; j--)
- swap(j, j-1, a);
- return;
- }
-
- int pm = n/2; // small arrays, middle element
- if (n > 7) {
- int pl = start;
- int pn = start + n-1;
-
- if (n > 40) { // big arrays, pseudomedian of 9
- int s = n/8;
- pl = med3(pl, pl+s, pl+2*s, a);
- pm = med3(pm-s, pm, pm+s, a);
- pn = med3(pn-2*s, pn-s, pn, a);
- }
- pm = med3(pl, pm, pn, a); // mid-size, med of 3
- }
-
- int pa, pb, pc, pd, pv;
- double r;
-
- pv = start; swap(pv, pm, a);
- pa = pb = start;
- pc = pd = start + n-1;
-
- for (;;) {
- while (pb <= pc && (r = cmp(a[pb], a[pv])) <= 0) {
- if (r == 0) { swap(pa, pb, a); pa++; }
- pb++;
- }
- while (pc >= pb && (r = cmp(a[pc], a[pv])) >= 0) {
- if (r == 0) { swap(pc, pd, a); pd--; }
- pc--;
- }
- if (pb > pc) break;
- swap(pb, pc, a);
- pb++;
- pc--;
- }
- int pn = start + n;
- int s;
- s = Math.min(pa-start, pb-pa); vecswap(start, pb-s, s, a);
- s = Math.min(pd-pc, pn-pd-1); vecswap(pb, pn-s, s, a);
- if ((s = pb-pa) > 1) qsort(a, start, s);
- if ((s = pd-pc) > 1) qsort(a, pn-s, s);
- }
-
- private static void vecswap(int i, int j, int n, double[] a) {
- for (; n > 0; i++, j++, n--)
- swap(i, j, a);
- }
-
- /**
- * Sort a float array into ascending order. The sort algorithm is an
- * optimised quicksort, as described in Jon L. Bentley and M. Douglas
- * McIlroy's "Engineering a Sort Function", Software-Practice and Experience,
- * Vol. 23(11) P. 1249-1265 (November 1993). This algorithm gives nlog(n)
- * performance on many arrays that would take quadratic time with a standard
- * quicksort. Note that this implementation, like Sun's, has undefined
- * behaviour if the array contains any NaN values.
- *
- * @param a the array to sort
- */
- public static void sort(float[] a) {
- qsort(a, 0, a.length);
- }
-
- private static float cmp(float i, float j) {
- return i-j;
- }
-
- private static int med3(int a, int b, int c, float[] d) {
- return cmp(d[a], d[b]) < 0 ?
- (cmp(d[b], d[c]) < 0 ? b : cmp(d[a], d[c]) < 0 ? c : a)
- : (cmp(d[b], d[c]) > 0 ? b : cmp(d[a], d[c]) > 0 ? c : a);
- }
-
- private static void swap(int i, int j, float[] a) {
- float c = a[i];
- a[i] = a[j];
- a[j] = c;
- }
-
- private static void qsort(float[] a, int start, int n) {
- // use an insertion sort on small arrays
- if (n < 7) {
- for (int i = start + 1; i < start + n; i++)
- for (int j = i; j > 0 && cmp(a[j-1], a[j]) > 0; j--)
- swap(j, j-1, a);
- return;
- }
-
- int pm = n/2; // small arrays, middle element
- if (n > 7) {
- int pl = start;
- int pn = start + n-1;
-
- if (n > 40) { // big arrays, pseudomedian of 9
- int s = n/8;
- pl = med3(pl, pl+s, pl+2*s, a);
- pm = med3(pm-s, pm, pm+s, a);
- pn = med3(pn-2*s, pn-s, pn, a);
- }
- pm = med3(pl, pm, pn, a); // mid-size, med of 3
- }
-
- int pa, pb, pc, pd, pv;
- float r;
-
- pv = start; swap(pv, pm, a);
- pa = pb = start;
- pc = pd = start + n-1;
-
- for (;;) {
- while (pb <= pc && (r = cmp(a[pb], a[pv])) <= 0) {
- if (r == 0) { swap(pa, pb, a); pa++; }
- pb++;
- }
- while (pc >= pb && (r = cmp(a[pc], a[pv])) >= 0) {
- if (r == 0) { swap(pc, pd, a); pd--; }
- pc--;
- }
- if (pb > pc) break;
- swap(pb, pc, a);
- pb++;
- pc--;
- }
- int pn = start + n;
- int s;
- s = Math.min(pa-start, pb-pa); vecswap(start, pb-s, s, a);
- s = Math.min(pd-pc, pn-pd-1); vecswap(pb, pn-s, s, a);
- if ((s = pb-pa) > 1) qsort(a, start, s);
- if ((s = pd-pc) > 1) qsort(a, pn-s, s);
- }
-
- private static void vecswap(int i, int j, int n, float[] a) {
- for (; n > 0; i++, j++, n--)
- swap(i, j, a);
- }
-
- /**
- * Sort an int array into ascending order. The sort algorithm is an optimised
- * quicksort, as described in Jon L. Bentley and M. Douglas McIlroy's
- * "Engineering a Sort Function", Software-Practice and Experience, Vol.
- * 23(11) P. 1249-1265 (November 1993). This algorithm gives nlog(n)
- * performance on many arrays that would take quadratic time with a standard
- * quicksort.
- *
- * @param a the array to sort
- */
- public static void sort(int[] a) {
- qsort(a, 0, a.length);
- }
-
- private static long cmp(int i, int j) {
- return (long)i-(long)j;
- }
-
- private static int med3(int a, int b, int c, int[] d) {
- return cmp(d[a], d[b]) < 0 ?
- (cmp(d[b], d[c]) < 0 ? b : cmp(d[a], d[c]) < 0 ? c : a)
- : (cmp(d[b], d[c]) > 0 ? b : cmp(d[a], d[c]) > 0 ? c : a);
- }
-
- private static void swap(int i, int j, int[] a) {
- int c = a[i];
- a[i] = a[j];
- a[j] = c;
- }
-
- private static void qsort(int[] a, int start, int n) {
- // use an insertion sort on small arrays
- if (n < 7) {
- for (int i = start + 1; i < start + n; i++)
- for (int j = i; j > 0 && cmp(a[j-1], a[j]) > 0; j--)
- swap(j, j-1, a);
- return;
- }
-
- int pm = n/2; // small arrays, middle element
- if (n > 7) {
- int pl = start;
- int pn = start + n-1;
-
- if (n > 40) { // big arrays, pseudomedian of 9
- int s = n/8;
- pl = med3(pl, pl+s, pl+2*s, a);
- pm = med3(pm-s, pm, pm+s, a);
- pn = med3(pn-2*s, pn-s, pn, a);
- }
- pm = med3(pl, pm, pn, a); // mid-size, med of 3
- }
-
- int pa, pb, pc, pd, pv;
- long r;
-
- pv = start; swap(pv, pm, a);
- pa = pb = start;
- pc = pd = start + n-1;
-
- for (;;) {
- while (pb <= pc && (r = cmp(a[pb], a[pv])) <= 0) {
- if (r == 0) { swap(pa, pb, a); pa++; }
- pb++;
- }
- while (pc >= pb && (r = cmp(a[pc], a[pv])) >= 0) {
- if (r == 0) { swap(pc, pd, a); pd--; }
- pc--;
- }
- if (pb > pc) break;
- swap(pb, pc, a);
- pb++;
- pc--;
- }
- int pn = start + n;
- int s;
- s = Math.min(pa-start, pb-pa); vecswap(start, pb-s, s, a);
- s = Math.min(pd-pc, pn-pd-1); vecswap(pb, pn-s, s, a);
- if ((s = pb-pa) > 1) qsort(a, start, s);
- if ((s = pd-pc) > 1) qsort(a, pn-s, s);
- }
-
- private static void vecswap(int i, int j, int n, int[] a) {
- for (; n > 0; i++, j++, n--)
- swap(i, j, a);
- }
-
- /**
- * Sort a long array into ascending order. The sort algorithm is an optimised
- * quicksort, as described in Jon L. Bentley and M. Douglas McIlroy's
- * "Engineering a Sort Function", Software-Practice and Experience, Vol.
- * 23(11) P. 1249-1265 (November 1993). This algorithm gives nlog(n)
- * performance on many arrays that would take quadratic time with a standard
- * quicksort.
- *
- * @param a the array to sort
- */
- public static void sort(long[] a) {
- qsort(a, 0, a.length);
- }
-
- // The "cmp" method has been removed from here and replaced with direct
- // compares in situ, to avoid problems with overflow if the difference
- // between two numbers is bigger than a long will hold.
- // One particular change as a result is the use of r1 and r2 in qsort
-
- private static int med3(int a, int b, int c, long[] d) {
- return d[a] < d[b] ?
- (d[b] < d[c] ? b : d[a] < d[c] ? c : a)
- : (d[b] > d[c] ? b : d[a] > d[c] ? c : a);
- }
-
- private static void swap(int i, int j, long[] a) {
- long c = a[i];
- a[i] = a[j];
- a[j] = c;
- }
-
- private static void qsort(long[] a, int start, int n) {
- // use an insertion sort on small arrays
- if (n < 7) {
- for (int i = start + 1; i < start + n; i++)
- for (int j = i; j > 0 && a[j-1] > a[j]; j--)
- swap(j, j-1, a);
- return;
- }
-
- int pm = n/2; // small arrays, middle element
- if (n > 7) {
- int pl = start;
- int pn = start + n-1;
-
- if (n > 40) { // big arrays, pseudomedian of 9
- int s = n/8;
- pl = med3(pl, pl+s, pl+2*s, a);
- pm = med3(pm-s, pm, pm+s, a);
- pn = med3(pn-2*s, pn-s, pn, a);
- }
- pm = med3(pl, pm, pn, a); // mid-size, med of 3
- }
-
- int pa, pb, pc, pd, pv;
- long r1, r2;
-
- pv = start; swap(pv, pm, a);
- pa = pb = start;
- pc = pd = start + n-1;
-
- for (;;) {
- while (pb <= pc && (r1 = a[pb]) <= (r2 = a[pv])) {
- if (r1 == r2) { swap(pa, pb, a); pa++; }
- pb++;
- }
- while (pc >= pb && (r1 = a[pc]) >= (r2 = a[pv])) {
- if (r1 == r2) { swap(pc, pd, a); pd--; }
- pc--;
- }
- if (pb > pc) break;
- swap(pb, pc, a);
- pb++;
- pc--;
- }
- int pn = start + n;
- int s;
- s = Math.min(pa-start, pb-pa); vecswap(start, pb-s, s, a);
- s = Math.min(pd-pc, pn-pd-1); vecswap(pb, pn-s, s, a);
- if ((s = pb-pa) > 1) qsort(a, start, s);
- if ((s = pd-pc) > 1) qsort(a, pn-s, s);
- }
-
- private static void vecswap(int i, int j, int n, long[] a) {
- for (; n > 0; i++, j++, n--)
- swap(i, j, a);
- }
-
- /**
- * Sort a short array into ascending order. The sort algorithm is an
- * optimised quicksort, as described in Jon L. Bentley and M. Douglas
- * McIlroy's "Engineering a Sort Function", Software-Practice and Experience,
- * Vol. 23(11) P. 1249-1265 (November 1993). This algorithm gives nlog(n)
- * performance on many arrays that would take quadratic time with a standard
- * quicksort.
- *
- * @param a the array to sort
- */
- public static void sort(short[] a) {
- qsort(a, 0, a.length);
- }
-
- private static int cmp(short i, short j) {
- return i-j;
- }
-
- private static int med3(int a, int b, int c, short[] d) {
- return cmp(d[a], d[b]) < 0 ?
- (cmp(d[b], d[c]) < 0 ? b : cmp(d[a], d[c]) < 0 ? c : a)
- : (cmp(d[b], d[c]) > 0 ? b : cmp(d[a], d[c]) > 0 ? c : a);
- }
-
- private static void swap(int i, int j, short[] a) {
- short c = a[i];
- a[i] = a[j];
- a[j] = c;
- }
-
- private static void qsort(short[] a, int start, int n) {
- // use an insertion sort on small arrays
- if (n < 7) {
- for (int i = start + 1; i < start + n; i++)
- for (int j = i; j > 0 && cmp(a[j-1], a[j]) > 0; j--)
- swap(j, j-1, a);
- return;
- }
-
- int pm = n/2; // small arrays, middle element
- if (n > 7) {
- int pl = start;
- int pn = start + n-1;
-
- if (n > 40) { // big arrays, pseudomedian of 9
- int s = n/8;
- pl = med3(pl, pl+s, pl+2*s, a);
- pm = med3(pm-s, pm, pm+s, a);
- pn = med3(pn-2*s, pn-s, pn, a);
- }
- pm = med3(pl, pm, pn, a); // mid-size, med of 3
- }
-
- int pa, pb, pc, pd, pv;
- int r;
-
- pv = start; swap(pv, pm, a);
- pa = pb = start;
- pc = pd = start + n-1;
-
- for (;;) {
- while (pb <= pc && (r = cmp(a[pb], a[pv])) <= 0) {
- if (r == 0) { swap(pa, pb, a); pa++; }
- pb++;
- }
- while (pc >= pb && (r = cmp(a[pc], a[pv])) >= 0) {
- if (r == 0) { swap(pc, pd, a); pd--; }
- pc--;
- }
- if (pb > pc) break;
- swap(pb, pc, a);
- pb++;
- pc--;
- }
- int pn = start + n;
- int s;
- s = Math.min(pa-start, pb-pa); vecswap(start, pb-s, s, a);
- s = Math.min(pd-pc, pn-pd-1); vecswap(pb, pn-s, s, a);
- if ((s = pb-pa) > 1) qsort(a, start, s);
- if ((s = pd-pc) > 1) qsort(a, pn-s, s);
- }
-
- private static void vecswap(int i, int j, int n, short[] a) {
- for (; n > 0; i++, j++, n--)
- swap(i, j, a);
- }
-
- /**
- * The bulk of the work for the object sort routines. In general,
- * the code attempts to be simple rather than fast, the idea being
- * that a good optimising JIT will be able to optimise it better
- * than I can, and if I try it will make it more confusing for the
- * JIT.
- */
- private static void mergeSort(Object[] a, int from, int to, Comparator c)
- {
- // First presort the array in chunks of length 6 with insertion sort.
- // mergesort would give too much overhead for this length.
- for (int chunk = from; chunk < to; chunk += 6)
- {
- int end = Math.min(chunk+6, to);
- for (int i = chunk + 1; i < end; i++)
- {
- if (c.compare(a[i-1], a[i]) > 0)
- {
- // not already sorted
- int j=i;
- Object elem = a[j];
- do
- {
- a[j] = a[j-1];
- j--;
- }
- while (j>chunk && c.compare(a[j-1], elem) > 0);
- a[j] = elem;
- }
- }
- }
-
- int len = to - from;
- // If length is smaller or equal 6 we are done.
- if (len <= 6)
- return;
-
- Object[] src = a;
- Object[] dest = new Object[len];
- Object[] t = null; // t is used for swapping src and dest
-
- // The difference of the fromIndex of the src and dest array.
- int srcDestDiff = -from;
-
- // The merges are done in this loop
- for (int size = 6; size < len; size <<= 1)
- {
- for (int start = from; start < to; start += size << 1)
- {
- // mid ist the start of the second sublist;
- // end the start of the next sublist (or end of array).
- int mid = start + size;
- int end = Math.min(to, mid + size);
-
- // The second list is empty or the elements are already in
- // order - no need to merge
- if (mid >= end || c.compare(src[mid - 1], src[mid]) <= 0) {
- System.arraycopy(src, start,
- dest, start + srcDestDiff, end - start);
-
- // The two halves just need swapping - no need to merge
- } else if (c.compare(src[start], src[end - 1]) > 0) {
- System.arraycopy(src, start,
- dest, end - size + srcDestDiff, size);
- System.arraycopy(src, mid,
- dest, start + srcDestDiff, end - mid);
-
- } else {
- // Declare a lot of variables to save repeating
- // calculations. Hopefully a decent JIT will put these
- // in registers and make this fast
- int p1 = start;
- int p2 = mid;
- int i = start + srcDestDiff;
-
- // The main merge loop; terminates as soon as either
- // half is ended
- while (p1 < mid && p2 < end)
- {
- dest[i++] =
- src[c.compare(src[p1], src[p2]) <= 0 ? p1++ : p2++];
- }
-
- // Finish up by copying the remainder of whichever half
- // wasn't finished.
- if (p1 < mid)
- System.arraycopy(src, p1, dest, i, mid - p1);
- else
- System.arraycopy(src, p2, dest, i, end - p2);
- }
- }
- // swap src and dest ready for the next merge
- t = src; src = dest; dest = t;
- from += srcDestDiff;
- to += srcDestDiff;
- srcDestDiff = -srcDestDiff;
- }
-
- // make sure the result ends up back in the right place. Note
- // that src and dest may have been swapped above, so src
- // contains the sorted array.
- if (src != a)
- {
- // Note that from == 0.
- System.arraycopy(src, 0, a, srcDestDiff, to);
- }
- }
-
- /**
- * Sort an array of Objects according to their natural ordering. The sort is
- * guaranteed to be stable, that is, equal elements will not be reordered.
- * The sort algorithm is a mergesort with the merge omitted if the last
- * element of one half comes before the first element of the other half. This
- * algorithm gives guaranteed O(nlog(n)) time, at the expense of making a
- * copy of the array.
- *
- * @param a the array to be sorted
- * @exception ClassCastException if any two elements are not mutually
- * comparable
- * @exception NullPointerException if an element is null (since
- * null.compareTo cannot work)
- */
- public static void sort(Object[] a) {
- mergeSort(a, 0, a.length, defaultComparator);
- }
-
- /**
- * Sort an array of Objects according to a Comparator. The sort is
- * guaranteed to be stable, that is, equal elements will not be reordered.
- * The sort algorithm is a mergesort with the merge omitted if the last
- * element of one half comes before the first element of the other half. This
- * algorithm gives guaranteed O(nlog(n)) time, at the expense of making a
- * copy of the array.
- *
- * @param a the array to be sorted
- * @param c a Comparator to use in sorting the array
- * @exception ClassCastException if any two elements are not mutually
- * comparable by the Comparator provided
- */
- public static void sort(Object[] a, Comparator c) {
- mergeSort(a, 0, a.length, c);
- }
-
- /**
- * Sort an array of Objects according to their natural ordering. The sort is
- * guaranteed to be stable, that is, equal elements will not be reordered.
- * The sort algorithm is a mergesort with the merge omitted if the last
- * element of one half comes before the first element of the other half. This
- * algorithm gives guaranteed O(nlog(n)) time, at the expense of making a
- * copy of the array.
- *
- * @param a the array to be sorted
- * @param fromIndex the index of the first element to be sorted.
- * @param toIndex the index of the last element to be sorted plus one.
- * @exception ClassCastException if any two elements are not mutually
- * comparable by the Comparator provided
- * @exception ArrayIndexOutOfBoundsException, if fromIndex and toIndex
- * are not in range.
- * @exception IllegalArgumentException if fromIndex > toIndex
- */
- public static void sort(Object[] a, int fromIndex,
- int toIndex) {
- if (fromIndex > toIndex)
- throw new IllegalArgumentException("fromIndex "+fromIndex
- +" > toIndex "+toIndex);
- mergeSort(a, fromIndex, toIndex, defaultComparator);
- }
-
- /**
- * Sort an array of Objects according to a Comparator. The sort is
- * guaranteed to be stable, that is, equal elements will not be reordered.
- * The sort algorithm is a mergesort with the merge omitted if the last
- * element of one half comes before the first element of the other half. This
- * algorithm gives guaranteed O(nlog(n)) time, at the expense of making a
- * copy of the array.
- *
- * @param a the array to be sorted
- * @param fromIndex the index of the first element to be sorted.
- * @param toIndex the index of the last element to be sorted plus one.
- * @param c a Comparator to use in sorting the array
- * @exception ClassCastException if any two elements are not mutually
- * comparable by the Comparator provided
- * @exception ArrayIndexOutOfBoundsException, if fromIndex and toIndex
- * are not in range.
- * @exception IllegalArgumentException if fromIndex > toIndex
- */
- public static void sort(Object[] a, int fromIndex,
- int toIndex, Comparator c) {
- if (fromIndex > toIndex)
- throw new IllegalArgumentException("fromIndex "+fromIndex
- +" > toIndex "+toIndex);
- mergeSort(a, fromIndex, toIndex, c);
- }
-
- /**
- * Returns a list "view" of the specified array. This method is intended to
- * make it easy to use the Collections API with existing array-based APIs and
- * programs.
- *
- * @param a the array to return a view of
- * @returns a fixed-size list, changes to which "write through" to the array
- */
- public static List asList(final Object[] a) {
-
- if (a == null) {
- throw new NullPointerException();
- }
-
- return new ListImpl( a );
- }
-
-
- /**
- * Inner class used by asList(Object[]) to provide a list interface
- * to an array. The methods are all simple enough to be self documenting.
- * Note: When Sun fully specify serialized forms, this class will have to
- * be renamed.
- */
- private static class ListImpl extends AbstractList {
-
- ListImpl(Object[] a) {
- this.a = a;
- }
-
- public Object get(int index) {
- return a[index];
- }
-
- public int size() {
- return a.length;
- }
-
- public Object set(int index, Object element) {
- Object old = a[index];
- a[index] = element;
- return old;
- }
-
- private Object[] a;
- }
-
-}
diff --git a/libjava/java/util/BitSet.java b/libjava/java/util/BitSet.java
deleted file mode 100644
index 56d89b116b6..00000000000
--- a/libjava/java/util/BitSet.java
+++ /dev/null
@@ -1,177 +0,0 @@
-// BitSet - A vector of bits.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-import java.io.Serializable;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 23, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * hashCode algorithm taken from JDK 1.2 docs.
- */
-
-public final class BitSet implements Cloneable, Serializable
-{
- public void and (BitSet bs)
- {
- int max = Math.min(bits.length, bs.bits.length);
- int i;
- for (i = 0; i < max; ++i)
- bits[i] &= bs.bits[i];
- for ( ; i < bits.length; ++i)
- bits[i] = 0;
- }
-
- public BitSet ()
- {
- this (64);
- }
-
- public BitSet (int nbits)
- {
- if (nbits < 0)
- throw new NegativeArraySizeException ();
- int length = nbits / 64;
- if (nbits % 64 != 0)
- ++length;
- bits = new long[length];
- }
-
- public void clear (int pos)
- {
- if (pos < 0)
- throw new IndexOutOfBoundsException ();
- int bit = pos % 64;
- int offset = pos / 64;
- ensure (offset);
- bits[offset] &= ~ (1L << bit);
- }
-
- public Object clone ()
- {
- BitSet bs = new BitSet (bits.length * 64);
- System.arraycopy(bits, 0, bs.bits, 0, bits.length);
- return bs;
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof BitSet))
- return false;
- BitSet bs = (BitSet) obj;
- int max = Math.min(bits.length, bs.bits.length);
- int i;
- for (i = 0; i < max; ++i)
- if (bits[i] != bs.bits[i])
- return false;
- // If one is larger, check to make sure all extra bits are 0.
- for (int j = i; j < bits.length; ++j)
- if (bits[j] != 0)
- return false;
- for (int j = i; j < bs.bits.length; ++j)
- if (bs.bits[j] != 0)
- return false;
- return true;
- }
-
- public boolean get (int pos)
- {
- if (pos < 0)
- throw new IndexOutOfBoundsException ();
-
- int bit = pos % 64;
- int offset = pos / 64;
-
- if (offset >= bits.length)
- return false;
-
- return (bits[offset] & (1L << bit)) == 0 ? false : true;
- }
-
- public int hashCode ()
- {
- long h = 1234;
- for (int i = bits.length - 1; i >= 0; --i)
- h ^= bits[i] * (i + 1);
- return (int) ((h >> 32) ^ h);
- }
-
- public void or (BitSet bs)
- {
- ensure (bs.bits.length - 1);
- int i;
- for (i = 0; i < bs.bits.length; ++i)
- bits[i] |= bs.bits[i];
- }
-
- public void set (int pos)
- {
- if (pos < 0)
- throw new IndexOutOfBoundsException ();
- int bit = pos % 64;
- int offset = pos / 64;
- ensure (offset);
- bits[offset] |= 1L << bit;
- }
-
- public int size ()
- {
- return bits.length * 64;
- }
-
- public String toString ()
- {
- StringBuffer result = new StringBuffer ("{");
- boolean first = true;
- for (int i = 0; i < bits.length; ++i)
- {
- int bit = 1;
- long word = bits[i];
- for (int j = 0; j < 64; ++j)
- {
- if ((word & bit) != 0)
- {
- if (! first)
- result.append(", ");
- result.append(64 * i + j);
- first = false;
- }
- bit <<= 1;
- }
- }
-
- return result.append("}").toString();
- }
-
- public void xor (BitSet bs)
- {
- ensure (bs.bits.length - 1);
- int i;
- for (i = 0; i < bs.bits.length; ++i)
- bits[i] ^= bs.bits[i];
- }
-
- // Make sure the vector is big enough.
- private final void ensure (int lastElt)
- {
- if (lastElt + 1 > bits.length)
- {
- long[] nd = new long[lastElt + 1];
- System.arraycopy(bits, 0, nd, 0, bits.length);
- bits = nd;
- }
- }
-
- // The actual bits.
- private long[] bits;
-}
diff --git a/libjava/java/util/Calendar.java b/libjava/java/util/Calendar.java
deleted file mode 100644
index b5eaa4d39d6..00000000000
--- a/libjava/java/util/Calendar.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 24, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * and "The Java Language Specification", ISBN 0-201-63451-1.
- * Status: Unimplemented: getAvailableLocales.
- * No Locale knowledge.
- */
-
-public abstract class Calendar implements java.io.Serializable, Cloneable
-{
- public final static int JANUARY = 0;
- public final static int FEBRUARY = 1;
- public final static int MARCH = 2;
- public final static int APRIL = 3;
- public final static int MAY = 4;
- public final static int JUNE = 5;
- public final static int JULY = 6;
- public final static int AUGUST = 7;
- public final static int SEPTEMBER = 8;
- public final static int OCTOBER = 9;
- public final static int NOVEMBER = 10;
- public final static int DECEMBER = 11;
- public final static int UNDECIMBER = 12;
-
- public final static int SUNDAY = 1;
- public final static int MONDAY = 2;
- public final static int TUESDAY = 3;
- public final static int WEDNESDAY = 4;
- public final static int THURSDAY = 5;
- public final static int FRIDAY = 6;
- public final static int SATURDAY = 7;
-
- public final static int AM = 0;
- public final static int PM = 1;
-
- public final static int FIELD_COUNT = 17;
-
- // These constants are not docuemnted, but were determined using
- // a simple test program.
- public final static int ERA = 0;
- public final static int YEAR = 1;
- public final static int MONTH = 2;
- public final static int WEEK_OF_YEAR = 3;
- public final static int WEEK_OF_MONTH = 4;
- public final static int DATE = 5;
- public final static int DAY_OF_MONTH = 5;
- public final static int DAY_OF_YEAR = 6;
- public final static int DAY_OF_WEEK = 7;
- public final static int DAY_OF_WEEK_IN_MONTH = 8;
- public final static int AM_PM = 9;
- public final static int HOUR = 10;
- public final static int HOUR_OF_DAY = 11;
- public final static int MINUTE = 12;
- public final static int SECOND = 13;
- public final static int MILLISECOND = 14;
- public final static int ZONE_OFFSET = 15;
- public final static int DST_OFFSET = 16;
-
- // The fields are as specified in Sun's "Serialized Form"
- // in the JDK 1.2 beta 4 API specification.
- protected boolean areFieldsSet;
- protected int[] fields;
- private int firstDayOfWeek;
- protected boolean[] isSet;
- protected boolean isTimeSet;
- private boolean lenient;
- private int minimalDaysInFirstWeek;
- private int nextStamp;
- //private int serialVersionOnStream;
- protected long time;
- private TimeZone zone;
-
- protected Calendar ()
- {
- this (null, null);
- }
-
- protected Calendar (TimeZone zone, Locale loc)
- {
- fields = new int[FIELD_COUNT];
- isSet = new boolean[FIELD_COUNT];
- firstDayOfWeek = SUNDAY; // Locale-dependent. FIXME.
- this.zone = zone != null ? zone : TimeZone.getDefault();
- }
-
- public Object clone ()
- {
- try
- {
- return super.clone();
- }
- catch (CloneNotSupportedException ex)
- {
- throw new RuntimeException("internal error - "+ex);
- }
- }
-
- public String toString ()
- {
- // We have much latitude in how we implement this.
- return ("areFieldsSet " + areFieldsSet
- + "; fields " + fields
- + "; firstDayOfWeek " + firstDayOfWeek
- + "; isSet " + isSet
- + "; isTimeSet " + isTimeSet
- + "; lenient " + lenient
- + "; minimalDaysInFirstWeek " + minimalDaysInFirstWeek
- + "; nextStamp " + nextStamp
- + "; time " + time
- + "; zone " + zone);
- }
-
- public static Calendar getInstance ()
- {
- return new GregorianCalendar ();
- }
-
- public static Calendar getInstance (TimeZone zone)
- {
- return new GregorianCalendar (zone);
- }
-
- public static Calendar getInstance (Locale locale)
- {
- return new GregorianCalendar (locale);
- }
-
- public static Calendar getInstance (TimeZone zone, Locale locale)
- {
- return new GregorianCalendar (zone, locale);
- }
-
- public boolean isLenient() { return lenient; }
- public void setLenient (boolean lenient) { this.lenient = lenient; }
-
- public int getFirstDayOfWeek ()
- {
- return firstDayOfWeek;
- }
-
- public void setFirstDayOfWeek (int value)
- {
- firstDayOfWeek = value;
- }
-
- public int getMinimalDaysInFirstWeek ()
- {
- return minimalDaysInFirstWeek;
- }
-
- public void setMinimalDaysInFirstWeek (int value)
- {
- minimalDaysInFirstWeek = value;
- }
-
- public TimeZone getTimeZone ()
- {
- return zone;
- }
-
- public void setTimeZone (TimeZone tz)
- {
- zone = tz;
- }
-
- abstract public void add(int fld, int amount);
- abstract public void roll (int fld, boolean up);
-
- public final void set (int year, int month, int date)
- {
- set(YEAR, year);
- set(MONTH, month);
- set(DATE, date);
- }
-
- public final void set (int year, int month, int date, int hour, int minute)
- {
- set(year, month, date);
- set(HOUR_OF_DAY, hour);
- set(MINUTE, minute);
- }
-
- public final void set (int year, int month, int date,
- int hour, int minute, int second)
- {
- set(year, month, date, hour, minute);
- set(SECOND, second);
- }
-
- public final void set (int fld, int value)
- {
- if (! areFieldsSet) computeFields();
- fields[fld] = value;
- isTimeSet = false;
- }
-
- public final void clear (int fld)
- {
- fields[fld] = 0;
- isSet[fld] = false;
- areFieldsSet = false;
- }
-
- public final void clear ()
- {
- for (int fld = FIELD_COUNT; --fld >= 0; )
- {
- fields[fld] = 0;
- isSet[fld] = false;
- }
- areFieldsSet = false;
- }
-
- protected void complete()
- {
- if (!isTimeSet) computeTime();
- if (!areFieldsSet) computeFields();
- }
-
- protected abstract void computeFields();
- protected abstract void computeTime();
-
- protected final int internalGet (int fld) { return fields[fld]; }
-
- public final int get(int fld)
- {
- complete();
- return fields[fld];
- }
-
- public abstract boolean after (Object cal);
- public abstract boolean before (Object cal);
- public abstract boolean equals (Object obj);
-
- protected long getTimeInMillis()
- {
- if (!isTimeSet) computeTime();
- return time;
- }
-
- public final Date getTime() { return new Date(getTimeInMillis()); }
-
- public final void setTime (Date date)
- {
- setTimeInMillis(date.getTime());
- }
-
- protected void setTimeInMillis (long millis)
- {
- time = millis;
- isTimeSet = true;
- clear();
- }
-
- abstract public int getMaximum(int fld);
- abstract public int getMinimum(int fld);
- abstract public int getGreatestMinimum(int fld);
- abstract public int getLeastMaximum(int fld);
-
- public final boolean isSet(int fld) { return isSet[fld]; }
-}
diff --git a/libjava/java/util/Collection.java b/libjava/java/util/Collection.java
deleted file mode 100644
index 46da71b1dc7..00000000000
--- a/libjava/java/util/Collection.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 16, 2000.
- */
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface Collection
-{
- public int size();
- public boolean isEmpty();
- public boolean contains(Object o);
- public Iterator iterator();
- public Object[] toArray();
- public Object[] toArray(Object[] a);
- public boolean add(Object o);
- public boolean remove(Object o);
- public boolean containsAll(Collection c);
- public boolean addAll(Collection c);
- public boolean removeAll(Collection c);
- public boolean retainAll(Collection c);
- public void clear();
- public boolean equals(Object o);
- public int hashCode();
-}
diff --git a/libjava/java/util/Comparator.java b/libjava/java/util/Comparator.java
deleted file mode 100644
index 8f114ee79b0..00000000000
--- a/libjava/java/util/Comparator.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 16, 2000.
- */
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface Comparator
-{
- public int compare(Object o1, Object o2);
- public boolean equals(Object obj);
-}
diff --git a/libjava/java/util/ConcurrentModificationException.java b/libjava/java/util/ConcurrentModificationException.java
deleted file mode 100644
index 6849fcc87bc..00000000000
--- a/libjava/java/util/ConcurrentModificationException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-/* Added in JDK 1.2 */
-public class ConcurrentModificationException extends RuntimeException
-{
- public ConcurrentModificationException()
- {
- super();
- }
-
- public ConcurrentModificationException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/util/Date.java b/libjava/java/util/Date.java
deleted file mode 100644
index 6a8a7654938..00000000000
--- a/libjava/java/util/Date.java
+++ /dev/null
@@ -1,483 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-import java.text.*;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 24, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * "The Java Language Specification", ISBN 0-201-63451-1,
- * and O'Reilly's "Java in a Nutshell".
- * Status: Need to re-write toString().
- * Missing: ToGMTString and toLocaleString.
- * Serialization spec: Specifies readObject/writeObject.
- */
-
-public class Date implements java.io.Serializable, Cloneable
-{
- private long millis;
-
- public Date() { millis = System.currentTimeMillis(); }
-
- public Date(long millis) { this.millis = millis; }
-
- public Date(int year, int month, int date, int hours,
- int minutes, int seconds)
- {
- setTime(year, month, date, hours, minutes, seconds);
- }
-
- public Date(int year, int month, int date, int hours, int minutes)
- {
- setTime(year, month, date, hours, minutes, 0);
- }
-
- public Date(int year, int month, int date)
- {
- setTime(year, month, date, 0, 0, 0);
- }
-
- public Date (String s) { this(parse(s)); }
-
- private static int skipParens(String string, int offset)
- {
- int len = string.length();
- int p = 0;
- int i;
-
- for (i = offset; i < len; ++i)
- {
- if (string.charAt(i) == '(')
- ++p;
- else if (string.charAt(i) == ')')
- {
- --p;
- if (p == 0)
- return i + 1;
- // If we've encounted unbalanced parens, just return the
- // leftover one as an ordinary character. It will be
- // caught later in parsing and cause an
- // IllegalArgumentException.
- if (p < 0)
- return i;
- }
- }
-
- // Not sure what to do if `p != 0' here.
- return i;
- }
-
- private static int parseTz(String tok, char sign)
- throws IllegalArgumentException
- {
- int num;
-
- try
- {
- // parseInt doesn't handle '+' so strip off sign.
- num = Integer.parseInt(tok.substring(1));
- }
- catch (NumberFormatException ex)
- {
- throw new IllegalArgumentException(tok);
- }
-
- // Convert hours to minutes.
- if (num < 24)
- num *= 60;
- else
- num = (num / 100) * 60 + num % 100;
-
- return sign == '-' ? -num : num;
- }
-
- private static int parseMonth(String tok)
- {
- // Initialize strings for month names.
- // We could possibly use the fields of DateFormatSymbols but that is
- // localized and thus might not match the English words specified.
- String months[] = { "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY",
- "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER",
- "NOVEMBER", "DECEMBER" };
-
- int i;
- for (i = 0; i < 12; i++)
- if (months[i].startsWith(tok))
- return i;
-
- // Return -1 if not found.
- return -1;
- }
-
- private static boolean parseDayOfWeek(String tok)
- {
- // Initialize strings for days of the week names.
- // We could possibly use the fields of DateFormatSymbols but that is
- // localized and thus might not match the English words specified.
- String daysOfWeek[] = { "SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY",
- "THURSDAY", "FRIDAY", "SATURDAY" };
-
- int i;
- for (i = 0; i < 7; i++)
- if (daysOfWeek[i].startsWith(tok))
- return true;
-
- return false;
- }
-
- public static long parse(String string)
- {
- // Initialize date/time fields before parsing begins.
- int year = -1;
- int month = -1;
- int day = -1;
- int hour = -1;
- int minute = -1;
- int second = -1;
- int timezone = 0;
- boolean localTimezone = true;
-
- // Trim out any nested stuff in parentheses now to make parsing easier.
- StringBuffer buf = new StringBuffer();
- int off = 0;
- int openParenOffset, tmpMonth;
- while ((openParenOffset = string.indexOf('(', off)) >= 0)
- {
- // Copy part of string leading up to open paren.
- buf.append(string.substring(off, openParenOffset));
- off = skipParens(string, openParenOffset);
- }
- buf.append(string.substring(off));
-
- // Make all chars upper case to simplify comparisons later.
- // Also ignore commas; treat them as delimiters.
- StringTokenizer strtok =
- new StringTokenizer(buf.toString().toUpperCase(), " \t\n\r,");
-
- while (strtok.hasMoreTokens())
- {
- String tok = strtok.nextToken();
- char firstch = tok.charAt(0);
- if ((firstch == '+' || firstch == '-') && year >= 0)
- {
- timezone = parseTz(tok, firstch);
- localTimezone = false;
- }
- else if (firstch >= '0' && firstch <= '9')
- {
- while (tok != null && tok.length() > 0)
- {
- // A colon or slash may be valid in the number.
- // Find the first of these before calling parseInt.
- int colon = tok.indexOf(':');
- int slash = tok.indexOf('/');
- int hyphen = tok.indexOf('-');
- // We choose tok.length initially because it makes
- // processing simpler.
- int punctOffset = tok.length();
- if (colon >= 0)
- punctOffset = Math.min(punctOffset, colon);
- if (slash >= 0)
- punctOffset = Math.min(punctOffset, slash);
- if (hyphen >= 0)
- punctOffset = Math.min(punctOffset, hyphen);
- // Following code relies on -1 being the exceptional
- // case.
- if (punctOffset == tok.length())
- punctOffset = -1;
-
- int num;
- try
- {
- num = Integer.parseInt(punctOffset < 0 ? tok :
- tok.substring(0, punctOffset));
- }
- catch (NumberFormatException ex)
- {
- throw new IllegalArgumentException(tok);
- }
-
- // TBD: Spec says year can be followed by a slash. That might
- // make sense if using YY/MM/DD formats, but it would fail in
- // that format for years <= 70. Also, what about 1900? That
- // is interpreted as the year 3800; seems that the comparison
- // should be num >= 1900 rather than just > 1900.
- // What about a year of 62 - 70? (61 or less could be a (leap)
- // second). 70/MM/DD cause an exception but 71/MM/DD is ok
- // even though there's no ambiguity in either case.
- // For the parse method, the spec as written seems too loose.
- // Until shown otherwise, we'll follow the spec as written.
- if (num > 70 && (punctOffset < 0 || punctOffset == slash))
- year = num > 1900 ? num - 1900 : num;
- else if (punctOffset > 0 && punctOffset == colon)
- {
- if (hour < 0)
- hour = num;
- else
- minute = num;
- }
- else if (punctOffset > 0 && punctOffset == slash)
- {
- if (month < 0)
- month = num - 1;
- else
- day = num;
- }
- else if (hour >= 0 && minute < 0)
- minute = num;
- else if (minute >= 0 && second < 0)
- second = num;
- else if (day < 0)
- day = num;
- else
- throw new IllegalArgumentException(tok);
-
- // Advance string if there's more to process in this token.
- if (punctOffset < 0 || punctOffset + 1 >= tok.length())
- tok = null;
- else
- tok = tok.substring(punctOffset + 1);
- }
- }
- else if (firstch >= 'A' && firstch <= 'Z')
- {
- if (tok.equals("AM"))
- {
- if (hour < 1 || hour > 12)
- throw new IllegalArgumentException(tok);
- if (hour == 12)
- hour = 0;
- }
- else if (tok.equals("PM"))
- {
- if (hour < 1 || hour > 12)
- throw new IllegalArgumentException(tok);
- if (hour < 12)
- hour += 12;
- }
- else if (parseDayOfWeek(tok))
- ; // Ignore it; throw the token away.
- else if (tok.equals("UT") || tok.equals("UTC") || tok.equals("GMT"))
- localTimezone = false;
- else if (tok.startsWith("UT") || tok.startsWith("GMT"))
- {
- int signOffset = 3;
- if (tok.charAt(1) == 'T' && tok.charAt(2) != 'C')
- signOffset = 2;
-
- char sign = tok.charAt(signOffset);
- if (sign != '+' && sign != '-')
- throw new IllegalArgumentException(tok);
-
- timezone = parseTz(tok.substring(signOffset), sign);
- localTimezone = false;
- }
- else if ((tmpMonth = parseMonth(tok)) >= 0)
- month = tmpMonth;
- else if (tok.length() == 3 && tok.charAt(2) == 'T')
- {
- // Convert timezone offset from hours to minutes.
- char ch = tok.charAt(0);
- if (ch == 'E')
- timezone = -5 * 60;
- else if (ch == 'C')
- timezone = -6 * 60;
- else if (ch == 'M')
- timezone = -7 * 60;
- else if (ch == 'P')
- timezone = -8 * 60;
- else
- throw new IllegalArgumentException(tok);
-
- // Shift 60 minutes for Daylight Savings Time.
- if (tok.charAt(1) == 'D')
- timezone += 60;
- else if (tok.charAt(1) != 'S')
- throw new IllegalArgumentException(tok);
-
- localTimezone = false;
- }
- else
- throw new IllegalArgumentException(tok);
- }
- else
- throw new IllegalArgumentException(tok);
- }
-
- // Unspecified minutes and seconds should default to 0.
- if (minute < 0)
- minute = 0;
- if (second < 0)
- second = 0;
-
- // Throw exception if any other fields have not been recognized and set.
- if (year < 0 || month < 0 || day < 0 || hour < 0)
- throw new IllegalArgumentException("Missing field");
-
- // Return the time in either local time or relative to GMT as parsed.
- // If no time-zone was specified, get the local one (in minutes) and
- // convert to milliseconds before adding to the UTC.
- return UTC(year, month, day, hour, minute, second) + (localTimezone ?
- new Date(year, month, day).getTimezoneOffset() * 60 * 1000:
- -timezone * 60 * 1000);
- }
-
- public boolean after (Date when) { return this.millis > when.millis; }
- public boolean before (Date when) { return this.millis < when.millis; }
-
- public boolean equals(Object obj)
- {
- return (obj != null && obj instanceof Date
- && ((Date)obj).millis == this.millis);
- }
-
- public long getTime() { return millis; }
-
- public int hashCode()
- {
- return (int)(millis^(millis>>>32));
- }
-
- private void setTime(int year, int month, int date,
- int hours, int minutes, int seconds)
- {
- Calendar cal = new GregorianCalendar(year+1900, month, date,
- hours, minutes, seconds);
- millis = cal.getTimeInMillis();
- }
-
- public void setTime(long millis) { this.millis = millis; }
-
- private int getField (int fld)
- {
- Calendar cal = new GregorianCalendar();
- cal.setTime(this);
- return cal.get(fld);
- }
-
- public int getYear ()
- {
- return getField(Calendar.YEAR) - 1900;
- }
-
- public int getMonth ()
- {
- return getField(Calendar.MONTH);
- }
-
- public int getDate ()
- {
- return getField(Calendar.DATE);
- }
-
- public int getDay ()
- {
- return getField(Calendar.DAY_OF_WEEK) - 1;
- }
-
- public int getHours ()
- {
- return getField(Calendar.HOUR_OF_DAY);
- }
-
- public int getMinutes ()
- {
- return getField(Calendar.MINUTE);
- }
-
- public int getSeconds ()
- {
- return getField(Calendar.SECOND);
- }
-
- private void setField (int fld, int value)
- {
- Calendar cal = new GregorianCalendar();
- cal.setTime(this);
- cal.set(fld, value);
- millis = cal.getTimeInMillis();
- }
-
- public void setYear (int year)
- {
- setField(Calendar.YEAR, 1900 + year);
- }
-
- public void setMonth (int month)
- {
- setField(Calendar.MONTH, month);
- }
-
- public void setDate (int date)
- {
- setField(Calendar.DATE, date);
- }
-
- public void setHours (int hours)
- {
- setField(Calendar.HOUR_OF_DAY, hours);
- }
-
- public void setMinutes (int minutes)
- {
- setField(Calendar.MINUTE, minutes);
- }
-
- public void setSeconds (int seconds)
- {
- setField(Calendar.SECOND, seconds);
- }
-
- public int getTimezoneOffset ()
- {
- Calendar cal = new GregorianCalendar();
- cal.setTime(this);
- return - (cal.get(Calendar.ZONE_OFFSET)
- + cal.get(Calendar.DST_OFFSET)/(60*1000));
- }
-
- public String toString ()
- {
- // This is slow, but does it matter? There is no particularly
- // fast way to do it, because we need the timezone offset, which
- // we don't store. Unix ctime() doesn't provide this information.
- SimpleDateFormat fmt = new SimpleDateFormat ("E MMM dd HH:mm:ss z yyyy",
- Locale.US);
- fmt.setTimeZone(TimeZone.getDefault());
- return fmt.format(this);
- }
-
- public String toGMTString ()
- {
- // This method is deprecated. We don't care if it is very slow.
- SimpleDateFormat fmt = new SimpleDateFormat ("d MMM yyyy HH:mm:ss 'GMT'",
- Locale.US);
- fmt.setTimeZone(TimeZone.zoneGMT);
- return fmt.format(this);
- }
-
- public String toLocaleString ()
- {
- // This method is deprecated. We don't care if it is very slow.
- DateFormat fmt = DateFormat.getDateTimeInstance();
- fmt.setTimeZone(TimeZone.getDefault());
- return fmt.format(this);
- }
-
- public static long UTC (int year, int month, int date,
- int hours, int minutes, int seconds)
- {
- GregorianCalendar cal = new GregorianCalendar (TimeZone.zoneGMT);
- cal.set(year+1900, month, date, hours, minutes, seconds);
- return cal.getTimeInMillis();
- }
-}
diff --git a/libjava/java/util/Dictionary.java b/libjava/java/util/Dictionary.java
deleted file mode 100644
index f127cc050fd..00000000000
--- a/libjava/java/util/Dictionary.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 31, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-/* The JDK 1.2 beta doc indicates that Dictionary is obsolete and that the
- * new java.util.Map interface should be used instead.
- */
-public abstract class Dictionary
-{
- public abstract Enumeration elements();
- public abstract Object get(Object key) throws NullPointerException;
- public abstract boolean isEmpty();
- public abstract Enumeration keys();
- public abstract Object put(Object key, Object elem)
- throws NullPointerException;
- public abstract Object remove(Object key) throws NullPointerException;
- public abstract int size();
-}
diff --git a/libjava/java/util/EmptyStackException.java b/libjava/java/util/EmptyStackException.java
deleted file mode 100644
index 234f3ff7c76..00000000000
--- a/libjava/java/util/EmptyStackException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class EmptyStackException extends RuntimeException
-{
- public EmptyStackException()
- {
- super();
- }
-}
diff --git a/libjava/java/util/Enumeration.java b/libjava/java/util/Enumeration.java
deleted file mode 100644
index 6f7299bc072..00000000000
--- a/libjava/java/util/Enumeration.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1.
- * Status: Believed complete and correct
- */
-
-public interface Enumeration
-{
- public boolean hasMoreElements();
- public Object nextElement() throws NoSuchElementException;
-}
diff --git a/libjava/java/util/EventListener.java b/libjava/java/util/EventListener.java
deleted file mode 100644
index 969f324238b..00000000000
--- a/libjava/java/util/EventListener.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// EventListener.java - Listen for events from event source.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date December 12, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Believed complete and correct.
- */
-
-public interface EventListener
-{
-}
diff --git a/libjava/java/util/EventObject.java b/libjava/java/util/EventObject.java
deleted file mode 100644
index ee6a7f64657..00000000000
--- a/libjava/java/util/EventObject.java
+++ /dev/null
@@ -1,42 +0,0 @@
-// EventObject.java - Represent events fired by objects.
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date December 12, 1998
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * Status: Believed complete, but not fully correct.
- */
-
-public class EventObject implements java.io.Serializable
-{
- public EventObject (Object source)
- {
- this.source = source;
- }
-
- public Object getSource ()
- {
- return source;
- }
-
- public String toString ()
- {
- // FIXME.
- return getSource().toString();
- }
-
- // Source of the event.
- protected transient Object source;
-}
diff --git a/libjava/java/util/GregorianCalendar.java b/libjava/java/util/GregorianCalendar.java
deleted file mode 100644
index d293790976b..00000000000
--- a/libjava/java/util/GregorianCalendar.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 24, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * and "The Java Language Specification", ISBN 0-201-63451-1.
- * Status: "leniency" is not handled, and neither is roll-over in
- * add and roll. This is partly because of unclear specification.
- * hashCode has no spec.
- */
-
-public class GregorianCalendar extends Calendar {
- public static final int BC = 0;
- public static final int AD = 1;
-
- // The fields are as specified in Sun's "Serialized Form"
- // in the JDK 1.2 beta 4 API specification.
- // Value from a simple test program (getGregorianChange.getTime()).
- long gregorianCutover = -12219292800000L;
-
- private final static int[] mins = {
- 0 /* ERA */,
- 1 /* YEAR */,
- 0 /* MONTH */,
- 0 /* WEEK_OF_YEAR */,
- 0 /* WEEK_OF_MONTH */,
- 1 /* DATE */,
- 1 /* DAY_OF_YEAR */,
- 1 /* DAY_OF_WEEK */,
- -1 /* DAY_OF_WEEK_IN_MONTH */,
- 0 /* AM_PM */,
- 0 /* HOUR */,
- 0 /* HOUR_OF_DAY */,
- 0 /* MINUTE */,
- 0 /* SECOND */,
- 0 /* MILLISECOND */,
- -43200000 /* ZONE_OFFSET */,
- 0 /* DST_OFFSET */
- };
-
- private final static int[] maxs = {
- 1 /* ERA */,
- 5000000 /* YEAR */,
- 11 /* MONTH */,
- 54 /* WEEK_OF_YEAR */,
- 6 /* WEEK_OF_MONTH */,
- 31 /* DATE */,
- 366 /* DAY_OF_YEAR */,
- 7 /* DAY_OF_WEEK */,
- 6 /* DAY_OF_WEEK_IN_MONTH */,
- 1 /* AM_PM */,
- 12 /* HOUR */,
- 23 /* HOUR_OF_DAY */,
- 59 /* MINUTE */,
- 59 /* SECOND */,
- 999 /* MILLISECOND */,
- 43200000 /* ZONE_OFFSET */,
- 3600000 /* DST_OFFSET */
- };
-
- private final static int[] leastMaximums = {
- 1 /* ERA */,
- 5000000 /* YEAR */,
- 11 /* MONTH */,
- 53 /* WEEK_OF_YEAR */,
- 6 /* WEEK_OF_MONTH */,
- 28 /* DATE */,
- 365 /* DAY_OF_YEAR */,
- 7 /* DAY_OF_WEEK */,
- 4 /* DAY_OF_WEEK_IN_MONTH */,
- 1 /* AM_PM */,
- 11 /* HOUR */,
- 23 /* HOUR_OF_DAY */,
- 59 /* MINUTE */,
- 59 /* SECOND */,
- 999 /* MILLISECOND */,
- 43200000 /* ZONE_OFFSET */,
- 3600000 /* DST_OFFSET */
- };
-
- public GregorianCalendar ()
- {
- this(null, null);
- }
-
- public GregorianCalendar (TimeZone zone)
- {
- this (zone, null);
- }
-
- public GregorianCalendar (Locale locale)
- {
- this (null, locale);
- }
-
- public GregorianCalendar (TimeZone zone, Locale locale)
- {
- super (zone, locale);
- setDefaultTime ();
- }
-
- public GregorianCalendar (int year, int month, int date)
- {
- this((TimeZone) null);
- setDefaultTime ();
- set (year, month, date);
- }
-
- public GregorianCalendar (int year, int month, int date,
- int hour, int minute)
- {
- this((TimeZone) null);
- setDefaultTime ();
- set (year, month, date, hour, minute);
- }
-
- public GregorianCalendar (int year, int month, int date,
- int hour, int minute, int second)
- {
- this((TimeZone) null);
- setDefaultTime ();
- set (year, month, date, hour, minute, second);
- }
-
- private final void setDefaultTime ()
- {
- setTimeInMillis (System.currentTimeMillis());
- }
-
- public int getMinimum(int calfield) { return mins[calfield]; }
- public int getGreatestMinimum(int calfield) { return mins[calfield]; }
- public int getMaximum(int calfield) { return maxs[calfield]; }
- public int getLeastMaximum(int calfield) { return leastMaximums[calfield]; }
-
- protected native void computeFields();
-
- protected native void computeTime();
-
- public void add (int fld, int amount)
- {
- if (fld >= ZONE_OFFSET)
- throw new IllegalArgumentException("bad field to add");
- fields[fld] += amount;
- adjust(fld);
- }
-
- public void roll (int fld, boolean up)
- {
- if (fld >= ZONE_OFFSET)
- throw new IllegalArgumentException("bad field to roll");
-
- int old = fields[fld];
- if (up)
- {
- fields[fld] = old == getMaximum(fld) ? getMinimum(fld)
- : old + 1;
- }
- else
- {
- fields[fld] = old == getMinimum(fld) ? getMaximum(fld)
- : old - 1;
- }
- }
-
- private void adjust (int fld)
- {
- int value = fields[fld];
- int radix = maxs[fld] + 1;
- switch (fld)
- {
- case MONTH:
- case SECOND:
- case MILLISECOND:
- if (value >= radix)
- {
- int next = value / radix;
- fields[fld] = value - radix * next;
- fields[fld - 1] += next;
- adjust(fld - 1);
- }
- else if (value < 0) // min[fld]
- {
- int next = (value - radix - 1) / radix;
- fields[fld] = value - radix * next;
- fields[fld - 1] += next;
- adjust(fld - 1);
- }
- break;
- }
- }
-
- public final Date getGregorianChange() { return new Date(gregorianCutover); }
- public void setGregorianChange (Date date)
- { gregorianCutover = date.getTime(); }
-
- public boolean isLeapYear(int year)
- {
- if ((year % 4) != 0)
- return false;
- if ((year % 100) != 0 || (year % 400) == 0)
- return true;
- // year divisible by 100 but not 400.
- GregorianCalendar date = new GregorianCalendar(year, FEBRUARY, 28);
- return gregorianCutover < date.getTimeInMillis();
- }
-
- public boolean after (Object cal)
- {
- return cal instanceof Calendar
- && getTimeInMillis() > ((Calendar) cal).getTimeInMillis();
- }
-
- public boolean before (Object cal)
- {
- return cal instanceof Calendar
- && getTimeInMillis() < ((Calendar) cal).getTimeInMillis();
- }
-
- public boolean equals (Object obj)
- {
- if (obj == null || ! (obj instanceof GregorianCalendar))
- return false;
- GregorianCalendar other = (GregorianCalendar) obj;
-
- for (int i = FIELD_COUNT; --i >= 0; )
- {
- boolean set = isSet[i];
- if (set != other.isSet[i]
- || (set && fields[i] != other.fields[i]))
- return false;
- }
- if (areFieldsSet != other.areFieldsSet
- || isTimeSet != other.isTimeSet
- || (isTimeSet && time != other.time)
- || getFirstDayOfWeek() != other.getFirstDayOfWeek()
- || getMinimalDaysInFirstWeek() != other.getMinimalDaysInFirstWeek()
- || isLenient() != other.isLenient()
- || ! getTimeZone().equals(other.getTimeZone()))
- return false;
- return true;
- }
-
- public int hashCode ()
- {
- int hashcode = 0;
- for (int i = FIELD_COUNT; --i >= 0; )
- {
- if (isSet[i])
- hashcode += 37 * fields[i];
- }
- if (isTimeSet)
- hashcode += 89 * time;
- return hashcode;
- }
-}
diff --git a/libjava/java/util/Hashtable.java b/libjava/java/util/Hashtable.java
deleted file mode 100644
index 5b5361152f4..00000000000
--- a/libjava/java/util/Hashtable.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-import java.io.Serializable;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 24, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-final class HashtableEntry
-{
- public Object key;
- public Object value;
- public HashtableEntry nextEntry = null;
-
- public HashtableEntry(Object key, Object value)
- {
- this.key = key;
- this.value = value;
- }
-}
-
-final class HashtableEnumeration implements Enumeration
-{
- // TBD: Enumeration is not safe if new elements are put in the table as
- // this could cause a rehash and we'd completely lose our place. Even
- // without a rehash, it is undetermined if a new element added would
- // appear in the enumeration. The spec says nothing about this, but
- // the "Java Class Libraries" book infers that modifications to the
- // hashtable during enumeration causes indeterminate results. Don't do it!
- // A safer way would be to make a copy of the table (e.g. into a vector)
- // but this is a fair bit more expensive.
- private HashtableEntry[] bucket;
- private int bucketIndex;
- private HashtableEntry elem;
- private int enumCount;
- private int size;
- private boolean values;
-
- public HashtableEnumeration(HashtableEntry[] bkt, int sz, boolean isValues)
- {
- bucket = bkt;
- bucketIndex = -1;
- enumCount = 0;
- elem = null;
- size = sz;
- values = isValues;
- }
-
- public boolean hasMoreElements()
- {
- return enumCount < size;
- }
-
- public Object nextElement()
- {
- if (!hasMoreElements())
- throw new NoSuchElementException();
-
- // Find next element
- if (elem != null) // In the middle of a bucket
- elem = elem.nextEntry;
- while (elem == null) // Find the next non-empty bucket
- elem = bucket[++bucketIndex];
-
- enumCount++;
- return values ? elem.value : elem.key;
- }
-}
-
-// TBD: The algorithm used here closely reflects what is described in
-// the "Java Class Libraries" book. The "Java Language Spec" is much
-// less specific about the implementation. Because of this freedom
-// provided by the actual spec, hash table algorithms should be
-// investigated to see if there is a better alternative to this one.
-
-// TODO12:
-// public class Hashtable extends Dictionary
-// implements Map, Cloneable, Serializable
-
-public class Hashtable extends Dictionary implements Cloneable, Serializable
-{
- private HashtableEntry bucket[];
- private float loadFactor;
- private int hsize = 0;
-
- public Hashtable()
- {
- // The "Java Class Libraries" book (p. 919) says that initial size in this
- // case is 101 (a prime number to increase the odds of even distribution).
- this(101, 0.75F);
- }
-
- public Hashtable(int initialSize)
- {
- this(initialSize, 0.75F);
- }
-
- public Hashtable(int initialSize, float loadFactor)
- {
- if (initialSize < 0 || loadFactor <= 0.0 || loadFactor > 1.0)
- throw new IllegalArgumentException();
-
- bucket = new HashtableEntry[initialSize];
- this.loadFactor = loadFactor;
- }
-
- // TODO12:
- // public Hashtable(Map t)
- // {
- // }
-
- public synchronized void clear()
- {
- // Aid the GC by nulling out the entries in the hash table.
- for (int i = 0; i < bucket.length; i++)
- {
- HashtableEntry elem = bucket[i];
- bucket[i] = null; // May already be null.
- while (elem != null)
- {
- HashtableEntry next = elem.nextEntry;
- elem.nextEntry = null; // May already be null.
- elem = next;
- }
- }
- hsize = 0;
- }
-
- public synchronized Object clone()
- {
- // New hashtable will have same initialCapacity and loadFactor.
- Hashtable newTable = new Hashtable(bucket.length, loadFactor);
-
- HashtableEntry newElem, prev = null;
- for (int i = 0; i < bucket.length; i++)
- for (HashtableEntry elem = bucket[i]; elem != null; elem = elem.nextEntry)
- {
- // An easy but expensive method is newTable.put(elem.key, elem.value);
- // Since the hash tables are the same size, the buckets and collisions
- // will be the same in the new one, so we can just clone directly.
- // This is much cheaper than using put.
- newElem = new HashtableEntry(elem.key, elem.value);
- if (newTable.bucket[i] == null)
- prev = newTable.bucket[i] = newElem;
- else
- prev = prev.nextEntry = newElem;
- }
-
- newTable.hsize = this.hsize;
- return newTable;
- }
-
- public synchronized boolean contains(Object value)
- throws NullPointerException
- {
- // An exception is thrown here according to the JDK 1.2 doc.
- if (value == null)
- throw new NullPointerException();
-
- for (int i = 0; i < bucket.length; i++)
- for (HashtableEntry elem = bucket[i]; elem != null; elem = elem.nextEntry)
- if (elem.value.equals(value))
- return true;
-
- return false;
- }
-
- public synchronized boolean containsKey(Object key)
- {
- for (HashtableEntry elem = bucket[Math.abs(key.hashCode()
- % bucket.length)];
- elem != null; elem = elem.nextEntry)
- if (elem.key.equals(key))
- return true;
-
- return false;
- }
-
- public synchronized Enumeration elements()
- {
- return new HashtableEnumeration(bucket, hsize, true);
- }
-
- public synchronized Object get(Object key)
- {
- for (HashtableEntry elem = bucket[Math.abs (key.hashCode()
- % bucket.length)];
- elem != null; elem = elem.nextEntry)
- if (elem.key.equals(key))
- return elem.value;
-
- return null;
- }
-
- public boolean isEmpty()
- {
- return this.hsize <= 0;
- }
-
- public synchronized Enumeration keys()
- {
- return new HashtableEnumeration(bucket, hsize, false);
- }
-
- public synchronized Object put(Object key, Object value)
- throws NullPointerException
- {
- // We could really just check `value == null', but checking both
- // is a bit clearer.
- if (key == null || value == null)
- throw new NullPointerException();
-
- HashtableEntry prevElem = null;
- final int index = Math.abs(key.hashCode() % bucket.length);
-
- for (HashtableEntry elem = bucket[index]; elem != null;
- prevElem = elem, elem = elem.nextEntry)
- if (elem.key.equals(key))
- {
- // Update with the new value and then return the old one.
- Object oldVal = elem.value;
- elem.value = value;
- return oldVal;
- }
-
- // At this point, we know we need to add a new element.
- HashtableEntry newElem = new HashtableEntry(key, value);
- if (bucket[index] == null)
- bucket[index] = newElem;
- else
- prevElem.nextEntry = newElem;
-
- if (++hsize > loadFactor * bucket.length)
- rehash();
-
- return null;
- }
-
- protected void rehash()
- {
- // Create a new table which is twice the size (plus one) of the old.
- // One is added to make the new array length odd so it thus has at least
- // a (small) possibility of being a prime number.
- HashtableEntry oldBucket[] = bucket;
- bucket = new HashtableEntry[bucket.length * 2 + 1];
-
- // Copy over each entry into the new table
- HashtableEntry elem;
- for (int i = 0; i < oldBucket.length; i++)
- for (elem = oldBucket[i]; elem != null; elem = elem.nextEntry)
- {
- // Calling put(elem.key, elem.value); would seem like the easy way
- // but it is dangerous since put increases 'hsize' and calls rehash!
- // This could become infinite recursion under the right
- // circumstances. Instead, we'll add the element directly; this is a
- // bit more efficient than put since the data is already verified.
- final int index = Math.abs(elem.key.hashCode() % bucket.length);
- HashtableEntry newElem = new HashtableEntry(elem.key, elem.value);
- if (bucket[index] == null)
- bucket[index] = newElem;
- else
- {
- // Since this key can't already be in the table, just add this
- // in at the top of the bucket.
- newElem.nextEntry = bucket[index];
- bucket[index] = newElem;
- }
- }
- }
-
- public synchronized Object remove(Object key)
- {
- // TBD: Hmm, none of the various docs say to throw an exception here.
- if (key == null)
- return null;
-
- Object retval;
- HashtableEntry prevElem = null;
- final int index = Math.abs(key.hashCode() % bucket.length);
-
- for (HashtableEntry elem = bucket[index]; elem != null;
- prevElem = elem, elem = elem.nextEntry)
- if (elem.key.equals(key))
- {
- retval = elem.value;
- if (prevElem == null)
- bucket[index] = elem.nextEntry;
- else
- prevElem.nextEntry = elem.nextEntry;
- --hsize;
- return retval;
- }
-
- return null;
- }
-
- public int size()
- {
- return this.hsize;
- }
-
- public synchronized String toString()
- {
- // Following the Java Lang Spec 21.5.4 (p. 636).
-
- Enumeration keys = keys();
- Enumeration values = elements();
-
- // Prepend first element with open bracket
- StringBuffer result = new StringBuffer("{");
-
- // add first element if one exists
- // TBD: Seems like it is more efficient to catch the exception than
- // to call hasMoreElements each time around.
- try
- {
- result.append(keys.nextElement().toString() + "=" +
- values.nextElement().toString());
- }
- catch (NoSuchElementException ex)
- {
- }
-
- // Prepend subsequent elements with ", "
- try
- {
- while (true)
- result.append(", " + keys.nextElement().toString() + "=" +
- values.nextElement().toString());
- }
- catch (NoSuchElementException ex)
- {
- }
-
- // Append last element with closing bracket
- result.append("}");
- return result.toString();
- }
-
- // TODO12:
- // public Set entrySet()
- // {
- // }
-
- // TODO12:
- // public Set keySet()
- // {
- // }
-
- // Since JDK 1.2:
- // This method is identical to contains but is part of the 1.2 Map interface.
- // TBD: Should contains return containsValue instead? Depends on which
- // will be called more typically.
- public synchronized boolean containsValue(Object value)
- {
- return this.contains(value);
- }
-
- // TODO12:
- // public boolean equals(Object o)
- // {
- // }
-
- // TODO12:
- // public boolean hashCode()
- // {
- // }
-
- // TODO12:
- // public void putAll(Map t)
- // {
- // }
-
- // TODO12:
- // public Collection values()
- // {
- // }
-}
diff --git a/libjava/java/util/Iterator.java b/libjava/java/util/Iterator.java
deleted file mode 100644
index f6942fefa19..00000000000
--- a/libjava/java/util/Iterator.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 16, 2000.
- */
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface Iterator
-{
- public boolean hasNext();
- public Object next();
- public void remove();
-}
diff --git a/libjava/java/util/List.java b/libjava/java/util/List.java
deleted file mode 100644
index ea69217553e..00000000000
--- a/libjava/java/util/List.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 16, 2000.
- */
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface List extends Collection
-{
- public int size();
- public boolean isEmpty();
- public boolean contains(Object o);
- public Iterator iterator();
- public Object[] toArray();
- public Object[] toArray(Object[] a);
- public boolean add(Object o);
- public boolean remove(Object o);
- public boolean containsAll(Collection c);
- public boolean addAll(Collection c);
- public boolean addAll(int index, Collection c);
- public boolean removeAll(Collection c);
- public boolean retainAll(Collection c);
- public void clear();
- public boolean equals(Object o);
- public int hashCode();
- public Object get(int index);
- public Object set(int index, Object element);
- public void add(int index, Object element);
- public Object remove(int index);
- public int indexOf(Object o);
- public int lastIndexOf(Object o);
- public ListIterator listIterator();
- public ListIterator listIterator(int index);
- public List subList(int fromIndex, int toIndex);
-}
diff --git a/libjava/java/util/ListIterator.java b/libjava/java/util/ListIterator.java
deleted file mode 100644
index 8250e2ab01a..00000000000
--- a/libjava/java/util/ListIterator.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (C) 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date March 16, 2000.
- */
-/* Written using on-line Java Platform 1.2 API Specification.
- * Status: Believed complete and correct.
- */
-
-// JDK1.2
-public interface ListIterator extends Iterator
-{
- public boolean hasNext();
- public Object next();
- public boolean hasPrevious();
- public Object previous();
- public int nextIndex();
- public int previousIndex();
- public void remove();
- public void set(Object o);
- public void add(Object o);
-}
diff --git a/libjava/java/util/ListResourceBundle.java b/libjava/java/util/ListResourceBundle.java
deleted file mode 100644
index c6d6e78f4e2..00000000000
--- a/libjava/java/util/ListResourceBundle.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Anthony Green <green@cygnus.com>
- * @date November 26, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * and "The Java Language Specification", ISBN 0-201-63451-1. */
-
-public abstract class ListResourceBundle extends ResourceBundle
-{
- public final Object handleGetObject(String key)
- {
- Object a[][] = getContents();
-
- for (int i = 0; i < a.length; i++)
- {
- if (key.compareTo((String) a[i][0]) == 0)
- return a[i][1];
- }
- throw new MissingResourceException("can't find handle",
- getClass().getName(),
- key);
- }
-
- public Enumeration getKeys()
- {
- Object a[][] = getContents();
-
- Vector keys = new Vector(a.length);
-
- for (int i = 0; i < a.length; i++)
- keys.addElement(a[i][0]);
-
- return keys.elements();
- }
-
- protected abstract Object[][] getContents();
-
- public ListResourceBundle()
- {
- }
-}
diff --git a/libjava/java/util/Locale.java b/libjava/java/util/Locale.java
deleted file mode 100644
index d2dc2f75917..00000000000
--- a/libjava/java/util/Locale.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 24, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * and "The Java Language Specification", ISBN 0-201-63451-1.
- * Status: None of the getDisplayXXX or getISO3XXX methods are implemented.
- */
-public final class Locale implements java.io.Serializable, Cloneable
-{
- // The fields are as specified in Sun's "Serialized Form"
- // in the JDK 1.2 beta 4 API specification.
- private String country;
- private int hashcode;
- private String language;
- private String variant;
- private static Locale defaultLocale;
-
- // These are as specified in the JDK 1.2 AP documentation
-
-
- // LANGUAGE constants ... country-neutral
- public static final Locale CHINESE = new Locale ("zh", "");
- public static final Locale ENGLISH = new Locale ("en", "");
- public static final Locale FRENCH = new Locale ("fr", "");
- public static final Locale GERMAN = new Locale ("de", "");
- public static final Locale ITALIAN = new Locale ("it", "");
- public static final Locale JAPANESE = new Locale ("ja", "");
- public static final Locale KOREAN = new Locale ("ko", "");
-
- // COUNTRY constants ... countries can be multi-lingual
- public static final Locale CANADA = new Locale ("en", "CA");
- public static final Locale CANADA_FRENCH = new Locale ("fr", "CA");
- public static final Locale FRANCE = new Locale ("fr", "FR");
- public static final Locale GERMANY = new Locale ("de", "DE");
- public static final Locale ITALY = new Locale ("it", "IT");
- public static final Locale JAPAN = new Locale ("ja", "JP");
- public static final Locale KOREA = new Locale ("ko", "KR");
- public static final Locale UK = new Locale ("en", "GB");
- public static final Locale US = new Locale ("en", "US");
-
- // Chinese has multiple scripts and political bodies
- public static final Locale SIMPLIFIED_CHINESE = new Locale ("zh", "CN");
- public static final Locale TRADITIONAL_CHINESE = new Locale ("zh", "TW");
- public static final Locale PRC = SIMPLIFIED_CHINESE;
- public static final Locale TAIWAN = TRADITIONAL_CHINESE;
- public static final Locale CHINA = PRC;
-
- public Locale (String languageCode, String countryCode)
- {
- this (languageCode, countryCode, "");
- }
-
- public Locale (String languageCode, String countryCode,
- String variantCode)
- {
- language = languageCode.toLowerCase();
- country = countryCode.toUpperCase();
- variant = variantCode.toUpperCase();
- hashcode = (languageCode.hashCode()
- ^ countryCode.hashCode()
- ^ variantCode.hashCode());
- }
-
- public Object clone ()
- {
- return (Object) new Locale (language, country, variant);
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof Locale))
- return false;
- Locale loc = (Locale) obj;
- return (language.equals(loc.language)
- && country.equals(loc.country)
- && variant.equals(loc.variant));
- }
-
- public String getCountry ()
- {
- return country;
- }
-
- public String getLanguage ()
- {
- return language;
- }
-
- public String getVariant ()
- {
- return variant;
- }
-
- public int hashCode ()
- {
- return hashcode;
- }
-
- private static synchronized Locale setDefault()
- {
- if (defaultLocale != null)
- return defaultLocale;
- String language = System.getProperty("user.language");
- String country = System.getProperty("user.region");
- defaultLocale = new Locale (language == null ? "en" : language,
- country == null ? "" : country);
- return defaultLocale;
- }
-
- public static Locale getDefault ()
- {
- return defaultLocale == null ? setDefault() : defaultLocale;
- }
-
- public static void setDefault (Locale newLocale)
- {
- defaultLocale = newLocale;
- }
-
- public String toString ()
- {
- StringBuffer result = new StringBuffer(20);
- result.append(language);
- if (country.length() > 0)
- {
- result.append('_');
- result.append(country);
- if (variant.length() > 0)
- {
- result.append('_');
- result.append(variant);
- }
- }
- return result.toString();
- }
-}
diff --git a/libjava/java/util/MissingResourceException.java b/libjava/java/util/MissingResourceException.java
deleted file mode 100644
index 5fe24a024b3..00000000000
--- a/libjava/java/util/MissingResourceException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class MissingResourceException extends RuntimeException
-{
- private String className;
- private String key;
-
- public MissingResourceException(String msg, String cName, String k)
- {
- super(msg);
- className = cName;
- key = k;
- }
-
- public String getClassName()
- {
- return className;
- }
-
- public String getKey()
- {
- return key;
- }
-}
-
diff --git a/libjava/java/util/NoSuchElementException.java b/libjava/java/util/NoSuchElementException.java
deleted file mode 100644
index eb8f27d8efb..00000000000
--- a/libjava/java/util/NoSuchElementException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class NoSuchElementException extends RuntimeException
-{
- public NoSuchElementException()
- {
- super();
- }
-
- public NoSuchElementException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/util/Observable.java b/libjava/java/util/Observable.java
deleted file mode 100644
index 1a205c15363..00000000000
--- a/libjava/java/util/Observable.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class Observable
-{
- /* tracks whether this object has changed */
- private boolean changed;
-
- /* list of the Observers registered as interested in this Observable */
- private Vector observerVec;
-
- /* TBD: This might be better implemented as an Observer[]
- * but that would mean writing more code rather than making use of
- * the existing Vector class (this also implies a larger text code
- * space in resulting executables). The tradeoff is one of speed
- * (manipulating the Observer[] directly) vs. size/reuse. In the future,
- * we may decide to make the tradeoff and reimplement with an Observer[].
- */
-
- public Observable()
- {
- changed = false;
- observerVec = new Vector();
- }
-
- public synchronized void addObserver(Observer obs)
- {
- // JDK 1.2 spec says not to add this if it is already there
- if (!observerVec.contains(obs))
- observerVec.addElement(obs);
- }
-
- protected synchronized void clearChanged()
- {
- changed = false;
- }
-
- public synchronized int countObservers()
- {
- return observerVec.size();
- }
-
- public synchronized void deleteObserver(Observer obs)
- {
- observerVec.removeElement(obs);
- }
-
- public synchronized void deleteObservers()
- {
- observerVec.removeAllElements();
- }
-
- public synchronized boolean hasChanged()
- {
- return changed;
- }
-
- public void notifyObservers()
- {
- notifyObservers(null);
- }
-
- public void notifyObservers(Object arg)
- {
- if (changed)
- {
- /* The JDK 1.2 spec states that though the order of notification
- * is unspecified in subclasses, in Observable it is in the order
- * of registration.
- */
- for (int i = 0, numObs = observerVec.size(); i < numObs; i++)
- ((Observer) (observerVec.elementAt(i))).update(this, arg);
- changed = false;
- }
- }
-
- protected synchronized void setChanged()
- {
- changed = true;
- }
-}
diff --git a/libjava/java/util/Observer.java b/libjava/java/util/Observer.java
deleted file mode 100644
index 3dc86ae7512..00000000000
--- a/libjava/java/util/Observer.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-public interface Observer
-{
- public void update(Observable observed, Object arg);
-}
diff --git a/libjava/java/util/Properties.java b/libjava/java/util/Properties.java
deleted file mode 100644
index 2f7a25159b7..00000000000
--- a/libjava/java/util/Properties.java
+++ /dev/null
@@ -1,391 +0,0 @@
-// Properties - Property list representation.
-
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.PushbackReader;
-
-/**
- * @author Tom Tromey <tromey@cygnus.com>
- * @date October 26, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * Status: Complete to JDK 1.2.
- */
-
-public class Properties extends Hashtable
-{
- protected Properties defaults;
-
- public String getProperty (String propName)
- {
- return getProperty (propName, null);
- }
-
- public String getProperty (String propName, String defVal)
- {
- String r = (String) get (propName);
- if (r == null)
- {
- if (defaults != null)
- r = defaults.getProperty(propName, defVal);
- else
- r = defVal;
- }
- return r;
- }
-
- public Object setProperty (String key, String value)
- {
- return put (key, value);
- }
-
- public void list (PrintStream out)
- {
- Enumeration e = propertyNames ();
- while (e.hasMoreElements())
- {
- String key = (String) e.nextElement();
- String value = getProperty(key);
- if (value != null)
- {
- if (value.length() > 40)
- {
- // JDK compatibility.
- value = value.substring(0, 37) + "...";
- }
- out.print(key);
- out.print("=");
- out.println(value);
- }
- }
- }
-
- public void list (PrintWriter writer)
- {
- Enumeration e = propertyNames ();
- while (e.hasMoreElements())
- {
- String key = (String) e.nextElement();
- String value = getProperty(key);
- if (value != null)
- {
- if (value.length() > 40)
- {
- // JDK compatibility.
- value = value.substring(0, 37) + "...";
- }
- writer.print(key);
- writer.print("=");
- writer.println(value);
- }
- }
- }
-
- private final boolean skip_ws (PushbackReader reader) throws IOException
- {
- while (true)
- {
- int c = reader.read();
- if (c == -1)
- return false;
- // FIXME: we use our own definition of whitespace.
- // Character.isWhitespace includes newlines, which we don't
- // want. Character.isSpaceChar doesn't include \t.
- if (c != ' ' && c != '\t')
- {
- reader.unread(c);
- return true;
- }
- }
- }
-
- // Note: this method needs to be rewritten for JDK 1.2.
- // We rather arbitrarily decide that an EOF in the middle of a line
- // means that the whole line should be ignored. The spec doesn't
- // specifically address this, but this interpretation seems valid.
- public synchronized void load (InputStream in) throws IOException
- {
- PushbackReader reader = new PushbackReader (new InputStreamReader (in));
-
- StringBuffer key = new StringBuffer ();
- StringBuffer value = new StringBuffer ();
-
- nextLine:
- while (true)
- {
- key.setLength(0);
- value.setLength(0);
-
- // Skip leading whitespace.
- if (! skip_ws (reader))
- return;
-
- // Read key until key terminator.
- boolean first_char = true;
- int c;
- while (true)
- {
- c = reader.read();
- if (c == -1)
- return;
- if (c == '\\')
- {
- first_char = false;
- c = reader.read();
- if (c == -1)
- return;
- }
-
- // If we found a comment, just read to end of line and
- // then keep going.
- if (first_char == true && (c == '#' || c == '!'))
- {
- while (c != -1 && c != '\r' && c != '\n')
- c = reader.read();
- if (c == -1)
- return;
- continue nextLine;
- }
-
- if (c == '\r' || c == '\n')
- {
- if (first_char)
- continue nextLine;
- reader.unread(c);
- break;
- }
- // FIXME: again, our own definition of whitespace.
- if (c == ' ' || c == '\t' || c == ':' || c == '=')
- break;
-
- first_char = false;
- key.append((char) c);
- }
-
- // Found end of key. Skip whitespace. If the terminator
- // was whitespace, also skip a single instance of a "real"
- // terminator, and then more whitespace.
- if (! skip_ws (reader))
- return;
- if (c != ':' && c != '=')
- {
- c = reader.read();
- if (c == -1)
- return;
- if (c == ':' || c == '=')
- {
- // Skip more whitespace.
- if (! skip_ws (reader))
- return;
- }
- else
- reader.unread(c);
- }
-
- // Now read the value.
- while (true)
- {
- c = reader.read();
- if (c == -1)
- return;
- if (c == '\r' || c == '\n')
- break;
- if (c == '\\')
- {
- c = reader.read();
- switch (c)
- {
- case -1:
- return;
- case 't':
- c = '\t';
- break;
- case 'r':
- c = '\r';
- break;
- case 'n':
- c = '\n';
- break;
- case 'u':
- c = 0;
- for (int i = 0; i < 4; ++i)
- {
- int x = reader.read();
- if (x == -1)
- return;
- int d = Character.digit((char) x, 16);
- // We follow JDK here: invalid characters
- // are treated as terminators.
- if (d == -1)
- {
- value.append((char) c);
- c = x;
- break;
- }
- c <<= 4;
- c |= d;
- }
- break;
- default:
- // Nothing.
- }
- }
- value.append((char) c);
- }
-
- put (key.toString(), value.toString());
- }
- }
-
- public Properties ()
- {
- defaults = null;
- }
-
- public Properties (Properties defs)
- {
- defaults = defs;
- }
-
- private final void addHashEntries (Hashtable base)
- {
- if (defaults != null)
- defaults.addHashEntries(base);
- Enumeration keys = keys ();
- while (keys.hasMoreElements())
- base.put(keys.nextElement(), base);
- }
-
- public Enumeration propertyNames ()
- {
- // We make a new Hashtable that holds all the keys. Then we
- // return an enumeration for this hash. We do this because we
- // don't want modifications to be reflected in the enumeration
- // (per JCL), and because there doesn't seem to be a
- // particularly better way to ensure that duplicates are
- // ignored.
- Hashtable t = new Hashtable ();
- addHashEntries (t);
- return t.keys();
- }
-
- public synchronized void save (OutputStream out, String comment)
- {
- try
- {
- store (out, comment);
- }
- catch (IOException _)
- {
- }
- }
-
- public synchronized void store (OutputStream out, String comment)
- throws IOException
- {
- // Use a buffer because writing a single string through
- // OutputStreamWriter is fairly expensive.
- BufferedWriter output
- = new BufferedWriter (new OutputStreamWriter (out));
- String newline = System.getProperty("line.separator");
-
- if (comment != null)
- {
- // We just lose if COMMENT contains a newline. This is
- // what JDK 1.1 does.
- output.write("#");
- output.write(comment);
- output.write(newline);
- }
- output.write("# ");
- output.write(new Date().toString());
- output.write(newline);
-
- Enumeration keys = keys ();
- while (keys.hasMoreElements())
- {
- String key = (String) keys.nextElement();
- String value = (String) get (key);
-
- // FIXME: JCL says that the key can contain many Unicode
- // characters. But it also doesn't say we should encode
- // it in any way.
- // FIXME: if key contains ':', '=', or whitespace, must
- // quote it here. Note that JDK 1.1 does not do this.
- output.write(key);
- output.write("=");
-
- boolean leading = true;
- for (int i = 0; i < value.length(); ++i)
- {
- boolean new_lead = false;
- char c = value.charAt(i);
- switch (c)
- {
- case '\n':
- output.write("\\n");
- break;
- case '\r':
- output.write("\\r");
- break;
- case '\t':
- output.write("\\t");
- break;
- case '\\':
- output.write("\\\\");
- break;
-
- case '#':
- case '!':
- case '=':
- case ':':
- output.write("\\");
- output.write(c);
- break;
-
- case ' ':
- new_lead = leading;
- if (leading)
- output.write("\\");
- output.write(c);
- break;
-
- default:
- if (c < '\u0020' || c > '\u007e')
- {
- output.write("\\u");
- output.write(Character.forDigit(c >>> 12, 16));
- output.write(Character.forDigit((c >>> 8) & 0xff,
- 16));
- output.write(Character.forDigit((c >>> 4) & 0xff,
- 16));
- output.write(Character.forDigit(c & 0xff, 16));
- }
- else
- output.write(c);
- }
- leading = new_lead;
- }
- output.write(newline);
- }
-
- output.flush();
- }
-}
diff --git a/libjava/java/util/PropertyResourceBundle.java b/libjava/java/util/PropertyResourceBundle.java
deleted file mode 100644
index 4171ddd29d2..00000000000
--- a/libjava/java/util/PropertyResourceBundle.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-import java.io.InputStream;
-import java.io.IOException;
-import gnu.gcj.util.EnumerationChain;
-
-/**
- * @author Anthony Green <green@cygnus.com>
- * @date April 29, 1999.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * and "The Java Language Specification", ISBN 0-201-63451-1. */
-
-public class PropertyResourceBundle extends ResourceBundle
-{
- private Properties properties;
-
- public PropertyResourceBundle (InputStream pstream) throws IOException
- {
- // Initialize and load our Properties.
- properties = new Properties();
- properties.load(pstream);
- }
-
- public Enumeration getKeys()
- {
- if (parent == null)
- return properties.propertyNames();
- else
- return new EnumerationChain (properties.propertyNames(),
- parent.getKeys ());
- }
-
- public Object handleGetObject (String key)
- {
- return properties.getProperty(key);
- }
-}
diff --git a/libjava/java/util/Random.java b/libjava/java/util/Random.java
deleted file mode 100644
index e4bac59cad3..00000000000
--- a/libjava/java/util/Random.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-import java.io.Serializable;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 25, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-/* This class is completely specified by the spec to ensure absolute
- * portability between all implementations of Java
- */
-public class Random implements Serializable
-{
- /* Used by next() to hold the state of the pseudorandom number generator */
- protected long seed;
-
- /* Used by nextGaussian() to hold a precomputed value */
- /* to be delivered by that method the next time it is called */
- protected double nextNextGaussian;
-
- /* Used by nextGaussian() to keep track of whether it is has precomputed */
- /* and stashed away the next value to be delivered by that method */
- protected boolean haveNextNextGaussian = false;
-
- public Random()
- {
- this(System.currentTimeMillis());
- }
-
- public Random(long seed)
- {
- setSeed(seed);
- }
-
- protected synchronized int next(int bits)
- {
- seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
- return (int)(seed >>> (48 - bits));
- }
-
- // JDK1.2
- public boolean nextBoolean()
- {
- return next(1) != 0;
- }
-
- /* The method nextBytes() is not fully specified in the published specs.
- * At first I implemented it simply via:
- * for (int i = 0; i < buf.length; i++)
- * buf[i] = (byte)next(8);
- * but a simple test did not yield the same results as the std implementation.
- * There seemed to be a relationship where each i byte above was at pos 4*i+3
- * in the std. For efficiency, by reducing calls to the expensive math
- * routines, the std probably was calling next(32) once rather than next(8)
- * 4 times. Changing the algorithm to the one below based on that assumption
- * then yielded identical results to the std.
- */
- public void nextBytes(byte[] buf)
- {
- int randInt = 0;
-
- for (int i = 0; i < buf.length; i++)
- {
- int shift = (i % 4) * 8;
- if (shift == 0)
- randInt = next(32);
- buf[i] = (byte) (randInt >> shift);
- }
- }
-
- public double nextDouble()
- {
- return (((long)next(26) << 27) + next(27)) / (double)(1L << 53);
- }
-
- public float nextFloat()
- {
- return next(24) / ((float)(1 << 24));
- }
-
- public synchronized double nextGaussian()
- {
- if (haveNextNextGaussian)
- {
- haveNextNextGaussian = false;
- return nextNextGaussian;
- }
- else
- {
- double v1, v2, s;
- do
- {
- v1 = 2 * nextDouble() - 1; // between -1.0 and 1.0
- v2 = 2 * nextDouble() - 1; // between -1.0 and 1.0
- s = v1 * v1 + v2 * v2;
- } while (s >= 1);
- double norm = Math.sqrt(-2 * Math.log(s)/s);
- nextNextGaussian = v2 * norm;
- haveNextNextGaussian = true;
- return v1 * norm;
- }
- }
-
- public int nextInt()
- {
- return next(32);
- }
-
- // JDK1.2
- public int nextInt(int n)
- {
- if (n <= 0)
- throw new IllegalArgumentException("n must be positive");
-
- int bits, val;
- do
- {
- bits = next(31);
- val = bits % n;
- } while (bits - val + (n-1) < 0);
- return val;
- }
-
- public long nextLong()
- {
- return ((long)next(32) << 32) + next(32);
- }
-
- public synchronized void setSeed(long seed)
- {
- this.seed = (seed ^ 0x5DEECE66DL) & ((1L << 48) - 1);
- haveNextNextGaussian = false;
- }
-}
diff --git a/libjava/java/util/ResourceBundle.java b/libjava/java/util/ResourceBundle.java
deleted file mode 100644
index b5edfbf20f9..00000000000
--- a/libjava/java/util/ResourceBundle.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-import java.io.InputStream;
-
-/**
- * @author Anthony Green <green@cygnus.com>
- * @date November 26, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3,
- * and "The Java Language Specification", ISBN 0-201-63451-1. */
-
-public abstract class ResourceBundle
-{
- protected ResourceBundle parent;
-
- // This is used to cache resource bundles.
- private static Hashtable resource_cache = new Hashtable ();
-
- public ResourceBundle ()
- {
- }
-
- public Locale getLocale()
- {
- // FIXME: Stub added for this missing method because it is needed for AWT.
- return null;
- }
-
- public final String getString (String key) throws MissingResourceException
- {
- return (String) getObject(key);
- }
-
- public final String[] getStringArray (String key)
- throws MissingResourceException
- {
- return (String[]) getObject(key);
- }
-
- public final Object getObject(String key) throws MissingResourceException
- {
- Object result;
-
- try
- {
- return handleGetObject (key);
- }
- catch (MissingResourceException ex)
- {
- if (parent != null)
- return parent.getObject(key);
- else
- throw ex;
- }
- }
-
- public static final ResourceBundle getBundle(String baseName)
- throws MissingResourceException
- {
- return getBundle(baseName, Locale.getDefault());
- }
-
- // Start searching with the name bundleName. Continue searching by
- // stripping off the '_' delimited tails until the search name is
- // the same as stopHere.
- private static final ResourceBundle trySomeGetBundle (String bundleName,
- String stopHere)
- {
- Class rbc;
- ResourceBundle needs_parent = null, r, result = null;
-
- while (true)
- {
- try
- {
- rbc = Class.forName(bundleName);
- r = null;
- try
- {
- r = (ResourceBundle) rbc.newInstance();
- }
- catch (IllegalAccessException ex)
- {
- // Fall through
- }
- catch (InstantiationException ex)
- {
- // Fall through
- }
- if (r != null)
- {
- if (result == null)
- result = r;
- if (needs_parent != null)
- {
- // We've been through the loop one or more times
- // already. Set the parent and keep going.
- needs_parent.setParent(r);
- }
- needs_parent = r;
- }
- }
- catch (ClassNotFoundException ex)
- {
- // Fall through.
- }
-
- // Look for a properties file.
- {
- String prop_name = (bundleName.replace('.', '/') + ".properties");
- System.out.println ("trying '" + prop_name + "' for '" + bundleName);
- InputStream i = ClassLoader.getSystemResourceAsStream (prop_name);
- /*
- InputStream i =
- ClassLoader.getSystemResourceAsStream (bundleName.replace ('.', '/')
- + ".properties");
- */
- if (i != null)
- {
- try {
- return new PropertyResourceBundle (i);
- } catch (java.io.IOException e) {
- // The docs don't appear to define what happens in
- // this case, but it seems like continuing the
- // search is a reasonable thing to do.
- }
- }
- }
-
- if (bundleName.equals(stopHere))
- return result;
- else
- {
- int last = bundleName.lastIndexOf('_');
-
- // No more underscores?
- if (last == -1)
- return result;
-
- // Loop around, testing this new shorter name.
- bundleName = bundleName.substring(0, last);
- }
- }
- }
-
- // Search for bundles, but stop at baseName_language (if required).
- // This is synchronized so that the cache works correctly.
- private static final synchronized ResourceBundle
- partialGetBundle (String baseName, Locale locale, boolean langStop)
- {
- ResourceBundle rb;
-
- // Explicitly invoke locale.toString() to force a
- // NullPointerException when required.
- String bundleName = baseName + "_" + locale.toString();
-
- // Check the cache.
- Object obj = resource_cache.get(bundleName);
- if (obj != null)
- return (ResourceBundle) obj;
-
- String stopHere = (baseName
- + (langStop ? ("_" + locale.getLanguage()) : ""));
-
-
- rb = trySomeGetBundle(bundleName, stopHere);
- if (rb != null)
- resource_cache.put(bundleName, rb);
-
- return rb;
- }
-
- public static final ResourceBundle getBundle (String baseName,
- Locale locale)
- throws MissingResourceException
- {
- ResourceBundle rb;
- Class rbc;
-
- if (baseName == null)
- throw new NullPointerException ();
-
- rb = partialGetBundle(baseName, locale, false);
- if (rb != null)
- return rb;
-
- // Finally, try the default locale.
- if (! locale.equals(Locale.getDefault()))
- {
- rb = partialGetBundle(baseName, Locale.getDefault(), true);
- if (rb != null)
- return rb;
- }
-
- throw new MissingResourceException("can't load bundle",
- baseName,
- "bundle");
- }
-
- protected void setParent(ResourceBundle parent)
- {
- this.parent = parent;
- }
-
- protected abstract Object handleGetObject(String key)
- throws MissingResourceException;
-
- public abstract Enumeration getKeys();
-}
diff --git a/libjava/java/util/SimpleTimeZone.java b/libjava/java/util/SimpleTimeZone.java
deleted file mode 100644
index 64f9c505a50..00000000000
--- a/libjava/java/util/SimpleTimeZone.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 24, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3.
- * Status: Does not know how to figure out if daylight savings time
- * is in effect; hence only correct for zones without DST.
- * No known spec for hashCode.
- */
-
-public class SimpleTimeZone extends TimeZone
-{
- // The fields are as specified in Sun's "Serialized Form"
- // in the JDK 1.2 beta 4 API specification.
-
- int dstSavings = 60 * 60 * 1000;
-
- int rawOffset;
-
- // int serialVersionOnStream;
-
- int startDay;
- int startDayOfWeek;
- int startMode; /// Seems to be JDK 1.2 only.
-
- int startMonth;
-
- int startTime;
-
- int startYear;
-
- int endDay;
-
- int endDayOfWeek;
-
- int endMode; // Seems to be JDK 1.2 only.
-
- int endMonth;
-
- int endTime;
-
- // byte[] monthLength;
-
- boolean useDaylight;
-
- public SimpleTimeZone (int rawOffset, String ID)
- {
- setID(ID);
- this.rawOffset = rawOffset;
- }
-
- public SimpleTimeZone (int rawOffset, String ID,
- int startMonth, int startDay,
- int startDayOfWeek, int startTime,
- int endMonth, int endDay,
- int endDayOfWeek, int endTime)
- {
- this(rawOffset, ID);
- setStartRule (startMonth, startDay, startDayOfWeek, startTime);
- setEndRule (endMonth, endDay, endDayOfWeek, endTime);
- }
-
- public int getRawOffset() { return rawOffset; }
- public void setRawOffset (int offsetMillis) { rawOffset = offsetMillis; }
-
- public int getOffset (int era, int year, int month, int day,
- int dayOfWeek, int millis)
- {
- int offset = getRawOffset();
- if (useDaylight)
- {
- if (startYear != 0
- && (year < startYear || era == GregorianCalendar.BC))
- return offset;
- boolean midYearSummer = startMonth < endMonth;
- if (midYearSummer ? (month < startMonth || month > endMonth)
- : (month < startMonth && month > endMonth))
- return offset; // Definitely not DST.
- if (midYearSummer ? (month > startMonth && month < endMonth)
- : (month > startMonth || month < endMonth))
- return offset + dstSavings; // Definitely DST.
- // Now it gets more complicated. Bail for now.
- throw new Error("not implemented - SimpleTimeZone.getOffset");
- }
- return offset;
- }
-
- public boolean useDaylightTime() { return useDaylight; }
-
- public boolean inDaylightTime(Date date)
- {
- if (! useDaylight)
- return false;
- throw new Error("not implemented - SimpleTimeZone.inDaylightTime");
- }
-
- public int getDSTSavings () { return dstSavings; }
-
- public void setDSTSavings (int millisSavedDuringDST)
- { dstSavings = millisSavedDuringDST; }
-
- public void setStartRule (int month, int dayOfWeekInMonth,
- int dayOfWeek, int time)
- {
- this.startMonth = month;
- this.startDay = dayOfWeekInMonth;
- this.startDayOfWeek = dayOfWeek;
- this.startTime = time;
- this.useDaylight = true;
- }
-
- public void setEndRule (int month, int dayOfWeekInMonth,
- int dayOfWeek, int time)
- {
- this.endMonth = month;
- this.endDay = dayOfWeekInMonth;
- this.endDayOfWeek = dayOfWeek;
- this.endTime = time;
- this.useDaylight = true;
- }
-
- public void setStartYear (int year)
- {
- this.startYear = startYear;
- }
-
- public boolean hasSameRules (TimeZone other)
- {
- if (this == other)
- return true;
- if (! (other instanceof SimpleTimeZone))
- return false;
- SimpleTimeZone o = (SimpleTimeZone) other;
- if (rawOffset != o.rawOffset)
- return false;
- if (useDaylight != o.useDaylight)
- return false;
- if (! useDaylight)
- return true;
- return startDay == o.startDay
- && startDayOfWeek == o.startDayOfWeek
- && startMonth == o.startMonth
- && startTime == o.startTime
- && endDay == o.endDay
- && endDayOfWeek == o.endDayOfWeek
- && endMonth == o.endMonth
- && endTime == o.endTime
- && startYear == o.startYear
- && startMode == o.startMode
- && endMode == o.endMode;
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof SimpleTimeZone))
- return false;
- SimpleTimeZone other = (SimpleTimeZone) obj;
- return getID() == other.getID() && hasSameRules(other);
- }
-
- public Object clone ()
- {
- // We know the superclass just call's Object's generic cloner.
- return super.clone ();
- }
-
- public String toString ()
- {
- // The docs don't say much about how we might implement this.
- // We choose a debugging implementation.
- return ("dstSavings " + dstSavings
- + "; rawOffset " + rawOffset
- + "; startDay " + startDay
- + "; startDayOfWeek " + startDayOfWeek
- + "; startMode " + startMode
- + "; startMonth " + startMonth
- + "; startTime " + startTime
- + "; startYear " + startYear
- + "; endDay " + endDay
- + "; endDayOfWeek " + endDayOfWeek
- + "; endMode " + endMode
- + "; endMonth " + endMonth
- + "; endTime " + endTime
- + "; useDaylight " + useDaylight);
- }
-
- public int hashCode ()
- {
- // FIXME - this does not folow any spec (since none is public)!
- int hash = rawOffset;
- if (useDaylight)
- hash += dstSavings + startYear + startMode + endMode
- + startDay + startDayOfWeek + startMonth + startTime
- + endDay + endDayOfWeek + endMonth + endTime;
- return hash;
- }
-}
diff --git a/libjava/java/util/Stack.java b/libjava/java/util/Stack.java
deleted file mode 100644
index c7cb1c05753..00000000000
--- a/libjava/java/util/Stack.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 20, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-public class Stack extends Vector
-{
- // Could use Vector methods internally for the following methods
- // but have used Vector fields directly for efficiency (i.e. this
- // often reduces out duplicate bounds checking).
-
- public boolean empty()
- {
- return elementCount == 0;
- }
-
- public synchronized Object peek()
- {
- if (elementCount == 0)
- throw new EmptyStackException();
-
- return elementData[elementCount - 1];
- }
-
- public synchronized Object pop()
- {
- if (elementCount == 0)
- throw new EmptyStackException();
-
- Object obj = elementData[--elementCount];
-
- // Set topmost element to null to assist the gc in cleanup
- elementData[elementCount] = null;
- return obj;
- }
-
- public Object push(Object obj)
- {
- // When growing the Stack, use the Vector routines in case more
- // memory is needed.
- // Note: spec indicates that this method *always* returns obj passed in!
-
- addElement(obj);
- return obj;
- }
-
- public synchronized int search(Object obj)
- {
- // Return the position of obj on the stack as measured from the top;
- // i.e. the top element is 1, the next element down is 2, etc.
- // If obj is not on the stack, return -1
-
- for (int i = elementCount-1; i >=0; --i)
- if (elementData[i].equals(obj))
- return elementCount - i;
-
- return -1;
- }
-}
diff --git a/libjava/java/util/StringTokenizer.java b/libjava/java/util/StringTokenizer.java
deleted file mode 100644
index 1686a0399e8..00000000000
--- a/libjava/java/util/StringTokenizer.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 24, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-public class StringTokenizer implements Enumeration
-{
- /* String to be parsed */
- private String inputString;
-
- /* String to be parsed put into a char array for efficient access */
- private char[] chArray;
-
- /* Set of delimiter characters for separating tokens */
- private String delimiters;
-
- /* Whether delimiters in this instance are treated as tokens themselves */
- private boolean returnDelimiters;
-
- /* Index into the input string to start parsing for the next token */
- private int inputStringIndex;
-
- public StringTokenizer(String str)
- {
- this(str, " \t\n\r", false);
- }
-
- public StringTokenizer(String str, String delims)
- {
- this(str, delims, false);
- }
-
- public StringTokenizer(String str, String delims, boolean retDelim)
- {
- inputString = str;
- delimiters = delims;
- returnDelimiters = retDelim;
- inputStringIndex = 0;
-
- // Work on a copy of the remaining string in a char array
- // to gain efficiency of using primitives
- chArray = new char[inputString.length()];
- inputString.getChars(0, inputString.length(), chArray, 0);
- }
-
- public int countTokens()
- {
- int count = 0;
- int delimiterCount = 0;
- boolean tokenFound = false; // Set when a non-delimiter is found
- int offset = inputStringIndex;
-
- // Note for efficiency, we count up the delimiters rather than check
- // returnDelimiters every time we encounter one. That way, we can
- // just do the conditional once at the end of the method
- while (offset < chArray.length)
- {
- if (isDelimiter(chArray[offset++]))
- {
- if (tokenFound)
- {
- // Got to the end of a token
- count++;
- tokenFound = false;
- }
-
- delimiterCount++; // Increment for this delimiter
- }
- else
- {
- tokenFound = true;
-
- // Get to the end of the token
- while (offset < chArray.length && !isDelimiter(chArray[offset]))
- offset++;
- }
- }
-
- // Make sure to count the last token
- if (tokenFound)
- count++;
-
- // if counting delmiters add them into the token count
- return returnDelimiters ? count + delimiterCount : count;
- }
-
- public boolean hasMoreElements()
- {
- return hasMoreTokens();
- }
-
- public boolean hasMoreTokens()
- {
- int offset = inputStringIndex;
-
- while (offset < chArray.length)
- if (!isDelimiter(chArray[offset++]) || returnDelimiters)
- {
- // update the current position with the start of the next token
- inputStringIndex = --offset;
-
- return true;
- }
-
- return false;
- }
-
- public Object nextElement()
- {
- return nextToken();
- }
-
- public String nextToken()
- {
- int offset = inputStringIndex;
- int startSubstr = -1;
-
- // Make sure we have more chars left to parse
- // and then find the start of the next token
- while (offset < chArray.length && startSubstr < 0)
- {
- // Find the start of the token; skipping initial delimiters
- if (!isDelimiter(chArray[offset++]))
- startSubstr = offset - 1;
- else if (returnDelimiters)
- {
- // The single char delimiter is treated as a token
- inputStringIndex = offset; // update the current position
-
- return inputString.substring(offset - 1, inputStringIndex);
- }
- }
-
- // Now look for the end of the token
- while (offset < chArray.length)
- {
- if (isDelimiter(chArray[offset++]))
- {
- // Found the end of token
- inputStringIndex = offset - 1; // update the current position
-
- return inputString.substring(startSubstr, inputStringIndex);
- }
- }
-
- // Got to the end of the string without finding the start of a token
- if (startSubstr < 0)
- throw new NoSuchElementException();
-
- // Got to the end of the string before a delimiter
- inputStringIndex = offset; // update the current position
-
- return inputString.substring(startSubstr, inputStringIndex);
- }
-
- public String nextToken(String delims)
- {
- // First replace with new set of delimiters
- delimiters = delims;
-
- return nextToken();
- }
-
- // This private method could be inlined but the other methods are
- // more readable this way, so we'll take the hit on efficiency.
- private boolean isDelimiter(char ch)
- {
- return delimiters.indexOf(ch, 0) >= 0;
- }
-}
diff --git a/libjava/java/util/TimeZone.java b/libjava/java/util/TimeZone.java
deleted file mode 100644
index 02296d9471c..00000000000
--- a/libjava/java/util/TimeZone.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Per Bothner <bothner@cygnus.com>
- * @date October 24, 1998.
- */
-
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3.
- * Status: getAvailableIDs, getDefault, getTimeZone only know about GMT.
- */
-
-public abstract class TimeZone implements java.io.Serializable, Cloneable
-{
- public static final int SHORT = 0;
- public static final int LONG = 1;
-
- // The fields are as specified in Sun's "Serialized Form"
- // in the JDK 1.2 beta 4 API specification.
- String ID;
-
- static final TimeZone zoneGMT = new SimpleTimeZone(0, "GMT");
-
- private static TimeZone zoneDefault;
-
- public TimeZone ()
- {
- }
-
- public abstract int getOffset (int era, int year, int month,
- int day, int dayOfWeek, int milliseconds);
-
- public abstract void setRawOffset (int offsetMillis);
-
- public abstract int getRawOffset ();
-
- public String getID () { return ID; }
-
- public void setID (String ID) { this.ID = ID; }
-
- public final String getDisplayName()
- {
- return ID; // FIXME
- }
-
- // public final String getDisplayName (Local locale) { ... } FIXME
-
- public final String getDisplayName (boolean daylight, int style)
- {
- return ID; // FIXME
- }
-
- /*
- public final String getDisplayName (boolean daylight, int style, Locale locale)
- {
- return ID; // FIXME
- }
- */
-
- public abstract boolean useDaylightTime();
-
- public abstract boolean inDaylightTime (Date date);
-
- public static synchronized TimeZone getTimeZone (String ID)
- {
- int i;
- for (i = 0; i < tzIDs.length; ++i)
- {
- if (ID.equals(tzIDs[i]))
- break;
- }
- if (i == tzIDs.length)
- return null;
-
- if (timeZones[i] == null)
- {
- if (ID.equals("GMT"))
- timeZones[i] = zoneGMT;
- else
- timeZones[i] = new SimpleTimeZone (rawOffsets[i], tzIDs[i]);
- }
-
- return timeZones[i];
- }
-
- public static String[] getAvailableIDs()
- {
- return (String[]) tzIDs.clone();
- }
-
- public static String[] getAvailableIDs(int rawOffset)
- {
- int first, last;
-
- for (first = 0; first < rawOffsets.length; ++first)
- {
- if (rawOffset == rawOffsets[first])
- break;
- }
- if (first == rawOffsets.length)
- return new String[0];
- for (last = first + 1; last < rawOffsets.length; ++last)
- {
- if (rawOffset != rawOffsets[last])
- break;
- }
-
- String[] r = new String[last - first];
- for (int i = first; i < last; ++i)
- {
- r[i - first] = tzIDs[i];
- }
-
- return r;
- }
-
- private static synchronized TimeZone setDefault()
- {
- if (zoneDefault == null)
- {
- try
- {
- String id = System.getProperty("user.timezone");
- if (id != null && ! id.equals("GMT"))
- zoneDefault = getTimeZone(id);
- }
- catch (Exception ex)
- {
- }
- if (zoneDefault == null)
- zoneDefault = zoneGMT;
- }
- return zoneDefault;
- }
-
- public static TimeZone getDefault()
- {
- return zoneDefault == null ? setDefault() : zoneDefault;
- }
-
- public static void setDefault (TimeZone zone) { zoneDefault = zone; }
-
- public boolean hasSameRules (TimeZone other)
- {
- return this == other;
- }
-
- public Object clone ()
- {
- // Just use Object's generic cloner.
- return super.clone ();
- }
-
- // Names of timezones. This array is kept in parallel with
- // rawOffsets. This list comes from the JCL 1.1 book.
- private static final String[] tzIDs =
- {
- "MIT", "HST", "AST", "PST", "PNT",
- "MST", "CST", "EST", "IET", "PRT",
- "CNT", "AGT", "BET", "CAT", "GMT",
- "ECT", "EET", "ART", "EAT", "MET",
- "NET", "PLT", "IST", "BST", "VST",
- "CTT", "JST", "ACT", "AET", "SST",
- "NST"
- };
- // This holds raw offsets in milliseconds.
- // 3600000 == 60 * 60 * 1000
- private static final int[] rawOffsets =
- {
- -11 * 3600000, -10 * 3600000, -9 * 3600000, -8 * 3600000, -7 * 3600000,
- -7 * 3600000, -6 * 3600000, -5 * 3600000, -5 * 3600000, -4 * 3600000,
- -35 * 360000, -3 * 3600000, -3 * 3600000, -1 * 3600000, 0,
- 1 * 3600000, 1 * 3600000, 2 * 3600000, 3 * 3600000, 35 * 360000,
- 4 * 3600000, 5 * 3600000, 55 * 360000, 6 * 3600000, 7 * 3600000,
- 8 * 3600000, 9 * 3600000, 95 * 360000, 10 * 3600000, 11 * 3600000,
- 12 * 3600000
- };
- // This caches all the corresponding zone objects.
- private static TimeZone[] timeZones = new TimeZone[tzIDs.length];
-}
diff --git a/libjava/java/util/TooManyListenersException.java b/libjava/java/util/TooManyListenersException.java
deleted file mode 100644
index c171aa5fd44..00000000000
--- a/libjava/java/util/TooManyListenersException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date September 2, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct.
- */
-
-public class TooManyListenersException extends Exception
-{
- public TooManyListenersException()
- {
- super();
- }
-
- public TooManyListenersException(String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/util/Vector.java b/libjava/java/util/Vector.java
deleted file mode 100644
index 347d0abe7a5..00000000000
--- a/libjava/java/util/Vector.java
+++ /dev/null
@@ -1,461 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util;
-
-import java.io.Serializable;
-
-/**
- * @author Warren Levy <warrenl@cygnus.com>
- * @date August 17, 1998.
- */
-/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
- * "The Java Language Specification", ISBN 0-201-63451-1
- * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
- * Status: Believed complete and correct
- */
-
-final class VectorEnumeration implements Enumeration
-{
- private int enumIndex;
- private Vector enumVec;
-
- public VectorEnumeration(Vector vec)
- {
- enumVec = vec;
- enumIndex = 0;
- }
-
- public boolean hasMoreElements()
- {
- return enumIndex < enumVec.size();
- }
-
- public Object nextElement()
- {
- if (! (enumIndex < enumVec.size()))
- throw new NoSuchElementException();
-
- return enumVec.elementData[enumIndex++];
- }
-}
-
-// TODO12:
-// public class Vector extends AbstractList
-// implements List, Cloneable, Serializable
-
-public class Vector implements Cloneable, Serializable
-{
- /* The size of the increment to use when growing this vector.
- The default of 0 means to double the capacity when growing. */
- protected int capacityIncrement;
-
- /* The number of elements currently in elementData */
- protected int elementCount;
-
- /* The buffer in which elements of this vector are stored */
- protected Object[] elementData;
-
- public Vector()
- {
- this(10, 0);
- }
-
- public Vector(int initCap)
- {
- this(initCap, 0);
- }
-
- public Vector(int initCap, int capIncrement)
- {
- if (initCap < 0)
- throw new IllegalArgumentException ();
- elementData = new Object[initCap];
- capacityIncrement = capIncrement;
- elementCount = 0;
- }
-
- public final synchronized void addElement(Object obj)
- {
- // Make sure there's room for a new element
- if (elementCount == elementData.length)
- ensureCapacity(elementCount+1);
-
- elementData[elementCount++] = obj;
- }
-
- public final int capacity()
- {
- return elementData.length;
- }
-
- public synchronized Object clone()
- {
- // New vector needs to have same size, capacity and capacityIncrement
- Vector newVec = new Vector(elementData.length, capacityIncrement);
-
- System.arraycopy(elementData, 0, newVec.elementData, 0, elementCount);
- newVec.elementCount = elementCount;
- return newVec;
- }
-
- public final boolean contains(Object obj)
- {
- for (int i = 0; i < elementCount; i++)
- {
- if (obj == null
- ? elementData[i] == null
- : obj.equals(elementData[i]))
- return true;
- }
-
- return false;
- }
-
- public final synchronized void copyInto(Object[] objArray)
- {
- System.arraycopy(elementData, 0, objArray, 0, elementCount);
- }
-
- public final synchronized Object elementAt(int idx)
- {
- if (idx < 0 || idx >= size())
- throw new ArrayIndexOutOfBoundsException();
-
- return elementData[idx];
- }
-
- public final synchronized Enumeration elements()
- {
- return new VectorEnumeration(this);
- }
-
- public final synchronized void ensureCapacity(int minCap)
- {
- // Increasing the vector could make it much larger than minCap;
- // e.g. if minCap is just larger than the vector, size may double.
- // If someone cares about this possibility they should set capacityIncrement
- if (minCap > elementData.length)
- {
- // Increase the vector; double it if capacityIncrement is zero
- int newSize = elementData.length;
- newSize +=
- (capacityIncrement > 0) ? capacityIncrement : elementData.length;
-
- // Make sure newSize is at least minCap
- if (newSize < minCap)
- newSize = minCap;
-
- Object[] newArray = new Object[newSize];
- System.arraycopy(elementData, 0, newArray, 0, elementCount);
- elementData = newArray;
- }
- }
-
- public final synchronized Object firstElement()
- {
- if (elementCount == 0)
- throw new NoSuchElementException();
-
- return elementData[0];
- }
-
- public final int indexOf(Object obj)
- {
- return indexOf(obj, 0);
- }
-
- public final synchronized int indexOf(Object obj, int idx)
- {
- if (idx < 0)
- throw new IllegalArgumentException ();
- for (int i = idx; i < elementCount; i++)
- {
- if (obj == null
- ? elementData[i] == null
- : obj.equals(elementData[i]))
- return i;
- }
-
- return -1;
- }
-
- public final synchronized void insertElementAt(Object obj, int idx)
- {
- if (idx < 0 || idx > size())
- throw new ArrayIndexOutOfBoundsException();
- else if (idx == size()) // Spec says just use addElement()
- addElement(obj);
- else
- {
- // Make sure there's room for a new element
- if (elementCount == elementData.length)
- ensureCapacity(elementCount+1);
-
- // Shift the existing elements up and increment elementCount
- for (int i = elementCount++; i > idx; --i)
- elementData[i] = elementData[i-1];
-
- elementData[idx] = obj;
- }
- }
-
- public final boolean isEmpty()
- {
- return elementCount == 0;
- }
-
- public final synchronized Object lastElement()
- {
- if (elementCount == 0)
- throw new NoSuchElementException();
-
- return elementData[elementCount - 1];
- }
-
- public final int lastIndexOf(Object obj)
- {
- return lastIndexOf(obj, size()-1);
- }
-
- public final synchronized int lastIndexOf(Object obj, int idx)
- {
- if (idx < 0)
- throw new IllegalArgumentException ();
- for (int i = idx; i >= 0; --i)
- {
- if (obj == null
- ? elementData[i] == null
- : obj.equals(elementData[i]))
- return i;
- }
-
- return -1;
- }
-
- public final synchronized void removeAllElements()
- {
- // Remove elements now to assist the gc in early cleanup
- for (int i = elementCount-1; i >= 0; --i)
- elementData[i] = null;
- elementCount = 0;
- }
-
- public final synchronized boolean removeElement(Object obj)
- {
- for (int i = 0; i < elementCount; i++)
- {
- if (obj == null
- ? elementData[i] == null
- : obj.equals(elementData[i]))
- {
- int j;
-
- // Decrement count first to ensure we don't walk off end of array
- --elementCount;
-
- for (j = i; j < elementCount; j++)
- elementData[j] = elementData[j+1];
-
- // At this point, j was incrememented and points to old last element
- // Remove element now to assist the gc in early cleanup
- elementData[j] = null;
- return true;
- }
- }
-
- return false;
- }
-
- public final synchronized void removeElementAt(int idx)
- {
- int i;
-
- if (idx < 0 || idx >= size())
- throw new ArrayIndexOutOfBoundsException();
-
- // Decrement count first to ensure we don't walk off the end of the array
- --elementCount;
-
- for (i = idx; i < elementCount; i++)
- elementData[i] = elementData[i+1];
-
- // At this point, i was incrememented and now points to the old last element
- // Remove element now to assist the gc in early cleanup
- elementData[i] = null;
- }
-
- public final synchronized void setElementAt(Object obj, int idx)
- {
- if (idx < 0 || idx >= size())
- throw new ArrayIndexOutOfBoundsException();
-
- elementData[idx] = obj;
- }
-
- public final synchronized void setSize(int newSize)
- {
- if (newSize < 0)
- throw new ArrayIndexOutOfBoundsException();
-
- // Java Lang Spec p. 658 says to remove the excess elements and discard
- // when new size is smaller than old size.
- // When truncating, we could alternatively just reset elementCount instead
- // of freeing up the memory if the spec hadn't specified. The spec makes
- // sense though; if someone cares enough to call a setSize() function
- // they probably are doing so to free memory.
- if (newSize < elementCount)
- {
- elementCount = newSize;
- trimToSize();
- }
- else if (newSize > elementCount) // Skip == case
- {
- // TBD: ensureCapacity() may create a vector much larger than newSize;
- // do we want to make the vector exactly newSize? Spec is unclear.
- ensureCapacity(newSize);
-
- // Make sure to null out new elements of grown vector
- for (int i = elementCount; i < newSize; i++)
- elementData[i] = null;
- elementCount = newSize;
- }
- }
-
- public final int size()
- {
- return elementCount;
- }
-
- public final synchronized String toString()
- {
- // Following the Java Lang Spec p. 656
-
- // Prepend first element with open bracket
- StringBuffer result = new StringBuffer("[");
-
- if (elementCount > 0) // add first element if one exists
- result.append(elementData[0].toString());
-
- // Prepend subsequent elements with ", "
- for (int i = 1; i < elementCount; i++)
- result.append(", ").append(elementData[i].toString());
-
- // Append last element with closing bracket
- result.append("]");
- return result.toString();
- }
-
- public final synchronized void trimToSize()
- {
- // Give up excess storage capacity to save memory
- //
- // Don't bother checking for the case where size() == the capacity of the
- // vector since that is a much less likely case; it's more efficient to
- // not do the check and lose a bit of performance in that infrequent case
- Object[] newArray = new Object[elementCount];
- System.arraycopy(elementData, 0, newArray, 0, elementCount);
- elementData = newArray;
- }
-
- // TODO12:
- // public Vector(Collection c)
- // {
- // }
-
- // TODO12:
- // public public boolean add(Object o)
- // {
- // }
-
- // TODO12:
- // public void add(int index, Object element)
- // {
- // }
-
- // TODO12:
- // public boolean addAll(Collection c)
- // {
- // }
-
- // TODO12:
- // public boolean addAll(int index, Collection c)
- // {
- // }
-
- // TODO12:
- // public void clear()
- // {
- // }
-
- // TODO12:
- // public boolean containsAll(Collection c)
- // {
- // }
-
- // TODO12:
- // public boolean equals(Object o)
- // {
- // }
-
- // TODO12:
- // public int hashCode()
- // {
- // }
-
- // TODO12:
- // public Object get(int index)
- // {
- // }
-
- public synchronized boolean remove(Object o)
- {
- for (int i = 0; i < elementCount; ++i)
- {
- if (o == null
- ? elementData[i] == null
- : o.equals (elementData[i]))
- {
- System.arraycopy (elementData, i, elementData, i + 1,
- elementCount - i - 1);
- return true;
- }
- }
- return false;
- }
-
- // TODO12:
- // public Object remove(int index)
- // {
- // }
-
- // TODO12:
- // public boolean removeAll(Collection c)
- // {
- // }
-
- // TODO12:
- // public boolean retainAll(Collection c)
- // {
- // }
-
- // TODO12:
- // public Object set(int index, Object element)
- // {
- // }
-
- // TODO12:
- // public Object[] toArray()
- // {
- // }
-
- // TODO12:
- // public Object[] toArray(Object[] a)
- // {
- // }
-}
diff --git a/libjava/java/util/jar/JarEntry.java b/libjava/java/util/jar/JarEntry.java
deleted file mode 100644
index eaebd1ad7d5..00000000000
--- a/libjava/java/util/jar/JarEntry.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.jar;
-
-import java.util.zip.*;
-
-/**
- * Does not implement the security and manifest methods.
- *
- * @author Kresten Krab Thorup <krab@gnu.org>
- * @date August 10, 1999.
- */
-
-public class JarEntry extends ZipEntry
-{
- ZipEntry zip;
-
- public JarEntry (ZipEntry ent)
- {
- super (ent);
- }
-
- public JarEntry (JarEntry ent)
- {
- super (ent);
- }
-
- public JarEntry (String name)
- {
- super (name);
- }
-
-}
diff --git a/libjava/java/util/jar/JarFile.java b/libjava/java/util/jar/JarFile.java
deleted file mode 100644
index b36338c218b..00000000000
--- a/libjava/java/util/jar/JarFile.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.jar;
-
-import java.util.zip.*;
-import java.io.File;
-
-/**
- * Does not implement any of the security. Just a place holder, so
- * that I can implement URLClassLoader.
- *
- * @author Kresten Krab Thorup <krab@gnu.org>
- * @date August 10, 1999.
- */
-
-public class JarFile extends ZipFile
-{
- private boolean verify;
-
- public JarFile (String file) throws java.io.IOException
- {
- super (file);
- }
-
- public JarFile (File file) throws java.io.IOException
- {
- super (file);
- }
-
- public JarFile (String file, boolean verify) throws java.io.IOException
- {
- super (file);
- this.verify = verify;
- }
-
- public JarFile (File file, boolean verify) throws java.io.IOException
- {
- super (file);
- this.verify = verify;
- }
-
- public JarEntry getJarEntry (String name)
- {
- ZipEntry ent = getEntry(name);
- if (ent == null)
- return null;
- else
- return new JarEntry(ent);
- }
-}
diff --git a/libjava/java/util/jar/JarInputStream.java b/libjava/java/util/jar/JarInputStream.java
deleted file mode 100644
index 33daf61c5fb..00000000000
--- a/libjava/java/util/jar/JarInputStream.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.jar;
-
-import java.util.zip.*;
-
-/**
- * Does not implement any of the security. Just a place holder, so
- * that I can implement URLClassLoader.
- *
- * @author Kresten Krab Thorup <krab@gnu.org>
- * @date August 10, 1999.
- */
-
-public class JarInputStream extends ZipInputStream
-{
- public JarEntry getNextJarEntry () throws java.io.IOException
- {
- return new JarEntry (getNextEntry ());
- }
-
- public JarInputStream (java.io.InputStream is)
- {
- super(is);
- }
-}
diff --git a/libjava/java/util/natGregorianCalendar.cc b/libjava/java/util/natGregorianCalendar.cc
deleted file mode 100644
index f412410518c..00000000000
--- a/libjava/java/util/natGregorianCalendar.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-#include <config.h>
-
-#ifdef ECOS
-#include <string.h>
-#endif
-
-#include <gcj/cni.h>
-#include <java/util/TimeZone.h>
-#include <java/util/GregorianCalendar.h>
-#include <time.h>
-
-void
-java::util::GregorianCalendar::computeTime ()
-{
- struct tm tim;
- tim.tm_sec = elements(fields)[SECOND];
- tim.tm_min = elements(fields)[MINUTE];
- tim.tm_hour = elements(fields)[HOUR_OF_DAY];
- tim.tm_mday = elements(fields)[DATE];
- tim.tm_mon = elements(fields)[MONTH];
- tim.tm_year = elements(fields)[YEAR] - 1900;
- tim.tm_isdst = 0; // FIXME
-#ifndef ECOS
- // FIXME: None of the standard C library access to the ECOS calendar
- // is yet available.
- time_t t = mktime (&tim);
-#else
- time_t t = 0;
-#endif
-
- // Adjust for local timezone (introduced by mktime) and our
- // timezone.
-#if defined (STRUCT_TM_HAS_GMTOFF)
- t += tim.tm_gmtoff;
-#elif defined (HAVE_TIMEZONE)
- t -= timezone;
-#endif
- java::util::TimeZone *zone = getTimeZone ();
- t += zone->getRawOffset();
-
- // Adjust for milliseconds.
- time = t * (jlong) 1000 + elements(fields)[MILLISECOND];
-
- isTimeSet = true;
-}
-
-void
-java::util::GregorianCalendar::computeFields ()
-{
- time_t t = time / 1000;
- int millis = time % 1000;
- if (t < 0 && millis != 0)
- {
- t--;
- millis = t - 1000 * t;
- }
- elements(fields)[MILLISECOND] = millis;
- struct tm tim;
- java::util::TimeZone *zone = getTimeZone ();
-
- // FIXME: None of the standard C library access to the ECOS calendar
- // is yet available.
-#ifdef ECOS
- memset (&tim, 0, sizeof tim);
-#else
- if (zone->getRawOffset() == 0 || ! zone->useDaylightTime())
- {
-#if defined(__JV_POSIX_THREADS__) && defined(HAVE_GMTIME_R)
- gmtime_r (&t, &tim);
-#else
- // Get global lock (because gmtime uses a global buffer). FIXME
- tim = *(struct tm*) gmtime (&t);
- // Release global lock. FIXME
-#endif
- }
- else
- {
-#if defined(__JV_POSIX_THREADS__) && defined(HAVE_LOCALTIME_R)
- localtime_r (&t, &tim);
-#else
- // Get global lock (because localtime uses a global buffer). FIXME
- tim = *(struct tm*) localtime (&t);
- // Release global lock. FIXME
-#endif
- }
-#endif /* ECOS */
- elements(fields)[SECOND] = tim.tm_sec;
- elements(fields)[MINUTE] = tim.tm_min;
- elements(fields)[HOUR_OF_DAY] = tim.tm_hour;
- elements(fields)[AM_PM] = tim.tm_hour < 12 ? AM : PM;
- elements(fields)[HOUR] = tim.tm_hour % 12;
- elements(fields)[DATE] = tim.tm_mday;
- elements(fields)[MONTH] = tim.tm_mon;
- elements(fields)[YEAR] = 1900 + tim.tm_year;
- elements(fields)[DAY_OF_WEEK] = tim.tm_wday + 1;
- elements(fields)[DAY_OF_WEEK_IN_MONTH] = ((tim.tm_mday - 1) / 7) + 1;
- elements(fields)[DAY_OF_YEAR] = tim.tm_yday + 1;
- elements(fields)[WEEK_OF_MONTH]
- = (tim.tm_mday + 6 + (5 - tim.tm_wday + getFirstDayOfWeek()) % 7) / 7;
- elements(fields)[WEEK_OF_YEAR]
- = (tim.tm_yday + 7 + (5 - tim.tm_wday + getFirstDayOfWeek()) % 7) / 7;
- elements(fields)[ERA] = AD;
- elements(fields)[DST_OFFSET] = tim.tm_isdst <= 0 ? 0 : 60*60*1000;
- elements(fields)[ZONE_OFFSET] = getTimeZone()->getRawOffset();
- areFieldsSet = true;
-}
diff --git a/libjava/java/util/zip/Adler32.java b/libjava/java/util/zip/Adler32.java
deleted file mode 100644
index fc9596cdf12..00000000000
--- a/libjava/java/util/zip/Adler32.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-
-/**
- * @author Per Bothner
- * @date April 6, 1999.
- */
-
-/*
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * The actual Adler32 algorithm is taken from RFC 1950.
- * Status: Believed complete and correct.
- */
-
-public class Adler32 implements Checksum
-{
- private static int BASE = 65521; /* largest prime smaller than 65536 */
-
- int s1;
- int s2;
-
- public Adler32 ()
- {
- reset();
- }
-
- public void reset () { s1 = 1; s2 = 0; }
-
- public void update (int bval)
- {
- s1 = (s1 + (bval & 0xFF)) % BASE;
- s2 = (s1 + s2) % BASE;
- }
-
- public void update (byte[] buffer)
- {
- update(buffer, 0, buffer.length);
- }
-
- public void update (byte[] buf, int off, int len)
- {
- int s1 = this.s1;
- int s2 = this.s2;
- while (len > 0)
- {
- // We can defer the modulo operation.
- int n = 4000;
- if (n > len)
- n = len;
- len -= n;
- while (--n >= 0)
- {
- s1 = s1 + (buf[off++] & 0xFF);
- s2 = s2 + s1;
- }
- s1 %= BASE;
- s2 %= BASE;
- }
- this.s1 = s1;
- this.s2 = s2;
- }
-
- public long getValue()
- {
- return ((long) s2 << 16) + s1;
- }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/libjava/java/util/zip/CRC32.java b/libjava/java/util/zip/CRC32.java
deleted file mode 100644
index 535cf184c72..00000000000
--- a/libjava/java/util/zip/CRC32.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-
-/**
- * @author Per Bothner
- * @date April 1, 1999.
- */
-
-/*
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * The actual CRC32 algorithm is taken from RFC 1952.
- * Status: Believed complete and correct.
- */
-
-public class CRC32 implements Checksum
-{
- int crc = 0;
-
- static int[] crc_table = make_crc_table();
-
- /* Make the table for a fast CRC. */
- static int[] make_crc_table ()
- {
- int[] crc_table = new int[256];
- for (int n = 0; n < 256; n++)
- {
- int c = n;
- for (int k = 8; --k >= 0; )
- {
- if ((c & 1) != 0)
- c = 0xedb88320 ^ (c >>> 1);
- else
- c = c >>> 1;
- }
- crc_table[n] = c;
- }
- return crc_table;
- }
-
- public long getValue ()
- {
- return (long) crc & 0xffffffffL;
- }
-
- public void reset () { crc = 0; }
-
- public void update (int bval)
- {
- int c = ~crc;
- c = crc_table[(c ^ bval) & 0xff] ^ (c >>> 8);
- crc = ~c;
- }
-
- public void update (byte[] buf, int off, int len)
- {
- int c = ~crc;
- while (--len >= 0)
- c = crc_table[(c ^ buf[off++]) & 0xff] ^ (c >>> 8);
- crc = ~c;
- }
- public void update (byte[] buf) { update(buf, 0, buf.length); }
-}
diff --git a/libjava/java/util/zip/CheckedInputStream.java b/libjava/java/util/zip/CheckedInputStream.java
deleted file mode 100644
index fce050d2a73..00000000000
--- a/libjava/java/util/zip/CheckedInputStream.java
+++ /dev/null
@@ -1,80 +0,0 @@
-// CheckedInputStream.java - Compute checksum of data being read.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-
-import java.io.FilterInputStream;
-import java.io.InputStream;
-import java.io.IOException;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class CheckedInputStream extends FilterInputStream
-{
- public CheckedInputStream (InputStream in, Checksum sum)
- {
- super (in);
- this.sum = sum;
- }
-
- public Checksum getChecksum ()
- {
- return sum;
- }
-
- public int read () throws IOException
- {
- int x = in.read();
- if (x != -1)
- sum.update(x);
- return x;
- }
-
- public int read (byte[] buf, int off, int len) throws IOException
- {
- int r = in.read(buf, off, len);
- if (r != -1)
- sum.update(buf, off, r);
- return r;
- }
-
- public long skip (long n) throws IOException
- {
- if (n == 0)
- return 0;
-
- int min = (int) Math.min(n, 1024);
- byte[] buf = new byte[min];
-
- long s = 0;
- while (n > 0)
- {
- int r = in.read(buf, 0, min);
- if (r == -1)
- break;
- n -= r;
- s += r;
- sum.update(buf, 0, r);
- }
-
- return s;
- }
-
- // The checksum object.
- private Checksum sum;
-}
diff --git a/libjava/java/util/zip/CheckedOutputStream.java b/libjava/java/util/zip/CheckedOutputStream.java
deleted file mode 100644
index a6323037cd7..00000000000
--- a/libjava/java/util/zip/CheckedOutputStream.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// CheckedOutputStream.java - Compute checksum of data being written.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-
-import java.io.FilterOutputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class CheckedOutputStream extends FilterOutputStream
-{
- public CheckedOutputStream (OutputStream out, Checksum cksum)
- {
- super (out);
- this.sum = cksum;
- }
-
- public Checksum getChecksum ()
- {
- return sum;
- }
-
- public void write (int bval) throws IOException
- {
- out.write(bval);
- sum.update(bval);
- }
-
- public void write (byte[] buf, int off, int len) throws IOException
- {
- out.write(buf, off, len);
- sum.update(buf, off, len);
- }
-
- // The checksum object.
- private Checksum sum;
-}
diff --git a/libjava/java/util/zip/Checksum.java b/libjava/java/util/zip/Checksum.java
deleted file mode 100644
index e37d1834e04..00000000000
--- a/libjava/java/util/zip/Checksum.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-
-/**
- * @author Per Bothner
- * @date January 9, 1999.
- */
-
-/*
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public interface Checksum
-{
- public long getValue ();
-
- public void reset ();
-
- public void update (int bval);
-
- public void update (byte[] buf, int off, int len);
-}
diff --git a/libjava/java/util/zip/DataFormatException.java b/libjava/java/util/zip/DataFormatException.java
deleted file mode 100644
index 10d1616cdd6..00000000000
--- a/libjava/java/util/zip/DataFormatException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// DataFormatException.java
-
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.util.zip;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Believed complete and correct.
- */
-
-public class DataFormatException extends Exception
-{
- public DataFormatException ()
- {
- super();
- }
-
- public DataFormatException (String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/util/zip/Deflater.java b/libjava/java/util/zip/Deflater.java
deleted file mode 100644
index 6cf82a79550..00000000000
--- a/libjava/java/util/zip/Deflater.java
+++ /dev/null
@@ -1,129 +0,0 @@
-// Deflater.java - Compress a data stream.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-
-import gnu.gcj.RawData;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class Deflater
-{
- public static final int BEST_COMPRESSION = 9;
- public static final int BEST_SPEED = 1;
- public static final int DEFAULT_COMPRESSION = -1;
- public static final int NO_COMPRESSION = 0;
-
- public static final int DEFAULT_STRATEGY = 0;
- public static final int FILTERED = 1;
- public static final int HUFFMAN_ONLY = 2;
-
- public static final int DEFLATED = 8;
-
- public int deflate (byte[] buf)
- {
- return deflate (buf, 0, buf.length);
- }
-
- public native int deflate (byte[] buf, int off, int len);
- public native void init (int level, boolean noHeader);
- public native void update ();
-
- public Deflater ()
- {
- this (DEFAULT_COMPRESSION, false);
- }
-
- public Deflater (int lvl)
- {
- this (lvl, false);
- }
-
- public Deflater (int lvl, boolean noHeader)
- {
- this.strategy = DEFAULT_STRATEGY;
- init (lvl, noHeader);
- setLevel (lvl);
- }
-
- public native void end ();
-
- protected void finalize ()
- {
- end ();
- }
-
- public native void finish ();
-
- public synchronized boolean finished ()
- {
- return is_finished;
- }
-
- public native int getAdler ();
- public native int getTotalIn ();
- public native int getTotalOut ();
- public native boolean needsInput ();
- public native void reset ();
-
- public void setDictionary (byte[] buf)
- {
- setDictionary (buf, 0, buf.length);
- }
-
- public native void setDictionary (byte[] buf, int off, int len);
-
- public void setInput (byte[] buf)
- {
- setInput (buf, 0, buf.length);
- }
-
- public native void setInput (byte[] buf, int off, int len);
-
- public synchronized void setLevel (int lvl)
- {
- if (lvl != -1 && (lvl < 0 || lvl > 9))
- throw new IllegalArgumentException ();
- level = (lvl == -1) ? 6 : lvl;
- update ();
- }
-
- public synchronized void setStrategy (int stgy)
- {
- if (stgy != DEFAULT_STRATEGY && stgy != FILTERED
- && stgy != HUFFMAN_ONLY)
- throw new IllegalArgumentException ();
- strategy = stgy;
- update ();
- }
-
- // Compression level.
- private int level;
-
- // Compression strategy.
- private int strategy;
-
- // The zlib stream.
- private RawData zstream;
-
- // True if finished.
- private boolean is_finished;
-
- // `Flush' flag to pass to next call to deflate.
- private int flush_flag;
-}
diff --git a/libjava/java/util/zip/DeflaterOutputStream.java b/libjava/java/util/zip/DeflaterOutputStream.java
deleted file mode 100644
index 410d8868106..00000000000
--- a/libjava/java/util/zip/DeflaterOutputStream.java
+++ /dev/null
@@ -1,87 +0,0 @@
-// DeflaterOutputStream.java - Output filter for compressing.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-
-import java.io.FilterOutputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class DeflaterOutputStream extends FilterOutputStream
-{
- public void close () throws IOException
- {
- finish ();
- out.close();
- }
-
- protected void deflate () throws IOException
- {
- while (true)
- {
- int len = def.deflate(buf, 0, buf.length);
- if (len == 0 || len == -1)
- break;
- out.write(buf, 0, len);
- }
- }
-
- public DeflaterOutputStream (OutputStream out)
- {
- this (out, new Deflater (), 512);
- }
-
- public DeflaterOutputStream (OutputStream out, Deflater defl)
- {
- this (out, defl, 512);
- }
-
- public DeflaterOutputStream(OutputStream out, Deflater defl, int bufsize)
- {
- super (out);
- buf = new byte[bufsize];
- def = defl;
- }
-
- public void finish () throws IOException
- {
- def.finish();
- deflate ();
- }
-
- public void write (int bval) throws IOException
- {
- byte[] b = new byte[1];
- b[0] = (byte) bval;
- write (b, 0, 1);
- }
-
- public void write (byte[] buf, int off, int len) throws IOException
- {
- def.setInput (buf, off, len);
- deflate ();
- }
-
- // The retrieval buffer.
- protected byte[] buf;
-
- // Deflater used to compress data.
- protected Deflater def;
-}
diff --git a/libjava/java/util/zip/GZIPInputStream.java b/libjava/java/util/zip/GZIPInputStream.java
deleted file mode 100644
index bea5eb38b1d..00000000000
--- a/libjava/java/util/zip/GZIPInputStream.java
+++ /dev/null
@@ -1,154 +0,0 @@
-// GZIPInputStream.java - Input tiler for reading gzip file.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class GZIPInputStream extends InflaterInputStream
-{
- public static final int GZIP_MAGIC = 0x8b1f;
-
- public void close () throws IOException
- {
- // Nothing to do here.
- super.close();
- }
-
- public GZIPInputStream (InputStream istream) throws IOException
- {
- this (istream, 512);
- }
-
- private final int eof_read () throws IOException
- {
- int r = in.read();
- if (r == -1)
- throw new ZipException ("gzip header corrupted");
- return r & 0xff;
- }
-
- public GZIPInputStream (InputStream istream, int readsize)
- throws IOException
- {
- super (istream, new Inflater (true), readsize);
-
- // NOTE: header reading code taken from zlib's gzio.c.
-
- // Read the magic number.
- int magic = eof_read () | (eof_read () << 8);
- if (magic != GZIP_MAGIC)
- throw new ZipException ("gzip header corrupted");
-
- int method = eof_read ();
- int flags = eof_read ();
- // Test from zlib.
- if (method != Z_DEFLATED || (flags & RESERVED) != 0)
- throw new ZipException ("gzip header corrupted");
-
- // Discard time, xflags, OS code.
- for (int i = 0; i < 6; ++i)
- eof_read ();
-
- // Skip the extra field.
- if ((flags & EXTRA_FIELD) != 0)
- {
- int len = eof_read () | (eof_read () << 8);
- while (len-- != 0)
- eof_read ();
- }
-
- if ((flags & ORIG_NAME) != 0)
- {
- while (true)
- {
- int c = eof_read ();
- if (c == 0)
- break;
- }
- }
-
- if ((flags & COMMENT) != 0)
- {
- while (true)
- {
- int c = eof_read ();
- if (c == 0)
- break;
- }
- }
-
- if ((flags & HEAD_CRC) != 0)
- {
- // FIXME: consider checking CRC of the header.
- eof_read ();
- eof_read ();
- }
-
- crc = new CRC32 ();
- }
-
- public int read (byte[] buf, int off, int len) throws IOException
- {
- if (eos)
- return -1;
- int r = super.read(buf, off, len);
- if (r == -1)
- {
- eos = true;
- int header_crc = read4 ();
- if (crc.getValue() != header_crc)
- throw new ZipException ("corrupted gzip file");
- // Read final `ISIZE' field.
- // FIXME: should we check this length?
- read4 ();
- return -1;
- }
- crc.update(buf, off, r);
- return r;
- }
-
- private final int read4 () throws IOException
- {
- int byte0 = in.read();
- int byte1 = in.read();
- int byte2 = in.read();
- int byte3 = in.read();
- if (byte3 < 0)
- throw new ZipException (".zip archive ended prematurely");
- return ((byte3 & 0xFF) << 24) + ((byte2 & 0xFF) << 16)
- + ((byte1 & 0xFF) << 8) + (byte0 & 0xFF);
- }
-
- // Checksum used by this input stream.
- protected CRC32 crc;
-
- // Indicates whether end-of-stream has been reached.
- protected boolean eos;
-
- // Some constants from zlib.
- static final int Z_DEFLATED = 8;
- static final int HEAD_CRC = 0x02;
- static final int EXTRA_FIELD = 0x04;
- static final int ORIG_NAME = 0x08;
- static final int COMMENT = 0x10;
- static final int RESERVED = 0xe0;
-}
diff --git a/libjava/java/util/zip/GZIPOutputStream.java b/libjava/java/util/zip/GZIPOutputStream.java
deleted file mode 100644
index be117273cde..00000000000
--- a/libjava/java/util/zip/GZIPOutputStream.java
+++ /dev/null
@@ -1,93 +0,0 @@
-// GZIPOutputStream.java - Create a file in gzip format.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class GZIPOutputStream extends DeflaterOutputStream
-{
- public void close () throws IOException
- {
- finish ();
- out.close ();
- }
-
- public void finish () throws IOException
- {
- super.finish();
- put4 ((int) crc.getValue());
- put4 (def.getTotalIn());
- }
-
- public GZIPOutputStream (OutputStream out) throws IOException
- {
- this (out, 512);
- }
-
- public GZIPOutputStream (OutputStream out, int readsize) throws IOException
- {
- super (out, new Deflater (Deflater.DEFAULT_COMPRESSION, true), readsize);
-
- put2 (GZIPInputStream.GZIP_MAGIC);
- out.write (GZIPInputStream.Z_DEFLATED);
- // No flags for now.
- out.write (0);
- // No time either.
- put2 (0);
- put2 (0);
- // No xflags either.
- out.write (0);
- // FIXME: unknown OS.
- out.write (255);
-
- crc = new CRC32 ();
- }
-
- public synchronized void write (byte[] buf) throws IOException
- {
- write (buf, 0, buf.length);
- }
-
- public synchronized void write (byte[] buf, int off, int len)
- throws IOException
- {
- super.write(buf, off, len);
- crc.update(buf, off, len);
- }
-
- private final void put2 (int i) throws IOException
- {
- out.write (i);
- out.write (i >> 8);
- }
-
- private final void put4 (int i) throws IOException
- {
- out.write (i);
- out.write (i >> 8);
- out.write (i >> 16);
- out.write (i >> 24);
- }
-
- // Checksum used by this stream.
- protected CRC32 crc;
-}
diff --git a/libjava/java/util/zip/Inflater.java b/libjava/java/util/zip/Inflater.java
deleted file mode 100644
index dc2e24dec1e..00000000000
--- a/libjava/java/util/zip/Inflater.java
+++ /dev/null
@@ -1,98 +0,0 @@
-// Inflater.java - Decompress a data stream.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-
-import gnu.gcj.RawData;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class Inflater
-{
- public native void end ();
-
- protected void finalize ()
- {
- end ();
- }
-
- public synchronized boolean finished ()
- {
- return is_finished;
- }
-
- public native int getAdler ();
- public native int getRemaining ();
- public native int getTotalIn ();
- public native int getTotalOut ();
-
- public int inflate (byte[] buf) throws DataFormatException
- {
- return inflate (buf, 0, buf.length);
- }
-
- public native int inflate (byte[] buf, int off, int len)
- throws DataFormatException;
-
- private native void init (boolean noHeader);
-
- public Inflater ()
- {
- this (false);
- }
-
- public Inflater (boolean noHeader)
- {
- init (noHeader);
- }
-
- public synchronized boolean needsDictionary ()
- {
- return dict_needed;
- }
-
- public synchronized boolean needsInput ()
- {
- return getRemaining () == 0;
- }
-
- public native void reset ();
-
- public void setDictionary (byte[] buf)
- {
- setDictionary (buf, 0, buf.length);
- }
-
- public native void setDictionary (byte[] buf, int off, int len);
-
- public void setInput (byte[] buf)
- {
- setInput (buf, 0, buf.length);
- }
-
- public native void setInput (byte[] buf, int off, int len);
-
- // The zlib stream.
- private RawData zstream;
-
- // True if finished.
- private boolean is_finished;
-
- // True if dictionary needed.
- private boolean dict_needed;
-}
diff --git a/libjava/java/util/zip/InflaterInputStream.java b/libjava/java/util/zip/InflaterInputStream.java
deleted file mode 100644
index c5840e7a5fa..00000000000
--- a/libjava/java/util/zip/InflaterInputStream.java
+++ /dev/null
@@ -1,109 +0,0 @@
-// InflaterInputStream.java - Input stream filter for decompressing.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-
-import java.io.FilterInputStream;
-import java.io.InputStream;
-import java.io.IOException;
-
-/**
- * @author Tom Tromey
- * @date May 17, 1999
- */
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class InflaterInputStream extends FilterInputStream
-{
- protected void fill () throws IOException
- {
- len = in.read(buf, 0, buf.length);
- if (len != -1)
- inf.setInput(buf, 0, len);
- }
-
- public InflaterInputStream (InputStream in)
- {
- this (in, new Inflater (), 512);
- }
-
- public InflaterInputStream (InputStream in, Inflater infl)
- {
- this (in, infl, 512);
- }
-
- public InflaterInputStream (InputStream in, Inflater infl, int bufsize)
- {
- super (in);
- this.inf = infl;
- this.buf = new byte[bufsize];
- }
-
- public int read () throws IOException
- {
- byte[] buf = new byte[1];
- int r = read (buf, 0, 1);
- if (r != -1)
- r = buf[0] & 0xff;
- return r;
- }
-
- public int read (byte[] buf, int off, int len) throws IOException
- {
- if (inf.finished())
- return -1;
- if (inf.needsInput())
- fill ();
- if (inf.needsDictionary())
- return -1;
- try
- {
- return inf.inflate(buf, off, len);
- }
- catch (DataFormatException dfe)
- {
- throw new ZipException (dfe.getMessage());
- }
- }
-
- public long skip (long n) throws IOException
- {
- if (n == 0)
- return 0;
-
- int min = (int) Math.min(n, 1024);
- byte[] buf = new byte[min];
-
- long s = 0;
- while (n > 0)
- {
- int r = read (buf, 0, min);
- if (r == -1)
- break;
- n -= r;
- s += r;
- }
-
- return s;
- }
-
- // Buffer for delivering uncompressed data to inflater.
- protected byte[] buf;
-
- // Inflater used to decompress data.
- protected Inflater inf;
-
- // Number of read bytes in buf.
- protected int len;
-}
diff --git a/libjava/java/util/zip/ZipConstants.java b/libjava/java/util/zip/ZipConstants.java
deleted file mode 100644
index 3e3cd8a1c37..00000000000
--- a/libjava/java/util/zip/ZipConstants.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-
-interface ZipConstants
-{
- // Size in bytes of local file header, including signature.
- public static final int LOCAL_FILE_HEADER_SIZE = 30;
-
- // Size in bytes of the "end of central directory" record, with signature.
- public static final int END_CENTRAL_DIR_SIZE = 22;
-}
diff --git a/libjava/java/util/zip/ZipEntry.java b/libjava/java/util/zip/ZipEntry.java
deleted file mode 100644
index cf8d98b4445..00000000000
--- a/libjava/java/util/zip/ZipEntry.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-
-/**
- * @author Per Bothner
- * @date January 6, 1999.
- */
-
-/*
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public class ZipEntry implements ZipConstants, Cloneable
-{
- // These values were determined using a simple test program.
- public static final int STORED = 0;
- public static final int DEFLATED = 8;
-
- String comment;
- long compressedSize = -1;
- long crc = -1;
- byte[] extra;
- int method = -1;
- String name;
- long size = -1;
- long time = -1;
- long relativeOffset = -1;
-
- ZipEntry next;
-
- public ZipEntry (String name)
- {
- if (name.length() > 65535)
- throw new IllegalArgumentException ();
- this.name = name;
- }
-
- public ZipEntry (ZipEntry ent)
- {
- comment = ent.comment;
- compressedSize = ent.compressedSize;
- crc = ent.crc;
- extra = ent.extra;
- method = ent.method;
- name = ent.name;
- size = ent.size;
- time = ent.time;
- relativeOffset = ent.relativeOffset;
- }
-
- public Object clone ()
- {
- // JCL defines this as being the same as the copy constructor above,
- // except that value of the "extra" field is also copied.
- ZipEntry clone = new ZipEntry (this);
- clone.extra = (byte[]) extra.clone ();
- return clone;
- }
-
- public String getComment () { return comment; }
-
- public long getCompressedSize () { return compressedSize; }
-
- public long getCrc () { return crc; }
-
- public byte[] getExtra() { return extra; }
-
- public int getMethod () { return method; }
-
- public String getName () { return name; }
-
- public long getSize () { return size; }
-
- public long getTime () { return time; }
-
- public boolean isDirectory ()
- {
- if (name != null)
- {
- int nlen = name.length();
- if (nlen > 0 && name.charAt(nlen-1) == '/')
- return true;
- }
- return false;
- }
-
- public void setComment (String comment)
- {
- if (comment != null && comment.length() > 65535)
- throw new IllegalArgumentException ();
- this.comment = comment;
- }
-
- public void setCompressedSize (long compressedSize)
- {
- if (size < 0 || size > 0xffffffffL)
- throw new IllegalArgumentException ();
- this.compressedSize = compressedSize;
- }
-
- public void setCrc (long crc)
- {
- if (crc < 0 || crc > 0xffffffffL)
- throw new IllegalArgumentException ();
- this.crc = crc;
- }
-
- public void setExtra (byte[] extra)
- {
- if (extra != null && extra.length > 65535)
- throw new IllegalArgumentException ();
- this.extra = extra;
- }
-
- public void setMethod (int method)
- {
- if (method != DEFLATED && method != STORED)
- throw new IllegalArgumentException ();
- this.method = method;
- }
-
- public void setSize (long size)
- {
- if (size < 0 || size > 0xffffffffL)
- throw new IllegalArgumentException ();
- this.size = size;
- }
-
- public void setTime (long time)
- {
- this.time = time;
- }
-
- private final static short[] daysToMonthStart = {
- //Jan Feb Mar Apr May Jun Jul
- 0, 31, 31+28, 2*31+28, 2*31+28+30, 3*31+28+30, 3*31+28+2*30,
- // Aug Sep Oct Nov Dec
- 4*31+28+2*30, 5*31+28+2*30, 5*31+28+3*30, 6*31+28+3*30, 6*31+28+4*30};
-
- /** Convert a DOS-style type value to milliseconds since 1970. */
- static long timeFromDOS (int date, int time)
- {
- int sec = 2 * (time & 0x1f);
- int min = (time >> 5) & 0x3f;
- int hrs = (time >> 11) & 0x1f;
- int day = date & 0x1f;
- int mon = ((date >> 5) & 0xf) - 1;
- int year = ((date >> 9) & 0x7f) + 10; /* Since 1970. */
-
- // Guard against invalid or missing date causing IndexOutOfBoundsException.
- if (mon < 0 || mon > 11)
- return -1;
-
- long mtime = (((hrs * 60) + min) * 60 + sec) * 1000;
-
- // Leap year calculations are rather trivial in this case ...
- int days = 365 * year + ((year+1)>>2);
- days += daysToMonthStart[mon];
- if ((year & 3) == 0 && mon > 1)
- days++;
- days += day;
- return (days * 24*60*60L + ((hrs * 60) + min) * 60 + sec) * 1000L;
- }
-
- public String toString () { return name; }
-
- public int hashCode () { return name.hashCode (); }
-}
diff --git a/libjava/java/util/zip/ZipException.java b/libjava/java/util/zip/ZipException.java
deleted file mode 100644
index a4a119c7480..00000000000
--- a/libjava/java/util/zip/ZipException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// ZipException.java
-
-/* Copyright (C) 1998, 1999 Free Software Foundation
-
- This file is part of libjava.
-
-This software is copyrighted work licensed under the terms of the
-Libjava License. Please consult the file "LIBJAVA_LICENSE" for
-details. */
-
-package java.util.zip;
-
-/**
- * @author Per Bothner
- * @date January 9, 1999.
- */
-
-/* Written using on-line Java Platform 1.2 API Specification.
- * Believed complete and correct.
- */
-
-public class ZipException extends java.io.IOException
-{
- public ZipException ()
- {
- super();
- }
-
- public ZipException (String msg)
- {
- super(msg);
- }
-}
diff --git a/libjava/java/util/zip/ZipFile.java b/libjava/java/util/zip/ZipFile.java
deleted file mode 100644
index 78257869fe9..00000000000
--- a/libjava/java/util/zip/ZipFile.java
+++ /dev/null
@@ -1,193 +0,0 @@
-// ZipFile.java - Read contents of a ZIP file.
-
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-import java.io.*;
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class ZipFile implements ZipConstants
-{
- public ZipFile (String fname) throws IOException
- {
- file = new RandomAccessFile(fname, "r");
- name = fname;
- readDirectory ();
- }
-
- public ZipFile (File f) throws IOException
- {
- file = new RandomAccessFile(f, "r");
- name = f.getName();
- readDirectory ();
- }
-
- void readDirectory () throws IOException
- {
- long size = file.length ();
- if (size < ZipConstants.END_CENTRAL_DIR_SIZE)
- throw new ZipException ("zipfile too short");
- // We do not handle a "zipfile comment", which the appnote says can
- // be at the end of a .zip file. We could handle this by seeking
- // to the beginning and reading forwards.
- file.seek(size - ZipConstants.END_CENTRAL_DIR_SIZE);
- if (file.read() != 'P'
- || file.read() != 'K'
- || file.read() != '\005'
- || file.read() != '\006')
- throw new ZipException("not a valid zipfile");
- file.skipBytes(6);
- numEntries = readu2();
- int dir_size = read4 (); // Read "size of the central directory".
- file.seek(size - (dir_size + ZipConstants.END_CENTRAL_DIR_SIZE));
-
- ZipEntry last = null;
- for (int i = 0; i < numEntries; i++)
- {
- file.skipBytes(10);
- int method = readu2();
- int modtime = readu2();
- int moddate = readu2();
- int crc = read4();
- int compressedSize = read4();
- int uncompressedSize = read4();
- int filenameLength = readu2();
- int extraLength = readu2();
- int commentLength = readu2();
- int diskNumberStart = readu2();
- int intAttributes = readu2();
- int extAttributes = read4();
- int relativeOffset = read4();
- byte[] bname = new byte[filenameLength];
- file.readFully(bname);
- ZipEntry entry = new ZipEntry(new String(bname, "8859_1"));
- if (extraLength > 0)
- {
- byte[] bextra = new byte[extraLength];
- file.readFully(bextra);
- entry.extra = bextra;
- }
- if (commentLength > 0)
- {
- byte[] bcomment = new byte[commentLength];
- file.readFully(bcomment);
- entry.comment = new String(bcomment, "8859_1");
- }
- entry.compressedSize = compressedSize;
- entry.size = uncompressedSize;
- entry.crc = (long) crc & 0xffffffffL;
- entry.method = method;
- entry.relativeOffset = relativeOffset;
- entry.time = ZipEntry.timeFromDOS(moddate, modtime);
- if (last == null)
- entries = entry;
- else
- last.next = entry;
- last = entry;
- }
- }
-
- public java.util.Enumeration entries()
- {
- return new ZipEnumeration(this);
- }
-
- public void close() throws IOException
- {
- file.close();
- entries = null;
- numEntries = 0;
- }
-
- public ZipEntry getEntry(String name)
- {
- for (ZipEntry entry = entries; entry != null; entry = entry.next)
- {
- if (name.equals(entry.getName()))
- return entry;
- }
- return null;
- }
-
- public InputStream getInputStream(ZipEntry ze) throws IOException
- {
- byte[] buffer = new byte[(int) ze.getSize()];
-
- /* Read the size of the extra field, and skip to the start of the
- data. */
- file.seek (ze.relativeOffset + ZipConstants.LOCAL_FILE_HEADER_SIZE - 2);
- int extraFieldLength = readu2();
- file.skipBytes (ze.getName().length() + extraFieldLength);
-
- file.readFully(buffer);
-
- InputStream is = new ByteArrayInputStream (buffer);
- if (ze.getMethod() == ZipEntry.DEFLATED)
- // Data in zipfile entries does not have a zlib header, so construct
- // an Inflater with the `nowrapper' option.
- is = new InflaterInputStream (is, new Inflater (true), 512);
- return is;
- }
-
- public String getName () { return name; }
-
- private int readu2 () throws IOException
- {
- int byte0 = file.read();
- int byte1 = file.read();
- if (byte0 < 0 || byte1 < 0)
- throw new ZipException (".zip archive ended prematurely");
- return ((byte1 & 0xFF) << 8) | (byte0 & 0xFF);
- }
-
- private int read4 () throws IOException
- {
- int byte0 = file.read();
- int byte1 = file.read();
- int byte2 = file.read();
- int byte3 = file.read();
- if (byte3 < 0)
- throw new ZipException (".zip archive ended prematurely");
- return ((byte3 & 0xFF) << 24) + ((byte2 & 0xFF) << 16)
- + ((byte1 & 0xFF) << 8) + (byte0 & 0xFF);
- }
-
- ZipEntry entries;
- int numEntries;
- RandomAccessFile file;
- String name;
-}
-
-final class ZipEnumeration implements java.util.Enumeration
-{
- ZipEntry entry;
-
- ZipEnumeration (ZipFile zfile)
- {
- entry = zfile.entries;
- }
-
- public boolean hasMoreElements ()
- {
- return entry != null;
- }
-
- public Object nextElement ()
- {
- ZipEntry cur = entry;
- if (cur == null)
- throw new java.util.NoSuchElementException();
- entry = cur.next;
- return cur;
- }
-}
diff --git a/libjava/java/util/zip/ZipInputStream.java b/libjava/java/util/zip/ZipInputStream.java
deleted file mode 100644
index 492cf67c733..00000000000
--- a/libjava/java/util/zip/ZipInputStream.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-import java.io.*;
-
-/**
- * @author Per Bothner
- * @date May 1999.
- */
-
-/*
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Quite incomplete, but can read uncompressed .zip archives.
- */
-
-// JDK1.2 has "protected ZipEntry createZipEntry(String)" but is very
-// vague about what the method does. FIXME.
-// We do not calculate the CRC and compare it with the specified value;
-// we probably should. FIXME.
-
-
-public class ZipInputStream extends InflaterInputStream implements ZipConstants
-{
- public ZipInputStream (InputStream in)
- {
- super (in, new Inflater (true));
- }
-
- public ZipEntry getNextEntry () throws IOException
- {
- if (current != null)
- closeEntry();
- if (in.read() != 'P'
- || in.read() != 'K')
- return null;
- int code = in.read();
- while (code == '\001')
- {
- code = in.read();
- if (code != '\002')
- return null;
- in.skip(16);
- int size = read4();
- in.skip(4);
- int fname_length = readu2();
- int extra_length = readu2();
- int fcomment_length = readu2();
- // `12' is the number of bytes between the comment length
- // field and the end of the fixed part of the header:
- // 2 bytes for `disk number start'
- // 2 bytes for `internal file attributes'
- // 4 bytes for `external file attributes'
- // 4 bytes for `relative offset of local header'
- in.skip(12 + fname_length + extra_length + fcomment_length);
- if (in.read() != 'P' || in.read() != 'K')
- return null;
- code = in.read();
- }
- if (code == '\005')
- {
- if (in.read() != '\006')
- return null;
- in.skip(16);
- int comment_size = readu2();
- in.skip(comment_size);
- if (in.read() != 'P' || in.read() != 'K')
- return null;
- code = in.read();
- }
- if (code != '\003'
- || in.read() != '\004')
- return null;
- int ex_version = readu2();
- current_flags = readu2();
- int method = readu2();
- int modtime = readu2();
- int moddate = readu2();
- int crc = read4();
- int compressedSize = read4();
- int uncompressedSize = read4();
- int filenameLength = readu2();
- int extraLength = readu2();
- byte[] bname = new byte[filenameLength];
- readFully(bname);
- ZipEntry entry = new ZipEntry(new String(bname, "8859_1"));
- if (extraLength > 0)
- {
- byte[] bextra = new byte[extraLength];
- readFully(bextra);
- entry.extra = bextra;
- }
- entry.compressedSize = compressedSize;
- entry.size = uncompressedSize;
- entry.crc = (long) crc & 0xffffffffL;
- entry.method = method;
- entry.time = ZipEntry.timeFromDOS(moddate, modtime);
- current = entry;
- avail = uncompressedSize;
- compressed_bytes = compressedSize;
- return entry;
- }
-
- // We override fill to let us control how much data gets read from
- // the underlying input stream. This lets us avoid having to push
- // back data.
- protected void fill () throws IOException
- {
- int count = buf.length;
- if (count > compressed_bytes)
- count = compressed_bytes;
- len = in.read(buf, 0, count);
- if (len != -1)
- {
- compressed_bytes -= len;
- inf.setInput(buf, 0, len);
- }
- }
-
- public int read (byte[] b, int off, int len) throws IOException
- {
- if (len > avail)
- len = avail;
- int count;
- if (current.method == Deflater.DEFLATED)
- count = super.read(b, off, len);
- else
- count = in.read(b, off, len);
- if (count == -1 || avail == 0)
- {
- inf.reset();
- count = -1;
- }
- else
- avail -= count;
- return count;
- }
-
- public long skip (long n) throws IOException
- {
- if (n > avail)
- n = avail;
- long count;
- if (current.method == Deflater.DEFLATED)
- count = super.skip(n);
- else
- count = in.skip(n);
- avail = avail - (int) count;
- return count;
- }
-
- private void readFully (byte[] b) throws IOException
- {
- int off = 0;
- int len = b.length;
- while (len > 0)
- {
- int count = in.read(b, off, len);
- if (count <= 0)
- throw new EOFException(".zip archive ended prematurely");
- off += count;
- len -= count;
- }
- }
-
- private int readu2 () throws IOException
- {
- int byte0 = in.read();
- int byte1 = in.read();
- if (byte0 < 0 || byte1 < 0)
- throw new EOFException(".zip archive ended prematurely");
- return ((byte1 & 0xFF) << 8) | (byte0 & 0xFF);
- }
-
- private int read4 () throws IOException
- {
- int byte0 = in.read();
- int byte1 = in.read();
- int byte2 = in.read();
- int byte3 = in.read();
- if (byte3 < 0)
- throw new EOFException(".zip archive ended prematurely");
- return ((byte3 & 0xFF) << 24) + ((byte2 & 0xFF) << 16)
- + ((byte1 & 0xFF) << 8) + (byte0 & 0xFF);
- }
-
- public void closeEntry () throws IOException
- {
- if (current != null)
- {
- if (avail > 0)
- skip (avail);
- if ((current_flags & 8) != 0)
- {
- int sig = read4();
- if (sig != 0x04034b50)
- throw new ZipException("bad/missing magic number at end of .zip entry");
- int crc = read4();
- int compressedSize = read4();
- int uncompressedSize = read4();
- if (current.compressedSize != compressedSize
- || current.size != uncompressedSize
- || current.crc != crc)
- throw new ZipException("bad data descriptor at end of .zip entry");
- }
- current = null;
- avail = 0;
- }
- }
-
- public void close () throws IOException
- {
- current = null;
- super.close();
- }
-
- private ZipEntry current;
- private int current_flags;
- // Number of uncompressed bytes to be read.
- private int avail;
- // Number of bytes we can read from underlying stream.
- private int compressed_bytes;
-}
diff --git a/libjava/java/util/zip/ZipOutputStream.java b/libjava/java/util/zip/ZipOutputStream.java
deleted file mode 100644
index afd5664ca28..00000000000
--- a/libjava/java/util/zip/ZipOutputStream.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-package java.util.zip;
-import java.io.*;
-
-/* Written using on-line Java Platform 1.2 API Specification
- * and JCL book.
- * Believed complete and correct.
- */
-
-public class ZipOutputStream extends DeflaterOutputStream
- implements ZipConstants
-{
- public static final int STORED = 0;
- public static final int DEFLATED = 8;
-
- public void close () throws IOException
- {
- finish ();
- out.close();
- }
-
- public void closeEntry () throws IOException
- {
- int uncompressed_size = def.getTotalIn();
- int compressed_size = def.getTotalOut();
- long crc = filter.getChecksum().getValue();
-
- bytes_written += compressed_size;
-
- bytes_written += put4 (0x08074b50);
- if (current.getCrc() == -1 || current.getCompressedSize() == -1
- || current.getSize() == -1)
- {
- current.setCrc(crc);
- current.compressedSize = compressed_size;
- current.setSize(uncompressed_size);
- }
- else
- {
- if (current.getCrc() != crc
- || current.getCompressedSize() != compressed_size
- || current.getSize() != uncompressed_size)
- throw new ZipException ("zip entry field incorrect");
- }
- bytes_written += put4 ((int) (current.getCrc()));
- bytes_written += put4 ((int) (current.getCompressedSize()));
- bytes_written += put4 ((int) (current.getSize()));
-
- current.next = chain;
- chain = current;
- current = null;
- filter = null;
- }
-
- public void finish () throws IOException
- {
- if (current != null)
- closeEntry ();
-
- // Write the central directory.
- long offset = bytes_written;
- int count = 0;
- int bytes = 0;
- while (chain != null)
- {
- bytes += write_entry (chain, false);
- ++count;
- chain = chain.next;
- }
-
- // Write the end of the central directory record.
- put4 (0x06054b50);
- // Disk number.
- put2 (0);
- // Another disk number.
- put2 (0);
- put2 (count);
- put4 (bytes);
- put4 ((int) offset);
-
- byte[] c = comment.getBytes("8859_1");
- put2 (c.length);
- out.write(c);
- out.write((byte) 0);
- }
-
- // Helper for finish and putNextEntry.
- private int write_entry (ZipEntry entry, boolean is_local)
- throws IOException
- {
- long offset = bytes_written;
-
- int bytes = put4 (is_local ? 0x04034b50 : 0x02014b50);
- if (! is_local)
- bytes += put_version ();
- bytes += put_version ();
-
- boolean crc_after = false;
- if (is_local
- && (entry.getCrc() == -1 || entry.getCompressedSize() == -1
- || entry.getSize() == -1))
- crc_after = true;
- // For the bits field we always indicate `normal' compression,
- // even if that isn't true.
- bytes += put2 (crc_after ? (1 << 3) : 0);
- bytes += put2 (entry.method);
-
- bytes += put2(0); // time - FIXME
- bytes += put2(0); // date - FIXME
-
- if (crc_after)
- {
- // CRC, compressedSize, and Size are always 0 in this header.
- // The actual values are given after the entry.
- bytes += put4 (0);
- bytes += put4 (0);
- bytes += put4 (0);
- }
- else
- {
- bytes += put4 ((int) (entry.getCrc()));
- bytes += put4 ((int) (entry.getCompressedSize()));
- bytes += put4 ((int) (entry.getSize()));
- }
-
- byte[] name = entry.name.getBytes("8859_1");
- bytes += put2 (name.length);
- bytes += put2 (entry.extra == null ? 0 : entry.extra.length);
-
- byte[] comment = null;
- if (! is_local)
- {
- if (entry.getComment() == null)
- bytes += put2 (0);
- else
- {
- comment = entry.getComment().getBytes("8859_1");
- bytes += put2 (comment.length);
- }
-
- // Disk number start.
- bytes += put2 (0);
- // Internal file attributes.
- bytes += put2 (0);
- // External file attributes.
- bytes += put2 (0);
- // Relative offset of local header.
- bytes += put2 ((int) offset);
- }
-
- out.write (name);
- out.write ((byte) 0);
- bytes += name.length + 1;
- if (entry.extra != null)
- {
- out.write(entry.extra);
- out.write((byte) 0);
- bytes += entry.extra.length + 1;
- }
- if (comment != null)
- {
- out.write(comment);
- out.write((byte) 0);
- bytes += comment.length + 1;
- }
-
- bytes_written += bytes;
- return bytes;
- }
-
- public void putNextEntry (ZipEntry entry) throws IOException
- {
- if (current != null)
- closeEntry ();
-
- if (entry.method < 0 )
- entry.method = method;
- if (entry.method == STORED)
- {
- if (entry.getSize() == -1 || entry.getCrc() == -1)
- throw new ZipException ("required entry not set");
- // Just in case.
- entry.compressedSize = entry.getSize();
- }
- write_entry (entry, true);
- current = entry;
- int compr = (method == STORED) ? Deflater.NO_COMPRESSION : level;
- def.reset();
- def.setLevel(compr);
- filter = new CheckedOutputStream (new DeflaterOutputStream (out, def),
- new CRC32 ());
- }
-
- public void setLevel (int level)
- {
- if (level != Deflater.DEFAULT_COMPRESSION
- && (level < Deflater.NO_COMPRESSION
- || level > Deflater.BEST_COMPRESSION))
- throw new IllegalArgumentException ();
- this.level = level;
- }
-
- public void setMethod (int method)
- {
- if (method != DEFLATED && method != STORED)
- throw new IllegalArgumentException ();
- this.method = method;
- }
-
- public void setComment (String comment)
- {
- if (comment.length() > 65535)
- throw new IllegalArgumentException ();
- this.comment = comment;
- }
-
- public synchronized void write (byte[] buf, int off, int len)
- throws IOException
- {
- if (filter == null)
- throw new ZipException ("no open zip entry");
- filter.write(buf, off, len);
- }
-
- public ZipOutputStream (OutputStream out)
- {
- super (out);
- def = new Deflater (level, true);
- }
-
- private int put2 (int i) throws IOException
- {
- out.write (i);
- out.write (i >> 8);
- return 2;
- }
-
- private int put4 (int i) throws IOException
- {
- out.write (i);
- out.write (i >> 8);
- out.write (i >> 16);
- out.write (i >> 24);
- return 4;
- }
-
- private int put_version () throws IOException
- {
- // FIXME: for now we assume Unix, and we ignore the version
- // number.
- return put2 (3 << 8);
- }
-
- // The entry we are currently writing, or null if we've called
- // closeEntry.
- private ZipEntry current;
- // The chain of entries which have been written to this file.
- private ZipEntry chain;
- // The output stream to which data should be sent.
- private CheckedOutputStream filter;
-
- private int method = DEFLATED;
- private int level = Deflater.DEFAULT_COMPRESSION;
- private String comment = "";
- private long bytes_written;
-
- // The Deflater we use.
- private Deflater def;
-}
diff --git a/libjava/java/util/zip/natDeflater.cc b/libjava/java/util/zip/natDeflater.cc
deleted file mode 100644
index 8ef6cf66d6e..00000000000
--- a/libjava/java/util/zip/natDeflater.cc
+++ /dev/null
@@ -1,214 +0,0 @@
-// natDeflater.cc - Implementation of Deflater native methods.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-// Written by Tom Tromey <tromey@cygnus.com>
-
-#include <config.h>
-
-#include <zlib.h>
-#include <stdlib.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-
-#include <java/util/zip/Deflater.h>
-#include <java/util/zip/DataFormatException.h>
-
-#include <java/lang/InternalError.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/ArrayIndexOutOfBoundsException.h>
-
-extern void *_Jv_ZMalloc (void *, uInt nitems, uInt size);
-extern void _Jv_ZFree (void *, void *addr);
-
-
-
-jint
-java::util::zip::Deflater::deflate (jbyteArray buf, jint off, jint len)
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- if (! buf)
- _Jv_Throw (new java::lang::NullPointerException);
- if (off < 0 || len < 0 || off + len > buf->length)
- _Jv_Throw (new java::lang::ArrayIndexOutOfBoundsException);
-
- if (len == 0)
- return 0;
-
- s->next_out = (Bytef *) (elements (buf) + off);
- s->avail_out = len;
-
- switch (::deflate (s, flush_flag))
- {
- case Z_STREAM_END:
- is_finished = true;
- if (s->avail_out == (unsigned int) len)
- return -1;
- break;
-
- case Z_STREAM_ERROR:
- case Z_BUF_ERROR:
- // FIXME?
- _Jv_Throw (new java::lang::InternalError);
- break;
-
- case Z_OK:
- break;
- }
-
- return len - s->avail_out;
-}
-
-void
-java::util::zip::Deflater::end ()
-{
- JvSynchronize sync (this);
- // Just ignore errors.
- deflateEnd ((z_streamp) zstream);
- _Jv_Free (zstream);
- zstream = NULL;
-}
-
-void
-java::util::zip::Deflater::finish ()
-{
- JvSynchronize sync (this);
- flush_flag = Z_FINISH;
-}
-
-jint
-java::util::zip::Deflater::getAdler ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->adler;
-}
-
-jint
-java::util::zip::Deflater::getTotalIn ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->total_in;
-}
-
-jint
-java::util::zip::Deflater::getTotalOut ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->total_out;
-}
-
-jboolean
-java::util::zip::Deflater::needsInput ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->avail_in == 0;
-}
-
-void
-java::util::zip::Deflater::reset ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- // Just ignore errors.
- deflateReset (s);
- flush_flag = 0;
-}
-
-void
-java::util::zip::Deflater::setDictionary (jbyteArray buf, jint off, jint len)
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- if (! buf)
- _Jv_Throw (new java::lang::NullPointerException);
- if (off < 0 || len < 0 || off + len > buf->length)
- _Jv_Throw (new java::lang::ArrayIndexOutOfBoundsException);
-
- // Ignore errors.
- deflateSetDictionary (s, (Bytef *) (elements (buf) + off), len);
-}
-
-void
-java::util::zip::Deflater::setInput (jbyteArray buf, jint off, jint len)
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- if (! buf)
- _Jv_Throw (new java::lang::NullPointerException);
- if (off < 0 || len < 0 || off + len > buf->length)
- _Jv_Throw (new java::lang::ArrayIndexOutOfBoundsException);
-
- s->next_in = (Bytef *) (elements (buf) + off);
- s->avail_in = len;
-}
-
-void
-java::util::zip::Deflater::update ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- int strat = Z_DEFAULT_STRATEGY;
- switch (strategy)
- {
- case DEFAULT_STRATEGY:
- strat = Z_DEFAULT_STRATEGY;
- break;
- case FILTERED:
- strat = Z_FILTERED;
- break;
- case HUFFMAN_ONLY:
- strat = Z_HUFFMAN_ONLY;
- break;
- default:
- JvFail ("unexpected strategy");
- }
-
- // Ignore errors.
- deflateParams (s, level, strat);
-}
-
-void
-java::util::zip::Deflater::init (jint level, jboolean no_header)
-{
- z_stream_s *stream = (z_stream_s *) _Jv_Malloc (sizeof (z_stream_s));
- stream->next_in = Z_NULL;
- stream->avail_in = 0;
- stream->zalloc = _Jv_ZMalloc;
- stream->zfree = _Jv_ZFree;
- stream->opaque = NULL;
-
- // Handle NO_HEADER using undocumented zlib feature.
- int wbits = MAX_WBITS;
- if (no_header)
- wbits = - wbits;
-
-#define DEFAULT_MEM_LEVEL 8
- if (deflateInit2 (stream, level, Z_DEFLATED, wbits,
- DEFAULT_MEM_LEVEL, Z_DEFAULT_STRATEGY) != Z_OK)
- {
- jstring msg = NULL;
- if (stream->msg != NULL)
- msg = JvNewStringLatin1 (stream->msg);
- _Jv_Throw (new java::lang::InternalError (msg));
- }
-
- zstream = reinterpret_cast<gnu::gcj::RawData *> (stream);
- is_finished = false;
- flush_flag = 0;
-}
diff --git a/libjava/java/util/zip/natInflater.cc b/libjava/java/util/zip/natInflater.cc
deleted file mode 100644
index f3d258cdd59..00000000000
--- a/libjava/java/util/zip/natInflater.cc
+++ /dev/null
@@ -1,206 +0,0 @@
-// natInflater.cc - Implementation of Inflater native methods.
-
-/* Copyright (C) 1999 Free Software Foundation
-
- This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
-details. */
-
-// Written by Tom Tromey <tromey@cygnus.com>
-
-#include <config.h>
-
-#include <zlib.h>
-#include <stdlib.h>
-
-#include <gcj/cni.h>
-#include <jvm.h>
-
-#include <java/util/zip/Inflater.h>
-#include <java/util/zip/DataFormatException.h>
-
-#include <java/lang/InternalError.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/ArrayIndexOutOfBoundsException.h>
-#include <java/lang/OutOfMemoryError.h>
-
-
-
-// A couple of helper functions used to interface with zlib's
-// allocation.
-
-void *
-_Jv_ZMalloc (void *, uInt nitems, uInt size)
-{
- return _Jv_Malloc (nitems * size);
-}
-
-void
-_Jv_ZFree (void *, void *addr)
-{
- _Jv_Free (addr);
-}
-
-
-
-void
-java::util::zip::Inflater::end ()
-{
- JvSynchronize sync (this);
- // Just ignore errors.
- inflateEnd ((z_streamp) zstream);
- _Jv_Free (zstream);
- zstream = NULL;
-}
-
-jint
-java::util::zip::Inflater::getAdler ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->adler;
-}
-
-jint
-java::util::zip::Inflater::getRemaining ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->avail_in;
-}
-
-jint
-java::util::zip::Inflater::getTotalIn ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->total_in;
-}
-
-jint
-java::util::zip::Inflater::getTotalOut ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- return s->total_out;
-}
-
-jint
-java::util::zip::Inflater::inflate (jbyteArray buf, jint off, jint len)
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- if (! buf)
- _Jv_Throw (new java::lang::NullPointerException);
- if (off < 0 || len < 0 || off + len > buf->length)
- _Jv_Throw (new java::lang::ArrayIndexOutOfBoundsException);
-
- if (len == 0)
- return 0;
-
- s->next_out = (Bytef *) (elements (buf) + off);
- s->avail_out = len;
-
- switch (::inflate (s, Z_SYNC_FLUSH))
- {
- case Z_STREAM_END:
- is_finished = true;
- if (s->avail_out == (unsigned int) len)
- return -1;
- break;
-
- case Z_NEED_DICT:
- dict_needed = true;
- break;
-
- case Z_DATA_ERROR:
- _Jv_Throw (new java::util::zip::DataFormatException
- (s->msg == NULL ? NULL : JvNewStringLatin1 (s->msg)));
- break;
-
- case Z_MEM_ERROR:
- _Jv_Throw (new java::lang::OutOfMemoryError);
- break;
-
- case Z_BUF_ERROR:
- // FIXME?
- _Jv_Throw (new java::lang::InternalError);
- break;
-
- case Z_OK:
- break;
- }
-
- return len - s->avail_out;
-}
-
-void
-java::util::zip::Inflater::reset ()
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
- // Just ignore errors.
- inflateReset (s);
-}
-
-void
-java::util::zip::Inflater::setDictionary (jbyteArray buf, jint off, jint len)
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- if (! buf)
- _Jv_Throw (new java::lang::NullPointerException);
- if (off < 0 || len < 0 || off + len > buf->length)
- _Jv_Throw (new java::lang::ArrayIndexOutOfBoundsException);
-
- // Ignore errors.
- inflateSetDictionary (s, (Bytef *) (elements (buf) + off), len);
- dict_needed = false;
-}
-
-void
-java::util::zip::Inflater::setInput (jbyteArray buf, jint off, jint len)
-{
- JvSynchronize sync (this);
- z_streamp s = (z_streamp) zstream;
-
- if (! buf)
- _Jv_Throw (new java::lang::NullPointerException);
- if (off < 0 || len < 0 || off + len > buf->length)
- _Jv_Throw (new java::lang::ArrayIndexOutOfBoundsException);
-
- s->next_in = (Bytef *) (elements (buf) + off);
- s->avail_in = len;
-}
-
-void
-java::util::zip::Inflater::init (jboolean no_header)
-{
- z_stream_s *stream = (z_stream_s *) _Jv_Malloc (sizeof (z_stream_s));
- stream->next_in = Z_NULL;
- stream->avail_in = 0;
- stream->zalloc = _Jv_ZMalloc;
- stream->zfree = _Jv_ZFree;
- stream->opaque = NULL;
-
- // Handle NO_HEADER using undocumented zlib feature.
- int wbits = MAX_WBITS;
- if (no_header)
- wbits = - wbits;
-
- if (inflateInit2 (stream, wbits) != Z_OK)
- {
- jstring msg = NULL;
- if (stream->msg != NULL)
- msg = JvNewStringLatin1 (stream->msg);
- _Jv_Throw (new java::lang::InternalError (msg));
- }
-
- zstream = reinterpret_cast<gnu::gcj::RawData *> (stream);
- is_finished = false;
- dict_needed = false;
-}