sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1696849 - in /sis/branches/JDK8/core: sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/ sis-referencing/src/main/java/org/apache/sis/parameter/ sis-referencing/src/test/java/org/apache/sis/parameter/ sis-referencing/s...
Date Thu, 20 Aug 2015 19:41:49 GMT
Author: desruisseaux
Date: Thu Aug 20 19:41:49 2015
New Revision: 1696849

URL: http://svn.apache.org/r1696849
Log:
Added JAXB annotation to DefaultParameterDescriptorGroup for <gml:OperationParameterGroup> support.

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java   (with props)
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java   (with props)
    sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/
    sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterDescriptorGroup.xml   (with props)
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterFormatTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java?rev=1696849&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java (added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java [UTF-8] Thu Aug 20 19:41:49 2015
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.jaxb.referencing;
+
+import javax.xml.bind.annotation.XmlElementRef;
+import org.opengis.parameter.ParameterDescriptor;
+import org.opengis.parameter.ParameterDescriptorGroup;
+import org.opengis.parameter.GeneralParameterDescriptor;
+import org.apache.sis.parameter.AbstractParameterDescriptor;
+import org.apache.sis.parameter.DefaultParameterDescriptor;
+import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
+import org.apache.sis.internal.jaxb.gco.PropertyType;
+
+
+/**
+ * JAXB adapter mapping implementing class to the GeoAPI interface. See
+ * package documentation for more information about JAXB and interface.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.6
+ * @version 0.6
+ * @module
+ */
+public final class CC_GeneralOperationParameter extends PropertyType<CC_GeneralOperationParameter,GeneralParameterDescriptor> {
+    /**
+     * Empty constructor for JAXB only.
+     */
+    public CC_GeneralOperationParameter() {
+    }
+
+    /**
+     * Returns the GeoAPI interface which is bound by this adapter.
+     * This method is indirectly invoked by the private constructor
+     * below, so it shall not depend on the state of this object.
+     *
+     * @return {@code GeneralParameterDescriptor.class}
+     */
+    @Override
+    protected Class<GeneralParameterDescriptor> getBoundType() {
+        return GeneralParameterDescriptor.class;
+    }
+
+    /**
+     * Constructor for the {@link #wrap} method only.
+     */
+    private CC_GeneralOperationParameter(final GeneralParameterDescriptor parameter) {
+        super(parameter);
+    }
+
+    /**
+     * Invoked by {@link PropertyType} at marshalling time for wrapping the given value in a
+     * {@code <gml:OperationParameter>} or {@code <gml:OperationParameterGroup>} XML element.
+     *
+     * @param  parameter The element to marshall.
+     * @return A {@code PropertyType} wrapping the given the element.
+     */
+    @Override
+    protected CC_GeneralOperationParameter wrap(final GeneralParameterDescriptor parameter) {
+        return new CC_GeneralOperationParameter(parameter);
+    }
+
+    /**
+     * Invoked by JAXB at marshalling time for getting the actual element to write
+     * inside the {@code <gml:OperationParameter>} XML element.
+     * This is the value or a copy of the value given in argument to the {@code wrap} method.
+     *
+     * @return The element to be marshalled.
+     */
+    @XmlElementRef
+    public AbstractParameterDescriptor getElement() {
+        final GeneralParameterDescriptor metadata = this.metadata;
+        if (metadata instanceof AbstractParameterDescriptor) {
+            return (AbstractParameterDescriptor) metadata;
+        }
+        if (metadata instanceof ParameterDescriptor) {
+            return DefaultParameterDescriptor.castOrCopy((ParameterDescriptor<?>) metadata);
+        }
+        if (metadata instanceof ParameterDescriptorGroup) {
+            return DefaultParameterDescriptorGroup.castOrCopy((ParameterDescriptorGroup) metadata);
+        }
+        return null;    // Unknown types are currently not marshalled (we may revisit that in a future SIS version).
+    }
+
+    /**
+     * Invoked by JAXB at unmarshalling time for storing the result temporarily.
+     *
+     * @param parameter The unmarshalled element.
+     */
+    public void setElement(final AbstractParameterDescriptor parameter) {
+        metadata = parameter;
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java?rev=1696849&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java (added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java [UTF-8] Thu Aug 20 19:41:49 2015
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.jaxb.referencing;
+
+import javax.xml.bind.annotation.XmlElement;
+import org.opengis.parameter.ParameterDescriptorGroup;
+import org.apache.sis.internal.jaxb.gco.PropertyType;
+import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
+
+
+/**
+ * JAXB adapter mapping implementing class to the GeoAPI interface. See
+ * package documentation for more information about JAXB and interface.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.6
+ * @version 0.6
+ * @module
+ */
+public final class CC_OperationParameterGroup extends PropertyType<CC_OperationParameterGroup,ParameterDescriptorGroup> {
+    /**
+     * Empty constructor for JAXB only.
+     */
+    public CC_OperationParameterGroup() {
+    }
+
+    /**
+     * Returns the GeoAPI interface which is bound by this adapter.
+     * This method is indirectly invoked by the private constructor
+     * below, so it shall not depend on the state of this object.
+     *
+     * @return {@code ParameterDescriptorGroup.class}
+     */
+    @Override
+    protected Class<ParameterDescriptorGroup> getBoundType() {
+        return ParameterDescriptorGroup.class;
+    }
+
+    /**
+     * Constructor for the {@link #wrap} method only.
+     */
+    private CC_OperationParameterGroup(final ParameterDescriptorGroup parameter) {
+        super(parameter);
+    }
+
+    /**
+     * Invoked by {@link PropertyType} at marshalling time for wrapping the given value
+     * in a {@code <gml:OperationParameterGroup>} XML element.
+     *
+     * @param  parameter The element to marshall.
+     * @return A {@code PropertyType} wrapping the given the element.
+     */
+    @Override
+    protected CC_OperationParameterGroup wrap(final ParameterDescriptorGroup parameter) {
+        return new CC_OperationParameterGroup(parameter);
+    }
+
+    /**
+     * Invoked by JAXB at marshalling time for getting the actual element to write
+     * inside the {@code <gml:OperationParameter>} XML element.
+     * This is the value or a copy of the value given in argument to the {@code wrap} method.
+     *
+     * @return The element to be marshalled.
+     */
+    @XmlElement(name = "OperationParameterGroup")
+    public DefaultParameterDescriptorGroup getElement() {
+        return DefaultParameterDescriptorGroup.castOrCopy(metadata);
+    }
+
+    /**
+     * Invoked by JAXB at unmarshalling time for storing the result temporarily.
+     *
+     * @param parameter The unmarshalled element.
+     */
+    public void setElement(final DefaultParameterDescriptorGroup parameter) {
+        metadata = parameter;
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java?rev=1696849&r1=1696848&r2=1696849&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java [UTF-8] Thu Aug 20 19:41:49 2015
@@ -102,7 +102,8 @@ import java.util.Objects;
     "nonDefaultMaximumOccurs"
 })
 @XmlSeeAlso({
-    DefaultParameterDescriptor.class
+    DefaultParameterDescriptor.class,
+    DefaultParameterDescriptorGroup.class
 })
 public abstract class AbstractParameterDescriptor extends AbstractIdentifiedObject implements GeneralParameterDescriptor {
     /**
@@ -214,6 +215,10 @@ public abstract class AbstractParameterD
         maximumOccurs = crop(descriptor.getMaximumOccurs());
     }
 
+    // NOTE: There is no 'castOrCopy' static method in this class because AbstractParameterDescriptor is abstract.
+    // If nevertheless we choose to add such method in the future, then CC_GeneralOperationParameter.getElement()
+    // should be simplified.
+
     /**
      * Crops the given integer in the [0 … 0xFFFF] range.
      */

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java?rev=1696849&r1=1696848&r2=1696849&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java [UTF-8] Thu Aug 20 19:41:49 2015
@@ -21,6 +21,9 @@ import java.util.Set;
 import java.util.List;
 import java.util.HashSet;
 import java.util.Collections;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
 import org.opengis.parameter.ParameterDirection;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptorGroup;
@@ -28,6 +31,7 @@ import org.opengis.parameter.GeneralPara
 import org.opengis.parameter.ParameterNotFoundException;
 import org.opengis.parameter.InvalidParameterNameException;
 import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.ArgumentChecks;
@@ -90,6 +94,8 @@ import static org.apache.sis.util.Utilit
  * @see DefaultParameterValueGroup
  * @see DefaultParameterDescriptor
  */
+@XmlType(name = "OperationParameterGroupType")
+@XmlRootElement(name = "OperationParameterGroup")
 public class DefaultParameterDescriptorGroup extends AbstractParameterDescriptor implements ParameterDescriptorGroup {
     /**
      * Serial number for inter-operability with different versions.
@@ -98,8 +104,22 @@ public class DefaultParameterDescriptorG
 
     /**
      * The {@linkplain #descriptors() parameter descriptors} for this group.
+     *
+     * <p><b>Consider this field as final!</b>
+     * This field is modified only at unmarshalling time by {@link #setDescriptors(GeneralParameterDescriptor[])}</p>
+     *
+     * @see #descriptors()
      */
-    private final List<GeneralParameterDescriptor> descriptors;
+    private List<GeneralParameterDescriptor> descriptors;
+
+    /**
+     * Constructs a new object in which every attributes are set to a null value or an empty list.
+     * <strong>This is not a valid object.</strong> This constructor is strictly reserved to JAXB,
+     * which will assign values to the fields using reflexion.
+     */
+    private DefaultParameterDescriptorGroup() {
+        descriptors = Collections.emptyList();
+    }
 
     /**
      * Constructs a parameter group from a set of properties. The properties map is given unchanged to the
@@ -310,8 +330,9 @@ public class DefaultParameterDescriptorG
      * @return The parameter descriptors in this group.
      */
     @Override
+    @SuppressWarnings("ReturnOfCollectionOrArrayField")
     public List<GeneralParameterDescriptor> descriptors() {
-        return descriptors;
+        return descriptors;     // Unmodifiable.
     }
 
     /**
@@ -396,4 +417,26 @@ public class DefaultParameterDescriptorG
     protected long computeHashCode() {
         return super.computeHashCode() + descriptors.hashCode();
     }
+
+    // ---- XML SUPPORT ----------------------------------------------------
+
+    /**
+     * Invoked by JAXB for getting the parameters to marshal.
+     */
+    @XmlElement(name = "parameter", required = true)
+    private GeneralParameterDescriptor[] getDescriptors() {
+        final List<GeneralParameterDescriptor> descriptors = descriptors();     // Give to user a chance to override.
+        return descriptors.toArray(new GeneralParameterDescriptor[descriptors.size()]);
+    }
+
+    /**
+     * Invoked by JAXB for setting the unmarshalled parameters.
+     */
+    private void setDescriptors(final GeneralParameterDescriptor[] parameters) {
+        if (ReferencingUtilities.canSetProperty(DefaultParameterValue.class,
+                "setDescriptors", "parameter", !descriptors.isEmpty()))
+        {
+            descriptors = asList(parameters);
+        }
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java?rev=1696849&r1=1696848&r2=1696849&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValueGroup.java [UTF-8] Thu Aug 20 19:41:49 2015
@@ -19,6 +19,8 @@ package org.apache.sis.parameter;
 import java.util.List;
 import java.util.ArrayList;
 import java.io.Serializable;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlRootElement;
 import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptor;
@@ -103,6 +105,8 @@ import java.util.Objects;
  * @see DefaultParameterDescriptorGroup
  * @see DefaultParameterValue
  */
+@XmlType(name = "ParameterValueGroupType")
+@XmlRootElement(name = "ParameterValueGroup")
 public class DefaultParameterValueGroup extends Parameters implements LenientComparable, Serializable {
     /**
      * Serial number for inter-operability with different versions.
@@ -169,8 +173,9 @@ public class DefaultParameterValueGroup
      * @return The values in this group.
      */
     @Override
+    @SuppressWarnings("ReturnOfCollectionOrArrayField")
     public List<GeneralParameterValue> values() {
-        return values;
+        return values;  // Intentionally modifiable.
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java?rev=1696849&r1=1696848&r2=1696849&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java [UTF-8] Thu Aug 20 19:41:49 2015
@@ -94,7 +94,9 @@
 })
 @XmlAccessorType(XmlAccessType.NONE)
 @XmlJavaTypeAdapters({
-    @XmlJavaTypeAdapter(CC_OperationParameter.class)
+    @XmlJavaTypeAdapter(CC_OperationParameter.class),
+    @XmlJavaTypeAdapter(CC_OperationParameterGroup.class),
+    @XmlJavaTypeAdapter(CC_GeneralOperationParameter.class)
 })
 package org.apache.sis.parameter;
 

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java?rev=1696849&r1=1696848&r2=1696849&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterBuilderTest.java [UTF-8] Thu Aug 20 19:41:49 2015
@@ -77,6 +77,7 @@ public final strictfp class ParameterBui
      */
     @Test
     @DependsOnMethod("testCreate")
+    @SuppressWarnings("UnnecessaryBoxing")
     public void testMercatorProjection() {
         final ParameterBuilder builder = new ParameterBuilder();
         builder.setCodeSpace(Citations.EPSG, "EPSG").setRequired(true);

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterFormatTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterFormatTest.java?rev=1696849&r1=1696848&r2=1696849&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterFormatTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterFormatTest.java [UTF-8] Thu Aug 20 19:41:49 2015
@@ -58,23 +58,36 @@ public final strictfp class ParameterFor
      * Creates the parameter descriptors to be used by all tests in this class. This method creates
      * a variant of the example documented in the {@link DefaultParameterDescriptorGroup} javadoc
      * with arbitrary non-zero default values.
+     *
+     * <div class="note"><b>Note:</b>
+     * the default values are not part of EPSG definitions. They are added here only for testing purpose.</div>
      */
     @BeforeClass
     public static void createParameterDescriptor() {
+        descriptor = createMercatorParameters();
+    }
+
+    /**
+     * Creates the test parameter for the Mercator projection, to be shared by {@link ParameterMarshallingTest}.
+     *
+     * <div class="note"><b>Note:</b>
+     * the default values are not part of EPSG definitions. They are added here only for testing purpose.</div>
+     */
+    static ParameterDescriptorGroup createMercatorParameters() {
         ParameterBuilder builder = new ParameterBuilder();
         builder.setCodeSpace(EPSG, "EPSG").setRequired(true);
         ParameterDescriptor<?>[] parameters = {
-            builder.addName("Latitude of natural origin")      .addName(OGC, "latitude_of_origin").createBounded( -80,  +84,  40, NonSI.DEGREE_ANGLE),
-            builder.addName("Longitude of natural origin")     .addName(OGC, "central_meridian")  .createBounded(-180, +180, -60, NonSI.DEGREE_ANGLE),
-            builder.addName("Scale factor at natural origin")  .addName(OGC, "scale_factor")      .createStrictlyPositive(1, Unit.ONE),
-            builder.addName("False easting").setRequired(false).addName(OGC, "false_easting")     .create( 5000, SI.METRE),
-            builder.addName("False northing")                  .addName(OGC, "false_northing")    .create(10000, SI.METRE)
+            builder.addIdentifier("8801").addName("Latitude of natural origin")      .addName(OGC, "latitude_of_origin").createBounded( -80,  +84,  40, NonSI.DEGREE_ANGLE),
+            builder.addIdentifier("8802").addName("Longitude of natural origin")     .addName(OGC, "central_meridian")  .createBounded(-180, +180, -60, NonSI.DEGREE_ANGLE),
+            builder.addIdentifier("8805").addName("Scale factor at natural origin")  .addName(OGC, "scale_factor")      .createStrictlyPositive(1, Unit.ONE),
+            builder.addIdentifier("8806").addName("False easting").setRequired(false).addName(OGC, "false_easting")     .create( 5000, SI.METRE),
+            builder.addIdentifier("8807").addName("False northing")                  .addName(OGC, "false_northing")    .create(10000, SI.METRE)
         };
         builder.addIdentifier("9804")
                .addName("Mercator (variant A)")
                .addName("Mercator (1SP)")
                .addName(OGC, "Mercator_1SP");
-        descriptor = builder.createGroup(parameters);
+        return builder.createGroup(parameters);
     }
 
     /**
@@ -175,6 +188,10 @@ public final strictfp class ParameterFor
 
     /**
      * Tests {@link ParameterFormat#format(Object, Appendable)} for descriptors with {@code ContentLevel.DETAILED}.
+     *
+     * <div class="note"><b>Note:</b>
+     * the default values expected by this method are not part of EPSG definitions.
+     * They are added here only for testing purpose.</div>
      */
     @Test
     public void testFormatDetailedDescriptors() {
@@ -185,24 +202,24 @@ public final strictfp class ParameterFor
                 "EPSG: Mercator (variant A) (9804)\n" +
                 "EPSG: Mercator (1SP)\n" +
                 "OGC:  Mercator_1SP\n" +
-                "╔══════════════════════════════════════╤════════╤════════════╤═══════════════╤═══════════════╗\n" +
-                "║ Name                                 │ Type   │ Obligation │ Value domain  │ Default value ║\n" +
-                "╟──────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢\n" +
-                "║ EPSG: Latitude of natural origin     │ Double │ Mandatory  │  [-80 … 84]°  │        40.0°  ║\n" +
-                "║ OGC:  latitude_of_origin             │        │            │               │               ║\n" +
-                "╟──────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢\n" +
-                "║ EPSG: Longitude of natural origin    │ Double │ Mandatory  │ [-180 … 180]° │       -60.0°  ║\n" +
-                "║ OGC:  central_meridian               │        │            │               │               ║\n" +
-                "╟──────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢\n" +
-                "║ EPSG: Scale factor at natural origin │ Double │ Mandatory  │    (0 … ∞)    │         1.0   ║\n" +
-                "║ OGC:  scale_factor                   │        │            │               │               ║\n" +
-                "╟──────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢\n" +
-                "║ EPSG: False easting                  │ Double │ Optional   │   (-∞ … ∞) m  │      5000.0 m ║\n" +
-                "║ OGC:  false_easting                  │        │            │               │               ║\n" +
-                "╟──────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢\n" +
-                "║ EPSG: False northing                 │ Double │ Optional   │   (-∞ … ∞) m  │     10000.0 m ║\n" +
-                "║ OGC:  false_northing                 │        │            │               │               ║\n" +
-                "╚══════════════════════════════════════╧════════╧════════════╧═══════════════╧═══════════════╝\n", text);
+                "╔═════════════════════════════════════════════╤════════╤════════════╤═══════════════╤═══════════════╗\n" +
+                "║ Name                                        │ Type   │ Obligation │ Value domain  │ Default value ║\n" +
+                "╟─────────────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢\n" +
+                "║ EPSG: Latitude of natural origin (8801)     │ Double │ Mandatory  │  [-80 … 84]°  │        40.0°  ║\n" +
+                "║ OGC:  latitude_of_origin                    │        │            │               │               ║\n" +
+                "╟─────────────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢\n" +
+                "║ EPSG: Longitude of natural origin (8802)    │ Double │ Mandatory  │ [-180 … 180]° │       -60.0°  ║\n" +
+                "║ OGC:  central_meridian                      │        │            │               │               ║\n" +
+                "╟─────────────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢\n" +
+                "║ EPSG: Scale factor at natural origin (8805) │ Double │ Mandatory  │    (0 … ∞)    │         1.0   ║\n" +
+                "║ OGC:  scale_factor                          │        │            │               │               ║\n" +
+                "╟─────────────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢\n" +
+                "║ EPSG: False easting (8806)                  │ Double │ Optional   │   (-∞ … ∞) m  │      5000.0 m ║\n" +
+                "║ OGC:  false_easting                         │        │            │               │               ║\n" +
+                "╟─────────────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢\n" +
+                "║ EPSG: False northing (8807)                 │ Double │ Optional   │   (-∞ … ∞) m  │     10000.0 m ║\n" +
+                "║ OGC:  false_northing                        │        │            │               │               ║\n" +
+                "╚═════════════════════════════════════════════╧════════╧════════════╧═══════════════╧═══════════════╝\n", text);
     }
 
     /**
@@ -219,21 +236,21 @@ public final strictfp class ParameterFor
                 "EPSG: Mercator (variant A) (9804)\n" +
                 "EPSG: Mercator (1SP)\n" +
                 "OGC:  Mercator_1SP\n" +
-                "╔══════════════════════════════════════╤════════╤════════════╤═══════════════╤══════════╗\n" +
-                "║ Name                                 │ Type   │ Obligation │ Value domain  │ Value    ║\n" +
-                "╟──────────────────────────────────────┼────────┼────────────┼───────────────┼──────────╢\n" +
-                "║ EPSG: Latitude of natural origin     │ Double │ Mandatory  │  [-80 … 84]°  │  20.0°   ║\n" +
-                "║ OGC:  latitude_of_origin             │        │            │               │          ║\n" +
-                "╟──────────────────────────────────────┼────────┼────────────┼───────────────┼──────────╢\n" +
-                "║ EPSG: Longitude of natural origin    │ Double │ Mandatory  │ [-180 … 180]° │ -60.0°   ║\n" +
-                "║ OGC:  central_meridian               │        │            │               │          ║\n" +
-                "╟──────────────────────────────────────┼────────┼────────────┼───────────────┼──────────╢\n" +
-                "║ EPSG: Scale factor at natural origin │ Double │ Mandatory  │    (0 … ∞)    │ 0.997    ║\n" +
-                "║ OGC:  scale_factor                   │        │            │               │          ║\n" +
-                "╟──────────────────────────────────────┼────────┼────────────┼───────────────┼──────────╢\n" +
-                "║ EPSG: False northing                 │ Double │ Optional   │   (-∞ … ∞) m  │  20.0 km ║\n" +
-                "║ OGC:  false_northing                 │        │            │               │          ║\n" +
-                "╚══════════════════════════════════════╧════════╧════════════╧═══════════════╧══════════╝\n", text);
+                "╔═════════════════════════════════════════════╤════════╤════════════╤═══════════════╤══════════╗\n" +
+                "║ Name                                        │ Type   │ Obligation │ Value domain  │ Value    ║\n" +
+                "╟─────────────────────────────────────────────┼────────┼────────────┼───────────────┼──────────╢\n" +
+                "║ EPSG: Latitude of natural origin (8801)     │ Double │ Mandatory  │  [-80 … 84]°  │  20.0°   ║\n" +
+                "║ OGC:  latitude_of_origin                    │        │            │               │          ║\n" +
+                "╟─────────────────────────────────────────────┼────────┼────────────┼───────────────┼──────────╢\n" +
+                "║ EPSG: Longitude of natural origin (8802)    │ Double │ Mandatory  │ [-180 … 180]° │ -60.0°   ║\n" +
+                "║ OGC:  central_meridian                      │        │            │               │          ║\n" +
+                "╟─────────────────────────────────────────────┼────────┼────────────┼───────────────┼──────────╢\n" +
+                "║ EPSG: Scale factor at natural origin (8805) │ Double │ Mandatory  │    (0 … ∞)    │ 0.997    ║\n" +
+                "║ OGC:  scale_factor                          │        │            │               │          ║\n" +
+                "╟─────────────────────────────────────────────┼────────┼────────────┼───────────────┼──────────╢\n" +
+                "║ EPSG: False northing (8807)                 │ Double │ Optional   │   (-∞ … ∞) m  │  20.0 km ║\n" +
+                "║ OGC:  false_northing                        │        │            │               │          ║\n" +
+                "╚═════════════════════════════════════════════╧════════╧════════════╧═══════════════╧══════════╝\n", text);
     }
 
     /**
@@ -254,15 +271,15 @@ public final strictfp class ParameterFor
 
         text = format.format(parameters.toArray(new IdentifiedObject[parameters.size()]));
         assertMultilinesEquals(
-                "┌────────────────────────────────┬────────────────────┐\n" +
-                "│ EPSG                           │ OGC                │\n" +
-                "├────────────────────────────────┼────────────────────┤\n" +
-                "│ Latitude of natural origin     │ latitude_of_origin │\n" +
-                "│ Longitude of natural origin    │ central_meridian   │\n" +
-                "│ Scale factor at natural origin │ scale_factor       │\n" +
-                "│ False easting                  │ false_easting      │\n" +
-                "│ False northing                 │ false_northing     │\n" +
-                "└────────────────────────────────┴────────────────────┘\n", text);
+                "┌────────────┬────────────────────────────────┬────────────────────┐\n" +
+                "│ Identifier │ EPSG                           │ OGC                │\n" +
+                "├────────────┼────────────────────────────────┼────────────────────┤\n" +
+                "│ EPSG:8801  │ Latitude of natural origin     │ latitude_of_origin │\n" +
+                "│ EPSG:8802  │ Longitude of natural origin    │ central_meridian   │\n" +
+                "│ EPSG:8805  │ Scale factor at natural origin │ scale_factor       │\n" +
+                "│ EPSG:8806  │ False easting                  │ false_easting      │\n" +
+                "│ EPSG:8807  │ False northing                 │ false_northing     │\n" +
+                "└────────────┴────────────────────────────────┴────────────────────┘\n", text);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java?rev=1696849&r1=1696848&r2=1696849&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterMarshallingTest.java [UTF-8] Thu Aug 20 19:41:49 2015
@@ -17,6 +17,7 @@
 package org.apache.sis.parameter;
 
 import java.util.Collections;
+import java.util.Iterator;
 import java.net.URI;
 import java.net.URISyntaxException;
 import javax.xml.bind.JAXBException;
@@ -32,10 +33,11 @@ import org.apache.sis.xml.Namespaces;
 import org.apache.sis.xml.XML;
 import org.junit.Test;
 
-import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.test.ReferencingAssert.*;
 
 // Branch-dependent imports
 import java.util.Objects;
+import org.opengis.parameter.GeneralParameterDescriptor;
 
 
 /**
@@ -234,7 +236,7 @@ public final strictfp class ParameterMar
      */
     @Test
     @DependsOnMethod("testStringValue")
-    public void testValue() throws JAXBException {
+    public void testDoubleValue() throws JAXBException {
         final DefaultParameterValue<Double> parameter = create(Double.class,
                 new MeasurementRange<Double>(Double.class, null, false, null, false, SI.METRE));
         parameter.setValue(3000, SI.METRE);
@@ -270,4 +272,41 @@ public final strictfp class ParameterMar
               + "    </gml:operationParameter>"
               + "</gml:ParameterValue>");
     }
+
+    /**
+     * Tests (un)marshalling of a parameter descriptor group.
+     *
+     * @throws JAXBException if an error occurred during marshalling or unmarshalling.
+     */
+    @Test
+    @DependsOnMethod("testDoubleValue")
+    public void testGroup() throws JAXBException {
+        assertMarshalEqualsFile("ParameterDescriptorGroup.xml",
+                ParameterFormatTest.createMercatorParameters(), "xmlns:*", "xsi:schemaLocation");
+
+        final DefaultParameterDescriptorGroup group = unmarshalFile(
+                DefaultParameterDescriptorGroup.class, "ParameterDescriptorGroup.xml");
+        assertEpsgIdentifierEquals(9804, group.getIdentifiers());
+        assertIdentifierEquals("name", "##unrestricted", "EPSG", null, "Mercator (variant A)", group.getName());
+        final Iterator<GeneralParameterDescriptor> it = group.descriptors().iterator();
+        verifyParameter(8801, "Latitude of natural origin",     "latitude_of_origin", true,  it.next());
+        verifyParameter(8802, "Longitude of natural origin",    "central_meridian",   true,  it.next());
+        verifyParameter(8805, "Scale factor at natural origin", "scale_factor",       true,  it.next());
+        verifyParameter(8806, "False easting",                  "false_easting",      false, it.next());
+        verifyParameter(8807, "False northing",                 "false_northing",     false, it.next());
+        assertFalse("Unexpected parameter.", it.hasNext());
+    }
+
+    /**
+     * Verifies that the given parameter descriptor has the expected EPSG code, name and OGC alias.
+     */
+    private static void verifyParameter(final int code, final String name, final String alias,
+            final boolean required, final GeneralParameterDescriptor descriptor)
+    {
+        assertEpsgIdentifierEquals(code, descriptor.getIdentifiers());
+        assertIdentifierEquals("name", "##unrestricted", "EPSG", null, name, descriptor.getName());
+        assertAliasTipEquals(alias, descriptor);
+        assertEquals("maximumOccurs", 1, descriptor.getMaximumOccurs());
+        assertEquals("minimumOccurs", required ? 1 : 0, descriptor.getMinimumOccurs());
+    }
 }

Added: sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterDescriptorGroup.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterDescriptorGroup.xml?rev=1696849&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterDescriptorGroup.xml (added)
+++ sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterDescriptorGroup.xml Thu Aug 20 19:41:49 2015
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<gml:OperationParameterGroup xsi:schemaLocation = "http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/coordinateOperations.xsd"
+                             xmlns:gml          = "http://www.opengis.net/gml/3.2"
+                             xmlns:xsi          = "http://www.w3.org/2001/XMLSchema-instance"
+                             gml:id             = "epsg-9804">
+
+  <gml:identifier codeSpace="EPSG">9804</gml:identifier>
+  <gml:name codeSpace="EPSG">Mercator (variant A)</gml:name>
+  <gml:name codeSpace="OGC">Mercator_1SP</gml:name>
+  <gml:minimumOccurs>0</gml:minimumOccurs>
+  <gml:parameter>
+    <gml:OperationParameter gml:id="epsg-parameter-8801">
+      <gml:identifier codeSpace="IOGP">urn:ogc:def:parameter:EPSG::8801</gml:identifier>
+      <gml:name codeSpace="EPSG">Latitude of natural origin</gml:name>
+      <gml:name codeSpace="OGC">latitude_of_origin</gml:name>
+    </gml:OperationParameter>
+  </gml:parameter>
+  <gml:parameter>
+    <gml:OperationParameter gml:id="epsg-parameter-8802">
+      <gml:identifier codeSpace="IOGP">urn:ogc:def:parameter:EPSG::8802</gml:identifier>
+      <gml:name codeSpace="EPSG">Longitude of natural origin</gml:name>
+      <gml:name codeSpace="OGC">central_meridian</gml:name>
+    </gml:OperationParameter>
+  </gml:parameter>
+  <gml:parameter>
+    <gml:OperationParameter gml:id="epsg-parameter-8805">
+      <gml:identifier codeSpace="IOGP">urn:ogc:def:parameter:EPSG::8805</gml:identifier>
+      <gml:name codeSpace="EPSG">Scale factor at natural origin</gml:name>
+      <gml:name codeSpace="OGC">scale_factor</gml:name>
+    </gml:OperationParameter>
+  </gml:parameter>
+  <gml:parameter>
+    <gml:OperationParameter gml:id="epsg-parameter-8806">
+      <gml:identifier codeSpace="IOGP">urn:ogc:def:parameter:EPSG::8806</gml:identifier>
+      <gml:name codeSpace="EPSG">False easting</gml:name>
+      <gml:name codeSpace="OGC">false_easting</gml:name>
+      <gml:minimumOccurs>0</gml:minimumOccurs>
+    </gml:OperationParameter>
+  </gml:parameter>
+  <gml:parameter>
+    <gml:OperationParameter gml:id="epsg-parameter-8807">
+      <gml:identifier codeSpace="IOGP">urn:ogc:def:parameter:EPSG::8807</gml:identifier>
+      <gml:name codeSpace="EPSG">False northing</gml:name>
+      <gml:name codeSpace="OGC">false_northing</gml:name>
+      <gml:minimumOccurs>0</gml:minimumOccurs>
+    </gml:OperationParameter>
+  </gml:parameter>
+</gml:OperationParameterGroup>

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterDescriptorGroup.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterDescriptorGroup.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java?rev=1696849&r1=1696848&r2=1696849&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java [UTF-8] Thu Aug 20 19:41:49 2015
@@ -76,6 +76,7 @@ public final class Utilities extends Sta
             final String text, final String accepted, final boolean toLowerCase)
     {
         boolean added = false;
+        boolean toUpperCase = false;
         if (text != null) {
             for (int i=0; i<text.length();) {
                 final int c = text.codePointAt(i);
@@ -86,8 +87,12 @@ public final class Utilities extends Sta
                     if (!isFirst && !added && separator != 0) {
                         appendTo.append(separator);
                     }
-                    appendTo.appendCodePoint(toLowerCase ? Character.toLowerCase(c) : c);
+                    appendTo.appendCodePoint(toLowerCase ? Character.toLowerCase(c) :
+                                             toUpperCase ? Character.toUpperCase(c) : c);
                     added = true;
+                    toUpperCase = false;
+                } else {
+                    toUpperCase = true;
                 }
                 i += Character.charCount(c);
             }



Mime
View raw message