sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1611113 - in /sis/branches/JDK6: ./ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ core/sis-metadata/src/main/java/org/apache/sis/metadata/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/ core/sis-m...
Date Wed, 16 Jul 2014 17:44:19 GMT
Author: desruisseaux
Date: Wed Jul 16 17:44:18 2014
New Revision: 1611113

URL: http://svn.apache.org/r1611113
Log:
Merge from the JDK7 branch.

Added:
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DefaultMetadataTest.java
      - copied unchanged from r1611108, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DefaultMetadataTest.java
    sis/branches/JDK6/core/sis-referencing/src/test/resources/org/apache/sis/test/integration/Metadata.xml
      - copied unchanged from r1611108, sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/test/integration/Metadata.xml
Modified:
    sis/branches/JDK6/   (props changed)
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/LegacyTelephones.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
    sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java
    sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK8:r1610649-1611104
  Merged /sis/branches/JDK7:r1610650-1611108

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java?rev=1611113&r1=1611112&r2=1611113&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java
[UTF-8] Wed Jul 16 17:44:18 2014
@@ -44,7 +44,7 @@ public abstract class LegacyPropertyAdap
     /**
      * The collection where to store the elements.
      */
-    final Collection<N> elements;
+    protected final Collection<N> elements;
 
     /**
      * For logging warning only once per collection usage.
@@ -224,13 +224,13 @@ public abstract class LegacyPropertyAdap
     /**
      * Adds a new element.
      *
-     * @param  element The element to add.
+     * @param  value The element to add.
      * @return {@code true} if the element has been added.
      */
     @Override
-    public final boolean add(final L element) {
-        ArgumentChecks.ensureNonNull("element", element);
-        return elements.add(wrap(element));
+    public boolean add(final L value) {
+        ArgumentChecks.ensureNonNull("value", value);
+        return elements.add(wrap(value));
     }
 
     /**

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java?rev=1611113&r1=1611112&r2=1611113&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
[UTF-8] Wed Jul 16 17:44:18 2014
@@ -86,8 +86,8 @@ import static org.apache.sis.internal.ja
 @XmlTransient
 public abstract class ModifiableMetadata extends AbstractMetadata implements Cloneable {
     /**
-     * Initial capacity of lists and sets. We use a small value because those
-     * collections will typically contain few elements (often just a singleton).
+     * Initial capacity of sets. We use a small value because collections will typically
+     * contain few elements (often just a singleton).
      */
     private static final int INITIAL_CAPACITY = 4;
 
@@ -500,7 +500,7 @@ public abstract class ModifiableMetadata
         if (useSet(elementType)) {
             collection = createSet(elementType, INITIAL_CAPACITY);
         } else {
-            collection = new CheckedArrayList<E>(elementType, INITIAL_CAPACITY);
+            collection = new CheckedArrayList<E>(elementType, 1);
         }
         collection.add(value);
         return collection;
@@ -523,7 +523,14 @@ public abstract class ModifiableMetadata
             return null;
         }
         if (isModifiable()) {
-            return new CheckedArrayList<E>(elementType, INITIAL_CAPACITY);
+            /*
+             * Do not specify an initial capacity, because the list will stay empty in a
majority of cases
+             * (i.e. the users will want to iterate over the list elements more often than
they will want
+             * to add elements). JDK implementation of ArrayList has a lazy instantiation
mechanism for
+             * initially empty lists, but as of JDK8 this lazy instantiation works only for
list having
+             * the default capacity.
+             */
+            return new CheckedArrayList<E>(elementType);
         }
         return Collections.emptyList();
     }
@@ -545,7 +552,7 @@ public abstract class ModifiableMetadata
             return null;
         }
         if (isModifiable()) {
-            return new CheckedHashSet<E>(elementType, INITIAL_CAPACITY);
+            return createSet(elementType, INITIAL_CAPACITY);
         }
         return Collections.emptySet();
     }
@@ -584,7 +591,8 @@ public abstract class ModifiableMetadata
             }
         } else {
             if (isModifiable) {
-                return new CheckedArrayList<E>(elementType, INITIAL_CAPACITY);
+                // Do not specify an initial capacity for the reason explained in nonNullList(…).
+                return new CheckedArrayList<E>(elementType);
             } else {
                 return Collections.emptyList();
             }

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java?rev=1611113&r1=1611112&r2=1611113&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java
[UTF-8] Wed Jul 16 17:44:18 2014
@@ -311,7 +311,7 @@ public class DefaultResponsibleParty ext
     /**
      * Sets the address of the responsible party.
      *
-     * <p>This implementation sets the contact info in the first pary found in the
collection of
+     * <p>This implementation sets the contact info in the first party found in the
collection of
      * {@linkplain #getParties() parties}.</p>
      *
      * @param newValue The new contact info, or {@code null} if none.

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/LegacyTelephones.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/LegacyTelephones.java?rev=1611113&r1=1611112&r2=1611113&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/LegacyTelephones.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/LegacyTelephones.java
[UTF-8] Wed Jul 16 17:44:18 2014
@@ -17,9 +17,11 @@
 package org.apache.sis.metadata.iso.citation;
 
 import java.util.Collection;
+import java.util.Iterator;
 import org.opengis.metadata.citation.Telephone;
 import org.opengis.metadata.citation.TelephoneType;
 import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
+import org.apache.sis.util.ArgumentChecks;
 
 
 /**
@@ -86,4 +88,27 @@ final class LegacyTelephones extends Leg
         }
         return false;
     }
+
+    /**
+     * Adds a new telephone number. As a special case if the first element is empty, then
the telephone number
+     * will be set in that element. We test only the first element because {@link DefaultTelephone#getOwner()}
+     * initialize new collections as collection containing {@code DefaultTelephone.this}.
+     *
+     * @param  value The telephone number to add.
+     * @return {@code true} if the element has been added.
+     */
+    @Override
+    public boolean add(final String value) {
+        ArgumentChecks.ensureNonNull("value", value);
+        final Iterator<Telephone> it = elements.iterator();
+        if (it.hasNext()) {
+            final Telephone telephone = it.next();
+            if (telephone instanceof DefaultTelephone && ((DefaultTelephone) telephone).isEmpty())
{
+                if (update(telephone, value)) {
+                    return true;
+                }
+            }
+        }
+        return elements.add(wrap(value));
+    }
 }

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java?rev=1611113&r1=1611112&r2=1611113&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
[UTF-8] Wed Jul 16 17:44:18 2014
@@ -82,16 +82,16 @@ public class DefaultVerticalExtent exten
     /**
      * Creates a vertical extent initialized to the specified values.
      *
-     * @param minimumValue The lowest vertical extent contained in the dataset.
-     * @param maximumValue The highest vertical extent contained in the dataset.
+     * @param minimumValue The lowest vertical extent contained in the dataset, or {@link
Double#NaN} if none.
+     * @param maximumValue The highest vertical extent contained in the dataset, or {@link
Double#NaN} if none.
      * @param verticalCRS  The information about the vertical coordinate reference system,
or {@code null}.
      */
     public DefaultVerticalExtent(final double minimumValue,
                                  final double maximumValue,
                                  final VerticalCRS verticalCRS)
     {
-        this.minimumValue = minimumValue;
-        this.maximumValue = maximumValue;
+        if (!Double.isNaN(minimumValue)) this.minimumValue = minimumValue;
+        if (!Double.isNaN(maximumValue)) this.maximumValue = maximumValue;
         this.verticalCRS  = verticalCRS;
     }
 

Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java?rev=1611113&r1=1611112&r2=1611113&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java
[UTF-8] Wed Jul 16 17:44:18 2014
@@ -38,6 +38,10 @@ import static org.apache.sis.test.Assert
  *   <li>{@code "core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso"}</li>
  * </ul>
  *
+ * Metadata tested by this class do not include Coordinate Reference System (CRS) information.
A metadata
+ * object with CRS information is tested by {@code org.apache.sis.test.integration.DefaultMetadataTest}
+ * in the {@code sis-referencing} module.
+ *
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-2.5)

Modified: sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1611113&r1=1611112&r2=1611113&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] Wed Jul 16 17:44:18 2014
@@ -26,7 +26,7 @@ import org.junit.BeforeClass;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.5
  * @module
  */
 @Suite.SuiteClasses({

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1611113&r1=1611112&r2=1611113&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Wed Jul 16 17:44:18 2014
@@ -113,7 +113,8 @@ import org.junit.BeforeClass;
 
     org.apache.sis.distance.LatLonPointRadiusTest.class, // Pending refactoring in a geometry
package.
 
-    org.apache.sis.test.integration.ReferencingInMetadataTest.class
+    org.apache.sis.test.integration.ReferencingInMetadataTest.class,
+    org.apache.sis.test.integration.DefaultMetadataTest.class
 })
 public final strictfp class ReferencingTestSuite extends TestSuite {
     /**



Mime
View raw message