sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1777943 - in /sis/branches/JDK7: ./ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/ core/sis-utility/src/test/java/org/apache/sis/test/ ide-project/ ide-pr...
Date Mon, 09 Jan 2017 09:15:08 GMT
Author: desruisseaux
Date: Mon Jan  9 09:15:07 2017
New Revision: 1777943

URL: http://svn.apache.org/viewvc?rev=1777943&view=rev
Log:
Merge from the JDK8 branch.

Added:
    sis/branches/JDK7/ide-project/LicenseHeader.txt
      - copied unchanged from r1777936, sis/branches/JDK8/ide-project/LicenseHeader.txt
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/
      - copied from r1777936, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/ConcurrentReadException.java
      - copied unchanged from r1777936, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ConcurrentReadException.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/ConcurrentWriteException.java
      - copied unchanged from r1777936, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ConcurrentWriteException.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/ForwardOnlyStorageException.java
      - copied unchanged from r1777936, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ForwardOnlyStorageException.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/
      - copied from r1777936, sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/
Removed:
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageOutputStream.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DataTransfer.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/HyperRectangleReader.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Markable.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryDataTransfer.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Region.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/InputStreamAdapter.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataInputTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageInputStreamTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageOutputStreamTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/DripByteChannel.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/HyperRectangleReaderTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/IOUtilitiesTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ImageInputStreamComparator.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/MemoryCacheImageOutputStream.java
Modified:
    sis/branches/JDK7/   (props changed)
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Merger.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/MergerTest.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
    sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties
    sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
    sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
    sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java
    sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java
    sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
    sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java
    sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
    sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/ChannelDecoderTest.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataOutput.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelFactory.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelImageInputStream.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/Region.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreClosedException.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreException.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalNameException.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/UnsupportedStorageException.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataInputTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataOutputTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelImageInputStreamTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelImageOutputStreamTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/HyperRectangleReaderTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java

Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan  9 09:15:07 2017
@@ -1,5 +1,5 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1777268
+/sis/branches/JDK8:1584960-1777936
 /sis/branches/JDK9:1773327-1773512
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Merger.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Merger.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Merger.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Merger.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -51,7 +51,8 @@ import org.apache.sis.internal.jdk8.JDK8
  *         <ul>
  *           <li>The {@linkplain MetadataStandard#getInterface(Class) standard type} of the source element
  *               is assignable to the type of the target element.</li>
- *           <li>There is no conflict, i.e. no property value that are not collection and not equal.</li>
+ *           <li>There is no conflict, i.e. no property value that are not collection and not equal
+ *               (note: this condition is disabled if {@link #avoidConflicts} is {@code false}).</li>
  *         </ul>
  *         If such pair is found, then the merge operation if performed recursively
  *         for that pair of source and target elements.</li>
@@ -81,6 +82,14 @@ public class Merger {
     protected final Locale locale;
 
     /**
+     * {@code true} for performing a greater effort of avoiding merge conflicts.
+     * The default value is {@code false}, which may cause {@link #unmerged unmerged(…)} to be invoked in
+     * situation where it could have been avoided. Setting this value to {@code true} increase the chances
+     * of merge success at the expense of more computations.
+     */
+    public boolean avoidConflicts;
+
+    /**
      * Creates a new merger.
      *
      * @param  locale  the locale to use for formatting error messages, or {@code null} for the default locale.
@@ -219,11 +228,16 @@ public class Merger {
                             final Iterator<?> it = sourceList.iterator();
                             while (it.hasNext()) {
                                 final Object value = it.next();
-                                if (merge(value, (ModifiableMetadata) element, true) &&
-                                    merge(value, (ModifiableMetadata) element, false))
-                                {
-                                    it.remove();
-                                    break;          // Merge at most one source element to each target element.
+                                if (!avoidConflicts || merge(value, (ModifiableMetadata) element, true)) {
+                                    /*
+                                     * If enabled, above 'merge' call verified that the merge can be done, including
+                                     * by recursive checks in all children. The intend is to have a "all or nothing"
+                                     * behavior, before the 'merge' call below starts to modify the values.
+                                     */
+                                    if (merge(value, (ModifiableMetadata) element, false)) {
+                                        it.remove();
+                                        break;          // Merge at most one source element to each target element.
+                                    }
                                 }
                             }
                         }
@@ -270,6 +284,9 @@ public class Merger {
      * The default implementation throws an {@link InvalidMetadataException}.
      * Subclasses can override this method if they want to perform a different processing.
      *
+     * <p><b>Tip:</b> to reduce the risks that this method is invoked, consider setting the
+     * {@link #avoidConflicts} flag to {@code true} before invoking {@link #merge merge(…)}.</p>
+     *
      * @param target        the metadata instance in which the value should have been written.
      * @param propertyName  the name of the property to write.
      * @param sourceValue   the value to write.

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/MergerTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/MergerTest.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/MergerTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/MergerTest.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -100,6 +100,7 @@ public final strictfp class MergerTest e
         final DefaultMetadata source = createSample1();
         final DefaultMetadata target = createSample2();
         final Merger merger = new Merger(null);
+        merger.avoidConflicts = true;
         merger.merge(source, target);
 
         assertSetEquals(Arrays.asList(Locale.JAPANESE, Locale.FRENCH),  target.getLanguages());

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -23,6 +23,14 @@ import java.util.Iterator;
 import java.util.Random;
 import java.util.concurrent.Callable;
 import java.io.PrintWriter;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Files;
+import java.nio.file.StandardOpenOption;
+import java.nio.ByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.SeekableByteChannel;
 import java.lang.reflect.UndeclaredThrowableException;
 import java.text.Format;
 import java.text.DateFormat;
@@ -46,7 +54,7 @@ import static org.apache.sis.internal.ut
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.7
+ * @version 0.8
  * @module
  */
 public final strictfp class TestUtilities extends Static {
@@ -437,4 +445,32 @@ public final strictfp class TestUtilitie
         } while (!stop);
         return true;
     }
+
+    /**
+     * Copies the full content of the given test resource in a temporary file and returns the channel for that file.
+     * The file is opened with {@link StandardOpenOption#DELETE_ON_CLOSE}, together with read and write options.
+     *
+     * @param  caller    defines the root from which to search for the {@code resource}.
+     * @param  resource  path (relative to the {@code caller}) of the test file to copy.
+     * @return a channel opened on a copy of the content of the given test resource.
+     * @throws IOException if an error occurred while copying the data.
+     *
+     * @since 0.8
+     */
+    public static SeekableByteChannel createTemporaryFile(final Class<?> caller, final String resource) throws IOException {
+        final SeekableByteChannel channel;
+        try (final ReadableByteChannel in = Channels.newChannel(caller.getResourceAsStream(resource))) {
+            final int s = resource.lastIndexOf('.');
+            final Path file = Files.createTempFile("SIS", (s >= 0) ? resource.substring(s) : null);
+            channel = Files.newByteChannel(file, StandardOpenOption.DELETE_ON_CLOSE,
+                                StandardOpenOption.READ, StandardOpenOption.WRITE);
+            final ByteBuffer buffer = ByteBuffer.allocate(4000);
+            while (in.read(buffer) >= 0) {
+                buffer.flip();
+                channel.write(buffer);
+                buffer.clear();
+            }
+        }
+        return channel.position(0);
+    }
 }

Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1] Mon Jan  9 09:15:07 2017
@@ -32,6 +32,7 @@ excludes             =
 main.class           =
 manifest.file        = manifest.mf
 project.license      = apache20
+project.licensePath  = ../../ide-project/LicenseHeader.txt
 no.dependencies      = true
 source.encoding      = UTF-8
 javac.source         = 1.7

Modified: sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -31,7 +31,7 @@ import org.apache.sis.storage.StorageCon
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
 import org.apache.sis.storage.UnsupportedStorageException;
-import org.apache.sis.internal.storage.ChannelDataInput;
+import org.apache.sis.internal.storage.io.ChannelDataInput;
 import org.apache.sis.internal.storage.MetadataBuilder;
 import org.apache.sis.metadata.sql.MetadataStoreException;
 import org.apache.sis.storage.DataStoreClosedException;

Modified: sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -30,7 +30,7 @@ import org.opengis.metadata.citation.Dat
 import org.opengis.util.FactoryException;
 import org.apache.sis.internal.jdk8.JDK8;
 import org.apache.sis.internal.geotiff.Resources;
-import org.apache.sis.internal.storage.ChannelDataInput;
+import org.apache.sis.internal.storage.io.ChannelDataInput;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
 import org.apache.sis.internal.storage.MetadataBuilder;

Modified: sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -27,7 +27,7 @@ import java.nio.ByteOrder;
 import java.text.ParseException;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
-import org.apache.sis.internal.storage.ChannelDataInput;
+import org.apache.sis.internal.storage.io.ChannelDataInput;
 import org.apache.sis.internal.storage.MetadataBuilder;
 import org.apache.sis.internal.geotiff.Resources;
 import org.apache.sis.util.resources.Errors;

Modified: sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -19,7 +19,7 @@ package org.apache.sis.storage.geotiff;
 import java.util.Arrays;
 import java.io.IOException;
 import java.nio.charset.Charset;
-import org.apache.sis.internal.storage.ChannelDataInput;
+import org.apache.sis.internal.storage.io.ChannelDataInput;
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.math.DecimalFunctions;
 import org.apache.sis.math.Vector;

Modified: sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -42,7 +42,7 @@ import org.apache.sis.internal.netcdf.Gr
 import org.apache.sis.internal.netcdf.NamedElement;
 import org.apache.sis.internal.netcdf.DiscreteSampling;
 import org.apache.sis.internal.netcdf.Resources;
-import org.apache.sis.internal.storage.ChannelDataInput;
+import org.apache.sis.internal.storage.io.ChannelDataInput;
 import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.internal.util.StandardDateFormat;
 import org.apache.sis.storage.DataStoreException;

Modified: sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -24,9 +24,9 @@ import ucar.nc2.constants.CDM;
 import ucar.nc2.constants._Coordinate;
 import org.apache.sis.internal.netcdf.DataType;
 import org.apache.sis.internal.netcdf.Variable;
-import org.apache.sis.internal.storage.ChannelDataInput;
-import org.apache.sis.internal.storage.HyperRectangleReader;
-import org.apache.sis.internal.storage.Region;
+import org.apache.sis.internal.storage.io.ChannelDataInput;
+import org.apache.sis.internal.storage.io.HyperRectangleReader;
+import org.apache.sis.internal.storage.io.Region;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
 import org.apache.sis.util.resources.Errors;

Modified: sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -27,7 +27,7 @@ import java.lang.reflect.UndeclaredThrow
 import org.apache.sis.internal.netcdf.Decoder;
 import org.apache.sis.internal.netcdf.impl.ChannelDecoder;
 import org.apache.sis.internal.netcdf.ucar.DecoderWrapper;
-import org.apache.sis.internal.storage.ChannelDataInput;
+import org.apache.sis.internal.storage.io.ChannelDataInput;
 import org.apache.sis.internal.system.SystemListener;
 import org.apache.sis.internal.system.Modules;
 import org.apache.sis.storage.DataStore;

Modified: sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/ChannelDecoderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/ChannelDecoderTest.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/ChannelDecoderTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/impl/ChannelDecoderTest.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -23,7 +23,7 @@ import java.nio.channels.Channels;
 import org.opengis.wrapper.netcdf.IOTestCase;
 import org.apache.sis.internal.netcdf.Decoder;
 import org.apache.sis.internal.netcdf.DecoderTest;
-import org.apache.sis.internal.storage.ChannelDataInput;
+import org.apache.sis.internal.storage.io.ChannelDataInput;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.test.DependsOn;
 

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -92,6 +92,16 @@ public final class Resources extends Ind
         public static final short ClosedWriter_1 = 5;
 
         /**
+         * One or more read operations are in progress in the “{0}” data store.
+         */
+        public static final short ConcurrentRead_1 = 19;
+
+        /**
+         * A write operation is in progress in the “{0}” data store.
+         */
+        public static final short ConcurrentWrite_1 = 20;
+
+        /**
          * Character string in the “{0}” file is too long. The string has {2} characters while the
          * limit is {1}.
          */
@@ -144,6 +154,16 @@ public final class Resources extends Ind
         public static final short StreamIsForwardOnly_1 = 13;
 
         /**
+         * The “{0}” data store can be read only once.
+         */
+        public static final short StreamIsReadOnce_1 = 18;
+
+        /**
+         * Can not modify previously written data in “{0}”.
+         */
+        public static final short StreamIsWriteOnce_1 = 21;
+
+        /**
          * Format of “{0}” is not recognized.
          */
         public static final short UnknownFormatFor_1 = 14;

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties [ISO-8859-1] Mon Jan  9 09:15:07 2017
@@ -25,6 +25,8 @@ CanNotReadFile_3                  = Can
 CanNotReadFile_4                  = Can not read line {2} (after column {3}) of \u201c{1}\u201d as part of a file in the {0} format.
 ClosedReader_1                    = This {0} reader is closed.
 ClosedWriter_1                    = This {0} writer is closed.
+ConcurrentRead_1                  = One or more read operations are in progress in the \u201c{0}\u201d data store.
+ConcurrentWrite_1                 = A write operation is in progress in the \u201c{0}\u201d data store.
 FeatureAlreadyPresent_2           = A feature named \u201c{1}\u201d is already present in the \u201c{0}\u201d data store.
 FeatureNotFound_2                 = Feature \u201c{1}\u201d has not been found in the \u201c{0}\u201d data store.
 ExcessiveStringSize_3             = Character string in the \u201c{0}\u201d file is too long. The string has {2} characters while the limit is {1}.
@@ -35,4 +37,6 @@ InconsistentNameComponents_2      = Comp
 MissingSchemeInURI_1              = Missing scheme in \u201c{0}\u201d URI.
 ProcessingExecutedOn_1            = Processing executed on {0}.
 StreamIsForwardOnly_1             = Can not move backward in the \u201c{0}\u201d stream.
+StreamIsReadOnce_1                = The \u201c{0}\u201d data store can be read only once.
+StreamIsWriteOnce_1               = Can not modify previously written data in \u201c{0}\u201d.
 UnknownFormatFor_1                = Format of \u201c{0}\u201d is not recognized.

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties [ISO-8859-1] Mon Jan  9 09:15:07 2017
@@ -30,6 +30,8 @@ CanNotReadFile_3                  = Ne p
 CanNotReadFile_4                  = Ne peut pas lire la ligne {2} (apr\u00e8s la colonne {3}) de \u00ab\u202f{1}\u202f\u00bb comme une partie d\u2019un fichier au format {0}.
 ClosedReader_1                    = Ce lecteur {0} est ferm\u00e9.
 ClosedWriter_1                    = Cet encodeur {0} est ferm\u00e9.
+ConcurrentRead_1                  = Une ou plusieurs op\u00e9rations de lecture sont en cours sur les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
+ConcurrentWrite_1                 = Une op\u00e9ration d\u2019\u00e9criture est en cours sur les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
 ExcessiveStringSize_3             = La cha\u00eene de caract\u00e8res dans le fichier \u00ab\u202f{0}\u202f\u00bb est trop longue. La cha\u00eene fait {2} caract\u00e8res alors que la limite est {1}.
 FeatureAlreadyPresent_2           = Une entit\u00e9 nomm\u00e9e \u00ab\u202f{1}\u202f\u00bb est d\u00e9j\u00e0 pr\u00e9sente dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
 FeatureNotFound_2                 = L\u2019entit\u00e9 \u00ab\u202f{1}\u202f\u00bb n\u2019est pas \u00e9t\u00e9 trouv\u00e9e dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
@@ -40,4 +42,6 @@ InconsistentNameComponents_2      = Les
 MissingSchemeInURI_1              = Il manque le sch\u00e9ma dans l\u2019URI \u00ab\u202f{0}\u202f\u00bb.
 ProcessingExecutedOn_1            = Traitement ex\u00e9cut\u00e9 sur {0}.
 StreamIsForwardOnly_1             = Ne peut pas reculer dans le flux de donn\u00e9es \u00ab\u202f{0}\u202f\u00bb.
+StreamIsReadOnce_1                = Les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb ne peuvent \u00eatre lues qu\u2019une seule fois.
+StreamIsWriteOnce_1               = Ne peut pas revenir sur les donn\u00e9es d\u00e9j\u00e0 \u00e9crites dans \u00ab\u202f{0}\u202f\u00bb.
 UnknownFormatFor_1                = Le format de \u00ab\u202f{0}\u202f\u00bb n\u2019est pas reconnu.

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -43,7 +43,7 @@ import org.apache.sis.referencing.CRS;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.internal.referencing.GeodeticObjectBuilder;
 import org.apache.sis.internal.storage.MetadataBuilder;
-import org.apache.sis.internal.storage.IOUtilities;
+import org.apache.sis.internal.storage.io.IOUtilities;
 import org.apache.sis.geometry.GeneralEnvelope;
 import org.apache.sis.metadata.iso.DefaultMetadata;
 import org.apache.sis.metadata.sql.MetadataStoreException;

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java?rev=1777943&r1=1777936&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataInput.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -34,6 +34,9 @@ import org.apache.sis.util.Debug;
 
 import static org.apache.sis.util.ArgumentChecks.ensureBetween;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk8.JDK8;
+
 
 /**
  * Provides convenience methods for working with a ({@link ReadableByteChannel}, {@link ByteBuffer}) pair.
@@ -256,7 +259,7 @@ public class ChannelDataInput extends Ch
      * @throws IOException if an error (including EOF) occurred while reading the stream.
      */
     public final byte readByte() throws IOException {
-        ensureBufferContains(Byte.BYTES);
+        ensureBufferContains(Byte.SIZE / Byte.SIZE);
         return buffer.get();
     }
 
@@ -272,7 +275,7 @@ public class ChannelDataInput extends Ch
      * @throws IOException if an error (including EOF) occurred while reading the stream.
      */
     public final int readUnsignedByte() throws IOException {
-        return Byte.toUnsignedInt(readByte());
+        return JDK8.toUnsignedInt(readByte());
     }
 
     /**
@@ -284,7 +287,7 @@ public class ChannelDataInput extends Ch
      * @throws IOException if an error (including EOF) occurred while reading the stream.
      */
     public final short readShort() throws IOException {
-        ensureBufferContains(Short.BYTES);
+        ensureBufferContains(Short.SIZE / Byte.SIZE);
         return buffer.getShort();
     }
 
@@ -300,7 +303,7 @@ public class ChannelDataInput extends Ch
      * @throws IOException if an error (including EOF) occurred while reading the stream.
      */
     public final int readUnsignedShort() throws IOException {
-        return Short.toUnsignedInt(readShort());
+        return readShort() & 0xFFFF;
     }
 
     /**
@@ -312,7 +315,7 @@ public class ChannelDataInput extends Ch
      * @throws IOException if an error (including EOF) occurred while reading the stream.
      */
     public final char readChar() throws IOException {
-        ensureBufferContains(Character.BYTES);
+        ensureBufferContains(Character.SIZE / Byte.SIZE);
         return buffer.getChar();
     }
 
@@ -325,7 +328,7 @@ public class ChannelDataInput extends Ch
      * @throws IOException if an error (including EOF) occurred while reading the stream.
      */
     public final int readInt() throws IOException {
-        ensureBufferContains(Integer.BYTES);
+        ensureBufferContains(Integer.SIZE / Byte.SIZE);
         return buffer.getInt();
     }
 
@@ -341,7 +344,7 @@ public class ChannelDataInput extends Ch
      * @throws IOException if an error (including EOF) occurred while reading the stream.
      */
     public final long readUnsignedInt() throws IOException {
-        return Integer.toUnsignedLong(readInt());
+        return readInt() & 0xFFFFFFFFL;
     }
 
     /**
@@ -353,7 +356,7 @@ public class ChannelDataInput extends Ch
      * @throws IOException if an error (including EOF) occurred while reading the stream.
      */
     public final long readLong() throws IOException {
-        ensureBufferContains(Long.BYTES);
+        ensureBufferContains(Long.SIZE / Byte.SIZE);
         return buffer.getLong();
     }
 
@@ -366,7 +369,7 @@ public class ChannelDataInput extends Ch
      * @throws IOException if an error (including EOF) occurred while reading the stream.
      */
     public final float readFloat() throws IOException {
-        ensureBufferContains(Float.BYTES);
+        ensureBufferContains(Float.SIZE / Byte.SIZE);
         return buffer.getFloat();
     }
 
@@ -379,7 +382,7 @@ public class ChannelDataInput extends Ch
      * @throws IOException if an error (including EOF) occurred while reading the stream.
      */
     public final double readDouble() throws IOException {
-        ensureBufferContains(Double.BYTES);
+        ensureBufferContains(Double.SIZE / Byte.SIZE);
         return buffer.getDouble();
     }
 

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataOutput.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataOutput.java?rev=1777943&r1=1777936&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataOutput.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelDataOutput.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -219,7 +219,7 @@ public class ChannelDataOutput extends C
      * @throws IOException if some I/O exception occurs during writing.
      */
     public final void writeByte(final int value) throws IOException {
-        ensureBufferAccepts(Byte.BYTES);
+        ensureBufferAccepts(Byte.SIZE / Byte.SIZE);
         buffer.put((byte) value);
     }
 
@@ -233,7 +233,7 @@ public class ChannelDataOutput extends C
      * @throws IOException if some I/O exception occurs during writing.
      */
     public final void writeShort(final int value) throws IOException {
-        ensureBufferAccepts(Short.BYTES);
+        ensureBufferAccepts(Short.SIZE / Byte.SIZE);
         buffer.putShort((short) value);
     }
 
@@ -246,7 +246,7 @@ public class ChannelDataOutput extends C
      * @throws IOException if some I/O exception occurs during writing.
      */
     public final void writeChar(final int value) throws IOException {
-        ensureBufferAccepts(Character.BYTES);
+        ensureBufferAccepts(Character.SIZE / Byte.SIZE);
         buffer.putChar((char) value);
     }
 
@@ -259,7 +259,7 @@ public class ChannelDataOutput extends C
      * @throws IOException if some I/O exception occurs during writing.
      */
     public final void writeInt(final int value) throws IOException {
-        ensureBufferAccepts(Integer.BYTES);
+        ensureBufferAccepts(Integer.SIZE / Byte.SIZE);
         buffer.putInt(value);
     }
 
@@ -272,7 +272,7 @@ public class ChannelDataOutput extends C
      * @throws IOException if some I/O exception occurs during writing.
      */
     public final void writeLong(final long value) throws IOException {
-        ensureBufferAccepts(Long.BYTES);
+        ensureBufferAccepts(Long.SIZE / Byte.SIZE);
         buffer.putLong(value);
     }
 
@@ -285,7 +285,7 @@ public class ChannelDataOutput extends C
      * @throws IOException if some I/O exception occurs during writing.
      */
     public final void writeFloat(final float value) throws IOException {
-        ensureBufferAccepts(Float.BYTES);
+        ensureBufferAccepts(Float.SIZE / Byte.SIZE);
         buffer.putFloat(value);
     }
 
@@ -298,7 +298,7 @@ public class ChannelDataOutput extends C
      * @throws IOException if some I/O exception occurs during writing.
      */
     public final void writeDouble(final double value) throws IOException {
-        ensureBufferAccepts(Double.BYTES);
+        ensureBufferAccepts(Double.SIZE / Byte.SIZE);
         buffer.putDouble(value);
     }
 
@@ -498,7 +498,7 @@ public class ChannelDataOutput extends C
             private CharBuffer view;
             @Override Buffer createView() {return view = buffer.asCharBuffer();}
             @Override void transfer(int offset, int n) {view.put(src, offset, n);}
-        }.writeFully(Character.BYTES, offset, length);
+        }.writeFully(Character.SIZE / Byte.SIZE, offset, length);
     }
 
     /**
@@ -514,7 +514,7 @@ public class ChannelDataOutput extends C
             private ShortBuffer view;
             @Override Buffer createView() {return view = buffer.asShortBuffer();}
             @Override void transfer(int offset, int length) {view.put(src, offset, length);}
-        }.writeFully(Short.BYTES, offset, length);
+        }.writeFully(Short.SIZE / Byte.SIZE, offset, length);
     }
 
     /**
@@ -530,7 +530,7 @@ public class ChannelDataOutput extends C
             private IntBuffer view;
             @Override Buffer createView() {return view = buffer.asIntBuffer();}
             @Override void transfer(int offset, int n) {view.put(src, offset, n);}
-        }.writeFully(Integer.BYTES, offset, length);
+        }.writeFully(Integer.SIZE / Byte.SIZE, offset, length);
     }
 
     /**
@@ -546,7 +546,7 @@ public class ChannelDataOutput extends C
             private LongBuffer view;
             @Override Buffer createView() {return view = buffer.asLongBuffer();}
             @Override void transfer(int offset, int n) {view.put(src, offset, n);}
-        }.writeFully(Long.BYTES, offset, length);
+        }.writeFully(Long.SIZE / Byte.SIZE, offset, length);
     }
 
     /**
@@ -562,7 +562,7 @@ public class ChannelDataOutput extends C
             private FloatBuffer view;
             @Override Buffer createView() {return view = buffer.asFloatBuffer();}
             @Override void transfer(int offset, int n) {view.put(src, offset, n);}
-        }.writeFully(Float.BYTES, offset, length);
+        }.writeFully(Float.SIZE / Byte.SIZE, offset, length);
     }
 
     /**
@@ -578,7 +578,7 @@ public class ChannelDataOutput extends C
             private DoubleBuffer view;
             @Override Buffer createView() {return view = buffer.asDoubleBuffer();}
             @Override void transfer(int offset, int n) {view.put(src, offset, n);}
-        }.writeFully(Double.BYTES, offset, length);
+        }.writeFully(Double.SIZE / Byte.SIZE, offset, length);
     }
 
     /**

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelFactory.java?rev=1777943&r1=1777936&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelFactory.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -126,7 +126,7 @@ public abstract class ChannelFactory {
          */
         final Set<OpenOption> optionSet;
         if (options == null || options.length == 0) {
-            optionSet = Collections.singleton(StandardOpenOption.READ);
+            optionSet = Collections.<OpenOption>singleton(StandardOpenOption.READ);
         } else {
             optionSet = new HashSet<>(Arrays.asList(options));
             optionSet.add(StandardOpenOption.READ);

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelImageInputStream.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelImageInputStream.java?rev=1777943&r1=1777936&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelImageInputStream.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelImageInputStream.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -25,6 +25,9 @@ import java.nio.channels.SeekableByteCha
 import javax.imageio.stream.IIOByteBuffer;
 import javax.imageio.stream.ImageInputStream;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk8.JDK8;
+
 
 /**
  * Adds the missing methods in {@code ChannelDataInput} for implementing the {@code ImageInputStream} interface.
@@ -192,7 +195,7 @@ loop:   while ((c = read()) >= 0) {
      */
     @Override
     public final int read() throws IOException {
-        return hasRemaining() ? Byte.toUnsignedInt(buffer.get()) : -1;
+        return hasRemaining() ? JDK8.toUnsignedInt(buffer.get()) : -1;
     }
 
     /**

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java?rev=1777943&r1=1777936&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/IOUtilities.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -46,6 +46,9 @@ import org.apache.sis.util.Static;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.storage.Resources;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk8.JDK8;
+
 
 /**
  * Utility methods related to I/O operations. Many methods in this class accept arbitrary {@link Object} argument
@@ -196,7 +199,7 @@ public final class IOUtilities extends S
                 }
                 for (final byte b : path.substring(i, i+n).getBytes(StandardCharsets.UTF_8)) {
                     buffer.append('%');
-                    final String hex = Integer.toHexString(Byte.toUnsignedInt(b)).toUpperCase(Locale.ROOT);
+                    final String hex = Integer.toHexString(JDK8.toUnsignedInt(b)).toUpperCase(Locale.ROOT);
                     if (hex.length() < 2) {
                         buffer.append('0');
                     }

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/Region.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/Region.java?rev=1777943&r1=1777936&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/Region.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/Region.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -16,6 +16,9 @@
  */
 package org.apache.sis.internal.storage.io;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk8.JDK8;
+
 
 /**
  * A sub-area in a <var>n</var>-dimensional hyper-rectangle, optionally with sub-sampling.
@@ -103,7 +106,7 @@ public final class Region {
             final long upper = lower + ((count-1) * step + 1);
             final long span  = size[i];
             assert (count > 0) && (lower >= 0) && (upper > lower) && (upper <= span) : i;
-            targetSize[i] = Math.toIntExact(count);
+            targetSize[i] = JDK8.toIntExact(count);
 
             position += stride * lower;
             skip     += stride * (span - (upper - lower));
@@ -138,6 +141,6 @@ public final class Region {
         for (int i=0; i<dimension; i++) {
             length *= targetSize[i];
         }
-        return Math.toIntExact(length);
+        return JDK8.toIntExact(length);
     }
 }

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -25,7 +25,7 @@
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.8
  * @module
  */
 package org.apache.sis.internal.storage;

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreClosedException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreClosedException.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreClosedException.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreClosedException.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -18,7 +18,7 @@ package org.apache.sis.storage;
 
 import java.util.Locale;
 import java.nio.file.OpenOption;
-import org.apache.sis.internal.storage.IOUtilities;
+import org.apache.sis.internal.storage.io.IOUtilities;
 import org.apache.sis.internal.storage.Resources;
 
 

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreException.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreException.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreException.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -20,7 +20,7 @@ import java.util.Locale;
 import org.opengis.util.InternationalString;
 import org.apache.sis.util.LocalizedException;
 import org.apache.sis.internal.storage.Resources;
-import org.apache.sis.internal.storage.IOUtilities;
+import org.apache.sis.internal.storage.io.IOUtilities;
 import org.apache.sis.util.Workaround;
 
 
@@ -66,7 +66,6 @@ public class DataStoreException extends
      * Creates an exception with no cause and no details message.
      */
     public DataStoreException() {
-        super();
     }
 
     /**

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalNameException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalNameException.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalNameException.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalNameException.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -44,7 +44,6 @@ public class IllegalNameException extend
      * Creates an exception with no cause and no details message.
      */
     public IllegalNameException() {
-        super();
     }
 
     /**

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -41,9 +41,11 @@ import org.apache.sis.util.Classes;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ObjectConverters;
 import org.apache.sis.util.resources.Errors;
-import org.apache.sis.internal.storage.IOUtilities;
-import org.apache.sis.internal.storage.ChannelDataInput;
-import org.apache.sis.internal.storage.ChannelImageInputStream;
+import org.apache.sis.internal.storage.io.IOUtilities;
+import org.apache.sis.internal.storage.io.ChannelFactory;
+import org.apache.sis.internal.storage.io.ChannelDataInput;
+import org.apache.sis.internal.storage.io.ChannelImageInputStream;
+import org.apache.sis.internal.storage.io.InputStreamAdapter;
 import org.apache.sis.setup.OptionKey;
 
 
@@ -73,7 +75,7 @@ import org.apache.sis.setup.OptionKey;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.8
  * @module
  */
 public class StorageConnector implements Serializable {
@@ -397,6 +399,12 @@ public class StorageConnector implements
             } else if (type == ChannelDataInput.class) {                // Undocumented case (SIS internal)
                 createChannelDataInput(false);
                 done = true;
+            } else if (type == ChannelFactory.class) {                  // Undocumented case (SIS internal)
+                /*
+                 * ChannelFactory may have been created as a side effect of creating a ReadableByteChannel.
+                 * Caller should have asked for another type (e.g. InputStream) before to ask for this type.
+                 */
+                done = true;
             }
         } catch (IOException e) {
             throw new DataStoreException(Errors.format(Errors.Keys.CanNotOpen_1, getStorageName()), e);
@@ -411,7 +419,7 @@ public class StorageConnector implements
         final Object value;
         try {
             value = createView(type);
-        } catch (RuntimeException e) {
+        } catch (RuntimeException | DataStoreException e) {
             throw e;
         } catch (Exception e) {
             throw new DataStoreException(Errors.format(Errors.Keys.CanNotOpen_1, getStorageName()), e);
@@ -455,11 +463,13 @@ public class StorageConnector implements
          * Following method call recognizes ReadableByteChannel, InputStream (with special case for FileInputStream),
          * URL, URI, File, Path or other types that may be added in future SIS versions.
          */
-        final ReadableByteChannel channel = IOUtilities.open(storage,
-                getOption(OptionKey.URL_ENCODING), getOption(OptionKey.OPEN_OPTIONS));
+        final ChannelFactory factory = ChannelFactory.prepare(storage,
+                getOption(OptionKey.URL_ENCODING), false, getOption(OptionKey.OPEN_OPTIONS));
 
         ChannelDataInput asDataInput = null;
-        if (channel != null) {
+        if (factory != null) {
+            final String name = getStorageName();
+            final ReadableByteChannel channel = factory.reader(name);
             addViewToClose(channel, storage);
             ByteBuffer buffer = getOption(OptionKey.BYTE_BUFFER);
             if (buffer == null) {
@@ -467,13 +477,19 @@ public class StorageConnector implements
                 // TODO: we do not create direct buffer yet, but this is something
                 // we may want to consider in a future SIS version.
             }
-            final String name = getStorageName();
             if (asImageInputStream) {
                 asDataInput = new ChannelImageInputStream(name, channel, buffer, false);
             } else {
                 asDataInput = new ChannelDataInput(name, channel, buffer, false);
             }
             addViewToClose(asDataInput, channel);
+            /*
+             * Following is an undocumented mechanism for allowing some Apache SIS implementations of DataStore
+             * to re-open the same channel or input stream another time, typically for re-reading the same data.
+             */
+            if (factory.canOpen()) {
+                addView(ChannelFactory.class, factory);
+            }
         }
         addView(ChannelDataInput.class, asDataInput);
     }

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/UnsupportedStorageException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/UnsupportedStorageException.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/UnsupportedStorageException.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/UnsupportedStorageException.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -20,7 +20,7 @@ import java.util.Locale;
 import java.nio.file.OpenOption;
 import org.apache.sis.util.Classes;
 import org.apache.sis.internal.storage.Resources;
-import org.apache.sis.internal.storage.IOUtilities;
+import org.apache.sis.internal.storage.io.IOUtilities;
 
 
 /**
@@ -43,7 +43,6 @@ public class UnsupportedStorageException
      * Creates an exception with no cause and no details message.
      */
     public UnsupportedStorageException() {
-        super();
     }
 
     /**

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -27,7 +27,7 @@
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.8
  * @module
  */
 package org.apache.sis.storage;

Modified: sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataInputTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataInputTest.java?rev=1777943&r1=1777936&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataInputTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataInputTest.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -58,7 +58,7 @@ public final strictfp class ChannelDataI
         final byte[] array = createRandomArray(STREAM_LENGTH);
         referenceStream = new DataInputStream(new ByteArrayInputStream(array));
         testedStream = new ChannelDataInput("testAllReadMethods", new DripByteChannel(array, random, 1, 1024),
-                ByteBuffer.allocate(random.nextInt(BUFFER_MAX_CAPACITY) + Double.BYTES), false);
+                ByteBuffer.allocate(random.nextInt(BUFFER_MAX_CAPACITY) + (Double.SIZE / Byte.SIZE)), false);
         transferRandomData(testedStream, array.length - ARRAY_MAX_LENGTH, 16);
     }
 
@@ -89,42 +89,42 @@ public final strictfp class ChannelDataI
                 break;
             }
             case 10: {
-                final int n = random.nextInt(ARRAY_MAX_LENGTH / Character.BYTES);
+                final int n = random.nextInt(ARRAY_MAX_LENGTH / (Character.SIZE / Byte.SIZE));
                 final char[] tmp = new char[n];
                 for (int i=0; i<n; i++) tmp[i] = r.readChar();
                 assertArrayEquals("readChars(int)", tmp, t.readChars(n));
                 break;
             }
             case 11: {
-                final int n = random.nextInt(ARRAY_MAX_LENGTH / Short.BYTES);
+                final int n = random.nextInt(ARRAY_MAX_LENGTH / (Short.SIZE / Byte.SIZE));
                 final short[] tmp = new short[n];
                 for (int i=0; i<n; i++) tmp[i] = r.readShort();
                 assertArrayEquals("readShorts(int)", tmp, t.readShorts(n));
                 break;
             }
             case 12: {
-                final int n = random.nextInt(ARRAY_MAX_LENGTH / Integer.BYTES);
+                final int n = random.nextInt(ARRAY_MAX_LENGTH / (Integer.SIZE / Byte.SIZE));
                 final int[] tmp = new int[n];
                 for (int i=0; i<n; i++) tmp[i] = r.readInt();
                 assertArrayEquals("readInts(int)", tmp, t.readInts(n));
                 break;
             }
             case 13: {
-                final int n = random.nextInt(ARRAY_MAX_LENGTH / Long.BYTES);
+                final int n = random.nextInt(ARRAY_MAX_LENGTH / (Long.SIZE / Byte.SIZE));
                 final long[] tmp = new long[n];
                 for (int i=0; i<n; i++) tmp[i] = r.readLong();
                 assertArrayEquals("readLongs(int)", tmp, t.readLongs(n));
                 break;
             }
             case 14: {
-                final int n = random.nextInt(ARRAY_MAX_LENGTH / Float.BYTES);
+                final int n = random.nextInt(ARRAY_MAX_LENGTH / (Float.SIZE / Byte.SIZE));
                 final float[] tmp = new float[n];
                 for (int i=0; i<n; i++) tmp[i] = r.readFloat();
                 assertArrayEquals("readFloats(int)", tmp, t.readFloats(n), 0);
                 break;
             }
             case 15: {
-                final int n = random.nextInt(ARRAY_MAX_LENGTH / Double.BYTES);
+                final int n = random.nextInt(ARRAY_MAX_LENGTH / (Double.SIZE / Byte.SIZE));
                 final double[] tmp = new double[n];
                 for (int i=0; i<n; i++) tmp[i] = r.readDouble();
                 assertArrayEquals("readDoubles(int)", tmp, t.readDoubles(n), 0);
@@ -160,7 +160,7 @@ public final strictfp class ChannelDataI
     public void testSeekOnForwardOnlyChannel() throws IOException {
         int length = random.nextInt(2048) + 1024;
         final byte[] array = createRandomArray(length);
-        length -= Long.BYTES; // Safety against buffer underflow.
+        length -= (Long.SIZE / Byte.SIZE);                      // Safety against buffer underflow.
         final ByteBuffer buffer = ByteBuffer.wrap(array);
         final ChannelDataInput input = new ChannelDataInput("testSeekOnForwardOnlyChannel",
                 new DripByteChannel(array, random, 1, 2048),

Modified: sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataOutputTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataOutputTest.java?rev=1777943&r1=1777936&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataOutputTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelDataOutputTest.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -108,7 +108,7 @@ public strictfp class ChannelDataOutputT
      */
     @Test
     public void testAllWriteMethods() throws IOException {
-        initialize("testAllWriteMethods", STREAM_LENGTH, random.nextInt(BUFFER_MAX_CAPACITY) + Double.BYTES);
+        initialize("testAllWriteMethods", STREAM_LENGTH, random.nextInt(BUFFER_MAX_CAPACITY) + (Double.SIZE / Byte.SIZE));
         writeInStreams();
         assertStreamContentEquals();
     }
@@ -132,11 +132,11 @@ public strictfp class ChannelDataOutputT
     @Test
     @DependsOnMethod("testAllWriteMethods")
     public void testWriteAndSeek() throws IOException {
-        initialize("testWriteAndSeek", STREAM_LENGTH, random.nextInt(BUFFER_MAX_CAPACITY) + Double.BYTES);
+        initialize("testWriteAndSeek", STREAM_LENGTH, random.nextInt(BUFFER_MAX_CAPACITY) + (Double.SIZE / Byte.SIZE));
         writeInStreams();
         ((Closeable) referenceStream).close();
         final byte[] expectedArray = expectedData.toByteArray();
-        final int seekRange = expectedArray.length - Long.BYTES;
+        final int seekRange = expectedArray.length - (Long.SIZE / Byte.SIZE);
         final ByteBuffer arrayView = ByteBuffer.wrap(expectedArray);
         for (int i=0; i<100; i++) {
             final int position = random.nextInt(seekRange);
@@ -295,14 +295,14 @@ public strictfp class ChannelDataOutputT
                 break;
             }
             case 7: {
-                final byte[] tmp = new byte[random.nextInt(ARRAY_MAX_LENGTH / Byte.BYTES)];
+                final byte[] tmp = new byte[random.nextInt(ARRAY_MAX_LENGTH / (Byte.SIZE / Byte.SIZE))];
                 random.nextBytes(tmp);
                 r.write(tmp);
                 t.write(tmp);
                 break;
             }
             case 8: {
-                final char[] tmp = new char[random.nextInt(ARRAY_MAX_LENGTH / Character.BYTES)];
+                final char[] tmp = new char[random.nextInt(ARRAY_MAX_LENGTH / (Character.SIZE / Byte.SIZE))];
                 for (int i=0; i<tmp.length; i++) {
                     tmp[i] = (char) random.nextInt(1 << Character.SIZE);
                     if (!(r instanceof ImageOutputStream)) {
@@ -316,7 +316,7 @@ public strictfp class ChannelDataOutputT
                 break;
             }
             case 9: {
-                final short[] tmp = new short[random.nextInt(ARRAY_MAX_LENGTH / Short.BYTES)];
+                final short[] tmp = new short[random.nextInt(ARRAY_MAX_LENGTH / (Short.SIZE / Byte.SIZE))];
                 for (int i=0; i<tmp.length; i++) {
                     tmp[i] = (short) random.nextInt(1 << Short.SIZE);
                     if (!(r instanceof ImageOutputStream)) {
@@ -330,7 +330,7 @@ public strictfp class ChannelDataOutputT
                 break;
             }
             case 10: {
-                final int[] tmp = new int[random.nextInt(ARRAY_MAX_LENGTH / Integer.BYTES)];
+                final int[] tmp = new int[random.nextInt(ARRAY_MAX_LENGTH / (Integer.SIZE / Byte.SIZE))];
                 for (int i=0; i<tmp.length; i++) {
                     tmp[i] = random.nextInt();
                     if (!(r instanceof ImageOutputStream)) {
@@ -344,7 +344,7 @@ public strictfp class ChannelDataOutputT
                 break;
             }
             case 11: {
-                final long[] tmp = new long[random.nextInt(ARRAY_MAX_LENGTH / Long.BYTES)];
+                final long[] tmp = new long[random.nextInt(ARRAY_MAX_LENGTH / (Long.SIZE / Byte.SIZE))];
                 for (int i=0; i<tmp.length; i++) {
                     tmp[i] = random.nextLong();
                     if (!(r instanceof ImageOutputStream)) {
@@ -358,7 +358,7 @@ public strictfp class ChannelDataOutputT
                 break;
             }
             case 12: {
-                final float[] tmp = new float[random.nextInt(ARRAY_MAX_LENGTH / Float.BYTES)];
+                final float[] tmp = new float[random.nextInt(ARRAY_MAX_LENGTH / (Float.SIZE / Byte.SIZE))];
                 for (int i=0; i<tmp.length; i++) {
                     tmp[i] = random.nextFloat();
                     if (!(r instanceof ImageOutputStream)) {
@@ -372,7 +372,7 @@ public strictfp class ChannelDataOutputT
                 break;
             }
             case 13: {
-                final double[] tmp = new double[random.nextInt(ARRAY_MAX_LENGTH / Double.BYTES)];
+                final double[] tmp = new double[random.nextInt(ARRAY_MAX_LENGTH / (Double.SIZE / Byte.SIZE))];
                 for (int i=0; i<tmp.length; i++) {
                     tmp[i] = random.nextDouble();
                     if (!(r instanceof ImageOutputStream)) {

Modified: sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelImageInputStreamTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelImageInputStreamTest.java?rev=1777943&r1=1777936&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelImageInputStreamTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelImageInputStreamTest.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -116,42 +116,42 @@ public final strictfp class ChannelImage
                 break;
             }
             case 15: {
-                final int length = random.nextInt(ARRAY_MAX_LENGTH / Character.BYTES);
+                final int length = random.nextInt(ARRAY_MAX_LENGTH / (Character.SIZE / Byte.SIZE));
                 final char[] expected = new char[length]; r.readFully(expected, 0, length);
                 final char[] actual   = new char[length]; t.readFully(actual,   0, length);
                 assertArrayEquals("readFully(char[])", expected, actual);
                 break;
             }
             case 16: {
-                final int length = random.nextInt(ARRAY_MAX_LENGTH / Short.BYTES);
+                final int length = random.nextInt(ARRAY_MAX_LENGTH / (Short.SIZE / Byte.SIZE));
                 final short[] expected = new short[length]; r.readFully(expected, 0, length);
                 final short[] actual   = new short[length]; t.readFully(actual,   0, length);
                 assertArrayEquals("readFully(short[])", expected, actual);
                 break;
             }
             case 17: {
-                final int length = random.nextInt(ARRAY_MAX_LENGTH / Integer.BYTES);
+                final int length = random.nextInt(ARRAY_MAX_LENGTH / (Integer.SIZE / Byte.SIZE));
                 final int[] expected = new int[length]; r.readFully(expected, 0, length);
                 final int[] actual   = new int[length]; t.readFully(actual,   0, length);
                 assertArrayEquals("readFully(int[])", expected, actual);
                 break;
             }
             case 18: {
-                final int length = random.nextInt(ARRAY_MAX_LENGTH / Long.BYTES);
+                final int length = random.nextInt(ARRAY_MAX_LENGTH / (Long.SIZE / Byte.SIZE));
                 final long[] expected = new long[length]; r.readFully(expected, 0, length);
                 final long[] actual   = new long[length]; t.readFully(actual,   0, length);
                 assertArrayEquals("readFully(long[])", expected, actual);
                 break;
             }
             case 19: {
-                final int length = random.nextInt(ARRAY_MAX_LENGTH / Float.BYTES);
+                final int length = random.nextInt(ARRAY_MAX_LENGTH / (Float.SIZE / Byte.SIZE));
                 final float[] expected = new float[length]; r.readFully(expected, 0, length);
                 final float[] actual   = new float[length]; t.readFully(actual,   0, length);
                 assertTrue("readFully(float[])", Arrays.equals(expected, actual));
                 break;
             }
             case 20: {
-                final int length = random.nextInt(ARRAY_MAX_LENGTH / Double.BYTES);
+                final int length = random.nextInt(ARRAY_MAX_LENGTH / (Double.SIZE / Byte.SIZE));
                 final double[] expected = new double[length]; r.readFully(expected, 0, length);
                 final double[] actual   = new double[length]; t.readFully(actual,   0, length);
                 assertTrue("readFully(double[])", Arrays.equals(expected, actual));

Modified: sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelImageOutputStreamTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelImageOutputStreamTest.java?rev=1777943&r1=1777936&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelImageOutputStreamTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/ChannelImageOutputStreamTest.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -58,7 +58,7 @@ public final strictfp class ChannelImage
      */
     @Test
     public void testWriteBits() throws IOException {
-        initialize("testWriteBits", STREAM_LENGTH, random.nextInt(BUFFER_MAX_CAPACITY) + Long.BYTES);
+        initialize("testWriteBits", STREAM_LENGTH, random.nextInt(BUFFER_MAX_CAPACITY) + (Long.SIZE / Byte.SIZE));
         final ImageOutputStream referenceStream = (ImageOutputStream) this.referenceStream;
         final int length = testedStreamBackingArray.length - ARRAY_MAX_LENGTH; // Keep a margin against buffer underflow.
         while (testedStream.getStreamPosition() < length) {
@@ -95,7 +95,7 @@ public final strictfp class ChannelImage
          */
         int nbMarks = 0;
         for (int i=0; i<STREAM_LENGTH; i++) {
-            if (randomEvent() && i < STREAM_LENGTH - Long.BYTES) {
+            if (randomEvent() && i < STREAM_LENGTH - (Long.SIZE / Byte.SIZE)) {
                 referenceStream.mark();
                 testedStream.mark();
                 nbMarks++;
@@ -144,7 +144,7 @@ public final strictfp class ChannelImage
     @DependsOnMethod("testMarkAndReset")
     public void testFlushBefore() throws IOException {
         final int N = 50; // Number of long values to write.
-        initialize("testFlushBefore", N*Long.BYTES, 200);
+        initialize("testFlushBefore", N*(Long.SIZE / Byte.SIZE), 200);
         final ImageOutputStream referenceStream = (ImageOutputStream) this.referenceStream;
         for (int i=0; i<N; i++) {
             switch (i) {
@@ -157,13 +157,13 @@ public final strictfp class ChannelImage
                     break;
                 }
                 case 10: {
-                    referenceStream.flushBefore(5 * Long.BYTES);
-                    testedStream.flushBefore(5 * Long.BYTES);
+                    referenceStream.flushBefore(5 * (Long.SIZE / Byte.SIZE));
+                    testedStream.flushBefore(5 * (Long.SIZE / Byte.SIZE));
                     break;
                 }
                 case 35: {
-                    referenceStream.flushBefore(32 * Long.BYTES);
-                    testedStream.flushBefore(32 * Long.BYTES);
+                    referenceStream.flushBefore(32 * (Long.SIZE / Byte.SIZE));
+                    testedStream.flushBefore(32 * (Long.SIZE / Byte.SIZE));
                     break;
                 }
             }

Modified: sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/HyperRectangleReaderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/HyperRectangleReaderTest.java?rev=1777943&r1=1777936&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/HyperRectangleReaderTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/io/HyperRectangleReaderTest.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -112,7 +112,7 @@ public final strictfp class HyperRectang
          * different than zero.
          */
         final int origin = random.nextInt(10);
-        final byte[] array = new byte[origin + length*Short.BYTES];
+        final byte[] array = new byte[origin + length*(Short.SIZE / Byte.SIZE)];
         for (int i=0; i<origin; i++) {
             array[i] = (byte) random.nextInt(0x100);
         }
@@ -120,7 +120,7 @@ public final strictfp class HyperRectang
          * Fill the array with short values using the encoding describes in javadoc.
          * Then wrap the array in a pseudo-channel so we can create the reader to test.
          */
-        final ShortBuffer view = ByteBuffer.wrap(array, origin, length*Short.BYTES).order(ByteOrder.nativeOrder()).asShortBuffer();
+        final ShortBuffer view = ByteBuffer.wrap(array, origin, length*(Short.SIZE / Byte.SIZE)).order(ByteOrder.nativeOrder()).asShortBuffer();
         for (int i3=0; i3<size[3]; i3++) {
             for (int i2=0; i2<size[2]; i2++) {
                 for (int i1=0; i1<size[1]; i1++) {

Modified: sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -26,8 +26,9 @@ import javax.imageio.ImageIO;
 import javax.imageio.stream.ImageInputStream;
 import java.sql.Connection;
 import org.apache.sis.setup.OptionKey;
-import org.apache.sis.internal.storage.ChannelDataInput;
-import org.apache.sis.internal.storage.ChannelImageInputStream;
+import org.apache.sis.internal.storage.io.ChannelDataInput;
+import org.apache.sis.internal.storage.io.ChannelImageInputStream;
+import org.apache.sis.internal.storage.io.InputStreamAdapter;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -45,7 +46,7 @@ import static org.opengis.test.Assert.*;
  * @module
  */
 @SuppressWarnings("OverlyStrongTypeCast")
-@DependsOn(org.apache.sis.internal.storage.ChannelImageInputStreamTest.class)
+@DependsOn(org.apache.sis.internal.storage.io.ChannelImageInputStreamTest.class)
 public final strictfp class StorageConnectorTest extends TestCase {
     /**
      * The magic number of Java class files, used for verifying the content of our test file.
@@ -88,7 +89,7 @@ public final strictfp class StorageConne
      * Tests the {@link StorageConnector#getStorageAs(Class)} method for the {@link String} type.
      *
      * @throws DataStoreException if an error occurred while using the storage connector.
-     * @throws IOException Should never happen.
+     * @throws IOException should never happen since we do not open any file.
      */
     @Test
     public void testGetAsString() throws DataStoreException, IOException {
@@ -201,11 +202,12 @@ public final strictfp class StorageConne
         assertNotSame(connection.getStorage(), in);
         assertSame("Expected cached value.", in, connection.getStorageAs(InputStream.class));
         assertInstanceOf("Expected Channel backend", InputStreamAdapter.class, in);
-        assertInstanceOf("Expected Channel backend", ChannelImageInputStream.class, ((InputStreamAdapter) in).input);
-        assertSame(((InputStreamAdapter) in).input, connection.getStorageAs(DataInput.class));
-        assertSame(((InputStreamAdapter) in).input, connection.getStorageAs(ImageInputStream.class));
+        final ImageInputStream input = ((InputStreamAdapter) in).input;
+        assertInstanceOf("Expected Channel backend", ChannelImageInputStream.class, input);
+        assertSame(input, connection.getStorageAs(DataInput.class));
+        assertSame(input, connection.getStorageAs(ImageInputStream.class));
 
-        final ReadableByteChannel channel = ((ChannelImageInputStream) ((InputStreamAdapter) in).input).channel;
+        final ReadableByteChannel channel = ((ChannelImageInputStream) input).channel;
         assertTrue(channel.isOpen());
         connection.closeAllExcept(null);
         assertFalse(channel.isOpen());
@@ -285,7 +287,7 @@ public final strictfp class StorageConne
     public void testGetAsTemporaryByteBuffer() throws DataStoreException, IOException {
         StorageConnector connection = create(true);
         final DataInput in = ImageIO.createImageInputStream(connection.getStorage());
-        assertNotNull("ImageIO.createImageInputStream(InputStream)", in); // Sanity check.
+        assertNotNull("ImageIO.createImageInputStream(InputStream)", in);                   // Sanity check.
         connection = new StorageConnector(in);
         assertSame(in, connection.getStorageAs(DataInput.class));
 
@@ -300,7 +302,7 @@ public final strictfp class StorageConne
      * Tests the {@link StorageConnector#getStorageAs(Class)} method for the {@link Connection} type.
      *
      * @throws DataStoreException if an error occurred while using the storage connector.
-     * @throws IOException Should never happen.
+     * @throws IOException should never happen since we do not open any file.
      */
     public void testGetAsConnection() throws DataStoreException, IOException {
         final StorageConnector connection = create(false);

Modified: sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java?rev=1777943&r1=1777942&r2=1777943&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java [UTF-8] Mon Jan  9 09:15:07 2017
@@ -31,12 +31,12 @@ import org.junit.BeforeClass;
  */
 @Suite.SuiteClasses({
     org.apache.sis.internal.storage.CodeTypeTest.class,
-    org.apache.sis.internal.storage.IOUtilitiesTest.class,
-    org.apache.sis.internal.storage.ChannelDataInputTest.class,
-    org.apache.sis.internal.storage.ChannelDataOutputTest.class,
-    org.apache.sis.internal.storage.ChannelImageInputStreamTest.class,
-    org.apache.sis.internal.storage.ChannelImageOutputStreamTest.class,
-    org.apache.sis.internal.storage.HyperRectangleReaderTest.class,
+    org.apache.sis.internal.storage.io.IOUtilitiesTest.class,
+    org.apache.sis.internal.storage.io.ChannelDataInputTest.class,
+    org.apache.sis.internal.storage.io.ChannelDataOutputTest.class,
+    org.apache.sis.internal.storage.io.ChannelImageInputStreamTest.class,
+    org.apache.sis.internal.storage.io.ChannelImageOutputStreamTest.class,
+    org.apache.sis.internal.storage.io.HyperRectangleReaderTest.class,
     org.apache.sis.internal.storage.MetadataBuilderTest.class,
     org.apache.sis.storage.FeatureNamingTest.class,
     org.apache.sis.storage.ProbeResultTest.class,



Mime
View raw message