You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2014/04/27 22:19:51 UTC

svn commit: r1590483 [1/2] - in /sis/branches/JDK6: ./ core/sis-build-helper/src/site/ core/sis-utility/src/main/java/org/apache/sis/util/resources/ core/sis-utility/src/main/javadoc/ core/sis-utility/src/site/ core/sis-utility/src/test/java/org/apache...

Author: desruisseaux
Date: Sun Apr 27 20:19:51 2014
New Revision: 1590483

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

Added:
    sis/branches/JDK6/src/README.txt
      - copied unchanged from r1590476, sis/branches/JDK7/src/README.txt
    sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java
      - copied, changed from r1590476, sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java
    sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java
      - copied, changed from r1590476, sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java
    sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageOutputStream.java
      - copied, changed from r1590476, sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageOutputStream.java
    sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java
      - copied, changed from r1590476, sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java
    sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java
      - copied, changed from r1590476, sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java
    sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java
      - copied, changed from r1590476, sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java
    sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageOutputStreamTest.java
      - copied, changed from r1590476, sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageOutputStreamTest.java
    sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/MemoryCacheImageOutputStream.java
      - copied, changed from r1590476, sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/MemoryCacheImageOutputStream.java
Removed:
    sis/branches/JDK6/core/sis-build-helper/src/site/
    sis/branches/JDK6/core/sis-utility/src/site/
Modified:
    sis/branches/JDK6/   (props changed)
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
    sis/branches/JDK6/core/sis-utility/src/main/javadoc/overview.html
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
    sis/branches/JDK6/pom.xml
    sis/branches/JDK6/src/main/javadoc/stylesheet.css
    sis/branches/JDK6/src/site/apt/index.apt
    sis/branches/JDK6/src/site/site.xml
    sis/branches/JDK6/storage/sis-storage/pom.xml
    sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
    sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
    sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
    sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java
    sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataInputTest.java
    sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelImageInputStreamTest.java
    sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java

Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK8:r1589202-1590469
  Merged /sis/branches/JDK7:r1589203-1590476

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -215,6 +215,11 @@ public final class Errors extends Indexe
         public static final short ExcessiveListSize_2 = 25;
 
         /**
+         * The character string is too long.
+         */
+        public static final short ExcessiveStringSize = 153;
+
+        /**
          * Attribute “{0}” is not allowed for an object of type ‘{1}’.
          */
         public static final short ForbiddenAttribute_2 = 26;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] Sun Apr 27 20:19:51 2014
@@ -54,6 +54,7 @@ EmptyEnvelope2D                   = Enve
 EmptyProperty_1                   = Property named \u201c{0}\u201d shall not be empty.
 ExcessiveArgumentSize_3           = Argument \u2018{0}\u2019 shall not contain more than {1} elements. A number of {2} is excessive.
 ExcessiveListSize_2               = A size of {1} elements is excessive for the \u201c{0}\u201d list.
+ExcessiveStringSize               = The character string is too long.
 ForbiddenAttribute_2              = Attribute \u201c{0}\u201d is not allowed for an object of type \u2018{1}\u2019.
 IllegalArgumentClass_2            = Argument \u2018{0}\u2019 can not be an instance of \u2018{1}\u2019.
 IllegalArgumentClass_3            = Argument \u2018{0}\u2019 can not be an instance of \u2018{2}\u2019. Expected an instance of \u2018{1}\u2019 or derived type.

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] Sun Apr 27 20:19:51 2014
@@ -44,6 +44,7 @@ EmptyEnvelope2D                   = L\u2
 EmptyProperty_1                   = La propri\u00e9t\u00e9 nomm\u00e9e \u00ab\u202f{0}\u202f\u00bb ne doit pas \u00eatre vide.
 ExcessiveArgumentSize_3           = L\u2019argument \u2018{0}\u2019 ne peut pas contenir plus de {1} \u00e9l\u00e9ments. Un nombre de {2} est excessif.
 ExcessiveListSize_2               = Une taille de {1} \u00e9l\u00e9ments est excessive pour la liste \u00ab\u202f{0}\u202f\u00bb.
+ExcessiveStringSize               = La cha\u00eene de caract\u00e8res est trop longue.
 ForbiddenAttribute_2              = L\u2019attribut \u00ab\u202f{0}\u202f\u00bb n\u2019est pas autoris\u00e9 pour un objet de type \u2018{1}\u2019.
 IllegalArgumentClass_2            = L\u2019argument \u2018{0}\u2019 ne peut pas \u00eatre de type \u2018{1}\u2019.
 IllegalArgumentClass_3            = L\u2019argument \u2018{0}\u2019 ne peut pas \u00eatre de type \u2018{2}\u2019. Une instance de \u2018{1}\u2019 ou d\u2019un type d\u00e9riv\u00e9 \u00e9tait attendue.

Modified: sis/branches/JDK6/core/sis-utility/src/main/javadoc/overview.html
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/javadoc/overview.html?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/javadoc/overview.html (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/javadoc/overview.html Sun Apr 27 20:19:51 2014
@@ -28,5 +28,20 @@
     Overview of Apache <code>sis-utility</code> module.
     This Javadoc is only about one specific module. For the full Apache SIS project,
     see the <a href="http://sis.apache.org/apidocs/overview-summary.html">aggregated Javadoc</a>.
+
+    <p>The <code>sis-utility</code> module provides simple data objects and miscellaneous utilities.
+    The services provided by this module include internationalization, operations on common Java types
+    like Arrays and character strings, logging, and more.</p>
+
+    <p>Some functionalities provided by this module may overlap some external libraries like
+    <code>common-logging</code> and <code>commons-collections</code>. However this module often implement
+    them in a slightly different way. For example instead of defining new API for logging operations,
+    SIS uses the standard Java logging framework with optional adaptors on top of <code>java.util.logging.Logger</code>
+    for users who want to redirect to other logging frameworks.</p>
+
+    <p>Since this is not the purpose of this module to compete with dedicated libraries, this
+    module should be considered as mostly internal to the Apache SIS project. For example
+    any future SIS release may change the collection implementations (how they perform
+    synchronizations, how they handle exceptions, <i>etc.</i>) in order to fit SIS needs.</p>
   </body>
 </html>

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -122,7 +122,7 @@ public strictfp class Assert extends org
     public static void assertMultilinesEquals(final String message, final CharSequence expected, final CharSequence actual) {
         final CharSequence[] expectedLines = CharSequences.splitOnEOL(expected);
         final CharSequence[] actualLines   = CharSequences.splitOnEOL(actual);
-        final int length = Math.min(expectedLines.length, actualLines.length);
+        final int length = StrictMath.min(expectedLines.length, actualLines.length);
         final StringBuilder buffer = new StringBuilder(message != null ? message : "Line").append('[');
         final int base = buffer.length();
         for (int i=0; i<length; i++) {

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -28,6 +28,7 @@ import java.text.Format;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import org.apache.sis.util.Debug;
 import org.apache.sis.util.Static;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.ArgumentChecks;
@@ -44,7 +45,7 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.16)
- * @version 0.4
+ * @version 0.5
  * @module
  */
 public final strictfp class TestUtilities extends Static {
@@ -171,6 +172,31 @@ public final strictfp class TestUtilitie
     }
 
     /**
+     * Returns a new random number generator with the given seed. This method is used only for debugging a test failure.
+     * The seed given in argument is the value printed by the test runner. This argument shall be removed after the test
+     * has been fixed.
+     *
+     * <p>The work flow is as below:</p>
+     * <ul>
+     *   <li>Uses {@link #createRandomNumberGenerator()} (without argument} in tests.</li>
+     *   <li>If a test fail, find the seed value printed by the test runner, then insert that value in argument
+     *       to {@code createRandomNumberGenerator(…)}.</li>
+     *   <li>Debug the test.</li>
+     *   <li>Once the test has been fixed, remove the argument from the {@code createRandomNumberGenerator()} call.</li>
+     * </ul>
+     *
+     * @param  seed The random generator seed.
+     * @return A new random number generator initialized with the given seed.
+     *
+     * @since 0.5
+     */
+    @Debug
+    public static Random createRandomNumberGenerator(final long seed) {
+        TestCase.randomSeed = seed;
+        return new Random(seed);
+    }
+
+    /**
      * Parses the date for the given string using the {@code "yyyy-MM-dd HH:mm:ss"} pattern
      * in UTC timezone.
      *

Modified: sis/branches/JDK6/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/pom.xml?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/pom.xml (original)
+++ sis/branches/JDK6/pom.xml Sun Apr 27 20:19:51 2014
@@ -596,7 +596,6 @@ Apache SIS is a free software, Java lang
           <additionalparam>
               -link http://www.geoapi.org/snapshot/javadoc/
               -link http://www.geoapi.org/snapshot/pending/
-              -Xdoclint:syntax -Xdoclint:missing -Xdoclint:accessibility
           </additionalparam>
 
           <!-- Separates packages on the overview page into the groups specified. -->

Modified: sis/branches/JDK6/src/main/javadoc/stylesheet.css
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/src/main/javadoc/stylesheet.css?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/src/main/javadoc/stylesheet.css (original)
+++ sis/branches/JDK6/src/main/javadoc/stylesheet.css Sun Apr 27 20:19:51 2014
@@ -149,6 +149,7 @@ div.block h6 {
 
 /*
  * Bullet and ordered lists. Put some space before and after the list.
+ * Listes of the "verbose" class also have some space betweem items.
  */
 div.block ul,
 div.block ol {
@@ -162,6 +163,11 @@ div.block li > ol {
   margin-bottom: 6px;
 }
 
+ul.verbose li {
+  margin-top:    6px;
+  margin-bottom: 6px;
+}
+
 
 
 

Modified: sis/branches/JDK6/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/src/site/apt/index.apt?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/src/site/apt/index.apt [UTF-8] (original)
+++ sis/branches/JDK6/src/site/apt/index.apt [UTF-8] Sun Apr 27 20:19:51 2014
@@ -42,42 +42,5 @@ The Apache SIS™ library
   SIS is a project of the {{{http://www.apache.org}Apache Software Foundation}}.
   The project home is {{http://sis.apache.org}}.
 
-
-* Modules
-
-  Maven-generated reports for SIS modules are available at the following locations:
-
-  * Core
-
-    * {{{./sis-build-helper/index.html}Build helper}} — Maven Mojos and Javadoc taglets for SIS build.
-
-    * {{{./sis-utility/index.html}Utilities}} — simple data objects and miscellaneous utilities.
-
-    * {{{./sis-metadata/index.html}Metadata}} — metadata classes derived from ISO 19115.
-
-    * {{{./sis-referencing/index.html}Referencing}} — Coordinate Reference Systems (CRS), conversion and transformation services derived from ISO 19111.
-
-    * {{{./sis-feature/index.html}Features}} — Representations of geographic features.
-
-  * Storage
-
-    * {{{./sis-storage/index.html}Storage}} — Base classes to be implemented by various storage formats.
-
-    * {{{./sis-shapefile/index.html}Shapefile}} — Read and write files in the Shapefile format.
-
-    * {{{./sis-netcdf/index.html}NetCDF}} — Bridge between NetCDF Climate and Forecast (CF) convention and ISO 19115 metadata.
-
-  * Applications
-
-    * {{{./sis-webapp/index.html}Wep application}} — Web application.
-
-    * {{{./sis-console/index.html}Console application}} — Console application.
-
-  * Profiles
-
-    * {{{./sis-french-profile/index.html}French profile}} — Extensions to ISO-19115 metadata mandated by the French government.
-
-  []
-
   Apache SIS, Apache, the Apache feather logo, and the Apache SIS project logo are trademarks of
   The Apache Software Foundation.

Modified: sis/branches/JDK6/src/site/site.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/src/site/site.xml?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/src/site/site.xml (original)
+++ sis/branches/JDK6/src/site/site.xml Sun Apr 27 20:19:51 2014
@@ -53,13 +53,9 @@
       <!-- Absolute URL in order to point to the aggregated Javadoc instead than module Javadoc. -->
     </menu>
 
-    <!--
-        Do not list the modules because the links generated by maven-site-plugin do not match the
-        directory layout created by Jenkins (http://issues.apache.org/jira/browse/SIS-112).
-    -->
-
-    <menu ref="parent"  inherit="top"/> <!-- Replaced by a link to the parent. -->
-    <menu ref="reports" inherit="top"/> <!-- Replaced by menus for any configured reports (mailing lists, etc.) -->
+    <menu ref="parent"  inherit="top"/>    <!-- Replaced by a link to the parent. -->
+    <menu ref="modules" inherit="top"/>    <!-- Replaced by menu for submodules. -->
+    <menu ref="reports" inherit="top"/>    <!-- Replaced by menus for any configured reports (mailing lists, etc.) -->
 
   </body>
 </project>

Modified: sis/branches/JDK6/storage/sis-storage/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/pom.xml?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-storage/pom.xml (original)
+++ sis/branches/JDK6/storage/sis-storage/pom.xml Sun Apr 27 20:19:51 2014
@@ -85,6 +85,16 @@ Provides the interfaces and base classes
         <role>developer</role>
       </roles>
     </contributor>
+    <contributor>
+      <name>Rémi Maréchal</name>
+      <email>remi.marechal@geomatys.com</email>
+      <organization>Geomatys</organization>
+      <organizationUrl>http://www.geomatys.com/</organizationUrl>
+      <timezone>+1</timezone>
+      <roles>
+        <role>developer</role>
+      </roles>
+    </contributor>
   </contributors>
 
 

Copied: sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java (from r1590476, sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java?p2=sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java&p1=sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java&r1=1590476&r2=1590483&rev=1590483&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -26,7 +26,7 @@ import org.apache.sis.util.resources.Err
 import static org.apache.sis.util.ArgumentChecks.ensureBetween;
 
 // Related to JDK7
-import java.nio.channels.SeekableByteChannel;
+import java.nio.channels.FileChannel;
 
 
 /**
@@ -121,7 +121,7 @@ public abstract class ChannelData {
     ChannelData(final String filename, final Channel channel, final ByteBuffer buffer) throws IOException {
         this.filename      = filename;
         this.buffer        = buffer;
-        this.channelOffset = (channel instanceof SeekableByteChannel) ? ((SeekableByteChannel) channel).position() : 0;
+        this.channelOffset = (channel instanceof FileChannel) ? ((FileChannel) channel).position() : 0;
     }
 
     /**

Modified: sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -28,7 +28,8 @@ import java.nio.FloatBuffer;
 import java.nio.DoubleBuffer;
 import java.nio.channels.ReadableByteChannel;
 import org.apache.sis.util.resources.Errors;
-import org.apache.sis.util.Debug;
+
+import static org.apache.sis.util.ArgumentChecks.ensureBetween;
 
 // Related to JDK7
 import java.nio.channels.FileChannel;
@@ -40,11 +41,11 @@ import java.nio.channels.FileChannel;
  * before {@code ChannelDataInput} creation.
  *
  * {@section Encapsulation}
- * This class exposes publicly the {@linkplain #channel} and the {@linkplain #buffer} because it is not expected
- * to perform all possible data manipulations that we can do with the buffers. This class is only a helper tool,
- * which often needs to be completed by specialized operations performed directly on the buffer. However, users
- * are encouraged to transfer data from the channel to the buffer using only the methods provided in this class
- * if they want to keep the {@link #seek(long)} and {@link #getStreamPosition()} values accurate.
+ * This class exposes publicly the {@linkplain #channel} and the {@linkplain #buffer buffer} because this class
+ * is not expected to perform all possible data manipulations that we can do with the buffers. This class is only
+ * a helper tool, which often needs to be completed by specialized operations performed directly on the buffer.
+ * However, users are encouraged to transfer data from the channel to the buffer using only the methods provided
+ * in this class if they want to keep the {@link #seek(long)} and {@link #getStreamPosition()} values accurate.
  *
  * <p>Since this class is only a helper tool, it does not "own" the channel and consequently does not provide
  * {@code close()} method. It is users responsibility to close the channel after usage.</p>
@@ -59,15 +60,10 @@ import java.nio.channels.FileChannel;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.07)
- * @version 0.4
+ * @version 0.5
  * @module
  */
-public class ChannelDataInput {
-    /**
-     * A file identifier used only for formatting error message.
-     */
-    public final String filename;
-
+public class ChannelDataInput extends ChannelData {
     /**
      * The channel from where data are read.
      * This is supplied at construction time.
@@ -75,30 +71,7 @@ public class ChannelDataInput {
     public final ReadableByteChannel channel;
 
     /**
-     * The buffer to use for transferring data from the channel to memory.
-     */
-    public final ByteBuffer buffer;
-
-    /**
-     * The position of the channel when this {@code ChannelDataInput} has been created.
-     * This is almost always 0, but we allow other values in case the data to read are
-     * encompassed inside a bigger file.
-     */
-    private final long channelOffset;
-
-    /**
-     * The position in {@link #channel} where is located the {@link #buffer} value at index 0.
-     * This is initially zero and shall be incremented as below:
-     *
-     * <ul>
-     *   <li>By {@link Buffer#position()} every time {@link ByteBuffer#compact()} is invoked.</li>
-     *   <li>By {@link Buffer#limit()}    every time {@link ByteBuffer#clear()}   is invoked.</li>
-     * </ul>
-     */
-    private long bufferOffset;
-
-    /**
-     * Creates a new input source for the given channel and using the given buffer.
+     * Creates a new data input for the given channel and using the given buffer.
      * If the buffer already contains some data, then the {@code filled} argument shall be {@code true}.
      * Otherwise (e.g. if it is a newly created buffer), then {@code filled} shall be {@code false}.
      *
@@ -112,10 +85,8 @@ public class ChannelDataInput {
     public ChannelDataInput(final String filename, final ReadableByteChannel channel, final ByteBuffer buffer,
             final boolean filled) throws IOException
     {
-        this.filename      = filename;
-        this.channel       = channel;
-        this.buffer        = buffer;
-        this.channelOffset = (channel instanceof FileChannel) ? ((FileChannel) channel).position() : 0;
+        super(filename, channel, buffer);
+        this.channel = channel;
         if (!filled) {
             buffer.clear();
             channel.read(buffer);
@@ -124,32 +95,6 @@ public class ChannelDataInput {
     }
 
     /**
-     * Invoked when a call to {@link ReadableByteChannel#read(ByteBuffer)} has returned zero.
-     * Note that this is unrelated to end-of-file, in which case {@code read} returns -1.
-     * A return value of 0 happen for example if the channel is a socket in non-blocking mode
-     * and the socket buffer has not yet received new data.
-     *
-     * <p>The current implementation sleeps an arbitrary amount of time before to allow a new try.
-     * We do that in order to avoid high CPU consumption when data are expected to take more than
-     * a few nanoseconds to arrive.</p>
-     *
-     * @throws IOException If the implementation chooses to stop the reading process.
-     */
-    protected void onEmptyChannelBuffer() throws IOException {
-        try {
-            Thread.sleep(200);
-        } catch (InterruptedException e) {
-            /*
-             * Someone doesn't want to let us sleep. Stop the reading process. We don't try to go back to work,
-             * because the waiting time was short and this method is invoked in loops. Consequently if the user
-             * interrupted us, it is probably because he waited for a long time and we still have not received
-             * any new data.
-             */
-            throw new IOException(e);
-        }
-    }
-
-    /**
      * Tries to read more bytes from the channel without changing the buffer position.
      * This method returns a negative number if the buffer is already full or if the channel reached the
      * <cite>end of stream</cite>. Otherwise this method reads an arbitrary amount of bytes not greater
@@ -170,7 +115,7 @@ public class ChannelDataInput {
         buffer.limit(capacity).position(limit);
         int c = channel.read(buffer);
         while (c == 0) {
-            onEmptyChannelBuffer();
+            onEmptyTransfer();
             c = channel.read(buffer);
         }
         buffer.limit(buffer.position()).position(position);
@@ -179,9 +124,9 @@ public class ChannelDataInput {
 
     /**
      * Returns {@code true} if the buffer or the channel has at least one byte remaining.
-     * If the {@linkplain #buffer} has no remaining bytes, then this method will attempts
-     * to read at least one byte from the {@linkplain #channel}. If no bytes can be read
-     * because the channel has reached the end of stream, then this method returns {@code false}.
+     * If the {@linkplain #buffer buffer} has no remaining bytes, then this method will attempts
+     * to read at least one byte from the {@linkplain #channel}. If no bytes can be read because
+     * the channel has reached the end of stream, then this method returns {@code false}.
      *
      * @return {@code true} if the buffer contains at least one remaining byte.
      * @throws IOException If it was necessary to read from the channel and this operation failed.
@@ -194,7 +139,7 @@ public class ChannelDataInput {
         buffer.clear();
         int c = channel.read(buffer);
         while (c == 0) {
-            onEmptyChannelBuffer();
+            onEmptyTransfer();
             c = channel.read(buffer);
         }
         buffer.flip();
@@ -206,12 +151,12 @@ public class ChannelDataInput {
      * It is caller's responsibility to ensure that the given number of bytes is
      * not greater than the {@linkplain ByteBuffer#capacity() buffer capacity}.
      *
-     * @param  n The minimal number of bytes needed in the {@linkplain #buffer}.
+     * @param  n The minimal number of bytes needed in the {@linkplain #buffer buffer}.
      * @throws EOFException If the channel has reached the end of stream.
      * @throws IOException If an other kind of error occurred while reading.
      */
     public final void ensureBufferContains(int n) throws EOFException, IOException {
-        assert n <= buffer.capacity() : n;
+        assert n >= 0 && n <= buffer.capacity() : n;
         n -= buffer.remaining();
         if (n > 0) {
             bufferOffset += buffer.position();
@@ -222,7 +167,7 @@ public class ChannelDataInput {
                     if (c != 0) {
                         throw new EOFException(eof());
                     }
-                    onEmptyChannelBuffer();
+                    onEmptyTransfer();
                 }
                 n -= c;
             } while (n > 0);
@@ -250,6 +195,59 @@ public class ChannelDataInput {
     }
 
     /**
+     * Pushes back the last processed byte. This is used when a call to {@code readBit()} did not
+     * used every bits in a byte, or when {@code readLine()} checked for the Windows-style of EOL.
+     */
+    final void pushBack() {
+        buffer.position(buffer.position() - 1);
+    }
+
+    /**
+     * Reads a single bit from the stream. The bit to be read depends on the
+     * {@linkplain #getBitOffset() current bit offset}.
+     *
+     * @return The value of the next bit from the stream.
+     * @throws IOException If an error occurred while reading (including EOF).
+     */
+    public final int readBit() throws IOException {
+        return (int) readBits(1);
+    }
+
+    /**
+     * Reads many bits from the stream. The first bit to be read depends on the
+     * {@linkplain #getBitOffset() current bit offset}.
+     *
+     * @param  numBits The number of bits to read.
+     * @return The value of the next bits from the stream.
+     * @throws IOException If an error occurred while reading (including EOF).
+     */
+    public final long readBits(int numBits) throws IOException {
+        ensureBetween("numBits", 0, Long.SIZE, numBits);
+        if (numBits == 0) {
+            return 0;
+        }
+        /*
+         * Reads the bits available in the next bytes (all of them if bitOffset == 0)
+         * and compute the number of bits that still need to be read. That number may
+         * be negative if we have read too many bits.
+         */
+        final int bitOffset = getBitOffset();
+        long value = readByte() & (0xFF >>> bitOffset);
+        numBits -= (Byte.SIZE - bitOffset);
+        while (numBits > 0) {
+            value = (value << Byte.SIZE) | readUnsignedByte();
+            numBits -= Byte.SIZE;
+        }
+        if (numBits != 0) {
+            value >>>= (-numBits); // Discard the unwanted bits.
+            numBits += Byte.SIZE;
+            pushBack();
+        }
+        setBitOffset(numBits);
+        return value;
+    }
+
+    /**
      * Reads the next byte value (8 bits) from the stream. This method ensures that there is at
      * least 1 byte remaining in the buffer, reading new bytes from the channel if necessary,
      * then delegates to {@link ByteBuffer#get()}.
@@ -561,7 +559,7 @@ public class ChannelDataInput {
             skipInBuffer(n * dataSize);
             while ((length -= n) != 0) {
                 offset += n;
-                ensureBufferContains(dataSize);
+                ensureBufferContains(dataSize); // Actually read as much data as possible.
                 view.position(0).limit(buffer.remaining() / dataSize);
                 transfer(offset, n = Math.min(view.remaining(), length));
                 skipInBuffer(n * dataSize);
@@ -701,6 +699,7 @@ public class ChannelDataInput {
      * @param  position The position where to move.
      * @throws IOException If the stream can not be moved to the given position.
      */
+    @Override
     public final void seek(final long position) throws IOException {
         long p = position - bufferOffset;
         if (p >= 0 && p <= buffer.limit()) {
@@ -717,9 +716,7 @@ public class ChannelDataInput {
              */
             ((FileChannel) channel).position(channelOffset + position);
             bufferOffset = position;
-            buffer.clear();
-            channel.read(buffer);
-            buffer.flip();
+            buffer.clear().limit(0);
         } else if (p >= 0) {
             /*
              * Requested position is after the current buffer limits and
@@ -734,7 +731,7 @@ public class ChannelDataInput {
                     if (c != 0) {
                         throw new EOFException(eof());
                     }
-                    onEmptyChannelBuffer();
+                    onEmptyTransfer();
                 }
                 buffer.flip();
             } while (p > buffer.limit());
@@ -746,40 +743,6 @@ public class ChannelDataInput {
              */
             throw new IOException(Errors.format(Errors.Keys.StreamIsForwardOnly_1, filename));
         }
-    }
-
-    /**
-     * Sets the current byte position of the stream. This method does <strong>not</strong> seeks the stream;
-     * this method only modifies the value to be returned by {@link #getStreamPosition()}. This method can
-     * be invoked when some external code has performed some work with the {@linkplain #channel} and wants
-     * to inform this {@code ChannelDataInput} about the new position resulting from this work.
-     *
-     * <p>This method does not need to be invoked when only the {@linkplain Buffer#position() buffer position}
-     * has changed.</p>
-     *
-     * @param position The new position of the stream.
-     */
-    public final void setStreamPosition(final long position) {
-        bufferOffset = position - buffer.position();
-    }
-
-    /**
-     * Returns the current byte position of the stream.
-     *
-     * @return The position of the stream.
-     */
-    public final long getStreamPosition() {
-        return bufferOffset + buffer.position();
-    }
-
-    /**
-     * Returns a string representation of this object for debugging purpose.
-     *
-     * @return A string representation of this channel.
-     */
-    @Debug
-    @Override
-    public String toString() {
-        return getClass().getSimpleName() + "[“" + filename + "” at " + getStreamPosition() + ']';
+        clearBitOffset();
     }
 }

Copied: sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java (from r1590476, sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java?p2=sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java&p1=sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java&r1=1590476&r2=1590483&rev=1590483&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -32,7 +32,7 @@ import org.apache.sis.util.resources.Err
 import static org.apache.sis.util.ArgumentChecks.ensureBetween;
 
 // Related to JDK7
-import java.nio.channels.SeekableByteChannel;
+import java.nio.channels.FileChannel;
 
 
 /**
@@ -597,13 +597,13 @@ public class ChannelDataOutput extends C
              */
             buffer.position((int) p);
             clearBitOffset();
-        } else if (channel instanceof SeekableByteChannel) {
+        } else if (channel instanceof FileChannel) {
             /*
              * Requested position is outside the current limits of the buffer,
              * but we can set the new position directly in the channel.
              */
             flush();
-            ((SeekableByteChannel) channel).position(channelOffset + position);
+            ((FileChannel) channel).position(channelOffset + position);
             bufferOffset = position;
         } else {
             // We can not move position beyond the buffered part.

Modified: sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -23,9 +23,6 @@ import java.nio.ByteOrder;
 import java.nio.channels.ReadableByteChannel;
 import javax.imageio.stream.IIOByteBuffer;
 import javax.imageio.stream.ImageInputStream;
-import org.apache.sis.util.resources.Errors;
-
-import static org.apache.sis.util.ArgumentChecks.ensureBetween;
 
 // Related to JDK7
 import java.nio.channels.FileChannel;
@@ -49,7 +46,7 @@ import java.nio.channels.FileChannel;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.07)
- * @version 0.3
+ * @version 0.5
  * @module
  *
  * @see javax.imageio.stream.FileImageInputStream
@@ -58,48 +55,7 @@ import java.nio.channels.FileChannel;
  */
 public class ChannelImageInputStream extends ChannelDataInput implements ImageInputStream {
     /**
-     * Number of bits needed for storing the bit offset in {@link #bitPosition}.
-     * The following condition must hold:
-     *
-     * {@preformat java
-     *     (1 << BIT_OFFSET_SIZE) == Byte.SIZE
-     * }
-     */
-    private static final int BIT_OFFSET_SIZE = 3;
-
-    /**
-     * The current bit position within the stream. The 3 lowest bits are the bit offset,
-     * and the remaining of the {@code long} value is the stream position where the bit
-     * offset is valid.
-     *
-     * @see #getBitOffset()
-     */
-    private long bitPosition;
-
-    /**
-     * The most recent mark, or {@code null} if none.
-     * This is the tail of a chained list of marks.
-     */
-    private Mark mark;
-
-    /**
-     * A mark pushed by the {@link ChannelImageInputStream#mark()} method
-     * and pooled by the {@link ChannelImageInputStream#reset()} method.
-     */
-    private static final class Mark {
-        final long position;
-        final byte bitOffset;
-        Mark next;
-
-        Mark(long position, byte bitOffset, Mark next) {
-            this.position  = position;
-            this.bitOffset = bitOffset;
-            this.next      = next;
-        }
-    }
-
-    /**
-     * Creates a new input source for the given channel and using the given buffer.
+     * Creates a new input stream for the given channel and using the given buffer.
      *
      * @param  filename A file identifier used only for formatting error message.
      * @param  channel  The channel from where data are read.
@@ -115,7 +71,7 @@ public class ChannelImageInputStream ext
     }
 
     /**
-     * Creates a new input source from the given {@code ChannelDataInput}.
+     * Creates a new input stream from the given {@code ChannelDataInput}.
      * This constructor is invoked when we need to change the implementation class
      * from {@code ChannelDataInput} to {@code ChannelImageInputStream}.
      *
@@ -128,7 +84,9 @@ public class ChannelImageInputStream ext
 
     /**
      * Sets the desired byte order for future reads of data values from this stream.
-     * The default value is {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN}.
+     * The default value is {@link ByteOrder#BIG_ENDIAN}.
+     *
+     * @param byteOrder The new {@linkplain #buffer buffer} byte order.
      */
     @Override
     public final void setByteOrder(final ByteOrder byteOrder) {
@@ -137,6 +95,9 @@ public class ChannelImageInputStream ext
 
     /**
      * Returns the byte order with which data values will be read from this stream.
+     * This is the {@linkplain #buffer buffer} byte order.
+     *
+     * @return The {@linkplain #buffer buffer} byte order.
      */
     @Override
     public final ByteOrder getByteOrder() {
@@ -146,6 +107,7 @@ public class ChannelImageInputStream ext
     /**
      * Returns the length of the stream (in bytes), or -1 if unknown.
      *
+     * @return The length of the stream (in bytes), or -1 if unknown.
      * @throws IOException If an error occurred while fetching the stream length.
      */
     @Override
@@ -157,101 +119,6 @@ public class ChannelImageInputStream ext
     }
 
     /**
-     * Returns the earliest position in the stream to which {@linkplain #seek(long) seeking}
-     * may be performed.
-     *
-     * @return the earliest legal position for seeking.
-     */
-    @Override
-    public final long getFlushedPosition() {
-        return getStreamPosition() - buffer.position();
-    }
-
-    /**
-     * Push back the last processed byte. This is used when a call to {@link #readBit()}
-     * did not used every bits in a byte, or when {@link #readLine()} checked for the
-     * Windows-style of EOL.
-     */
-    private void pushBack() {
-        buffer.position(buffer.position() - 1);
-    }
-
-    /**
-     * Returns the current bit offset, as an integer between 0 and 7 inclusive.
-     *
-     * <p>According {@link ImageInputStream} contract, the bit offset shall be reset to 0 by every call to
-     * any {@code read} method except {@code readBit()} and {@link #readBits(int)}.</p>
-     *
-     * @return The bit offset of the stream.
-     */
-    @Override
-    public final int getBitOffset() {
-        final long currentPosition = getStreamPosition();
-        if ((bitPosition >>> BIT_OFFSET_SIZE) != currentPosition) {
-            bitPosition = currentPosition << BIT_OFFSET_SIZE;
-        }
-        return (int) (bitPosition & (Byte.SIZE - 1));
-    }
-
-    /**
-     * Sets the bit offset to the given value.
-     *
-     * @param bitOffset The new bit offset of the stream.
-     */
-    @Override
-    public final void setBitOffset(final int bitOffset) {
-        ensureBetween("bitOffset", 0, Byte.SIZE - 1, bitOffset);
-        bitPosition = (getStreamPosition() << BIT_OFFSET_SIZE) | bitOffset;
-    }
-
-    /**
-     * Reads a single bit from the stream. The bit to be read depends on the
-     * {@linkplain #getBitOffset() current bit offset}.
-     *
-     * @return The value of the next bit from the stream.
-     * @throws IOException If an error occurred while reading (including EOF).
-     */
-    @Override
-    public final int readBit() throws IOException {
-        return (int) (readBits(1) & 1);
-    }
-
-    /**
-     * Reads many bits from the stream. The first bit to be read depends on the
-     * {@linkplain #getBitOffset() current bit offset}.
-     *
-     * @param  numBits The number of bits to read.
-     * @return The value of the next bits from the stream.
-     * @throws IOException If an error occurred while reading (including EOF).
-     */
-    @Override
-    public final long readBits(int numBits) throws IOException {
-        ensureBetween("numBits", 0, Long.SIZE, numBits);
-        if (numBits == 0) {
-            return 0;
-        }
-        /*
-         * Reads the bits available in the next bytes (all of them if bitOffset == 0)
-         * and compute the number of bits that still need to be read. That number may
-         * be negative if we have read too many bits.
-         */
-        final int bitOffset = getBitOffset();
-        long value = readByte() & (0xFF >>> bitOffset);
-        numBits -= (Byte.SIZE - bitOffset);
-        while (numBits > 0) {
-            value = (value << Byte.SIZE) | readUnsignedByte();
-            numBits -= Byte.SIZE;
-        }
-        if (numBits != 0) {
-            value >>>= (-numBits); // Discard the unwanted bits.
-            numBits += Byte.SIZE;
-            pushBack();
-        }
-        setBitOffset(numBits);
-        return value;
-    }
-
-    /**
      * Reads a byte from the stream and returns a {@code true} if it is nonzero, {@code false} otherwise.
      * The implementation is as below:
      *
@@ -426,31 +293,6 @@ loop:   while ((c = read()) >= 0) {
     }
 
     /**
-     * Pushes the current stream position onto a stack of marked positions.
-     */
-    @Override
-    public final void mark() {
-        mark = new Mark(getStreamPosition(), (byte) getBitOffset(), mark);
-    }
-
-    /**
-     * Resets the current stream byte and bit positions from the stack of marked positions.
-     * An {@code IOException} will be thrown if the previous marked position lies in the
-     * discarded portion of the stream.
-     *
-     * @throws IOException If an I/O error occurs.
-     */
-    @Override
-    public final void reset() throws IOException {
-        if (mark == null) {
-            throw new IOException("No marked position.");
-        }
-        seek(mark.position);
-        setBitOffset(mark.bitOffset);
-        mark = mark.next;
-    }
-
-    /**
      * Discards the initial position of the stream prior to the current stream position.
      * The implementation is as below:
      *
@@ -466,47 +308,6 @@ loop:   while ((c = read()) >= 0) {
     }
 
     /**
-     * Discards the initial portion of the stream prior to the indicated position.
-     * Attempting to {@linkplain #seek(long) seek} to an offset within the flushed
-     * portion of the stream will result in an {@link IndexOutOfBoundsException}.
-     *
-     * <p>This method moves the data starting at the given position to the beginning of the {@link #buffer},
-     * thus making more room for new data before the data at the given position is discarded.</p>
-     *
-     * @param  position The length of the stream prefix that may be flushed.
-     * @throws IOException If an I/O error occurred.
-     */
-    @Override
-    public final void flushBefore(final long position) throws IOException {
-        final long bufferOffset    = getFlushedPosition();
-        final long currentPosition = getStreamPosition();
-        if (position < bufferOffset || position > currentPosition) {
-            throw new IndexOutOfBoundsException(Errors.format(Errors.Keys.ValueOutOfRange_4,
-                    "position", bufferOffset, currentPosition, position));
-        }
-        final int n = (int) (position - bufferOffset);
-        final int p = buffer.position() - n;
-        final int r = buffer.limit() - n;
-        buffer.position(n); // Number of bytes to forget.
-        buffer.compact().position(p).limit(r);
-        setStreamPosition(currentPosition);
-
-        // Discard obolete marks.
-        Mark parent = null;
-        for (Mark m = mark; m != null; m = m.next) {
-            if (m.position < position) {
-                if (parent != null) {
-                    parent.next = null;
-                } else {
-                    mark = null;
-                }
-                break;
-            }
-            parent = m;
-        }
-    }
-
-    /**
      * Synonymous of {@link #isCachedMemory()} since the caching behavior of this class is uniquely determined
      * by the policy that we choose for {@code isCachedMemory()}. This class never creates temporary files.
      *

Copied: sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageOutputStream.java (from r1590476, sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageOutputStream.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageOutputStream.java?p2=sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageOutputStream.java&p1=sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageOutputStream.java&r1=1590476&r2=1590483&rev=1590483&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageOutputStream.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageOutputStream.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -26,7 +26,6 @@ import javax.imageio.stream.ImageOutputS
 import org.apache.sis.util.resources.Errors;
 
 
-
 /**
  * Adds the missing methods in {@code ChannelDataOutput} for implementing the {@code DataOutput} interface.
  * Current implementation does not yet implements the {@code ImageOutputStream} sub-interface, but a future

Modified: sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -88,7 +88,7 @@ public abstract class DataStoreProvider 
      *             // probably not a File, URL, URI, InputStream neither a ReadableChannel.
      *             return ProbeResult.UNSUPPORTED_STORAGE;
      *         }
-     *         if (buffer.remaining() < Integer.SIZE / Byte.SIZE) {
+     *         if (buffer.remaining() < Integer.BYTES) {
      *             // If the buffer does not contain enough bytes for the integer type, this is not
      *             // necessarily because the file is truncated. It may be because the data were not
      *             // yet available at the time this method has been invoked.

Modified: sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/storage/ProbeResult.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -100,7 +100,7 @@ public class ProbeResult implements Seri
      *         if (buffer == null) {
      *             return ProbeResult.UNSUPPORTED_STORAGE;
      *         }
-     *         if (buffer.remaining() < Integer.SIZE / Byte.SIZE) {
+     *         if (buffer.remaining() < Integer.BYTES) {
      *             return ProbeResult.INSUFFICIENT_BYTES;
      *         }
      *         // Other verifications here.

Copied: sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java (from r1590476, sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java?p2=sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java&p1=sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java&r1=1590476&r2=1590483&rev=1590483&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ByteArrayChannel.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -19,9 +19,11 @@ package org.apache.sis.internal.storage;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.channels.ClosedChannelException;
-import java.nio.channels.SeekableByteChannel;
 import org.apache.sis.util.ArgumentChecks;
 
+// Related to JDK7
+import java.nio.channels.ByteChannel;
+
 
 /**
  * A readable and writable channel backed by an array.
@@ -36,7 +38,7 @@ import org.apache.sis.util.ArgumentCheck
  * @see ChannelDataOutputTest
  * @see ChannelImageOutputStream
  */
-final strictfp class ByteArrayChannel implements SeekableByteChannel {
+final strictfp class ByteArrayChannel implements ByteChannel {
     /**
      * Bytes array where to write the data.
      * The length of this array is the capacity.
@@ -97,7 +99,6 @@ final strictfp class ByteArrayChannel im
     /**
      * Returns this channel position.
      */
-    @Override
     public long position() throws IOException {
         ensureOpen();
         return position;
@@ -106,8 +107,7 @@ final strictfp class ByteArrayChannel im
     /**
      * Sets this channel position.
      */
-    @Override
-    public SeekableByteChannel position(final long newPosition) throws IOException {
+    public ByteArrayChannel position(final long newPosition) throws IOException {
         ensureOpen();
         ArgumentChecks.ensureBetween("position", 0, limit, newPosition);
         position = (int) newPosition;
@@ -117,7 +117,6 @@ final strictfp class ByteArrayChannel im
     /**
      * Returns the current size.
      */
-    @Override
     public long size() throws IOException {
         ensureOpen();
         return limit;
@@ -126,8 +125,7 @@ final strictfp class ByteArrayChannel im
     /**
      * Truncates the data to the given size.
      */
-    @Override
-    public SeekableByteChannel truncate(final long size) throws IOException {
+    public ByteArrayChannel truncate(final long size) throws IOException {
         ensureOpen();
         ArgumentChecks.ensureBetween("position", 0, limit, size);
         limit = (int) size;

Modified: sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataInputTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataInputTest.java?rev=1590483&r1=1590482&r2=1590483&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataInputTest.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataInputTest.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -16,14 +16,11 @@
  */
 package org.apache.sis.internal.storage;
 
-import java.util.Random;
 import java.io.DataInput;
 import java.io.DataInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import org.apache.sis.test.TestUtilities;
-import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
@@ -35,28 +32,19 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.07)
- * @version 0.4
+ * @version 0.5
  * @module
  */
-public final strictfp class ChannelDataInputTest extends TestCase {
+public final strictfp class ChannelDataInputTest extends ChannelDataTestCase {
     /**
-     * The maximal size of the arrays to be used for the tests, in bytes.
+     * The implementation to test.
      */
-    private static final int ARRAY_MAX_SIZE = 256;
+    private ChannelDataInput testedStream;
 
     /**
-     * Creates an array filled with random values.
-     *
-     * @param length The length of the array to create.
-     * @param random The random number generator to use.
+     * A stream to use as a reference implementation.
      */
-    static byte[] createRandomArray(final int length, final Random random) {
-        final byte[] array = new byte[length];
-        for (int i=0; i<length; i++) {
-            array[i] = (byte) random.nextInt(256);
-        }
-        return array;
-    }
+    private DataInput referenceStream;
 
     /**
      * Fills a buffer with random data and compare the result with a standard image input stream.
@@ -67,90 +55,80 @@ public final strictfp class ChannelDataI
      */
     @Test
     public void testAllReadMethods() throws IOException {
-        final Random random = TestUtilities.createRandomNumberGenerator();
-        final byte[] array = createRandomArray(ARRAY_MAX_SIZE * 1024, random);
-        compareStreamToBuffer(random, array.length,
-                new DataInputStream(new ByteArrayInputStream(array)),
-                new ChannelDataInput("testAllReadMethods",
-                    new DripByteChannel(array, random, 1, 1024),
-                    ByteBuffer.allocate(random.nextInt(ARRAY_MAX_SIZE / 4) + (Double.SIZE / Byte.SIZE)), false));
+        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.SIZE / Byte.SIZE)), false);
+        transferRandomData(testedStream, array.length - ARRAY_MAX_LENGTH, 16);
     }
 
     /**
-     * Compares the data returned by the given input to the data returned by the given buffer.
-     *
-     * @param  random A random number generator for executing the test.
-     * @param  length Number of bytes in the {@code r} stream.
-     * @param  data   A stream over all expected data.
-     * @param  input  The instance to test.
-     * @throws IOException Should never happen.
-     */
-    private static void compareStreamToBuffer(final Random random, int length,
-            final DataInput data, final ChannelDataInput input) throws IOException
-    {
-        length -= ARRAY_MAX_SIZE; // Margin against buffer underflow.
-        while (input.getStreamPosition() < length) {
-            final int operation = random.nextInt(16);
-            switch (operation) {
-                default: throw new AssertionError(operation);
-                case  0: assertEquals("readByte()",          data.readByte(),              input.readByte());          break;
-                case  1: assertEquals("readShort()",         data.readShort(),             input.readShort());         break;
-                case  2: assertEquals("readUnsignedShort()", data.readUnsignedShort(),     input.readUnsignedShort()); break;
-                case  3: assertEquals("readChar()",          data.readChar(),              input.readChar());          break;
-                case  4: assertEquals("readInt()",           data.readInt(),               input.readInt());           break;
-                case  5: assertEquals("readUnsignedInt()",   data.readInt() & 0xFFFFFFFFL, input.readUnsignedInt());   break;
-                case  6: assertEquals("readLong()",          data.readLong(),              input.readLong());          break;
-                case  7: assertEquals("readFloat()",         data.readFloat(),             input.readFloat(),  0f);    break;
-                case  8: assertEquals("readDouble()",        data.readDouble(),            input.readDouble(), 0d);    break;
-                case  9: {
-                    final int n = random.nextInt(ARRAY_MAX_SIZE);
-                    final byte[] tmp = new byte[n];
-                    data.readFully(tmp);
-                    assertArrayEquals("readBytes(int)", tmp, input.readBytes(n));
-                    break;
-                }
-                case 10: {
-                    final int n = random.nextInt(ARRAY_MAX_SIZE / (Character.SIZE / Byte.SIZE));
-                    final char[] tmp = new char[n];
-                    for (int i=0; i<n; i++) tmp[i] = data.readChar();
-                    assertArrayEquals("readChars(int)", tmp, input.readChars(n));
-                    break;
-                }
-                case 11: {
-                    final int n = random.nextInt(ARRAY_MAX_SIZE / (Short.SIZE / Byte.SIZE));
-                    final short[] tmp = new short[n];
-                    for (int i=0; i<n; i++) tmp[i] = data.readShort();
-                    assertArrayEquals("readShorts(int)", tmp, input.readShorts(n));
-                    break;
-                }
-                case 12: {
-                    final int n = random.nextInt(ARRAY_MAX_SIZE / (Integer.SIZE / Byte.SIZE));
-                    final int[] tmp = new int[n];
-                    for (int i=0; i<n; i++) tmp[i] = data.readInt();
-                    assertArrayEquals("readInts(int)", tmp, input.readInts(n));
-                    break;
-                }
-                case 13: {
-                    final int n = random.nextInt(ARRAY_MAX_SIZE / (Long.SIZE / Byte.SIZE));
-                    final long[] tmp = new long[n];
-                    for (int i=0; i<n; i++) tmp[i] = data.readLong();
-                    assertArrayEquals("readLongs(int)", tmp, input.readLongs(n));
-                    break;
-                }
-                case 14: {
-                    final int n = random.nextInt(ARRAY_MAX_SIZE / (Float.SIZE / Byte.SIZE));
-                    final float[] tmp = new float[n];
-                    for (int i=0; i<n; i++) tmp[i] = data.readFloat();
-                    assertArrayEquals("readFloats(int)", tmp, input.readFloats(n), 0);
-                    break;
-                }
-                case 15: {
-                    final int n = random.nextInt(ARRAY_MAX_SIZE / (Double.SIZE / Byte.SIZE));
-                    final double[] tmp = new double[n];
-                    for (int i=0; i<n; i++) tmp[i] = data.readDouble();
-                    assertArrayEquals("readDoubles(int)", tmp, input.readDoubles(n), 0);
-                    break;
-                }
+     * Reads a random unit of data using a method selected randomly.
+     * This method is invoked (indirectly) by {@link #testAllReadMethods()}.
+     */
+    @Override
+    final void transferRandomData(final int operation) throws IOException {
+        final ChannelDataInput t = testedStream;
+        final DataInput r = referenceStream;
+        switch (operation) {
+            default: throw new AssertionError(operation);
+            case  0: assertEquals("readByte()",          r.readByte(),              t.readByte());          break;
+            case  1: assertEquals("readShort()",         r.readShort(),             t.readShort());         break;
+            case  2: assertEquals("readUnsignedShort()", r.readUnsignedShort(),     t.readUnsignedShort()); break;
+            case  3: assertEquals("readChar()",          r.readChar(),              t.readChar());          break;
+            case  4: assertEquals("readInt()",           r.readInt(),               t.readInt());           break;
+            case  5: assertEquals("readUnsignedInt()",   r.readInt() & 0xFFFFFFFFL, t.readUnsignedInt());   break;
+            case  6: assertEquals("readLong()",          r.readLong(),              t.readLong());          break;
+            case  7: assertEquals("readFloat()",         r.readFloat(),             t.readFloat(),  0f);    break;
+            case  8: assertEquals("readDouble()",        r.readDouble(),            t.readDouble(), 0d);    break;
+            case  9: {
+                final int n = random.nextInt(ARRAY_MAX_LENGTH);
+                final byte[] tmp = new byte[n];
+                r.readFully(tmp);
+                assertArrayEquals("readBytes(int)", tmp, t.readBytes(n));
+                break;
+            }
+            case 10: {
+                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.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.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.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.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.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);
+                break;
             }
         }
     }
@@ -162,7 +140,6 @@ public final strictfp class ChannelDataI
      */
     @Test
     public void testReadString() throws IOException {
-        final Random random   = TestUtilities.createRandomNumberGenerator();
         final String expected = "お元気ですか";
         final byte[] array    = expected.getBytes("UTF-8");
         assertEquals(expected.length()*3, array.length); // Sanity check.
@@ -181,9 +158,8 @@ public final strictfp class ChannelDataI
      */
     @Test
     public void testSeekOnForwardOnlyChannel() throws IOException {
-        final Random random = TestUtilities.createRandomNumberGenerator();
         int length = random.nextInt(2048) + 1024;
-        final byte[] array = createRandomArray(length, random);
+        final byte[] array = createRandomArray(length);
         length -= (Long.SIZE / Byte.SIZE); // Safety against buffer underflow.
         final ByteBuffer buffer = ByteBuffer.wrap(array);
         final ChannelDataInput input = new ChannelDataInput("testSeekOnForwardOnlyChannel",
@@ -205,9 +181,8 @@ public final strictfp class ChannelDataI
      */
     @Test
     public void testPrefetch() throws IOException {
-        final Random     random = TestUtilities.createRandomNumberGenerator();
         final int        length = random.nextInt(256) + 128;
-        final byte[]     array  = createRandomArray(length, random);
+        final byte[]     array  = createRandomArray(length);
         final ByteBuffer buffer = ByteBuffer.allocate(random.nextInt(64) + 16);
         final ChannelDataInput input = new ChannelDataInput("testPrefetch",
                 new DripByteChannel(array, random, 1, 64), buffer, false);

Copied: sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java (from r1590476, sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java?p2=sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java&p1=sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java&r1=1590476&r2=1590483&rev=1590483&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataOutputTest.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -125,6 +125,14 @@ public strictfp class ChannelDataOutputT
         final ByteBuffer arrayView = ByteBuffer.wrap(expectedArray);
         for (int i=0; i<100; i++) {
             final int position = random.nextInt(seekRange);
+
+            // JDK6 specific: can not seek to arbitrary position because
+            // Java 6 does not provide the SeekableByteChannel interface.
+            if (position < testedStream.getFlushedPosition()) {
+                continue;
+            }
+            // End of JDK6 specific.
+
             testedStream.seek(position);
             assertEquals("getStreamPosition()", position, testedStream.getStreamPosition());
             final long v = random.nextLong();
@@ -152,13 +160,6 @@ public strictfp class ChannelDataOutputT
             assertTrue(message, message.contains("bitOffset"));
         }
         try {
-            testedStream.seek(1);
-            fail("Shall not seek further than stream length.");
-        } catch (IllegalArgumentException e) {
-            final String message = e.getMessage();
-            assertTrue(message, message.contains("position"));
-        }
-        try {
             testedStream.reset();
             fail("Shall not accept reset without mark.");
         } catch (InvalidMarkException e) {

Copied: sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java (from r1590476, sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java?p2=sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java&p1=sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java&r1=1590476&r2=1590483&rev=1590483&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/ChannelDataTestCase.java [UTF-8] Sun Apr 27 20:19:51 2014
@@ -108,7 +108,7 @@ abstract strictfp class ChannelDataTestC
                 operation = random.nextInt(numOperations);
                 transferRandomData(operation);
             }
-        } catch (AssertionError | RuntimeException e) {
+        } catch (AssertionError e) {
             out.println("Iter. count: " + count);
             out.println("Position:    " + position);
             out.println("Bit offset:  " + bitOffset);