Author: desruisseaux
Date: Fri Jun 7 15:24:29 2013
New Revision: 1490682
URL: http://svn.apache.org/r1490682
Log:
Renamed DataStoreConnection as StorageConnector, as suggested on the mailing
list.
Added:
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
- copied, changed from r1490663,
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreConnection.java
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
- copied, changed from r1490663,
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoreConnectionTest.java
Removed:
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreConnection.java
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoreConnectionTest.java
Modified:
sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java
sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreTest.java
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
Modified:
sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java?rev=1490682&r1=1490681&r2=1490682&view=diff
==============================================================================
---
sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
[UTF-8] (original)
+++
sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
[UTF-8] Fri Jun 7 15:24:29 2013
@@ -21,13 +21,13 @@ import org.opengis.metadata.Metadata;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.DataStoreConnection;
+import org.apache.sis.storage.StorageConnector;
import org.apache.sis.internal.netcdf.Decoder;
/**
* A data store backed by NetCDF files.
- * Instances of this data store are created by {@link
NetcdfStoreProvider#open(DataStoreConnection)}.
+ * Instances of this data store are created by {@link
NetcdfStoreProvider#open(StorageConnector)}.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
@@ -50,13 +50,13 @@ public class NetcdfStore extends DataSto
/**
* Creates a new NetCDF store from the given file, URL, stream or {@link
ucar.nc2.NetcdfFile} object.
- * This constructor invokes {@link
DataStoreConnection#closeAllExcept(Object)}, keeping open only the
+ * This constructor invokes {@link
StorageConnector#closeAllExcept(Object)}, keeping open only the
* needed resource.
*
* @param storage 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.
*/
- public NetcdfStore(final DataStoreConnection storage) throws
DataStoreException {
+ public NetcdfStore(final StorageConnector storage) throws
DataStoreException {
ArgumentChecks.ensureNonNull("storage", storage);
try {
decoder = NetcdfStoreProvider.decoder(listeners, storage);
Modified:
sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java?rev=1490682&r1=1490681&r2=1490682&view=diff
==============================================================================
---
sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
[UTF-8] (original)
+++
sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
[UTF-8] Fri Jun 7 15:24:29 2013
@@ -28,13 +28,13 @@ import org.apache.sis.internal.netcdf.uc
import org.apache.sis.internal.storage.ChannelDataInput;
import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.DataStoreProvider;
-import org.apache.sis.storage.DataStoreConnection;
+import org.apache.sis.storage.StorageConnector;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.util.logging.WarningListeners;
/**
- * The provider of {@link NetcdfStore} instances. Given a {@link
DataStoreConnection} input,
+ * The provider of {@link NetcdfStore} instances. Given a {@link
StorageConnector} input,
* this class tries to instantiate a {@code NetcdfStore} using the embedded
NetCDF decoder.
* If the embedded decoder can not decode the given input and the UCAR library
is reachable
* on the classpath, then this class tries to instantiate a {@code
NetcdfStore} backed by
@@ -88,7 +88,7 @@ public class NetcdfStoreProvider extends
* Returns {@code TRUE} if the given storage appears to be supported by
{@link NetcdfStore}.
* Returning {@code TRUE} from this method does not guarantee that reading
or writing will succeed,
* only that there appears to be a reasonable chance of success based on a
brief inspection of the
- * {@linkplain DataStoreConnection#getStorage() storage object} or
contents.
+ * {@linkplain StorageConnector#getStorage() storage object} or contents.
*
* @param storage Information about the storage (URL, stream, {@link
ucar.nc2.NetcdfFile} instance, <i>etc</i>).
* @return {@link Boolean#TRUE} if the given storage seems to be usable by
the {@code NetcdfStore} instances,
@@ -97,7 +97,7 @@ public class NetcdfStoreProvider extends
* @throws DataStoreException if an I/O error occurred.
*/
@Override
- public Boolean canOpen(DataStoreConnection storage) throws
DataStoreException {
+ public Boolean canOpen(StorageConnector storage) throws DataStoreException
{
final ByteBuffer buffer = storage.getStorageAs(ByteBuffer.class);
if (buffer != null) {
if (buffer.remaining() < Integer.SIZE / Byte.SIZE) {
@@ -142,19 +142,19 @@ public class NetcdfStoreProvider extends
/**
* Returns a {@link NetcdfStore} implementation associated with this
provider. This method invokes
- * {@link DataStoreConnection#closeAllExcept(Object)} after data store
creation, keeping open only
+ * {@link StorageConnector#closeAllExcept(Object)} after data store
creation, keeping open only
* the needed resource.
*
* @param storage Information about the storage (URL, stream, {@link
ucar.nc2.NetcdfFile} instance, <i>etc</i>).
*/
@Override
- public DataStore open(final DataStoreConnection storage) throws
DataStoreException {
+ public DataStore open(final StorageConnector storage) throws
DataStoreException {
return new NetcdfStore(storage);
}
/**
* Creates a decoder for the given input. This method invokes
- * {@link DataStoreConnection#closeAllExcept(Object)} after the decoder
has been created.
+ * {@link StorageConnector#closeAllExcept(Object)} after the decoder has
been created.
*
* @param listeners Where to send the warnings.
* @param storage Information about the input (file, input stream,
<i>etc.</i>)
@@ -162,7 +162,7 @@ public class NetcdfStoreProvider extends
* @throws IOException If an error occurred while opening the NetCDF file.
* @throws DataStoreException If a logical error (other than I/O) occurred.
*/
- static Decoder decoder(final WarningListeners<?> listeners, final
DataStoreConnection storage)
+ static Decoder decoder(final WarningListeners<?> listeners, final
StorageConnector storage)
throws IOException, DataStoreException
{
Decoder decoder;
Modified:
sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java?rev=1490682&r1=1490681&r2=1490682&view=diff
==============================================================================
---
sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java
[UTF-8] (original)
+++
sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreProviderTest.java
[UTF-8] Fri Jun 7 15:24:29 2013
@@ -24,7 +24,7 @@ import org.apache.sis.internal.netcdf.De
import org.apache.sis.internal.netcdf.ucar.DecoderWrapper;
import org.apache.sis.internal.netcdf.impl.ChannelDecoder;
import org.apache.sis.internal.netcdf.impl.ChannelDecoderTest;
-import org.apache.sis.storage.DataStoreConnection;
+import org.apache.sis.storage.StorageConnector;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.test.DependsOn;
import org.junit.Test;
@@ -45,21 +45,21 @@ import static org.opengis.test.Assert.*;
})
public final strictfp class NetcdfStoreProviderTest extends IOTestCase {
/**
- * Tests {@link NetcdfStoreProvider#canOpen(DataStoreConnection)} for an
input stream which shall
+ * Tests {@link NetcdfStoreProvider#canOpen(StorageConnector)} for an
input stream which shall
* be recognized as a classic NetCDF file.
*
* @throws DataStoreException Should never happen.
*/
@Test
public void testCanOpenFromStream() throws DataStoreException {
- final DataStoreConnection c = new
DataStoreConnection(IOTestCase.class.getResourceAsStream(NCEP));
+ final StorageConnector c = new
StorageConnector(IOTestCase.class.getResourceAsStream(NCEP));
final NetcdfStoreProvider provider = new NetcdfStoreProvider();
assertTrue(provider.canOpen(c));
c.closeAllExcept(null);
}
/**
- * Tests {@link NetcdfStoreProvider#canOpen(DataStoreConnection)} for a
UCAR {@link NetcdfFile} object.
+ * Tests {@link NetcdfStoreProvider#canOpen(StorageConnector)} for a UCAR
{@link NetcdfFile} object.
*
* @throws IOException If an error occurred while opening the NetCDF file.
* @throws DataStoreException Should never happen.
@@ -67,14 +67,14 @@ public final strictfp class NetcdfStoreP
@Test
public void testCanOpenFromUCAR() throws IOException, DataStoreException {
final NetcdfFile file = open(NCEP);
- final DataStoreConnection c = new DataStoreConnection(file);
+ final StorageConnector c = new StorageConnector(file);
final NetcdfStoreProvider provider = new NetcdfStoreProvider();
assertTrue(provider.canOpen(c));
file.close();
}
/**
- * Tests {@link NetcdfStoreProvider#decoder(WarningListeners,
DataStoreConnection)} for an input stream which
+ * Tests {@link NetcdfStoreProvider#decoder(WarningListeners,
StorageConnector)} for an input stream which
* shall be recognized as a classic NetCDF file. The provider shall
instantiate a {@link ChannelDecoder}.
*
* @throws IOException If an error occurred while opening the NetCDF file.
@@ -82,14 +82,14 @@ public final strictfp class NetcdfStoreP
*/
@Test
public void testDecoderFromStream() throws IOException, DataStoreException
{
- final DataStoreConnection c = new
DataStoreConnection(IOTestCase.class.getResourceAsStream(NCEP));
+ final StorageConnector c = new
StorageConnector(IOTestCase.class.getResourceAsStream(NCEP));
final Decoder decoder =
NetcdfStoreProvider.decoder(TestCase.LISTENERS, c);
assertInstanceOf(NCEP, ChannelDecoder.class, decoder);
decoder.close();
}
/**
- * Tests {@link NetcdfStoreProvider#decoder(WarningListeners,
DataStoreConnection)} for a UCAR
+ * Tests {@link NetcdfStoreProvider#decoder(WarningListeners,
StorageConnector)} for a UCAR
* {@link NetcdfFile} object. The provider shall instantiate a {@link
DecoderWrapper}.
*
* @throws IOException If an error occurred while opening the NetCDF file.
@@ -97,7 +97,7 @@ public final strictfp class NetcdfStoreP
*/
@Test
public void testDecoderFromUCAR() throws IOException, DataStoreException {
- final DataStoreConnection c = new DataStoreConnection(open(NCEP));
+ final StorageConnector c = new StorageConnector(open(NCEP));
final Decoder decoder =
NetcdfStoreProvider.decoder(TestCase.LISTENERS, c);
assertInstanceOf(NCEP, DecoderWrapper.class, decoder);
decoder.close();
Modified:
sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreTest.java?rev=1490682&r1=1490681&r2=1490682&view=diff
==============================================================================
---
sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreTest.java
[UTF-8] (original)
+++
sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/NetcdfStoreTest.java
[UTF-8] Fri Jun 7 15:24:29 2013
@@ -18,7 +18,7 @@ package org.apache.sis.storage.netcdf;
import org.opengis.metadata.Metadata;
import org.opengis.wrapper.netcdf.IOTestCase;
-import org.apache.sis.storage.DataStoreConnection;
+import org.apache.sis.storage.StorageConnector;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.test.DependsOn;
import org.junit.Test;
@@ -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
DataStoreConnection(IOTestCase.class.getResource(dataset)));
+ return new NetcdfStore(new
StorageConnector(IOTestCase.class.getResource(dataset)));
}
/**
Modified:
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java?rev=1490682&r1=1490681&r2=1490682&view=diff
==============================================================================
---
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
[UTF-8] (original)
+++
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
[UTF-8] Fri Jun 7 15:24:29 2013
@@ -684,8 +684,8 @@ public class ChannelDataInput {
/*
* Requested position is outside the current limits of the buffer,
* but we can set the new position directly in the channel. Note
- * that DataStoreConnection.rewind() needs the buffer content to
- * be valid as a result of this seek, so we reload it immediately.
+ * that StorageConnector.rewind() needs the buffer content to be
+ * valid as a result of this seek, so we reload it immediately.
*/
((SeekableByteChannel) channel).position(channelOffset + position);
bufferOffset = position;
Modified:
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java?rev=1490682&r1=1490681&r2=1490682&view=diff
==============================================================================
---
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
[UTF-8] (original)
+++
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
[UTF-8] Fri Jun 7 15:24:29 2013
@@ -18,7 +18,7 @@ package org.apache.sis.storage;
/**
- * Creates {@link DataStore} instances for a specific format from a given
{@link DataStoreConnection} input.
+ * Creates {@link DataStore} instances for a specific format from a given
{@link StorageConnector} input.
* There is typically a different {@code DataStoreProvider} instance for each
format provided by a library.
*
* @author Martin Desruisseaux (Geomatys)
@@ -37,7 +37,7 @@ public abstract class DataStoreProvider
* Returns {@code TRUE} if the given storage appears to be supported by
the {@code DataStore}.
* Returning {@code TRUE} from this method does not guarantee that reading
or writing will succeed,
* only that there appears to be a reasonable chance of success based on a
brief inspection of the
- * {@linkplain DataStoreConnection#getStorage() storage object} or
contents.
+ * {@linkplain StorageConnector#getStorage() storage object} or contents.
*
* <p>Implementations will typically check the first bytes of the stream
for a "magic number"
* associated with the format, as in the following example:</p>
@@ -45,9 +45,9 @@ public abstract class DataStoreProvider
* {@preformat java
* final ByteBuffer buffer = storage.getStorageAs(ByteBuffer.class);
* if (buffer == null) {
- * // If DataStoreConnection can not provide a ByteBuffer, then
the storage is probably
- * // not a File, URL, URI, InputStream neither a ReadableChannel.
In this example, our
- * // provider can not handle such unknown source.
+ * // If StorageConnector can not provide a ByteBuffer, then the
storage is probably
+ * // not a File, URL, URI, InputStream neither a ReadableChannel.
In this example,
+ * // our provider can not handle such unknown source.
* return Boolean.FALSE;
* }
* if (buffer.remaining() < Integer.SIZE / Byte.SIZE) {
@@ -73,18 +73,18 @@ public abstract class DataStoreProvider
* @throws DataStoreException if an I/O or SQL error occurred. The error
shall be unrelated to the logical
* structure of the storage.
*/
- public abstract Boolean canOpen(DataStoreConnection storage) throws
DataStoreException;
+ public abstract Boolean canOpen(StorageConnector storage) throws
DataStoreException;
/**
* Returns a data store implementation associated with this provider.
*
* <p><b>Implementation note:</b>
- * Implementors shall invoke {@link
DataStoreConnection#closeAllExcept(Object)} after {@code DataStore}
+ * Implementors shall invoke {@link
StorageConnector#closeAllExcept(Object)} after {@code DataStore}
* creation, keeping open only the needed resource.</p>
*
* @param storage 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.
*/
- public abstract DataStore open(DataStoreConnection storage) throws
DataStoreException;
+ public abstract DataStore open(StorageConnector storage) throws
DataStoreException;
}
Copied:
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
(from r1490663,
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreConnection.java)
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java?p2=sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java&p1=sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreConnection.java&r1=1490663&r2=1490682&rev=1490682&view=diff
==============================================================================
---
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreConnection.java
[UTF-8] (original)
+++
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
[UTF-8] Fri Jun 7 15:24:29 2013
@@ -41,7 +41,7 @@ import org.apache.sis.setup.OptionKey;
/**
* Information for creating a connection to a {@link DataStore} in read and/or
write mode.
- * {@code DataStoreConnection} wraps an input {@link Object}, which can be any
of the following types:
+ * {@code StorageConnector} wraps an input {@link Object}, which can be any of
the following types:
*
* <ul>
* <li>A {@link java.nio.file.Path} or a {@link java.io.File} or file or a
directory in a file system.</li>
@@ -57,7 +57,7 @@ import org.apache.sis.setup.OptionKey;
* of {@code getStorageAs(…)} may return the same input stream.
*
* <p>This class is used only for discovery of a {@code DataStore}
implementation capable to handle the input.
- * Once a suitable {@code DataStore} has been found, the {@code
DataStoreConnection} instance is typically
+ * Once a suitable {@code DataStore} has been found, the {@code
StorageConnector} instance is typically
* discarded since each data store implementation will use their own
input/output objects.</p>
*
* <p>Instances of this class are serializable if the {@code storage} object
given at construction time
@@ -68,7 +68,7 @@ import org.apache.sis.setup.OptionKey;
* @version 0.3
* @module
*/
-public class DataStoreConnection implements Serializable {
+public class StorageConnector implements Serializable {
/**
* For cross-version compatibility.
*/
@@ -141,7 +141,7 @@ public class DataStoreConnection impleme
*
* @param storage The input/output object as a URL, file, image input
stream, <i>etc.</i>.
*/
- public DataStoreConnection(final Object storage) {
+ public StorageConnector(final Object storage) {
ArgumentChecks.ensureNonNull("storage", storage);
this.storage = storage;
}
@@ -293,15 +293,15 @@ public class DataStoreConnection impleme
* </li>
* </ul>
*
- * Multiple invocations of this method on the same {@code
DataStoreConnection} instance will try
+ * Multiple invocations of this method on the same {@code
StorageConnector} instance will try
* to return the same instance on a <cite>best effort</cite> basis.
Consequently, implementations
- * of {@link DataStoreProvider#canOpen(DataStoreConnection)} methods shall
not close the stream or
- * database connection returned by this method. In addition, those {@code
canOpen(DataStoreConnection)}
+ * of {@link DataStoreProvider#canOpen(StorageConnector)} methods shall
not close the stream or
+ * database connection returned by this method. In addition, those {@code
canOpen(StorageConnector)}
* methods are responsible for restoring the stream or byte buffer to its
original position on return.
*
* @param <T> The compile-time type of the {@code type} argument.
* @param type The desired type as one of {@code ByteBuffer}, {@code
DataInput}, {@code Connection}
- * class or other type supported by {@code DataStoreConnection}
subclasses.
+ * class or other type supported by {@code StorageConnector}
subclasses.
* @return The storage as a view of the given type, or {@code null} if no
view can be created for the given type.
* @throws IllegalArgumentException If the given {@code type} argument is
not a known type.
* @throws DataStoreException If an error occurred while opening a stream
or database connection.
@@ -508,7 +508,7 @@ public class DataStoreConnection impleme
}
/**
- * Closes all streams and connections created by this {@code
DataStoreConnection} except the given view.
+ * Closes all streams and connections created by this {@code
StorageConnector} except the given view.
* This method closes all objects created by the {@link
#getStorageAs(Class)} method except the given {@code view}.
* If {@code view} is {@code null}, then this method closes everything
including the {@linkplain #getStorage()
* storage} if it is closeable.
@@ -517,13 +517,13 @@ public class DataStoreConnection impleme
* by the data store is given in argument to this method - or when no
suitable {@code DataStore} has been
* found - in which case the {@code view} argument is null.</p>
*
- * <p>This {@code DataStoreConnection} instance shall not be used anymore
after invocation of this method.</p>
+ * <p>This {@code StorageConnector} instance shall not be used anymore
after invocation of this method.</p>
*
* @param view The view to leave open, or {@code null} if none.
* @throws DataStoreException If an error occurred while closing the
stream or database connection.
*
* @see #getStorageAs(Class)
- * @see DataStoreProvider#open(DataStoreConnection)
+ * @see DataStoreProvider#open(StorageConnector)
*/
public void closeAllExcept(final Object view) throws DataStoreException {
/*
@@ -561,7 +561,7 @@ public class DataStoreConnection impleme
}
/**
- * Returns a string representation of this {@code DataStoreConnection} for
debugging purpose.
+ * Returns a string representation of this {@code StorageConnector} for
debugging purpose.
*/
@Override
public String toString() {
Modified:
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java?rev=1490682&r1=1490681&r2=1490682&view=diff
==============================================================================
---
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java
[UTF-8] (original)
+++
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/package-info.java
[UTF-8] Fri Jun 7 15:24:29 2013
@@ -19,6 +19,20 @@
* {@linkplain org.apache.sis.storage.DataStore Data store} base types for
retrieving and saving geospatial data
* in various storage formats.
*
+ * <p>Different {@code DataStore} implementations will want different kind of
input/output objects. Some examples are
+ * {@link java.lang.String}, {@link java.nio.file.Path}, {@link java.io.File},
{@link java.net.URI}, {@link java.net.URL},
+ * {@link java.io.InputStream}, {@link javax.imageio.stream.ImageInputStream},
{@link java.nio.channels.ReadableChannel},
+ * JDBC {@link java.sql.Connection} or {@link javax.sql.DataSource}, or even
+ * datastore-specific objects like {@link ucar.nc2.NetcdfFile}.
+ * Because of this variety, SIS does not know which kind of object to accept
before the appropriate {@code DataStore}
+ * instance has been found. For this reason, storages are represented by
arbitrary {@link java.lang.Object} encapsulated
+ * in {@link org.apache.sis.storage.StorageConnector}. The later can open the
object in various ways, for example
+ * as {@link java.io.DataInput} or as {@link java.nio.ByteBuffer}, depending
on {@code DataStore needs}.
+ * Future versions may contain additional information like login/password.</p>
+ *
+ * <p>{@code StorageConnector} is used only for the "discovery" phase, and
discarded once the actual
+ * {@code DataStore} instance has been created.</p>
+ *
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
* @since 0.3 (derived from geotk-3.10)
Copied:
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
(from r1490663,
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoreConnectionTest.java)
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java?p2=sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java&p1=sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoreConnectionTest.java&r1=1490663&r2=1490682&rev=1490682&view=diff
==============================================================================
---
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoreConnectionTest.java
[UTF-8] (original)
+++
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
[UTF-8] Fri Jun 7 15:24:29 2013
@@ -33,7 +33,7 @@ import static org.opengis.test.Assert.*;
/**
- * Tests {@link DataStoreConnection}.
+ * Tests {@link StorageConnector}.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
@@ -41,56 +41,56 @@ import static org.opengis.test.Assert.*;
* @module
*/
@DependsOn(org.apache.sis.internal.storage.ChannelImageInputStreamTest.class)
-public final strictfp class DataStoreConnectionTest extends TestCase {
+public final strictfp class StorageConnectorTest extends TestCase {
/**
* The magic number of Java class files, used for verifying the content of
our test file.
*/
private static final int MAGIC_NUMBER = 0xCAFEBABE;
/**
- * Creates the instance to test. This method uses the {@code
DataStoreConnectionTest} compiled
+ * Creates the instance to test. This method uses the {@code
StorageConnectorTest} compiled
* class file as the resource to test. The resource can be provided either
as a URL or as a stream.
*/
- private DataStoreConnection create(final boolean asStream) {
- final Class<?> c = DataStoreConnectionTest.class;
+ private StorageConnector create(final boolean asStream) {
+ final Class<?> c = StorageConnectorTest.class;
final String name = c.getSimpleName() + ".class";
final Object storage = asStream ? c.getResourceAsStream(name) :
c.getResource(name);
assertNotNull(storage);
- return new DataStoreConnection(storage);
+ return new StorageConnector(storage);
}
/**
- * Tests the {@link DataStoreConnection#getStorageName()} method.
+ * Tests the {@link StorageConnector#getStorageName()} method.
*/
@Test
public void testGetStorageName() {
- final DataStoreConnection c = create(false);
- assertEquals("DataStoreConnectionTest.class", c.getStorageName());
+ final StorageConnector c = create(false);
+ assertEquals("StorageConnectorTest.class", c.getStorageName());
}
/**
- * Tests the {@link DataStoreConnection#getFileExtension()} method.
+ * Tests the {@link StorageConnector#getFileExtension()} method.
*/
@Test
public void testGetExtension() {
- final DataStoreConnection c = create(false);
+ final StorageConnector c = create(false);
assertEquals("class", c.getFileExtension());
}
/**
- * Tests the {@link DataStoreConnection#getStorageAs(Class)} method for
the {@link String} type.
+ * Tests the {@link StorageConnector#getStorageAs(Class)} method for the
{@link String} type.
*
* @throws DataStoreException Should never happen.
* @throws IOException Should never happen.
*/
@Test
public void testGetAsString() throws DataStoreException, IOException {
- final DataStoreConnection c = create(false);
-
assertTrue(c.getStorageAs(String.class).endsWith("org/apache/sis/storage/DataStoreConnectionTest.class"));
+ final StorageConnector c = create(false);
+
assertTrue(c.getStorageAs(String.class).endsWith("org/apache/sis/storage/StorageConnectorTest.class"));
}
/**
- * Tests the {@link DataStoreConnection#getStorageAs(Class)} method for
the I/O types.
+ * Tests the {@link StorageConnector#getStorageAs(Class)} method for the
I/O types.
* The initial storage object is a {@link java.net.URL}.
*
* @throws DataStoreException Should never happen.
@@ -102,7 +102,7 @@ public final strictfp class DataStoreCon
}
/**
- * Tests the {@link DataStoreConnection#getStorageAs(Class)} method for
the I/O types.
+ * Tests the {@link StorageConnector#getStorageAs(Class)} method for the
I/O types.
* The initial storage object is an {@link java.io.InputStream}.
*
* @throws DataStoreException Should never happen.
@@ -117,7 +117,7 @@ public final strictfp class DataStoreCon
* Implementation of {@link #testGetAsDataInputFromURL()} and {@link
#testGetAsDataInputFromStream()}.
*/
private void testGetAsDataInput(final boolean asStream) throws
DataStoreException, IOException {
- final DataStoreConnection connection = create(asStream);
+ final StorageConnector connection = create(asStream);
final DataInput input = connection.getStorageAs(DataInput.class);
assertSame("Value shall be cached.", input,
connection.getStorageAs(DataInput.class));
assertInstanceOf("Needs the SIS implementation",
ChannelImageInputStream.class, input);
@@ -134,7 +134,7 @@ public final strictfp class DataStoreCon
}
/**
- * Tests the {@link DataStoreConnection#getStorageAs(Class)} method for
the {@link ImageInputStream} type.
+ * Tests the {@link StorageConnector#getStorageAs(Class)} method for the
{@link ImageInputStream} type.
* This is basically a synonymous of {@code getStorageAs(DataInput.class)}.
*
* @throws DataStoreException Should never happen.
@@ -142,14 +142,14 @@ public final strictfp class DataStoreCon
*/
@Test
public void testGetAsImageInputStream() throws DataStoreException,
IOException {
- final DataStoreConnection connection = create(false);
+ final StorageConnector connection = create(false);
final ImageInputStream in =
connection.getStorageAs(ImageInputStream.class);
assertSame(connection.getStorageAs(DataInput.class), in);
connection.closeAllExcept(null);
}
/**
- * Tests the {@link DataStoreConnection#getStorageAs(Class)} method for
the {@link ChannelDataInput} type.
+ * Tests the {@link StorageConnector#getStorageAs(Class)} method for the
{@link ChannelDataInput} type.
* The initial value should not be an instance of {@link
ChannelImageInputStream} in order to avoid initializing
* the Image I/O classes. However after a call to {@code
getStorageAt(ChannelImageInputStream.class)}, the type
* should have been promoted.
@@ -159,7 +159,7 @@ public final strictfp class DataStoreCon
*/
@Test
public void testGetAsChannelDataInput() throws DataStoreException,
IOException {
- final DataStoreConnection connection = create(true);
+ final StorageConnector connection = create(true);
final ChannelDataInput input =
connection.getStorageAs(ChannelDataInput.class);
assertFalse(input instanceof ChannelImageInputStream);
assertEquals(MAGIC_NUMBER, input.buffer.getInt());
@@ -176,7 +176,7 @@ public final strictfp class DataStoreCon
}
/**
- * Tests the {@link DataStoreConnection#getStorageAs(Class)} method for
the {@link ByteBuffer} type.
+ * Tests the {@link StorageConnector#getStorageAs(Class)} method for the
{@link ByteBuffer} type.
* This method uses the same test file than {@link
#testGetAsDataInputFromURL()}.
*
* @throws DataStoreException Should never happen.
@@ -185,16 +185,16 @@ public final strictfp class DataStoreCon
@Test
@DependsOnMethod("testGetAsDataInputFromURL")
public void testGetAsByteBuffer() throws DataStoreException, IOException {
- final DataStoreConnection connection = create(false);
+ final StorageConnector connection = create(false);
final ByteBuffer buffer = connection.getStorageAs(ByteBuffer.class);
assertNotNull("getStorageAs(ByteBuffer.class)", buffer);
- assertEquals(DataStoreConnection.DEFAULT_BUFFER_SIZE,
buffer.capacity());
+ assertEquals(StorageConnector.DEFAULT_BUFFER_SIZE, buffer.capacity());
assertEquals(MAGIC_NUMBER, buffer.getInt());
connection.closeAllExcept(null);
}
/**
- * Tests the {@link DataStoreConnection#getStorageAs(Class)} method for
the {@link ByteBuffer} type when
+ * Tests the {@link StorageConnector#getStorageAs(Class)} method for the
{@link ByteBuffer} type when
* the buffer is only temporary. The difference between this test and
{@link #testGetAsByteBuffer()} is
* that the buffer created in this test will not be used for the "real"
reading process in the data store.
* Consequently, it should be a smaller, only temporary, buffer.
@@ -205,21 +205,21 @@ public final strictfp class DataStoreCon
@Test
@DependsOnMethod("testGetAsDataInputFromStream")
public void testGetAsTemporaryByteBuffer() throws DataStoreException,
IOException {
- DataStoreConnection connection = create(true);
+ StorageConnector connection = create(true);
final DataInput in =
ImageIO.createImageInputStream(connection.getStorage());
assertNotNull("ImageIO.createImageInputStream(InputStream)", in); //
Sanity check.
- connection = new DataStoreConnection(in);
+ connection = new StorageConnector(in);
assertSame(in, connection.getStorageAs(DataInput.class));
final ByteBuffer buffer = connection.getStorageAs(ByteBuffer.class);
assertNotNull("getStorageAs(ByteBuffer.class)", buffer);
- assertTrue(buffer.capacity() <
DataStoreConnection.DEFAULT_BUFFER_SIZE);
+ assertTrue(buffer.capacity() < StorageConnector.DEFAULT_BUFFER_SIZE);
assertEquals(MAGIC_NUMBER, buffer.getInt());
connection.closeAllExcept(null);
}
/**
- * Tests the {@link DataStoreConnection#closeAllExcept(Object)} method.
+ * Tests the {@link StorageConnector#closeAllExcept(Object)} method.
*
* @throws DataStoreException Should never happen.
* @throws IOException If an error occurred while reading the test file.
@@ -227,7 +227,7 @@ public final strictfp class DataStoreCon
@Test
@DependsOnMethod("testGetAsDataInputFromStream")
public void testCloseAllExcept() throws DataStoreException, IOException {
- final DataStoreConnection connection = create(true);
+ final StorageConnector connection = create(true);
final DataInput input = connection.getStorageAs(DataInput.class);
final ReadableByteChannel channel = ((ChannelImageInputStream)
input).channel;
assertTrue("channel.isOpen()", channel.isOpen());
Modified:
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java?rev=1490682&r1=1490681&r2=1490682&view=diff
==============================================================================
---
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
[UTF-8] (original)
+++
sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
[UTF-8] Fri Jun 7 15:24:29 2013
@@ -33,7 +33,7 @@ import org.junit.BeforeClass;
org.apache.sis.internal.storage.IOUtilitiesTest.class,
org.apache.sis.internal.storage.ChannelDataInputTest.class,
org.apache.sis.internal.storage.ChannelImageInputStreamTest.class,
- org.apache.sis.storage.DataStoreConnectionTest.class
+ org.apache.sis.storage.StorageConnectorTest.class
})
public final strictfp class StorageTestSuite extends TestSuite {
/**