You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/01/02 17:22:07 UTC
svn commit: r491834 [1/7] - in
/harmony/enhanced/classlib/trunk/modules/luni/src/main/java: java/net/
java/util/ org/apache/harmony/luni/internal/nls/
org/apache/harmony/luni/internal/reflect/ org/apache/harmony/luni/net/
Author: tellison
Date: Tue Jan 2 08:22:05 2007
New Revision: 491834
URL: http://svn.apache.org/viewvc?view=rev&rev=491834
Log:
Externalize messages. fix compiler warnings, format with spaces.
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ContentHandler.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractMap.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractSet.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Arrays.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/BitSet.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Currency.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Date.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/DuplicateFormatFlagsException.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/EnumMap.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/EnumSet.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Formatter.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/HashMap.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Hashtable.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermission.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/PropertyPermissionCollection.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UUID.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/WeakHashMap.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/nls/messages.properties
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyCharArrayCache.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/reflect/ProxyObjectCache.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/Socks4Message.java
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ContentHandler.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ContentHandler.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ContentHandler.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ContentHandler.java Tue Jan 2 08:22:05 2007
@@ -29,41 +29,43 @@
* @see URLConnection#getContent()
*/
public abstract class ContentHandler {
- /**
- * Answers the object pointed by the specified URL Connection
- * <code>uConn</code>.
- *
- * @return java.lang.Object the object referred by <code>uConn</code>
- * @param uConn
- * URLConnection the URL connection that points to the
- * desired object
- * @throws IOException
- * thrown if an IO error occurs during the retrieval of the
- * object
- */
- public abstract Object getContent(URLConnection uConn) throws IOException;
+ /**
+ * Answers the object pointed by the specified URL Connection
+ * <code>uConn</code>.
+ *
+ * @return java.lang.Object the object referred by <code>uConn</code>
+ * @param uConn
+ * URLConnection the URL connection that points to the desired
+ * object
+ * @throws IOException
+ * thrown if an IO error occurs during the retrieval of the
+ * object
+ */
+ public abstract Object getContent(URLConnection uConn) throws IOException;
- /**
- * Answers the object pointed by the specified URL Connection
- * <code>uConn</code>.
- *
- * @param uConn
- * java.net.URLConnection the URL connection that points to the
- * desired object
- * @param types
- * The list of acceptable content types
- * @return Object The object of the resource pointed by this URL, or null if
- * the content does not match a specified content type.
- *
- * @throws IOException
- * If an error occurred obtaining the content.
- */
- public Object getContent(URLConnection uConn, Class[] types)
+ /**
+ * Answers the object pointed by the specified URL Connection
+ * <code>uConn</code>.
+ *
+ * @param uConn
+ * java.net.URLConnection the URL connection that points to the
+ * desired object
+ * @param types
+ * The list of acceptable content types
+ * @return Object The object of the resource pointed by this URL, or null if
+ * the content does not match a specified content type.
+ *
+ * @throws IOException
+ * If an error occurred obtaining the content.
+ */
+ @SuppressWarnings("unchecked")
+ // Class arg not generified in the spec.
+ public Object getContent(URLConnection uConn, Class[] types)
throws IOException {
Object content = getContent(uConn);
Class<?> cl = content.getClass();
for (int i = 0; i < types.length; i++) {
- if (cl == types[i]) {
+ if (cl.isInstance(types[i])) {
return content;
}
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java Tue Jan 2 08:22:05 2007
@@ -17,255 +17,260 @@
package java.util;
-
/**
* AbstractList is an abstract implementation of the List interface, optimized
* for a backing store which supports random access. This implementation does
* not support adding or replacing. A subclass must implement the abstract
* methods get() and size().
+ *
* @since 1.2
*/
-public abstract class AbstractList<E> extends AbstractCollection<E> implements List<E> {
+public abstract class AbstractList<E> extends AbstractCollection<E> implements
+ List<E> {
+
+ protected transient int modCount;
- protected transient int modCount;
+ private class SimpleListIterator implements Iterator<E> {
+ int pos = -1;
- private class SimpleListIterator implements Iterator<E> {
- int pos = -1;
int expectedModCount;
- int lastPosition = -1;
- SimpleListIterator() {
+ int lastPosition = -1;
+
+ SimpleListIterator() {
super();
- expectedModCount = modCount;
- }
+ expectedModCount = modCount;
+ }
- public boolean hasNext() {
- return pos + 1 < size();
- }
-
- public E next() {
- if (expectedModCount == modCount) {
- try {
- E result = get(pos + 1);
- lastPosition = ++pos;
- return result;
- } catch (IndexOutOfBoundsException e) {
- throw new NoSuchElementException();
- }
- }
- throw new ConcurrentModificationException();
- }
-
- public void remove() {
- if (expectedModCount == modCount) {
- try {
- AbstractList.this.remove(lastPosition);
- } catch (IndexOutOfBoundsException e) {
- throw new IllegalStateException();
- }
- if (modCount != expectedModCount) {
+ public boolean hasNext() {
+ return pos + 1 < size();
+ }
+
+ public E next() {
+ if (expectedModCount == modCount) {
+ try {
+ E result = get(pos + 1);
+ lastPosition = ++pos;
+ return result;
+ } catch (IndexOutOfBoundsException e) {
+ throw new NoSuchElementException();
+ }
+ }
+ throw new ConcurrentModificationException();
+ }
+
+ public void remove() {
+ if (expectedModCount == modCount) {
+ try {
+ AbstractList.this.remove(lastPosition);
+ } catch (IndexOutOfBoundsException e) {
+ throw new IllegalStateException();
+ }
+ if (modCount != expectedModCount) {
expectedModCount++;
}
- if (pos == lastPosition) {
+ if (pos == lastPosition) {
pos--;
}
- lastPosition = -1;
- } else {
+ lastPosition = -1;
+ } else {
throw new ConcurrentModificationException();
}
- }
- }
+ }
+ }
- private final class FullListIterator extends SimpleListIterator implements
- ListIterator<E> {
- FullListIterator(int start) {
+ private final class FullListIterator extends SimpleListIterator implements
+ ListIterator<E> {
+ FullListIterator(int start) {
super();
- if (0 <= start && start <= size()) {
+ if (0 <= start && start <= size()) {
pos = start - 1;
} else {
throw new IndexOutOfBoundsException();
}
- }
+ }
- public void add(E object) {
- if (expectedModCount == modCount) {
- try {
- AbstractList.this.add(pos + 1, object);
- } catch (IndexOutOfBoundsException e) {
- throw new NoSuchElementException();
- }
- pos++;
- lastPosition = -1;
- if (modCount != expectedModCount) {
+ public void add(E object) {
+ if (expectedModCount == modCount) {
+ try {
+ AbstractList.this.add(pos + 1, object);
+ } catch (IndexOutOfBoundsException e) {
+ throw new NoSuchElementException();
+ }
+ pos++;
+ lastPosition = -1;
+ if (modCount != expectedModCount) {
expectedModCount++;
}
- } else {
+ } else {
throw new ConcurrentModificationException();
}
- }
+ }
+
+ public boolean hasPrevious() {
+ return pos >= 0;
+ }
+
+ public int nextIndex() {
+ return pos + 1;
+ }
+
+ public E previous() {
+ if (expectedModCount == modCount) {
+ try {
+ E result = get(pos);
+ lastPosition = pos;
+ pos--;
+ return result;
+ } catch (IndexOutOfBoundsException e) {
+ throw new NoSuchElementException();
+ }
+ }
+ throw new ConcurrentModificationException();
+ }
+
+ public int previousIndex() {
+ return pos;
+ }
- public boolean hasPrevious() {
- return pos >= 0;
- }
-
- public int nextIndex() {
- return pos + 1;
- }
-
- public E previous() {
- if (expectedModCount == modCount) {
- try {
- E result = get(pos);
- lastPosition = pos;
- pos--;
- return result;
- } catch (IndexOutOfBoundsException e) {
- throw new NoSuchElementException();
- }
- }
- throw new ConcurrentModificationException();
- }
-
- public int previousIndex() {
- return pos;
- }
-
- public void set(E object) {
- if (expectedModCount == modCount) {
- try {
- AbstractList.this.set(lastPosition, object);
- } catch (IndexOutOfBoundsException e) {
- throw new IllegalStateException();
- }
- } else {
+ public void set(E object) {
+ if (expectedModCount == modCount) {
+ try {
+ AbstractList.this.set(lastPosition, object);
+ } catch (IndexOutOfBoundsException e) {
+ throw new IllegalStateException();
+ }
+ } else {
throw new ConcurrentModificationException();
}
- }
- }
+ }
+ }
- private static final class SubAbstractListRandomAccess<E> extends
- SubAbstractList<E> implements RandomAccess {
- SubAbstractListRandomAccess(AbstractList<E> list, int start, int end) {
- super(list, start, end);
- }
- }
+ private static final class SubAbstractListRandomAccess<E> extends
+ SubAbstractList<E> implements RandomAccess {
+ SubAbstractListRandomAccess(AbstractList<E> list, int start, int end) {
+ super(list, start, end);
+ }
+ }
+
+ private static class SubAbstractList<E> extends AbstractList<E> {
+ private final AbstractList<E> fullList;
- private static class SubAbstractList<E> extends AbstractList<E> {
- private final AbstractList<E> fullList;
+ private int offset;
- private int offset;
private int size;
- private static final class SubAbstractListIterator<E> implements
- ListIterator<E> {
- private final SubAbstractList<E> subList;
+ private static final class SubAbstractListIterator<E> implements
+ ListIterator<E> {
+ private final SubAbstractList<E> subList;
+
+ private final ListIterator<E> iterator;
- private final ListIterator<E> iterator;
+ private int start;
- private int start;
private int end;
- SubAbstractListIterator(ListIterator<E> it, SubAbstractList<E> list,
- int offset, int length) {
+ SubAbstractListIterator(ListIterator<E> it,
+ SubAbstractList<E> list, int offset, int length) {
super();
- iterator = it;
- subList = list;
- start = offset;
- end = start + length;
- }
-
- public void add(E object) {
- iterator.add(object);
- subList.sizeChanged(true);
- end++;
- }
-
- public boolean hasNext() {
- return iterator.nextIndex() < end;
- }
-
- public boolean hasPrevious() {
- return iterator.previousIndex() >= start;
- }
+ iterator = it;
+ subList = list;
+ start = offset;
+ end = start + length;
+ }
+
+ public void add(E object) {
+ iterator.add(object);
+ subList.sizeChanged(true);
+ end++;
+ }
- public E next() {
- if (iterator.nextIndex() < end) {
+ public boolean hasNext() {
+ return iterator.nextIndex() < end;
+ }
+
+ public boolean hasPrevious() {
+ return iterator.previousIndex() >= start;
+ }
+
+ public E next() {
+ if (iterator.nextIndex() < end) {
return iterator.next();
}
- throw new NoSuchElementException();
- }
+ throw new NoSuchElementException();
+ }
- public int nextIndex() {
- return iterator.nextIndex() - start;
- }
+ public int nextIndex() {
+ return iterator.nextIndex() - start;
+ }
- public E previous() {
- if (iterator.previousIndex() >= start) {
+ public E previous() {
+ if (iterator.previousIndex() >= start) {
return iterator.previous();
}
- throw new NoSuchElementException();
- }
+ throw new NoSuchElementException();
+ }
- public int previousIndex() {
- int previous = iterator.previousIndex();
- if (previous >= start) {
+ public int previousIndex() {
+ int previous = iterator.previousIndex();
+ if (previous >= start) {
return previous - start;
}
- return -1;
- }
+ return -1;
+ }
+
+ public void remove() {
+ iterator.remove();
+ subList.sizeChanged(false);
+ end--;
+ }
- public void remove() {
- iterator.remove();
- subList.sizeChanged(false);
- end--;
- }
-
- public void set(E object) {
- iterator.set(object);
- }
- }
+ public void set(E object) {
+ iterator.set(object);
+ }
+ }
- SubAbstractList(AbstractList<E> list, int start, int end) {
+ SubAbstractList(AbstractList<E> list, int start, int end) {
super();
- fullList = list;
- modCount = fullList.modCount;
- offset = start;
- size = end - start;
- }
+ fullList = list;
+ modCount = fullList.modCount;
+ offset = start;
+ size = end - start;
+ }
- @Override
+ @Override
public void add(int location, E object) {
- if (modCount == fullList.modCount) {
- if (0 <= location && location <= size) {
- fullList.add(location + offset, object);
- size++;
- modCount = fullList.modCount;
- } else {
+ if (modCount == fullList.modCount) {
+ if (0 <= location && location <= size) {
+ fullList.add(location + offset, object);
+ size++;
+ modCount = fullList.modCount;
+ } else {
throw new IndexOutOfBoundsException();
}
- } else {
+ } else {
throw new ConcurrentModificationException();
}
- }
+ }
- @Override
+ @Override
public boolean addAll(int location, Collection<? extends E> collection) {
- if (modCount == fullList.modCount) {
- if (0 <= location && location <= size) {
- boolean result = fullList.addAll(location + offset,
- collection);
- if (result) {
- size += collection.size();
- modCount = fullList.modCount;
- }
- return result;
- }
- throw new IndexOutOfBoundsException();
- }
- throw new ConcurrentModificationException();
- }
+ if (modCount == fullList.modCount) {
+ if (0 <= location && location <= size) {
+ boolean result = fullList.addAll(location + offset,
+ collection);
+ if (result) {
+ size += collection.size();
+ modCount = fullList.modCount;
+ }
+ return result;
+ }
+ throw new IndexOutOfBoundsException();
+ }
+ throw new ConcurrentModificationException();
+ }
- @Override
+ @Override
public boolean addAll(Collection<? extends E> collection) {
if (modCount == fullList.modCount) {
boolean result = fullList.addAll(offset + size, collection);
@@ -278,420 +283,420 @@
throw new ConcurrentModificationException();
}
- @Override
+ @Override
public E get(int location) {
- if (modCount == fullList.modCount) {
- if (0 <= location && location < size) {
+ if (modCount == fullList.modCount) {
+ if (0 <= location && location < size) {
return fullList.get(location + offset);
}
- throw new IndexOutOfBoundsException();
- }
- throw new ConcurrentModificationException();
- }
+ throw new IndexOutOfBoundsException();
+ }
+ throw new ConcurrentModificationException();
+ }
- @Override
+ @Override
public Iterator<E> iterator() {
- return listIterator(0);
- }
+ return listIterator(0);
+ }
- @Override
+ @Override
public ListIterator<E> listIterator(int location) {
- if (modCount == fullList.modCount) {
- if (0 <= location && location <= size) {
+ if (modCount == fullList.modCount) {
+ if (0 <= location && location <= size) {
return new SubAbstractListIterator<E>(fullList
- .listIterator(location + offset), this, offset,
- size);
+ .listIterator(location + offset), this, offset,
+ size);
}
- throw new IndexOutOfBoundsException();
- }
- throw new ConcurrentModificationException();
- }
+ throw new IndexOutOfBoundsException();
+ }
+ throw new ConcurrentModificationException();
+ }
- @Override
+ @Override
public E remove(int location) {
- if (modCount == fullList.modCount) {
- if (0 <= location && location < size) {
- E result = fullList.remove(location + offset);
- size--;
- modCount = fullList.modCount;
- return result;
- }
- throw new IndexOutOfBoundsException();
- }
- throw new ConcurrentModificationException();
- }
+ if (modCount == fullList.modCount) {
+ if (0 <= location && location < size) {
+ E result = fullList.remove(location + offset);
+ size--;
+ modCount = fullList.modCount;
+ return result;
+ }
+ throw new IndexOutOfBoundsException();
+ }
+ throw new ConcurrentModificationException();
+ }
- @Override
+ @Override
protected void removeRange(int start, int end) {
- if (start != end) {
- if (modCount == fullList.modCount) {
- fullList.removeRange(start + offset, end + offset);
- size -= end - start;
- modCount = fullList.modCount;
- } else {
+ if (start != end) {
+ if (modCount == fullList.modCount) {
+ fullList.removeRange(start + offset, end + offset);
+ size -= end - start;
+ modCount = fullList.modCount;
+ } else {
throw new ConcurrentModificationException();
}
- }
- }
+ }
+ }
- @Override
+ @Override
public E set(int location, E object) {
- if (modCount == fullList.modCount) {
- if (0 <= location && location < size) {
+ if (modCount == fullList.modCount) {
+ if (0 <= location && location < size) {
return fullList.set(location + offset, object);
}
- throw new IndexOutOfBoundsException();
- }
- throw new ConcurrentModificationException();
- }
+ throw new IndexOutOfBoundsException();
+ }
+ throw new ConcurrentModificationException();
+ }
- @Override
+ @Override
public int size() {
- return size;
- }
+ return size;
+ }
- void sizeChanged(boolean increment) {
- if (increment) {
+ void sizeChanged(boolean increment) {
+ if (increment) {
size++;
} else {
size--;
}
- modCount = fullList.modCount;
- }
- }
-
- /**
- * Constructs a new instance of this AbstractList.
- *
- */
- protected AbstractList() {
+ modCount = fullList.modCount;
+ }
+ }
+
+ /**
+ * Constructs a new instance of this AbstractList.
+ *
+ */
+ protected AbstractList() {
super();
- }
+ }
+
+ /**
+ * Inserts the specified object into this List at the specified location.
+ * The object is inserted before any previous element at the specified
+ * location. If the location is equal to the size of this List, the object
+ * is added at the end.
+ *
+ *
+ * @param location
+ * the index at which to insert
+ * @param object
+ * the object to add
+ *
+ * @exception UnsupportedOperationException
+ * when adding to this List is not supported
+ * @exception ClassCastException
+ * when the class of the object is inappropriate for this
+ * List
+ * @exception IllegalArgumentException
+ * when the object cannot be added to this List
+ * @exception IndexOutOfBoundsException
+ * when <code>location < 0 || >= size()</code>
+ */
+ public void add(int location, E object) {
+ throw new UnsupportedOperationException();
+ }
- /**
- * Inserts the specified object into this List at the specified location.
- * The object is inserted before any previous element at the specified
- * location. If the location is equal to the size of this List, the object
- * is added at the end.
- *
- *
- * @param location
- * the index at which to insert
- * @param object
- * the object to add
- *
- * @exception UnsupportedOperationException
- * when adding to this List is not supported
- * @exception ClassCastException
- * when the class of the object is inappropriate for this
- * List
- * @exception IllegalArgumentException
- * when the object cannot be added to this List
- * @exception IndexOutOfBoundsException
- * when <code>location < 0 || >= size()</code>
- */
- public void add(int location, E object) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Adds the specified object at the end of this List.
- *
- *
- * @param object
- * the object to add
- * @return true
- *
- * @exception UnsupportedOperationException
- * when adding to this List is not supported
- * @exception ClassCastException
- * when the class of the object is inappropriate for this
- * List
- * @exception IllegalArgumentException
- * when the object cannot be added to this List
- */
- @Override
+ /**
+ * Adds the specified object at the end of this List.
+ *
+ *
+ * @param object
+ * the object to add
+ * @return true
+ *
+ * @exception UnsupportedOperationException
+ * when adding to this List is not supported
+ * @exception ClassCastException
+ * when the class of the object is inappropriate for this
+ * List
+ * @exception IllegalArgumentException
+ * when the object cannot be added to this List
+ */
+ @Override
public boolean add(E object) {
- add(size(), object);
- return true;
- }
-
- /**
- * Inserts the objects in the specified Collection at the specified location
- * in this List. The objects are added in the order they are returned from
- * the Collection iterator.
- *
- *
- * @param location
- * the index at which to insert
- * @param collection
- * the Collection of objects
- * @return true if this List is modified, false otherwise
- *
- * @exception UnsupportedOperationException
- * when adding to this List is not supported
- * @exception ClassCastException
- * when the class of an object is inappropriate for this List
- * @exception IllegalArgumentException
- * when an object cannot be added to this List
- * @exception IndexOutOfBoundsException
- * when <code>location < 0 || >= size()</code>
- */
- public boolean addAll(int location, Collection<? extends E> collection) {
- Iterator<? extends E> it = collection.iterator();
- while (it.hasNext()) {
+ add(size(), object);
+ return true;
+ }
+
+ /**
+ * Inserts the objects in the specified Collection at the specified location
+ * in this List. The objects are added in the order they are returned from
+ * the Collection iterator.
+ *
+ *
+ * @param location
+ * the index at which to insert
+ * @param collection
+ * the Collection of objects
+ * @return true if this List is modified, false otherwise
+ *
+ * @exception UnsupportedOperationException
+ * when adding to this List is not supported
+ * @exception ClassCastException
+ * when the class of an object is inappropriate for this List
+ * @exception IllegalArgumentException
+ * when an object cannot be added to this List
+ * @exception IndexOutOfBoundsException
+ * when <code>location < 0 || >= size()</code>
+ */
+ public boolean addAll(int location, Collection<? extends E> collection) {
+ Iterator<? extends E> it = collection.iterator();
+ while (it.hasNext()) {
add(location++, it.next());
}
- return !collection.isEmpty();
- }
+ return !collection.isEmpty();
+ }
- /**
- * Removes all elements from this List, leaving it empty.
- *
- *
- * @exception UnsupportedOperationException
- * when removing from this List is not supported
- *
- * @see List#isEmpty
- * @see List#size
- */
- @Override
+ /**
+ * Removes all elements from this List, leaving it empty.
+ *
+ *
+ * @exception UnsupportedOperationException
+ * when removing from this List is not supported
+ *
+ * @see List#isEmpty
+ * @see List#size
+ */
+ @Override
public void clear() {
- removeRange(0, size());
- }
+ removeRange(0, size());
+ }
- /**
- * Compares the specified object to this List and answer if they are equal.
- * The object must be a List which contains the same objects in the same
- * order.
- *
- *
- * @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this List, false
- * otherwise
- *
- * @see #hashCode
- */
- @Override
+ /**
+ * Compares the specified object to this List and answer if they are equal.
+ * The object must be a List which contains the same objects in the same
+ * order.
+ *
+ *
+ * @param object
+ * the object to compare with this object
+ * @return true if the specified object is equal to this List, false
+ * otherwise
+ *
+ * @see #hashCode
+ */
+ @Override
public boolean equals(Object object) {
- if (this == object) {
+ if (this == object) {
return true;
}
- if (object instanceof List) {
- List<?> list = (List) object;
- if (list.size() != size()) {
+ if (object instanceof List) {
+ List<?> list = (List<?>) object;
+ if (list.size() != size()) {
return false;
}
- Iterator<?> it1 = iterator(), it2 = list.iterator();
- while (it1.hasNext()) {
- Object e1 = it1.next(), e2 = it2.next();
- if (!(e1 == null ? e2 == null : e1.equals(e2))) {
+ Iterator<?> it1 = iterator(), it2 = list.iterator();
+ while (it1.hasNext()) {
+ Object e1 = it1.next(), e2 = it2.next();
+ if (!(e1 == null ? e2 == null : e1.equals(e2))) {
return false;
}
- }
- return true;
- }
- return false;
- }
-
- /**
- * Answers the element at the specified location in this List.
- *
- *
- * @param location
- * the index of the element to return
- * @return the element at the specified index
- *
- * @exception IndexOutOfBoundsException
- * when <code>location < 0 || >= size()</code>
- */
- public abstract E get(int location);
-
- /**
- * Answers an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
- @Override
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Answers the element at the specified location in this List.
+ *
+ *
+ * @param location
+ * the index of the element to return
+ * @return the element at the specified index
+ *
+ * @exception IndexOutOfBoundsException
+ * when <code>location < 0 || >= size()</code>
+ */
+ public abstract E get(int location);
+
+ /**
+ * Answers an integer hash code for the receiver. Objects which are equal
+ * answer the same value for this method.
+ *
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+ @Override
public int hashCode() {
- int result = 1;
- Iterator<?> it = iterator();
- while (it.hasNext()) {
- Object object = it.next();
- result = (31 * result) + (object == null ? 0 : object.hashCode());
- }
- return result;
- }
-
- /**
- * Searches this List for the specified object and returns the index of the
- * first occurrence.
- *
- *
- * @param object
- * the object to search for
- * @return the index of the first occurrence of the object
- */
- public int indexOf(Object object) {
- ListIterator<?> it = listIterator();
- if (object != null) {
- while (it.hasNext()) {
+ int result = 1;
+ Iterator<?> it = iterator();
+ while (it.hasNext()) {
+ Object object = it.next();
+ result = (31 * result) + (object == null ? 0 : object.hashCode());
+ }
+ return result;
+ }
+
+ /**
+ * Searches this List for the specified object and returns the index of the
+ * first occurrence.
+ *
+ *
+ * @param object
+ * the object to search for
+ * @return the index of the first occurrence of the object
+ */
+ public int indexOf(Object object) {
+ ListIterator<?> it = listIterator();
+ if (object != null) {
+ while (it.hasNext()) {
if (object.equals(it.next())) {
return it.previousIndex();
}
}
- } else {
- while (it.hasNext()) {
+ } else {
+ while (it.hasNext()) {
if (it.next() == null) {
return it.previousIndex();
}
}
- }
- return -1;
- }
-
- /**
- * Answers an Iterator on the elements of this List. The elements are
- * iterated in the same order that they occur in the List.
- *
- *
- * @return an Iterator on the elements of this List
- *
- * @see Iterator
- */
- @Override
+ }
+ return -1;
+ }
+
+ /**
+ * Answers an Iterator on the elements of this List. The elements are
+ * iterated in the same order that they occur in the List.
+ *
+ *
+ * @return an Iterator on the elements of this List
+ *
+ * @see Iterator
+ */
+ @Override
public Iterator<E> iterator() {
- return new SimpleListIterator();
- }
+ return new SimpleListIterator();
+ }
- /**
- * Searches this List for the specified object and returns the index of the
- * last occurrence.
- *
- *
- * @param object
- * the object to search for
- * @return the index of the last occurrence of the object
- */
- public int lastIndexOf(Object object) {
- ListIterator<?> it = listIterator(size());
- if (object != null) {
- while (it.hasPrevious()) {
+ /**
+ * Searches this List for the specified object and returns the index of the
+ * last occurrence.
+ *
+ *
+ * @param object
+ * the object to search for
+ * @return the index of the last occurrence of the object
+ */
+ public int lastIndexOf(Object object) {
+ ListIterator<?> it = listIterator(size());
+ if (object != null) {
+ while (it.hasPrevious()) {
if (object.equals(it.previous())) {
return it.nextIndex();
}
}
- } else {
- while (it.hasPrevious()) {
+ } else {
+ while (it.hasPrevious()) {
if (it.previous() == null) {
return it.nextIndex();
}
}
- }
- return -1;
- }
-
- /**
- * Answers a ListIterator on the elements of this List. The elements are
- * iterated in the same order that they occur in the List.
- *
- *
- * @return a ListIterator on the elements of this List
- *
- * @see ListIterator
- */
- public ListIterator<E> listIterator() {
- return listIterator(0);
- }
-
- /**
- * Answers a ListIterator on the elements of this List. The elements are
- * iterated in the same order that they occur in the List. The iteration
- * starts at the specified location.
- *
- *
- * @param location
- * the index at which to start the iteration
- * @return a ListIterator on the elements of this List
- *
- * @exception IndexOutOfBoundsException
- * when <code>location < 0 || >= size()</code>
- *
- * @see ListIterator
- */
- public ListIterator<E> listIterator(int location) {
- return new FullListIterator(location);
- }
-
- /**
- * Removes the object at the specified location from this List.
- *
- *
- * @param location
- * the index of the object to remove
- * @return the removed object
- *
- * @exception UnsupportedOperationException
- * when removing from this List is not supported
- * @exception IndexOutOfBoundsException
- * when <code>location < 0 || >= size()</code>
- */
- public E remove(int location) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Removes the objects in the specified range from the start to the, but not
- * including, end index.
- *
- *
- * @param start
- * the index at which to start removing
- * @param end
- * the index one past the end of the range to remove
- *
- * @exception UnsupportedOperationException
- * when removing from this List is not supported
- * @exception IndexOutOfBoundsException
- * when <code>start < 0
- */
- protected void removeRange(int start, int end) {
- Iterator<?> it = listIterator(start);
- for (int i = start; i < end; i++) {
- it.next();
- it.remove();
- }
- }
-
- /**
- * Replaces the element at the specified location in this List with the
- * specified object.
- *
- *
- * @param location
- * the index at which to put the specified object
- * @param object
- * the object to add
- * @return the previous element at the index
- *
- * @exception UnsupportedOperationException
- * when replacing elements in this List is not supported
- * @exception ClassCastException
- * when the class of an object is inappropriate for this List
- * @exception IllegalArgumentException
- * when an object cannot be added to this List
- * @exception IndexOutOfBoundsException
- * when <code>location < 0 || >= size()</code>
- */
- public E set(int location, E object) {
- throw new UnsupportedOperationException();
- }
+ }
+ return -1;
+ }
+
+ /**
+ * Answers a ListIterator on the elements of this List. The elements are
+ * iterated in the same order that they occur in the List.
+ *
+ *
+ * @return a ListIterator on the elements of this List
+ *
+ * @see ListIterator
+ */
+ public ListIterator<E> listIterator() {
+ return listIterator(0);
+ }
+
+ /**
+ * Answers a ListIterator on the elements of this List. The elements are
+ * iterated in the same order that they occur in the List. The iteration
+ * starts at the specified location.
+ *
+ *
+ * @param location
+ * the index at which to start the iteration
+ * @return a ListIterator on the elements of this List
+ *
+ * @exception IndexOutOfBoundsException
+ * when <code>location < 0 || >= size()</code>
+ *
+ * @see ListIterator
+ */
+ public ListIterator<E> listIterator(int location) {
+ return new FullListIterator(location);
+ }
+
+ /**
+ * Removes the object at the specified location from this List.
+ *
+ *
+ * @param location
+ * the index of the object to remove
+ * @return the removed object
+ *
+ * @exception UnsupportedOperationException
+ * when removing from this List is not supported
+ * @exception IndexOutOfBoundsException
+ * when <code>location < 0 || >= size()</code>
+ */
+ public E remove(int location) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Removes the objects in the specified range from the start to the, but not
+ * including, end index.
+ *
+ *
+ * @param start
+ * the index at which to start removing
+ * @param end
+ * the index one past the end of the range to remove
+ *
+ * @exception UnsupportedOperationException
+ * when removing from this List is not supported
+ * @exception IndexOutOfBoundsException
+ * when <code>start < 0
+ */
+ protected void removeRange(int start, int end) {
+ Iterator<?> it = listIterator(start);
+ for (int i = start; i < end; i++) {
+ it.next();
+ it.remove();
+ }
+ }
+
+ /**
+ * Replaces the element at the specified location in this List with the
+ * specified object.
+ *
+ *
+ * @param location
+ * the index at which to put the specified object
+ * @param object
+ * the object to add
+ * @return the previous element at the index
+ *
+ * @exception UnsupportedOperationException
+ * when replacing elements in this List is not supported
+ * @exception ClassCastException
+ * when the class of an object is inappropriate for this List
+ * @exception IllegalArgumentException
+ * when an object cannot be added to this List
+ * @exception IndexOutOfBoundsException
+ * when <code>location < 0 || >= size()</code>
+ */
+ public E set(int location, E object) {
+ throw new UnsupportedOperationException();
+ }
/**
* Returns a part of consecutive elements of this list as a view. From start
@@ -737,16 +742,16 @@
* @exception IllegalArgumentException
* when (start > end)
*/
- public List<E> subList(int start, int end) {
- if (0 <= start && end <= size()) {
- if (start <= end) {
- if (this instanceof RandomAccess) {
+ public List<E> subList(int start, int end) {
+ if (0 <= start && end <= size()) {
+ if (start <= end) {
+ if (this instanceof RandomAccess) {
return new SubAbstractListRandomAccess<E>(this, start, end);
}
- return new SubAbstractList<E>(this, start, end);
- }
- throw new IllegalArgumentException();
- }
- throw new IndexOutOfBoundsException();
- }
+ return new SubAbstractList<E>(this, start, end);
+ }
+ throw new IllegalArgumentException();
+ }
+ throw new IndexOutOfBoundsException();
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractMap.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractMap.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractMap.java Tue Jan 2 08:22:05 2007
@@ -19,8 +19,9 @@
/**
* AbstractMap is an abstract implementation of the Map interface. This
- * Implementation does not support adding. A subclass must implement the abstract
- * method entrySet().
+ * Implementation does not support adding. A subclass must implement the
+ * abstract method entrySet().
+ *
* @since 1.2
*/
public abstract class AbstractMap<K, V> implements Map<K, V> {
@@ -29,7 +30,7 @@
Set<K> keySet;
Collection<V> valuesCollection;
-
+
/**
* Constructs a new instance of this AbstractMap.
*/
@@ -131,7 +132,7 @@
return true;
}
if (object instanceof Map) {
- Map<?, ?> map = (Map) object;
+ Map<?, ?> map = (Map<?, ?>) object;
if (size() != map.size()) {
return false;
}
@@ -367,7 +368,7 @@
} else {
buffer.append("(this Map)"); //$NON-NLS-1$
}
- if(it.hasNext()) {
+ if (it.hasNext()) {
buffer.append(", "); //$NON-NLS-1$
}
}
@@ -411,7 +412,8 @@
@Override
public Iterator<V> iterator() {
return new Iterator<V>() {
- Iterator<Map.Entry<K, V>> setIterator = entrySet().iterator();
+ Iterator<Map.Entry<K, V>> setIterator = entrySet()
+ .iterator();
public boolean hasNext() {
return setIterator.hasNext();
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractSet.java?view=diff&rev=491834&r1=491833&r2=491834
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractSet.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractSet.java Tue Jan 2 08:22:05 2007
@@ -17,92 +17,93 @@
package java.util;
-
/**
* AbstractSet is an abstract implementation of the Set interface. This
- * Implementation does not support adding. A subclass must implement the abstract
- * methods iterator() and size().
+ * Implementation does not support adding. A subclass must implement the
+ * abstract methods iterator() and size().
+ *
* @since 1.2
*/
-public abstract class AbstractSet<E> extends AbstractCollection<E> implements Set<E> {
-
- /**
- * Constructs a new instance of this AbstractSet.
- */
- protected AbstractSet() {
- super();
- }
+public abstract class AbstractSet<E> extends AbstractCollection<E> implements
+ Set<E> {
+
+ /**
+ * Constructs a new instance of this AbstractSet.
+ */
+ protected AbstractSet() {
+ super();
+ }
- /**
- * Compares the specified object to this Set and answer if they are equal.
- * The object must be an instance of Set and contain the same objects.
- *
- * @param object
- * the object to compare with this object
- * @return true if the specified object is equal to this Set, false
- * otherwise
- *
- * @see #hashCode
- */
- @Override
+ /**
+ * Compares the specified object to this Set and answer if they are equal.
+ * The object must be an instance of Set and contain the same objects.
+ *
+ * @param object
+ * the object to compare with this object
+ * @return true if the specified object is equal to this Set, false
+ * otherwise
+ *
+ * @see #hashCode
+ */
+ @Override
public boolean equals(Object object) {
- if (this == object) {
+ if (this == object) {
return true;
}
- if (object instanceof Set) {
- Set<?> s = (Set) object;
- return size() == s.size() && containsAll(s);
- }
- return false;
- }
+ if (object instanceof Set) {
+ Set<?> s = (Set<?>) object;
+ return size() == s.size() && containsAll(s);
+ }
+ return false;
+ }
- /**
- * Answers an integer hash code for the receiver. Objects which are equal
- * answer the same value for this method.
- *
- * @return the receiver's hash
- *
- * @see #equals
- */
- @Override
+ /**
+ * Answers an integer hash code for the receiver. Objects which are equal
+ * answer the same value for this method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+ @Override
public int hashCode() {
- int result = 0;
- Iterator<?> it = iterator();
- while (it.hasNext()) {
- Object next = it.next();
- result += next == null ? 0 : next.hashCode();
- }
- return result;
- }
+ int result = 0;
+ Iterator<?> it = iterator();
+ while (it.hasNext()) {
+ Object next = it.next();
+ result += next == null ? 0 : next.hashCode();
+ }
+ return result;
+ }
- /**
- * Removes all occurrences in this Collection of each object in the
- * specified Collection.
- *
- * @param collection
- * the Collection of objects to remove
- * @return true if this Collection is modified, false otherwise
- *
- * @exception UnsupportedOperationException
- * when removing from this Collection is not supported
- */
- @Override
+ /**
+ * Removes all occurrences in this Collection of each object in the
+ * specified Collection.
+ *
+ * @param collection
+ * the Collection of objects to remove
+ * @return true if this Collection is modified, false otherwise
+ *
+ * @exception UnsupportedOperationException
+ * when removing from this Collection is not supported
+ */
+ @Override
public boolean removeAll(Collection<?> collection) {
- boolean result = false;
- if (size() <= collection.size()) {
- Iterator<?> it = iterator();
- while (it.hasNext()) {
- if (collection.contains(it.next())) {
- it.remove();
- result = true;
- }
- }
- } else {
- Iterator<?> it = collection.iterator();
- while (it.hasNext()) {
+ boolean result = false;
+ if (size() <= collection.size()) {
+ Iterator<?> it = iterator();
+ while (it.hasNext()) {
+ if (collection.contains(it.next())) {
+ it.remove();
+ result = true;
+ }
+ }
+ } else {
+ Iterator<?> it = collection.iterator();
+ while (it.hasNext()) {
result = remove(it.next()) || result;
}
- }
- return result;
- }
+ }
+ return result;
+ }
}