You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/05/31 10:42:25 UTC

svn commit: r410464 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java

Author: mloenko
Date: Wed May 31 01:42:24 2006
New Revision: 410464

URL: http://svn.apache.org/viewvc?rev=410464&view=rev
Log:
applied the second patch from HARMONY-342 (Java 5 Enhancement: new Java5 methods in java.util.Collections class)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java?rev=410464&r1=410463&r2=410464&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java Wed May 31 01:42:24 2006
@@ -2318,6 +2318,18 @@
     }
 
     /**
+     * Returns a dynamically typesafe view of the specified sorted set.
+     * 
+     * @param c the sorted set
+     * @param type the type of the elements is permitted to insert
+     * 
+     * @return a typesafe sorted set
+     */
+    public static SortedSet checkedSortedSet(SortedSet s, Class type) {
+        return new CheckedSortedSet(s, type);
+    }
+
+    /**
      * Adds all the specified elements to the specified collection
      * 
      * @param c the collection the elements are to be inserted into
@@ -3163,6 +3175,68 @@
 
         }
 
+    }
+
+    /**
+     * Class represents a dynamically typesafe view of the specified sortedSet.
+     */
+    private static class CheckedSortedSet extends CheckedSet implements
+            SortedSet {
+
+        private SortedSet ss;
+
+        /**
+         * Constructs a dynamically typesafe view of the specified sortedSet.
+         * 
+         * @param s - the sortedSet for which a dynamically typesafe view is to
+         *        be constructed.
+         */
+        public CheckedSortedSet(SortedSet s, Class type) {
+            super(s, type);
+            this.ss = s;
+        }
+
+        /**
+         * @see java.util.SortedSet#comparator()
+         */
+        public Comparator comparator() {
+            return ss.comparator();
+        }
+
+        /**
+         * @see java.util.SortedSet#subSet(Object, Object)
+         */
+        public SortedSet subSet(Object fromElement, Object toElement) {
+            return new CheckedSortedSet(ss.subSet(fromElement, toElement), type);
+        }
+
+        /**
+         * @see java.util.SortedSet#headSet(Object)
+         */
+        public SortedSet headSet(Object toElement) {
+            return new CheckedSortedSet(ss.headSet(toElement), type);
+        }
+
+        /**
+         * @see java.util.SortedSet#tailSet(Object)
+         */
+        public SortedSet tailSet(Object fromElement) {
+            return new CheckedSortedSet(ss.tailSet(fromElement), type);
+        }
+
+        /**
+         * @see java.util.SortedSet#first()
+         */
+        public Object first() {
+            return ss.first();
+        }
+
+        /**
+         * @see java.util.SortedSet#last()
+         */
+        public Object last() {
+            return ss.last();
+        }
     }
 
     /**