sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1625094 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/ si...
Date Mon, 15 Sep 2014 16:35:55 GMT
Author: desruisseaux
Date: Mon Sep 15 16:35:55 2014
New Revision: 1625094

URL: http://svn.apache.org/r1625094
Log:
ServiceParameter shall infer the ReferenceIdentifier from the MemberName.
This is the reverse of the "MemberName to Identifier" mapping done previously.

Added:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java
      - copied, changed from r1624413, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NameToIdentifier.java
Removed:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NameToIdentifier.java
Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java?rev=1625094&r1=1625093&r2=1625094&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java
[UTF-8] Mon Sep 15 16:35:55 2014
@@ -23,6 +23,9 @@ import org.opengis.referencing.Reference
 import org.apache.sis.internal.simple.SimpleIdentifiedObject;
 import org.apache.sis.util.ComparisonMode;
 
+// Branch-dependent imports
+import java.util.Objects;
+
 
 /**
  * An implementation of {@link ReferenceSystem} marshalled as specified in ISO 19115.
@@ -81,7 +84,7 @@ public class ReferenceSystemMetadata ext
      */
     @Override
     @XmlElement(name = "referenceSystemIdentifier")
-    public ReferenceIdentifier getName() {
+    public final ReferenceIdentifier getName() {
         return super.getName();
     }
 
@@ -90,7 +93,7 @@ public class ReferenceSystemMetadata ext
      *
      * @param name The new primary name.
      */
-    public void setName(final ReferenceIdentifier name) {
+    public final void setName(final ReferenceIdentifier name) {
         this.name = name;
     }
 
@@ -103,6 +106,14 @@ public class ReferenceSystemMetadata ext
      */
     @Override
     public boolean equals(final Object object, final ComparisonMode mode) {
-        return super.equals(object, mode) && (object instanceof ReferenceSystem);
+        if (super.equals(object, mode) && (object instanceof ReferenceSystem)) {
+            final ReferenceSystem that = (ReferenceSystem) object;
+            if (mode.ordinal() >= ComparisonMode.IGNORE_METADATA.ordinal()) {
+                // Compare the name because it was ignored by super.equals(…) in "ignore
metadata" mode.
+                return Objects.equals(getName(), that.getName());
+            }
+            return that.getDomainOfValidity() == null && that.getScope() == null;
+        }
+        return false;
     }
 }

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java?rev=1625094&r1=1625093&r2=1625094&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java
[UTF-8] Mon Sep 15 16:35:55 2014
@@ -32,14 +32,17 @@ import org.opengis.parameter.ParameterDe
 import org.opengis.referencing.ReferenceIdentifier;
 import org.apache.sis.internal.simple.SimpleIdentifiedObject;
 import org.apache.sis.internal.jaxb.metadata.direct.GO_MemberName;
+import org.apache.sis.internal.metadata.NameToIdentifier;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.iso.Names;
 import org.apache.sis.xml.Namespaces;
 
+import static org.apache.sis.util.Utilities.deepEquals;
 import static org.apache.sis.internal.util.CollectionsExt.nonNull;
 import static org.apache.sis.internal.jaxb.gco.PropertyType.LEGACY_XML;
 
-import static org.apache.sis.util.Utilities.deepEquals;
+// Branch-dependent imports
+import java.util.Objects;
 
 
 /**
@@ -197,12 +200,12 @@ public final class ServiceParameter exte
      * @return The parameter name as an identifier (the type specified by ISO 19111).
      */
     @Override
-    public ReferenceIdentifier getName() {
+    public synchronized ReferenceIdentifier getName() {
         if (name == null && memberName != null) {
             if (memberName instanceof ReferenceIdentifier) {
                 name = (ReferenceIdentifier) memberName;
             } else {
-                // TODO: name = new NameToIdentifier(memberName);
+                name = new NameToIdentifier(memberName);
             }
         }
         return name;
@@ -323,9 +326,10 @@ public final class ServiceParameter exte
                 that.getValueClass()   == getValueClass())
             {
                 if (mode.ordinal() >= ComparisonMode.IGNORE_METADATA.ordinal()) {
-                    return true;
+                    return Objects.equals(toString(getName()), toString(that.getName()));
                 }
                 return deepEquals(that.getDescription(), getDescription(), mode) &&
+                       that.getDirection()     == getDirection()     &&
                        that.getMinimumOccurs() == getMinimumOccurs() &&
                        that.getMaximumOccurs() == getMaximumOccurs() &&
                        that.getValidValues()   == null &&
@@ -335,4 +339,12 @@ public final class ServiceParameter exte
         }
         return false;
     }
+
+    /**
+     * Null-safe string representation of the given identifier, for comparison purpose.
+     * We ignore codespace because they can not be represented in ISO 19139 XML documents.
+     */
+    private static String toString(final ReferenceIdentifier identifier) {
+        return (identifier != null) ? identifier.toString() : null;
+    }
 }

Copied: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java
(from r1624413, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NameToIdentifier.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java?p2=sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java&p1=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NameToIdentifier.java&r1=1624413&r2=1625094&rev=1625094&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/NameToIdentifier.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java
[UTF-8] Mon Sep 15 16:35:55 2014
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.referencing;
+package org.apache.sis.internal.metadata;
 
 import java.util.Locale;
 import org.opengis.util.NameSpace;
@@ -23,18 +23,21 @@ import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.referencing.ReferenceIdentifier;
-import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.util.iso.DefaultNameSpace;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 
+// Branch-dependent imports
+import java.util.Objects;
+
 
 /**
  * Does the unobvious mapping between {@link ReferenceIdentifier} properties and {@link GenericName}
ones.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.5
  * @module
  */
 public final class NameToIdentifier implements ReferenceIdentifier {
@@ -131,13 +134,43 @@ public final class NameToIdentifier impl
     }
 
     /**
+     * Returns a hash code value for this object.
+     */
+    @Override
+    public int hashCode() {
+        return ~Objects.hashCode(name);
+    }
+
+    /**
+     * Compares this object with the given one for equality.
+     *
+     * @param object The object to compare with this identifier.
+     * @return {@code true} if both objects are equal.
+     */
+    @Override
+    public boolean equals(final Object object) {
+        if (object == this) {
+            return true;
+        }
+        if (object != null && object.getClass() == getClass()) {
+            return Objects.equals(name, ((NameToIdentifier) object).name);
+        }
+        return false;
+    }
+
+    /**
      * Returns the string representation of this identifier.
      *
      * @return The string representation of this identifier.
      */
     @Override
     public String toString() {
-        return IdentifiedObjects.toString(this);
+        final String code = getCode();
+        final String cs = getCodeSpace();
+        if (cs != null && !cs.isEmpty()) {
+            return cs + DefaultNameSpace.DEFAULT_SEPARATOR + code;
+        }
+        return code;
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java?rev=1625094&r1=1625093&r2=1625094&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/service/DefaultServiceIdentificationTest.java
[UTF-8] Mon Sep 15 16:35:55 2014
@@ -19,6 +19,7 @@ package org.apache.sis.metadata.iso.serv
 import javax.xml.bind.JAXBException;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.service.CouplingType;
+import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.xml.NilReason;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.XMLTestCase;
@@ -83,6 +84,6 @@ public final strictfp class DefaultServi
      */
     @Test
     public void testUnmarshal() throws JAXBException {
-        assertEquals(create(), unmarshalFile(DefaultServiceIdentification.class, XML_FILE));
+        assertTrue(create().equals(unmarshalFile(DefaultServiceIdentification.class, XML_FILE),
ComparisonMode.DEBUG));
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java?rev=1625094&r1=1625093&r2=1625094&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
[UTF-8] Mon Sep 15 16:35:55 2014
@@ -50,7 +50,7 @@ import org.apache.sis.util.ArgumentCheck
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.resources.Vocabulary;
 import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.internal.referencing.NameToIdentifier;
+import org.apache.sis.internal.metadata.NameToIdentifier;
 import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.internal.util.X364;
 

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java?rev=1625094&r1=1625093&r2=1625094&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
[UTF-8] Mon Sep 15 16:35:55 2014
@@ -38,7 +38,7 @@ import org.apache.sis.io.wkt.Colors;
 import org.apache.sis.io.wkt.ElementKind;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.RangeFormat;
-import org.apache.sis.internal.referencing.NameToIdentifier;
+import org.apache.sis.internal.metadata.NameToIdentifier;
 import org.apache.sis.internal.util.X364;
 
 import static org.apache.sis.internal.util.X364.*;

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java?rev=1625094&r1=1625093&r2=1625094&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
[UTF-8] Mon Sep 15 16:35:55 2014
@@ -32,7 +32,7 @@ import org.opengis.metadata.citation.Cit
 import org.opengis.metadata.Identifier;
 import org.opengis.referencing.ReferenceIdentifier;
 import org.opengis.parameter.InvalidParameterValueException;
-import org.apache.sis.internal.referencing.NameToIdentifier;
+import org.apache.sis.internal.metadata.NameToIdentifier;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.metadata.iso.ImmutableIdentifier;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java?rev=1625094&r1=1625093&r2=1625094&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java
[UTF-8] Mon Sep 15 16:35:55 2014
@@ -31,7 +31,10 @@ import org.apache.sis.util.iso.DefaultNa
 import org.apache.sis.util.LenientComparable;
 import org.apache.sis.util.ComparisonMode;
 
-import static org.apache.sis.util.Utilities.deepEquals;
+import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
+
+// Branch-dependent imports
+import java.util.Objects;
 
 
 /**
@@ -42,6 +45,8 @@ import static org.apache.sis.util.Utilit
  * @since   0.5 (derived from geotk-3.00)
  * @version 0.3
  * @module
+ *
+ * @see org.apache.sis.referencing.AbstractIdentifiedObject
  */
 public class SimpleIdentifiedObject implements IdentifiedObject, LenientComparable, Serializable
{
     /**
@@ -93,10 +98,13 @@ public class SimpleIdentifiedObject impl
      * Method required by the {@link IdentifiedObject} interface.
      * Current implementation returns an empty set.
      *
+     * <p>If a future version allows this method to returns a non-empty set,
+     * revisit {@link #equals(Object, ComparisonMode)}.</p>
+     *
      * @return The identifiers, or an empty set if none.
      */
     @Override
-    public Set<ReferenceIdentifier> getIdentifiers() {
+    public final Set<ReferenceIdentifier> getIdentifiers() {
         return Collections.emptySet();
     }
 
@@ -104,10 +112,13 @@ public class SimpleIdentifiedObject impl
      * Method required by the {@link IdentifiedObject} interface.
      * Current implementation returns an empty set.
      *
+     * <p>If a future version allows this method to returns a non-empty set,
+     * revisit {@link #equals(Object, ComparisonMode)}.</p>
+     *
      * @return The aliases, or an empty set if none.
      */
     @Override
-    public Collection<GenericName> getAlias() {
+    public final Collection<GenericName> getAlias() {
         return Collections.emptySet();
     }
 
@@ -115,9 +126,12 @@ public class SimpleIdentifiedObject impl
      * Method required by most {@link IdentifiedObject} sub-interfaces.
      * Current implementation returns {@code null}.
      *
+     * <p>If a future version allows this method to returns a non-null value,
+     * revisit {@link #equals(Object, ComparisonMode)} in subclasses.</p>
+     *
      * @return The domain of validity, or {@code null} if none.
      */
-    public Extent getDomainOfValidity() {
+    public final Extent getDomainOfValidity() {
         return null;
     }
 
@@ -125,9 +139,12 @@ public class SimpleIdentifiedObject impl
      * Method required by most {@link IdentifiedObject} sub-interfaces.
      * Current implementation returns {@code null}.
      *
+     * <p>If a future version allows this method to returns a non-null value,
+     * revisit {@link #equals(Object, ComparisonMode)} in subclasses.</p>
+     *
      * @return The scope, or {@code null} if none.
      */
-    public InternationalString getScope() {
+    public final InternationalString getScope() {
         return null;
     }
 
@@ -135,10 +152,13 @@ public class SimpleIdentifiedObject impl
      * Method required by the {@link IdentifiedObject} interface.
      * Current implementation returns {@code null}.
      *
+     * <p>If a future version allows this method to returns a non-null value,
+     * revisit {@link #equals(Object, ComparisonMode)}.</p>
+     *
      * @return The remarks, or {@code null} if none.
      */
     @Override
-    public InternationalString getRemarks() {
+    public final InternationalString getRemarks() {
         return null;
     }
 
@@ -148,7 +168,7 @@ public class SimpleIdentifiedObject impl
     @Override
     public final int hashCode() {
         int code = (int) serialVersionUID;
-        final ReferenceIdentifier name = this.name;
+        final ReferenceIdentifier name = getName();
         if (name != null) {
             code ^= name.hashCode();
         }
@@ -168,6 +188,9 @@ public class SimpleIdentifiedObject impl
 
     /**
      * Compares this object with the given one for equality.
+     * This method compares the {@linkplain #name} only in "strict" or "by contract" modes.
+     * If name is a critical component of this object, then it shall be compared by the subclass.
+     * This behavior is consistent with {@link org.apache.sis.referencing.AbstractIdentifiedObject}.
      *
      * @param  object The object to compare with this reference system.
      * @param  mode The strictness level of the comparison.
@@ -181,14 +204,13 @@ public class SimpleIdentifiedObject impl
         if (object instanceof IdentifiedObject) {
             if (mode != ComparisonMode.STRICT || object.getClass() == getClass()) {
                 final IdentifiedObject that = (IdentifiedObject) object;
-                if (deepEquals(getName(), that.getName(), mode)) {
-                    if (mode.ordinal() >= ComparisonMode.IGNORE_METADATA.ordinal()) {
-                        return true;
-                    }
-                    return deepEquals(getAlias(),       that.getAlias(),       mode) &&
-                           deepEquals(getIdentifiers(), that.getIdentifiers(), mode) &&
-                           deepEquals(getRemarks(),     that.getRemarks(),     mode);
+                if (mode.ordinal() >= ComparisonMode.IGNORE_METADATA.ordinal()) {
+                    return true;
                 }
+                return Objects.equals(getName(), that.getName()) &&
+                        isNullOrEmpty(that.getIdentifiers()) &&
+                        isNullOrEmpty(that.getAlias()) &&
+                        that.getRemarks() == null;
             }
         }
         return false;
@@ -222,7 +244,7 @@ public class SimpleIdentifiedObject impl
             codespace = null;
             authority = null;
         }
-        final StringBuilder buffer = new StringBuilder("OBJECT[\"");
+        final StringBuilder buffer = new StringBuilder("IdentifiedObject[\"");
         if (codespace != null) {
             buffer.append(codespace).append(DefaultNameSpace.DEFAULT_SEPARATOR);
         }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java?rev=1625094&r1=1625093&r2=1625094&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java [UTF-8]
Mon Sep 15 16:35:55 2014
@@ -22,6 +22,7 @@ import java.util.Collection;
 import java.util.LinkedList;
 import java.util.Map;
 import java.util.Set;
+import org.apache.sis.util.collection.CheckedContainer;
 
 // Branch-dependent imports
 import java.util.Objects;
@@ -229,7 +230,7 @@ public final class Utilities extends Sta
         final Iterator<?> it2 = object2.iterator();
         while (it1.hasNext()) {
             if (!it2.hasNext()) {
-                assert isNotDebug(mode) : "Sizes not equal";
+                assert isNotDebug(mode) : mismatchedElement("Iterable", object1, object2,
"size");
                 return false;
             }
             Object element1 = it1.next();
@@ -238,7 +239,7 @@ public final class Utilities extends Sta
                 continue;
             }
             if (!(object1 instanceof Set<?> && object2 instanceof Set<?>))
{
-                assert isNotDebug(mode) : "Lists not equal";
+                assert isNotDebug(mode) : mismatchedElement("Iterable", object1, object2,
"element");
                 return false;
             }
             /*
@@ -258,7 +259,7 @@ public final class Utilities extends Sta
             while (true) {
                 final Iterator<?> it = copy.iterator();
                 do if (!it.hasNext()) {
-                    assert isNotDebug(mode) : "Sets not equal";
+                    assert isNotDebug(mode) : mismatchedElement("Set", object1, object2,
"element");
                     return false; // An element has not been found.
                 } while (!deepEquals(it.next(), element2, mode));
                 it.remove();
@@ -293,6 +294,20 @@ public final class Utilities extends Sta
     }
 
     /**
+     * Returns an assertion error message for mismatched collections.
+     */
+    private static String mismatchedElement(final String header, final Iterable<?>
object1, final Iterable<?> object2, final String tail) {
+        Class<?> type = null;
+        if (object1 instanceof CheckedContainer<?>) {
+            type = ((CheckedContainer<?>) object1).getElementType();
+        }
+        if (type == null && object2 instanceof CheckedContainer<?>) {
+            type = ((CheckedContainer<?>) object2).getElementType();
+        }
+        return header + '<' + (type != null ? type.getSimpleName() : "?") + ">: " +
tail + " not equals.";
+    }
+
+    /**
      * Returns a hash code for the specified object, which may be an array.
      * This method returns one of the following values:
      *

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java?rev=1625094&r1=1625093&r2=1625094&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java
[UTF-8] Mon Sep 15 16:35:55 2014
@@ -115,12 +115,13 @@ final class TypeNames {
             } while (base != Boolean.class); // See MAPPING javadoc for the role of Boolean
as a sentinel value.
             /*
              * Found no special case. Checks for the UML annotation, to be also formatted
in the "OGC:" namespace.
-             * If no UML identifier is found, then we will format the Java class in the "class:"
namespace.
+             * If no UML identifier is found, then we will format the Java class in the "class:"
namespace. We use
+             * Class.getName() - not Class.getCanonicalName() - because we want a name readable
by Class.forName(…).
              */
             name = Types.getStandardName(valueClass);
             if (name == null) {
                 ns = classNS;
-                name = valueClass.getCanonicalName();
+                name = valueClass.getName(); // See above comment.
             }
         }
         /*



Mime
View raw message