sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1696890 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/internal/jaxb/referencing/ main/java/org/apache/sis/internal/referencing/ main/java/org/apache/sis/parameter/ test/java/org/apache/sis/parameter/ test/resou...
Date Fri, 21 Aug 2015 04:04:48 GMT
Author: desruisseaux
Date: Fri Aug 21 04:04:48 2015
New Revision: 1696890

URL: http://svn.apache.org/r1696890
Log:
Partial support of <gml:ParameterValueGroup>.
Still missing the handling of the ParameterDescriptorGroup under the <gml:group> element.

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
      - copied, changed from r1696849, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterValue.txt
  (with props)
    sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterValueGroup.xml
      - copied, changed from r1696849, sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterDescriptorGroup.xml
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.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/ParameterValueList.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.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/ParameterMarshallingTest.java

Modified: 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=1696890&r1=1696889&r2=1696890&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
[UTF-8] Fri Aug 21 04:04:48 2015
@@ -75,10 +75,12 @@ public final class CC_GeneralOperationPa
 
     /**
      * Invoked by JAXB at marshalling time for getting the actual element to write
-     * inside the {@code <gml:OperationParameter>} XML element.
+     * inside the {@code <gml:parameter>} 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.
+     *
+     * @see CC_GeneralParameterValue#getElement()
      */
     @XmlElementRef
     public AbstractParameterDescriptor getElement() {

Copied: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
(from r1696849, 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_GeneralParameterValue.java?p2=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java&p1=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java&r1=1696849&r2=1696890&rev=1696890&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
[UTF-8] Fri Aug 21 04:04:48 2015
@@ -16,13 +16,13 @@
  */
 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 javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import org.opengis.parameter.ParameterValue;
+import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.parameter.GeneralParameterValue;
+import org.apache.sis.parameter.DefaultParameterValue;
+import org.apache.sis.parameter.DefaultParameterValueGroup;
 import org.apache.sis.internal.jaxb.gco.PropertyType;
 
 
@@ -35,11 +35,11 @@ import org.apache.sis.internal.jaxb.gco.
  * @version 0.6
  * @module
  */
-public final class CC_GeneralOperationParameter extends PropertyType<CC_GeneralOperationParameter,GeneralParameterDescriptor>
{
+public final class CC_GeneralParameterValue extends PropertyType<CC_GeneralParameterValue,
GeneralParameterValue> {
     /**
      * Empty constructor for JAXB only.
      */
-    public CC_GeneralOperationParameter() {
+    public CC_GeneralParameterValue() {
     }
 
     /**
@@ -47,50 +47,58 @@ public final class CC_GeneralOperationPa
      * 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}
+     * @return {@code GeneralParameterValue.class}
      */
     @Override
-    protected Class<GeneralParameterDescriptor> getBoundType() {
-        return GeneralParameterDescriptor.class;
+    protected Class<GeneralParameterValue> getBoundType() {
+        return GeneralParameterValue.class;
     }
 
     /**
      * Constructor for the {@link #wrap} method only.
      */
-    private CC_GeneralOperationParameter(final GeneralParameterDescriptor parameter) {
+    private CC_GeneralParameterValue(final GeneralParameterValue 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.
+     * Invoked by {@link PropertyType} at marshalling time for wrapping the given value
+     * in a {@code <gml:ParameterValue>} or {@code <gml:ParameterValueGroup>}
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);
+    protected CC_GeneralParameterValue wrap(final GeneralParameterValue parameter) {
+        return new CC_GeneralParameterValue(parameter);
     }
 
     /**
      * Invoked by JAXB at marshalling time for getting the actual element to write
-     * inside the {@code <gml:OperationParameter>} XML element.
+     * inside the {@code <gml:parameterValue>} 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.
+     *
+     * @see CC_GeneralOperationParameter#getElement()
      */
-    @XmlElementRef
-    public AbstractParameterDescriptor getElement() {
-        final GeneralParameterDescriptor metadata = this.metadata;
-        if (metadata instanceof AbstractParameterDescriptor) {
-            return (AbstractParameterDescriptor) metadata;
+    @XmlElements({  // We can not use @XmlElementRef because we have no public AbstractParameterValue
parent class.
+        @XmlElement(name = "ParameterValue",      type = DefaultParameterValue.class),
+        @XmlElement(name = "ParameterValueGroup", type = DefaultParameterValueGroup.class)
+    })
+    public GeneralParameterValue getElement() {
+        final GeneralParameterValue metadata = this.metadata;
+        if (metadata instanceof DefaultParameterValue<?>) {
+            return (DefaultParameterValue<?>) metadata;
+        }
+        if (metadata instanceof DefaultParameterValueGroup) {
+            return (DefaultParameterValueGroup) metadata;
         }
-        if (metadata instanceof ParameterDescriptor) {
-            return DefaultParameterDescriptor.castOrCopy((ParameterDescriptor<?>) metadata);
+        if (metadata instanceof ParameterValue) {
+            return new DefaultParameterValue<>((ParameterValue<?>) metadata);
         }
-        if (metadata instanceof ParameterDescriptorGroup) {
-            return DefaultParameterDescriptorGroup.castOrCopy((ParameterDescriptorGroup)
metadata);
+        if (metadata instanceof ParameterValueGroup) {
+            return new DefaultParameterValueGroup((ParameterValueGroup) metadata);
         }
         return null;    // Unknown types are currently not marshalled (we may revisit that
in a future SIS version).
     }
@@ -100,7 +108,7 @@ public final class CC_GeneralOperationPa
      *
      * @param parameter The unmarshalled element.
      */
-    public void setElement(final AbstractParameterDescriptor parameter) {
+    public void setElement(final GeneralParameterValue parameter) {
         metadata = parameter;
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java?rev=1696890&r1=1696889&r2=1696890&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
[UTF-8] Fri Aug 21 04:04:48 2015
@@ -19,6 +19,7 @@ package org.apache.sis.internal.referenc
 import java.util.Collection;
 import org.apache.sis.internal.jaxb.TypeRegistration;
 import org.apache.sis.parameter.DefaultParameterValue;
+import org.apache.sis.parameter.DefaultParameterValueGroup;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
 
 
@@ -39,5 +40,6 @@ public final class ReferencingTypes exte
     public void getTypes(final Collection<Class<?>> addTo) {
         addTo.add(AbstractIdentifiedObject.class);
         addTo.add(DefaultParameterValue.class);
+        addTo.add(DefaultParameterValueGroup.class);
     }
 }

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterValue.txt
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterValue.txt?rev=1696890&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterValue.txt
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterValue.txt
[UTF-8] Fri Aug 21 04:04:48 2015
@@ -0,0 +1,5 @@
+There is no AbstractParameterValue class because we do not need it.
+However if a public AbstractParameterValue class is provided in the
+future, then we could simplify a little bit the JAXB annotations on
+CC_GeneralParameterValue.getElement(). We don't do that for now
+because this is a too minor convenience for growing the public API.

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterValue.txt
------------------------------------------------------------------------------
    svn:eol-style = native

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

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=1696890&r1=1696889&r2=1696890&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] Fri Aug 21 04:04:48 2015
@@ -43,19 +43,23 @@ import static org.apache.sis.util.Utilit
 /**
  * The definition of a group of related parameters used by an operation method.
  * {@code DefaultParameterDescriptorGroup} instances are immutable and thus thread-safe.
- * Each map projection or process will typically defines a single static {@code ParameterDescriptorGroup},
- * to be shared by all users of that projection or process.
  *
  * <div class="section">Instantiation</div>
- * Coordinate operation or process <em>implementors</em> may use the {@link ParameterBuilder}
class for making
- * their task easier.
+ * Parameter descriptors are usually pre-defined by the SIS library and available through
the following methods:
+ *
+ * <ul>
+ *   <li>{@link org.apache.sis.referencing.operation.DefaultOperationMethod#getParameters()}</li>
+ * </ul>
+ *
+ * If nevertheless a {@code ParameterDescriptorGroup} needs to be instantiated directly,
+ * then the {@link ParameterBuilder} class may make the task easier.
  *
  * <div class="note"><b>Example:</b>
  * The following example declares the parameters for a <cite>Mercator (variant A)</cite>
projection method
  * valid from 80°S to 84°N on all the longitude range (±180°).
  *
  * {@preformat java
- *     public class Mercator {
+ *     class Mercator {
  *         static final ParameterDescriptorGroup PARAMETERS;
  *         static {
  *             ParameterBuilder builder = new ParameterBuilder();
@@ -77,18 +81,10 @@ import static org.apache.sis.util.Utilit
  * }
  * </div>
  *
- * <div class="section">Usage</div>
- * Users can simply reference the descriptor provided par a coordinate operation or process
providers like below:
- *
- * {@preformat java
- *     ParameterValueGroup parameters = Mercator.PARAMETERS.createValue();
- *     // See DefaultParameterValueGroup for examples on 'parameters' usage.
- * }
- *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @author  Johann Sorel (Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.6
  * @module
  *
  * @see DefaultParameterValueGroup

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=1696890&r1=1696889&r2=1696890&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] Fri Aug 21 04:04:48 2015
@@ -18,8 +18,10 @@ package org.apache.sis.parameter;
 
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.io.Serializable;
 import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
@@ -29,6 +31,8 @@ import org.opengis.parameter.GeneralPara
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.opengis.parameter.ParameterNotFoundException;
 import org.opengis.parameter.InvalidParameterCardinalityException;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.util.collection.Containers;
 import org.apache.sis.util.LenientComparable;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.resources.Errors;
@@ -105,7 +109,10 @@ import java.util.Objects;
  * @see DefaultParameterDescriptorGroup
  * @see DefaultParameterValue
  */
-@XmlType(name = "ParameterValueGroupType")
+@XmlType(name = "ParameterValueGroupType", propOrder = {
+    "values",
+    "descriptor"
+})
 @XmlRootElement(name = "ParameterValueGroup")
 public class DefaultParameterValueGroup extends Parameters implements LenientComparable,
Serializable {
     /**
@@ -116,12 +123,23 @@ public class DefaultParameterValueGroup
     /**
      * Contains the descriptor and the {@linkplain #values() parameter values} for this group.
      *
-     * <p>Consider this field as final. It is not for the purpose of {@link #clone()}.</p>
+     * <p><b>Consider this field as final!</b>
+     * This field is modified only by the {@link #clone()} method and
+     * at unmarshalling time by {@link #setValues(GeneralParameterValue[])}</p>
+     *
+     * @see #values()
      */
     private ParameterValueList values;
 
     /**
-     * Constructs a parameter group from the specified descriptor.
+     * Default constructor for JAXB only. The values list is initialized to {@code null},
+     * but will be assigned a value after XML unmarshalling.
+     */
+    private DefaultParameterValueGroup() {
+    }
+
+    /**
+     * Creates a parameter group from the specified descriptor.
      *
      * <p><b>Usage note:</b> {@code ParameterValueGroup} are usually not
instantiated directly. Instead, consider
      * invoking <code>descriptor.{@linkplain DefaultParameterDescriptorGroup#createValue()
createValue()}</code>
@@ -135,6 +153,23 @@ public class DefaultParameterValueGroup
     }
 
     /**
+     * Creates a new instance initialized with all values from the specified parameter group.
+     * This is a <em>shallow</em> copy constructor, since the values contained
in the given
+     * group is not cloned.
+     *
+     * @param parameters The parameters to copy values from.
+     *
+     * @see #clone()
+     *
+     * @since 0.6
+     */
+    public DefaultParameterValueGroup(final ParameterValueGroup parameters) {
+        ArgumentChecks.ensureNonNull("parameters", parameters);
+        values = new ParameterValueList(parameters.getDescriptor());
+        values.addAll(parameters.values());
+    }
+
+    /**
      * Conservatively returns {@code false} if this instance is for a subclass, because we
do not know if the
      * subclass overrides {@link #parameter(String)} in a way incompatible with {@link #parameterIfExist(String)}.
      * (note: using {@code Class.getMethod(…).getDeclaringClass()} is presumed not worth
the cost.
@@ -150,8 +185,11 @@ public class DefaultParameterValueGroup
      * @return The abstract definition of this group of parameters.
      */
     @Override
+    @XmlElement(name = "group")
     public ParameterDescriptorGroup getDescriptor() {
-        return values.descriptor;
+        // The descriptor is not allowed to be null, but this situation
+        // may exist temporarily during XML unmarshalling.
+        return (values != null) ? values.descriptor : null;
     }
 
     /**
@@ -464,4 +502,45 @@ public class DefaultParameterValueGroup
     public void print() {
         ParameterFormat.print(this);
     }
+
+    // ---- XML SUPPORT ----------------------------------------------------
+
+    /**
+     * Invoked by JAXB for getting the parameters to marshal.
+     */
+    @XmlElement(name = "parameterValue", required = true)
+    private GeneralParameterValue[] getValues() {
+        final List<GeneralParameterValue> values = values();   // Gives to user a chance
to override.
+        return values.toArray(new GeneralParameterValue[values.size()]);
+    }
+
+    /**
+     * Invoked by JAXB for setting the unmarshalled parameters.
+     */
+    private void setValues(final GeneralParameterValue[] parameters) {
+        if (ReferencingUtilities.canSetProperty(DefaultParameterValue.class,
+                "setValues", "parameterValue", !Containers.isNullOrEmpty(values)))
+        {
+            if (values == null) {
+                values = new ParameterValueList(parameters);
+            } else {
+                values.addAll(Arrays.asList(parameters));
+            }
+        }
+    }
+
+    /**
+     * Invoked by JAXB for setting the parameter descriptor.
+     *
+     * @see #getDescriptor()
+     */
+    private void setDescriptor(final ParameterDescriptorGroup descriptor) {
+        if (values == null) {
+// TODO     values = new ParameterValueList(descriptor);
+        } else if (ReferencingUtilities.canSetProperty(DefaultParameterValue.class,
+                "setDescriptor", "group", values.descriptor != null))
+        {
+            values.descriptor = descriptor;
+        }
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java?rev=1696890&r1=1696889&r2=1696890&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
[UTF-8] Fri Aug 21 04:04:48 2015
@@ -62,8 +62,12 @@ final class ParameterValueList extends A
      *
      * <p>This descriptor shall not be used in {@link #equals(Object)} and {@link #hashCode()}
      * implementations in order to stay consistent with the {@link List} contract.</p>
+     *
+     * <p><b>Consider this field as final!</b>
+     * This field is modified only at unmarshalling time by
+     * {@link DefaultParameterValueGroup#setDescriptor(ParameterDescriptorGroup)}.</p>
      */
-    final ParameterDescriptorGroup descriptor;
+    ParameterDescriptorGroup descriptor;
 
     /**
      * The parameter values in the group. The length of this array is the list capacity.
@@ -77,6 +81,17 @@ final class ParameterValueList extends A
     private int size;
 
     /**
+     * Constructs a parameter without descriptor and with the given parameters.
+     * <b>It is caller's responsibility to assign an instance to the {@link #descriptor}
field.</b>
+     *
+     * <p>This constructor shall be used only at JAXB unmarshalling time, when the
descriptor is not yet known.</p>
+     */
+    ParameterValueList(final GeneralParameterValue[] parameters) {
+        values = parameters;
+        size = parameters.length;
+    }
+
+    /**
      * Constructs an initially empty parameter list.
      *
      * @param descriptor The descriptor for this list.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java?rev=1696890&r1=1696889&r2=1696890&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
[UTF-8] Fri Aug 21 04:04:48 2015
@@ -20,6 +20,7 @@ import java.util.Map;
 import java.util.HashMap;
 import java.util.List;
 import java.io.Serializable;
+import javax.xml.bind.annotation.XmlTransient;
 import javax.measure.unit.Unit;
 import org.opengis.util.MemberName;
 import org.opengis.metadata.Identifier;
@@ -110,6 +111,7 @@ import static org.apache.sis.referencing
  * @version 0.6
  * @module
  */
+@XmlTransient
 public abstract class Parameters implements ParameterValueGroup, Cloneable {
     /**
      * For subclass constructors only.

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=1696890&r1=1696889&r2=1696890&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] Fri Aug 21 04:04:48 2015
@@ -96,7 +96,8 @@
 @XmlJavaTypeAdapters({
     @XmlJavaTypeAdapter(CC_OperationParameter.class),
     @XmlJavaTypeAdapter(CC_OperationParameterGroup.class),
-    @XmlJavaTypeAdapter(CC_GeneralOperationParameter.class)
+    @XmlJavaTypeAdapter(CC_GeneralOperationParameter.class),
+    @XmlJavaTypeAdapter(CC_GeneralParameterValue.class)
 })
 package org.apache.sis.parameter;
 

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=1696890&r1=1696889&r2=1696890&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] Fri Aug 21 04:04:48 2015
@@ -21,9 +21,14 @@ import java.util.Iterator;
 import java.net.URI;
 import java.net.URISyntaxException;
 import javax.xml.bind.JAXBException;
+import javax.measure.unit.Unit;
 import javax.measure.unit.SI;
+import javax.measure.unit.NonSI;
 import org.opengis.test.Validators;
+import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterDescriptor;
+import org.opengis.parameter.GeneralParameterValue;
+import org.opengis.parameter.GeneralParameterDescriptor;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.MeasurementRange;
 import org.apache.sis.test.DependsOn;
@@ -37,7 +42,6 @@ import static org.apache.sis.test.Refere
 
 // Branch-dependent imports
 import java.util.Objects;
-import org.opengis.parameter.GeneralParameterDescriptor;
 
 
 /**
@@ -280,7 +284,7 @@ public final strictfp class ParameterMar
      */
     @Test
     @DependsOnMethod("testDoubleValue")
-    public void testGroup() throws JAXBException {
+    public void testDescriptorGroup() throws JAXBException {
         assertMarshalEqualsFile("ParameterDescriptorGroup.xml",
                 ParameterFormatTest.createMercatorParameters(), "xmlns:*", "xsi:schemaLocation");
 
@@ -288,19 +292,42 @@ public final strictfp class ParameterMar
                 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());
+        verifyDescriptor(8801, "Latitude of natural origin",     "latitude_of_origin", true,
 it.next());
+        verifyDescriptor(8802, "Longitude of natural origin",    "central_meridian",   true,
 it.next());
+        verifyDescriptor(8805, "Scale factor at natural origin", "scale_factor",       true,
 it.next());
+        verifyDescriptor(8806, "False easting",                  "false_easting",      false,
it.next());
+        verifyDescriptor(8807, "False northing",                 "false_northing",     false,
it.next());
+        assertFalse("Unexpected parameter.", it.hasNext());
+    }
+
+    /**
+     * Tests (un)marshalling of a parameter value group.
+     *
+     * @throws JAXBException if an error occurred during marshalling or unmarshalling.
+     */
+    @Test
+    @DependsOnMethod("testDescriptorGroup")
+    public void testValueGroup() throws JAXBException {
+        assertMarshalEqualsFile("ParameterValueGroup.xml",
+                ParameterFormatTest.createMercatorParameters().createValue(),
+                "xmlns:*", "xsi:schemaLocation", "gml:id");
+
+        final DefaultParameterValueGroup group = unmarshalFile(
+                DefaultParameterValueGroup.class, "ParameterValueGroup.xml");
+
+        final Iterator<GeneralParameterValue> it = group.values().iterator();
+        verifyParameter(8801, "Latitude of natural origin",     "latitude_of_origin", true,
 40, NonSI.DEGREE_ANGLE, it.next());
+        verifyParameter(8802, "Longitude of natural origin",    "central_meridian",   true,
-60, NonSI.DEGREE_ANGLE, it.next());
+        verifyParameter(8805, "Scale factor at natural origin", "scale_factor",       true,
  1, Unit.ONE,           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,
+    private static void verifyDescriptor(final int code, final String name, final String
alias,
             final boolean required, final GeneralParameterDescriptor descriptor)
     {
         assertEpsgIdentifierEquals(code, descriptor.getIdentifiers());
@@ -309,4 +336,21 @@ public final strictfp class ParameterMar
         assertEquals("maximumOccurs", 1, descriptor.getMaximumOccurs());
         assertEquals("minimumOccurs", required ? 1 : 0, descriptor.getMinimumOccurs());
     }
+
+    /**
+     * Verifies that the given parameter value has the expected value and descriptor properties.
+     */
+    private static void verifyParameter(final int code, final String name, final String alias,
+            final boolean required, final double value, final Unit<?> unit,
+            final GeneralParameterValue parameter)
+    {
+        verifyDescriptor(code, name, alias, required, parameter.getDescriptor());
+        assertInstanceOf(name, ParameterValue.class, parameter);
+        final ParameterValue<?> p = (ParameterValue<?>) parameter;
+        final ParameterDescriptor<?> d = p.getDescriptor();
+        assertEquals("value",      value,        p.doubleValue(), STRICT);
+        assertEquals("unit",       unit,         p.getUnit());
+        assertEquals("valueClass", Double.class, d.getValueClass());
+        assertEquals("unit",       unit,         d.getUnit());
+    }
 }

Copied: sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterValueGroup.xml
(from r1696849, 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/ParameterValueGroup.xml?p2=sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterValueGroup.xml&p1=sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterDescriptorGroup.xml&r1=1696849&r2=1696890&rev=1696890&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterDescriptorGroup.xml
(original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/parameter/ParameterValueGroup.xml
Fri Aug 21 04:04:48 2015
@@ -18,50 +18,95 @@
   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:ParameterValueGroup 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: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:parameterValue>
+    <gml:ParameterValue>
+      <gml:value uom="urn:ogc:def:uom:EPSG::9102">40.0</gml:value>
+      <gml:operationParameter>
+        <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:operationParameter>
+    </gml:ParameterValue>
+  </gml:parameterValue>
+  <gml:parameterValue>
+    <gml:ParameterValue>
+      <gml:value uom="urn:ogc:def:uom:EPSG::9102">-60.0</gml:value>
+      <gml:operationParameter>
+        <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:operationParameter>
+    </gml:ParameterValue>
+  </gml:parameterValue>
+  <gml:parameterValue>
+    <gml:ParameterValue>
+      <gml:value uom="urn:ogc:def:uom:EPSG::9201">1.0</gml:value>
+      <gml:operationParameter>
+        <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:operationParameter>
+    </gml:ParameterValue>
+  </gml:parameterValue>
+  <gml:group>
+    <gml:OperationParameterGroup 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: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>
+
+      <!-- All parameters below this point are duplication of the parameters already defined
above.
+           For now we do not yet use the XML references, but this is something that we will
need to
+           support in a future SIS version. See https://issues.apache.org/jira/browse/SIS-173
issue.
+           In the meantime, we have to change the gml:id attribute values used below for
avoiding
+           collisions with the gml:id attribute used in above parameters. -->
+      <gml:parameter>
+        <gml:OperationParameter gml:id="epsg-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-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-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>
+  </gml:group>
+</gml:ParameterValueGroup>



Mime
View raw message