sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1398637 - in /sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis: util/collection/Cache.java xml/Namespaces.java
Date Tue, 16 Oct 2012 04:12:35 GMT
Author: desruisseaux
Date: Tue Oct 16 04:12:35 2012
New Revision: 1398637

URL: http://svn.apache.org/viewvc?rev=1398637&view=rev
Log:
Leverage ArgumentChecks, and documentation updates.

Modified:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java?rev=1398637&r1=1398636&r2=1398637&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
Tue Oct 16 04:12:35 2012
@@ -32,6 +32,7 @@ import net.jcip.annotations.GuardedBy;
 import net.jcip.annotations.ThreadSafe;
 
 import org.apache.sis.util.Disposable;
+import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.util.ReferenceQueueConsumer;
 
@@ -204,14 +205,8 @@ public class Cache<K,V> extends Abstract
      * @param soft If {@code true}, use {@link SoftReference} instead of {@link WeakReference}.
      */
     public Cache(int initialCapacity, final long costLimit, final boolean soft) {
-        if (initialCapacity < 1) {
-            throw new IllegalArgumentException(Errors.format(
-                    Errors.Keys.IllegalArgumentValue_2, "initialCapacity", initialCapacity));
-        }
-        if (costLimit < 0) {
-            throw new IllegalArgumentException(Errors.format(
-                    Errors.Keys.IllegalArgumentValue_2, "costLimit", costLimit));
-        }
+        ArgumentChecks.ensureStrictlyPositive("initialCapacity", initialCapacity);
+        ArgumentChecks.ensurePositive("costLimit", costLimit);
         initialCapacity = Collections.hashMapCapacity(initialCapacity);
         this.map        = new ConcurrentHashMap<>(initialCapacity);
         this.costs      = new LinkedHashMap<>((int) Math.min(initialCapacity, costLimit),
0.75f, true);

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java?rev=1398637&r1=1398636&r2=1398637&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java Tue Oct
16 04:12:35 2012
@@ -20,8 +20,8 @@ import java.util.Map;
 import java.util.HashMap;
 import java.util.Locale;
 import javax.xml.XMLConstants;
-
 import org.apache.sis.util.Static;
+import org.apache.sis.util.ArgumentChecks;
 
 
 /**
@@ -163,11 +163,15 @@ public final class Namespaces extends St
     /**
      * Returns the preferred prefix for the given name space URI.
      *
-     * @param  namespace  The name space URI for which the prefix needs to be found. Can
not be {@code null}.
-     * @param  suggestion The suggested prefix, returned if the given name space is not recognized.
-     * @return The prefix inferred from the name space URI.
+     * @param  namespace    The name space URI for which the prefix needs to be found.
+     *                      Can not be {@code null}.
+     * @param  defaultValue The default prefix to returned if the given {@code namespace}
+     *                      is not recognized, or {@code null}.
+     * @return The prefix inferred from the name space URI, or {@code null} if the given
name space
+     *         is unrecognized and the {@code defaultValue} is null.
      */
-    public static String getPreferredPrefix(String namespace, final String suggestion) {
+    public static String getPreferredPrefix(String namespace, final String defaultValue)
{
+        ArgumentChecks.ensureNonNull("namespace", namespace);
         String prefix = SPECIFIC_URLS.get(namespace);
         if (prefix != null) {
             return prefix;
@@ -185,6 +189,6 @@ public final class Namespaces extends St
                 return prefix;
             }
         }
-        return suggestion;
+        return defaultValue;
     }
 }



Mime
View raw message