sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1577502 - in /sis/branches/JDK7/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 Fri, 14 Mar 2014 12:12:02 GMT
Author: desruisseaux
Date: Fri Mar 14 12:12:02 2014
New Revision: 1577502

URL: http://svn.apache.org/r1577502
Log:
ParameterFormat should include a column about parameter obligation (mandatory / optional).

Modified:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterFormatTest.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java?rev=1577502&r1=1577501&r2=1577502&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java [UTF-8] Fri Mar 14 12:12:02 2014
@@ -74,15 +74,15 @@ import static org.apache.sis.util.collec
  *
  * {@preformat text
  *   EPSG: Mercator (variant A)
- *   ┌────────────────────────────────┬────────┬───────────────┬───────────────┐
- *   │ Name (EPSG)                    │ Type   │ Value domain  │ Default value │
- *   ├────────────────────────────────┼────────┼───────────────┼───────────────┤
- *   │ Latitude of natural origin     │ Double │  [-80 … 84]°  │         0.0°  │
- *   │ Longitude of natural origin    │ Double │ [-180 … 180]° │         0.0°  │
- *   │ Scale factor at natural origin │ Double │    (0 … ∞)    │         1.0   │
- *   │ False easting                  │ Double │   (-∞ … ∞) m  │         0.0 m │
- *   │ False northing                 │ Double │   (-∞ … ∞) m  │         0.0 m │
- *   └────────────────────────────────┴────────┴───────────────┴───────────────┘
+ *   ┌────────────────────────────────┬────────┬────────────┬───────────────┬───────────────┐
+ *   │ Name (EPSG)                    │ Type   │ Obligation │ Value domain  │ Default value │
+ *   ├────────────────────────────────┼────────┼────────────┼───────────────┼───────────────┤
+ *   │ Latitude of natural origin     │ Double │ Mandatory  │  [-80 … 84]°  │         0.0°  │
+ *   │ Longitude of natural origin    │ Double │ Mandatory  │ [-180 … 180]° │         0.0°  │
+ *   │ Scale factor at natural origin │ Double │ Mandatory  │    (0 … ∞)    │         1.0   │
+ *   │ False easting                  │ Double │ Optional   │   (-∞ … ∞) m  │         0.0 m │
+ *   │ False northing                 │ Double │ Optional   │   (-∞ … ∞) m  │         0.0 m │
+ *   └────────────────────────────────┴────────┴────────────┴───────────────┴───────────────┘
  * }
  * </div>
  *
@@ -147,24 +147,24 @@ public class ParameterFormat extends Tab
          *   EPSG: Mercator (variant A) (9804)
          *   EPSG: Mercator (1SP)
          *   OGC:  Mercator_1SP
-         *   ╔══════════════════════════════════════╤════════╤═══════════════╤═══════════════╗
-         *   ║ Name                                 │ Type   │ Value domain  │ Default value ║
-         *   ╟──────────────────────────────────────┼────────┼───────────────┼───────────────╢
-         *   ║ EPSG: Latitude of natural origin     │ Double │  [-80 … 84]°  │         0.0°  ║
-         *   ║ OGC:  latitude_of_origin             │        │               │               ║
-         *   ╟──────────────────────────────────────┼────────┼───────────────┼───────────────╢
-         *   ║ EPSG: Longitude of natural origin    │ Double │ [-180 … 180]° │         0.0°  ║
-         *   ║ OGC:  central_meridian               │        │               │               ║
-         *   ╟──────────────────────────────────────┼────────┼───────────────┼───────────────╢
-         *   ║ EPSG: Scale factor at natural origin │ Double │    (0 … ∞)    │         1.0   ║
-         *   ║ OGC:  scale_factor                   │        │               │               ║
-         *   ╟──────────────────────────────────────┼────────┼───────────────┼───────────────╢
-         *   ║ EPSG: False easting                  │ Double │   (-∞ … ∞) m  │         0.0 m ║
-         *   ║ OGC:  false_easting                  │        │               │               ║
-         *   ╟──────────────────────────────────────┼────────┼───────────────┼───────────────╢
-         *   ║ EPSG: False northing                 │ Double │   (-∞ … ∞) m  │         0.0 m ║
-         *   ║ OGC:  false_northing                 │        │               │               ║
-         *   ╚══════════════════════════════════════╧════════╧═══════════════╧═══════════════╝
+         *   ╔══════════════════════════════════════╤════════╤════════════╤═══════════════╤═══════════════╗
+         *   ║ Name                                 │ Type   │ Obligation │ Value domain  │ Default value ║
+         *   ╟──────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢
+         *   ║ EPSG: Latitude of natural origin     │ Double │ Mandatory  │  [-80 … 84]°  │         0.0°  ║
+         *   ║ OGC:  latitude_of_origin             │        │            │               │               ║
+         *   ╟──────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢
+         *   ║ EPSG: Longitude of natural origin    │ Double │ Mandatory  │ [-180 … 180]° │         0.0°  ║
+         *   ║ OGC:  central_meridian               │        │            │               │               ║
+         *   ╟──────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢
+         *   ║ EPSG: Scale factor at natural origin │ Double │ Mandatory  │    (0 … ∞)    │         1.0   ║
+         *   ║ OGC:  scale_factor                   │        │            │               │               ║
+         *   ╟──────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢
+         *   ║ EPSG: False easting                  │ Double │ Optional   │   (-∞ … ∞) m  │         0.0 m ║
+         *   ║ OGC:  false_easting                  │        │            │               │               ║
+         *   ╟──────────────────────────────────────┼────────┼────────────┼───────────────┼───────────────╢
+         *   ║ EPSG: False northing                 │ Double │ Optional   │   (-∞ … ∞) m  │         0.0 m ║
+         *   ║ OGC:  false_northing                 │        │            │               │               ║
+         *   ╚══════════════════════════════════════╧════════╧════════════╧═══════════════╧═══════════════╝
          * }
          * </div>
          */
@@ -182,15 +182,15 @@ public class ParameterFormat extends Tab
          *
          * {@preformat text
          *   EPSG: Mercator (variant A)
-         *   ┌────────────────────────────────┬────────┬───────────────┬───────────────┐
-         *   │ Name (EPSG)                    │ Type   │ Value domain  │ Default value │
-         *   ├────────────────────────────────┼────────┼───────────────┼───────────────┤
-         *   │ Latitude of natural origin     │ Double │  [-80 … 84]°  │         0.0°  │
-         *   │ Longitude of natural origin    │ Double │ [-180 … 180]° │         0.0°  │
-         *   │ Scale factor at natural origin │ Double │    (0 … ∞)    │         1.0   │
-         *   │ False easting                  │ Double │   (-∞ … ∞) m  │         0.0 m │
-         *   │ False northing                 │ Double │   (-∞ … ∞) m  │         0.0 m │
-         *   └────────────────────────────────┴────────┴───────────────┴───────────────┘
+         *   ┌────────────────────────────────┬────────┬────────────┬───────────────┬───────────────┐
+         *   │ Name (EPSG)                    │ Type   │ Obligation │ Value domain  │ Default value │
+         *   ├────────────────────────────────┼────────┼────────────┼───────────────┼───────────────┤
+         *   │ Latitude of natural origin     │ Double │ Mandatory  │  [-80 … 84]°  │         0.0°  │
+         *   │ Longitude of natural origin    │ Double │ Mandatory  │ [-180 … 180]° │         0.0°  │
+         *   │ Scale factor at natural origin │ Double │ Mandatory  │    (0 … ∞)    │         1.0   │
+         *   │ False easting                  │ Double │ Optional   │   (-∞ … ∞) m  │         0.0 m │
+         *   │ False northing                 │ Double │ Optional   │   (-∞ … ∞) m  │         0.0 m │
+         *   └────────────────────────────────┴────────┴────────────┴───────────────┴───────────────┘
          * }
          * </div>
          */
@@ -378,6 +378,14 @@ public class ParameterFormat extends Tab
     }
 
     /**
+     * Invoked when the formatter needs to move to the next column.
+     */
+    private void nextColumn(final TableAppender table) {
+        table.append(beforeFill);
+        table.nextColumn(fillCharacter);
+    }
+
+    /**
      * Formats the given object to the given stream of buffer.
      * The object may be an instance of any of the following types:
      *
@@ -437,11 +445,12 @@ public class ParameterFormat extends Tab
     private void format(final String name, final ParameterDescriptorGroup group,
             final ParameterValueGroup values, final Appendable out) throws IOException
     {
-        final boolean    isBrief       = (contentLevel == ContentLevel.BRIEF);
-        final boolean    hasColors     = (colors != null);
-        final String     lineSeparator = this.lineSeparator;
-        final ParameterTableRow header = new ParameterTableRow(group, displayLocale, preferredCodespaces, isBrief);
-        final String    groupCodespace = header.getCodeSpace();
+        final boolean    isBrief        = (contentLevel == ContentLevel.BRIEF);
+        final boolean    showObligation = !isBrief || (values == null);
+        final boolean    hasColors      = (colors != null);
+        final String     lineSeparator  = this.lineSeparator;
+        final ParameterTableRow header  = new ParameterTableRow(group, displayLocale, preferredCodespaces, isBrief);
+        final String    groupCodespace  = header.getCodeSpace();
         /*
          * Prepares the informations to be printed later as table rows. We scan all rows before to print them
          * in order to compute the width of codespaces. During this process, we split the objects to be printed
@@ -504,11 +513,11 @@ public class ParameterFormat extends Tab
          *   - Value domains are formatted.
          *   - Position of the character on which to do the alignment are remembered.
          */
-        int     unitWidth            = 0;
-        int     valueDomainAlignment = 0;
-        boolean writeCodespaces      = (groupCodespace == null);
-        final   StringBuffer  buffer = new StringBuffer();
-        final   FieldPosition fp     = new FieldPosition(-1);
+        int     unitWidth             = 0;
+        int     valueDomainAlignment  = 0;
+        boolean writeCodespaces       = (groupCodespace == null);
+        final   StringBuffer  buffer  = new StringBuffer();
+        final   FieldPosition dummyFP = new FieldPosition(-1);
         for (final Map.Entry<GeneralParameterDescriptor,ParameterTableRow> entry : descriptorValues.entrySet()) {
             final GeneralParameterDescriptor descriptor = entry.getKey();
             if (descriptor instanceof ParameterDescriptor<?>) {
@@ -540,7 +549,7 @@ public class ParameterFormat extends Tab
                 for (int i=0; i<length; i++) {
                     final Object unit = row.units.get(i);
                     if (unit != null) {
-                        if (getFormat(Unit.class).format(unit, buffer, fp).length() != 0) {
+                        if (getFormat(Unit.class).format(unit, buffer, dummyFP).length() != 0) {
                             if (Character.isLetterOrDigit(buffer.codePointAt(0))) {
                                 buffer.insert(0, ' ');
                             }
@@ -572,10 +581,30 @@ public class ParameterFormat extends Tab
             boolean end = false;
             final short key;
             switch (i) {
-                case 0: key = Vocabulary.Keys.Name; break;
-                case 1: key = Vocabulary.Keys.Type; break;
-                case 2: key = Vocabulary.Keys.ValueDomain; break;
-                case 3: key = (values == null) ? Vocabulary.Keys.DefaultValue : Vocabulary.Keys.Value; end = true; break;
+                case 0: {
+                    key = Vocabulary.Keys.Name;
+                    break;
+                }
+                case 1: {
+                    key = Vocabulary.Keys.Type;
+                    break;
+                }
+                case 2: {
+                    if (!showObligation) {
+                       continue;
+                    }
+                    key = Vocabulary.Keys.Obligation;
+                    break;
+                }
+                case 3: {
+                    key = Vocabulary.Keys.ValueDomain;
+                    break;
+                }
+                case 4: {
+                    key = (values == null) ? Vocabulary.Keys.DefaultValue : Vocabulary.Keys.Value;
+                    end = true;
+                    break;
+                }
                 default: throw new AssertionError(i);
             }
             if (hasColors) table.append(X364.BOLD.sequence());
@@ -585,8 +614,7 @@ public class ParameterFormat extends Tab
                 table.append(" (").append(groupCodespace).append(')');
             }
             if (end) break;
-            table.append(beforeFill);
-            table.nextColumn(fillCharacter);
+            nextColumn(table);
         }
         table.nextLine();
         /*
@@ -604,8 +632,7 @@ public class ParameterFormat extends Tab
             final ParameterTableRow row = entry.getValue();
             row.codespaceWidth = codespaceWidth;
             row.writeIdentifiers(table, writeCodespaces, null, hasColors, lineSeparator);
-            table.append(beforeFill);
-            table.nextColumn(fillCharacter);
+            nextColumn(table);
             final GeneralParameterDescriptor generalDescriptor = entry.getKey();
             if (generalDescriptor instanceof ParameterDescriptor<?>) {
                 /*
@@ -613,19 +640,39 @@ public class ParameterFormat extends Tab
                  */
                 final ParameterDescriptor<?> descriptor = (ParameterDescriptor<?>) generalDescriptor;
                 final Class<?> valueClass = descriptor.getValueClass();
-                table.append(getFormat(Class.class).format(valueClass, buffer, fp).toString());
-                table.append(beforeFill);
-                table.nextColumn(fillCharacter);
+                table.append(getFormat(Class.class).format(valueClass, buffer, dummyFP).toString());
+                nextColumn(table);
                 buffer.setLength(0);
                 /*
+                 * Writes the obligation (mandatory or optional).
+                 */
+                if (showObligation) {
+                    final int minimumOccurs = descriptor.getMinimumOccurs();
+                    final int maximumOccurs = descriptor.getMaximumOccurs();
+                    if (maximumOccurs == 1) {
+                        table.append(resources.getString(minimumOccurs == 0 ?
+                                Vocabulary.Keys.Optional : Vocabulary.Keys.Mandatory));
+                    } else {
+                        final Format f = getFormat(Integer.class);
+                        table.append(f.format(minimumOccurs, buffer, dummyFP).toString()).append(" … ");
+                        buffer.setLength(0);
+                        if (maximumOccurs == Integer.MAX_VALUE) {
+                            table.append('∞');
+                        } else {
+                            table.append(f.format(maximumOccurs, buffer, dummyFP).toString());
+                            buffer.setLength(0);
+                        }
+                    }
+                    nextColumn(table);
+                }
+                /*
                  * Writes minimum and maximum values, together with the unit of measurement (if any).
                  */
                 final String valueDomain = row.valueDomain;
                 if (valueDomain != null) {
                     table.append(CharSequences.spaces(valueDomainAlignment - row.valueDomainAlignment)).append(valueDomain);
                 }
-                table.append(beforeFill);
-                table.nextColumn(fillCharacter);
+                nextColumn(table);
                 /*
                  * Writes the values, each on its own line, together with their unit of measurement.
                  */
@@ -639,7 +686,7 @@ public class ParameterFormat extends Tab
                         }
                         final Format format = getFormat(value.getClass());
                         if (format != null) {
-                            value = format.format(value, buffer, fp);
+                            value = format.format(value, buffer, dummyFP);
                         }
                         table.append(value.toString());
                         buffer.setLength(0);
@@ -789,8 +836,7 @@ public class ParameterFormat extends Tab
                 codespace = X364.BOLD.sequence() + codespace + X364.NORMAL.sequence();
             }
             table.append(codespace);
-            table.append(beforeFill);
-            table.nextColumn(fillCharacter);
+            nextColumn(table);
         }
         table.appendHorizontalSeparator();
         /*
@@ -805,8 +851,7 @@ public class ParameterFormat extends Tab
                         table.append(name);
                     }
                 }
-                table.append(beforeFill);
-                table.nextColumn(fillCharacter);
+                nextColumn(table);
             }
             table.nextLine();
         }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java?rev=1577502&r1=1577501&r2=1577502&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java [UTF-8] Fri Mar 14 12:12:02 2014
@@ -307,6 +307,9 @@ final class ParameterTableRow {
     final void writeIdentifiers(final Appendable out, final boolean writeCodespaces,
             final Colors colors, final boolean colorsForRows, final String lineSeparator) throws IOException
     {
+        if (codespaceWidth != 0) {
+            codespaceWidth++; // Add a space between codespace and code in e.g. "OGC: Mercator".
+        }
         boolean isNewLine = false;
         for (final Map.Entry<String,Set<Object>> entry : identifiers.entrySet()) {
             final String codespace = entry.getKey();
@@ -323,7 +326,7 @@ final class ParameterTableRow {
                  */
                 writeColor(out, colors, ElementKind.NAME);
                 if (writeCodespaces) {
-                    int pad = codespaceWidth + 1;
+                    int pad = codespaceWidth;
                     if (codespace != null) {
                         writeColor(out, FAINT, colorsForRows);
                         out.append(codespace).append(':');

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterFormatTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterFormatTest.java?rev=1577502&r1=1577501&r2=1577502&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterFormatTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/parameter/ParameterFormatTest.java [UTF-8] Fri Mar 14 12:12:02 2014
@@ -63,11 +63,11 @@ public final strictfp class ParameterFor
         ParameterBuilder builder = new ParameterBuilder();
         builder.setCodeSpace(OGP, "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")                 .addName(OGC, "false_easting")     .create( 5000, SI.METRE),
-            builder.addName("False northing")                .addName(OGC, "false_northing")    .create(10000, SI.METRE)
+            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("9804")
                .addName("Mercator (variant A)")
@@ -86,55 +86,76 @@ public final strictfp class ParameterFor
 
     /**
      * Creates parameter values with some arbitrary values different than the default values.
+     * This method intentionally leaves {@code "central_meridian"} (a mandatory parameter) and
+     * {@code "false_easting"} (an optional parameter) undefined, in order to test whether the
+     * formatter fallback on default values.
      */
     private static ParameterValueGroup createParameterValues() {
         final ParameterValueGroup group = descriptor.createValue();
         group.parameter("latitude_of_origin").setValue(20);
-        group.parameter("central_meridian").setValue(-70);
         group.parameter("scale_factor").setValue(0.997);
         group.parameter("false_northing").setValue(20, SI.KILOMETRE);
         return group;
     }
 
     /**
-     * Tests {@link ParameterFormat#format(Object, Appendable)} with {@code ContentLevel.BRIEF}.
+     * Tests {@link ParameterFormat#format(Object, Appendable)} for descriptors with {@code ContentLevel.BRIEF}.
+     * All parameter shall unconditionally be shown, even if optional. The table contains a column saying whether
+     * the parameter is mandatory or optional.
      */
     @Test
-    public void testFormatBrief() {
+    public void testFormatBriefDescriptors() {
         final ParameterFormat format = new ParameterFormat(null, null);
         format.setContentLevel(ParameterFormat.ContentLevel.BRIEF);
-        String text = format.format(descriptor);
+        final String text = format.format(descriptor);
         assertMultilinesEquals(
                 "EPSG: Mercator (variant A)\n" +
-                "┌────────────────────────────────┬────────┬───────────────┬───────────────┐\n" +
-                "│ Name (EPSG)                    │ Type   │ Value domain  │ Default value │\n" +
-                "├────────────────────────────────┼────────┼───────────────┼───────────────┤\n" +
-                "│ Latitude of natural origin     │ Double │  [-80 … 84]°  │        40.0°  │\n" +
-                "│ Longitude of natural origin    │ Double │ [-180 … 180]° │       -60.0°  │\n" +
-                "│ Scale factor at natural origin │ Double │    (0 … ∞)    │         1.0   │\n" +
-                "│ False easting                  │ Double │   (-∞ … ∞) m  │      5000.0 m │\n" +
-                "│ False northing                 │ Double │   (-∞ … ∞) m  │     10000.0 m │\n" +
-                "└────────────────────────────────┴────────┴───────────────┴───────────────┘\n", text);
+                "┌────────────────────────────────┬────────┬────────────┬───────────────┬───────────────┐\n" +
+                "│ Name (EPSG)                    │ Type   │ Obligation │ Value domain  │ Default value │\n" +
+                "├────────────────────────────────┼────────┼────────────┼───────────────┼───────────────┤\n" +
+                "│ Latitude of natural origin     │ Double │ Mandatory  │  [-80 … 84]°  │        40.0°  │\n" +
+                "│ Longitude of natural origin    │ Double │ Mandatory  │ [-180 … 180]° │       -60.0°  │\n" +
+                "│ Scale factor at natural origin │ Double │ Mandatory  │    (0 … ∞)    │         1.0   │\n" +
+                "│ False easting                  │ Double │ Optional   │   (-∞ … ∞) m  │      5000.0 m │\n" +
+                "│ False northing                 │ Double │ Optional   │   (-∞ … ∞) m  │     10000.0 m │\n" +
+                "└────────────────────────────────┴────────┴────────────┴───────────────┴───────────────┘\n", text);
+    }
 
-        text = format.format(createParameterValues());
+    /**
+     * Tests {@link ParameterFormat#format(Object, Appendable)} for values with {@code ContentLevel.BRIEF}.
+     * Expected behavior:
+     *
+     * <ul>
+     *   <li>{@code "Longitude of natural origin"} parameter, while not defined, shall be shown with its default
+     *       value, because this parameter is defined as mandatory in this test suite.</li>
+     *   <li>{@code "False easting"} parameter shall be omitted, because this parameter is defined as
+     *       optional in this test suite and its value has not been defined.</li>
+     *   <li>The obligation column is omitted, because not very useful in the case of parameter values..</li>
+     * </ul>
+     */
+    @Test
+    @DependsOnMethod("testFormatBriefDescriptors")
+    public void testFormatBriefValues() {
+        final ParameterFormat format = new ParameterFormat(null, null);
+        format.setContentLevel(ParameterFormat.ContentLevel.BRIEF);
+        final String text = format.format(createParameterValues());
         assertMultilinesEquals(
                 "EPSG: Mercator (variant A)\n" +
-                "┌────────────────────────────────┬────────┬───────────────┬───────────┐\n" +
-                "│ Name (EPSG)                    │ Type   │ Value domain  │ Value     │\n" +
-                "├────────────────────────────────┼────────┼───────────────┼───────────┤\n" +
-                "│ Latitude of natural origin     │ Double │  [-80 … 84]°  │   20.0°   │\n" +
-                "│ Longitude of natural origin    │ Double │ [-180 … 180]° │  -70.0°   │\n" +
-                "│ Scale factor at natural origin │ Double │    (0 … ∞)    │  0.997    │\n" +
-                "│ False easting                  │ Double │   (-∞ … ∞) m  │ 5000.0 m  │\n" +
-                "│ False northing                 │ Double │   (-∞ … ∞) m  │   20.0 km │\n" +
-                "└────────────────────────────────┴────────┴───────────────┴───────────┘\n", text);
+                "┌────────────────────────────────┬────────┬───────────────┬──────────┐\n" +
+                "│ Name (EPSG)                    │ Type   │ Value domain  │ Value    │\n" +
+                "├────────────────────────────────┼────────┼───────────────┼──────────┤\n" +
+                "│ Latitude of natural origin     │ Double │  [-80 … 84]°  │  20.0°   │\n" +
+                "│ Longitude of natural origin    │ Double │ [-180 … 180]° │ -60.0°   │\n" +
+                "│ Scale factor at natural origin │ Double │    (0 … ∞)    │ 0.997    │\n" +
+                "│ False northing                 │ Double │   (-∞ … ∞) m  │  20.0 km │\n" +
+                "└────────────────────────────────┴────────┴───────────────┴──────────┘\n", text);
     }
 
     /**
      * Tests formatting in a non-English locale.
      */
     @Test
-    @DependsOnMethod("testFormatBrief")
+    @DependsOnMethod("testFormatBriefValues")
     public void testFormatLocalized() {
         final ParameterFormat format = new ParameterFormat(Locale.FRANCE, null);
         format.setContentLevel(ParameterFormat.ContentLevel.BRIEF);
@@ -145,67 +166,73 @@ public final strictfp class ParameterFor
                 "│ Nom (EPSG)                     │ Type   │ Domaine des valeurs │ Valeur   │\n" +
                 "├────────────────────────────────┼────────┼─────────────────────┼──────────┤\n" +
                 "│ Latitude of natural origin     │ Double │  [-80 … 84]°        │    20°   │\n" +
-                "│ Longitude of natural origin    │ Double │ [-180 … 180]°       │   -70°   │\n" +
+                "│ Longitude of natural origin    │ Double │ [-180 … 180]°       │   -60°   │\n" +
                 "│ Scale factor at natural origin │ Double │    (0 … ∞)          │ 0,997    │\n" +
-                "│ False easting                  │ Double │   (-∞ … ∞) m        │ 5 000 m  │\n" +
                 "│ False northing                 │ Double │   (-∞ … ∞) m        │    20 km │\n" +
                 "└────────────────────────────────┴────────┴─────────────────────┴──────────┘\n", text);
     }
 
     /**
-     * Tests {@link ParameterFormat#format(Object, Appendable)} with {@code ContentLevel.DETAILED}.
+     * Tests {@link ParameterFormat#format(Object, Appendable)} for descriptors with {@code ContentLevel.DETAILED}.
      */
     @Test
-    public void testFormatDetailed() {
+    public void testFormatDetailedDescriptors() {
         final ParameterFormat format = new ParameterFormat(null, null);
         format.setContentLevel(ParameterFormat.ContentLevel.DETAILED);
-        String text = format.format(descriptor);
+        final String text = format.format(descriptor);
         assertMultilinesEquals(
                 "EPSG: Mercator (variant A) (9804)\n" +
                 "EPSG: Mercator (1SP)\n" +
                 "OGC:  Mercator_1SP\n" +
-                "╔══════════════════════════════════════╤════════╤═══════════════╤═══════════════╗\n" +
-                "║ Name                                 │ Type   │ Value domain  │ Default value ║\n" +
-                "╟──────────────────────────────────────┼────────┼───────────────┼───────────────╢\n" +
-                "║ EPSG: Latitude of natural origin     │ Double │  [-80 … 84]°  │        40.0°  ║\n" +
-                "║ OGC:  latitude_of_origin             │        │               │               ║\n" +
-                "╟──────────────────────────────────────┼────────┼───────────────┼───────────────╢\n" +
-                "║ EPSG: Longitude of natural origin    │ Double │ [-180 … 180]° │       -60.0°  ║\n" +
-                "║ OGC:  central_meridian               │        │               │               ║\n" +
-                "╟──────────────────────────────────────┼────────┼───────────────┼───────────────╢\n" +
-                "║ EPSG: Scale factor at natural origin │ Double │    (0 … ∞)    │         1.0   ║\n" +
-                "║ OGC:  scale_factor                   │        │               │               ║\n" +
-                "╟──────────────────────────────────────┼────────┼───────────────┼───────────────╢\n" +
-                "║ EPSG: False easting                  │ Double │   (-∞ … ∞) m  │      5000.0 m ║\n" +
-                "║ OGC:  false_easting                  │        │               │               ║\n" +
-                "╟──────────────────────────────────────┼────────┼───────────────┼───────────────╢\n" +
-                "║ EPSG: False northing                 │ Double │   (-∞ … ∞) 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     │ 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);
+    }
 
-        text = format.format(createParameterValues());
+    /**
+     * Tests {@link ParameterFormat#format(Object, Appendable)} for values with {@code ContentLevel.DETAILED}.
+     * The same comments than {@link #testFormatBriefValues()} apply, except that the column of obligation is
+     * still shown.
+     */
+    @Test
+    public void testFormatDetailedValues() {
+        final ParameterFormat format = new ParameterFormat(null, null);
+        format.setContentLevel(ParameterFormat.ContentLevel.DETAILED);
+        final String text = format.format(createParameterValues());
         assertMultilinesEquals(
                 "EPSG: Mercator (variant A) (9804)\n" +
                 "EPSG: Mercator (1SP)\n" +
                 "OGC:  Mercator_1SP\n" +
-                "╔══════════════════════════════════════╤════════╤═══════════════╤═══════════╗\n" +
-                "║ Name                                 │ Type   │ Value domain  │ Value     ║\n" +
-                "╟──────────────────────────────────────┼────────┼───────────────┼───────────╢\n" +
-                "║ EPSG: Latitude of natural origin     │ Double │  [-80 … 84]°  │   20.0°   ║\n" +
-                "║ OGC:  latitude_of_origin             │        │               │           ║\n" +
-                "╟──────────────────────────────────────┼────────┼───────────────┼───────────╢\n" +
-                "║ EPSG: Longitude of natural origin    │ Double │ [-180 … 180]° │  -70.0°   ║\n" +
-                "║ OGC:  central_meridian               │        │               │           ║\n" +
-                "╟──────────────────────────────────────┼────────┼───────────────┼───────────╢\n" +
-                "║ EPSG: Scale factor at natural origin │ Double │    (0 … ∞)    │  0.997    ║\n" +
-                "║ OGC:  scale_factor                   │        │               │           ║\n" +
-                "╟──────────────────────────────────────┼────────┼───────────────┼───────────╢\n" +
-                "║ EPSG: False easting                  │ Double │   (-∞ … ∞) m  │ 5000.0 m  ║\n" +
-                "║ OGC:  false_easting                  │        │               │           ║\n" +
-                "╟──────────────────────────────────────┼────────┼───────────────┼───────────╢\n" +
-                "║ EPSG: False northing                 │ Double │   (-∞ … ∞) 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     │ 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);
     }
 
     /**
@@ -241,7 +268,7 @@ public final strictfp class ParameterFor
      * Tests the effect of {@link ParameterFormat#setPreferredCodespaces(String[])}.
      */
     @Test
-    @DependsOnMethod({"testFormatNameSummary", "testFormatBrief"})
+    @DependsOnMethod({"testFormatNameSummary", "testFormatBriefValues"})
     public void testPreferredCodespaces() {
         final ParameterFormat format = new ParameterFormat(null, null);
         format.setContentLevel(ParameterFormat.ContentLevel.NAME_SUMMARY);
@@ -270,14 +297,36 @@ public final strictfp class ParameterFor
         text = format.format(createParameterValues());
         assertMultilinesEquals(
                 "OGC: Mercator_1SP\n" +
-                "┌────────────────────┬────────┬───────────────┬───────────┐\n" +
-                "│ Name (OGC)         │ Type   │ Value domain  │ Value     │\n" +
-                "├────────────────────┼────────┼───────────────┼───────────┤\n" +
-                "│ latitude_of_origin │ Double │  [-80 … 84]°  │   20.0°   │\n" +
-                "│ central_meridian   │ Double │ [-180 … 180]° │  -70.0°   │\n" +
-                "│ scale_factor       │ Double │    (0 … ∞)    │  0.997    │\n" +
-                "│ false_easting      │ Double │   (-∞ … ∞) m  │ 5000.0 m  │\n" +
-                "│ false_northing     │ Double │   (-∞ … ∞) m  │   20.0 km │\n" +
-                "└────────────────────┴────────┴───────────────┴───────────┘\n", text);
+                "┌────────────────────┬────────┬───────────────┬──────────┐\n" +
+                "│ Name (OGC)         │ Type   │ Value domain  │ Value    │\n" +
+                "├────────────────────┼────────┼───────────────┼──────────┤\n" +
+                "│ latitude_of_origin │ Double │  [-80 … 84]°  │  20.0°   │\n" +
+                "│ central_meridian   │ Double │ [-180 … 180]° │ -60.0°   │\n" +
+                "│ scale_factor       │ Double │    (0 … ∞)    │ 0.997    │\n" +
+                "│ false_northing     │ Double │   (-∞ … ∞) m  │  20.0 km │\n" +
+                "└────────────────────┴────────┴───────────────┴──────────┘\n", text);
+    }
+
+    /**
+     * 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.
+     */
+    @Test
+    @DependsOnMethod("testFormatBriefDescriptors")
+    public void testInvalidCardinality() {
+        final ParameterFormat format = new ParameterFormat(null, null);
+        format.setContentLevel(ParameterFormat.ContentLevel.BRIEF);
+        final String text = format.format(DefaultParameterDescriptorGroupTest.M1_M1_O1_O2);
+        assertMultilinesEquals(
+                "Test group\n" +
+                "┌─────────────┬─────────┬────────────┬──────────────┬───────────────┐\n" +
+                "│ Name        │ Type    │ Obligation │ Value domain │ Default value │\n" +
+                "├─────────────┼─────────┼────────────┼──────────────┼───────────────┤\n" +
+                "│ Mandatory 1 │ Integer │ Mandatory  │              │            10 │\n" +
+                "│ Mandatory 2 │ Integer │ Mandatory  │              │            10 │\n" +
+                "│ Optional 3  │ Integer │ Optional   │              │            10 │\n" +
+                "│ Optional 4  │ Integer │ 0 … 2      │              │            10 │\n" +
+                "└─────────────┴─────────┴────────────┴──────────────┴───────────────┘\n", text);
     }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1577502&r1=1577501&r2=1577502&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java [UTF-8] Fri Mar 14 12:12:02 2014
@@ -90,6 +90,11 @@ public final class Vocabulary extends In
         public static final short BarometricAltitude = 5;
 
         /**
+         * Cardinality
+         */
+        public static final short Cardinality = 76;
+
+        /**
          * Character encoding
          */
         public static final short CharacterEncoding = 6;
@@ -245,6 +250,11 @@ public final class Vocabulary extends In
         public static final short Longitude = 32;
 
         /**
+         * Mandatory
+         */
+        public static final short Mandatory = 77;
+
+        /**
          * Maximum value
          */
         public static final short MaximumValue = 33;
@@ -280,6 +290,11 @@ public final class Vocabulary extends In
         public static final short NumberOfValues = 39;
 
         /**
+         * Obligation
+         */
+        public static final short Obligation = 78;
+
+        /**
          * {0} ({1} of {2})
          */
         public static final short Of_3 = 40;
@@ -295,6 +310,11 @@ public final class Vocabulary extends In
         public static final short OperatingSystem = 42;
 
         /**
+         * Optional
+         */
+        public static final short Optional = 79;
+
+        /**
          * Options
          */
         public static final short Options = 43;

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1577502&r1=1577501&r2=1577502&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties [ISO-8859-1] Fri Mar 14 12:12:02 2014
@@ -21,6 +21,7 @@ AngularMinutes          = Minutes
 AngularSeconds          = Seconds
 Attributes              = Attributes
 BarometricAltitude      = Barometric altitude
+Cardinality             = Cardinality
 CharacterEncoding       = Character encoding
 Classpath               = Classpath
 Code_1                  = {0} code
@@ -52,6 +53,7 @@ LocalConfiguration      = Local configur
 Locale                  = Locale
 Localization            = Localization
 Logging                 = Logging
+Mandatory               = Mandatory
 MaximumValue            = Maximum value
 MeanValue               = Mean value
 MinimumValue            = Minimum value
@@ -59,9 +61,11 @@ ModifiedJulian          = Modified Julia
 Name                    = Name
 NumberOfValues          = Number of values
 NumberOfNaN             = Number of \u2018NaN\u2019
+Obligation              = Obligation
 Of_3                    = {0} ({1} of {2})
 Offset                  = Offset
 OperatingSystem         = Operating system
+Optional                = Optional
 Options                 = Options
 Others                  = Others
 OtherSurface            = Other surface

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1577502&r1=1577501&r2=1577502&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties [ISO-8859-1] Fri Mar 14 12:12:02 2014
@@ -21,6 +21,7 @@ AngularMinutes          = Minutes
 AngularSeconds          = Secondes
 Attributes              = Attributs
 BarometricAltitude      = Altitude barom\u00e9trique
+Cardinality             = Cardinalit\u00e9
 CharacterEncoding       = Encodage des caract\u00e8res
 Classpath               = Chemin de classes
 Code_1                  = Code {0}
@@ -52,6 +53,7 @@ LocalConfiguration      = Configuration 
 Locale                  = Locale
 Localization            = R\u00e9gionalisation
 Logging                 = Journalisation
+Mandatory               = Requis
 MaximumValue            = Valeur maximale
 MeanValue               = Valeur moyenne
 MinimumValue            = Valeur minimale
@@ -59,9 +61,11 @@ ModifiedJulian          = Julien modifi\
 Name                    = Nom
 NumberOfValues          = Nombre de valeurs
 NumberOfNaN             = Nombre de \u2018NaN\u2019
+Obligation              = Obligation
 Of_3                    = {0} ({1} de {2})
 Offset                  = D\u00e9calage
 OperatingSystem         = Syst\u00e8me d'exploitation
+Optional                = Optionnel
 Options                 = Options
 Others                  = Autres
 OtherSurface            = Autre surface



Mime
View raw message