sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1479501 - in /sis/branches/JDK6: ./ sis-metadata/src/main/java/org/apache/sis/metadata/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/ sis-metadata/src/main/java/...
Date Mon, 06 May 2013 09:08:37 GMT
Author: desruisseaux
Date: Mon May  6 09:07:41 2013
New Revision: 1479501

URL: http://svn.apache.org/r1479501
Log:
Merge from the JDK7 branch.

Added:
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
      - copied, changed from r1479498, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
      - copied, changed from r1479498, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/TreeTableView.java
      - copied unchanged from r1479498, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeTableView.java
    sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
      - copied, changed from r1479498, sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
    sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeTest.java
      - copied unchanged from r1479498, sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeTest.java
    sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java
      - copied, changed from r1479498, sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java
Removed:
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataTreeChildren.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataTreeNode.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataTreeTable.java
    sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTreeChildrenTest.java
    sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTreeNodeTest.java
    sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTreeTableTest.java
Modified:
    sis/branches/JDK6/   (props changed)
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ValueExistencePolicy.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java
    sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
    sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
    sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties

Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK7:r1478865-1479498

Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java
[UTF-8] Mon May  6 09:07:41 2013
@@ -41,19 +41,25 @@ import org.apache.sis.util.logging.Loggi
  * The methods that modify the metadata may throw {@link UnmodifiableMetadataException} if
the
  * metadata does not support the operation. Those methods are:
  *
- * <ul>
- *   <li>{@link #prune()}</li>
- *   <li>{@link #asMap()} with {@code put} operations</li>
- * </ul>
- *
- * Read-only operations operating on metadata values are:
- *
- * <ul>
- *   <li>{@link #isEmpty()}</li>
- *   <li>{@link #asMap()} with {@code get} operations</li>
- *   <li>{@link #asTreeTable()}</li>
- *   <li>{@link #equals(Object, ComparisonMode)}</li>
- * </ul>
+ * <table class="sis">
+ * <tr>
+ *   <th>Read-only operations</th>
+ *   <th class="sep">Read/write operations</th>
+ * </tr>
+ * <tr>
+ *   <td><ul>
+ *     <li>{@link #isEmpty()}</li>
+ *     <li>{@link #asMap()} with {@code get} operations</li>
+ *     <li>{@link #asTreeTable()} with {@code getValue} operations</li>
+ *     <li>{@link #equals(Object, ComparisonMode)}</li>
+ *   </ul></td>
+ *   <td class="sep"><ul>
+ *     <li>{@link #prune()}</li>
+ *     <li>{@link #asMap()} with {@code put} operations</li>
+ *     <li>{@link #asTreeTable()} with {@code setValue} operations</li>
+ *   </ul></td>
+ * </tr>
+ * </table>
  *
  * Instances of this class are <strong>not</strong> synchronized for multi-threading.
  * Synchronization, if needed, is caller's responsibility. Note that synchronization locks
@@ -72,13 +78,6 @@ public abstract class AbstractMetadata i
     protected static final Logger LOGGER = Logging.getLogger(AbstractMetadata.class);
 
     /**
-     * A view of this metadata as a map. Will be created only when first needed.
-     *
-     * @see #asMap()
-     */
-    private transient Map<String,Object> asMap;
-
-    /**
      * Creates an initially empty metadata.
      */
     protected AbstractMetadata() {
@@ -155,25 +154,29 @@ public abstract class AbstractMetadata i
      * object, so changes in the underlying metadata object are immediately reflected in
the map
      * and conversely.
      *
-     * <p>The map supports the {@link Map#put(Object, Object) put(…)} and {@link
Map#remove(Object)
+     * {@section Supported operations}
+     * The map supports the {@link Map#put(Object, Object) put(…)} and {@link Map#remove(Object)
      * remove(…)} operations if the underlying metadata object contains setter methods.
-     * The {@code remove(…)} method is implemented by a call to {@code put(…, null)}.</p>
+     * The {@code remove(…)} method is implemented by a call to {@code put(…, null)}.
      *
-     * <p>The keys are case-insensitive and can be either the JavaBeans property name,
the getter method name
+     * {@section Keys and values}
+     * The keys are case-insensitive and can be either the JavaBeans property name, the getter
method name
      * or the {@linkplain org.opengis.annotation.UML#identifier() UML identifier}. The value
given to a call
      * to the {@code put(…)} method shall be an instance of the type expected by the corresponding
setter method,
      * or an instance of a type {@linkplain org.apache.sis.util.ObjectConverters#find(Class,
Class) convertible}
-     * to the expected type.</p>
+     * to the expected type.
      *
-     * <p>Calls to {@code put(…)} replace the previous value, with one noticeable
exception: if the metadata
+     * {@section Multi-values entries}
+     * Calls to {@code put(…)} replace the previous value, with one noticeable exception:
if the metadata
      * property associated to the given key is a {@link java.util.Collection} but the given
value is a single
      * element (not a collection), then the given value is {@linkplain java.util.Collection#add(Object)
added}
      * to the existing collection. In other words, the returned map behaves as a <cite>multi-values
map</cite>
      * for the properties that allow multiple values. If the intend is to unconditionally
discard all previous
      * values, then make sure that the given value is a collection when the associated metadata
property expects
-     * such collection.</p>
+     * such collection.
      *
-     * <p>The default implementation is equivalent to the following method call:</p>
+     * {@section Default implementation}
+     * The default implementation is equivalent to the following method call:
      *
      * {@preformat java
      *   return getStandard().asValueMap(this, KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_EMPTY);
@@ -184,10 +187,7 @@ public abstract class AbstractMetadata i
      * @see MetadataStandard#asValueMap(Object, KeyNamePolicy, ValueExistencePolicy)
      */
     public Map<String,Object> asMap() {
-        if (asMap == null) {
-            asMap = getStandard().asValueMap(this, KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_EMPTY);
-        }
-        return asMap;
+        return getStandard().asValueMap(this, KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_EMPTY);
     }
 
     /**
@@ -195,7 +195,55 @@ public abstract class AbstractMetadata i
      * The tree table is backed by the metadata object using Java reflection, so changes
in the
      * underlying metadata object are immediately reflected in the tree table and conversely.
      *
-     * <p>The default implementation is equivalent to the following method call:</p>
+     * <p>The returned {@code TreeTable} instance contains the following columns:</p>
+     * <ul>
+     *   <li><p>{@link org.apache.sis.util.collection.TableColumn#IDENTIFIER}<br>
+     *       The {@linkplain org.opengis.annotation.UML#identifier() UML identifier} if any,
+     *       or the Java Beans property name otherwise, of a metadata property. For example
+     *       in a tree table view of {@link org.apache.sis.metadata.iso.citation.DefaultCitation},
+     *       there is a node having the {@code "title"} identifier.</p></li>
+     *
+     *   <li><p>{@link org.apache.sis.util.collection.TableColumn#INDEX}<br>
+     *       If the metadata property is a collection, then the zero-based index of the element
in that collection.
+     *       Otherwise {@code null}. For example in a tree table view of {@code DefaultCitation},
if the
+     *       {@code "alternateTitle"} collection contains two elements, then there is a node
with index 0
+     *       for the first element and an other node with index 1 for the second element.</p>
+     *
+     *       <p>The {@code (IDENTIFIER, INDEX)} pair can be used as a primary key for
uniquely identifying
+     *       a node in a list of children. Note that the uniqueness is guaranteed only for
the children of
+     *       a given node; the same keys may appear in the children of any other nodes.</p></li>
+     *
+     *   <li><p>{@link org.apache.sis.util.collection.TableColumn#NAME}<br>
+     *       A human-readable name for the node, derived from the identifier and the index.
+     *       This is the column shown in the default {@link #toString()} implementation and
+     *       may be localizable.</p></li>
+     *
+     *   <li><p>{@link org.apache.sis.util.collection.TableColumn#TYPE}<br>
+     *       The base type of the value (usually an interface).</p></li>
+     *
+     *   <li><p>{@link org.apache.sis.util.collection.TableColumn#VALUE}<br>
+     *       The metadata value for the node. Values in this column are writable if the underlying
+     *       metadata class have a setter method for the property represented by the node.</p></li>
+     * </ul>
+     *
+     * {@section Write operations}
+     * Only the {@code VALUE} column may be writable, with one exception: newly created children
need
+     * to have their {@code IDENTIFIER} set before any other operation. For example the following
code
+     * adds a title to a citation:
+     *
+     * {@preformat java
+     *     TreeTable.Node node = ...; // The node for a DefaultCitation.
+     *     TreeTable.Node child = node.newChild();
+     *     child.setValue(TableColumn.IDENTIFIER, "title");
+     *     child.setValue(TableColumn.VALUE, "Le petit prince");
+     *     // Nothing else to do - the child node has been added.
+     * }
+     *
+     * Nodes can be removed by invoking the {@link java.util.Iterator#remove()} method on
the
+     * {@linkplain org.apache.sis.util.collection.TreeTable.Node#getChildren() children}
iterator.
+     *
+     * {@section Default implementation}
+     * The default implementation is equivalent to the following method call:
      *
      * {@preformat java
      *   return getStandard().asTreeTable(this, ValueExistencePolicy.NON_EMPTY);

Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
[UTF-8] Mon May  6 09:07:41 2013
@@ -580,25 +580,28 @@ public class MetadataStandard implements
      * {@code valuePolicy} determines whether entries having a null value or an empty collection
      * shall be included in the map.</p>
      *
-     * <p>The map supports the {@link Map#put(Object, Object) put(…)} and {@link
Map#remove(Object)
+     * {@section Supported operations}
+     * The map supports the {@link Map#put(Object, Object) put(…)} and {@link Map#remove(Object)
      * remove(…)} operations if the underlying metadata object contains setter methods.
      * The {@code remove(…)} method is implemented by a call to {@code put(…, null)}.
      * Note that whether the entry appears as effectively removed from the map or just cleared
-     * (i.e. associated to a null value) depends on the {@code valuePolicy} argument.</p>
+     * (i.e. associated to a null value) depends on the {@code valuePolicy} argument.
      *
-     * <p>The keys are case-insensitive and can be either the JavaBeans property name,
the getter method name
+     * {@section Keys and values}
+     * The keys are case-insensitive and can be either the JavaBeans property name, the getter
method name
      * or the {@linkplain org.opengis.annotation.UML#identifier() UML identifier}. The value
given to a call
      * to the {@code put(…)} method shall be an instance of the type expected by the corresponding
setter method,
      * or an instance of a type {@linkplain org.apache.sis.util.ObjectConverters#find(Class,
Class) convertible}
-     * to the expected type.</p>
+     * to the expected type.
      *
-     * <p>Calls to {@code put(…)} replace the previous value, with one noticeable
exception: if the metadata
+     * {@section Multi-values entries}
+     * Calls to {@code put(…)} replace the previous value, with one noticeable exception:
if the metadata
      * property associated to the given key is a {@link java.util.Collection} but the given
value is a single
      * element (not a collection), then the given value is {@linkplain java.util.Collection#add(Object)
added}
      * to the existing collection. In other words, the returned map behaves as a <cite>multi-values
map</cite>
      * for the properties that allow multiple values. If the intend is to unconditionally
discard all previous
      * values, then make sure that the given value is a collection when the associated metadata
property expects
-     * such collection.</p>
+     * such collection.
      *
      * @param  metadata The metadata object to view as a map.
      * @param  keyPolicy Determines the string representation of map keys.
@@ -624,6 +627,55 @@ public class MetadataStandard implements
      * The tree table is backed by the metadata object using Java reflection, so changes
in the
      * underlying metadata object are immediately reflected in the tree table and conversely.
      *
+     * <p>The returned {@code TreeTable} instance contains the following columns:</p>
+     * <ul>
+     *   <li><p>{@link org.apache.sis.util.collection.TableColumn#IDENTIFIER}<br>
+     *       The {@linkplain org.opengis.annotation.UML#identifier() UML identifier} if any,
+     *       or the Java Beans property name otherwise, of a metadata property. For example
+     *       in a tree table view of {@link org.apache.sis.metadata.iso.citation.DefaultCitation},
+     *       there is a node having the {@code "title"} identifier.</p></li>
+     *
+     *   <li><p>{@link org.apache.sis.util.collection.TableColumn#INDEX}<br>
+     *       If the metadata property is a collection, then the zero-based index of the element
in that collection.
+     *       Otherwise {@code null}. For example in a tree table view of {@code DefaultCitation},
if the
+     *       {@code "alternateTitle"} collection contains two elements, then there is a node
with index 0
+     *       for the first element and an other node with index 1 for the second element.</p>
+     *
+     *       <p>The {@code (IDENTIFIER, INDEX)} pair can be used as a primary key for
uniquely identifying
+     *       a node in a list of children. Note that the uniqueness is guaranteed only for
the children of
+     *       a given node; the same keys may appear in the children of any other nodes.</p></li>
+     *
+     *   <li><p>{@link org.apache.sis.util.collection.TableColumn#NAME}<br>
+     *       A human-readable name for the node, derived from the identifier and the index.
+     *       This is the column shown in the default {@link #toString()} implementation and
+     *       may be localizable.</p></li>
+     *
+     *   <li><p>{@link org.apache.sis.util.collection.TableColumn#TYPE}<br>
+     *       The base type of the value (usually an interface).</p></li>
+     *
+     *   <li><p>{@link org.apache.sis.util.collection.TableColumn#VALUE}<br>
+     *       The metadata value for the node. Values in this column are writable if the underlying
+     *       metadata class have a setter method for the property represented by the node.</p></li>
+     * </ul>
+     *
+     * {@section Write operations}
+     * Only the {@code VALUE} column may be writable, with one exception: newly created children
need
+     * to have their {@code IDENTIFIER} set before any other operation. For example the following
code
+     * adds a title to a citation:
+     *
+     * {@preformat java
+     *     TreeTable.Node node = ...; // The node for a DefaultCitation.
+     *     TreeTable.Node child = node.newChild();
+     *     child.setValue(TableColumn.IDENTIFIER, "title");
+     *     child.setValue(TableColumn.VALUE, "Le petit prince");
+     *     // Nothing else to do - the child node has been added.
+     * }
+     *
+     * Nodes can be removed by invoking the {@link java.util.Iterator#remove()} method on
the
+     * {@linkplain org.apache.sis.util.collection.TreeTable.Node#getChildren() children}
iterator.
+     * Note that whether the child appears as effectively removed from the node or just cleared
+     * (i.e. associated to a null value) depends on the {@code valuePolicy} argument.
+     *
      * @param  metadata The metadata object to view as a tree table.
      * @param  valuePolicy Whether the property having null value or empty collection shall
be
      *         included in the tree.
@@ -638,7 +690,7 @@ public class MetadataStandard implements
     {
         ensureNonNull("metadata",    metadata);
         ensureNonNull("valuePolicy", valuePolicy);
-        return new MetadataTreeTable(this, metadata, valuePolicy);
+        return new TreeTableView(this, metadata, valuePolicy);
     }
 
     /**

Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java
[UTF-8] Mon May  6 09:07:41 2013
@@ -41,9 +41,6 @@ import org.opengis.annotation.Obligation
  *       fallbacks on alphabetical order.</li>
  * </ol>
  *
- * The first criterion (mandatory methods first) is necessary for reducing the risk
- * of ambiguity in the {@link MetadataTreeTable#parse} method.
- *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-2.4)
  * @version 0.3

Copied: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java
(from r1479498, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java?p2=sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java&p1=sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java&r1=1479498&r2=1479501&rev=1479501&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java [UTF-8]
(original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNode.java [UTF-8]
Mon May  6 09:07:41 2013
@@ -447,13 +447,13 @@ class TreeNode implements Node {
                     it.next(); // Inefficient way to move at the desired index, but hopefully
rare.
                 }
                 return it.next();
-            } catch (NullPointerException | IndexOutOfBoundsException | NoSuchElementException
e) {
+            } catch (RuntimeException e) { // (NullPointerException | IndexOutOfBoundsException
| NoSuchElementException) on JDK7.
                 /*
                  * May happen if the collection for this metadata property changed after
the iteration
                  * in the TreeNodeChildren. Users should not keep TreeNode references instances
for a
                  * long time, but instead iterate again over TreeNodeChildren when needed.
                  */
-                throw new ConcurrentModificationException(e);
+                throw (ConcurrentModificationException) new ConcurrentModificationException().initCause(e);
             }
         }
 
@@ -488,7 +488,7 @@ class TreeNode implements Node {
                 ((List) values).set(indexInList, value);
             } catch (IndexOutOfBoundsException e) {
                 // Same rational than in the getUserObject() method.
-                throw new ConcurrentModificationException(e);
+                throw (ConcurrentModificationException) new ConcurrentModificationException().initCause(e);
             }
         }
     }

Copied: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
(from r1479498, sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java?p2=sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java&p1=sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java&r1=1479498&r2=1479501&rev=1479501&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/TreeNodeChildren.java
[UTF-8] Mon May  6 09:07:41 2013
@@ -26,6 +26,9 @@ import org.apache.sis.util.collection.Tr
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.Debug;
 
+// Related to JDK7
+import org.apache.sis.internal.jdk7.JDK7;
+
 
 /**
  * The collection of children to be returned by {@link TreeNode#getChildren()}.
@@ -396,7 +399,7 @@ final class TreeNodeChildren extends Abs
                         if (nextValue != null) {
                             subIterator = ((Iterable<?>) nextValue).iterator();
                         } else {
-                            subIterator = Collections.emptyIterator();
+                            subIterator = Collections.emptySet().iterator();
                             // Null collections are illegal (it shall be empty collections
instead),
                             // but we try to keep the iterator robut to ill-formed metadata,
because
                             // we want AbstractMetadata.toString() to work so we can spot
problems.
@@ -529,7 +532,7 @@ final class TreeNodeChildren extends Abs
     @Debug
     @Override
     public String toString() {
-        final String lineSeparator = System.lineSeparator();
+        final String lineSeparator = JDK7.lineSeparator();
         final StringBuilder buffer = new StringBuilder(512);
         parent.toString(buffer);
         buffer.append(lineSeparator);

Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ValueExistencePolicy.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ValueExistencePolicy.java?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ValueExistencePolicy.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ValueExistencePolicy.java
[UTF-8] Mon May  6 09:07:41 2013
@@ -47,7 +47,7 @@ public enum ValueExistencePolicy {
         }
 
         /** Substitutes null or empty collections by a null singleton element
-            in order to make the property visible in {@link MetadataTreeNode}. */
+            in order to make the property visible in {@link TreeNode}. */
         @Override boolean substituteByNullElement(final Collection<?> values) {
             return (values == null) || values.isEmpty();
         }
@@ -101,12 +101,12 @@ public enum ValueExistencePolicy {
     abstract boolean isSkipped(Object value);
 
     /**
-     * Returns {@code true} if {@link MetadataTreeNode} shall substitute the given collection
by
+     * Returns {@code true} if {@link TreeNode} shall substitute the given collection by
      * a singleton containing only a null element.
      *
      * <p><b>Purpose:</b>
      * When a collection is null or empty, while not excluded according this {@code ValueExistencePolicy},
-     * we need an empty space for making the metadata property visible in {@code MetadataTreeNode}.</p>
+     * we need an empty space for making the metadata property visible in {@code TreeNode}.</p>
      */
     abstract boolean substituteByNullElement(Collection<?> values);
 

Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
[UTF-8] Mon May  6 09:07:41 2013
@@ -51,14 +51,6 @@ public class ISOMetadata extends Modifia
     protected Collection<Identifier> identifiers;
 
     /**
-     * The {@linkplain #getIdentifierMap() identifier map} as a wrapper around the
-     * {@linkplain #identifiers} collection. This map is created only when first needed.
-     *
-     * @see #getIdentifierMap()
-     */
-    private transient IdentifierMap identifierMap;
-
-    /**
      * Constructs an initially empty metadata.
      */
     protected ISOMetadata() {
@@ -102,19 +94,20 @@ public class ISOMetadata extends Modifia
     /**
      * {@inheritDoc}
      *
-     * <p>The default implementation returns a wrapper around the {@linkplain #identifiers}
list.
+     * <p>The default implementation returns a wrapper around the list returned by
{@link #getIdentifiers()}.
      * That map is <cite>live</cite>: changes in the identifiers list will be
reflected in the map,
      * and conversely.</p>
      */
     @Override
     public IdentifierMap getIdentifierMap() {
-        if (identifierMap == null) {
-            final Collection<Identifier> identifiers = getIdentifiers();
-            if (identifiers == null) {
-                return IdentifierMapWithSpecialCases.EMPTY;
-            }
-            identifierMap = new IdentifierMapWithSpecialCases(identifiers);
+        /*
+         * We do not cache (for now) the IdentifierMap because it is cheap to create, and
if were
+         * caching it we would need anyway to check if 'identifiers' still references the
same list.
+         */
+        final Collection<Identifier> identifiers = getIdentifiers();
+        if (identifiers == null) {
+            return IdentifierMapWithSpecialCases.EMPTY;
         }
-        return identifierMap;
+        return new IdentifierMapWithSpecialCases(identifiers);
     }
 }

Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultObjective.java
[UTF-8] Mon May  6 09:07:41 2013
@@ -162,8 +162,7 @@ public class DefaultObjective extends IS
     @Override
     @XmlElement(name = "identifier", required = true)
     public Collection<Identifier> getIdentifiers() {
-        identifiers = nonNullCollection(identifiers, Identifier.class);
-        return NonMarshalledAuthority.excludeOnMarshalling(identifiers);
+        return NonMarshalledAuthority.excludeOnMarshalling(super.getIdentifiers());
     }
 
     /**

Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
[UTF-8] Mon May  6 09:07:41 2013
@@ -365,8 +365,7 @@ public class DefaultCitation extends ISO
     @Override
     @XmlElement(name = "identifier")
     public Collection<Identifier> getIdentifiers() {
-        identifiers = nonNullCollection(identifiers, Identifier.class);
-        return NonMarshalledAuthority.excludeOnMarshalling(identifiers);
+        return NonMarshalledAuthority.excludeOnMarshalling(super.getIdentifiers());
     }
 
     /**

Copied: sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
(from r1479498, sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java?p2=sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java&p1=sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java&r1=1479498&r2=1479501&rev=1479501&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TreeNodeChildrenTest.java
[UTF-8] Mon May  6 09:07:41 2013
@@ -368,7 +368,7 @@ public final strictfp class TreeNodeChil
      * @param children The collection from which to remove elements.
      */
     private static void testRemove(final Random random, final TreeNodeChildren children)
{
-        final List<TreeTable.Node> reference = new ArrayList<>(children);
+        final List<TreeTable.Node> reference = new ArrayList<TreeTable.Node>(children);
         assertFalse("The collection shall not be initially empty.", reference.isEmpty());
         do {
             final Iterator<TreeTable.Node> rit = reference.iterator(); // The reference
iterator.

Copied: sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java
(from r1479498, sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java?p2=sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java&p1=sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java&r1=1479498&r2=1479501&rev=1479501&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/metadata/TreeTableViewTest.java
[UTF-8] Mon May  6 09:07:41 2013
@@ -90,13 +90,19 @@ public final strictfp class TreeTableVie
         final Object original = create(ValueExistencePolicy.NON_EMPTY);
         final Object deserialized;
         final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-        try (ObjectOutputStream out = new ObjectOutputStream(buffer)) {
+        final ObjectOutputStream out = new ObjectOutputStream(buffer);
+        try {
             out.writeObject(original);
+        } finally {
+            out.close();
         }
         // Now reads the object we just serialized.
         final byte[] data = buffer.toByteArray();
-        try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data)))
{
+        final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data));
+        try {
             deserialized = in.readObject();
+        } finally {
+            in.close();
         }
         assertExpectedString((TreeTableView) deserialized);
     }

Modified: sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
[UTF-8] Mon May  6 09:07:41 2013
@@ -42,9 +42,9 @@ import org.junit.BeforeClass;
     org.apache.sis.metadata.TypeMapTest.class,
     org.apache.sis.metadata.InformationMapTest.class,
     org.apache.sis.metadata.ValueMapTest.class,
-    org.apache.sis.metadata.MetadataTreeChildrenTest.class,
-    org.apache.sis.metadata.MetadataTreeNodeTest.class,
-    org.apache.sis.metadata.MetadataTreeTableTest.class,
+    org.apache.sis.metadata.TreeNodeChildrenTest.class,
+    org.apache.sis.metadata.TreeNodeTest.class,
+    org.apache.sis.metadata.TreeTableViewTest.class,
     org.apache.sis.metadata.MetadataStandardTest.class,
     org.apache.sis.metadata.PrunerTest.class,
     org.apache.sis.metadata.iso.AllMetadataTest.class

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
[UTF-8] Mon May  6 09:07:41 2013
@@ -101,11 +101,6 @@ public class IdentifierMapAdapter extend
     public final Collection<Identifier> identifiers;
 
     /**
-     * A view over the entries, created only when first needed.
-     */
-    private transient Set<Entry<Citation,String>> entries;
-
-    /**
      * Creates a new map which will be a view over the given identifiers.
      *
      * @param identifiers The identifiers to wrap in a map view.
@@ -329,11 +324,14 @@ public class IdentifierMapAdapter extend
      * @return A view over the collection of identifiers.
      */
     @Override
-    public synchronized Set<Entry<Citation,String>> entrySet() {
-        if (entries == null) {
-            entries = new Entries(identifiers);
-        }
-        return entries;
+    public Set<Entry<Citation,String>> entrySet() {
+        /*
+         * Do not cache the entries set because if is very cheap to create and not needed
very often.
+         * Not caching allows this implementation to be thread-safe without synchronization
or volatile
+         * fields if the underlying list is thread-safe. Furthermore, IdentifierMapAdapter
are temporary
+         * objects anyway in the current ISOMetadata implementation.
+         */
+        return new Entries(identifiers);
     }
 
     /**

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java [UTF-8] Mon
May  6 09:07:41 2013
@@ -22,7 +22,7 @@ package org.apache.sis.util;
  * purpose only. The list below summarizes some of the utility classes:
  *
  * <table class="sis">
- * <tr><th colspan="2">Basic classes of the Java language</th></tr>
+ * <tr><th colspan="2">Classes of the Java language</th></tr>
  * <tr><td>{@link Characters}</td>
  *     <td>Find subscript and superscript digit characters.</td></tr>
  * <tr><td>{@link CharSequences}</td>
@@ -30,9 +30,15 @@ package org.apache.sis.util;
  * <tr><td>{@link StringBuilders}</td>
  *     <td>Methods modifying {@link StringBuilder} content in-place.</td></tr>
  * <tr><td>{@link Numbers}</td>
- *     <td>Conversions between different kind of {@link Number}.</td></tr>
+ *     <td>Methods working with {@link Number} instances (include conversions between
different types).</td></tr>
  * <tr><td>{@link Classes}</td>
- *     <td>Methods working on {@link Class} instances.</td></tr>
+ *     <td>Methods working with {@link Class} instances.</td></tr>
+ * <tr><td>{@link org.apache.sis.util.collection.Containers}</td>
+ *     <td>Additions to the JDK {@link java.util.Collections} methods, also related
to the
+ *         {@link org.apache.sis.util.collection.CheckedContainer} interface.</td></tr>
+ * <tr><td>{@link ArraysExt}</td>
+ *     <td>Additions to the JDK {@link java.util.Arrays} methods
+ *         (include insert or remove of elements in the middle of arrays).</td></tr>
  *
  * <tr><th colspan="2" class="hsep">Mathematics and units of measurement</th></tr>
  * <tr><td>{@link org.apache.sis.math.MathFunctions}</td>
@@ -41,13 +47,6 @@ package org.apache.sis.util;
  *     <td>Get a {@linkplain javax.measure.unit.Unit unit} from a symbol or EPSG code,
  *         and test if a unit is angular, linear or temporal.</td></tr>
  *
- * <tr><th colspan="2" class="hsep">Structures (trees, collections, arrays, parameters)</th></tr>
- * <tr><td>{@link org.apache.sis.util.collection.Containers}</td>
- *     <td>Additions to the JDK {@link java.util.Collections} methods, also related
to the
- *         {@link org.apache.sis.util.collection.CheckedContainer} interface.</td></tr>
- * <tr><td>{@link ArraysExt}</td>
- *     <td>Insert or remove elements in the middle of arrays.</td></tr>
- *
  * <tr><th colspan="2" class="hsep">OGC/ISO objects (metadata, referencing, geometries)</th></tr>
  * <tr><td>{@link org.apache.sis.metadata.iso.extent.Extents}</td>
  *     <td>Extract information from {@link org.opengis.metadata.extent.Extent} objects.</td></tr>

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
[UTF-8] Mon May  6 09:07:41 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<Integer>("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).
      */
@@ -229,7 +237,7 @@ public class TableColumn<V> implements C
         private Object readResolve() throws InvalidObjectException {
             try {
                 return TableColumn.class.getField(field).get(null);
-            } catch (Exception cause) { // Many exceptions, including unchecked ones.
+            } catch (Exception cause) { // (ReflectiveOperationException) on JDK7 branch.
                 InvalidObjectException e = new InvalidObjectException(cause.toString());
                 e.initCause(cause);
                 throw e;

Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] Mon May  6 09:07:41 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/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] Mon May  6 09:07:41 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/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1479501&r1=1479500&r2=1479501&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] Mon May  6 09:07:41 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