sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1776236 [2/2] - in /sis/trunk: ./ core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/ core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco...
Date Wed, 28 Dec 2016 07:26:36 GMT
Modified: sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -62,9 +62,27 @@ public class NetcdfStore extends DataSto
      *
      * @param  connector information about the storage (URL, stream, {@link ucar.nc2.NetcdfFile} instance, <i>etc</i>).
      * @throws DataStoreException if an error occurred while opening the NetCDF file.
+     *
+     * @deprecated Replaced by {@link #NetcdfStore(NetcdfStoreProvider, StorageConnector)}.
      */
+    @Deprecated
     public NetcdfStore(final StorageConnector connector) throws DataStoreException {
-        super(connector);
+        this(null, connector);
+    }
+
+    /**
+     * Creates a new NetCDF store from the given file, URL, stream or {@link ucar.nc2.NetcdfFile} object.
+     * This constructor invokes {@link StorageConnector#closeAllExcept(Object)}, keeping open only the
+     * needed resource.
+     *
+     * @param  provider   the factory that created this {@code DataStore} instance, or {@code null} if unspecified.
+     * @param  connector  information about the storage (URL, stream, {@link ucar.nc2.NetcdfFile} instance, <i>etc</i>).
+     * @throws DataStoreException if an error occurred while opening the NetCDF file.
+     *
+     * @since 0.8
+     */
+    public NetcdfStore(final NetcdfStoreProvider provider, final StorageConnector connector) throws DataStoreException {
+        super(provider, connector);
         try {
             decoder = NetcdfStoreProvider.decoder(listeners, connector);
         } catch (IOException e) {

Modified: sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -207,7 +207,7 @@ public class NetcdfStoreProvider extends
      */
     @Override
     public DataStore open(final StorageConnector connector) throws DataStoreException {
-        return new NetcdfStore(connector);
+        return new NetcdfStore(this, connector);
     }
 
     /**

Modified: sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreTest.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreTest.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -46,7 +46,7 @@ public final strictfp class NetcdfStoreT
      * @throws DataStoreException if an error occurred while reading the NetCDF file.
      */
     private static NetcdfStore create(final String dataset) throws DataStoreException {
-        return new NetcdfStore(new StorageConnector(IOTestCase.getResource(dataset)));
+        return new NetcdfStore(null, new StorageConnector(IOTestCase.getResource(dataset)));
     }
 
     /**

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -20,14 +20,12 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.InvalidMarkException;
 import java.nio.channels.Channel;
+import java.nio.channels.SeekableByteChannel;
 import org.apache.sis.util.Debug;
 import org.apache.sis.util.resources.Errors;
 
 import static org.apache.sis.util.ArgumentChecks.ensureBetween;
 
-// Branch-dependent imports
-import java.nio.channels.SeekableByteChannel;
-
 
 /**
  * Properties common to {@link ChannelDataInput} and {@link ChannelDataOutput}.
@@ -39,7 +37,7 @@ import java.nio.channels.SeekableByteCha
  * @version 0.5
  * @module
  */
-public abstract class ChannelData {
+public abstract class ChannelData implements Markable {
     /**
      * Number of bits needed for storing the bit offset in {@link #bitPosition}.
      * The following condition must hold:
@@ -113,10 +111,10 @@ public abstract class ChannelData {
      * Creates a new instance for the given channel and using the given buffer.
      * The channel is not stored by this class - it shall be stored by the subclass.
      *
-     * @param  filename A file identifier used only for formatting error message.
-     * @param  channel  The channel from where data are read or where to wrote.
-     * @param  buffer   The buffer where to store the data.
-     * @throws IOException If an error occurred while reading the channel.
+     * @param  filename  a file identifier used only for formatting error message.
+     * @param  channel   the channel from where data are read or where to wrote.
+     * @param  buffer    the buffer where to store the data.
+     * @throws IOException if an error occurred while reading the channel.
      */
     ChannelData(final String filename, final Channel channel, final ByteBuffer buffer) throws IOException {
         this.filename      = filename;
@@ -131,7 +129,7 @@ public abstract class ChannelData {
      * by every call to any {@code read} or {@code write} method except {@code readBit()}, {@code readBits(int)},
      * {@code writeBit(int)} and {@code writeBits(long, int)}.</p>
      *
-     * @return The bit offset of the stream.
+     * @return the bit offset of the stream.
      */
     public final int getBitOffset() {
         final long position = bufferOffset + buffer.position();
@@ -144,7 +142,7 @@ public abstract class ChannelData {
     /**
      * Sets the bit offset to the given value.
      *
-     * @param bitOffset The new bit offset of the stream.
+     * @param  bitOffset  the new bit offset of the stream.
      */
     public final void setBitOffset(final int bitOffset) {
         ensureBetween("bitOffset", 0, Byte.SIZE - 1, bitOffset);
@@ -162,8 +160,9 @@ public abstract class ChannelData {
     /**
      * Returns the current byte position of the stream.
      *
-     * @return The position of the stream.
+     * @return the position of the stream.
      */
+    @Override
     public long getStreamPosition() {
         return bufferOffset + buffer.position();
     }
@@ -182,7 +181,7 @@ public abstract class ChannelData {
      *       has changed.</li>
      * </ul>
      *
-     * @param position The new position of the stream.
+     * @param position the new position of the stream.
      */
     public final void setStreamPosition(final long position) {
         bufferOffset = position - buffer.position();
@@ -193,8 +192,7 @@ public abstract class ChannelData {
     }
 
     /**
-     * Returns the earliest position in the stream to which {@linkplain #seek(long) seeking}
-     * may be performed.
+     * Returns the earliest position in the stream to which {@linkplain #seek(long) seeking} may be performed.
      *
      * @return the earliest legal position for seeking.
      */
@@ -210,8 +208,8 @@ public abstract class ChannelData {
      * <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.
+     * @param  position  the length of the stream prefix that may be flushed.
+     * @throws IOException if an I/O error occurred.
      */
     public final void flushBefore(final long position) throws IOException {
         final long currentPosition = getStreamPosition();
@@ -254,8 +252,8 @@ public abstract class ChannelData {
     /**
      * Moves to the given position in the stream, relative to the stream position at construction time.
      *
-     * @param  position The position where to move.
-     * @throws IOException If the stream can not be moved to the given position.
+     * @param  position  the position where to move.
+     * @throws IOException if the stream can not be moved to the given position.
      */
     public abstract void seek(final long position) throws IOException;
 
@@ -264,6 +262,7 @@ public abstract class ChannelData {
      * Note that {@code ChannelData} maintains its own marks - the buffer's
      * mark is left unchanged.
      */
+    @Override
     public final void mark() {
         mark = new Mark(getStreamPosition(), (byte) getBitOffset(), mark);
     }
@@ -281,8 +280,9 @@ public abstract class ChannelData {
      *       doing nothing. Doing nothing is considered a too high risk of error.</li>
      * </ul>
      *
-     * @throws IOException If an I/O error occurs.
+     * @throws IOException if an I/O error occurs.
      */
+    @Override
     public final void reset() throws IOException {
         final Mark m = mark;
         if (m == null) {
@@ -303,7 +303,7 @@ public abstract class ChannelData {
      * 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 process.
+     * @throws IOException if the implementation chooses to stop the process.
      */
     protected void onEmptyTransfer() throws IOException {
         try {
@@ -322,7 +322,7 @@ public abstract class ChannelData {
     /**
      * Returns a string representation of this object for debugging purpose.
      *
-     * @return A string representation of this object.
+     * @return a string representation of this object.
      */
     @Debug
     @Override

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -27,14 +27,12 @@ import java.nio.LongBuffer;
 import java.nio.FloatBuffer;
 import java.nio.DoubleBuffer;
 import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.SeekableByteChannel;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.Debug;
 
 import static org.apache.sis.util.ArgumentChecks.ensureBetween;
 
-// Branch-dependent imports
-import java.nio.channels.SeekableByteChannel;
-
 
 /**
  * Provides convenience methods for working with a ({@link ReadableByteChannel}, {@link ByteBuffer}) pair.

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -27,13 +27,11 @@ import java.nio.FloatBuffer;
 import java.nio.IntBuffer;
 import java.nio.LongBuffer;
 import java.nio.ShortBuffer;
+import java.nio.channels.SeekableByteChannel;
 import java.nio.channels.WritableByteChannel;
 
 import static org.apache.sis.util.ArgumentChecks.ensureBetween;
 
-// Branch-dependent imports
-import java.nio.channels.SeekableByteChannel;
-
 
 /**
  * Provides convenience methods for working with a ({@link WritableByteChannel}, {@link ByteBuffer}) pair.
@@ -74,10 +72,10 @@ public class ChannelDataOutput extends C
     /**
      * Creates a new data output for the given channel and using the given buffer.
      *
-     * @param  filename A file identifier used only for formatting error message.
-     * @param  channel  The channel where data are written.
-     * @param  buffer   The buffer where to put the data.
-     * @throws IOException If an error occurred while creating the data output.
+     * @param  filename  a file identifier used only for formatting error message.
+     * @param  channel   the channel where data are written.
+     * @param  buffer    the buffer where to put the data.
+     * @throws IOException if an error occurred while creating the data output.
      */
     public ChannelDataOutput(final String filename, final WritableByteChannel channel, final ByteBuffer buffer)
             throws IOException
@@ -95,8 +93,8 @@ public class ChannelDataOutput extends C
      * <p>After this method call, the buffer {@linkplain ByteBuffer#limit() limit}
      * will be equal or greater than {@code position + n}.</p>
      *
-     * @param  n The minimal number of additional bytes that the {@linkplain #buffer buffer} shall accept.
-     * @throws IOException If an error occurred while writing to the channel.
+     * @param  n  the minimal number of additional bytes that the {@linkplain #buffer buffer} shall accept.
+     * @throws IOException if an error occurred while writing to the channel.
      */
     private void ensureBufferAccepts(final int n) throws IOException {
         final int capacity = buffer.capacity();
@@ -132,7 +130,7 @@ public class ChannelDataOutput extends C
     /**
      * Returns the current byte position of the stream.
      *
-     * @return The position of the stream.
+     * @return the position of the stream.
      */
     @Override
     public long getStreamPosition() {
@@ -152,8 +150,8 @@ public class ChannelDataOutput extends C
      * Writes a single bit. This method uses only the rightmost bit of the given argument;
      * the upper 31 bits are ignored.
      *
-     * @param bit The bit to write (rightmost bit).
-     * @throws IOException If an error occurred while creating the data output.
+     * @param  bit  the bit to write (rightmost bit).
+     * @throws IOException if an error occurred while creating the data output.
      */
     public final void writeBit(final int bit) throws IOException {
         writeBits(bit, 1);
@@ -163,9 +161,9 @@ public class ChannelDataOutput extends C
      * Writes a sequence of bits. This method uses only the <code>numBits</code> rightmost bits;
      * other bits are ignored.
      *
-     * @param  bits The bits to write (rightmost bits).
-     * @param  numBits The number of bits to write.
-     * @throws IOException If an error occurred while creating the data output.
+     * @param  bits     the bits to write (rightmost bits).
+     * @param  numBits  the number of bits to write.
+     * @throws IOException if an error occurred while creating the data output.
      */
     public final void writeBits(long bits, int numBits) throws IOException {
         ensureBetween("numBits", 0, Long.SIZE, numBits);
@@ -216,12 +214,12 @@ public class ChannelDataOutput extends C
      * This method ensures that there is space for at least 1 byte in the buffer,
      * (writing previous bytes into the channel if necessary), then delegates to {@link ByteBuffer#put(byte)}.
      *
-     * @param  v byte to be written.
+     * @param  value  byte to be written.
      * @throws IOException if some I/O exception occurs during writing.
      */
-    public final void writeByte(final int v) throws IOException {
+    public final void writeByte(final int value) throws IOException {
         ensureBufferAccepts(Byte.SIZE / Byte.SIZE);
-        buffer.put((byte) v);
+        buffer.put((byte) value);
     }
 
     /**
@@ -230,12 +228,12 @@ public class ChannelDataOutput extends C
      * This method ensures that there is space for at least 2 bytes in the buffer,
      * (writing previous bytes into the channel if necessary), then delegates to {@link ByteBuffer#put(short)}.
      *
-     * @param  v short to be written.
+     * @param  value  short integer to be written.
      * @throws IOException if some I/O exception occurs during writing.
      */
-    public final void writeShort(final int v) throws IOException {
+    public final void writeShort(final int value) throws IOException {
         ensureBufferAccepts(Short.SIZE / Byte.SIZE);
-        buffer.putShort((short) v);
+        buffer.putShort((short) value);
     }
 
     /**
@@ -243,12 +241,12 @@ public class ChannelDataOutput extends C
      * This method ensures that there is space for at least 2 bytes in the buffer,
      * (writing previous bytes into the channel if necessary), then delegates to {@link ByteBuffer#put(char)}.
      *
-     * @param  v char to be written.
+     * @param  value  character to be written.
      * @throws IOException if some I/O exception occurs during writing.
      */
-    public final void writeChar(final int v) throws IOException {
+    public final void writeChar(final int value) throws IOException {
         ensureBufferAccepts(Character.SIZE / Byte.SIZE);
-        buffer.putChar((char) v);
+        buffer.putChar((char) value);
     }
 
     /**
@@ -256,12 +254,12 @@ public class ChannelDataOutput extends C
      * This method ensures that there is space for at least 4 bytes in the buffer,
      * (writing previous bytes into the channel if necessary), then delegates to {@link ByteBuffer#put(int)}.
      *
-     * @param  v Integer to be written.
+     * @param  value  integer to be written.
      * @throws IOException if some I/O exception occurs during writing.
      */
-    public final void writeInt(final int v) throws IOException {
+    public final void writeInt(final int value) throws IOException {
         ensureBufferAccepts(Integer.SIZE / Byte.SIZE);
-        buffer.putInt(v);
+        buffer.putInt(value);
     }
 
     /**
@@ -269,12 +267,12 @@ public class ChannelDataOutput extends C
      * This method ensures that there is space for at least 4 bytes in the buffer,
      * (writing previous bytes into the channel if necessary), then delegates to {@link ByteBuffer#put(long)}.
      *
-     * @param  v Long to be written.
+     * @param  value  long integer to be written.
      * @throws IOException if some I/O exception occurs during writing.
      */
-    public final void writeLong(final long v) throws IOException {
+    public final void writeLong(final long value) throws IOException {
         ensureBufferAccepts(Long.SIZE / Byte.SIZE);
-        buffer.putLong(v);
+        buffer.putLong(value);
     }
 
     /**
@@ -282,12 +280,12 @@ public class ChannelDataOutput extends C
      * This method ensures that there is space for at least 4 bytes in the buffer,
      * (writing previous bytes into the channel if necessary), then delegates to {@link ByteBuffer#put(float)}.
      *
-     * @param  v Float to be written.
+     * @param  value floating point value to be written.
      * @throws IOException if some I/O exception occurs during writing.
      */
-    public final void writeFloat(final float v) throws IOException {
+    public final void writeFloat(final float value) throws IOException {
         ensureBufferAccepts(Float.SIZE / Byte.SIZE);
-        buffer.putFloat(v);
+        buffer.putFloat(value);
     }
 
     /**
@@ -295,12 +293,12 @@ public class ChannelDataOutput extends C
      * This method ensures that there is space for at least 8 bytes in the buffer,
      * (writing previous bytes into the channel if necessary), then delegates to {@link ByteBuffer#put(double)}.
      *
-     * @param  v Double to be written.
+     * @param  value  double precision floating point value to be written.
      * @throws IOException if some I/O exception occurs during writing.
      */
-    public final void writeDouble(final double v) throws IOException {
+    public final void writeDouble(final double value) throws IOException {
         ensureBufferAccepts(Double.SIZE / Byte.SIZE);
-        buffer.putDouble(v);
+        buffer.putDouble(value);
     }
 
     /**
@@ -311,8 +309,8 @@ public class ChannelDataOutput extends C
      *     return write(src, 0, src.length);
      * }
      *
-     * @param  src An array of bytes to be written into stream.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src  an array of bytes to be written into stream.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void write(final byte[] src) throws IOException {
         write(src, 0, src.length);
@@ -326,8 +324,8 @@ public class ChannelDataOutput extends C
      *     return writeShorts(src, 0, src.length);
      * }
      *
-     * @param  src An array of shorts to be written into stream.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src  an array of shorts to be written into stream.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void writeShorts(final short[] src) throws IOException {
         writeShorts(src, 0, src.length);
@@ -341,8 +339,8 @@ public class ChannelDataOutput extends C
      *     return writeChars(src, 0, src.length);
      * }
      *
-     * @param  src An array of characters to be written into stream.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src  an array of characters to be written into stream.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void writeChars(final char[] src) throws IOException {
         writeChars(src, 0, src.length);
@@ -356,8 +354,8 @@ public class ChannelDataOutput extends C
      *     return writeInts(src, 0, src.length);
      * }
      *
-     * @param  src An array of integers to be written into stream.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src  an array of integers to be written into stream.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void writeInts(final int[] src) throws IOException {
         writeInts(src, 0, src.length);
@@ -371,8 +369,8 @@ public class ChannelDataOutput extends C
      *     return writeLongs(src, 0, src.length);
      * }
      *
-     * @param  src An array of longs to be written into stream.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src  an array of longs to be written into stream.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void writeLongs(final long[] src) throws IOException {
         writeLongs(src, 0, src.length);
@@ -386,8 +384,8 @@ public class ChannelDataOutput extends C
      *     return writeFloats(src, 0, src.length);
      * }
      *
-     * @param  src An array of floats to be written into stream.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src  an array of floats to be written into stream.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void writeFloats(final float[] src) throws IOException {
         writeFloats(src, 0, src.length);
@@ -401,8 +399,8 @@ public class ChannelDataOutput extends C
      *     return writeDoubles(src, 0, src.length);
      * }
      *
-     * @param  src An array of doubles to be written into stream.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src  an array of doubles to be written into stream.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void writeDoubles(final double[] src) throws IOException {
         writeDoubles(src, 0, src.length);
@@ -411,10 +409,10 @@ public class ChannelDataOutput extends C
     /**
      * Writes {@code length} bytes starting at index {@code offset} from the given array.
      *
-     * @param  src    An array containing the bytes to write.
-     * @param  offset Index within {@code src} of the first byte to write.
-     * @param  length The number of bytes to write.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src     an array containing the bytes to write.
+     * @param  offset  index within {@code src} of the first byte to write.
+     * @param  length  the number of bytes to write.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void write(final byte[] src, int offset, int length) throws IOException {
         if (length != 0) {
@@ -455,7 +453,7 @@ public class ChannelDataOutput extends C
          * Skips the given amount of bytes in the buffer. It is caller responsibility to ensure
          * that there is enough bytes remaining in the buffer.
          *
-         * @param nByte byte shift of buffer position.
+         * @param  nByte  byte shift of buffer position.
          */
         private void skipInBuffer(int nByte) {
             buffer.position(buffer.position() + nByte);
@@ -464,10 +462,10 @@ public class ChannelDataOutput extends C
         /**
          * Writes {@code length} characters from the array to the stream.
          *
-         * @param  dataSize The size of the Java primitive type which is the element of the array.
-         * @param  offset   The starting position within {@code src} to write.
-         * @param  length   The number of characters to write.
-         * @throws IOException If an error occurred while writing the stream.
+         * @param  dataSize  the size of the Java primitive type which is the element of the array.
+         * @param  offset    the starting position within {@code src} to write.
+         * @param  length    the number of characters to write.
+         * @throws IOException if an error occurred while writing the stream.
          */
         final void writeFully(final int dataSize, int offset, int length) throws IOException {
             clearBitOffset(); // Actually needed only if length == 0.
@@ -489,10 +487,10 @@ public class ChannelDataOutput extends C
     /**
      * Writes {@code length} chars starting at index {@code offset} from the given array.
      *
-     * @param  src    An array containing the characters to write.
-     * @param  offset Index within {@code src} of the first char to write.
-     * @param  length The number of chars to write.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src     an array containing the characters to write.
+     * @param  offset  index within {@code src} of the first char to write.
+     * @param  length  the number of chars to write.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void writeChars(final char[] src, int offset, int length) throws IOException {
         new ArrayWriter() {
@@ -505,10 +503,10 @@ public class ChannelDataOutput extends C
     /**
      * Writes {@code length} shorts starting at index {@code offset} from the given array.
      *
-     * @param  src    An array containing the shorts to write.
-     * @param  offset Index within {@code src} of the first short to write.
-     * @param  length The number of shorts to write.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src     an array containing the shorts to write.
+     * @param  offset  index within {@code src} of the first short to write.
+     * @param  length  the number of shorts to write.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void writeShorts(final short[] src, int offset, int length) throws IOException {
         new ArrayWriter() {
@@ -521,10 +519,10 @@ public class ChannelDataOutput extends C
     /**
      * Writes {@code length} integers starting at index {@code offset} from the given array.
      *
-     * @param  src    An array containing the integers to write.
-     * @param  offset Index within {@code src} of the first integer to write.
-     * @param  length The number of integers to write.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src     an array containing the integers to write.
+     * @param  offset  index within {@code src} of the first integer to write.
+     * @param  length  the number of integers to write.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void writeInts(final int[] src, int offset, int length) throws IOException {
         new ArrayWriter() {
@@ -537,10 +535,10 @@ public class ChannelDataOutput extends C
     /**
      * Writes {@code length} longs starting at index {@code offset} from the given array.
      *
-     * @param  src    An array containing the longs to write.
-     * @param  offset Index within {@code src} of the first long to write.
-     * @param  length The number of longs to write.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src     an array containing the longs to write.
+     * @param  offset  index within {@code src} of the first long to write.
+     * @param  length  the number of longs to write.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void writeLongs(final long[] src, int offset, int length) throws IOException {
         new ArrayWriter() {
@@ -553,10 +551,10 @@ public class ChannelDataOutput extends C
     /**
      * Writes {@code length} floats starting at index {@code offset} from the given array.
      *
-     * @param  src    An array containing the floats to write.
-     * @param  offset Index within {@code src} of the first float to write.
-     * @param  length The number of floats to write.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src     an array containing the floats to write.
+     * @param  offset  index within {@code src} of the first float to write.
+     * @param  length  the number of floats to write.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void writeFloats(final float[] src, int offset, int length) throws IOException {
         new ArrayWriter() {
@@ -569,10 +567,10 @@ public class ChannelDataOutput extends C
     /**
      * Writes {@code length} doubles starting at index {@code offset} from the given array.
      *
-     * @param  src    An array containing the doubles to write.
-     * @param  offset Index within {@code src} of the first double to write.
-     * @param  length The number of doubles to write.
-     * @throws IOException If an error occurred while writing the stream.
+     * @param  src     an array containing the doubles to write.
+     * @param  offset  index within {@code src} of the first double to write.
+     * @param  length  the number of doubles to write.
+     * @throws IOException if an error occurred while writing the stream.
      */
     public final void writeDoubles(final double[] src, int offset, int length) throws IOException {
         new ArrayWriter() {
@@ -603,8 +601,8 @@ public class ChannelDataOutput extends C
      * If the given position is greater than the stream length, then the values of bytes between the
      * previous stream length and the given position are unspecified. The limit is unchanged.
      *
-     * @param  position The position where to move.
-     * @throws IOException If the stream can not be moved to the given position.
+     * @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 {
@@ -657,7 +655,7 @@ public class ChannelDataOutput extends C
      * Flushes the {@link #buffer buffer} content to the channel.
      * This method does <strong>not</strong> flush the channel itself.
      *
-     * @throws IOException If an error occurred while writing to the channel.
+     * @throws IOException if an error occurred while writing to the channel.
      */
     @Override
     public final void flush() throws IOException {
@@ -684,7 +682,7 @@ public class ChannelDataOutput extends C
      * Writes fully the buffer content from its position to its limit.
      * After this method call, the buffer position is equals to its limit.
      *
-     * @throws IOException If an error occurred while writing to the channel.
+     * @throws IOException if an error occurred while writing to the channel.
      */
     private void writeFully() throws IOException {
         int n = buffer.remaining();

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -21,12 +21,10 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.SeekableByteChannel;
 import javax.imageio.stream.IIOByteBuffer;
 import javax.imageio.stream.ImageInputStream;
 
-// Branch-dependent imports
-import java.nio.channels.SeekableByteChannel;
-
 
 /**
  * Adds the missing methods in {@code ChannelDataInput} for implementing the {@code ImageInputStream} interface.
@@ -57,12 +55,12 @@ public class ChannelImageInputStream ext
     /**
      * 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.
-     * @param  buffer   The buffer where to copy the data.
-     * @param  filled   {@code true} if the buffer already contains data, or {@code false} if it needs
-     *                  to be initially filled with some content read from the channel.
-     * @throws IOException If an error occurred while reading the channel.
+     * @param  filename  a file identifier used only for formatting error message.
+     * @param  channel   the channel from where data are read.
+     * @param  buffer    the buffer where to copy the data.
+     * @param  filled    {@code true} if the buffer already contains data, or {@code false} if it needs
+     *                   to be initially filled with some content read from the channel.
+     * @throws IOException if an error occurred while reading the channel.
      */
     public ChannelImageInputStream(final String filename, final ReadableByteChannel channel,
             final ByteBuffer buffer, final boolean filled) throws IOException
@@ -75,8 +73,8 @@ public class ChannelImageInputStream ext
      * This constructor is invoked when we need to change the implementation class
      * from {@code ChannelDataInput} to {@code ChannelImageInputStream}.
      *
-     * @param  input The existing instance from which to takes the channel and buffer.
-     * @throws IOException If an error occurred while reading the channel.
+     * @param  input  the existing instance from which to takes the channel and buffer.
+     * @throws IOException if an error occurred while reading the channel.
      */
     public ChannelImageInputStream(final ChannelDataInput input) throws IOException {
         super(input.filename, input.channel, input.buffer, true);
@@ -86,7 +84,7 @@ 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}.
      *
-     * @param byteOrder The new {@linkplain #buffer buffer} byte order.
+     * @param  byteOrder  the new {@linkplain #buffer buffer} byte order.
      */
     @Override
     public final void setByteOrder(final ByteOrder byteOrder) {
@@ -97,7 +95,7 @@ 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.
+     * @return the {@linkplain #buffer buffer} byte order.
      */
     @Override
     public final ByteOrder getByteOrder() {
@@ -107,8 +105,8 @@ 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.
+     * @return the length of the stream (in bytes), or -1 if unknown.
+     * @throws IOException if an error occurred while fetching the stream length.
      */
     @Override
     public final long length() throws IOException {
@@ -126,8 +124,8 @@ public class ChannelImageInputStream ext
      *     return readByte() != 0;
      * }
      *
-     * @return The value of the next boolean from the stream.
-     * @throws IOException If an error (including EOF) occurred while reading the stream.
+     * @return the value of the next boolean from the stream.
+     * @throws IOException if an error (including EOF) occurred while reading the stream.
      */
     @Override
     public final boolean readBoolean() throws IOException {
@@ -137,8 +135,8 @@ public class ChannelImageInputStream ext
     /**
      * Reads in a string that has been encoded using a UTF-8 string.
      *
-     * @return The string reads from the stream.
-     * @throws IOException If an error (including EOF) occurred while reading the stream.
+     * @return the string reads from the stream.
+     * @throws IOException if an error (including EOF) occurred while reading the stream.
      */
     @Override
     public final String readUTF() throws IOException {
@@ -156,8 +154,8 @@ public class ChannelImageInputStream ext
      * This method is provided for compliance with the {@link java.io.DataInput} interface,
      * but is generally not recommended.
      *
-     * @return The next line, or {@code null} if the EOF has been reached.
-     * @throws IOException If an error occurred while reading.
+     * @return the next line, or {@code null} if the EOF has been reached.
+     * @throws IOException if an error occurred while reading.
      */
     @Override
     public final String readLine() throws IOException {
@@ -189,8 +187,8 @@ loop:   while ((c = read()) >= 0) {
      * Returns the next byte from the stream as an unsigned integer between 0 and 255,
      * or -1 if we reached the end of stream.
      *
-     * @return The next byte as an unsigned integer, or -1 on end of stream.
-     * @throws IOException If an error occurred while reading the stream.
+     * @return the next byte as an unsigned integer, or -1 on end of stream.
+     * @throws IOException if an error occurred while reading the stream.
      */
     @Override
     public final int read() throws IOException {
@@ -205,9 +203,9 @@ loop:   while ((c = read()) >= 0) {
      *     return read(dest, 0, dest.length);
      * }
      *
-     * @param  dest An array of bytes to be written to.
-     * @return The number of bytes actually read, or -1 on EOF.
-     * @throws IOException If an error occurred while reading.
+     * @param  dest  an array of bytes to be written to.
+     * @return the number of bytes actually read, or -1 on EOF.
+     * @throws IOException if an error occurred while reading.
      */
     @Override
     public final int read(final byte[] dest) throws IOException {
@@ -219,11 +217,11 @@ loop:   while ((c = read()) >= 0) {
      * starting at index {@code offset}. If no bytes can be read because the end of the stream
      * has been reached, -1 is returned.
      *
-     * @param  dest   An array of bytes to be written to.
-     * @param  offset The starting position within {@code dest} to write.
-     * @param  length The maximum number of bytes to read.
-     * @return The number of bytes actually read, or -1 on EOF.
-     * @throws IOException If an error occurred while reading.
+     * @param  dest    an array of bytes to be written to.
+     * @param  offset  the starting position within {@code dest} to write.
+     * @param  length  the maximum number of bytes to read.
+     * @return the number of bytes actually read, or -1 on EOF.
+     * @throws IOException if an error occurred while reading.
      */
     @Override
     public final int read(final byte[] dest, int offset, int length) throws IOException {
@@ -245,9 +243,9 @@ loop:   while ((c = read()) >= 0) {
      * {@code IIOByteBuffer} to indicate the byte array, offset, and length where
      * the data may be found.
      *
-     * @param  dest The buffer to be written to.
-     * @param  length The maximum number of bytes to read.
-     * @throws IOException If an error occurred while reading.
+     * @param  dest    the buffer to be written to.
+     * @param  length  the maximum number of bytes to read.
+     * @throws IOException if an error occurred while reading.
      */
     @Override
     public final void readBytes(final IIOByteBuffer dest, int length) throws IOException {
@@ -262,9 +260,9 @@ loop:   while ((c = read()) >= 0) {
      * Skips over <var>n</var> bytes of data from the input stream.
      * This implementation does not skip more bytes than the buffer capacity.
      *
-     * @param  n Maximal number of bytes to skip.
-     * @return Number of bytes actually skipped.
-     * @throws IOException If an error occurred while reading.
+     * @param  n  maximal number of bytes to skip.
+     * @return number of bytes actually skipped.
+     * @throws IOException if an error occurred while reading.
      */
     @Override
     public final int skipBytes(int n) throws IOException {
@@ -283,9 +281,9 @@ loop:   while ((c = read()) >= 0) {
      * Advances the current stream position by the given amount of bytes.
      * The bit offset is reset to 0 by this method.
      *
-     * @param  n The number of bytes to seek forward.
-     * @return The number of bytes skipped.
-     * @throws IOException If an error occurred while skipping.
+     * @param  n  the number of bytes to seek forward.
+     * @return the number of bytes skipped.
+     * @throws IOException if an error occurred while skipping.
      */
     @Override
     public final long skipBytes(final long n) throws IOException {
@@ -300,7 +298,7 @@ loop:   while ((c = read()) >= 0) {
      *     flushBefore(getStreamPosition());
      * }
      *
-     * @throws IOException If an I/O error occurred.
+     * @throws IOException if an I/O error occurred.
      */
     @Override
     public final void flush() throws IOException {
@@ -346,7 +344,7 @@ loop:   while ((c = read()) >= 0) {
     /**
      * Closes the {@linkplain #channel}.
      *
-     * @throws IOException If an error occurred while closing the channel.
+     * @throws IOException if an error occurred while closing the channel.
      */
     @Override
     public final void close() throws IOException {

Copied: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureStore.java (from r1776235, sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureStore.java)
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureStore.java?p2=sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureStore.java&p1=sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureStore.java&r1=1776235&r2=1776236&rev=1776236&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureStore.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureStore.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -22,7 +22,7 @@ import org.apache.sis.storage.DataStoreE
 
 // Branch-dependent imports
 import org.apache.sis.internal.jdk8.Stream;
-import org.opengis.feature.Feature;
+import org.apache.sis.feature.AbstractFeature;
 
 
 /**
@@ -54,5 +54,5 @@ public abstract class FeatureStore exten
      * @return a stream over all features in the file.
      * @throws DataStoreException if an error occurred while creating the feature stream.
      */
-    public abstract Stream<Feature> getFeatures() throws DataStoreException;
+    public abstract Stream<AbstractFeature> getFeatures() throws DataStoreException;
 }

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -26,6 +26,8 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 import java.io.IOException;
+import java.io.LineNumberReader;
+import java.io.Reader;
 import java.net.URI;
 import java.net.URL;
 import java.net.URLDecoder;
@@ -61,7 +63,7 @@ import org.apache.sis.internal.system.Mo
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Johann Sorel (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.8
  * @module
  */
 public final class IOUtilities extends Static {
@@ -553,4 +555,53 @@ public final class IOUtilities extends S
     private static void recoverableException(final Exception warning) {
         Logging.recoverableException(Logging.getLogger(Modules.STORAGE), IOUtilities.class, "open", warning);
     }
+
+    /**
+     * Returns an error message a file that can not be parsed because of an error at the given location.
+     *
+     * @param  errors    the resource bundle to use for creating the message.
+     * @param  format    abbreviation of the file format (e.g. "CSV", "GML", "WKT", <i>etc</i>).
+     * @param  filename  name of the file being parsed.
+     * @param  line      1-based line number where the error occurred, or 0 if unknown.
+     * @param  column    1-based column number where the error occurred, or 0 if unknown.
+     * @return a localized error message for a file that can not be parsed.
+     *
+     * @since 0.8
+     */
+    @SuppressWarnings("fallthrough")
+    public static String canNotParseFile(final Errors errors, final String format,
+            final String filename, final int line, final int column)
+    {
+        final Object[] params = new Object[(line == 0) ? 2 : (column == 0) ? 3 : 4];
+        switch (params.length) {
+            default: // Fallthrough everywhere
+            case 4:  params[3] = column;
+            case 3:  params[2] = line;
+            case 2:  params[1] = filename;
+            case 1:  params[0] = format;
+            case 0:  break;
+        }
+        return errors.getString((line   == 0) ? Errors.Keys.CanNotParseFile_2 :
+                                (column == 0) ? Errors.Keys.CanNotParseFile_3 :
+                                                Errors.Keys.CanNotParseFile_4, params);
+    }
+
+    /**
+     * Returns an error message a file that can not be parsed because of an error at the current line.
+     * This method uses the {@link LineNumberReader#getLineNumber()} value if the given {@code input}
+     * is an instance of {@link LineNumberReader}.
+     *
+     * @param  errors    the resource bundle to use for creating the message.
+     * @param  format    abbreviation of the file format (e.g. "CSV", "GML", "WKT", <i>etc</i>).
+     * @param  filename  name of the file being parsed.
+     * @param  input     the reader, preferably as an instance of {@link LineNumberReader}.
+     * @return a localized error message for a file that can not be parsed.
+     *
+     * @since 0.8
+     */
+    @SuppressWarnings("fallthrough")
+    public static String canNotParseFile(final Errors errors, final String format, final String filename, final Reader input) {
+        return canNotParseFile(errors, format, filename,
+                (input instanceof LineNumberReader) ? ((LineNumberReader) input).getLineNumber() : 0, 0);
+    }
 }

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -43,12 +43,14 @@ 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.geometry.GeneralEnvelope;
 import org.apache.sis.metadata.iso.DefaultMetadata;
 import org.apache.sis.metadata.sql.MetadataStoreException;
-import org.apache.sis.storage.DataStore;
+import org.apache.sis.internal.storage.FeatureStore;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
+import org.apache.sis.storage.DataStoreReferencingException;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.setup.OptionKey;
 import org.apache.sis.util.ArraysExt;
@@ -56,7 +58,6 @@ import org.apache.sis.util.CharSequences
 import org.apache.sis.util.ObjectConverter;
 import org.apache.sis.util.ObjectConverters;
 import org.apache.sis.util.resources.Errors;
-import org.apache.sis.util.resources.IndexedResourceBundle;
 import org.apache.sis.util.collection.BackingStoreException;
 import org.apache.sis.measure.Units;
 
@@ -80,7 +81,7 @@ import org.apache.sis.internal.jdk8.Stre
  * @version 0.8
  * @module
  */
-public final class Store extends DataStore {
+public final class Store extends FeatureStore {
     /**
      * The character at the beginning of lines to ignore in the header.
      * Note that this is not part of OGC Moving Feature Specification.
@@ -174,11 +175,12 @@ public final class Store extends DataSto
      * <p>If the CSV file is known to be a Moving Feature file, then the given connector should
      * have an {@link org.apache.sis.setup.OptionKey#ENCODING} associated to the UTF-8 value.</p>
      *
+     * @param  provider   the factory that created this {@code DataStore} instance, or {@code null} if unspecified.
      * @param  connector  information about the storage (URL, stream, <i>etc</i>).
      * @throws DataStoreException if an error occurred while opening the stream.
      */
-    public Store(final StorageConnector connector) throws DataStoreException {
-        super(connector);
+    public Store(final StoreProvider provider, final StorageConnector connector) throws DataStoreException {
+        super(provider, connector);
         filename = connector.getStorageName();
         final Reader r = connector.getStorageAs(Reader.class);
         connector.closeAllExcept(r);
@@ -235,8 +237,12 @@ public final class Store extends DataSto
                 source.mark(1024);
             }
             source.reset();
-        } catch (IOException | FactoryException | IllegalArgumentException | DateTimeException e) {
-            throw new DataStoreException(errors().getString(Errors.Keys.CanNotParseFile_2, "CSV", filename), e);
+        } catch (IOException e) {
+            throw new DataStoreException(canNotParseFile(), e);
+        } catch (FactoryException e) {
+            throw new DataStoreReferencingException(canNotParseFile(), e);
+        } catch (IllegalArgumentException | DateTimeException e) {
+            throw new DataStoreContentException(canNotParseFile(), e);
         }
         this.encoding    = connector.getOption(OptionKey.ENCODING);
         this.envelope    = envelope;
@@ -494,7 +500,7 @@ public final class Store extends DataSto
             try {
                 builder.addExtent(envelope);
             } catch (TransformException e) {
-                throw new DataStoreContentException(errors().getString(Errors.Keys.CanNotParseFile_2, "CSV", filename), e);
+                throw new DataStoreReferencingException(canNotParseFile(), e);
             } catch (UnsupportedOperationException e) {
                 // Failed to set the temporal components if the sis-temporal module was
                 // not on the classpath, but the other dimensions still have been set.
@@ -513,6 +519,7 @@ public final class Store extends DataSto
      *
      * @todo Needs to reset the position when doing another pass on the features.
      */
+    @Override
     public Stream<AbstractFeature> getFeatures() {
         return StreamSupport.stream(new Iter(), false);
     }
@@ -639,7 +646,7 @@ public final class Store extends DataSto
             try {
                 return read(action, false);
             } catch (IOException | IllegalArgumentException | DateTimeException e) {
-                throw new BackingStoreException(canNotParse(), e);
+                throw new BackingStoreException(canNotParseFile(), e);
             }
         }
 
@@ -651,18 +658,11 @@ public final class Store extends DataSto
             try {
                 read(action, true);
             } catch (IOException | IllegalArgumentException | DateTimeException e) {
-                throw new BackingStoreException(canNotParse(), e);
+                throw new BackingStoreException(canNotParseFile(), e);
             }
         }
 
         /**
-         * Returns the error message for a file that can not be parsed.
-         */
-        private String canNotParse() {
-            return errors().getString(Errors.Keys.CanNotParseFile_2, "CSV", filename);
-        }
-
-        /**
          * Current implementation can not split this iterator.
          */
         @Override
@@ -762,9 +762,17 @@ public final class Store extends DataSto
     }
 
     /**
+     * Returns the error message for a file that can not be parsed.
+     * The error message will contain the line number if available.
+     */
+    final String canNotParseFile() {
+        return IOUtilities.canNotParseFile(errors(), "CSV", filename, source);
+    }
+
+    /**
      * Returns the resources to use for producing error messages.
      */
-    private IndexedResourceBundle errors() {
+    private Errors errors() {
         return Errors.getResources(getLocale());
     }
 

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -120,6 +120,6 @@ public class StoreProvider extends DataS
      */
     @Override
     public DataStore open(final StorageConnector connector) throws DataStoreException {
-        return new Store(connector);
+        return new Store(this, connector);
     }
 }

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -34,6 +34,7 @@ import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
+import org.apache.sis.internal.storage.IOUtilities;
 import org.apache.sis.metadata.iso.DefaultMetadata;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.CharSequences;
@@ -81,11 +82,12 @@ final class Store extends DataStore {
     /**
      * Creates a new WKT store from the given file, URL or stream.
      *
-     * @param  connector information about the storage (URL, stream, <i>etc</i>).
+     * @param  provider   the factory that created this {@code DataStore} instance, or {@code null} if unspecified.
+     * @param  connector  information about the storage (URL, stream, <i>etc</i>).
      * @throws DataStoreException if an error occurred while opening the stream.
      */
-    public Store(final StorageConnector connector) throws DataStoreException {
-        super(connector);
+    public Store(final StoreProvider provider, final StorageConnector connector) throws DataStoreException {
+        super(provider, connector);
         objects = new ArrayList<>();
         name    = connector.getStorageName();
         source  = connector.getStorageAs(Reader.class);
@@ -136,12 +138,22 @@ final class Store extends DataStore {
                     listeners.warning(record);
                 }
             } while (pos.getIndex() < wkt.length());
-        } catch (IOException | ParseException e) {
-            throw new DataStoreException(Errors.format(Errors.Keys.CanNotParseFile_2, "WKT", name), e);
+        } catch (ParseException e) {
+            throw new DataStoreContentException(canNotParseFile(in), e);
+        } catch (IOException e) {
+            throw new DataStoreException(canNotParseFile(in), e);
         }
     }
 
     /**
+     * Returns the error message for a file that can not be parsed.
+     * The error message will contain the line number if available.
+     */
+    private String canNotParseFile(final Reader in) {
+        return IOUtilities.canNotParseFile(Errors.getResources(getLocale()), "WKT", name, in);
+    }
+
+    /**
      * Returns the metadata associated to the parsed objects, or {@code null} if none.
      * The current implementation retains only instances of {@link ReferenceSystem}
      * and ignore other cases.

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -165,6 +165,6 @@ public class StoreProvider extends DataS
      */
     @Override
     public DataStore open(final StorageConnector connector) throws DataStoreException {
-        return new Store(connector);
+        return new Store(this, connector);
     }
 }

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -52,7 +52,7 @@ import static java.util.Collections.sing
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.7
+ * @version 0.8
  * @module
  */
 final class Store extends DataStore {
@@ -80,11 +80,12 @@ final class Store extends DataStore {
     /**
      * Creates a new XML store from the given file, URL or stream.
      *
-     * @param  connector information about the storage (URL, stream, <i>etc</i>).
+     * @param  provider   the factory that created this {@code DataStore} instance, or {@code null} if unspecified.
+     * @param  connector  information about the storage (URL, stream, <i>etc</i>).
      * @throws DataStoreException if an error occurred while opening the stream.
      */
-    public Store(final StorageConnector connector) throws DataStoreException {
-        super(connector);
+    public Store(final StoreProvider provider, final StorageConnector connector) throws DataStoreException {
+        super(provider, connector);
         name = connector.getStorageName();
         final InputStream in = connector.getStorageAs(InputStream.class);
         if (in != null) {

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -135,6 +135,6 @@ public class StoreProvider extends DataS
      */
     @Override
     public DataStore open(final StorageConnector connector) throws DataStoreException {
-        return new Store(connector);
+        return new Store(this, connector);
     }
 }

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -42,6 +42,15 @@ import org.apache.sis.util.logging.Warni
  */
 public abstract class DataStore implements Localized, AutoCloseable {
     /**
+     * The factory that created this {@code DataStore} instance, or {@code null} if unspecified.
+     * This information can be useful for fetching information common to all {@code DataStore}
+     * instances of the same class.
+     *
+     * @since 0.8
+     */
+    protected final DataStoreProvider provider;
+
+    /**
      * The locale to use for formatting warnings.
      * This is not the locale for formatting data in the storage.
      *
@@ -56,24 +65,30 @@ public abstract class DataStore implemen
     protected final WarningListeners<DataStore> listeners;
 
     /**
-     * Creates a new instance with initially no listener.
+     * Creates a new instance with no provider and initially no listener.
      */
     protected DataStore() {
-        locale = Locale.getDefault(Locale.Category.DISPLAY);
+        provider  = null;
+        locale    = Locale.getDefault(Locale.Category.DISPLAY);
         listeners = new WarningListeners<>(this);
     }
 
     /**
      * Creates a new instance for the given storage (typically file or database).
+     * The {@code provider} argument is an optional information.
+     * The {@code connector} argument is mandatory.
      *
-     * @param connector information about the storage (URL, stream, reader instance, <i>etc</i>).
+     * @param  provider   the factory that created this {@code DataStore} instance, or {@code null} if unspecified.
+     * @param  connector  information about the storage (URL, stream, reader instance, <i>etc</i>).
+     * @throws DataStoreException if an error occurred while creating the data store for the given storage.
      *
      * @since 0.8
      */
-    protected DataStore(final StorageConnector connector) {
+    protected DataStore(final DataStoreProvider provider, final StorageConnector connector) throws DataStoreException {
         ArgumentChecks.ensureNonNull("connector", connector);
-        locale = Locale.getDefault(Locale.Category.DISPLAY);
-        listeners = new WarningListeners<>(this);
+        this.provider  = provider;
+        this.locale    = Locale.getDefault(Locale.Category.DISPLAY);
+        this.listeners = new WarningListeners<>(this);
         /*
          * A future version could fetch some information from the StorageConnector.
          * For now we do not, not even OptionKey.LOCALE because we are not talking

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -119,11 +119,11 @@ public abstract class DataStoreProvider
      * Implementors shall invoke {@link StorageConnector#closeAllExcept(Object)} after {@code DataStore}
      * creation, keeping open only the needed resource.
      *
-     * @param  storage  information about the storage (URL, stream, JDBC connection, <i>etc</i>).
+     * @param  connector  information about the storage (URL, stream, JDBC connection, <i>etc</i>).
      * @return a data store implementation associated with this provider for the given storage.
      * @throws DataStoreException if an error occurred while creating the data store instance.
      *
      * @see DataStores#open(Object)
      */
-    public abstract DataStore open(StorageConnector storage) throws DataStoreException;
+    public abstract DataStore open(StorageConnector connector) throws DataStoreException;
 }

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/InputStreamAdapter.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/InputStreamAdapter.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/InputStreamAdapter.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/InputStreamAdapter.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -19,17 +19,18 @@ package org.apache.sis.storage;
 import java.io.InputStream;
 import java.io.IOException;
 import javax.imageio.stream.ImageInputStream;
+import org.apache.sis.internal.storage.Markable;
 
 
 /**
- * Wraps a {@link ImageInputStream} as a standard {@link InputStream}.
+ * Wraps an {@link ImageInputStream} as a standard {@link InputStream}.
  *
  * @author  Martin Desruisseaux (IRD)
  * @since   0.4
- * @version 0.4
+ * @version 0.8
  * @module
  */
-final class InputStreamAdapter extends InputStream {
+final class InputStreamAdapter extends InputStream implements Markable {
     /**
      * The data input stream.
      */
@@ -95,6 +96,7 @@ final class InputStreamAdapter extends I
     /**
      * Marks the current position in this input stream.
      *
+     * @param  readlimit ignored.
      * @throws IOException if an I/O error occurs.
      */
     @Override
@@ -103,6 +105,16 @@ final class InputStreamAdapter extends I
     }
 
     /**
+     * Marks the current position in this input stream.
+     *
+     * @throws IOException if an I/O error occurs.
+     */
+    @Override
+    public void mark() {
+        input.mark();
+    }
+
+    /**
      * Repositions this stream to the position at the time the {@code mark} method was last called.
      *
      * @throws IOException if an I/O error occurs.
@@ -113,6 +125,17 @@ final class InputStreamAdapter extends I
     }
 
     /**
+     * Returns the current byte position of the stream.
+     *
+     * @return the position of the stream.
+     * @throws IOException if the position can not be obtained.
+     */
+    @Override
+    public long getStreamPosition() throws IOException {
+        return input.getStreamPosition();
+    }
+
+    /**
      * Closes this input stream.
      *
      * @throws IOException if an I/O error occurs.

Modified: sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -78,7 +78,7 @@ public final strictfp class StoreTest ex
     @Test
     public void testGetMetadata() throws DataStoreException {
         final Metadata metadata;
-        try (Store store = new Store(new StorageConnector(testData()))) {
+        try (Store store = new Store(null, new StorageConnector(testData()))) {
             metadata = store.getMetadata();
         }
         final Extent extent = getSingleton(((AbstractIdentification) getSingleton(metadata.getIdentificationInfo())).getExtents());
@@ -97,7 +97,7 @@ public final strictfp class StoreTest ex
      */
     @Test
     public void testGetFeatures() throws DataStoreException {
-        try (Store store = new Store(new StorageConnector(testData()))) {
+        try (Store store = new Store(null, new StorageConnector(testData()))) {
             verifyFeatureType(store.featureType);
             assertEquals("foliation", Foliation.TIME, store.foliation);
             final Iterator<AbstractFeature> it = store.getFeatures().iterator();

Modified: sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreTest.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/StoreTest.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -18,6 +18,7 @@ package org.apache.sis.internal.storage.
 
 import java.io.StringReader;
 import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
 import org.opengis.metadata.Metadata;
 import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.referencing.cs.AxisDirection;
@@ -30,9 +31,6 @@ import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
 
-// Branch-dependent imports
-import java.nio.charset.StandardCharsets;
-
 
 /**
  * Tests the WKT {@link Store}.
@@ -68,12 +66,12 @@ public final strictfp class StoreTest ex
     /**
      * Tests {@link Store#getMetadata()} reading from a {@link Reader}.
      *
-     * @throws DataStoreException If an error occurred while reading the metadata.
+     * @throws DataStoreException if an error occurred while reading the metadata.
      */
     @Test
     public void testFromReader() throws DataStoreException {
         final Metadata metadata;
-        try (Store store = new Store(new StorageConnector(new StringReader(WKT)))) {
+        try (Store store = new Store(null, new StorageConnector(new StringReader(WKT)))) {
             metadata = store.getMetadata();
             assertSame("Expected cached value.", metadata, store.getMetadata());
         }
@@ -93,7 +91,7 @@ public final strictfp class StoreTest ex
         final StoreProvider p = new StoreProvider();
         final StorageConnector c = new StorageConnector(new ByteArrayInputStream(StoreTest.WKT.getBytes(StandardCharsets.US_ASCII)));
         assertTrue("isSupported", p.probeContent(c).isSupported());
-        try (Store store = new Store(c)) {
+        try (Store store = new Store(null, c)) {
             metadata = store.getMetadata();
             assertSame("Expected cached value.", metadata, store.getMetadata());
         }

Modified: sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java?rev=1776236&r1=1776235&r2=1776236&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java [UTF-8] Wed Dec 28 07:26:35 2016
@@ -91,7 +91,7 @@ public final strictfp class StoreTest ex
     @Test
     public void testMetadata() throws DataStoreException {
         final Metadata metadata;
-        try (Store store = new Store(new StorageConnector(new StringReader(XML)))) {
+        try (Store store = new Store(null, new StorageConnector(new StringReader(XML)))) {
             metadata = store.getMetadata();
             assertSame("Expected cached value.", metadata, store.getMetadata());
         }



Mime
View raw message