sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1420597 [2/3] - in /sis/branches/JDK6: ./ ide-project/NetBeans/nbproject/ sis-metadata/src/main/java/org/apache/sis/internal/ sis-utility/src/main/java/org/apache/sis/internal/jaxb/ sis-utility/src/main/java/org/apache/sis/internal/jaxb/gc...
Date Wed, 12 Dec 2012 09:56:52 GMT
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java Wed Dec 12 09:56:36 2012
@@ -19,6 +19,7 @@ package org.apache.sis.util;
 import java.util.Set;
 import java.util.Iterator;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.LinkedHashSet;
 import java.lang.reflect.Type;
 import java.lang.reflect.Field;
@@ -30,6 +31,7 @@ import java.lang.reflect.ParameterizedTy
 import static java.util.Arrays.copyOf;
 import static org.apache.sis.util.Arrays.resize;
 import static org.apache.sis.util.Arrays.contains;
+import static org.apache.sis.util.collection.Collections.hashMapCapacity;
 
 
 /**
@@ -56,6 +58,11 @@ import static org.apache.sis.util.Arrays
  */
 public final class Classes extends Static {
     /**
+     * An empty array of classes.
+     */
+    private static final Class<?>[] EMPTY_ARRAY = new Class<?>[0];
+
+    /**
      * Methods to be rejected by {@link #isGetter(Method)}. They are mostly methods inherited
      * from {@link Object}. Only no-argument methods having a non-void return value need to be
      * declared in this list.
@@ -109,7 +116,7 @@ public final class Classes extends Stati
                 do element = element.getComponentType();
                 while (element!=null && ++dimension != 0);
             } else if (element != Void.TYPE) {
-                final StringBuilder buffer = new StringBuilder(16);
+                final StringBuilder buffer = new StringBuilder();
                 do buffer.insert(0, '[');
                 while (--dimension != 0);
                 if (element.isPrimitive()) {
@@ -297,28 +304,39 @@ public final class Classes extends Stati
      *         interface), or an empty set if none. Callers can freely modify the returned set.
      */
     public static Set<Class<?>> getAllInterfaces(Class<?> type) {
-        final Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>();
+        Set<Class<?>> interfaces = null;
         while (type != null) {
-            getAllInterfaces(type, interfaces);
+            interfaces = getAllInterfaces(type, interfaces);
             type = type.getSuperclass();
         }
-        return interfaces;
+        return (interfaces != null) ? interfaces : Collections.<Class<?>>emptySet();
     }
 
     /**
-     * Adds to the given collection every interfaces implemented by the given class or interface.
+     * Adds to the given set every interfaces implemented by the given class or interface.
+     *
+     * @param  type  The type for which to add the interfaces in the given set.
+     * @param  addTo The set where to add interfaces, or {@code null} if not yet created.
+     * @return The given set (may be {@code null}), or a new set if the given set was null
+     *         and at least one interface has been found.
      */
-    private static void getAllInterfaces(final Class<?> type, final Set<Class<?>> interfaces) {
-        for (final Class<?> i : type.getInterfaces()) {
-            if (interfaces.add(i)) {
-                getAllInterfaces(i, interfaces);
+    private static Set<Class<?>> getAllInterfaces(final Class<?> type, Set<Class<?>> addTo) {
+        final Class<?>[] interfaces = type.getInterfaces();
+        for (int i=0; i<interfaces.length; i++) {
+            final Class<?> candidate = interfaces[i];
+            if (addTo == null) {
+                addTo = new LinkedHashSet<Class<?>>(hashMapCapacity(interfaces.length - i));
+            }
+            if (addTo.add(candidate)) {
+                getAllInterfaces(candidate, addTo);
             }
         }
+        return addTo;
     }
 
     /**
      * Returns the interfaces implemented by the given class and assignable to the given base
-     * interface, or {@code null} if none. If more than one interface extends the given base,
+     * interface, or an empty array if none. If more than one interface extends the given base,
      * then the most specialized interfaces are returned. For example if the given class
      * implements both the {@link Set} and {@link Collection} interfaces, then the returned
      * array contains only the {@code Set} interface.
@@ -328,15 +346,14 @@ public final class Classes extends Stati
      * containing {@code List.class}.
      *
      * @param  <T>  The type of the {@code baseInterface} class argument.
-     * @param  type A class for which the implemented interface is desired.
-     * @param  baseInterface The base type of the interface to search.
-     * @return The leaf interfaces matching the given criterion, or {@code null} if none.
-     *         If non-null, than the array is guaranteed to contain at least one element.
+     * @param  type A class for which the implemented interfaces are desired.
+     * @param  baseInterface The base type of the interfaces to search.
+     * @return The leaf interfaces matching the given criterion, or an empty array if none.
      */
     @SuppressWarnings("unchecked")
     public static <T> Class<? extends T>[] getLeafInterfaces(Class<?> type, final Class<T> baseInterface) {
         int count = 0;
-        Class<?>[] types = null;
+        Class<?>[] types = EMPTY_ARRAY;
         while (type != null) {
             final Class<?>[] candidates = type.getInterfaces();
 next:       for (final Class<?> candidate : candidates) {
@@ -356,7 +373,7 @@ next:       for (final Class<?> candidat
                             continue next;
                         }
                     }
-                    if (types == null) {
+                    if (types == EMPTY_ARRAY) {
                         types = candidates;
                     }
                     if (count >= types.length) {
@@ -484,7 +501,7 @@ next:       for (final Class<?> candidat
         interfaces.retainAll(buffer);
         for (Iterator<Class<?>> it=interfaces.iterator(); it.hasNext();) {
             final Class<?> candidate = it.next();
-            buffer.clear();
+            buffer.clear(); // Safe because the buffer can not be Collections.EMPTY_SET at this point.
             getAllInterfaces(candidate, buffer);
             if (interfaces.removeAll(buffer)) {
                 it = interfaces.iterator();
@@ -494,11 +511,13 @@ next:       for (final Class<?> candidat
     }
 
     /**
-     * Returns {@code true} if the two specified objects implements exactly the same set of
-     * interfaces. Only interfaces assignable to {@code base} are compared. Declaration order
-     * doesn't matter. For example in ISO 19111, different interfaces exist for different coordinate
-     * system geometries ({@code CartesianCS}, {@code PolarCS}, etc.). We can check if two
-     * CS implementations has the same geometry with the following code:
+     * Returns {@code true} if the two specified objects implements exactly the same set
+     * of interfaces. Only interfaces assignable to {@code baseInterface} are compared.
+     * Declaration order doesn't matter.
+     *
+     * For example in ISO 19111, different interfaces exist for different coordinate system (CS)
+     * geometries ({@code CartesianCS}, {@code PolarCS}, etc.). One can check if two implementations
+     * have the same geometry with the following code:
      *
      * {@preformat java
      *     if (implementSameInterfaces(cs1, cs2, CoordinateSystem.class)) {
@@ -508,46 +527,32 @@ next:       for (final Class<?> candidat
      *
      * @param object1 The first object to check for interfaces.
      * @param object2 The second object to check for interfaces.
-     * @param base    The parent of all interfaces to check.
-     * @return        {@code true} if both objects implement the same set of interfaces,
-     *                considering only sub-interfaces of {@code base}.
+     * @param baseInterface The parent of all interfaces to check.
+     * @return {@code true} if both objects implement the same set of interfaces,
+     *         considering only sub-interfaces of {@code baseInterface}.
      */
-    public static boolean implementSameInterfaces(final Class<?> object1, final Class<?> object2, final Class<?> base) {
+    public static boolean implementSameInterfaces(final Class<?> object1, final Class<?> object2, final Class<?> baseInterface) {
         if (object1 == object2) {
             return true;
         }
         if (object1 == null || object2 == null) {
             return false;
         }
-        final Class<?>[] c1 = object1.getInterfaces();
-        final Class<?>[] c2 = object2.getInterfaces();
+        final Class<?>[] c1 = getLeafInterfaces(object1, baseInterface);
+        final Class<?>[] c2 = getLeafInterfaces(object2, baseInterface);
         /*
-         * Trim all interfaces that are not assignable to 'base' in the 'c2' array.
-         * Doing this once will avoid to redo the same test many time in the inner
-         * loops j=[0..n].
+         * For each interface in the 'c1' array, check if
+         * this interface exists also in the 'c2' array.
          */
-        int n = 0;
-        for (int i=0; i<c2.length; i++) {
-            final Class<?> c = c2[i];
-            if (base.isAssignableFrom(c)) {
-                c2[n++] = c;
-            }
-        }
-        /*
-         * For each interface assignable to 'base' in the 'c1' array, check if
-         * this interface exists also in the 'c2' array. Order doesn't matter.
-         */
-compare:for (int i=0; i<c1.length; i++) {
-            final Class<?> c = c1[i];
-            if (base.isAssignableFrom(c)) {
-                for (int j=0; j<n; j++) {
-                    if (c == c2[j]) {
-                        System.arraycopy(c2, j+1, c2, j, --n-j);
-                        continue compare;
-                    }
+        int n = c2.length;
+cmp:    for (final Class<?> c : c1) {
+            for (int j=n; --j>=0;) {
+                if (c == c2[j]) {
+                    System.arraycopy(c2, j+1, c2, j, --n-j);
+                    continue cmp;
                 }
-                return false; // Interface not found in 'c2'.
             }
+            return false; // Interface not found in 'c2'.
         }
         return n == 0; // If n>0, at least one interface was not found in 'c1'.
     }

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ComparisonMode.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ComparisonMode.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ComparisonMode.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ComparisonMode.java Wed Dec 12 09:56:36 2012
@@ -18,12 +18,12 @@ package org.apache.sis.util;
 
 
 /**
- * Specifies the degree of strictness when comparing two {@link LenientComparable} objects
+ * Specifies the level of strictness when comparing two {@link LenientComparable} objects
  * for equality. This enumeration allows users to specify which kind of differences can be
  * tolerated between two objects: differences in implementation class, differences in
  * some kinds of property, or slight difference in numerical values.
  *
- * <p>This enumeration is <em>ordered</em> from stricter to more lenient degrees:</p>
+ * <p>This enumeration is <em>ordered</em> from stricter to more lenient levels:</p>
  *
  * <ol>
  *   <li>{@link #STRICT}          – All attributes of the compared objects shall be strictly equal.</li>
@@ -31,13 +31,13 @@ package org.apache.sis.util;
  *   <li>{@link #IGNORE_METADATA} – Only the attributes relevant to the object functionality are compared.</li>
  *   <li>{@link #APPROXIMATIVE}   – Only the attributes relevant to the object functionality are compared,
  *                                  with some tolerance threshold on numerical values.</li>
- *   <li>{@link #DEBUG}:          – Special mode for figuring out why two objects expected to be equal are not.</li>
+ *   <li>{@link #DEBUG}           – Special mode for figuring out why two objects expected to be equal are not.</li>
  * </ol>
  *
- * If two objects are equal at some degree of strictness <var>E</var>, then they should also
- * be equal at all degrees listed below <var>E</var> in the above list. For example if two objects
- * are equal at the degree {@link #BY_CONTRACT}, then they should also be equal at the degree
- * {@link #IGNORE_METADATA} but not necessarily at the degree {@link #STRICT}.
+ * If two objects are equal at some level of strictness <var>E</var>, then they should also
+ * be equal at all levels listed below <var>E</var> in the above list. For example if two objects
+ * are equal at the {@link #BY_CONTRACT} level, then they should also be equal at the
+ * {@link #IGNORE_METADATA} level but not necessarily at the {@link #STRICT} level.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.18)

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java Wed Dec 12 09:56:36 2012
@@ -26,7 +26,7 @@ package org.apache.sis.util;
  * {@section Conditions for equality}
  * <ul>
  *   <li>{@link org.apache.sis.metadata.iso.MetadataEntity} subclasses
- *     <ul class="verbose">
+ *     <ol>
  *       <li>{@link ComparisonMode#STRICT STRICT} – Objects must be of the same class
  *           and all attributes must be equal, including {@code xlink} and others
  *           {@linkplain org.apache.sis.metadata.iso.MetadataEntity#getIdentifiers() identifiers}.</li>
@@ -39,10 +39,10 @@ package org.apache.sis.util;
  *       <li>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE} – The same attributes than the above
  *           {@code IGNORE_METADATA} mode are compared, but a slight (implementation dependant)
  *           difference is tolerated in floating point numbers.</li>
- *     </ul>
+ *     </ol>
  *   </li>
  *   <li>{@link org.apache.sis.referencing.AbstractIdentifiedObject} subclasses
- *     <ul class="verbose">
+ *     <ol>
  *       <li>{@link ComparisonMode#STRICT STRICT} – Objects must be of the same class
  *           and all attributes must be equal.</li>
  *       <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT} – The same attributes than the above
@@ -60,11 +60,11 @@ package org.apache.sis.util;
  *       <li>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE} – The same attributes than the above
  *           {@code IGNORE_METADATA} mode are compared, but a slight (implementation dependant)
  *           difference is tolerated in floating point numbers.</li>
- *     </ul>
+ *     </ol>
  *   </li>
  *   <li>{@link org.apache.sis.referencing.operation.transform.AbstractMathTransform} subclasses
  *       except {@link org.apache.sis.referencing.operation.transform.LinearTransform}
- *     <ul class="verbose">
+ *     <ol>
  *       <li>{@link ComparisonMode#STRICT STRICT} – Objects must be of the same class and all
  *           attributes must be equal, including the
  *           {@linkplain org.apache.sis.referencing.operation.transform.AbstractMathTransform#getParameterValues() parameter values}.</li>
@@ -80,11 +80,11 @@ package org.apache.sis.util;
  *       <li>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE} – The same attributes than the above
  *           {@code IGNORE_METADATA} mode are compared, but a slight (implementation dependant)
  *           difference is tolerated in floating point numbers.</li>
- *     </ul>
+ *     </ol>
  *   </li>
  *   <li>{@link org.apache.sis.referencing.operation.matrix.XMatrix} and
  *       {@link org.apache.sis.referencing.operation.transform.LinearTransform} implementations
- *     <ul class="verbose">
+ *     <ol>
  *       <li>{@link ComparisonMode#STRICT STRICT} – Objects must be of the same class, matrixes
  *           must have the same size and all matrix elements must be equal.</li>
  *       <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT} – Matrixes must have the same size
@@ -95,7 +95,7 @@ package org.apache.sis.util;
  *       <li>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE} – The same attributes than the above
  *           {@code BY_CONTRACT} mode are compared, but a slight (implementation dependant)
  *           difference is tolerated in floating point numbers.</li>
- *     </ul>
+ *     </ol>
  *   </li>
  * </ul>
  *
@@ -124,6 +124,11 @@ public interface LenientComparable {
      *        special mode for figuring out why two objects expected to be equal are not.</li>
      * </ol>
      *
+     * Note that {@code this.equals(other, mode)} is <strong>not</strong> guaranteed to be equals
+     * to {@code other.equals(this, mode)}.  In particular, the {@code BY_CONTRACT} level and all
+     * levels below it will typically compare only the properties known to {@code this} instance,
+     * ignoring any properties that may be known only by the {@code other} instance.
+     *
      * @param  other The object to compare to {@code this}.
      * @param  mode The strictness level of the comparison.
      * @return {@code true} if both objects are equal.

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java Wed Dec 12 09:56:36 2012
@@ -22,7 +22,6 @@ import java.util.Arrays;
 import java.util.Locale;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
-import java.util.MissingResourceException;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 
@@ -199,24 +198,6 @@ public final class Locales extends Stati
     }
 
     /**
-     * Returns the {@linkplain Locale#getISO3Language() 3-letters ISO language code} if available,
-     * or the {@linkplain Locale#getLanguage() 2-letters code} otherwise.
-     *
-     * @param  locale The locale for which we want the language.
-     * @return The language code, 3 letters if possible or 2 letters otherwise.
-     *
-     * @see Locale#getISO3Language()
-     */
-    public static String getLanguageCode(final Locale locale) {
-        try {
-            return locale.getISO3Language();
-        } catch (MissingResourceException e) {
-            Logging.recoverableException(Locales.class, "getLanguage", e);
-            return locale.getLanguage();
-        }
-    }
-
-    /**
      * Parses the given locale. The string is the language code either as the 2 letters or the
      * 3 letters ISO code. It can optionally be followed by the {@code '_'} character and the
      * country code (again either as 2 or 3 letters), optionally followed by {@code '_'} and

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java Wed Dec 12 09:56:36 2012
@@ -50,6 +50,8 @@ package org.apache.sis.util;
  * <tr><th colspan="2" class="hsep">Input / Output (including CRS, XML, images)</th></tr>
  * <tr><td>{@link org.apache.sis.io.IO}</td>
  *     <td>Methods working on {@link Appendable} instances.</td></tr>
+ * <tr><td>{@link org.apache.sis.xml.XML}</td>
+ *     <td>Marshal or unmarshal ISO 19115 objects.</td></tr>
  *
  * <tr><th colspan="2" class="hsep">Loggings and exceptions</th></tr>
  * <tr><td>{@link ArgumentChecks}</td>

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Version.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Version.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Version.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Version.java Wed Dec 12 09:56:36 2012
@@ -81,6 +81,7 @@ public class Version implements CharSequ
      * @param version The version as a string.
      */
     public Version(final String version) {
+        ArgumentChecks.ensureNonNull("version", version);
         this.version = CharSequences.trimWhitespaces(version);
     }
 

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java Wed Dec 12 09:56:36 2012
@@ -163,8 +163,8 @@ public class DefaultTreeTable implements
             default: map = new LinkedHashMap<TableColumn<?>,Integer>(hashMapCapacity(columns.length)); break;
         }
         for (int i=0; i<columns.length; i++) {
-            ArgumentChecks.ensureNonNull("columns", i, columns);
             final TableColumn<?> column = columns[i];
+            ArgumentChecks.ensureNonNullElement("columns", i, column);
             final Integer pos = i;
             if (map == null) {
                 map = Collections.<TableColumn<?>,Integer>singletonMap(column, pos);

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java Wed Dec 12 09:56:36 2012
@@ -21,7 +21,7 @@ import java.util.Collections;
 import java.io.Serializable;
 import java.io.InvalidObjectException;
 import org.opengis.util.InternationalString;
-import org.apache.sis.util.type.Types;
+import org.apache.sis.util.iso.Types;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Vocabulary;
 

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/UnmodifiableArrayList.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/UnmodifiableArrayList.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/UnmodifiableArrayList.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/UnmodifiableArrayList.java Wed Dec 12 09:56:36 2012
@@ -140,6 +140,23 @@ public class UnmodifiableArrayList<E> ex
     }
 
     /**
+     * Returns the size of the array backing this list. This is the length of the array
+     * given to the constructor. It is equal to {@link #size()} except if this instance
+     * is a {@linkplain #subList(int,int) sublist}, in which case the value returned by
+     * this method is greater than {@code size()}.
+     *
+     * <p>This method can be used as a hint for choosing a {@code UnmodifiableArrayList}
+     * instance to keep when there is a choice between many equal instances. Note that a
+     * greater value is not necessarily more memory consuming, since the backing array
+     * may be shared by many sublists.</p>
+     *
+     * @return The length of the backing array.
+     */
+    public final int arraySize() {
+        return array.length;
+    }
+
+    /**
      * Returns the element at the specified index.
      */
     @Override

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java?rev=1420597&r1=1420581&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java Wed Dec 12 09:56:36 2012
@@ -30,7 +30,7 @@ import org.opengis.util.InternationalStr
 import org.apache.sis.util.resources.Errors;
 
 // Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.util.Objects;
 
 
 /**

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/CodeLists.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/CodeLists.java?rev=1420597&r1=1420581&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/CodeLists.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/CodeLists.java Wed Dec 12 09:56:36 2012
@@ -245,7 +245,7 @@ public final class CodeLists extends Sta
                 throw (Error) cause;
             }
             throw new UndeclaredThrowableException(cause);
-        } catch (NoSuchMethodException | IllegalAccessException e) {
+        } catch (Exception e) { // (NoSuchMethodException | IllegalAccessException) on JDK7
             values = Array.newInstance(codeType, 0);
         }
         return (T[]) values;

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java?rev=1420597&r1=1420581&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java Wed Dec 12 09:56:36 2012
@@ -34,7 +34,7 @@ import org.apache.sis.util.resources.Err
 import static org.apache.sis.util.collection.Collections.isNullOrEmpty;
 
 // Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.util.Objects;
 
 
 /**
@@ -107,7 +107,7 @@ public class DefaultInternationalString 
             if (!it.hasNext()) {
                 localeMap = Collections.singletonMap(entry.getKey(), entry.getValue());
             } else {
-                localeMap = new LinkedHashMap<>(strings);
+                localeMap = new LinkedHashMap<Locale,String>(strings);
                 // If HashMap is replaced by an other type, please revisit 'getLocales()'.
             }
         }
@@ -132,7 +132,7 @@ public class DefaultInternationalString 
                 }
                 case 1: {
                     // If HashMap is replaced by an other type, please revisit 'getLocales()'.
-                    localeMap = new LinkedHashMap<>(localeMap);
+                    localeMap = new LinkedHashMap<Locale,String>(localeMap);
                     localeSet = null;
                     break;
                 }

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java?rev=1420597&r1=1420581&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java Wed Dec 12 09:56:36 2012
@@ -32,7 +32,7 @@ import org.apache.sis.util.ArgumentCheck
 import org.apache.sis.internal.jaxb.gco.CharSequenceAdapter;
 
 // Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.util.Objects;
 
 
 /**

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java?rev=1420597&r1=1420581&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java Wed Dec 12 09:56:36 2012
@@ -80,7 +80,7 @@ public class DefaultNameFactory extends 
      * Creates a new factory.
      */
     public DefaultNameFactory() {
-        pool = new WeakHashSet<>(GenericName.class);
+        pool = new WeakHashSet<GenericName>(GenericName.class);
     }
 
     /**
@@ -260,7 +260,7 @@ public class DefaultNameFactory extends 
             separator = DEFAULT_SEPARATOR_STRING;
         }
         final int s = separator.length();
-        final List<String> names = new ArrayList<>();
+        final List<String> names = new ArrayList<String>();
         int lower = 0;
         final String string = name.toString();
         while (true) {

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java?rev=1420597&r1=1420581&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java Wed Dec 12 09:56:36 2012
@@ -33,7 +33,7 @@ import org.apache.sis.util.collection.Un
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 
 // Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.util.Objects;
 
 
 /**
@@ -164,7 +164,7 @@ public class DefaultNameSpace implements
      * Initializes the transient fields.
      */
     private void init() {
-        childs = new WeakValueHashMap<>(String.class);
+        childs = new WeakValueHashMap<String,Object>(String.class);
     }
 
     /**

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/ResourceInternationalString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/ResourceInternationalString.java?rev=1420597&r1=1420581&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/ResourceInternationalString.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/ResourceInternationalString.java Wed Dec 12 09:56:36 2012
@@ -27,7 +27,7 @@ import org.opengis.util.InternationalStr
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 
 // Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.util.Objects;
 
 
 /**

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/SimpleInternationalString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/SimpleInternationalString.java?rev=1420597&r1=1420581&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/SimpleInternationalString.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/SimpleInternationalString.java Wed Dec 12 09:56:36 2012
@@ -27,7 +27,7 @@ import org.opengis.util.InternationalStr
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 
 // Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.util.Objects;
 
 
 /**

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java?rev=1420597&r1=1420581&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java Wed Dec 12 09:56:36 2012
@@ -125,10 +125,10 @@ public final class Types extends Static 
             try {
                 props.load(in);
                 in.close();
-            } catch (IOException | IllegalArgumentException e) {
+            } catch (Exception e) { // (IOException | IllegalArgumentException) on JDK7
                 throw new BackingStoreException(e);
             }
-            typeForNames = new HashMap<>(props);
+            typeForNames = new HashMap<Object,Object>(props);
         }
         final Object value = typeForNames.get(identifier);
         if (value == null || value instanceof Class<?>) {

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java Wed Dec 12 09:56:36 2012
@@ -548,7 +548,7 @@ public final class Logging extends Stati
          * because in a client-server architecture, we want the locale on the server-side instead
          * than the locale on the client side.
          */
-        final StringBuilder buffer = new StringBuilder(Classes.getShortClassName(error));
+        final StringBuilder buffer = new StringBuilder(256).append(Classes.getShortClassName(error));
         String message = error.getMessage(); // Targeted to system administrators.
         if (message != null) {
             buffer.append(": ").append(message);

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=1420597&r1=1420596&r2=1420597&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 Wed Dec 12 09:56:36 2012
@@ -84,11 +84,31 @@ public final class Errors extends Indexe
         public static final int EmptyArgument_1 = 1;
 
         /**
+         * The dictionary shall contains at least one entry.
+         */
+        public static final int EmptyDictionary = 54;
+
+        /**
+         * Property named “{0}” shall not be empty.
+         */
+        public static final int EmptyProperty_1 = 55;
+
+        /**
+         * Argument ‘{0}’ shall not contain more than {1} elements. A number of {2} is excessive.
+         */
+        public static final int ExcessiveArgumentSize_3 = 52;
+
+        /**
          * Attribute “{0}” is not allowed for an object of type ‘{1}’.
          */
         public static final int ForbiddenAttribute_2 = 21;
 
         /**
+         * Identifier “{0}” is already associated to another object.
+         */
+        public static final int IdentifierAlreadyBound_1 = 50;
+
+        /**
          * Argument ‘{0}’ can not be an instance of ‘{1}’.
          */
         public static final int IllegalArgumentClass_2 = 17;
@@ -156,6 +176,16 @@ public final class Errors extends Indexe
         public static final int InfiniteArgumentValue_1 = 45;
 
         /**
+         * Infinite recursivity.
+         */
+        public static final int InfiniteRecursivity = 51;
+
+        /**
+         * Argument ‘{0}’ shall contain at least {1} elements. A number of {2} is insufficient.
+         */
+        public static final int InsufficientArgumentSize_3 = 53;
+
+        /**
          * A different value is already associated to the “{0}” key.
          */
         public static final int KeyCollision_1 = 19;
@@ -241,6 +271,11 @@ public final class Errors extends Indexe
         public static final int UnexpectedArgumentDimension_3 = 5;
 
         /**
+         * Unexpected change in ‘{0}’.
+         */
+        public static final int UnexpectedChange_1 = 56;
+
+        /**
          * More characters were expected at the end of “{0}”.
          */
         public static final int UnexpectedEndOfString_1 = 30;

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=1420597&r1=1420596&r2=1420597&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 Wed Dec 12 09:56:36 2012
@@ -20,6 +20,9 @@ DeadThread_1                    = Thread
 DuplicatedValue_1               = Value \u201c{0}\u201d is duplicated.
 ElementAlreadyPresent_1         = Element \u201c{0}\u201d is already present.
 EmptyArgument_1                 = Argument \u2018{0}\u2019 shall not be empty.
+EmptyDictionary                 = The dictionary shall contains at least one entry.
+EmptyProperty_1                 = Property named \u201c{0}\u201d shall not be empty.
+ExcessiveArgumentSize_3         = Argument \u2018{0}\u2019 shall not contain more than {1} elements. A number of {2} is excessive.
 ForbiddenAttribute_2            = Attribute \u201c{0}\u201d is not allowed for an object of type \u2018{1}\u2019.
 IllegalArgumentClass_2          = Argument \u2018{0}\u2019 can not be an instance of \u2018{1}\u2019.
 IllegalArgumentClass_3          = Argument \u2018{0}\u2019 can not be an instance of \u2018{1}\u2019. Expected an instance of \u2018{2}\u2019 or derived type.
@@ -32,8 +35,11 @@ IllegalLanguageCode_1           = The \u
 IllegalRange_2                  = Range [{0} \u2026 {1}] is not valid.
 InconsistentAttribute_2         = Value \u201c{1}\u201d of attribute \u2018{0}\u2019 is inconsistent with other attributes.
 InconsistentTableColumns        = Inconsistent table columns.
+IdentifierAlreadyBound_1        = Identifier \u201c{0}\u201d is already associated to another object.
 IndexOutOfBounds_1              = Index {0} is out of bounds.
 InfiniteArgumentValue_1         = Argument \u2018{0}\u2019 can not take an infinite value.
+InfiniteRecursivity             = Infinite recursivity.
+InsufficientArgumentSize_3      = Argument \u2018{0}\u2019 shall contain at least {1} elements. A number of {2} is insufficient.
 KeyCollision_1                  = A different value is already associated to the \u201c{0}\u201d key.
 MandatoryAttribute_2            = Attribute \u201c{0}\u201d is mandatory for an object of type \u2018{1}\u2019.
 NegativeArgument_2              = Argument \u2018{0}\u2019 shall not be negative. The given value was {1}.
@@ -51,6 +57,7 @@ NullArgument_1                  = Argume
 RecursiveCreateCallForKey_1     = Recursive call while creating an object for the \u201c{0}\u201d key.
 RequireDecimalSeparator         = A decimal separator is required.
 UnexpectedArgumentDimension_3   = Argument \u2018{0}\u2019 has {1} dimensions, while {2} was expected.
+UnexpectedChange_1              = Unexpected change in \u2018{0}\u2019.
 UnexpectedEndOfString_1         = More characters were expected at the end of \u201c{0}\u201d.
 UnmodifiableAffineTransform     = This affine transform is unmodifiable.
 UnmodifiableGeometry            = This geometry is unmodifiable.

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=1420597&r1=1420596&r2=1420597&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 Wed Dec 12 09:56:36 2012
@@ -20,6 +20,9 @@ DeadThread_1                    = La t\u
 DuplicatedValue_1               = La valeur \u201c{0}\u201d est dupliqu\u00e9e.
 ElementAlreadyPresent_1         = L\u2019\u00e9lement \u201c{0}\u201d est d\u00e9j\u00e0 pr\u00e9sent.
 EmptyArgument_1                 = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre vide.
+EmptyDictionary                 = Le dictionnaire doit contenir au moins une entr\u00e9e.
+EmptyProperty_1                 = La propri\u00e9t\u00e9 nomm\u00e9e \u201c{0}\u201d ne doit pas \u00eatre vide.
+ExcessiveArgumentSize_3         = L\u2019argument \u2018{0}\u2019 ne peut pas contenir plus de {1} \u00e9l\u00e9ments. Un nombre de {2} est excessif.
 ForbiddenAttribute_2            = L\u2019attribut \u201c{0}\u201d n\u2019est pas autoris\u00e9 pour un objet de type \u2018{1}\u2019.
 IllegalArgumentClass_2          = L\u2019argument \u2018{0}\u2019 ne peut pas \u00eatre de type \u2018{1}\u2019.
 IllegalArgumentClass_3          = L\u2019argument \u2018{0}\u2019 ne peut pas \u00eatre de type \u2018{1}\u2019. Une instance de \u2018{2}\u2019 ou d\u2019un type d\u00e9riv\u00e9 \u00e9tait attendue.
@@ -32,8 +35,11 @@ IllegalLanguageCode_1           = Le cod
 IllegalRange_2                  = La plage [{0} \u2026 {1}] n\u2019est pas valide.
 InconsistentAttribute_2         = La valeur \u201c{1}\u201d de l\u2019attribut \u2018{0}\u2019 n\u2019est pas coh\u00e9rente avec celles des autres attributs.
 InconsistentTableColumns        = Les colonnes des tables ne sont pas coh\u00e9rentes.
+IdentifierAlreadyBound_1        = L\u2019identifiant \u201c{0}\u201d est d\u00e9j\u00e0 associ\u00e9 \u00e0 un autre objet.
 IndexOutOfBounds_1              = L\u2019index {0} est en dehors des limites permises.
 InfiniteArgumentValue_1         = L\u2019argument \u2018{0}\u2019 ne peut pas prendre une valeur infinie.
+InfiniteRecursivity             = R\u00e9cursivit\u00e9 infinie.
+InsufficientArgumentSize_3      = L\u2019argument \u2018{0}\u2019 doit contenir au moins {1} \u00e9l\u00e9ments. Un nombre de {2} est insuffisant.
 KeyCollision_1                  = Une valeur diff\u00e9rente est d\u00e9j\u00e0 associ\u00e9e \u00e0 la cl\u00e9 \u201c{0}\u201d.
 MandatoryAttribute_2            = L\u2019attribut \u201c{0}\u201d est obligatoire pour un objet de type \u2018{1}\u2019.
 NegativeArgument_2              = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre n\u00e9gatif. La valeur donn\u00e9e \u00e9tait {1}.
@@ -51,6 +57,7 @@ NullArgument_1                  = L\u201
 RecursiveCreateCallForKey_1     = Appel r\u00e9cursif lors de la cr\u00e9ation d\u2019un objet pour la cl\u00e9 \u201c{0}\u201d.
 RequireDecimalSeparator         = Un s\u00e9parateur d\u00e9cimal est requis.
 UnexpectedArgumentDimension_3   = L\u2019argument \u2018{0}\u2019 a {1} dimensions, alors qu\u2019on en attendait {2}.
+UnexpectedChange_1              = Changement inattendu dans \u2018{0}\u2019.
 UnexpectedEndOfString_1         = D\u2019autres caract\u00e8res \u00e9taient attendus \u00e0 la fin du texte \u201c{0}\u201d.
 UnmodifiableAffineTransform     = Cette transformation affine n\u2019est pas modifiable.
 UnmodifiableGeometry            = Cette g\u00e9om\u00e9trie n\u2019est pas modifiable.

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java Wed Dec 12 09:56:36 2012
@@ -26,14 +26,14 @@ import java.util.MissingResourceExceptio
 import net.jcip.annotations.Immutable;
 import org.apache.sis.util.Utilities;
 import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.type.AbstractInternationalString;
+import org.apache.sis.util.iso.AbstractInternationalString;
 
 // Related to JDK7
 import org.apache.sis.internal.util.Objects;
 
 
 /**
- * A copy of {@link org.apache.sis.util.type.ResourceInternationalString} specialized for
+ * A copy of {@link org.apache.sis.util.iso.ResourceInternationalString} specialized for
  * {@link IndexedResourceBundle}. Compared to the public class, this specialization works
  * with integer resource keys and accepts arguments.
  *

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java Wed Dec 12 09:56:36 2012
@@ -77,6 +77,6 @@
  *
  * @see java.util.ResourceBundle
  * @see java.text.MessageFormat
- * @see org.apache.sis.util.type.ResourceInternationalString
+ * @see org.apache.sis.util.iso.ResourceInternationalString
  */
 package org.apache.sis.util.resources;

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifiedObject.java Wed Dec 12 09:56:36 2012
@@ -65,7 +65,7 @@ import org.opengis.metadata.citation.Cit
  *
  * @see IdentifierSpace
  * @see org.apache.sis.metadata.iso.MetadataEntity
- * @see ObjectLinker#newIdentifiedObject(Class, Identifier[])
+ * @see ReferenceResolver#newIdentifiedObject(MarshalContext, Class, Identifier[])
  */
 public interface IdentifiedObject {
     /**

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifierMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifierMap.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifierMap.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifierMap.java Wed Dec 12 09:56:36 2012
@@ -64,7 +64,10 @@ public interface IdentifierMap extends M
      * @param  value The identifier to be associated with the given namespace.
      * @return The previous identifier associated with {@code authority}, or {@code null}
      *         if there was no mapping of the specialized type for {@code authority}.
+     * @throws IdentifierAlreadyBoundException If this map expects unique identifiers for the
+     *         given authority, and the given value is already associated to another object.
      * @throws UnsupportedOperationException If the identifier map is unmodifiable.
      */
-    <T> T putSpecialized(IdentifierSpace<T> authority, T value) throws UnsupportedOperationException;
+    <T> T putSpecialized(IdentifierSpace<T> authority, T value)
+            throws IdentifierAlreadyBoundException, UnsupportedOperationException;
 }

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/MarshalContext.java Wed Dec 12 09:56:36 2012
@@ -31,20 +31,6 @@ import org.apache.sis.util.Version;
  */
 public abstract class MarshalContext {
     /**
-     * A constant for GML version 3.0.
-     *
-     * @see #getVersion(String)
-     */
-    public static final Version GML_3_0 = new Version("3.0");
-
-    /**
-     * A constant for GML version 3.2.
-     *
-     * @see #getVersion(String)
-     */
-    public static final Version GML_3_2 = new Version("3.2");
-
-    /**
      * Creates a new (un)marshalling context.
      */
     protected MarshalContext() {
@@ -61,8 +47,7 @@ public abstract class MarshalContext {
      *     <th>Typical values</th>
      *   </tr>
      *   <tr>
-     *     <td>gml</td><td>Geographic Markup Language</td>
-     *     <td>{@link #GML_3_0}, {@link #GML_3_2}</td>
+     *     <td>gml</td> <td>Geographic Markup Language</td> <td>{@code 3.0}, {@code 3.2}</td>
      *   </tr>
      * </table>
      *
@@ -79,6 +64,23 @@ public abstract class MarshalContext {
      * In particular children of {@link org.opengis.metadata.Metadata} inherit the locale
      * specified by the {@link org.opengis.metadata.Metadata#getLanguage()} attribute.
      *
+     * {@section Null locale}
+     * Null locales are typically interpreted as a request for locale-independent strings in SIS.
+     * The meaning of "locale-independent" is implementation specific -
+     * this is usually very close to the English locale, but not necessarily
+     * (e.g. dates formatted according ISO standard instead then English locale).
+     * If the locale is {@code null}, then callers shall select a default locale as documented
+     * in the {@link org.apache.sis.util.iso.DefaultInternationalString#toString(Locale)} javadoc.
+     * As a matter of rule:
+     *
+     * <ul>
+     *   <li>If the locale is given to an {@code InternationalString.toString(Locale)} method,
+     *       keep the {@code null} value since the international string is already expected to
+     *       returns a "unlocalized" string in such case.</li>
+     *   <li>Otherwise, if a {@code Locale} instance is really needed, use {@link Locale#US}
+     *       as an approximation of "unlocalized" string.</li>
+     * </ul>
+     *
      * @return The locale for the XML fragment being (un)marshalled, or {@code null} is unspecified.
      */
     public abstract Locale getLocale();

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java Wed Dec 12 09:56:36 2012
@@ -74,7 +74,7 @@ package org.apache.sis.xml;
  * @module
  *
  * @see NilReason#createNilObject(Class)
- * @see ObjectLinker#resolve(Class, NilReason)
+ * @see ReferenceResolver#resolve(MarshalContext, Class, NilReason)
  * @see org.apache.sis.util.Numbers#valueOfNil(Class)
  */
 public interface NilObject {

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java Wed Dec 12 09:56:36 2012
@@ -31,6 +31,7 @@ import org.apache.sis.util.ComparisonMod
 import org.apache.sis.util.LenientComparable;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.jaxb.IdentifierMapAdapter;
+import org.apache.sis.internal.jaxb.IdentifierMapWithSpecialCases;
 
 // Related to JDK7
 import org.apache.sis.internal.util.Objects;
@@ -71,7 +72,7 @@ final class NilObjectHandler implements 
                 asList.add(identifier);
             }
         }
-        attribute = IdentifierMapAdapter.create(asList);
+        attribute = new IdentifierMapWithSpecialCases(asList, null);
     }
 
     /**

Copied: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java (from r1420581, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java?p2=sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java&p1=sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java&r1=1420581&r2=1420597&rev=1420597&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java Wed Dec 12 09:56:36 2012
@@ -359,9 +359,12 @@ public class ValueConverter {
     public URL toURL(final MarshalContext context, final URI value) throws MalformedURLException {
         if (value != null) try {
             return value.toURL();
-        } catch (MalformedURLException | IllegalArgumentException e) {
+        } catch (Exception e) { // MalformedURLException | IllegalArgumentException
             if (!exceptionOccured(context, value, URI.class, URL.class, e)) {
-                throw e;
+                if (e instanceof RuntimeException) {
+                    throw (RuntimeException) e;
+                }
+                throw (MalformedURLException) e;
             }
         }
         return null;

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/XLink.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/XLink.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/XLink.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/XLink.java Wed Dec 12 09:56:36 2012
@@ -67,9 +67,9 @@ import org.apache.sis.internal.util.Obje
  * </table></blockquote>
  *
  * When {@code xlink} attributes are found at unmarshalling time instead of an object definition,
- * those attributes are given to the {@link ObjectLinker#resolve(Class, XLink)} method. Users can
- * override that method in order to fetch an instance in some catalog for the given {@code xlink}
- * values.
+ * those attributes are given to the {@link ReferenceResolver#resolve(MarshalContext, Class, XLink)}
+ * method. Users can override that method in order to fetch an instance in some catalog for the given
+ * {@code xlink} values.
  *
  * @author  Guilhem Legal (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
@@ -839,7 +839,7 @@ public class XLink implements Serializab
      */
     @Override
     public synchronized String toString() {
-        final StringBuilder buffer = new StringBuilder(32);
+        final StringBuilder buffer = new StringBuilder(64);
         buffer.append(Classes.getShortClassName(this)).append('[');
         append(buffer, "type",    getType());
         append(buffer, "href",    getHRef());

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/package-info.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/package-info.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/package-info.java Wed Dec 12 09:56:36 2012
@@ -53,7 +53,7 @@
  * <p>The most common namespace URLs are defined in the {@link org.apache.sis.xml.Namespaces} class.
  * The parsing of some objects like {@link java.net.URL} and {@link java.util.UUID},
  * together with the behavior in case of parsing error, can be specified by the
- * {@link org.apache.sis.xml.ObjectConverters} class.</p>
+ * {@link org.apache.sis.xml.ValueConverter} class.</p>
  *
  * @author  Cédric Briançon (Geomatys)
  * @author  Guilhem Legal (Geomatys)

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapAdapterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapAdapterTest.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapAdapterTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapAdapterTest.java Wed Dec 12 09:56:36 2012
@@ -44,7 +44,8 @@ import static org.apache.sis.xml.Identif
 public strictfp class IdentifierMapAdapterTest extends TestCase {
     /**
      * Creates the {@link IdentifierMapAdapter} instance to test for the given identifiers.
-     * Subclasses will override this method.
+     * This {@code IdentifierMapAdapterTest} class creates {@link IdentifierMapAdapter} instances.
+     * Subclasses will override this method in order to create instances of the class to test.
      *
      * @param  identifiers The identifiers to wrap in an {@code IdentifierMapAdapter}.
      * @return The {@code IdentifierMapAdapter} to test.
@@ -56,6 +57,8 @@ public strictfp class IdentifierMapAdapt
     /**
      * Asserts that the content of the given map is equals to the given content, represented
      * as a string. Subclasses can override this method in order to alter the expected string.
+     * This is needed when, using the "special case rules", {@code "href"} have been replaced
+     * be {@code "xlink:href"}.
      *
      * @param  expected The expected content.
      * @return The map to compare with the expected content.
@@ -82,59 +85,71 @@ public strictfp class IdentifierMapAdapt
     public void testGetAndPut() {
         final List<Identifier> identifiers = new ArrayList<Identifier>();
         final Map<Citation,String> map = create(identifiers);
-        assertTrue(map.isEmpty());
-        assertEquals(0, map.size());
-
-        identifiers.add(new IdentifierMapEntry(ID,   "myID"));
-        identifiers.add(new IdentifierMapEntry(UUID, "myUUID"));
-        assertFalse (map.isEmpty());
-        assertEquals(2, map.size());
-        assertEquals(2, identifiers.size());
-        assertTrue  (map.containsKey(ID));
-        assertTrue  (map.containsKey(UUID));
-        assertFalse (map.containsKey(HREF));
-        assertEquals("myID",   map.get(ID));
-        assertEquals("myUUID", map.get(UUID));
-        assertNull  (          map.get(HREF));
-        assertTrue  (map.containsValue("myID"));
-        assertTrue  (map.containsValue("myUUID"));
-        assertFalse (map.containsValue("myHREF"));
+        assertTrue  ("Newly created map shall be empty.", map.isEmpty());
+        assertEquals("Newly created map shall be empty.", 0, map.size());
+        /*
+         * Add two entries, then verify the map content.
+         */
+        assertTrue(identifiers.add(new IdentifierMapEntry(ID,   "myID")));
+        assertTrue(identifiers.add(new IdentifierMapEntry(UUID, "myUUID")));
+        assertFalse ("After add, map shall not be empty.", map.isEmpty());
+        assertEquals("After add, map shall not be empty.", 2, map.size());
+        assertEquals("After add, map shall not be empty.", 2, identifiers.size());
+        assertTrue  ("Shall contain the entry we added.",        map.containsKey(ID));
+        assertTrue  ("Shall contain the entry we added.",        map.containsKey(UUID));
+        assertFalse ("Shall not contain entry we didn't added.", map.containsKey(HREF));
+        assertTrue  ("Shall contain the entry we added.",        map.containsValue("myID"));
+        assertTrue  ("Shall contain the entry we added.",        map.containsValue("myUUID"));
+        assertFalse ("Shall not contain entry we didn't added.", map.containsValue("myHREF"));
+        assertEquals("Shall contain the entry we added.",        "myID",   map.get(ID));
+        assertEquals("Shall contain the entry we added.",        "myUUID", map.get(UUID));
+        assertNull  ("Shall not contain entry we didn't added.",           map.get(HREF));
         assertMapEquals("{gml:id=“myID”, gco:uuid=“myUUID”}", map);
-
-        assertEquals("myUUID", map.put(UUID, "myNewUUID"));
-        assertFalse (map.containsValue("myUUID"));
-        assertTrue  (map.containsValue("myNewUUID"));
+        /*
+         * Alter one entry (no new entry added).
+         */
+        assertEquals("Shall get the old value.",       "myUUID", map.put(UUID, "myNewUUID"));
+        assertFalse ("Shall not contain anymore the old value.", map.containsValue("myUUID"));
+        assertTrue  ("Shall contain the new value.",             map.containsValue("myNewUUID"));
         assertMapEquals("{gml:id=“myID”, gco:uuid=“myNewUUID”}", map);
-        assertEquals(2, map.size());
-        assertEquals(2, identifiers.size());
-
-        assertNull  (map.put(HREF, "myHREF"));
-        assertTrue  (map.containsValue("myHREF"));
-        assertTrue  (map.containsKey(HREF));
+        assertEquals("Map size shall be unchanged.", 2, map.size());
+        assertEquals("Map size shall be unchanged.", 2, identifiers.size());
+        /*
+         * Add a third identifier.
+         */
+        assertNull  ("Shall not contain entry we didn't added.", map.put(HREF, "myHREF"));
+        assertTrue  ("Shall contain the entry we added.",        map.containsValue("myHREF"));
+        assertTrue  ("Shall contain the entry we added.",        map.containsKey(HREF));
         assertMapEquals("{gml:id=“myID”, gco:uuid=“myNewUUID”, xlink:href=“myHREF”}", map);
-        assertEquals(3, map.size());
-        assertEquals(3, identifiers.size());
-
-        assertEquals("myNewUUID", map.remove(UUID));
-        assertFalse (map.containsValue("myNewUUID"));
-        assertFalse (map.containsKey(UUID));
+        assertEquals("Map size shall be updated.", 3, map.size());
+        assertEquals("Map size shall be updated.", 3, identifiers.size());
+        /*
+         * Remove an identifier using the Map.remove(…) API.
+         */
+        assertEquals("Shall get the old value.",   "myNewUUID", map.remove(UUID));
+        assertFalse ("Shall not contain the entry we removed.", map.containsValue("myNewUUID"));
+        assertFalse ("Shall not contain the entry we removed.", map.containsKey(UUID));
         assertMapEquals("{gml:id=“myID”, xlink:href=“myHREF”}", map);
-        assertEquals(2, map.size());
-        assertEquals(2, identifiers.size());
-
+        assertEquals("Map size shall be updated.", 2, map.size());
+        assertEquals("Map size shall be updated.", 2, identifiers.size());
+        /*
+         * Remove an identifier using the Set.remove(…) API on values.
+         */
         assertTrue  (map.values().remove(toHRefString("myHREF")));
-        assertFalse (map.containsValue("myHREF"));
-        assertFalse (map.containsKey(HREF));
+        assertFalse ("Shall not contain the entry we removed.", map.containsValue("myHREF"));
+        assertFalse ("Shall not contain the entry we removed.", map.containsKey(HREF));
         assertMapEquals("{gml:id=“myID”}", map);
-        assertEquals(1, map.size());
-        assertEquals(1, identifiers.size());
-
+        assertEquals("Map size shall be updated.", 1, map.size());
+        assertEquals("Map size shall be updated.", 1, identifiers.size());
+        /*
+         * Remove an identifier using the Set.remove(…) API on keys.
+         */
         assertTrue  (map.keySet().remove(ID));
-        assertFalse (map.containsValue("myID"));
-        assertFalse (map.containsKey(ID));
+        assertFalse ("Shall not contain the entry we removed.", map.containsValue("myID"));
+        assertFalse ("Shall not contain the entry we removed.", map.containsKey(ID));
         assertMapEquals("{}", map);
-        assertEquals(0, map.size());
-        assertEquals(0, identifiers.size());
+        assertEquals("Map size shall be updated.", 0, map.size());
+        assertEquals("Map size shall be updated.", 0, identifiers.size());
     }
 
     /**
@@ -148,9 +163,9 @@ public strictfp class IdentifierMapAdapt
         final java.util.UUID myUUID = fromString("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7");
         final URI myURI = URI.create("http://mylink");
 
-        map.putSpecialized(ID,   myID);
-        map.putSpecialized(UUID, myUUID);
-        map.putSpecialized(HREF, myURI);
+        assertNull(map.putSpecialized(ID,   myID));
+        assertNull(map.putSpecialized(UUID, myUUID));
+        assertNull(map.putSpecialized(HREF, myURI));
         assertMapEquals("{gml:id=“myID”,"
                 + " gco:uuid=“a1eb6e53-93db-4942-84a6-d9e7fb9db2c7”,"
                 + " xlink:href=“http://mylink”}", map);
@@ -171,9 +186,9 @@ public strictfp class IdentifierMapAdapt
         final List<Identifier> identifiers = new ArrayList<Identifier>();
         final IdentifierMap map = create(identifiers);
 
-        map.put(ID,   "myID");
-        map.put(UUID, "a1eb6e53-93db-4942-84a6-d9e7fb9db2c7");
-        map.put(HREF, "http://mylink");
+        assertNull(map.put(ID,   "myID"));
+        assertNull(map.put(UUID, "a1eb6e53-93db-4942-84a6-d9e7fb9db2c7"));
+        assertNull(map.put(HREF, "http://mylink"));
         assertMapEquals("{gml:id=“myID”,"
                 + " gco:uuid=“a1eb6e53-93db-4942-84a6-d9e7fb9db2c7”,"
                 + " xlink:href=“http://mylink”}", map);
@@ -192,9 +207,9 @@ public strictfp class IdentifierMapAdapt
     @Test
     public void testDuplicatedAuthorities() {
         final List<Identifier> identifiers = new ArrayList<Identifier>();
-        identifiers.add(new IdentifierMapEntry(ID,   "myID1"));
-        identifiers.add(new IdentifierMapEntry(UUID, "myUUID"));
-        identifiers.add(new IdentifierMapEntry(ID,   "myID2"));
+        assertTrue(identifiers.add(new IdentifierMapEntry(ID,   "myID1")));
+        assertTrue(identifiers.add(new IdentifierMapEntry(UUID, "myUUID")));
+        assertTrue(identifiers.add(new IdentifierMapEntry(ID,   "myID2")));
 
         final IdentifierMap map = create(identifiers);
         assertEquals("Duplicated authorities shall be filtered.", 2, map.size());
@@ -225,8 +240,8 @@ public strictfp class IdentifierMapAdapt
 
         final List<Identifier> identifiers = new ArrayList<Identifier>();
         final Map<Citation,String> map = create(identifiers);
-        identifiers.add(new IdentifierMapEntry(ID,   "myID"));
-        identifiers.add(new IdentifierMapEntry(UUID, "myUUID"));
+        assertTrue(identifiers.add(new IdentifierMapEntry(ID,   "myID")));
+        assertTrue(identifiers.add(new IdentifierMapEntry(UUID, "myUUID")));
 
         final Map<Citation,String> copy = assertSerializedEquals(map);
         assertNotSame(map, copy);

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java Wed Dec 12 09:56:36 2012
@@ -21,6 +21,7 @@ import java.util.Map;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.UUID;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Citation;
 import org.apache.sis.xml.IdentifierMap;
@@ -49,19 +50,20 @@ public final strictfp class IdentifierMa
     private static final String TO_REPLACE = "xlink:href=“";
 
     /**
-     * Creates the {@link IdentifierMapAdapter} instance to test for the given identifiers.
+     * Creates the {@link IdentifierMapWithSpecialCases} instance to test for the given identifiers.
      *
      * @param  identifiers The identifiers to wrap in an {@code IdentifierMapAdapter}.
      * @return The {@code IdentifierMapAdapter} to test.
      */
     @Override
     IdentifierMapAdapter create(final Collection<Identifier> identifiers) {
-        return new IdentifierMapWithSpecialCases(identifiers);
+        return new IdentifierMapWithSpecialCases(identifiers, null);
     }
 
     /**
-     * Replaces the {@code xlink:href} value by the {@link XLink#toString()} value
-     * before to compare with the map content.
+     * Replaces the {@code xlink:href} value by the {@link XLink#toString()} value before
+     * to compare with the map content. This is needed because the "special case rules"
+     * cause the {@code "href"} identifier to be replaced by {@code "xlink:href"}.
      */
     @Override
     void assertMapEquals(String expected, final Map<Citation,String> map) {
@@ -91,19 +93,42 @@ public final strictfp class IdentifierMa
      * Tests explicitely the special handling of {@code href} values.
      */
     @Test
-    public void testSpecialCases() {
+    public void testHRefSubstitution() {
         final List<Identifier> identifiers = new ArrayList<Identifier>();
         final IdentifierMap map = create(identifiers);
-        map.put(IdentifierSpace.HREF, "myHREF");
-        assertEquals("myHREF", map.get(IdentifierSpace.HREF));
+        assertNull(map.put(IdentifierSpace.HREF, "myHREF"));
+        assertEquals("Shall contain the entry we added.", "myHREF", map.get(IdentifierSpace.HREF));
 
         // Check the XLink object
         final XLink link = map.getSpecialized(IdentifierSpace.XLINK);
-        assertEquals("myHREF", String.valueOf(link.getHRef()));
-        assertEquals(link.toString(), getSingleton(identifiers).getCode());
+        assertEquals("Added href shall be stored as XLink attribute.", "myHREF", String.valueOf(link.getHRef()));
+        assertEquals("Identifier list shall contain the XLink.", link.toString(), getSingleton(identifiers).getCode());
 
         // Modidfy the XLink object directly
         link.setHRef(URI.create("myNewHREF"));
-        assertEquals("myNewHREF", map.get(IdentifierSpace.HREF));
+        assertEquals("Change in XLink shall be reflected in href.", "myNewHREF", map.get(IdentifierSpace.HREF));
+    }
+
+    /**
+     * Tests the binding of UUID.
+     */
+    @Test
+    public void testUUIDs() {
+        final String object = "IdentifiedObject";
+        final List<Identifier> identifiers = new ArrayList<Identifier>();
+        final IdentifierMap map = new IdentifierMapWithSpecialCases(identifiers, object);
+        final UUID id1 = UUID.fromString("434f3107-c6d2-4c8c-bb25-553f68641c5c");
+        final UUID id2 = UUID.fromString("42924124-032a-4dfe-b06e-113e3cb81cf0");
+
+        // Add first UUID.
+        assertNull("Shall not contain UUID before put.", UUIDs.lookup(id1));
+        assertNull(map.putSpecialized(IdentifierSpace.UUID, id1));
+        assertSame("Object sholl be associated to UUID.", object, UUIDs.lookup(id1));
+
+        // Replace UUID by a new one.
+        assertNull("Shall not contain UUID before put.", UUIDs.lookup(id2));
+        assertSame(id1, map.putSpecialized(IdentifierSpace.UUID, id2));
+        assertNull("Shall not contain the removed UUID.", UUIDs.lookup(id1));
+        assertSame("Object sholl be associated to UUID.", object, UUIDs.lookup(id2));
     }
 }

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/measure/AngleFormatTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/measure/AngleFormatTest.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/measure/AngleFormatTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/measure/AngleFormatTest.java Wed Dec 12 09:56:36 2012
@@ -210,7 +210,7 @@ public final strictfp class AngleFormatT
     public void testFieldPosition() {
         final Latitude latitude = new Latitude(FormattedCharacterIteratorTest.LATITUDE_VALUE);
         final AngleFormat f = new AngleFormat("DD°MM′SS.s″", Locale.CANADA);
-        final StringBuffer buffer = new StringBuffer(12);
+        final StringBuffer buffer = new StringBuffer();
         for (int i=AngleFormat.DEGREES_FIELD; i<=AngleFormat.HEMISPHERE_FIELD; i++) {
             final AngleFormat.Field field;
             final int start, limit;

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java Wed Dec 12 09:56:36 2012
@@ -260,8 +260,6 @@ public final strictfp class UnitsTest ex
 
     /**
      * Tests {@link Units#valueOfEPSG(int)}.
-     *
-     * @since 3.20
      */
     @Test
     public void testValueOfEPSG() {

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java Wed Dec 12 09:56:36 2012
@@ -68,6 +68,11 @@ public final strictfp class TestUtilitie
     };
 
     /**
+     * The thread group for every threads created for testing purpose.
+     */
+    public static final ThreadGroup THREADS = new ThreadGroup("SIS-Tests");
+
+    /**
      * Do not allow instantiation of this class.
      */
     private TestUtilities() {

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java Wed Dec 12 09:56:36 2012
@@ -29,54 +29,58 @@ import org.junit.runners.Suite;
  * @module
  */
 @Suite.SuiteClasses({
-  // Following are testing the test tools.
-  org.apache.sis.internal.test.AssertTest.class,
-  org.apache.sis.internal.test.XMLComparatorTest.class,
+    // Following are testing the test tools.
+    org.apache.sis.internal.test.AssertTest.class,
+    org.apache.sis.internal.test.XMLComparatorTest.class,
 
-  // Most basic functions of SIS library.
-  org.apache.sis.util.ArraysTest.class,
-  org.apache.sis.util.CharactersTest.class,
-  org.apache.sis.util.CharSequencesTest.class,
-  org.apache.sis.util.StringBuildersTest.class,
-  org.apache.sis.util.UtilitiesTest.class,
-  org.apache.sis.util.VersionTest.class,
-  org.apache.sis.util.LocalesTest.class,
-  org.apache.sis.util.resources.IndexedResourceBundleTest.class,
-  org.apache.sis.util.logging.PerformanceLevelTest.class,
-  org.apache.sis.math.MathFunctionsTest.class,
-  org.apache.sis.math.StatisticsTest.class,
+    // Most basic functions of SIS library.
+    org.apache.sis.util.ArraysTest.class,
+    org.apache.sis.util.CharactersTest.class,
+    org.apache.sis.util.CharSequencesTest.class,
+    org.apache.sis.util.StringBuildersTest.class,
+    org.apache.sis.util.UtilitiesTest.class,
+    org.apache.sis.util.ClassesTest.class,
+    org.apache.sis.util.VersionTest.class,
+    org.apache.sis.util.LocalesTest.class,
+    org.apache.sis.util.resources.IndexedResourceBundleTest.class,
+    org.apache.sis.util.logging.PerformanceLevelTest.class,
+    org.apache.sis.math.MathFunctionsTest.class,
+    org.apache.sis.math.StatisticsTest.class,
 
-  // Collections.
-  org.apache.sis.internal.util.ReferenceQueueConsumerTest.class,
-  org.apache.sis.util.collection.WeakHashSetTest.class,
-  org.apache.sis.util.collection.WeakValueHashMapTest.class,
-  org.apache.sis.util.collection.CacheTest.class,
-  org.apache.sis.util.collection.DerivedSetTest.class,
-  org.apache.sis.util.collection.DerivedMapTest.class,
-  org.apache.sis.util.collection.TableColumnTest.class,
-  org.apache.sis.util.collection.DefaultTreeTableTest.class,
+    // Collections.
+    org.apache.sis.internal.util.ReferenceQueueConsumerTest.class,
+    org.apache.sis.util.collection.WeakHashSetTest.class,
+    org.apache.sis.util.collection.WeakValueHashMapTest.class,
+    org.apache.sis.util.collection.CacheTest.class,
+    org.apache.sis.util.collection.DerivedSetTest.class,
+    org.apache.sis.util.collection.DerivedMapTest.class,
+    org.apache.sis.util.collection.TableColumnTest.class,
+    org.apache.sis.util.collection.DefaultTreeTableTest.class,
 
-  // GeoAPI most basic types.
-  org.apache.sis.util.type.TypesTest.class,
-  org.apache.sis.util.type.SimpleInternationalStringTest.class,
-  org.apache.sis.util.type.DefaultInternationalStringTest.class,
-  org.apache.sis.internal.util.LocalizedParseExceptionTest.class,
+    // GeoAPI most basic types.
+    org.apache.sis.util.iso.TypesTest.class,
+    org.apache.sis.util.iso.CodeListsTest.class,
+    org.apache.sis.util.iso.SimpleInternationalStringTest.class,
+    org.apache.sis.util.iso.DefaultInternationalStringTest.class,
+    org.apache.sis.internal.util.LocalizedParseExceptionTest.class,
+    org.apache.sis.util.iso.AbstractNameTest.class,
+    org.apache.sis.util.iso.DefaultNameFactoryTest.class,
 
-  // Measurements and formatting.
-  org.apache.sis.measure.UnitsTest.class,
-  org.apache.sis.measure.FormattedCharacterIteratorTest.class,
-  org.apache.sis.measure.AngleFormatTest.class,
-  org.apache.sis.measure.AngleTest.class,
-  org.apache.sis.internal.util.X364Test.class,
-  org.apache.sis.io.LineFormatterTest.class,
-  org.apache.sis.io.TableFormatterTest.class,
-  org.apache.sis.util.collection.TreeTableFormatTest.class,
+    // Measurements and formatting.
+    org.apache.sis.measure.UnitsTest.class,
+    org.apache.sis.measure.FormattedCharacterIteratorTest.class,
+    org.apache.sis.measure.AngleFormatTest.class,
+    org.apache.sis.measure.AngleTest.class,
+    org.apache.sis.internal.util.X364Test.class,
+    org.apache.sis.io.LineFormatterTest.class,
+    org.apache.sis.io.TableFormatterTest.class,
+    org.apache.sis.util.collection.TreeTableFormatTest.class,
 
-  // XML most basic types.
-  org.apache.sis.xml.XLinkTest.class,
-  org.apache.sis.xml.NilReasonTest.class,
-  org.apache.sis.internal.jaxb.IdentifierMapAdapterTest.class,
-  org.apache.sis.internal.jaxb.IdentifierMapWithSpecialCasesTest.class
+    // XML most basic types.
+    org.apache.sis.xml.XLinkTest.class,
+    org.apache.sis.xml.NilReasonTest.class,
+    org.apache.sis.internal.jaxb.IdentifierMapAdapterTest.class,
+    org.apache.sis.internal.jaxb.IdentifierMapWithSpecialCasesTest.class
 })
 public final strictfp class UtilityTestSuite extends TestSuite {
 }

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java Wed Dec 12 09:56:36 2012
@@ -21,7 +21,7 @@ import java.nio.CharBuffer;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.DependsOnMethod;
-import org.apache.sis.util.type.SimpleInternationalString;
+import org.apache.sis.util.iso.SimpleInternationalString;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
@@ -37,7 +37,10 @@ import static org.apache.sis.util.CharSe
  * @version 0.3
  * @module
  */
-@DependsOn(ArraysTest.class)
+@DependsOn({
+    ArraysTest.class,
+    CharactersTest.class
+})
 public final strictfp class CharSequencesTest extends TestCase {
     /**
      * Tests {@link CharSequences#spaces(int)}.
@@ -312,12 +315,12 @@ public final strictfp class CharSequence
     }
 
     /**
-     * Tests the {@link CharSequences#isJavaIdentifier(CharSequence)} method.
+     * Tests the {@link CharSequences#isUnicodeIdentifier(CharSequence)} method.
      */
     @Test
-    public void testIsJavaIdentifier() {
-        assertTrue ("A123", isJavaIdentifier("A123"));
-        assertFalse("123A", isJavaIdentifier("123A"));
+    public void testIsUnicodeIdentifier() {
+        assertTrue ("A123", isUnicodeIdentifier("A123"));
+        assertFalse("123A", isUnicodeIdentifier("123A"));
     }
 
     /**
@@ -325,9 +328,9 @@ public final strictfp class CharSequence
      */
     @Test
     public void testIsUpperCase() {
-        assertTrue ("ABC", isUpperCase("ABC"));
-        assertFalse("AbC", isUpperCase("AbC"));
-        assertFalse("A2C", isUpperCase("A2C"));
+        assertTrue ("ABC", isUpperCase("ABC", 0, 3));
+        assertFalse("AbC", isUpperCase("AbC", 0, 3));
+        assertFalse("A2C", isUpperCase("A2C", 0, 3));
     }
 
     /**
@@ -341,6 +344,19 @@ public final strictfp class CharSequence
     }
 
     /**
+     * Tests the {@link CharSequences#equalsFiltered(CharSequence, CharSequence, Characters.Filter, boolean)} method.
+     */
+    @Test
+    public void testEqualsFiltered() {
+        assertTrue (equalsFiltered(" UTF-8 ", "utf8",  Characters.Filter.LETTERS_AND_DIGITS, true));
+        assertFalse(equalsFiltered(" UTF-8 ", "utf8",  Characters.Filter.LETTERS_AND_DIGITS, false));
+        assertTrue (equalsFiltered("UTF-8", " utf 8",  Characters.Filter.LETTERS_AND_DIGITS, true));
+        assertFalse(equalsFiltered("UTF-8", " utf 16", Characters.Filter.LETTERS_AND_DIGITS, true));
+        assertTrue (equalsFiltered("WGS84", "WGS_84",  Characters.Filter.LETTERS_AND_DIGITS, true));
+        assertFalse(equalsFiltered("WGS84", "WGS_84",  Characters.Filter.UNICODE_IDENTIFIER, true));
+    }
+
+    /**
      * Tests the {@link CharSequences#equals(CharSequence, CharSequence)} method.
      */
     @Test

Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java?rev=1420597&r1=1420596&r2=1420597&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java Wed Dec 12 09:56:36 2012
@@ -92,4 +92,52 @@ public final strictfp class CharactersTe
         assertEquals(c, toNormalScript(c));
         assertFalse(isSubScript(c));
     }
+
+    /**
+     * Tests the pre-defined {@link Characters.Filter} constants.
+     */
+    @Test
+    public void testPredefinedFilters() {
+        assertTrue (Filter.UNICODE_IDENTIFIER.contains('a'));
+        assertTrue (Filter.LETTERS_AND_DIGITS.contains('a'));
+        assertTrue (Filter.UNICODE_IDENTIFIER.contains('_'));
+        assertFalse(Filter.LETTERS_AND_DIGITS.contains('_'));
+        assertFalse(Filter.UNICODE_IDENTIFIER.contains(' '));
+        assertFalse(Filter.LETTERS_AND_DIGITS.contains(' '));
+    }
+
+    /**
+     * Tests the {@link Characters.Filter#forTypes(byte[])} method.
+     */
+    @Test
+    public void testFilterForTypes() {
+        final Filter filter = Filter.forTypes(Character.SPACE_SEPARATOR, Character.DECIMAL_DIGIT_NUMBER);
+        assertTrue (filter.contains('0'));
+        assertTrue (filter.contains(' '));
+        assertFalse(filter.contains('A'));
+    }
+
+    /**
+     * Scans the full {@code char} range in order to check for {@link Character.Filter} consistency.
+     */
+    @Test
+    public void scanCharacterRange() {
+        for (int c=Character.MIN_VALUE; c<=Character.MAX_VALUE; c++) {
+            final int type = Character.getType(c);
+predefined: for (int i=0; ; i++) {
+                final Characters.Filter filter;
+                switch (i) {
+                    case 0:  filter = Filter.UNICODE_IDENTIFIER; break;
+                    case 1:  filter = Filter.LETTERS_AND_DIGITS; break;
+                    default: break predefined;
+                }
+                final boolean cc = filter.contains(c);
+                final boolean ct = filter.containsType(type);
+                if (cc != ct) {
+                    fail(filter + ".contains('" + (char) c + "') == " + cc + " but "
+                            + filter + ".containsType(" + type + ") == " + ct);
+                }
+            }
+        }
+    }
 }



Mime
View raw message