sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1479138 - in /sis/branches/JDK7: sis-metadata/src/main/java/org/apache/sis/metadata/ sis-metadata/src/test/java/org/apache/sis/metadata/ sis-utility/src/main/java/org/apache/sis/util/collection/ sis-utility/src/main/java/org/apache/sis/uti...
Date Sat, 04 May 2013 16:53:05 GMT
Author: desruisseaux
Date: Sat May  4 16:53:05 2013
New Revision: 1479138

URL: http://svn.apache.org/r1479138
Log:
Added the index column.

Modified:
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeTableView.java
    sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeTest.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java?rev=1479138&r1=1479137&r2=1479138&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java [UTF-8]
(original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java [UTF-8]
Sat May  4 16:53:05 2013
@@ -172,8 +172,20 @@ class TreeNode implements Node {
     }
 
     /**
-     * Gets the name of this node. The name shall be stable, since it will be cached by the
caller.
-     * The default implementation is suitable only for the root node - subclasses must override.
+     * Returns the index in the collection if the metadata property type is a collection,
+     * or {@code null} otherwise. The (<var>identifier</var>, <var>index</var>)
pair can
+     * be used as a primary key for identifying this node among its siblings.
+     */
+    Integer getIndex() {
+        return null;
+    }
+
+    /**
+     * Gets the human-readable name of this node. The name shall be stable, since it will
be cached
+     * by the caller. The name typically contains {@linkplain #getIdentifier() identifier}
and
+     * {@linkplain #getIndex() index} information, eventually localized.
+     *
+     * <p>The default implementation is suitable only for the root node - subclasses
must override.</p>
      */
     CharSequence getName() {
         return Classes.getShortClassName(metadata);
@@ -366,7 +378,16 @@ class TreeNode implements Node {
         }
 
         /**
+         * Returns the zero-based index of this node in the metadata property.
+         */
+        @Override
+        Integer getIndex() {
+            return indexInList;
+        }
+
+        /**
          * Appends the index of this property, if there is more than one.
+         * Index numbering begins at 1, since this name if for human reading.
          */
         @Override
         CharSequence getName() {
@@ -655,19 +676,24 @@ class TreeNode implements Node {
     public final <V> V getValue(final TableColumn<V> column) {
         ArgumentChecks.ensureNonNull("column", column);
         Object value = null;
-        if (column == TableColumn.NAME) {
-            value = name;
-            if (value == null) {
-                value = name = getName();
-            }
-        } else if (column == TableColumn.VALUE) {
+
+        // Check the columns in what we think may be the most frequently
+        // asked columns first, and less frequently asked columns last.
+        if (column == TableColumn.VALUE) {
             if (isLeaf()) {
                 value = getUserObject();
             }
-        } else if (column == TableColumn.TYPE) {
-            value = getElementType();
+        } else if (column == TableColumn.NAME) {
+            if (name == null) {
+                name = getName();
+            }
+            value = name;
         } else if (column == TableColumn.IDENTIFIER) {
             value = getIdentifier();
+        } else if (column == TableColumn.INDEX) {
+            value = getIndex();
+        } else if (column == TableColumn.TYPE) {
+            value = getElementType();
         }
         return column.getElementType().cast(value);
     }

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeTableView.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeTableView.java?rev=1479138&r1=1479137&r2=1479138&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeTableView.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeTableView.java
[UTF-8] Sat May  4 16:53:05 2013
@@ -33,9 +33,10 @@ import org.apache.sis.internal.util.Unmo
  * The tree table is made of three columns:
  *
  * <ul>
- *   <li>{@link TableColumn#IDENTIFIER} - the property standard identifier.</li>
- *   <li>{@link TableColumn#NAME}       - the property name.</li>
- *   <li>{@link TableColumn#TYPE}       - the element type.</li>
+ *   <li>{@link TableColumn#IDENTIFIER} - the property identifier as defined by the
UML (if any).</li>
+ *   <li>{@link TableColumn#INDEX}      - the index in the collection, or null if the
property is not a collection.</li>
+ *   <li>{@link TableColumn#NAME}       - the human-readable property name, inferred
from the identifier and index.</li>
+ *   <li>{@link TableColumn#TYPE}       - the base interface of property values.</li>
  *   <li>{@link TableColumn#VALUE}      - the property value.</li>
  * </ul>
  *
@@ -55,6 +56,7 @@ final class TreeTableView implements Tre
      */
     static final List<TableColumn<?>> COLUMNS = UnmodifiableArrayList.wrap(new
TableColumn<?>[] {
         TableColumn.IDENTIFIER,
+        TableColumn.INDEX,
         TableColumn.NAME,
         TableColumn.TYPE,
         TableColumn.VALUE

Modified: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeTest.java?rev=1479138&r1=1479137&r2=1479138&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeTest.java
[UTF-8] Sat May  4 16:53:05 2013
@@ -216,6 +216,35 @@ public final strictfp class TreeNodeTest
     }
 
     /**
+     * Tests {@link TreeNode#getIndex()} on a metadata with a hierarchy.
+     */
+    @Test
+    @DependsOnMethod("testGetIdentifier")
+    public void testGetIndex() {
+        final Integer ZERO = Integer.valueOf(0);
+        final Integer ONE  = Integer.valueOf(1);
+        final DefaultCitation citation = metadataWithHierarchy();
+        assertColumnContentEquals(create(citation, ValueExistencePolicy.NON_EMPTY), TableColumn.INDEX,
+            null,           // CI_Citation
+              null,         // title
+              ZERO,         // alternateTitle
+              ONE,          // alternateTitle
+              null,         // edition
+              ZERO,         // citedResponsibleParty
+                null,       // organisationName
+                null,       // role
+              ONE,          // citedResponsibleParty
+                null,       // individualName
+                null,       // contactInfo
+                  null,     // address
+                    ZERO,   // electronicMailAddress
+                null,       // role
+              ZERO,         // presentationForm
+              ONE,          // presentationForm
+              null);        // otherCitationDetails
+    }
+
+    /**
      * Tests {@link TreeNode#getElementType()} on a metadata with a hierarchy.
      */
     @Test

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java?rev=1479138&r1=1479137&r2=1479138&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
[UTF-8] Sat May  4 16:53:05 2013
@@ -116,6 +116,14 @@ public class TableColumn<V> implements C
             String.class, Vocabulary.Keys.Identifier);
 
     /**
+     * Frequently-used constant for a column of index values.
+     * The column {@linkplain #getHeader() header} is "<cite>Index</cite>" (eventually
localized)
+     * and the column elements are instances of {@link Integer}.
+     */
+    public static final TableColumn<Integer> INDEX = new Constant<>("INDEX",
+            Integer.class, Vocabulary.Keys.Index);
+
+    /**
      * Frequently-used constant for a column of object types.
      * The column {@linkplain #getHeader() header} is "<cite>Type</cite>" (eventually
localized).
      */

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1479138&r1=1479137&r2=1479138&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] Sat May  4 16:53:05 2013
@@ -120,6 +120,11 @@ public final class Vocabulary extends In
         public static final int Identifier = 42;
 
         /**
+         * Index
+         */
+        public static final int Index = 44;
+
+        /**
          * Java extensions
          */
         public static final int JavaExtensions = 26;

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1479138&r1=1479137&r2=1479138&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] Sat May  4 16:53:05 2013
@@ -27,6 +27,7 @@ DaylightTime       = Daylight time
 Destination        = Destination
 Directory          = Directory
 Identifier         = Identifier
+Index              = Index
 JavaExtensions     = Java extensions
 JavaHome           = Java home directory
 Latitude           = Latitude

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1479138&r1=1479137&r2=1479138&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] Sat May  4 16:53:05 2013
@@ -27,6 +27,7 @@ DaylightTime       = Heure normale
 Destination        = Destination
 Directory          = R\u00e9pertoire
 Identifier         = Identifiant
+Index              = Index
 JavaExtensions     = Extensions du Java
 JavaHome           = R\u00e9pertoire du Java
 Latitude           = Latitude



Mime
View raw message