sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1754842 - in /sis/branches/JDK8/core/sis-feature/src: main/java/org/apache/sis/feature/FeatureFormat.java main/java/org/apache/sis/feature/builder/package-info.java test/java/org/apache/sis/feature/FeatureFormatTest.java
Date Tue, 02 Aug 2016 08:06:34 GMT
Author: desruisseaux
Date: Tue Aug  2 08:06:34 2016
New Revision: 1754842

URL: http://svn.apache.org/viewvc?rev=1754842&view=rev
Log:
When formatting FeatureType, shows also the names of parent types.

Modified:
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/package-info.java
    sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureFormatTest.java

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java?rev=1754842&r1=1754841&r2=1754842&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
[UTF-8] Tue Aug  2 08:06:34 2016
@@ -75,7 +75,7 @@ import org.opengis.feature.Operation;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.6
+ * @version 0.8
  * @module
  */
 public class FeatureFormat extends TabularFormat<Object> {
@@ -194,9 +194,20 @@ public class FeatureFormat extends Tabul
             }
         }
         /*
-         * Format the column header.
+         * Format the feature type name. In the case of feature type, format also the names
of super-type
+         * after the UML symbol for inheritance (an arrow with white head). We do not use
the " : " ASCII
+         * character for avoiding confusion with the ":" separator in namespaces. After the
feature (type)
+         * name, format the column header: property name, type, cardinality and (default)
value.
          */
-        toAppendTo.append(toString(featureType.getName())).append(getLineSeparator());
+        toAppendTo.append(toString(featureType.getName()));
+        if (feature == null) {
+            String separator = " ⇾ ";   // UML symbol for inheritance.
+            for (final FeatureType parent : featureType.getSuperTypes()) {
+                toAppendTo.append(separator).append(toString(parent.getName()));
+                separator = ", ";
+            }
+        }
+        toAppendTo.append(getLineSeparator());
         final Vocabulary resources = Vocabulary.getResources(displayLocale);
         final TableAppender table = new TableAppender(toAppendTo, columnSeparator);
         table.setMultiLinesCells(true);

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/package-info.java?rev=1754842&r1=1754841&r2=1754842&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/package-info.java
[UTF-8] Tue Aug  2 08:06:34 2016
@@ -21,12 +21,13 @@
  * their attributes and associations.
  *
  * <p>The starting point is {@link org.apache.sis.feature.builder.FeatureTypeBuilder}.
- * Example:</p>
+ * The following example creates a feature type for a capital, as a special kind of city,
+ * named "Utopia" by default:</p>
  *
  * {@preformat java
  *     // Create a feature type for a city, which contains a name and a population.
  *     FeatureTypeBuilder builder = new FeatureTypeBuilder().setName("City");
- *     builder.addAttribute(String.class).setName("name");
+ *     builder.addAttribute(String.class).setName("name").setDefaultValue("Utopia");
  *     builder.addAttribute(Integer.class).setName("population");
  *     FeatureType city = builder.build();
  *
@@ -36,6 +37,19 @@
  *     FeatureType capital = builder.build();
  * }
  *
+ * A call to {@code System.out.println(capital)} prints the following table:
+ *
+ * {@preformat text
+ *   Capital ⇾ City
+ *   ┌────────────┬─────────┬─────────────┬───────────────┐
+ *   │ Name       │ Type    │ Cardinality │ Default value │
+ *   ├────────────┼─────────┼─────────────┼───────────────┤
+ *   │ name       │ String  │ [1 … 1]     │ Utopia        │
+ *   │ population │ Integer │ [1 … 1]     │               │
+ *   │ parliament │ String  │ [1 … 1]     │               │
+ *   └────────────┴─────────┴─────────────┴───────────────┘
+ * }
+ *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.8

Modified: sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureFormatTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureFormatTest.java?rev=1754842&r1=1754841&r2=1754842&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureFormatTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureFormatTest.java
[UTF-8] Tue Aug  2 08:06:34 2016
@@ -32,7 +32,7 @@ import static org.apache.sis.test.Assert
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.6
+ * @version 0.8
  * @module
  */
 @DependsOn({
@@ -48,7 +48,7 @@ public final strictfp class FeatureForma
         final DefaultFeatureType feature = DefaultFeatureTypeTest.worldMetropolis();
         final FeatureFormat format = new FeatureFormat(Locale.US, null);
         final String text = format.format(feature);
-        assertMultilinesEquals("World metropolis\n" +
+        assertMultilinesEquals("World metropolis ⇾ Metropolis, University city\n" +
                 "┌──────────────┬─────────────────────┬─────────────┬───────────────┬────────────────────────────┐\n"
+
                 "│ Name         │ Type                │ Cardinality │ Default value
│ Characteristics            │\n" +
                 "├──────────────┼─────────────────────┼─────────────┼───────────────┼────────────────────────────┤\n"
+



Mime
View raw message