sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1476404 - 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/
Date Fri, 26 Apr 2013 21:06:58 GMT
Author: desruisseaux
Date: Fri Apr 26 21:06:57 2013
New Revision: 1476404

URL: http://svn.apache.org/r1476404
Log:
Minor change in toString() formatting, javadoc et exception handling.

Modified:
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataTreeNode.java
    sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
    sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataTreeNode.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataTreeNode.java?rev=1476404&r1=1476403&r2=1476404&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataTreeNode.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataTreeNode.java
[UTF-8] Fri Apr 26 21:06:57 2013
@@ -20,6 +20,8 @@ import java.util.List;
 import java.util.Iterator;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.NoSuchElementException;
+import java.util.ConcurrentModificationException;
 import java.io.Serializable;
 import org.apache.sis.util.Debug;
 import org.apache.sis.util.Classes;
@@ -328,15 +330,18 @@ class MetadataTreeNode implements TreeTa
         @Override
         public Object getUserObject() {
             final Collection<?> values = (Collection<?>) super.getUserObject();
-            if (values instanceof List<?>) {
-                return ((List<?>) values).get(indexInList);
-            }
-            // TODO: following fallback is inefficient.
-            final Iterator<?> it = values.iterator();
-            for (int i=0; i<indexInList; i++) {
-                it.next();
+            try {
+                if (values instanceof List<?>) {
+                    return ((List<?>) values).get(indexInList);
+                }
+                final Iterator<?> it = values.iterator();
+                for (int i=0; i<indexInList; i++) {
+                    it.next();
+                }
+                return it.next();
+            } catch (IndexOutOfBoundsException | NoSuchElementException e) {
+                throw new ConcurrentModificationException(e);
             }
-            return it.next();
         }
     }
 

Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java?rev=1476404&r1=1476403&r2=1476404&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java
[UTF-8] Fri Apr 26 21:06:57 2013
@@ -1108,18 +1108,27 @@ final class PropertyAccessor {
      * Output example:
      *
      * {@preformat text
-     *     PropertyAccessor[13 properties in DefaultCitation:Citation from “ISO 19115”]
+     *     PropertyAccessor[13 getters & 13 setters in DefaultCitation:Citation from
“ISO 19115”]
      * }
      */
     @Debug
     @Override
     public String toString() {
         final StringBuilder buffer = new StringBuilder(60);
-        buffer.append("PropertyAccessor[").append(standardCount).append(" properties");
+        buffer.append("PropertyAccessor[").append(standardCount).append(" getters");
         final int extra = allCount - standardCount;
         if (extra != 0) {
             buffer.append(" (+").append(extra).append(" ext.)");
         }
+        if (setters != null) {
+            int c = 0;
+            for (final Method setter : setters) {
+                if (setter != null) {
+                    c++;
+                }
+            }
+            buffer.append(" & ").append(c).append(" setters");
+        }
         buffer.append(" in ").append(Classes.getShortName(implementation));
         if (type != implementation) {
             buffer.append(':').append(Classes.getShortName(type));

Modified: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java?rev=1476404&r1=1476403&r2=1476404&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
[UTF-8] Fri Apr 26 21:06:57 2013
@@ -407,6 +407,6 @@ public final strictfp class PropertyAcce
     @Test
     public void testToString() {
         final PropertyAccessor accessor = createPropertyAccessor();
-        assertEquals("PropertyAccessor[13 properties in DefaultCitation:Citation from “ISO
19115”]", accessor.toString());
+        assertEquals("PropertyAccessor[13 getters & 13 setters in DefaultCitation:Citation
from “ISO 19115”]", accessor.toString());
     }
 }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java?rev=1476404&r1=1476403&r2=1476404&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java [UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java [UTF-8] Fri
Apr 26 21:06:57 2013
@@ -570,11 +570,11 @@ cmp:    for (final Class<?> c : c1) {
      *
      * <table class="sis">
      *   <tr>
-     *     <td>Class</td>
-     *     <td>{@code getName()}</td>
-     *     <td>{@code getSimpleName()}</td>
-     *     <td>{@code getCanonicalName()}</td>
-     *     <td>{@code getShortName()}</td>
+     *     <th>Class</th>
+     *     <th>{@code getName()}</th>
+     *     <th>{@code getSimpleName()}</th>
+     *     <th>{@code getCanonicalName()}</th>
+     *     <th>{@code getShortName()}</th>
      *   </tr>
      *   <tr>
      *     <td>{@link String}</td>



Mime
View raw message