sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1653480 - in /sis/branches/JDK8/core: sis-referencing/src/main/java/org/apache/sis/parameter/ sis-referencing/src/test/java/org/apache/sis/parameter/ sis-utility/src/main/java/org/apache/sis/util/resources/
Date Wed, 21 Jan 2015 11:20:37 GMT
Author: desruisseaux
Date: Wed Jan 21 11:20:37 2015
New Revision: 1653480

URL: http://svn.apache.org/r1653480
Log:
Ported Parameters.copy(...) and tuned formatting of multi-occurrences of a parameter value.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.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/ParametersTest.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java?rev=1653480&r1=1653479&r2=1653480&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
[UTF-8] Wed Jan 21 11:20:37 2015
@@ -578,6 +578,7 @@ public class ParameterFormat extends Tab
                 new TableAppender(out, columnSeparator) : new TableAppender(out);
         table.setMultiLinesCells(true);
         table.nextLine(horizontalBorder);
+        int numColumnsBeforeValue = 0;
         for (int i=0; ; i++) {
             boolean end = false;
             final short key;
@@ -616,6 +617,7 @@ public class ParameterFormat extends Tab
             }
             if (end) break;
             nextColumn(table);
+            numColumnsBeforeValue++;
         }
         table.nextLine();
         /*
@@ -683,8 +685,25 @@ public class ParameterFormat extends Tab
                     Object value = row.values.get(i);
                     if (value != null) {
                         if (i != 0) {
-                            table.append(lineSeparator);
+                            /*
+                             * If the same parameter is repeated more than once (not allowed
by ISO 19111,
+                             * but this extra flexibility is allowed by Apache SIS), write
the ditto mark
+                             * in all previous columns (name, type, etc.) on a new row.
+                             */
+                            final String ditto = resources.getString(Vocabulary.Keys.DittoMark);
+                            table.nextLine();
+                            table.setCellAlignment(TableAppender.ALIGN_CENTER);
+                            for (int j=0; j<numColumnsBeforeValue; j++) {
+                                table.append(ditto);
+                                nextColumn(table);
+                            }
+                            table.setCellAlignment(TableAppender.ALIGN_RIGHT);
                         }
+                        /*
+                         * Format the value followed by the unit of measure, or followed
by spaces if there is no unit
+                         * for this value. The intend is the right align the numerical value
rather than the numerical
+                         * + unit tupple.
+                         */
                         final Format format = getFormat(value.getClass());
                         if (format != null) {
                             value = format.format(value, buffer, dummyFP);

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=1653480&r1=1653479&r2=1653480&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] Wed Jan 21 11:20:37 2015
@@ -18,8 +18,7 @@ package org.apache.sis.parameter;
 
 import javax.measure.unit.Unit;
 import org.opengis.util.MemberName;
-import org.opengis.parameter.ParameterValue;
-import org.opengis.parameter.ParameterDescriptor;
+import org.opengis.parameter.*; // We use almost all types from this package.
 import org.apache.sis.internal.jaxb.metadata.replace.ServiceParameter;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.NumberRange;
@@ -44,6 +43,75 @@ public final class Parameters extends St
     }
 
     /**
+     * Gets the parameter name as an instance of {@code MemberName}.
+     * This method performs the following checks:
+     *
+     * <ul>
+     *   <li>If the {@linkplain DefaultParameterDescriptor#getName() primary name}
is an instance of {@code MemberName},
+     *       returns that primary name.</li>
+     *   <li>Otherwise this method searches for the first {@linkplain DefaultParameterDescriptor#getAlias()
alias}
+     *       which is an instance of {@code MemberName}. If found, that alias is returned.</li>
+     *   <li>If no alias is found, then this method tries to build a member name from
the primary name and the
+     *       {@linkplain DefaultParameterDescriptor#getValueClass() value class}, using the
mapping defined in
+     *       {@link org.apache.sis.util.iso.DefaultTypeName} javadoc.</li>
+     * </ul>
+     *
+     * This method can be used as a bridge between the parameter object
+     * defined by ISO 19111 (namely {@code CC_OperationParameter}) and the one
+     * defined by ISO 19115 (namely {@code SV_Parameter}).
+     *
+     * @param  parameter The parameter from which to get the name (may be {@code null}).
+     * @return The member name, or {@code null} if none.
+     *
+     * @see org.apache.sis.util.iso.Names#createMemberName(CharSequence, String, CharSequence,
Class)
+     *
+     * @since 0.5
+     */
+    public static MemberName getMemberName(final ParameterDescriptor<?> parameter)
{
+        return ServiceParameter.getMemberName(parameter);
+    }
+
+    /**
+     * Returns the domain of valid values defined by the given descriptor, or {@code null}
if none.
+     * This method builds the range from the {@linkplain DefaultParameterDescriptor#getMinimumValue()
minimum value},
+     * {@linkplain DefaultParameterDescriptor#getMaximumValue() maximum value} and, if the
values are numeric, from
+     * the {@linkplain DefaultParameterDescriptor#getUnit() unit}.
+     *
+     * @param  descriptor The parameter descriptor, or {@code null}.
+     * @return The domain of valid values, or {@code null} if none.
+     *
+     * @see DefaultParameterDescriptor#getValueDomain()
+     */
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    public static Range<?> getValueDomain(final ParameterDescriptor<?> descriptor)
{
+        if (descriptor != null) {
+            if (descriptor instanceof DefaultParameterDescriptor<?>) {
+                return ((DefaultParameterDescriptor<?>) descriptor).getValueDomain();
+            }
+            final Class<?> valueClass = descriptor.getValueClass();
+            final Comparable<?> minimumValue = descriptor.getMinimumValue();
+            final Comparable<?> maximumValue = descriptor.getMaximumValue();
+            if ((minimumValue == null || valueClass.isInstance(minimumValue)) &&
+                (maximumValue == null || valueClass.isInstance(maximumValue)))
+            {
+                if (Number.class.isAssignableFrom(valueClass)) {
+                    final Unit<?> unit = descriptor.getUnit();
+                    if (unit != null) {
+                        return new MeasurementRange((Class) valueClass,
+                                (Number) minimumValue, true, (Number) maximumValue, true,
unit);
+                    } else if (minimumValue != null || maximumValue != null) {
+                        return new NumberRange((Class) valueClass,
+                                (Number) minimumValue, true, (Number) maximumValue, true);
+                    }
+                } else if (minimumValue != null || maximumValue != null) {
+                    return new Range(valueClass, minimumValue, true, maximumValue, true);
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
      * Casts the given parameter descriptor to the given type.
      * An exception is thrown immediately if the parameter does not have the expected
      * {@linkplain DefaultParameterDescriptor#getValueClass() value class}.
@@ -100,71 +168,65 @@ public final class Parameters extends St
     }
 
     /**
-     * Returns the domain of valid values defined by the given descriptor, or {@code null}
if none.
-     * This method builds the range from the {@linkplain DefaultParameterDescriptor#getMinimumValue()
minimum value},
-     * {@linkplain DefaultParameterDescriptor#getMaximumValue() maximum value} and, if the
values are numeric, from
-     * the {@linkplain DefaultParameterDescriptor#getUnit() unit}.
-     *
-     * @param  descriptor The parameter descriptor, or {@code null}.
-     * @return The domain of valid values, or {@code null} if none.
+     * Copies the values of a parameter group into another parameter group.
+     * All values in the {@code source} group shall be valid for the {@code destination}
group,
+     * but the {@code destination} may have more parameters.
+     * Sub-groups are copied recursively.
+     *
+     * <p>A typical usage of this method is for transferring values from an arbitrary
implementation
+     * to some specific implementation.</p>
+     *
+     * @param  values The parameters values to copy.
+     * @param  destination Where to copy the values.
+     * @throws InvalidParameterNameException if a {@code source} parameter name is unknown
to the {@code destination}.
+     * @throws InvalidParameterValueException if the value of a {@code source} parameter
is invalid for the {@code destination}.
      *
-     * @see DefaultParameterDescriptor#getValueDomain()
+     * @since 0.5
      */
-    @SuppressWarnings({"unchecked", "rawtypes"})
-    public static Range<?> getValueDomain(final ParameterDescriptor<?> descriptor)
{
-        if (descriptor != null) {
-            if (descriptor instanceof DefaultParameterDescriptor<?>) {
-                return ((DefaultParameterDescriptor<?>) descriptor).getValueDomain();
-            }
-            final Class<?> valueClass = descriptor.getValueClass();
-            final Comparable<?> minimumValue = descriptor.getMinimumValue();
-            final Comparable<?> maximumValue = descriptor.getMaximumValue();
-            if ((minimumValue == null || valueClass.isInstance(minimumValue)) &&
-                (maximumValue == null || valueClass.isInstance(maximumValue)))
-            {
-                if (Number.class.isAssignableFrom(valueClass)) {
-                    final Unit<?> unit = descriptor.getUnit();
-                    if (unit != null) {
-                        return new MeasurementRange((Class) valueClass,
-                                (Number) minimumValue, true, (Number) maximumValue, true,
unit);
-                    } else if (minimumValue != null || maximumValue != null) {
-                        return new NumberRange((Class) valueClass,
-                                (Number) minimumValue, true, (Number) maximumValue, true);
-                    }
-                } else if (minimumValue != null || maximumValue != null) {
-                    return new Range(valueClass, minimumValue, true, maximumValue, true);
+    public static void copy(final ParameterValueGroup values, final ParameterValueGroup destination)
+            throws InvalidParameterNameException, InvalidParameterValueException
+    {
+        for (final GeneralParameterValue value : values.values()) {
+            final String name = value.getDescriptor().getName().getCode();
+            if (value instanceof ParameterValueGroup) {
+                /*
+                 * Contains sub-group - invokes 'copy' recursively.
+                 */
+                final GeneralParameterDescriptor descriptor;
+                descriptor = destination.getDescriptor().descriptor(name);
+                if (descriptor instanceof ParameterDescriptorGroup) {
+                    final ParameterValueGroup groups = (ParameterValueGroup) descriptor.createValue();
+                    copy((ParameterValueGroup) value, groups);
+                    values.groups(name).add(groups);
+                    continue;
+                } else {
+                    throw new InvalidParameterNameException(Errors.format(
+                            Errors.Keys.UnexpectedParameter_1, name), name);
                 }
             }
+            /*
+             * Single parameter - copy the value, with special care for value with units.
+             */
+            final ParameterValue<?> source = (ParameterValue<?>) value;
+            final ParameterValue<?> target;
+            try {
+                target = destination.parameter(name);
+            } catch (ParameterNotFoundException cause) {
+                throw new InvalidParameterNameException(Errors.format(
+                            Errors.Keys.UnexpectedParameter_1, name), cause, name);
+            }
+            final Object  v    = source.getValue();
+            final Unit<?> unit = source.getUnit();
+            if (unit == null) {
+                target.setValue(v);
+            } else if (v instanceof Number) {
+                target.setValue(((Number) v).doubleValue(), unit);
+            } else if (v instanceof double[]) {
+                target.setValue((double[]) v, unit);
+            } else {
+                throw new InvalidParameterValueException(Errors.format(
+                        Errors.Keys.IllegalArgumentValue_2, name, v), name, v);
+            }
         }
-        return null;
-    }
-
-    /**
-     * Gets the parameter name as an instance of {@code MemberName}.
-     * This method performs the following checks:
-     *
-     * <ul>
-     *   <li>If the {@linkplain DefaultParameterDescriptor#getName() primary name}
is an instance of {@code MemberName},
-     *       returns that primary name.</li>
-     *   <li>Otherwise this method searches for the first {@linkplain DefaultParameterDescriptor#getAlias()
alias}
-     *       which is an instance of {@code MemberName}. If found, that alias is returned.</li>
-     *   <li>If no alias is found, then this method tries to build a member name from
the primary name and the
-     *       {@linkplain DefaultParameterDescriptor#getValueClass() value class}, using the
mapping defined in
-     *       {@link org.apache.sis.util.iso.DefaultTypeName} javadoc.</li>
-     * </ul>
-     *
-     * This method can be used as a bridge between the parameter object
-     * defined by ISO 19111 (namely {@code CC_OperationParameter}) and the one
-     * defined by ISO 19115 (namely {@code SV_Parameter}).
-     *
-     * @param  parameter The parameter from which to get the name (may be {@code null}).
-     * @return The member name, or {@code null} if none.
-     *
-     * @see org.apache.sis.util.iso.Names#createMemberName(CharSequence, String, CharSequence,
Class)
-     *
-     * @since 0.5
-     */
-    public static MemberName getMemberName(final ParameterDescriptor<?> parameter)
{
-        return ServiceParameter.getMemberName(parameter);
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java?rev=1653480&r1=1653479&r2=1653480&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorGroupTest.java
[UTF-8] Wed Jan 21 11:20:37 2015
@@ -26,9 +26,9 @@ import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.apache.sis.test.Assert.*;
 import static org.opengis.test.Validators.*;
 import static java.util.Collections.singletonMap;
+import static org.apache.sis.test.MetadataAssert.*;
 import static org.opengis.referencing.IdentifiedObject.*;
 
 
@@ -57,8 +57,8 @@ public final strictfp class DefaultParam
         M1_M1_O1_O2 = new DefaultParameterDescriptorGroup(singletonMap(NAME_KEY, "Test group"),
0, 1,
             new DefaultParameterDescriptor<>(name(properties, "Mandatory 1", "Ambiguity"),
1, 1, type, null, null, DEFAULT_VALUE),
             new DefaultParameterDescriptor<>(name(properties, "Mandatory 2", "Alias
2"),   1, 1, type, null, null, DEFAULT_VALUE),
-            new DefaultParameterDescriptor<>(name(properties, "Optional 3", "Alias
3"),    0, 1, type, null, null, DEFAULT_VALUE),
-            new DefaultParameterDescriptor<>(name(properties, "Optional 4", "Ambiguity"),
 0, 2, type, null, null, DEFAULT_VALUE)
+            new DefaultParameterDescriptor<>(name(properties, "Optional 3",  "Alias
3"),   0, 1, type, null, null, DEFAULT_VALUE),
+            new DefaultParameterDescriptor<>(name(properties, "Optional 4",  "Ambiguity"),
0, 2, type, null, null, DEFAULT_VALUE)
         );
     }
 
@@ -79,7 +79,7 @@ public final strictfp class DefaultParam
         final Class<Integer> type = Integer.class;
         final Map<String,Object> properties = new HashMap<>(4);
         final DefaultParameterDescriptor<Integer> p1, p2;
-        p1 = new DefaultParameterDescriptor<>(name(properties,    "Name", null), 1,
1, type, null, null, null);
+        p1 = new DefaultParameterDescriptor<>(name(properties,   "Name",  null), 1,
1, type, null, null, null);
         p2 = new DefaultParameterDescriptor<>(name(properties, "  NAME ", null), 1,
1, type, null, null, null);
         try {
             new DefaultParameterDescriptorGroup(singletonMap(NAME_KEY, "Test group"), 0,
1, p1, p2);
@@ -169,6 +169,19 @@ public final strictfp class DefaultParam
     }
 
     /**
+     * Tests the WKT representation.
+     */
+    @Test
+    public void testWKT() {
+        assertWktEquals(
+                "ParameterGroup[“Test group”,\n" +
+                "  Parameter[“Mandatory 1”, 10],\n" +
+                "  Parameter[“Mandatory 2”, 10],\n" +
+                "  Parameter[“Optional 3”, 10],\n" +
+                "  Parameter[“Optional 4”, 10]]", M1_M1_O1_O2);
+    }
+
+    /**
      * Tests {@link DefaultParameterDescriptorGroup} serialization.
      */
     @Test

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.java?rev=1653480&r1=1653479&r2=1653480&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueGroupTest.java
[UTF-8] Wed Jan 21 11:20:37 2015
@@ -31,7 +31,7 @@ import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.apache.sis.test.MetadataAssert.*;
+import static org.apache.sis.test.Assert.*;
 import static org.opengis.test.Validators.*;
 import static java.util.Collections.singletonMap;
 import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
@@ -42,7 +42,7 @@ import static org.opengis.referencing.Id
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4 (derived from geotk-2.1)
- * @version 0.4
+ * @version 0.5
  * @module
  */
 @DependsOn({
@@ -356,19 +356,6 @@ public final strictfp class DefaultParam
     }
 
     /**
-     * Tests the WKT representation.
-     */
-    @Test
-    public void testWKT() {
-        assertWktEquals(
-                "ParameterGroup[“Test group”,\n" +
-                "  Parameter[“Mandatory 1”, 10],\n" +
-                "  Parameter[“Mandatory 2”, 10],\n" +
-                "  Parameter[“Optional 3”, 10],\n" +
-                "  Parameter[“Optional 4”, 10]]", descriptor);
-    }
-
-    /**
      * Tests {@link DefaultParameterValueGroup} serialization.
      */
     @Test

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=1653480&r1=1653479&r2=1653480&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] Wed Jan 21 11:20:37 2015
@@ -26,6 +26,7 @@ import org.opengis.parameter.ParameterDe
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.parameter.ParameterValue;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -43,7 +44,7 @@ import static org.apache.sis.metadata.is
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.5
  * @module
  */
 @DependsOn(ParameterBuilderTest.class)
@@ -308,13 +309,14 @@ public final strictfp class ParameterFor
     }
 
     /**
-     * Tests the formatting of a parameter value group with an invalid cardinality.
-     * While not allowed by ISO 19111, the Apache SIS implementation shall be robust
-     * to those cases.
+     * Tests the formatting of a parameter descriptor group with a cardinality
+     * invalid according ISO 19111, but allowed by Apache SIS implementation.
+     * ISO 19111 restricts {@link ParameterDescriptor} cardinality to the [0 … 1] range,
+     * but SIS can handle arbitrary ranges ([0 … 2] in this test).
      */
     @Test
     @DependsOnMethod("testFormatBriefDescriptors")
-    public void testInvalidCardinality() {
+    public void testExtendedCardinality() {
         final ParameterFormat format = new ParameterFormat(null, null);
         format.setContentLevel(ParameterFormat.ContentLevel.BRIEF);
         final String text = format.format(DefaultParameterDescriptorGroupTest.M1_M1_O1_O2);
@@ -329,4 +331,40 @@ public final strictfp class ParameterFor
                 "│ Optional 4  │ Integer │ 0 … 2      │              │      
     10 │\n" +
                 "└─────────────┴─────────┴────────────┴──────────────┴───────────────┘\n",
text);
     }
+
+    /**
+     * Tests the formatting of a parameter value group with a cardinality
+     * invalid according ISO 19111, but allowed by Apache SIS implementation.
+     * ISO 19111 restricts {@link ParameterValue} cardinality to the [0 … 1] range,
+     * but SIS can handle arbitrary number of occurrences (2 in this test).
+     */
+    @Test
+    @DependsOnMethod("testExtendedCardinality")
+    public void testMultiOccurrence() {
+        final ParameterValueGroup group = DefaultParameterDescriptorGroupTest.M1_M1_O1_O2.createValue();
+        group.parameter("Mandatory 2").setValue(20);
+        final ParameterValue<?> value = group.parameter("Optional 4");
+        value.setValue(40);
+        /*
+         * Adding a second occurrence of the same parameter.
+         * Not straightforward because not allowed by ISO 19111.
+         */
+        final ParameterValue<?> secondOccurrence = value.getDescriptor().createValue();
+        group.values().add(secondOccurrence);
+        secondOccurrence.setValue(50);
+
+        final ParameterFormat format = new ParameterFormat(null, null);
+        format.setContentLevel(ParameterFormat.ContentLevel.BRIEF);
+        final String text = format.format(group);
+        assertMultilinesEquals(
+                "Test group\n" +
+                "┌─────────────┬─────────┬──────────────┬───────┐\n"
+
+                "│ Name        │ Type    │ Value domain │ Value │\n" +
+                "├─────────────┼─────────┼──────────────┼───────┤\n"
+
+                "│ Mandatory 1 │ Integer │              │    10 │\n" +
+                "│ Mandatory 2 │ Integer │              │    20 │\n" +
+                "│ Optional 4  │ Integer │              │    40 │\n" +
+                "│      ″      │    ″    │      ″       │    50 │\n" +
+                "└─────────────┴─────────┴──────────────┴───────┘\n",
text);
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParametersTest.java?rev=1653480&r1=1653479&r2=1653480&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParametersTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParametersTest.java
[UTF-8] Wed Jan 21 11:20:37 2015
@@ -22,6 +22,7 @@ import javax.measure.unit.SI;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDirection;
 import org.opengis.parameter.ParameterValue;
+import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.metadata.Identifier;
 import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
@@ -128,4 +129,28 @@ public final strictfp class ParametersTe
             @Override public String                   toWKT()            {return descriptor.toWKT();}
         }));
     }
+
+    /**
+     * Tests {@link Parameters#copy(ParameterValueGroup, ParameterValueGroup)}.
+     */
+    @Test
+    public void testCopy() {
+        final ParameterValueGroup source = DefaultParameterDescriptorGroupTest.M1_M1_O1_O2.createValue();
+        final ParameterValue<?> o1 = source.parameter("Optional 4");
+        final ParameterValue<?> o2 = o1.getDescriptor().createValue(); // See ParameterFormatTest.testMultiOccurrence()
+        source.parameter("Mandatory 2").setValue(20);
+        source.values().add(o2);
+        o1.setValue(40);
+        o2.setValue(50);
+
+        final ParameterValueGroup destination = DefaultParameterDescriptorGroupTest.M1_M1_O1_O2.createValue();
+        destination.parameter("Mandatory 1").setValue(-10);  // We expect this value to be
overwritten.
+        destination.parameter("Optional 3") .setValue( 30);  // We expect this value to be
preserved.
+        Parameters.copy(source, destination);
+
+        assertEquals("Mandatory 1", 10, destination.parameter("Mandatory 1").intValue());
+        assertEquals("Mandatory 2", 20, destination.parameter("Mandatory 2").intValue());
+        assertEquals("Optional 3",  30, destination.parameter("Optional 3") .intValue());
+// TODO assertEquals("Optional 4",  40, destination.parameter("Optional 4") .intValue());
+    }
 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1653480&r1=1653479&r2=1653480&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] Wed Jan 21 11:20:37 2015
@@ -166,6 +166,11 @@ public final class Vocabulary extends In
         public static final short Directory = 16;
 
         /**
+         * ″
+         */
+        public static final short DittoMark = 82;
+
+        /**
          * Dublin Julian
          */
         public static final short DublinJulian = 17;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1653480&r1=1653479&r2=1653480&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] Wed Jan 21 11:20:37 2015
@@ -36,6 +36,7 @@ Description             = Description
 Destination             = Destination
 Dimensions              = Dimensions
 Directory               = Directory
+DittoMark               = \u2033
 DublinJulian            = Dublin Julian
 Ellipsoid               = Ellipsoid
 EllipsoidalHeight       = Ellipsoidal height

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1653480&r1=1653479&r2=1653480&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] Wed Jan 21 11:20:37 2015
@@ -36,6 +36,7 @@ Description             = Description
 Destination             = Destination
 Dimensions              = Dimensions
 Directory               = R\u00e9pertoire
+DittoMark               = \u2033
 DublinJulian            = Julien Dublin
 Ellipsoid               = Ellipso\u00efde
 EllipsoidalHeight       = Hauteur ellipso\u00efdale



Mime
View raw message