sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1519828 - in /sis/trunk: ./ core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/ core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ core/sis-build-helper/src/main/resources/META-INF/m2e/ core/sis-metadata/src/...
Date Tue, 03 Sep 2013 20:03:34 GMT
Author: desruisseaux
Date: Tue Sep  3 20:03:33 2013
New Revision: 1519828

URL: http://svn.apache.org/r1519828
Log:
Merge from the JDK6 branch.

Added:
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/
      - copied from r1519815, sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java
      - copied unchanged from r1519815, sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/NumericsTest.java
      - copied unchanged from r1519815, sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/NumericsTest.java
Modified:
    sis/trunk/   (props changed)
    sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
    sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
    sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
    sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java
    sis/trunk/core/sis-build-helper/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
  (props changed)
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java
    sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/UtilitiesTest.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
    sis/trunk/pom.xml

Propchange: sis/trunk/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK7:r1519082-1519810
  Merged /sis/branches/JDK6:r1519085-1519815

Modified: sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
[UTF-8] (original)
+++ sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -56,7 +56,7 @@ public class Assembler extends AbstractM
     /**
      * Project information (name, version, URL).
      *
-     * @parameter default-value="${project}"
+     * @parameter property="project"
      * @required
      * @readonly
      */

Modified: sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
[UTF-8] (original)
+++ sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -50,7 +50,7 @@ public class BundleCreator extends Abstr
     /**
      * Project information (name, version, URL).
      *
-     * @parameter default-value="${project}"
+     * @parameter property="project"
      * @required
      * @readonly
      */

Modified: sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
[UTF-8] (original)
+++ sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -54,6 +54,7 @@ public final class JarCollector extends 
      *
      * @parameter property="project"
      * @required
+     * @readonly
      */
     private MavenProject project;
 

Modified: sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java
[UTF-8] (original)
+++ sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -44,9 +44,14 @@ import org.sonatype.plexus.build.increme
  */
 public class ResourceCompilerMojo extends AbstractMojo implements FilenameFilter {
     /**
+     * Pattern to filter properties files that were modified.
+     */
+    private static final String[] PROPERTIES_PATTERN = new String[] {"**/*.properties"};
+
+    /**
      * Project information (name, version, URL).
      *
-     * @parameter expression="${project}"
+     * @parameter property="project"
      * @required
      * @readonly
      */
@@ -113,17 +118,18 @@ public class ResourceCompilerMojo extend
                  * been modified. This is okay for now since changes in resource files are
rare and compiling
                  * them is very fast.
                  */
-                if (!isIncremental) {
+                if (isIncremental) {
                     Scanner scanner = buildContext.newScanner(directory);
-                    scanner.setIncludes(new String[] {"*.properties"});
+                    scanner.setIncludes(PROPERTIES_PATTERN);
                     scanner.scan();
-                    if (scanner.getIncludedFiles() == null) {
+                    final String[] includedFiles = scanner.getIncludedFiles();
+                    if (includedFiles == null || includedFiles.length == 0) {
                         continue;
                     }
                 }
                 javaDirectoryFile = directory;
                 errors += processAllResourceDirectories(directory);
-                buildContext.refresh(directory);
+                buildContext.refresh(outputDirectory);
             }
         }
         if (errors != 0) {

Propchange: sis/trunk/core/sis-build-helper/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Tue Sep  3 20:03:33 2013
@@ -1 +1 @@
-text/xml
+text/plain;charset=UTF-8

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -50,7 +50,7 @@ import org.apache.sis.xml.IdentifiedObje
 
 import static org.apache.sis.metadata.PropertyComparator.*;
 import static org.apache.sis.metadata.ValueExistencePolicy.isNullOrEmpty;
-import static org.apache.sis.internal.util.Utilities.floatEpsilonEqual;
+import static org.apache.sis.internal.util.Numerics.floatEpsilonEqual;
 import static org.apache.sis.internal.util.CollectionsExt.snapshot;
 import static org.apache.sis.internal.util.CollectionsExt.modifiableCopy;
 import static org.apache.sis.util.collection.Containers.hashMapCapacity;

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -472,8 +472,8 @@ public class ImmutableIdentifier impleme
      *        behavior, in order to be compliant with the contract of the <code>GenericName</code>
      *        interface.}
      *
-     * @see IdentifiedObjects#toString(Identifier)
-     * @see NamedIdentifier#toString()
+     * @see org.apache.sis.referencing.IdentifiedObjects#toString(Identifier)
+     * @see org.apache.sis.referencing.NamedIdentifier#toString()
      */
     @Override
     public String toString() {

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -56,6 +56,8 @@ import org.apache.sis.internal.metadata.
  * @module
  *
  * @see Extents#getGeographicBoundingBox(Extent)
+ * @see org.apache.sis.referencing.AbstractReferenceSystem#getDomainOfValidity()
+ * @see org.apache.sis.referencing.datum.AbstractDatum#getDomainOfValidity()
  */
 @XmlType(name = "EX_Extent_Type", propOrder = {
     "description",

Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -185,6 +185,7 @@ public abstract strictfp class MetadataT
                 }
             }
         }
+        done();
     }
 
     /**

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -36,7 +36,7 @@ import org.apache.sis.util.ComparisonMod
 import org.apache.sis.util.resources.Errors;
 
 import static java.lang.Double.doubleToLongBits;
-import static org.apache.sis.internal.util.Utilities.SIGN_BIT_MASK;
+import static org.apache.sis.internal.util.Numerics.SIGN_BIT_MASK;
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.util.ArgumentChecks.ensureDimensionMatches;
 import static org.apache.sis.util.StringBuilders.trimFractionalPart;

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java [UTF-8]
(original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/io/wkt/Convention.java [UTF-8]
Tue Sep  3 20:03:33 2013
@@ -19,6 +19,7 @@ package org.apache.sis.io.wkt;
 import javax.measure.unit.SI;
 import javax.measure.unit.Unit;
 import javax.measure.quantity.Angle;
+import javax.measure.quantity.Quantity;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.cs.CoordinateSystem;
@@ -221,7 +222,7 @@ public enum Convention {
      * which means that the angular units are inferred from the context as required by the
      * <a href="http://www.geoapi.org/3.0/javadoc/org/opengis/referencing/doc-files/WKT.html#PRIMEM">WKT
specification</a>.
      *
-     * @see ReferencingParser#getForcedAngularUnit()
+     * @see #getForcedUnit(Class)
      */
     final Unit<Angle> forcedAngularUnit;
 
@@ -241,9 +242,9 @@ public enum Convention {
      * Creates a new enumeration value.
      */
     private Convention(final Citation authority, final Unit<Angle> angularUnit, final
boolean unitUS) {
-        this.authority = authority;
+        this.authority         = authority;
         this.forcedAngularUnit = angularUnit;
-        this.unitUS = unitUS;
+        this.unitUS            = unitUS;
     }
 
     /**
@@ -258,6 +259,25 @@ public enum Convention {
     }
 
     /**
+     * If non-null, {@code PRIMEM} and {@code PARAMETER} values shall unconditionally use
the returned units.
+     * The standard value is {@code null}, which means that units are inferred from the context
as required by the
+     * <a href="http://www.geoapi.org/3.0/javadoc/org/opengis/referencing/doc-files/WKT.html#PRIMEM">WKT
specification</a>.
+     * However some conventions ignore the above WKT specification and use hard-coded units
instead.
+     *
+     * @param  <T>       The compile-time type specified by the {@code quantity} argument.
+     * @param  quantity  The kind of quantity for which to get the unit.
+     *                   The most typical value for this argument is <code>{@linkplain
Angle}.class</code>.
+     * @return The unit to use for the given kind of quantity, or {@code null} for inferring
the unit in the standard way.
+     */
+    @SuppressWarnings("unchecked")
+    public <T extends Quantity> Unit<T> getForcedUnit(final Class<T> quantity)
{
+        if (quantity == Angle.class) {
+            return (Unit) forcedAngularUnit;
+        }
+        return null;
+    }
+
+    /**
      * Returns the convention for the organization, standard or project specified by the
given citation.
      *
      * @param  authority The organization, standard or project for which to get the convention,
or {@code null}.

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -39,7 +39,6 @@ import org.opengis.referencing.Identifie
 import org.opengis.referencing.ReferenceIdentifier;
 import org.apache.sis.io.wkt.FormattableObject;
 import org.apache.sis.xml.Namespaces;
-import org.apache.sis.util.Classes;
 import org.apache.sis.util.Immutable;
 import org.apache.sis.util.ThreadSafe;
 import org.apache.sis.util.Deprecable;
@@ -452,16 +451,18 @@ public class AbstractIdentifiedObject ex
 
     /**
      * Returns {@code true} if either the {@linkplain #getName() primary name} or at least
-     * one {@linkplain #getAlias alias} matches the specified string.
-     * This method performs the search in the following order, regardless of any authority:
+     * one {@linkplain #getAlias() alias} matches the specified string.
+     * This method returns {@code true} if the given name is equal to one of the following
names,
+     * regardless of any authority:
      *
      * <ul>
-     *   <li>The {@linkplain #getName() primary name} of this object</li>
-     *   <li>The {@linkplain ScopedName fully qualified name} of an alias</li>
-     *   <li>The {@linkplain LocalName local name} of an alias</li>
+     *   <li>The {@linkplain #getName() primary name} of this object.</li>
+     *   <li>The {@linkplain org.opengis.util.GenericName#toFullyQualifiedName() fully
qualified name} of an alias.</li>
+     *   <li>The {@linkplain org.opengis.util.ScopedName#tail() tail} of an alias.</li>
+     *   <li>The tail of the previous tail, recursively up to the {@linkplain org.opengis.util.ScopedName#tip()
tip}.</li>
      * </ul>
      *
-     * @param  name The name to compare.
+     * @param  name The name to compare with the object name or aliases.
      * @return {@code true} if the primary name of at least one alias matches the specified
{@code name}.
      *
      * @see IdentifiedObjects#nameMatches(IdentifiedObject, String)
@@ -471,25 +472,6 @@ public class AbstractIdentifiedObject ex
     }
 
     /**
-     * Compares the specified object with this object for equality.
-     * This method is implemented as below (omitting assertions):
-     *
-     * {@preformat java
-     *     return equals(other, ComparisonMode.STRICT);
-     * }
-     *
-     * @param  object The other object (may be {@code null}).
-     * @return {@code true} if both objects are equal.
-     */
-    @Override
-    public final boolean equals(final Object object) {
-        final boolean eq = equals(object, ComparisonMode.STRICT);
-        // If objects are equal, then they must have the same hash code value.
-        assert !eq || hashCode() == object.hashCode() : this;
-        return eq;
-    }
-
-    /**
      * Compares this object with the specified object for equality.
      * The strictness level is controlled by the second argument:
      *
@@ -498,9 +480,9 @@ public class AbstractIdentifiedObject ex
      *       are compared including {@linkplain #getName() name}, {@linkplain #getRemarks()
remarks},
      *       {@linkplain #getIdentifiers() identifiers code}, <i>etc.</i></li>
      *   <li>If {@code mode} is {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA},
-     *       then this method compare only the properties needed for computing transformations.
-     *       In other words, {@code sourceCS.equals(targetCS, IGNORE_METADATA)} returns {@code
true}
-     *       if the transformation from {@code sourceCS} to {@code targetCS} is likely to
be the
+     *       then this method compares only the properties needed for computing transformations.
+     *       In other words, {@code sourceCRS.equals(targetCRS, IGNORE_METADATA)} returns
{@code true}
+     *       if the transformation from {@code sourceCRS} to {@code targetCRS} is likely
to be the
      *       identity transform, no matter what {@link #getName()} said.</li>
      * </ul>
      *
@@ -517,6 +499,9 @@ public class AbstractIdentifiedObject ex
      *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only
properties
      *         relevant to transformations.
      * @return {@code true} if both objects are equal.
+     *
+     * @see #hashCode(ComparisonMode)
+     * @see org.apache.sis.util.Utilities#deepEquals(Object, Object, ComparisonMode)
      */
     @Override
     public boolean equals(final Object object, final ComparisonMode mode) {
@@ -575,51 +560,88 @@ public class AbstractIdentifiedObject ex
     }
 
     /**
-     * Returns a hash value for this identified object.
-     * This method invokes {@link #computeHashCode()} when first needed and caches the value
for future invocations.
-     * Subclasses shall override {@code computeHashCode()} instead than this method.
+     * Computes a hash value consistent with the given comparison mode.
+     * This method accepts only the following enumeration values:
      *
-     * {@section Implementation specific feature}
-     * In the Apache SIS implementation, the {@linkplain #getName() name}, {@linkplain #getIdentifiers()
identifiers}
-     * and {@linkplain #getRemarks() remarks} are not used for hash code computation.
-     * Consequently two identified objects will return the same hash value if they are equal
in the sense of
-     * <code>{@linkplain #equals(Object, ComparisonMode) equals}(…, {@linkplain ComparisonMode#IGNORE_METADATA})</code>.
+     * <ul>
+     *   <li>{@link ComparisonMode#STRICT} (the default): this method may use any property,
+     *       including implementation-specific ones if any, at implementation choice.</li>
+     *   <li>{@link ComparisonMode#BY_CONTRACT}: this method can use any property defined
+     *       in the implemented interface (typically a GeoAPI interface).</li>
+     *   <li>{@link ComparisonMode#IGNORE_METADATA}: this method ignores the metadata
that do not affect
+     *       coordinate operations. By default, the ignored properties are the {@linkplain
#getName() name},
+     *       {@linkplain #getIdentifiers() identifiers} and {@linkplain #getRemarks() remarks}.
+     *       However subclasses may ignore a different list of properties.</li>
+     * </ul>
+     *
+     * In the later case, two identified objects will return the same hash value if they
are equal in the sense of
+     * <code>{@linkplain #equals(Object, ComparisonMode) equals}(object, {@linkplain
ComparisonMode#IGNORE_METADATA})</code>.
      * This feature allows users to implement metadata-insensitive {@link java.util.HashMap}.
      *
+     * @param  mode Specifies the set of properties that can be used for hash code computation.
      * @return The hash code value. This value may change between different execution of
the Apache SIS library.
+     * @throws IllegalArgumentException If the given {@code mode} is not one of {@code STRICT},
{@code BY_CONTRACT}
+     *         or {@code IGNORE_METADATA} enumeration values.
      */
-    @Override
-    public final int hashCode() { // No need to synchronize; ok if invoked twice.
-        int hash = hashCode;
-        if (hash == 0) {
-            hash = computeHashCode();
-            if (hash == 0) {
-                hash = -1;
+    public int hashCode(final ComparisonMode mode) throws IllegalArgumentException {
+        int code = (int) serialVersionUID;
+        switch (mode) {
+            case STRICT: {
+                code ^= Objects.hash(name, nonNull(alias), nonNull(identifiers), remarks);
+                break;
+            }
+            case BY_CONTRACT: {
+                code ^= Objects.hash(getName(), getAlias(), getIdentifiers(), getRemarks());
+                break;
+            }
+            case IGNORE_METADATA: {
+                break;
+            }
+            default: {
+                throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalArgumentValue_2,
"mode", mode));
             }
-            hashCode = hash;
         }
-        assert hash == -1 || hash == computeHashCode() : this;
-        return hash;
+        return code;
     }
 
     /**
-     * Computes a hash value for this identified object.
-     * This method is invoked by {@link #hashCode()} when first needed.
+     * Compares the specified object with this object for equality.
+     * This method is implemented as below (omitting assertions):
      *
-     * <p>The default implementation computes a code derived from the list of {@link
IdentifiedObject} interfaces
-     * implemented by this instance. The {@linkplain #getName() name}, {@linkplain #getIdentifiers()
identifiers}
-     * and {@linkplain #getRemarks() remarks} are intentionally <strong>not</strong>
used for hash code computation.
-     * See the <cite>Implementation specific feature</cite> section in {@link
#hashCode()} for more information.</p>
+     * {@preformat java
+     *     return equals(other, ComparisonMode.STRICT);
+     * }
+     *
+     * @param  object The other object (may be {@code null}).
+     * @return {@code true} if both objects are equal.
+     */
+    @Override
+    public final boolean equals(final Object object) {
+        final boolean eq = equals(object, ComparisonMode.STRICT);
+        // If objects are equal, then they must have the same hash code value.
+        assert !eq || hashCode() == object.hashCode() : this;
+        return eq;
+    }
+
+    /**
+     * Returns a hash value for this identified object.
+     * This method invokes <code>{@linkplain #hashCode(ComparisonMode) hashCode}(ComparisonMode.STRICT)</code>
+     * when first needed and caches the value for future invocations.
+     * Subclasses shall override {@link #hashCode(ComparisonMode)} instead than this method.
      *
      * @return The hash code value. This value may change between different execution of
the Apache SIS library.
      */
-    protected int computeHashCode() {
-        // Subclasses need to overrides this!!!!
-        int code = (int) serialVersionUID;
-        for (final Class<?> type : Classes.getLeafInterfaces(getClass(), IdentifiedObject.class))
{
-            // Use a plain addition in order to be insensitive to array element order.
-            code += type.hashCode();
+    @Override
+    public final int hashCode() { // No need to synchronize; ok if invoked twice.
+        int hash = hashCode;
+        if (hash == 0) {
+            hash = hashCode(ComparisonMode.STRICT);
+            if (hash == 0) {
+                hash = -1;
+            }
+            hashCode = hash;
         }
-        return code;
+        assert hash == -1 || hash == hashCode(ComparisonMode.STRICT) : this;
+        return hash;
     }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractReferenceSystem.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -61,12 +61,16 @@ public class AbstractReferenceSystem ext
 
     /**
      * Area for which the (coordinate) reference system is valid.
+     *
+     * @see #getDomainOfValidity()
      */
     private final Extent domainOfValidity;
 
     /**
      * Description of domain of usage, or limitations of usage,
      * for which this (coordinate) reference system object is valid.
+     *
+     * @see #getScope()
      */
     @XmlElement(required = true)
     private final InternationalString scope;
@@ -123,6 +127,8 @@ public class AbstractReferenceSystem ext
      * or {@code null} if unspecified.
      *
      * @return Area or region or timeframe in which this (coordinate) reference system is
valid, or {@code null}.
+     *
+     * @see org.apache.sis.metadata.iso.extent.DefaultExtent
      */
     @Override
     public Extent getDomainOfValidity() {
@@ -176,4 +182,27 @@ public class AbstractReferenceSystem ext
         }
         return false;
     }
+
+    /**
+     * Computes a hash value consistent with the given comparison mode.
+     * If the given argument is {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA}, then
the
+     * {@linkplain #getDomainOfValidity() domain of validity} and the {@linkplain #getScope()
scope}
+     * properties are ignored, in addition to other ignored properties documented in the
+     * {@linkplain AbstractIdentifiedObject#hashCode(ComparisonMode) super-class}.
+     */
+    @Override
+    public int hashCode(final ComparisonMode mode) throws IllegalArgumentException {
+        int code = super.hashCode(mode) ^ (int) serialVersionUID;
+        switch (mode) {
+            case STRICT: {
+                code ^= Objects.hash(domainOfValidity, scope);
+                break;
+            }
+            case BY_CONTRACT: {
+                code ^= Objects.hash(getDomainOfValidity(), getScope());
+                break;
+            }
+        }
+        return code;
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -89,7 +89,7 @@ public final class IdentifiedObjects ext
      *
      *   <li><p>Otherwise, if the alias implements the {@link GenericName} interface,
then this method
      *       compares the {@linkplain GenericName#scope() name scope} against the specified
citation
-     *       using the {@linkplain Citations#identifierMatches(Citation, String)} method.
+     *       using the {@link Citations#identifierMatches(Citation, String)} method.
      *       If a matching is found, then this method returns the
      *       {@linkplain GenericName#tip() name tip} of that object.</p></li>
      * </ul>
@@ -291,18 +291,22 @@ public final class IdentifiedObjects ext
     /**
      * Returns {@code true} if either the {@linkplain IdentifiedObject#getName() primary
name} or
      * at least one {@linkplain IdentifiedObject#getAlias() alias} matches the specified
string.
-     * This method performs the search in the following order, regardless of any authority:
+     * This method returns {@code true} if the given name is equal to one of the following
names,
+     * regardless of any authority:
      *
-     * <ol>
+     * <ul>
      *   <li>The {@linkplain IdentifiedObject#getName() primary name} of the object.</li>
-     *   <li>The {@linkplain ScopedName fully qualified name} of an alias.</li>
-     *   <li>The {@linkplain LocalName local name} of an alias.</li>
-     * </ol>
+     *   <li>The {@linkplain GenericName#toFullyQualifiedName() fully qualified name}
of an alias.</li>
+     *   <li>The {@linkplain ScopedName#tail() tail} of an alias.</li>
+     *   <li>The tail of the previous tail, recursively up to the {@linkplain ScopedName#tip()
tip}.</li>
+     * </ul>
+     *
+     * If the given object is an instance of {@link AbstractIdentifiedObject}, then this
method delegates
+     * to its {@code nameMatches(String)} method. Otherwise this method fallbacks on a generic
algorithm.
      *
      * @param  object The object for which to check the name or alias.
-     * @param  name The name.
-     * @return {@code true} if the primary name of at least one alias
-     *         matches the specified {@code name}.
+     * @param  name The name to compare with the object name or aliases.
+     * @return {@code true} if the primary name of at least one alias matches the specified
{@code name}.
      *
      * @see AbstractIdentifiedObject#nameMatches(String)
      */
@@ -390,7 +394,7 @@ public final class IdentifiedObjects ext
      * @param  identifier The identifier, or {@code null}.
      * @return A string representation of the given identifier, or {@code null}.
      *
-     * @see DefaultIdentifier#toString()
+     * @see org.apache.sis.metadata.iso.ImmutableIdentifier#toString()
      * @see NamedIdentifier#toString()
      */
     public static String toString(final Identifier identifier) {

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractIdentifiedObjectTest.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -45,12 +45,9 @@ public final strictfp class AbstractIden
     @Test
     public void testCreateFromMap() {
         final Map<String,Object> properties = new HashMap<String,Object>(10);
-        assertNull(properties.put("name",             "This is a name"));
-        assertNull(properties.put("remarks",          "There is remarks"));
-        assertNull(properties.put("remarks_fr",       "Voici des remarques"));
-        assertNull(properties.put("anchorPoint",      "Anchor point"));
-        assertNull(properties.put("realizationEpoch", "Realization epoch"));
-        assertNull(properties.put("validArea",        "Valid area"));
+        assertNull(properties.put("name",       "This is a name"));
+        assertNull(properties.put("remarks",    "There is remarks"));
+        assertNull(properties.put("remarks_fr", "Voici des remarques"));
 
         final AbstractIdentifiedObject object = new AbstractIdentifiedObject(properties);
         Validators.validate(object);

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java [UTF-8]
(original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java [UTF-8]
Tue Sep  3 20:03:33 2013
@@ -22,9 +22,6 @@ import org.apache.sis.util.Static;
 import org.apache.sis.util.Classes;
 import org.apache.sis.util.CharSequences;
 
-import static java.lang.Math.abs;
-import static java.lang.Math.max;
-
 
 /**
  * Miscellaneous utilities which should not be put in public API.
@@ -35,49 +32,6 @@ import static java.lang.Math.max;
  * @module
  */
 public final class Utilities extends Static {
-    /**
-     * Relative difference tolerated when comparing floating point numbers using
-     * {@link org.apache.sis.util.ComparisonMode#APPROXIMATIVE}.
-     *
-     * <p>Historically, this was the relative tolerance threshold for considering two
-     * matrixes as equal. This value has been determined empirically in order to allow
-     * {@link org.apache.sis.referencing.operation.transform.ConcatenatedTransform} to
-     * detect the cases where two {@link org.apache.sis.referencing.operation.transform.LinearTransform}
-     * are equal for practical purpose. This threshold can be used as below:</p>
-     *
-     * {@preformat java
-     *     Matrix m1 = ...;
-     *     Matrix m2 = ...;
-     *     if (Matrices.epsilonEqual(m1, m2, EQUIVALENT_THRESHOLD, true)) {
-     *         // Consider that matrixes are equal.
-     *     }
-     * }
-     *
-     * By extension, the same threshold value is used for comparing other floating point
values.
-     *
-     * @see org.apache.sis.internal.referencing.Utilities#LINEAR_TOLERANCE
-     * @see org.apache.sis.internal.referencing.Utilities#ANGULAR_TOLERANCE
-     */
-    public static final double COMPARISON_THRESHOLD = 1E-14;
-
-    /**
-     * Bit mask to isolate the sign bit of non-{@linkplain Double#isNaN(double) NaN} values
in a
-     * {@code double}. For any real value, the following code evaluate to 0 if the given
value is
-     * positive:
-     *
-     * {@preformat java
-     *     Double.doubleToRawLongBits(value) & SIGN_BIT_MASK;
-     * }
-     *
-     * Note that this idiom differentiates positive zero from negative zero.
-     * It should be used only when such difference matter.
-     *
-     * @see org.apache.sis.math.MathFunctions#isPositive(double)
-     * @see org.apache.sis.math.MathFunctions#isNegative(double)
-     * @see org.apache.sis.math.MathFunctions#isSameSign(double, double)
-     * @see org.apache.sis.math.MathFunctions#xorSign(double, double)
-     */
-    public static final long SIGN_BIT_MASK = Long.MIN_VALUE;
 
     /**
      * Do not allow instantiation of this class.
@@ -86,38 +40,6 @@ public final class Utilities extends Sta
     }
 
     /**
-     * Returns {@code true} if the given values are approximatively equal,
-     * up to the {@linkplain #COMPARISON_THRESHOLD comparison threshold}.
-     *
-     * @param  v1 The first value to compare.
-     * @param  v2 The second value to compare.
-     * @return {@code true} If both values are approximatively equal.
-     */
-    public static boolean epsilonEqual(final double v1, final double v2) {
-        final double threshold = COMPARISON_THRESHOLD * max(abs(v1), abs(v2));
-        if (threshold == Double.POSITIVE_INFINITY || Double.isNaN(threshold)) {
-            return Double.doubleToLongBits(v1) == Double.doubleToLongBits(v2);
-        }
-        return abs(v1 - v2) <= threshold;
-    }
-
-    /**
-     * Returns {@code true} if the following objects are floating point numbers ({@link Float}
or
-     * {@link Double} types) and approximatively equal. If the given object are not floating
point
-     * numbers, then this method returns {@code false} unconditionally on the assumption
that
-     * strict equality has already been checked before this method call.
-     *
-     * @param  v1 The first value to compare.
-     * @param  v2 The second value to compare.
-     * @return {@code true} If both values are real number and approximatively equal.
-     */
-    public static boolean floatEpsilonEqual(final Object v1, final Object v2) {
-        return (v1 instanceof Float || v1 instanceof Double) &&
-               (v2 instanceof Float || v2 instanceof Double) &&
-               epsilonEqual(((Number) v1).doubleValue(), ((Number) v2).doubleValue());
-    }
-
-    /**
      * Returns a string representation of an instance of the given class having the given
properties.
      * This is a convenience method for implementation of {@link Object#toString()} methods
that are
      * used mostly for debugging purpose.

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java [UTF-8]
(original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java [UTF-8]
Tue Sep  3 20:03:33 2013
@@ -27,7 +27,7 @@ import static java.lang.Float.intBitsToF
 import static java.lang.Float.floatToRawIntBits;
 import static java.lang.Double.longBitsToDouble;
 import static java.lang.Double.doubleToRawLongBits;
-import static org.apache.sis.internal.util.Utilities.SIGN_BIT_MASK;
+import static org.apache.sis.internal.util.Numerics.SIGN_BIT_MASK;
 
 
 /**

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/UtilitiesTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/UtilitiesTest.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/UtilitiesTest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/UtilitiesTest.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -19,10 +19,6 @@ package org.apache.sis.internal.util;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static java.lang.Double.NaN;
-import static java.lang.Double.POSITIVE_INFINITY;
-import static java.lang.Double.NEGATIVE_INFINITY;
-import static org.apache.sis.internal.util.Utilities.*;
 import static org.apache.sis.test.Assert.*;
 
 
@@ -36,23 +32,6 @@ import static org.apache.sis.test.Assert
  */
 public final strictfp class UtilitiesTest extends TestCase {
     /**
-     * Tests the {@link Utilities#epsilonEqual(double, double)} method.
-     */
-    @Test
-    public void testEpsilonEqual() {
-        assertTrue (epsilonEqual(POSITIVE_INFINITY, POSITIVE_INFINITY));
-        assertTrue (epsilonEqual(NEGATIVE_INFINITY, NEGATIVE_INFINITY));
-        assertFalse(epsilonEqual(POSITIVE_INFINITY, NEGATIVE_INFINITY));
-        assertFalse(epsilonEqual(POSITIVE_INFINITY, NaN));
-        assertTrue (epsilonEqual(NaN,               NaN));
-        assertFalse(epsilonEqual(   0,        COMPARISON_THRESHOLD / 2));
-        assertTrue (epsilonEqual(   1,    1 + COMPARISON_THRESHOLD / 2));
-        assertFalse(epsilonEqual(   1,    1 + COMPARISON_THRESHOLD * 2));
-        assertTrue (epsilonEqual(-100, -100 + COMPARISON_THRESHOLD * 50));
-        assertFalse(epsilonEqual( 100,  100 + COMPARISON_THRESHOLD * 150));
-    }
-
-    /**
      * Tests the {@link Utilities#toString(Class, Object[])} method.
      */
     @Test

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java
[UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/AnnotationsTestCase.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -638,7 +638,7 @@ public abstract strictfp class Annotatio
      * Shall be invoked after every successful test in order
      * to disable the report of failed class or method.
      */
-    private void done() {
+    protected final void done() {
         testingClass  = null;
         testingMethod = null;
     }

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
[UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
[UTF-8] Tue Sep  3 20:03:33 2013
@@ -57,6 +57,7 @@ import org.junit.BeforeClass;
     org.apache.sis.math.StatisticsTest.class,
     org.apache.sis.math.StatisticsFormatTest.class,
     org.apache.sis.internal.util.UtilitiesTest.class,
+    org.apache.sis.internal.util.NumericsTest.class,
     org.apache.sis.internal.jdk8.JDK8Test.class,
 
     // Collections.

Modified: sis/trunk/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/pom.xml?rev=1519828&r1=1519827&r2=1519828&view=diff
==============================================================================
--- sis/trunk/pom.xml (original)
+++ sis/trunk/pom.xml Tue Sep  3 20:03:33 2013
@@ -443,6 +443,7 @@ Apache SIS is a free software, Java lang
         <artifactId>maven-jar-plugin</artifactId>
         <configuration>
           <archive>
+            <addMavenDescriptor>false</addMavenDescriptor>
             <index>false</index>
             <manifest>
               <addClasspath>true</addClasspath>



Mime
View raw message