harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r440606 [3/3] - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/
Date Wed, 06 Sep 2006 04:01:23 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java?view=diff&rev=440606&r1=440605&r2=440606
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java
Tue Sep  5 21:01:21 2006
@@ -15,7 +15,6 @@
 
 package java.util;
 
-
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
@@ -28,20 +27,19 @@
  * order or a specified Comparator.
  * @since 1.2
  */
-
 public class TreeMap<K, V> extends AbstractMap<K, V> implements SortedMap<K,
V>, Cloneable,
 		Serializable {
 	private static final long serialVersionUID = 919286545866124006L;
 
-	transient int size = 0;
+	transient int size;
 
-	transient Entry<K, V> root;
+    transient Entry<K, V> root;
 
-	private Comparator<? super K> comparator;
+    private Comparator<? super K> comparator;
 
-	transient int modCount = 0;
+    transient int modCount;
 
-        transient Set<Map.Entry<K,V>> entrySet = null;
+    transient Set<Map.Entry<K, V>> entrySet;
 
 	/**
 	 * Entry is an internal class which is used to hold the entries of a
@@ -167,135 +165,136 @@
             }
         }
 
-        private static class ComparatorBoundedIterator <K, V> extends AbstractMapIterator<K,
V>  {
-            final private K endKey;
-            final private Comparator<? super K> cmp;
-     
-            ComparatorBoundedIterator(TreeMap<K, V> map,
-                                           Entry<K, V> startNode, K end) {
-                super(map, startNode);
-                endKey = end;
-                cmp = map.comparator();
-            }
-     
-            final void cleanNext() {
-                if (node != null && cmp.compare(endKey, node.key) <= 0) {
-                    node = null;
-                }
-            }
-            
-            @Override
-            public boolean hasNext() {
-                return (node != null) && (cmp.compare( node.key, endKey ) < 0);
-            }
-        }
+        private static class ComparatorBoundedIterator<K, V> extends AbstractMapIterator<K,
V> {
+            private final  K endKey;
 
-        private static class ComparatorBoundedEntryIterator <K, V> extends ComparatorBoundedIterator<K,
V> implements Iterator<Map.Entry<K, V>> {
+            private final Comparator<? super K> cmp;
 
-            ComparatorBoundedEntryIterator(TreeMap<K, V> map,
-                                           Entry<K, V> startNode, K end) {
-                super(map, startNode,end);
-            }
+        ComparatorBoundedIterator(TreeMap<K, V> map, Entry<K, V> startNode, K
end) {
+            super(map, startNode);
+            endKey = end;
+            cmp = map.comparator();
+        }
 
-            public Map.Entry<K, V> next() {
-                makeNext();
-                cleanNext();
-                return lastNode;
+        final void cleanNext() {
+            if (node != null && cmp.compare(endKey, node.key) <= 0) {
+                node = null;
             }
         }
 
-        private static class ComparatorBoundedKeyIterator <K, V> extends ComparatorBoundedIterator<K,
V> implements Iterator<K> {
+        @Override
+        public boolean hasNext() {
+            return (node != null) && (cmp.compare(node.key, endKey) < 0);
+        }
+    }
 
-            ComparatorBoundedKeyIterator(TreeMap<K, V> map,
-                                         Entry<K, V> startNode, K end) {
-                super(map, startNode,end);
-            }
+    private static class ComparatorBoundedEntryIterator<K, V> extends
+            ComparatorBoundedIterator<K, V> implements Iterator<Map.Entry<K,
V>> {
 
-            public K next() {
-                makeNext();
-                cleanNext();
-                return lastNode.key;
-            }
+        ComparatorBoundedEntryIterator(TreeMap<K, V> map, Entry<K, V> startNode,
K end) {
+            super(map, startNode, end);
         }
 
+        public Map.Entry<K, V> next() {
+            makeNext();
+            cleanNext();
+            return lastNode;
+        }
+    }
 
-        private static class ComparatorBoundedValueIterator <K, V> extends ComparatorBoundedIterator<K,
V> implements Iterator<V> {
+    private static class ComparatorBoundedKeyIterator<K, V> extends
+            ComparatorBoundedIterator<K, V> implements Iterator<K> {
 
-            ComparatorBoundedValueIterator(TreeMap<K, V> map,
-                                           Entry<K, V> startNode, K end) {
-                super(map, startNode,end);
-            }
+        ComparatorBoundedKeyIterator(TreeMap<K, V> map, Entry<K, V> startNode,
K end) {
+            super(map, startNode, end);
+        }
 
-            public V next() {
-                makeNext();
-                cleanNext();
-                return lastNode.value;
-            }
+        public K next() {
+            makeNext();
+            cleanNext();
+            return lastNode.key;
         }
+    }
 
-        private static class ComparableBoundedIterator <K, V> extends AbstractMapIterator<K,
V> {
-            final private Comparable endKey;
+    private static class ComparatorBoundedValueIterator<K, V> extends
+            ComparatorBoundedIterator<K, V> implements Iterator<V> {
 
-            public ComparableBoundedIterator(TreeMap<K, V> treeMap, Entry<K, V>
entry, Comparable endKey) {
-                super(treeMap, entry);
-                this.endKey = endKey;
-            }
+        ComparatorBoundedValueIterator(TreeMap<K, V> map, Entry<K, V> startNode,
K end) {
+            super(map, startNode, end);
+        }
 
-            final void cleanNext() {
-                if ((node != null) && (endKey.compareTo(node.key) <= 0)) {
-                    node = null;
-                }
-            }
-            
-            @Override
-            public boolean hasNext() {
-                return (node != null) && (endKey.compareTo(node.key) > 0);
-            }
+        public V next() {
+            makeNext();
+            cleanNext();
+            return lastNode.value;
         }
+    }
 
-        private static class ComparableBoundedEntryIterator <K, V> extends ComparableBoundedIterator<K,
V> implements Iterator<Map.Entry<K, V>> {
+    private static class ComparableBoundedIterator<K, V> extends AbstractMapIterator<K,
V> {
+        private final Comparable<K> endKey;
 
+        public ComparableBoundedIterator(TreeMap<K, V> treeMap, Entry<K, V> entry,
+                Comparable<K> endKey) {
+            super(treeMap, entry);
+            this.endKey = endKey;
+        }
 
-            ComparableBoundedEntryIterator(TreeMap<K, V> map,
-                                           Entry<K, V> startNode, Comparable end) {
-                super(map, startNode, end);
+        final void cleanNext() {
+            if ((node != null) && (endKey.compareTo(node.key) <= 0)) {
+                node = null;
             }
+        }
 
-            public Map.Entry<K, V> next() {
-                makeNext();
-                cleanNext();
-                return lastNode;
-            }
+        @Override
+        public boolean hasNext() {
+            return (node != null) && (endKey.compareTo(node.key) > 0);
+        }
+    }
 
+    private static class ComparableBoundedEntryIterator<K, V> extends
+            ComparableBoundedIterator<K, V> implements Iterator<Map.Entry<K,
V>> {
+
+        ComparableBoundedEntryIterator(TreeMap<K, V> map, Entry<K, V> startNode,
+                Comparable<K> end) {
+            super(map, startNode, end);
         }
 
-        private static class ComparableBoundedKeyIterator <K, V> extends ComparableBoundedIterator<K,
V> implements Iterator<K> {
+        public Map.Entry<K, V> next() {
+            makeNext();
+            cleanNext();
+            return lastNode;
+        }
 
-            ComparableBoundedKeyIterator(TreeMap<K, V> map,
-                                         Entry<K, V> startNode, Comparable end) {
-                super(map, startNode,end);
-            }
+    }
 
-            public K next() {
-                makeNext();
-                cleanNext();
-                return lastNode.key;
-            }
+    private static class ComparableBoundedKeyIterator<K, V> extends
+            ComparableBoundedIterator<K, V> implements Iterator<K> {
+
+        ComparableBoundedKeyIterator(TreeMap<K, V> map, Entry<K, V> startNode,
Comparable<K> end) {
+            super(map, startNode, end);
         }
 
-        private static class ComparableBoundedValueIterator <K, V> extends ComparableBoundedIterator<K,
V> implements Iterator<V> {
+        public K next() {
+            makeNext();
+            cleanNext();
+            return lastNode.key;
+        }
+    }
 
-            ComparableBoundedValueIterator(TreeMap<K, V> map,
-                                           Entry<K, V> startNode, Comparable end) {
-                super(map, startNode,end);
-            }
+    private static class ComparableBoundedValueIterator<K, V> extends
+            ComparableBoundedIterator<K, V> implements Iterator<V> {
 
-            public V next() {
-                makeNext();
-                cleanNext();
-                return lastNode.value;
-            }
+        ComparableBoundedValueIterator(TreeMap<K, V> map, Entry<K, V> startNode,
+                Comparable<K> end) {
+            super(map, startNode, end);
+        }
+
+        public V next() {
+            makeNext();
+            cleanNext();
+            return lastNode.value;
         }
+    }
 
         static final class SubMap<K,V> extends AbstractMap<K,V> implements SortedMap<K,V>,
Serializable {
             private static final long serialVersionUID = -6520786458950516097L;
@@ -328,19 +327,23 @@
             }
 
             private void checkRange(K key) {
-                Comparator cmp = backingMap.comparator;
+                Comparator<? super K> cmp = backingMap.comparator;
                 if (cmp == null) {
-                    Comparable<K> object = (Comparable<K>) key;
-                    if (hasStart && object.compareTo(startKey) < 0)
+                    Comparable<K> object = toComparable(key);
+                    if (hasStart && object.compareTo(startKey) < 0) {
                         throw new IllegalArgumentException();
-                    if (hasEnd && object.compareTo(endKey) >= 0)
+                    }
+                    if (hasEnd && object.compareTo(endKey) >= 0) {
                         throw new IllegalArgumentException();
+                    }
                 } else {
                     if (hasStart
-                            && backingMap.comparator().compare(key, startKey) <
0)
+                            && backingMap.comparator().compare(key, startKey) <
0) {
                         throw new IllegalArgumentException();
-                    if (hasEnd && backingMap.comparator().compare(key, endKey) >=
0)
+                    }
+                    if (hasEnd && backingMap.comparator().compare(key, endKey) >=
0) {
                         throw new IllegalArgumentException();
+                    }
                 }
             }
 
@@ -348,15 +351,19 @@
                 Comparator<? super K> cmp = backingMap.comparator;
                 if (cmp == null) {
                     Comparable<K> object = toComparable(key);
-                    if (hasStart && object.compareTo(startKey) < 0)
+                    if (hasStart && object.compareTo(startKey) < 0) {
                         return false;
-                    if (hasEnd && object.compareTo(endKey) >= 0)
+                    }
+                    if (hasEnd && object.compareTo(endKey) >= 0) {
                         return false;
+                    }
                 } else {
-                    if (hasStart && cmp.compare(key, startKey) < 0)
+                    if (hasStart && cmp.compare(key, startKey) < 0) {
+                        return false;
+                    }
+                    if (hasEnd && cmp.compare(key, endKey) >= 0) {
                         return false;
-                    if (hasEnd && cmp.compare(key, endKey) >= 0)
-                       return false;
+                    }
                 }
                 return true;
             }
@@ -365,38 +372,38 @@
                 if (hasEnd) {
                     Comparator<? super K> cmp = backingMap.comparator;
                     if (cmp == null) {
-                        return (((Comparable<K>) key).compareTo(endKey) < 0);
-                    } else {
-                        return (cmp.compare(key, endKey) < 0);
+                        return (toComparable(key).compareTo(endKey) < 0);
                     }
-                } else {
-                    return true;
+                    return (cmp.compare(key, endKey) < 0);
                 }
+                return true;
             }
 
             private boolean checkLowerBound(K key) {
                 if (hasStart) {
                     Comparator<? super K> cmp = backingMap.comparator;
                     if (cmp == null) {
-                        return (((Comparable<K>) key).compareTo(endKey) >= 0);
-                    } else {
-                        return (cmp.compare(key, endKey) >= 0);
+                        return (toComparable(key).compareTo(endKey) >= 0);
                     }
-                } else {
-                    return true;
+                    return (cmp.compare(key, endKey) >= 0);
                 }
+                return true;
             }
 
             public Comparator<? super K> comparator() {
                 return backingMap.comparator();
             }
 
+            @SuppressWarnings("unchecked")
+            @Override
             public boolean containsKey(Object key) {
-                if (isInRange((K)key))
+                if (isInRange((K)key)) {
                     return backingMap.containsKey(key);
+                }
                 return false;
             }
 
+            @Override
             public Set<Map.Entry<K,V>> entrySet() {
                 if(entrySet==null) {
                     entrySet = new SubMapEntrySet<K,V>(this);
@@ -420,24 +427,28 @@
                 TreeMap.Entry<K,V> node = backingMap.findAfter(startKey);
                 if (node != null && checkUpperBound(node.key)) {
                     return node;
-                } else {
-                    return null;
                 }
+                return null;
             }
 
+            @SuppressWarnings("unchecked")
+            @Override
             public V get(Object key) {
-                if (isInRange((K)key))
+                if (isInRange((K)key)) {
                     return backingMap.get(key);
+                }
                 return null;
             }
 
             public SortedMap<K,V> headMap(K endKey) {
                 checkRange(endKey);
-                if (hasStart)
+                if (hasStart) {
                     return new SubMap<K,V>(startKey, backingMap, endKey);
+                }
                 return new SubMap<K,V>(backingMap, endKey);
             }
 
+            @Override
             public boolean isEmpty() {
                 if (hasStart) {
                     TreeMap.Entry<K,V> node = backingMap.findAfter(startKey);
@@ -446,6 +457,7 @@
                 return backingMap.findBefore(endKey) == null;
             }
 
+            @Override
             public Set<K> keySet() {
                 if (keySet == null) {
                     keySet = new SubMapKeySet<K,V>(this);
@@ -454,47 +466,58 @@
             }
 
             public K lastKey() {
-                if (!hasEnd)
+                if (!hasEnd) {
                     return backingMap.lastKey();
+                }
                 TreeMap.Entry<K,V> node = backingMap.findBefore(endKey);
-                if (node != null && checkLowerBound(node.key))
+                if (node != null && checkLowerBound(node.key)) {
                     return node.key;
+                }
                 throw new NoSuchElementException();
             }
 
+            @Override
             public V put(K key, V value) {
-                if (isInRange(key))
+                if (isInRange(key)) {
                     return backingMap.put(key, value);
+                }
                 throw new IllegalArgumentException();
             }
 
+            @SuppressWarnings("unchecked")
+            @Override
             public V remove(Object key) {
-                if (isInRange((K)key))
+                if (isInRange((K)key)) {
                     return backingMap.remove(key);
+                }
                 return null;
             }
 
             public SortedMap<K,V> subMap(K startKey, K endKey) {
                 checkRange(startKey);
                 checkRange(endKey);
-                Comparator c = backingMap.comparator();
+                Comparator<? super K> c = backingMap.comparator();
                 if (c == null) {
-                    if (((Comparable) startKey).compareTo(endKey) <= 0)
+                    if (toComparable(startKey).compareTo(endKey) <= 0) {
                         return new SubMap<K,V>(startKey, backingMap, endKey);
+                    }
                 } else {
-                    if (c.compare(startKey, endKey) <= 0)
+                    if (c.compare(startKey, endKey) <= 0) {
                         return new SubMap<K,V>(startKey, backingMap, endKey);
+                    }
                 }
                 throw new IllegalArgumentException();
             }
 
             public SortedMap<K,V> tailMap(K startKey) {
                 checkRange(startKey);
-                if (hasEnd)
+                if (hasEnd) {
                     return new SubMap<K,V>(startKey, backingMap, endKey);
+                }
                 return new SubMap<K,V>(startKey, backingMap);
             }
 
+            @Override
             public Collection<V> values() {
                 if(valuesCollection==null) {
                     valuesCollection = new SubMapValuesCollection<K,V>(this);
@@ -510,24 +533,25 @@
                 subMap = map;
             }
 
+            @Override
             public boolean isEmpty() {
                 return subMap.isEmpty();
             }
 
+            @Override
             public Iterator<Map.Entry<K,V>> iterator() {
                 TreeMap.Entry<K,V> startNode = subMap.firstEntry();
                 if (subMap.hasEnd) {
                     Comparator<? super K> cmp = subMap.comparator();
                     if (cmp == null) {
-                        return new ComparableBoundedEntryIterator<K,V>(subMap.backingMap,
startNode, (Comparable<K>) subMap.endKey);
-                    } else {
-                        return new ComparatorBoundedEntryIterator<K,V>(subMap.backingMap,
startNode, subMap.endKey);
+                        return new ComparableBoundedEntryIterator<K,V>(subMap.backingMap,
startNode, toComparable(subMap.endKey));
                     }
-                } else {
-                    return new UnboundedEntryIterator<K,V>(subMap.backingMap, startNode);
+                    return new ComparatorBoundedEntryIterator<K,V>(subMap.backingMap,
startNode, subMap.endKey);
                 }
+                return new UnboundedEntryIterator<K,V>(subMap.backingMap, startNode);
             }
 
+            @Override
             public int size() {
                 int size = 0;
                 Iterator<Map.Entry<K,V>> it = iterator();
@@ -538,6 +562,8 @@
                 return size;
             }
 
+            @SuppressWarnings("unchecked")
+            @Override
             public boolean contains(Object object) {
                 if (object instanceof Map.Entry) {
                     Map.Entry<K,V> entry = (Map.Entry<K,V>) object;
@@ -559,14 +585,17 @@
                 subMap = map;
             }
 
+            @Override
             public boolean contains(Object object) {
                 return subMap.containsKey(object);
             }
 
+            @Override
             public boolean isEmpty() {
                 return subMap.isEmpty();
             }
 
+            @Override
             public int size() {
                 int size = 0;
                 Iterator<K> it = iterator();
@@ -577,18 +606,17 @@
                 return size;
             }
 
+            @Override
             public Iterator<K> iterator() {
                 TreeMap.Entry<K,V> startNode = subMap.firstEntry();
                 if (subMap.hasEnd) {
                     Comparator<? super K> cmp = subMap.comparator();
                     if (cmp == null) {
-                        return new ComparableBoundedKeyIterator<K,V>(subMap.backingMap,
startNode, (Comparable<K>) subMap.endKey);
-                    } else {
-                        return new ComparatorBoundedKeyIterator<K,V>(subMap.backingMap,
startNode, subMap.endKey);
+                        return new ComparableBoundedKeyIterator<K,V>(subMap.backingMap,
startNode, toComparable(subMap.endKey));
                     }
-                } else {
-                    return new UnboundedKeyIterator<K,V>(subMap.backingMap, startNode);
+                    return new ComparatorBoundedKeyIterator<K,V>(subMap.backingMap,
startNode, subMap.endKey);
                 }
+                return new UnboundedKeyIterator<K,V>(subMap.backingMap, startNode);
             }
         }
 
@@ -599,24 +627,25 @@
                 this.subMap = subMap;
             }
 
+            @Override
             public boolean isEmpty() {
                 return subMap.isEmpty();
             }
 
+            @Override
             public Iterator<V> iterator() {
                 TreeMap.Entry<K,V> startNode = subMap.firstEntry();
                 if (subMap.hasEnd) {
                     Comparator<? super K> cmp = subMap.comparator();
                     if (cmp == null) {
-                        return new ComparableBoundedValueIterator<K,V>(subMap.backingMap,
startNode, (Comparable<K>) subMap.endKey);
-                    } else {
-                        return new ComparatorBoundedValueIterator<K,V>(subMap.backingMap,
startNode, subMap.endKey);
+                        return new ComparableBoundedValueIterator<K,V>(subMap.backingMap,
startNode, toComparable(subMap.endKey));
                     }
-                } else {
-                    return new UnboundedValueIterator<K,V>(subMap.backingMap, startNode);
+                    return new ComparatorBoundedValueIterator<K,V>(subMap.backingMap,
startNode, subMap.endKey);
                 }
+                return new UnboundedValueIterator<K,V>(subMap.backingMap, startNode);
             }
 
+            @Override
             public int size() {
                 int cnt = 0;
                 for (Iterator<V> it = iterator(); it.hasNext();) {
@@ -848,6 +877,7 @@
                     TreeMap.this.clear();
                 }
 
+                @SuppressWarnings("unchecked")
                 @Override
                 public boolean contains(Object object) {
                     if (object instanceof Map.Entry) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeSet.java?view=diff&rev=440606&r1=440605&r2=440606
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeSet.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeSet.java
Tue Sep  5 21:01:21 2006
@@ -31,13 +31,13 @@
 public class TreeSet<E> extends AbstractSet<E> implements SortedSet<E>,
Cloneable,
 		Serializable {
 	
-	private static final long serialVersionUID = -2479143000061671589L;
+    private static final long serialVersionUID = -2479143000061671589L;
 
-	private transient SortedMap<E, E> backingMap;
+    private transient SortedMap<E, E> backingMap;
 
-        private TreeSet(SortedMap<E,E> map) {
-            this.backingMap = map;
-        }
+    private TreeSet(SortedMap<E,E> map) {
+        this.backingMap = map;
+    }
 
 	/**
 	 * Constructs a new empty instance of TreeSet which uses natural ordering.
@@ -83,11 +83,11 @@
 	 *            the SortedSet of elements to add
 	 */
 	public TreeSet(SortedSet<E> set) {
-		this(set.comparator());
-		Iterator<E> it = set.iterator();
-                while (it.hasNext()) {
-                    add(it.next());
-                }
+	    this(set.comparator());
+	    Iterator<E> it = set.iterator();
+	    while (it.hasNext()) {
+	        add(it.next());
+	    }
 	}
 
 	/**
@@ -105,7 +105,8 @@
 	 *                when the object is null and the comparator cannot handle
 	 *                null
 	 */
-	public boolean add(E object) {
+	@Override
+    public boolean add(E object) {
 		return backingMap.put(object, object) == null;
 	}
 
@@ -123,7 +124,8 @@
 	 *                when an object in the Collection is null and the
 	 *                comparator cannot handle null
 	 */
-	public boolean addAll(Collection<? extends E> collection) {
+	@Override
+    public boolean addAll(Collection<? extends E> collection) {
 		return super.addAll(collection);
 	}
 
@@ -133,7 +135,8 @@
 	 * @see #isEmpty
 	 * @see #size
 	 */
-	public void clear() {
+	@Override
+    public void clear() {
 		backingMap.clear();
 	}
 
@@ -145,25 +148,27 @@
 	 * 
 	 * @see java.lang.Cloneable
 	 */
-	public Object clone() {
-		try {
-			TreeSet<E> clone = (TreeSet<E>) super.clone();
-                        if (backingMap instanceof TreeMap) {
-                            clone.backingMap = (SortedMap<E,E>) ((TreeMap<E,E>)
backingMap).clone();
-                        } else {
-                            clone.backingMap = new TreeMap<E,E>(backingMap);
-                        }
-			return clone;
-		} catch (CloneNotSupportedException e) {
-			return null;
-		}
-	}
+	@SuppressWarnings("unchecked")
+    @Override
+    public Object clone() {
+        try {
+            TreeSet<E> clone = (TreeSet<E>) super.clone();
+            if (backingMap instanceof TreeMap) {
+                clone.backingMap = (SortedMap<E, E>) ((TreeMap<E, E>) backingMap).clone();
+            } else {
+                clone.backingMap = new TreeMap<E, E>(backingMap);
+            }
+            return clone;
+        } catch (CloneNotSupportedException e) {
+            return null;
+        }
+    }
 
 	/**
-	 * Answers the Comparator used to compare elements in this TreeSet.
-	 * 
-	 * @return a Comparator or null if the natural ordering is used
-	 */
+     * Answers the Comparator used to compare elements in this TreeSet.
+     * 
+     * @return a Comparator or null if the natural ordering is used
+     */
 	public Comparator<? super E> comparator() {
 		return backingMap.comparator();
 	}
@@ -183,7 +188,8 @@
 	 *                when the object is null and the comparator cannot handle
 	 *                null
 	 */
-	public boolean contains(Object object) {
+	@Override
+    public boolean contains(Object object) {
 		return backingMap.containsKey(object);
 	}
 
@@ -215,14 +221,16 @@
 	 *                when the end object is null and the comparator cannot
 	 *                handle null
 	 */
-	public SortedSet<E> headSet(E end) {
-		// Check for errors
-		Comparator<? super E> c = backingMap.comparator();
-		if (c == null)
-			((Comparable<E>) end).compareTo(end);
-		else
-			c.compare(end, end);
-                return new TreeSet<E>(backingMap.headMap(end));
+	@SuppressWarnings("unchecked")
+    public SortedSet<E> headSet(E end) {
+	    // Check for errors
+	    Comparator<? super E> c = backingMap.comparator();
+	    if (c == null) {
+	        ((Comparable<E>) end).compareTo(end);
+	    } else {
+	        c.compare(end, end);
+	    }
+	    return new TreeSet<E>(backingMap.headMap(end));
 	}
 
 	/**
@@ -232,7 +240,8 @@
 	 * 
 	 * @see #size
 	 */
-	public boolean isEmpty() {
+	@Override
+    public boolean isEmpty() {
 		return backingMap.isEmpty();
 	}
 
@@ -243,7 +252,8 @@
 	 * 
 	 * @see Iterator
 	 */
-	public Iterator<E> iterator() {
+	@Override
+    public Iterator<E> iterator() {
 		return backingMap.keySet().iterator();
 	}
 
@@ -273,7 +283,8 @@
 	 *                when the object is null and the comparator cannot handle
 	 *                null
 	 */
-	public boolean remove(Object object) {
+	@Override
+    public boolean remove(Object object) {
 		return backingMap.remove(object) != null;
 	}
 
@@ -282,7 +293,8 @@
 	 * 
 	 * @return the number of elements in this TreeSet
 	 */
-	public int size() {
+	@Override
+    public int size() {
 		return backingMap.size();
 	}
 
@@ -306,17 +318,20 @@
 	 *                when the start or end object is null and the comparator
 	 *                cannot handle null
 	 */
-	public SortedSet<E> subSet(E start, E end) {
-		Comparator<? super E> c = backingMap.comparator();
-		if (c == null) {
-			if (((Comparable<E>) start).compareTo(end) <= 0)
-                                return new TreeSet<E>(backingMap.subMap(start, end));
-		} else {
-			if (c.compare(start, end) <= 0)
-                                return new TreeSet<E>(backingMap.subMap(start, end));
-		}
-		throw new IllegalArgumentException();
-	}
+	@SuppressWarnings("unchecked")
+    public SortedSet<E> subSet(E start, E end) {
+        Comparator<? super E> c = backingMap.comparator();
+        if (c == null) {
+            if (((Comparable<E>) start).compareTo(end) <= 0) {
+                return new TreeSet<E>(backingMap.subMap(start, end));
+            }
+        } else {
+            if (c.compare(start, end) <= 0) {
+                return new TreeSet<E>(backingMap.subMap(start, end));
+            }
+        }
+        throw new IllegalArgumentException();
+    }
 
 	/**
 	 * Answers a SortedSet of the specified portion of this TreeSet which
@@ -336,49 +351,52 @@
 	 *                when the start object is null and the comparator cannot
 	 *                handle null
 	 */
-	public SortedSet<E> tailSet(E start) {
+	@SuppressWarnings("unchecked")
+    public SortedSet<E> tailSet(E start) {
 		// Check for errors
 		Comparator<? super E> c = backingMap.comparator();
-		if (c == null)
-			((Comparable<E>) start).compareTo(start);
-		else
-			c.compare(start, start);
-                return new TreeSet<E>(backingMap.tailMap(start));
+		if (c == null) {
+            ((Comparable<E>) start).compareTo(start);
+        } else {
+            c.compare(start, start);
+        }
+		return new TreeSet<E>(backingMap.tailMap(start));
 	}
 
 	private void writeObject(ObjectOutputStream stream) throws IOException {
-		stream.defaultWriteObject();
-		stream.writeObject(backingMap.comparator());
-                int size = backingMap.size();
-                stream.writeInt(size);
-                if (size > 0) {
-                    Iterator<E> it = backingMap.keySet().iterator();
-                    while (it.hasNext()) {
-                        stream.writeObject(it.next());
-                    }
-		}
+	    stream.defaultWriteObject();
+	    stream.writeObject(backingMap.comparator());
+	    int size = backingMap.size();
+	    stream.writeInt(size);
+	    if (size > 0) {
+	        Iterator<E> it = backingMap.keySet().iterator();
+	        while (it.hasNext()) {
+	            stream.writeObject(it.next());
+	        }
+	    }
 	}
 
+	@SuppressWarnings("unchecked")
 	private void readObject(ObjectInputStream stream) throws IOException,
-			ClassNotFoundException {
-		stream.defaultReadObject();
-                TreeMap<E, E> map = new TreeMap<E, E>((Comparator<? super
E>) stream.readObject());
-                int size = stream.readInt();
-                if (size > 0) {
-                    E key = (E)stream.readObject();
-                    TreeMap.Entry<E,E> last = new TreeMap.Entry<E,E>(key,key);
-                    map.root = last;
-                    map.size = 1;
-                    for (int i=1; i<size; i++) {
-                        key = (E)stream.readObject();
-                        TreeMap.Entry<E,E> x = new TreeMap.Entry<E,E>(key,key);
-                        x.parent = last;
-                        last.right = x;
-                        map.size++;
-                        map.balance(x);
-                        last = x;
-                    }
-                }
-                backingMap = map;
+	ClassNotFoundException {
+	    stream.defaultReadObject();
+	    TreeMap<E, E> map = new TreeMap<E, E>((Comparator<? super E>) stream.readObject());
+	    int size = stream.readInt();
+	    if (size > 0) {
+	        E key = (E)stream.readObject();
+	        TreeMap.Entry<E,E> last = new TreeMap.Entry<E,E>(key,key);
+	        map.root = last;
+	        map.size = 1;
+	        for (int i=1; i<size; i++) {
+	            key = (E)stream.readObject();
+	            TreeMap.Entry<E,E> x = new TreeMap.Entry<E,E>(key,key);
+	            x.parent = last;
+	            last.right = x;
+	            map.size++;
+	            map.balance(x);
+	            last = x;
+	        }
+	    }
+	    backingMap = map;
 	}
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UUID.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UUID.java?view=diff&rev=440606&r1=440605&r2=440606
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UUID.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UUID.java
Tue Sep  5 21:01:21 2006
@@ -97,8 +97,9 @@
         // setup version field
         version = (int) ((mostSigBits & 0x000000000000F000) >>> 12);
 
-        if (variant != 2 && version != 1)
+        if (variant != 2 && version != 1) {
             return;
+        }
 
         // setup timestamp field
         long timeLow = (mostSigBits & 0xFFFFFFFF00000000L) >>> 32;
@@ -162,8 +163,9 @@
      * @return A UUID instance.
      */
     public static UUID nameUUIDFromBytes(byte[] name) {
-        if (name == null)
+        if (name == null) {
             throw new NullPointerException();
+        }
 
         byte[] hash;
         try {
@@ -207,26 +209,32 @@
      *         correctly.
      */
     public static UUID fromString(String uuid) {
-        if (uuid == null)
+        if (uuid == null) {
             throw new NullPointerException();
-        if (uuid.length() != 36)
+        }
+        if (uuid.length() != 36) {
             throw new IllegalArgumentException(
                     "The UUID String must be 36 chars long.");
+        }
 
         try {
             long m1 = Long.parseLong(uuid.substring(0, 8), 16);
-            if (uuid.charAt(8) != '-')
+            if (uuid.charAt(8) != '-') {
                 throw new IllegalArgumentException();
+            }
             long m2 = Long.parseLong(uuid.substring(9, 13), 16);
-            if (uuid.charAt(13) != '-')
+            if (uuid.charAt(13) != '-') {
                 throw new IllegalArgumentException();
+            }
             long m3 = Long.parseLong(uuid.substring(14, 18), 16);
-            if (uuid.charAt(18) != '-')
+            if (uuid.charAt(18) != '-') {
                 throw new IllegalArgumentException();
+            }
 
             long lsb1 = Long.parseLong(uuid.substring(19, 23), 16);
-            if (uuid.charAt(23) != '-')
+            if (uuid.charAt(23) != '-') {
                 throw new IllegalArgumentException();
+            }
             long lsb2 = Long.parseLong(uuid.substring(24), 16);
 
             long msb = (m1 << 32) | (m2 << 16) | m3;
@@ -309,8 +317,9 @@
      * @throws UnsupportedOperationException if {@link #version()} is not 1.
      */
     public long timestamp() {
-        if (version != 1)
+        if (version != 1) {
             throw new UnsupportedOperationException();
+        }
         return timestamp;
     }
 
@@ -324,8 +333,9 @@
      * @throws UnsupportedOperationException if {@link #version()} is not 1.
      */
     public int clockSequence() {
-        if (version != 1)
+        if (version != 1) {
             throw new UnsupportedOperationException();
+        }
         return clockSequence;
     }
 
@@ -339,15 +349,16 @@
      * @throws UnsupportedOperationException if {@link #version()} is not 1.
      */
     public long node() {
-        if (version != 1)
+        if (version != 1) {
             throw new UnsupportedOperationException();
+        }
         return node;
     }
 
     /**
      * <p>
-     * Compares this UUID to the specificed UUID. The natural ordering of UUIDs
-     * is based upon the value of the bits from most significant ot least
+     * Compares this UUID to the specified UUID. The natural ordering of UUIDs
+     * is based upon the value of the bits from most significant to least
      * significant.
      * </p>
      * 
@@ -356,8 +367,9 @@
      *         greater than <code>uuid</code>.
      */
     public int compareTo(UUID uuid) {
-        if (uuid == this)
+        if (uuid == this) {
             return 0;
+        }
 
         if (this.mostSigBits != uuid.mostSigBits) {
             return this.mostSigBits < uuid.mostSigBits ? -1 : 1;
@@ -385,15 +397,19 @@
      * @return A <code>true</code> if this UUID is equal to
      *         <code>object</code> or <code>false</code> if not.
      */
+    @Override
     public boolean equals(Object object) {
-        if (object == null)
+        if (object == null) {
             return false;
+        }
 
-        if (this == object)
+        if (this == object) {
             return true;
+        }
 
-        if (!(object instanceof UUID))
+        if (!(object instanceof UUID)) {
             return false;
+        }
 
         UUID that = (UUID) object;
 
@@ -409,6 +425,7 @@
      * 
      * @return An int value.
      */
+    @Override
     public int hashCode() {
         return hash;
     }
@@ -439,6 +456,7 @@
      * 
      * @return A String instance.
      */
+    @Override
     public String toString() {
         StringBuilder builder = new StringBuilder(36);
         String msbStr = Long.toHexString(mostSigBits);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UnknownFormatConversionException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UnknownFormatConversionException.java?view=diff&rev=440606&r1=440605&r2=440606
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UnknownFormatConversionException.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UnknownFormatConversionException.java
Tue Sep  5 21:01:21 2006
@@ -14,6 +14,8 @@
  */
 package java.util;
 
+import org.apache.harmony.luni.util.Msg;
+
 /**
  * The unchecked exception will be thrown out if the format conversion is
  * unknown.
@@ -50,7 +52,8 @@
 	 * 
 	 * @return The message of the exception.
 	 */
-	public String getMessage() {
-        return org.apache.harmony.luni.util.Msg.getString("K0349", s);
+	@Override
+    public String getMessage() {
+        return Msg.getString("K0349", s);
     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UnknownFormatFlagsException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UnknownFormatFlagsException.java?view=diff&rev=440606&r1=440605&r2=440606
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UnknownFormatFlagsException.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/UnknownFormatFlagsException.java
Tue Sep  5 21:01:21 2006
@@ -15,6 +15,8 @@
 
 package java.util;
 
+import org.apache.harmony.luni.util.Msg;
+
 /**
  * The unchecked exception will be thrown out if there is an unknown flag.
  * 
@@ -41,7 +43,7 @@
 	/**
 	 * Returns the flags associated with the exception.
 	 * 
-	 * @return The flags associated with the excepiton.
+	 * @return The flags associated with the exception.
 	 */
 	public String getFlags() {
 		return flags;
@@ -52,7 +54,8 @@
 	 * 
 	 * @return The message associated with the exception.
 	 */
-	public String getMessage() {
-        return org.apache.harmony.luni.util.Msg.getString("K034a", flags);
+	@Override
+    public String getMessage() {
+        return Msg.getString("K034a", flags);
     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Vector.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Vector.java?view=diff&rev=440606&r1=440605&r2=440606
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Vector.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Vector.java
Tue Sep  5 21:01:21 2006
@@ -191,9 +191,8 @@
 			elementCount += size;
 			modCount++;
 			return true;
-		} else {
-            throw new ArrayIndexOutOfBoundsException(location);
-        }
+		}
+        throw new ArrayIndexOutOfBoundsException(location);
 	}
 
 	/**
@@ -686,9 +685,8 @@
                 }
 			}
 			return -1;
-		} else {
-            throw new ArrayIndexOutOfBoundsException(location);
-        }
+		}
+        throw new ArrayIndexOutOfBoundsException(location);
 	}
 
 	/*
@@ -709,9 +707,8 @@
 			elementData[elementCount] = null;
 			modCount++;
 			return result;
-		} else {
-            throw new ArrayIndexOutOfBoundsException(location);
-        }
+		}
+        throw new ArrayIndexOutOfBoundsException(location);
 	}
 
 	/**
@@ -876,9 +873,8 @@
 			E result = elementData[location];
 			elementData[location] = object;
 			return result;
-		} else {
-            throw new ArrayIndexOutOfBoundsException(location);
-        }
+		}
+        throw new ArrayIndexOutOfBoundsException(location);
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/WeakHashMap.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/WeakHashMap.java?view=diff&rev=440606&r1=440605&r2=440606
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/WeakHashMap.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/WeakHashMap.java
Tue Sep  5 21:01:21 2006
@@ -29,6 +29,8 @@
  */
 public class WeakHashMap<K, V> extends AbstractMap<K, V> implements Map<K,
V> {
 
+    private static final int DEFAULT_SIZE = 16;
+    
     private final ReferenceQueue<K> referenceQueue;
 
     int elementCount;
@@ -40,8 +42,6 @@
     private int threshold;
 
     transient int modCount;
-
-    private static final int DEFAULT_SIZE = 16;
     
     //Simple utility method to isolate unchecked cast for array creation
     @SuppressWarnings("unchecked")
@@ -155,12 +155,10 @@
                     // free the key
                     nextKey = null;
                     return result;
-                } else {
-                    throw new NoSuchElementException();
                 }
-            } else {
-                throw new ConcurrentModificationException();
+                throw new NoSuchElementException();
             }
+            throw new ConcurrentModificationException();
         }
 
         public void remove() {



Mime
View raw message