sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1815605 [3/3] - in /sis/branches/JDK7: ./ application/ application/sis-console/src/main/artifact/ application/sis-console/src/main/java/org/apache/sis/console/ application/sis-openoffice/ application/sis-openoffice/src/main/java/org/apache...
Date Fri, 17 Nov 2017 17:56:37 GMT
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DocumentedStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DocumentedStoreProvider.java?rev=1815605&r1=1815604&r2=1815605&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DocumentedStoreProvider.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DocumentedStoreProvider.java
[UTF-8] Fri Nov 17 17:56:36 2017
@@ -16,7 +16,8 @@
  */
 package org.apache.sis.internal.storage;
 
-import java.util.logging.Logger;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
 import org.opengis.metadata.distribution.Format;
 import org.apache.sis.metadata.sql.MetadataSource;
 import org.apache.sis.metadata.sql.MetadataStoreException;
@@ -98,13 +99,17 @@ public abstract class DocumentedStorePro
             if (listeners != null) {
                 listeners.warning(null, e);
             } else {
-                final Logger logger = Logging.getLogger(Modules.STORAGE);
+                final Level level;
                 if (!logged) {
                     logged = true;      // Not atomic - not a big deal if we use warning
level twice.
-                    Logging.unexpectedException(logger, getClass(), "getFormat", e);
+                    level = Level.WARNING;
                 } else {
-                    Logging.recoverableException(logger, getClass(), "getFormat", e);
+                    level = Level.FINE;
                 }
+                final LogRecord record = Resources.forLocale(null).getLogRecord(level,
+                        Resources.Keys.CanNotGetCommonMetadata_2, getShortName(), e.getLocalizedMessage());
+                record.setLoggerName(Modules.STORAGE);
+                Logging.log(getClass(), "getFormat", record);
             }
         }
         return super.getFormat();

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java?rev=1815605&r1=1815604&r2=1815605&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
[UTF-8] Fri Nov 17 17:56:36 2017
@@ -32,7 +32,7 @@ import org.apache.sis.util.resources.Res
  * all modules in the Apache SIS project, see {@link org.apache.sis.util.resources} package.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.8
  * @module
  */
@@ -67,6 +67,11 @@ public final class Resources extends Ind
         public static final short AmbiguousName_4 = 15;
 
         /**
+         * Can not get metadata common to “{0}” files. Reason: {1}
+         */
+        public static final short CanNotGetCommonMetadata_2 = 39;
+
+        /**
          * Can not read the Coordinate Reference System (CRS) Well Known Text (WKT) in “{0}”.
          */
         public static final short CanNotReadCRS_WKT_1 = 37;
@@ -153,6 +158,11 @@ public final class Resources extends Ind
         public static final short FeatureNotFound_2 = 17;
 
         /**
+         * Whether to assemble trajectory fragments (lines in CSV file) in a single feature
instance.
+         */
+        public static final short FoliationRepresentation = 38;
+
+        /**
          * The {0} data store does not accept features of type “{1}”.
          */
         public static final short IllegalFeatureType_2 = 7;

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties?rev=1815605&r1=1815604&r2=1815605&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
[ISO-8859-1] Fri Nov 17 17:56:36 2017
@@ -20,6 +20,7 @@
 # For resources shared by all modules in the Apache SIS project, see "org.apache.sis.util.resources"
package.
 #
 AmbiguousName_4                   = Name \u201c{3}\u201d is ambiguous because it can be understood
as either \u201c{1}\u201d or \u201c{2}\u201d in the context of \u201c{0}\u201d data.
+CanNotGetCommonMetadata_2         = Can not get metadata common to \u201c{0}\u201d files.
Reason: {1}
 CanNotReadCRS_WKT_1               = Can not read the Coordinate Reference System (CRS) Well
Known Text (WKT) in \u201c{0}\u201d.
 CanNotReadDirectory_1             = Can not read \u201c{0}\u201d directory.
 CanNotReadFile_2                  = Can not read \u201c{1}\u201d as a file in the {0} format.
@@ -36,6 +37,7 @@ DataStoreTimeZone                 = Time
 DirectoryContent_1                = Content of \u201c{0}\u201d directory.
 FeatureAlreadyPresent_2           = A feature named \u201c{1}\u201d is already present in
the \u201c{0}\u201d data store.
 FeatureNotFound_2                 = Feature \u201c{1}\u201d has not been found in the \u201c{0}\u201d
data store.
+FoliationRepresentation           = Whether to assemble trajectory fragments (lines in CSV
file) in a single feature instance.
 ExcessiveStringSize_3             = Character string in the \u201c{0}\u201d file is too long.
The string has {2} characters while the limit is {1}.
 IllegalFeatureType_2              = The {0} data store does not accept features of type \u201c{1}\u201d.
 IllegalInputTypeForReader_2       = The {0} reader does not accept inputs of type \u2018{1}\u2019.

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties?rev=1815605&r1=1815604&r2=1815605&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
[ISO-8859-1] Fri Nov 17 17:56:36 2017
@@ -25,6 +25,7 @@
 #   U+00A0 NO-BREAK SPACE         before  :
 #
 AmbiguousName_4                   = Le nom \u00ab\u202f{3}\u202f\u00bb est ambigu\u00eb car
il peut \u00eatre interpr\u00e9t\u00e9 aussi bien comme \u00ab\u202f{1}\u202f\u00bb ou \u00ab\u202f{2}\u202f\u00bb
dans le contexte des donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
+CanNotGetCommonMetadata_2         = Ne peut pas obtenir les m\u00e9ta-donn\u00e9es communes
aux fichiers \u00ab\u202f{0}\u202f\u00bb. Raison\u2008: {1}
 CanNotReadCRS_WKT_1               = Ne peut pas lire le syst\u00e8me de r\u00e9f\u00e9rence
spatial dans le \u00ab\u202fWell Known Text\u202f\u00bb (WKT) de \u00ab\u202f{0}\u202f\u00bb.
 CanNotReadDirectory_1             = Ne peut pas lire le r\u00e9pertoire \u00ab\u202f{0}\u202f\u00bb.
 CanNotReadFile_2                  = Ne peut pas lire \u00ab\u202f{1}\u202f\u00bb comme un
fichier au format {0}.
@@ -41,7 +42,8 @@ DataStoreTimeZone                 = Fuse
 DirectoryContent_1                = Contenu du r\u00e9pertoire \u00ab\u202f{0}\u202f\u00bb.
 ExcessiveStringSize_3             = La cha\u00eene de caract\u00e8res dans le fichier \u00ab\u202f{0}\u202f\u00bb
est trop longue. La cha\u00eene fait {2} caract\u00e8res alors que la limite est {1}.
 FeatureAlreadyPresent_2           = Une entit\u00e9 nomm\u00e9e \u00ab\u202f{1}\u202f\u00bb
est d\u00e9j\u00e0 pr\u00e9sente dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
-FeatureNotFound_2                 = L\u2019entit\u00e9 \u00ab\u202f{1}\u202f\u00bb n\u2019est
pas \u00e9t\u00e9 trouv\u00e9e dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
+FeatureNotFound_2                 = L\u2019entit\u00e9 \u00ab\u202f{1}\u202f\u00bb n\u2019a
pas \u00e9t\u00e9 trouv\u00e9e dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
+FoliationRepresentation           = Indique s\u2019il faut assembler les fragments de trajectoires
(lignes dans un fichier CSV) dans une entit\u00e9 unique.
 IllegalFeatureType_2              = Le format {0} ne stocke pas de donn\u00e9es de type \u00ab\u202f{1}\u202f\u00bb.
 IllegalInputTypeForReader_2       = Le lecteur {0} n\u2019accepte pas des entr\u00e9s de
type \u2018{1}\u2019.
 IllegalOutputTypeForWriter_2      = Le l\u2019encodeur {0} n\u2019accepte pas des sorties
de type \u2018{1}\u2019.

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java?rev=1815605&r1=1815604&r2=1815605&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/URIDataStore.java
[UTF-8] Fri Nov 17 17:56:36 2017
@@ -17,14 +17,17 @@
 package org.apache.sis.internal.storage;
 
 import java.net.URI;
+import java.nio.charset.Charset;
+import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
-import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.parameter.ParameterNotFoundException;
 import org.apache.sis.parameter.ParameterBuilder;
+import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.DataStoreProvider;
 import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.StorageConnector;
+import org.apache.sis.storage.IllegalOpenParameterException;
 import org.apache.sis.internal.storage.io.IOUtilities;
 
 
@@ -35,7 +38,7 @@ import org.apache.sis.internal.storage.i
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.8
  * @module
  */
@@ -69,12 +72,12 @@ public abstract class URIDataStore exten
 
     /**
      * Creates parameter value group for the current location, if non-null.
-     * This convenience method is used for public {@code DataStore} implementations that
can not extend
-     * {@code URIDataStore} directly, because this class is internal.
+     * This convenience method is used for {@link DataStore#getOpenParameters()} implementations
in public
+     * {@code DataStore} that can not extend {@code URIDataStore} directly, because this
class is internal.
      *
-     * @param provider
-     * @param location
-     * @return
+     * @param  provider  the provider of the data store for which to get open parameters.
+     * @param  location  file opened by the data store.
+     * @return parameters to be returned by {@link DataStore#getOpenParameters()}.
      *
      * @todo Verify if non-exported classes in JDK9 are hidden from Javadoc, like package-private
classes.
      *       If true, we could remove this hack and extend {@code URIDataStore} even in public
classes.
@@ -99,11 +102,19 @@ public abstract class URIDataStore exten
         /**
          * Description of the location parameter.
          */
-        public static final ParameterDescriptor<URI> LOCATION_PARAM = new ParameterBuilder()
-                .setDescription(Resources.formatInternational(Resources.Keys.DataStoreLocation))
-                .addName(LOCATION)
-                .setRequired(true)
-                .create(URI.class, null);
+        public static final ParameterDescriptor<URI> LOCATION_PARAM;
+
+        /**
+         * Description of the optional parameter for character encoding used by the data
store.
+         * This parameter is not included in the descriptor created by {@link #build(ParameterBuilder)}
+         * default implementation. It is subclass responsibility to add it if desired.
+         */
+        public static final ParameterDescriptor<Charset> ENCODING;
+        static {
+            final ParameterBuilder builder = new ParameterBuilder();
+            ENCODING       = builder.addName("encoding").setDescription(Resources.formatInternational(Resources.Keys.DataStoreEncoding)).create(Charset.class,
null);
+            LOCATION_PARAM = builder.addName( LOCATION ).setDescription(Resources.formatInternational(Resources.Keys.DataStoreLocation)).setRequired(true).create(URI.class,
null);
+        }
 
         /**
          * The parameter descriptor to be returned by {@link #getOpenParameters()}.
@@ -161,6 +172,31 @@ public abstract class URIDataStore exten
         public static ParameterDescriptorGroup descriptor(final String name) {
             return new ParameterBuilder().addName(name).createGroup(LOCATION_PARAM);
         }
+
+        /**
+         * Creates a storage connector initialized to the location declared in given parameters.
+         * This convenience method does not set any other parameters.
+         *
+         * @param  provider    the provider for which to create a storage connector (for
error messages).
+         * @param  parameters  the parameters to use for creating a storage connector.
+         * @return the storage connector initialized to the location specified in the parameters.
+         * @throws IllegalOpenParameterException if no {@value #LOCATION} parameter has been
found.
+         */
+        public static StorageConnector connector(final DataStoreProvider provider, final
ParameterValueGroup parameters)
+                throws IllegalOpenParameterException
+        {
+            ParameterNotFoundException cause = null;
+            try {
+                final Object location = parameters.parameter(LOCATION).getValue();
+                if (location != null) {
+                    return new StorageConnector(location);
+                }
+            } catch (ParameterNotFoundException e) {
+                cause = e;
+            }
+            throw new IllegalOpenParameterException(Resources.format(Resources.Keys.UndefinedParameter_2,
+                        provider.getShortName(), LOCATION), cause);
+        }
     }
 
     /**

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java?rev=1815605&r1=1815604&r2=1815605&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
[UTF-8] Fri Nov 17 17:56:36 2017
@@ -39,6 +39,7 @@ import org.opengis.referencing.crs.Tempo
 import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.feature.DefaultAttributeType;
 import org.apache.sis.feature.DefaultFeatureType;
+import org.apache.sis.feature.FoliationRepresentation;
 import org.apache.sis.referencing.CRS;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.internal.referencing.GeodeticObjectBuilder;
@@ -54,6 +55,7 @@ import org.apache.sis.geometry.GeneralEn
 import org.apache.sis.geometry.ImmutableEnvelope;
 import org.apache.sis.metadata.iso.DefaultMetadata;
 import org.apache.sis.metadata.sql.MetadataStoreException;
+import org.apache.sis.storage.DataOptionKey;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
 import org.apache.sis.storage.DataStoreReferencingException;
@@ -83,7 +85,7 @@ import org.opengis.feature.AttributeType
  * See package javadoc for more information on the syntax.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.7
  * @module
  */
@@ -226,12 +228,9 @@ final class Store extends URIDataStore 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>).
-     * @param  immediate  {@code true} for forcing the creation of a distinct {@code Feature}
instance for each line.
      * @throws DataStoreException if an error occurred while opening the stream.
      */
-    public Store(final StoreProvider provider, final StorageConnector connector, final boolean
immediate)
-            throws DataStoreException
-    {
+    public Store(final StoreProvider provider, final StorageConnector connector) throws DataStoreException
{
         super(provider, connector);
         final Reader r = connector.getStorageAs(Reader.class);
         connector.closeAllExcept(r);
@@ -241,7 +240,7 @@ final class Store extends URIDataStore i
         }
         source     = (r instanceof BufferedReader) ? (BufferedReader) r : new LineNumberReader(r);
         geometries = Geometries.implementation(connector.getOption(OptionKey.GEOMETRY_LIBRARY));
-        dissociate = immediate;
+        dissociate = FoliationRepresentation.FRAGMENTED.equals(connector.getOption(DataOptionKey.FOLIATION_REPRESENTATION));
         GeneralEnvelope envelope    = null;
         FeatureType     featureType = null;
         Foliation       foliation   = null;

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java?rev=1815605&r1=1815604&r2=1815605&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
[UTF-8] Fri Nov 17 17:56:36 2017
@@ -16,14 +16,23 @@
  */
 package org.apache.sis.internal.storage.csv;
 
+import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.parameter.ParameterDescriptor;
+import org.opengis.parameter.ParameterDescriptorGroup;
+import org.apache.sis.parameter.ParameterBuilder;
+import org.apache.sis.parameter.Parameters;
 import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.DataOptionKey;
 import org.apache.sis.storage.ProbeResult;
 import org.apache.sis.storage.StorageConnector;
+import org.apache.sis.feature.FoliationRepresentation;
+import org.apache.sis.internal.storage.Resources;
 import org.apache.sis.internal.storage.Capability;
 import org.apache.sis.internal.storage.Capabilities;
 import org.apache.sis.internal.storage.URIDataStore;
 import org.apache.sis.internal.storage.wkt.FirstKeywordPeek;
+import org.apache.sis.util.ArgumentChecks;
 
 
 /**
@@ -35,7 +44,7 @@ import org.apache.sis.internal.storage.w
  * the part of the caller. However the {@link Store} instances created by this factory are
not thread-safe.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.8
  * @module
  */
@@ -101,6 +110,19 @@ public final class StoreProvider extends
     }
 
     /**
+     * Description of the optional parameter for specifying whether the reader should assemble
distinct CSV lines
+     * into a single {@code Feature} instance forming a foliation. This is ignored if the
CSV file does not seem
+     * to contain moving features.
+     */
+    private static final ParameterDescriptor<FoliationRepresentation> FOLIATION;
+    static {
+        final ParameterBuilder builder = new ParameterBuilder();
+        FOLIATION = builder.addName("foliation")
+                .setDescription(Resources.formatInternational(Resources.Keys.FoliationRepresentation))
+                .create(FoliationRepresentation.class, FoliationRepresentation.ASSEMBLED);
+    }
+
+    /**
      * Creates a new provider.
      */
     public StoreProvider() {
@@ -138,6 +160,32 @@ public final class StoreProvider extends
      */
     @Override
     public DataStore open(final StorageConnector connector) throws DataStoreException {
-        return new Store(this, connector, false);
+        return new Store(this, connector);
+    }
+
+    /**
+     * Returns a CSV {@link Store} implementation from the given parameters.
+     *
+     * @return a data store implementation associated with this provider for the given parameters.
+     * @throws DataStoreException if an error occurred while creating the data store instance.
+     */
+    @Override
+    public DataStore open(final ParameterValueGroup parameters) throws DataStoreException
{
+        ArgumentChecks.ensureNonNull("parameter", parameters);
+        final StorageConnector connector = connector(this, parameters);
+        final Parameters pg = Parameters.castOrWrap(parameters);
+        connector.setOption(DataOptionKey.ENCODING, pg.getValue(ENCODING));
+        connector.setOption(DataOptionKey.FOLIATION_REPRESENTATION, pg.getValue(FOLIATION));
+        return new Store(this, connector);
+    }
+
+    /**
+     * Invoked by {@link #getOpenParameters()} the first time that a parameter descriptor
needs to be created.
+     *
+     * @return the parameters descriptor for CSV files.
+     */
+    @Override
+    protected ParameterDescriptorGroup build(final ParameterBuilder builder) {
+        return builder.createGroup(LOCATION_PARAM, ENCODING, FOLIATION);
     }
 }

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/package-info.java?rev=1815605&r1=1815604&r2=1815605&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/package-info.java
[UTF-8] Fri Nov 17 17:56:36 2017
@@ -53,7 +53,7 @@
  * </ul>
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.7
  * @module
  */

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java?rev=1815605&r1=1815604&r2=1815605&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStoreProvider.java
[UTF-8] Fri Nov 17 17:56:36 2017
@@ -27,7 +27,6 @@ import org.opengis.util.InternationalStr
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
-import org.opengis.parameter.ParameterNotFoundException;
 import org.apache.sis.parameter.ParameterBuilder;
 import org.apache.sis.parameter.Parameters;
 import org.apache.sis.storage.DataStore;
@@ -35,7 +34,6 @@ import org.apache.sis.storage.DataStoreP
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.ProbeResult;
-import org.apache.sis.storage.IllegalOpenParameterException;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.internal.system.Modules;
@@ -84,11 +82,18 @@ public final class FolderStoreProvider e
         final ParameterDescriptor<Path> location;
         final ParameterBuilder builder = new ParameterBuilder();
         final InternationalString remark = Resources.formatInternational(Resources.Keys.UsedOnlyIfNotEncoded);
+        ENCODING   = annotate(builder, URIDataStore.Provider.ENCODING, remark);
         LOCALE     = builder.addName("locale"  ).setDescription(Resources.formatInternational(Resources.Keys.DataStoreLocale
 )).setRemarks(remark).create(Locale.class,   null);
         TIMEZONE   = builder.addName("timezone").setDescription(Resources.formatInternational(Resources.Keys.DataStoreTimeZone)).setRemarks(remark).create(TimeZone.class,
null);
-        ENCODING   = builder.addName("encoding").setDescription(Resources.formatInternational(Resources.Keys.DataStoreEncoding)).setRemarks(remark).create(Charset.class,
 null);
-        location   = builder.addName( LOCATION ).setDescription(URIDataStore.Provider.LOCATION_PARAM.getDescription())
         .setRequired(true) .create(Path.class,     null);
-        PARAMETERS = builder.addName( NAME     ).createGroup(location, LOCALE, TIMEZONE,
ENCODING);
+        location   = new ParameterBuilder(URIDataStore.Provider.LOCATION_PARAM).create(Path.class,
null);
+        PARAMETERS = builder.addName(NAME).createGroup(location, LOCALE, TIMEZONE, ENCODING);
+    }
+
+    /**
+     * Creates a parameter descriptor equals to the given one except for the remarks which
are set to the given value.
+     */
+    private static <T> ParameterDescriptor<T> annotate(ParameterBuilder builder,
ParameterDescriptor<T> e, InternationalString remark) {
+        return builder.addName(e.getName()).setDescription(e.getDescription()).setRemarks(remark).create(e.getValueClass(),
null);
     }
 
     /**
@@ -173,22 +178,12 @@ public final class FolderStoreProvider e
     @Override
     public DataStore open(final ParameterValueGroup parameters) throws DataStoreException
{
         ArgumentChecks.ensureNonNull("parameter", parameters);
-        ParameterNotFoundException cause = null;
-        try {
-            final Object location = parameters.parameter(LOCATION).getValue();
-            if (location != null) {
-                final Parameters pg = Parameters.castOrWrap(parameters);
-                final StorageConnector connector = new StorageConnector(location);
-                connector.setOption(OptionKey.LOCALE,   pg.getValue(LOCALE));
-                connector.setOption(OptionKey.TIMEZONE, pg.getValue(TIMEZONE));
-                connector.setOption(OptionKey.ENCODING, pg.getValue(ENCODING));
-                return open(connector);
-            }
-        } catch (ParameterNotFoundException e) {
-            cause = e;
-        }
-        throw new IllegalOpenParameterException(Resources.format(Resources.Keys.UndefinedParameter_2,
-                getShortName(), LOCATION), cause);
+        final StorageConnector connector = URIDataStore.Provider.connector(this, parameters);
+        final Parameters pg = Parameters.castOrWrap(parameters);
+        connector.setOption(OptionKey.LOCALE,   pg.getValue(LOCALE));
+        connector.setOption(OptionKey.TIMEZONE, pg.getValue(TIMEZONE));
+        connector.setOption(OptionKey.ENCODING, pg.getValue(ENCODING));
+        return open(connector);
     }
 
     /**

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java?rev=1815605&r1=1815604&r2=1815605&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/package-info.java
[UTF-8] Fri Nov 17 17:56:36 2017
@@ -24,7 +24,7 @@
  * may change in incompatible ways in any future version without notice.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.3
  * @module
  */

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=1815605&r1=1815604&r2=1815605&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 Nov 17 17:56:36 2017
@@ -18,10 +18,9 @@ package org.apache.sis.storage;
 
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptorGroup;
-import org.opengis.parameter.ParameterNotFoundException;
 import org.opengis.metadata.distribution.Format;
 import org.apache.sis.internal.simple.SimpleFormat;
-import org.apache.sis.internal.storage.Resources;
+import org.apache.sis.internal.storage.URIDataStore;
 import org.apache.sis.metadata.iso.citation.DefaultCitation;
 import org.apache.sis.metadata.iso.distribution.DefaultFormat;
 import org.apache.sis.measure.Range;
@@ -287,18 +286,6 @@ public abstract class DataStoreProvider
      */
     public DataStore open(final ParameterValueGroup parameters) throws DataStoreException
{
         ArgumentChecks.ensureNonNull("parameter", parameters);
-        ParameterNotFoundException cause = null;
-        Object location;
-        try {
-            location = parameters.parameter(LOCATION).getValue();
-        } catch (ParameterNotFoundException e) {
-            location = null;
-            cause = e;
-        }
-        if (location == null) {
-            throw new IllegalOpenParameterException(Resources.format(Resources.Keys.UndefinedParameter_2,
-                    getShortName(), LOCATION), cause);
-        }
-        return open(new StorageConnector(location));
+        return open(URIDataStore.Provider.connector(this, parameters));
     }
 }

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=1815605&r1=1815604&r2=1815605&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 Nov 17 17:56:36 2017
@@ -26,7 +26,7 @@
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.3
  * @module
  */

Modified: sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java?rev=1815605&r1=1815604&r2=1815605&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java
[UTF-8] Fri Nov 17 17:56:36 2017
@@ -22,8 +22,10 @@ import java.io.StringReader;
 import org.opengis.metadata.Metadata;
 import org.opengis.metadata.extent.Extent;
 import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.apache.sis.feature.FoliationRepresentation;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.StorageConnector;
+import org.apache.sis.storage.DataOptionKey;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 import com.esri.core.geometry.Point2D;
@@ -46,7 +48,7 @@ import org.opengis.feature.AttributeType
  * Tests {@link Store}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.7
  * @module
  */
@@ -79,6 +81,15 @@ public final strictfp class StoreTest ex
     }
 
     /**
+     * Opens a CSV store on the test data for reading the lines as-is, without assembling
them in a single trajectory.
+     */
+    private static Store open() throws DataStoreException {
+        StorageConnector connector = new StorageConnector(testData());
+        connector.setOption(DataOptionKey.FOLIATION_REPRESENTATION, FoliationRepresentation.FRAGMENTED);
+        return new Store(null, connector);
+    }
+
+    /**
      * Tests {@link Store#getMetadata()}.
      *
      * @throws DataStoreException if an error occurred while parsing the data.
@@ -86,7 +97,7 @@ public final strictfp class StoreTest ex
     @Test
     public void testGetMetadata() throws DataStoreException {
         final Metadata metadata;
-        try (Store store = new Store(null, new StorageConnector(testData()), true)) {
+        try (Store store = open()) {
             metadata = store.getMetadata();
         }
         final Extent extent = getSingleton(getSingleton(metadata.getIdentificationInfo()).getExtents());
@@ -105,7 +116,7 @@ public final strictfp class StoreTest ex
      */
     @Test
     public void testStaticFeatures() throws DataStoreException {
-        try (Store store = new Store(null, new StorageConnector(testData()), true)) {
+        try (Store store = open()) {
             verifyFeatureType(store.featureType, double[].class, 1);
             assertEquals("foliation", Foliation.TIME, store.foliation);
             final Iterator<Feature> it = store.features(false).iterator();
@@ -134,7 +145,7 @@ public final strictfp class StoreTest ex
     @Test
     public void testMovingFeatures() throws DataStoreException {
         isMovingFeature = true;
-        try (Store store = new Store(null, new StorageConnector(testData()), false)) {
+        try (Store store = new Store(null, new StorageConnector(testData()))) {
             verifyFeatureType(store.featureType, Polyline.class, Integer.MAX_VALUE);
             assertEquals("foliation", Foliation.TIME, store.foliation);
             final Iterator<Feature> it = store.features(false).iterator();



Mime
View raw message