sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1397415 - in /sis/branches/JDK6: ./ sis-utility/src/main/java/org/apache/sis/util/collection/ sis-utility/src/main/java/org/apache/sis/util/resources/ sis-utility/src/main/java/org/apache/sis/util/type/ sis-utility/src/test/java/org/apache...
Date Fri, 12 Oct 2012 01:50:37 GMT
Author: desruisseaux
Date: Fri Oct 12 01:50:36 2012
New Revision: 1397415

URL: http://svn.apache.org/viewvc?rev=1397415&view=rev
Log:
Merge from the JDK7 branch.

Modified:
    sis/branches/JDK6/   (props changed)
    sis/branches/JDK6/pom.xml
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/type/Types.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
    sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java

Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK7:r1397091-1397414

Modified: sis/branches/JDK6/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/pom.xml?rev=1397415&r1=1397414&r2=1397415&view=diff
==============================================================================
--- sis/branches/JDK6/pom.xml (original)
+++ sis/branches/JDK6/pom.xml Fri Oct 12 01:50:36 2012
@@ -412,6 +412,11 @@ Apache SIS is a toolkit for describing l
     <pluginManagement>
       <plugins>
         <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>build-helper-maven-plugin</artifactId>
+          <version>1.7</version>
+        </plugin>
+        <plugin>
           <groupId>org.mortbay.jetty</groupId>
           <artifactId>jetty-maven-plugin</artifactId>
           <version>8.0.0.M2</version>

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java?rev=1397415&r1=1397414&r2=1397415&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
(original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
Fri Oct 12 01:50:36 2012
@@ -177,13 +177,6 @@ public class Cache<K,V> extends Abstract
     private final boolean soft;
 
     /**
-     * {@code true} if different values may be assigned to the same key. This is usually
-     * an error, so the default {@code Cache} behavior is to thrown an exception in such
-     * case.
-     */
-    private volatile boolean keyCollisionAllowed;
-
-    /**
      * A view over the entries in the cache.
      */
     private transient Set<Entry<K,V>> entries;
@@ -523,18 +516,6 @@ public class Cache<K,V> extends Abstract
             @SuppressWarnings("unchecked")
             final Work work = (Work) value;
             if (work.isHeldByCurrentThread()) {
-                if (isKeyCollisionAllowed()) {
-                    /*
-                     * Example of key collision: the EPSG database defines the CoordinateOperation
-                     * 8653 ("ED50 to WGS84" using polynomial equations).  The EPSG factory
sets a
-                     * lock for this code, then searches for OperationParameters associated
to this
-                     * operation. One of those parameters ("Bu0v4") has the same key (EPSG:8653).
-                     * So we get a key collision. If we ignore the second occurrence, its
value will
-                     * not be cached. This is okay since the value that we really want to
cache is
-                     * CoordinateOperation, which is associated to the first occurrence of
that key.
-                     */
-                    return new Simple<V>(null);
-                }
                 throw new IllegalStateException(Errors.format(Errors.Keys.RecursiveCreateCallForKey_1,
key));
             }
             return work.new Wait();
@@ -629,8 +610,6 @@ public class Cache<K,V> extends Abstract
 
         /**
          * Do nothing (except checking for programming error), since we don't hold any lock.
-         * We do not localize the exception message since it is targeted to the developer
-         * rather than the end user.
          *
          * {@note An alternative would have been to store the result in the map anyway.
          *        But doing so is unsafe because we have no lock; we have no guarantee that
@@ -638,8 +617,8 @@ public class Cache<K,V> extends Abstract
          */
         @Override
         public void putAndUnlock(final V result) throws IllegalStateException {
-            if (result != value && !isKeyCollisionAllowed()) {
-                throw new IllegalStateException("Key collision: the cache already has a value.");
+            if (result != value) {
+                throw new IllegalStateException(Errors.format(Errors.Keys.KeyCollision_1,
"<unknown>"));
             }
         }
     }
@@ -653,7 +632,7 @@ public class Cache<K,V> extends Abstract
         /**
          * The key to use for storing the result in the map.
          */
-        private final K key;
+        final K key;
 
         /**
          * The result. This is initially null, as we expect since the value has not yet
@@ -737,8 +716,6 @@ public class Cache<K,V> extends Abstract
 
             /**
              * Do nothing (except checking for programming error), since we don't hold any
lock.
-             * We do not localize the exception message since it is targeted to the developer
-             * rather than the end user.
              *
              * {@note An alternative would have been to store the result in the map anyway.
              *        But doing so is unsafe because we have no lock; we have no guarantee
and
@@ -746,8 +723,8 @@ public class Cache<K,V> extends Abstract
              */
             @Override
             public void putAndUnlock(final V result) throws IllegalStateException {
-                if (result != get() && !isKeyCollisionAllowed()) {
-                    throw new IllegalStateException("Key collision: the cache already has
a value.");
+                if (result != get()) {
+                    throw new IllegalStateException(Errors.format(Errors.Keys.KeyCollision_1,
key));
                 }
             }
         }
@@ -876,40 +853,6 @@ public class Cache<K,V> extends Abstract
     }
 
     /**
-     * Returns {@code true} if different values may be assigned to the same key.
-     * The default value is {@code false}.
-     *
-     * @return {@code true} if key collisions are allowed.
-     */
-    public boolean isKeyCollisionAllowed() {
-        return keyCollisionAllowed;
-    }
-
-    /**
-     * If set to {@code true}, different values may be assigned to the same key. This is
usually an
-     * error, so the default {@code Cache} behavior is to thrown an {@link IllegalStateException}
-     * in such cases, typically when {@link Handler#putAndUnlock(Object)} is invoked. However
in
-     * some cases we may want to relax this check. For example the EPSG database sometime
assigns
-     * the same key to different kind of objects.
-     * <p>
-     * If key collisions are allowed, then if two threads invoke {@link #lock(Object)} concurrently
-     * for the same key, then the value to be stored in the map will be the one computed
by the first
-     * thread to get the lock. The value computed by any other concurrent thread will be
ignored by
-     * this {@code Cache} class (however that thread would still return its computed value
to its
-     * user).
-     * <p>
-     * This property can also be set in order to allow some recursivity. If during the creation
of
-     * an object, the program asks to this {@code Cache} for the same object (using the
same key),
-     * then the default {@code Cache} implementation will consider this situation as a key
collision
-     * unless this property has been set to {@code true}.
-     *
-     * @param allowed {@code true} if key collisions should be allowed.
-     */
-    public void setKeyCollisionAllowed(final boolean allowed) {
-        keyCollisionAllowed = allowed;
-    }
-
-    /**
      * Computes an estimation of the cost of the given value. The default implementation
returns 1
      * in all cases. Subclasses should override this method if they have some easy way to
measure
      * the relative cost of value objects.

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java?rev=1397415&r1=1397414&r2=1397415&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java
(original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java
Fri Oct 12 01:50:36 2012
@@ -28,12 +28,12 @@ import static org.apache.sis.util.Argume
 
 
 /**
- * A {@linkplain Collections#checkedList(List) checked} and
- * {@linkplain Collections#synchronizedList(List) synchronized} {@link ArrayList}.
+ * A {@linkplain java.util.Collections#checkedList(List) checked} and
+ * {@linkplain java.util.Collections#synchronizedList(List) synchronized} {@link ArrayList}.
  * The type checks are performed at run-time in addition to the compile-time checks.
  *
  * <p>Using this class is similar to wrapping an {@link ArrayList} using the methods
provided
- * in the standard {@link Collections} class, except for the following advantages:</p>
+ * in the standard {@link java.util.Collections} class, except for the following advantages:</p>
  *
  * <ul>
  *   <li>Avoid the two levels of indirection (for type check and synchronization).</li>
@@ -58,8 +58,8 @@ import static org.apache.sis.util.Argume
  * @version 0.3
  * @module
  *
- * @see Collections#checkedList(List)
- * @see Collections#synchronizedList(List)
+ * @see java.util.Collections#checkedList(List)
+ * @see java.util.Collections#synchronizedList(List)
  */
 @ThreadSafe
 public class CheckedArrayList<E> extends ArrayList<E> implements CheckedContainer<E>,
Cloneable {
@@ -157,7 +157,7 @@ public class CheckedArrayList<E> extends
      *
      * {@section Note for subclass implementors}
      * Subclasses that override this method must be careful to update the lock reference
-     * when this list is {@linkplain #clone() cloned}.
+     * (if needed) when this list is {@linkplain #clone() cloned}.
      *
      * @return The synchronization lock.
      */

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java?rev=1397415&r1=1397414&r2=1397415&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java
(original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java
Fri Oct 12 01:50:36 2012
@@ -26,12 +26,12 @@ import static org.apache.sis.util.Argume
 
 
 /**
- * A {@linkplain Collections#checkedMap(Map) checked} and
- * {@linkplain Collections#synchronizedMap(Map) synchronized} {@link LinkedHashMap}.
+ * A {@linkplain java.util.Collections#checkedMap(Map) checked} and
+ * {@linkplain java.util.Collections#synchronizedMap(Map) synchronized} {@link LinkedHashMap}.
  * The type checks are performed at run-time in addition to the compile-time checks.
  *
  * <p>Using this class is similar to wrapping a {@link LinkedHashMap} using the methods
provided
- * in the standard {@link Collections} class, except for the following advantages:</p>
+ * in the standard {@link java.util.Collections} class, except for the following advantages:</p>
  *
  * <ul>
  *   <li>Avoid the two levels of indirection (for type check and synchronization).</li>
@@ -59,8 +59,8 @@ import static org.apache.sis.util.Argume
  * @version 0.3
  * @module
  *
- * @see Collections#checkedMap(Map)
- * @see Collections#synchronizedMap(Map)
+ * @see java.util.Collections#checkedMap(Map)
+ * @see java.util.Collections#synchronizedMap(Map)
  */
 @ThreadSafe
 public class CheckedHashMap<K,V> extends LinkedHashMap<K,V> implements Cloneable
{
@@ -132,7 +132,7 @@ public class CheckedHashMap<K,V> extends
      *
      * {@section Note for subclass implementors}
      * Subclasses that override this method must be careful to update the lock reference
-     * when this map is {@linkplain #clone() cloned}.
+     * (if needed) when this map is {@linkplain #clone() cloned}.
      *
      * @return The synchronization lock.
      */

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java?rev=1397415&r1=1397414&r2=1397415&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java
(original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java
Fri Oct 12 01:50:36 2012
@@ -28,12 +28,12 @@ import static org.apache.sis.util.Argume
 
 
 /**
- * A {@linkplain Collections#checkedSet(Set) checked} and
- * {@linkplain Collections#synchronizedSet(Set) synchronized} {@link LinkedHashSet}.
+ * A {@linkplain java.util.Collections#checkedSet(Set) checked} and
+ * {@linkplain java.util.Collections#synchronizedSet(Set) synchronized} {@link LinkedHashSet}.
  * The type checks are performed at run-time in addition to the compile-time checks.
  *
  * <p>Using this class is similar to wrapping a {@link LinkedHashSet} using the methods
provided
- * in the standard {@link Collections} class, except for the following advantages:</p>
+ * in the standard {@link java.util.Collections} class, except for the following advantages:</p>
  *
  * <ul>
  *   <li>Avoid the two levels of indirection (for type check and synchronization).</li>
@@ -43,7 +43,7 @@ import static org.apache.sis.util.Argume
  * </ul>
  *
  * <p>The synchronization is provided mostly in order to prevent damages
- * to the set in case of concurrent accesses. It does <strong>not</strong> prevent
+ * to the set in case of concurrent access. It does <strong>not</strong> prevent
  * {@link java.util.ConcurrentModificationException} to be thrown during iterations,
  * unless the whole iteration is synchronized on this set {@linkplain #getLock() lock}.
  * For real concurrency, see the {@link java.util.concurrent} package instead.</p>
@@ -58,8 +58,8 @@ import static org.apache.sis.util.Argume
  * @version 0.3
  * @module
  *
- * @see Collections#checkedSet(Set)
- * @see Collections#synchronizedSet(Set)
+ * @see java.util.Collections#checkedSet(Set)
+ * @see java.util.Collections#synchronizedSet(Set)
  */
 @ThreadSafe
 public class CheckedHashSet<E> extends LinkedHashSet<E> implements CheckedContainer<E>,
Cloneable {
@@ -157,7 +157,7 @@ public class CheckedHashSet<E> extends L
      *
      * {@section Note for subclass implementors}
      * Subclasses that override this method must be careful to update the lock reference
-     * when this set is {@linkplain #clone() cloned}.
+     * (if needed) when this set is {@linkplain #clone() cloned}.
      *
      * @return The synchronization lock.
      */

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java?rev=1397415&r1=1397414&r2=1397415&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
(original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
Fri Oct 12 01:50:36 2012
@@ -33,7 +33,7 @@
  *     and supports concurrency, while the other implementations are more lightweight, sometime
  *     thread-safe but without concurrency support.
  *   </p></li><li><p>
- *     {@link org.apache.sis.util.collection.CheckedCollection},
+ *     {@link org.apache.sis.util.collection.CheckedContainer},
  *     {@link org.apache.sis.util.collection.CheckedArrayList},
  *     {@link org.apache.sis.util.collection.CheckedHashSet} and
  *     {@link org.apache.sis.util.collection.CheckedHashMap} can be used for combining <em>runtime</em>

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1397415&r1=1397414&r2=1397415&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
(original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
Fri Oct 12 01:50:36 2012
@@ -97,6 +97,11 @@ public final class Errors extends Indexe
         public static final int IndexOutOfBounds_1 = 4;
 
         /**
+         * A different value is already associated to the “{0}” key.
+         */
+        public static final int KeyCollision_1 = 19;
+
+        /**
          * Argument ‘{0}’ shall not be negative. The given value was {1}.
          */
         public static final int NegativeArgument_2 = 8;

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1397415&r1=1397414&r2=1397415&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
(original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
Fri Oct 12 01:50:36 2012
@@ -24,6 +24,7 @@ IllegalClass_2                  = Class 
 IllegalLanguageCode_1           = The \u201c{0}\u201d language is not recognized.
 IllegalRange_2                  = Range [{0} \u2026 {1}] is not valid.
 IndexOutOfBounds_1              = Index {0} is out of bounds.
+KeyCollision_1                  = A different value is already associated to the \u201c{0}\u201d
key.
 NegativeArgument_2              = Argument \u2018{0}\u2019 shall not be negative. The given
value was {1}.
 NotANumber_1                    = Argument \u2018{0}\u2019 shall not be NaN (Not-a-Number).
 NotAPrimitiveWrapper_1          = Class \u2018{0}\u2019 is not a primitive type wrapper.

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1397415&r1=1397414&r2=1397415&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
(original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
Fri Oct 12 01:50:36 2012
@@ -24,6 +24,7 @@ IllegalClass_2                  = La cla
 IllegalLanguageCode_1           = Le code de langue \u201c{0}\u201d n\u2019est pas reconnu.
 IllegalRange_2                  = La plage [{0} \u2026 {1}] n\u2019est pas valide.
 IndexOutOfBounds_1              = L\u2019index {0} est en dehors des limites permises.
+KeyCollision_1                  = Une valeur diff\u00e9rente est d\u00e9j\u00e0 associ\u00e9e
\u00e0 la cl\u00e9 \u201c{0}\u201d.
 NegativeArgument_2              = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre n\u00e9gatif.
La valeur donn\u00e9e \u00e9tait {1}.
 NotANumber_1                    = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre NaN
(Not-a-Number).
 NotAPrimitiveWrapper_1          = La classe \u2018{0}\u2019 n\u2019est pas un adaptateur
d\u2019un type primitif.

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/type/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/type/Types.java?rev=1397415&r1=1397414&r2=1397415&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/type/Types.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/type/Types.java Fri Oct
12 01:50:36 2012
@@ -152,7 +152,7 @@ public final class Types extends Static 
      * If the given array is null or an instance of {@code InternationalString[]}, then this
method
      * returns it unchanged. Otherwise a new array of type {@code InternationalString[]}
is created
      * and every elements from the given array is copied or
-     * {@linkplain #InternationalString(CharSequence) converted} in the new array.
+     * {@linkplain #toInternationalString(CharSequence) converted} in the new array.
      * <p>
      * If a defensive copy of the {@code strings} array is wanted, then the caller needs
to check
      * if the returned array is the same instance than the one given in argument to this
method.

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java?rev=1397415&r1=1397414&r2=1397415&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java Fri Oct
12 01:50:36 2012
@@ -120,8 +120,8 @@ public final class TestRunner extends Bl
 
     /**
      * Validates all tests methods in the test class. This method first performs the default
-     * verification documented in {@link BlockJUnit4ClassRunner#validateTestMethods()}, then
-     * ensures that all {@link DependsOnMethod} annotations refer to an existing method.
+     * verification documented in {@link BlockJUnit4ClassRunner#validateTestMethods(List)},
+     * then ensures that all {@link DependsOnMethod} annotations refer to an existing method.
      *
      * @param errors The list where to report any problem found.
      */

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java?rev=1397415&r1=1397414&r2=1397415&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java
(original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java
Fri Oct 12 01:50:36 2012
@@ -39,7 +39,7 @@ import static org.junit.Assert.*;
  */
 public final strictfp class IndexedResourceBundleTest extends TestCase {
     /**
-     * Tests the {@link Errors#getResources()} method on different locales.
+     * Tests the {@link Errors#getResources(Locale)} method on different locales.
      */
     @Test
     public void testGetResources() {



Mime
View raw message