sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1804347 - in /sis/branches/JDK8/storage: sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/ sis-storage/src/main/java/org/apache/sis/internal/storage/ sis-storage/src/main/java/org/apache/sis/internal/storage/csv/ sis-storage/src/main...
Date Mon, 07 Aug 2017 16:02:24 GMT
Author: desruisseaux
Date: Mon Aug  7 16:02:24 2017
New Revision: 1804347

URL: http://svn.apache.org/viewvc?rev=1804347&view=rev
Log:
Remove FeatureStore, replaced by FeatureSet.

Added:
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java
  (with props)
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/FeatureAccess.java
      - copied, changed from r1804191, sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
Removed:
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureStore.java
Modified:
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractFeatureSet.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractResource.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureCatalogBuilder.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
    sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java?rev=1804347&r1=1804346&r2=1804347&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
[UTF-8] Mon Aug  7 16:02:24 2017
@@ -118,7 +118,10 @@ public class NetcdfStore extends DataSto
     }
 
     /**
-     * This implementation do not provide any resource yet.
+     * This implementation does not provide any resource yet.
+     *
+     * @return currently {@code null} (will be implemented in future Apache SIS version).
+     * @throws DataStoreException if an error occurred while reading the data.
      */
     @Override
     public Resource getRootResource() throws DataStoreException {

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractFeatureSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractFeatureSet.java?rev=1804347&r1=1804346&r2=1804347&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractFeatureSet.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractFeatureSet.java
[UTF-8] Mon Aug  7 16:02:24 2017
@@ -35,10 +35,10 @@ public abstract class AbstractFeatureSet
     /**
      * Creates a new resource.
      *
-     * @param owner      the data store which contains this resource.
+     * @param store      the data store which contains this resource.
      * @param listeners  the set of registered warning listeners for the data store.
      */
-    protected AbstractFeatureSet(final DataStore owner, final WarningListeners<DataStore>
listeners) {
-        super(owner, listeners);
+    protected AbstractFeatureSet(final DataStore store, final WarningListeners<DataStore>
listeners) {
+        super(store, listeners);
     }
 }

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractResource.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractResource.java?rev=1804347&r1=1804346&r2=1804347&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractResource.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractResource.java
[UTF-8] Mon Aug  7 16:02:24 2017
@@ -43,7 +43,7 @@ public abstract class AbstractResource i
     /**
      * The data store which contains this resource.
      */
-    protected final DataStore owner;
+    protected final DataStore store;
 
     /**
      * The set of registered warning listeners for the data store.
@@ -56,11 +56,11 @@ public abstract class AbstractResource i
     /**
      * Creates a new resource.
      *
-     * @param owner      the data store which contains this resource.
+     * @param store      the data store which contains this resource.
      * @param listeners  the set of registered warning listeners for the data store.
      */
-    protected AbstractResource(final DataStore owner, final WarningListeners<DataStore>
listeners) {
-        this.owner     = owner;
+    protected AbstractResource(final DataStore store, final WarningListeners<DataStore>
listeners) {
+        this.store     = store;
         this.listeners = listeners;
     }
 

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureCatalogBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureCatalogBuilder.java?rev=1804347&r1=1804346&r2=1804347&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureCatalogBuilder.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureCatalogBuilder.java
[UTF-8] Mon Aug  7 16:02:24 2017
@@ -39,7 +39,7 @@ import org.opengis.feature.FeatureType;
  * @since 0.8
  * @module
  */
-public class FeatureCatalogBuilder extends MetadataBuilder {
+public final class FeatureCatalogBuilder extends MetadataBuilder {
     /**
      * The data store for which the metadata will be created, or {@code null} if unknown.
      * This is used for producing error message if an exception is thrown.

Added: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java?rev=1804347&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java
(added)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java
[UTF-8] Mon Aug  7 16:02:24 2017
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.storage.csv;
+
+import org.opengis.metadata.Metadata;
+import org.apache.sis.storage.DataStore;
+import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.internal.storage.AbstractFeatureSet;
+import org.apache.sis.util.logging.WarningListeners;
+
+// Branch-dependent imports
+import java.util.stream.Stream;
+import org.opengis.feature.Feature;
+import org.opengis.feature.FeatureType;
+
+
+/**
+ * Provides access to feature instances.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 0.8
+ * @since   0.8
+ * @module
+ */
+final class FeatureAccess extends AbstractFeatureSet {
+    /**
+     * Creates a {@code FeatureSet} for the given CSV store.
+     */
+    FeatureAccess(final Store store, final WarningListeners<DataStore> listeners) {
+        super(store, listeners);
+    }
+
+    /**
+     * Returns information about the dataset as a whole.
+     *
+     * @return information about the dataset, or {@code null} if none.
+     * @throws DataStoreException if an error occurred while reading the metadata.
+     */
+    @Override
+    public Metadata getMetadata() throws DataStoreException {
+        return store.getMetadata();
+    }
+
+    /**
+     * Returns the type of features in the CSV file. The feature type name will be the value
+     * specified at the following path (only one such value exists for a CSV data store):
+     *
+     * <blockquote>
+     * {@link #getMetadata()} /
+     * {@link org.apache.sis.metadata.iso.DefaultMetadata#getContentInfo() contentInfo} /
+     * {@link org.apache.sis.metadata.iso.content.DefaultFeatureCatalogueDescription#getFeatureTypeInfo()
featureTypes} /
+     * {@link org.apache.sis.metadata.iso.content.DefaultFeatureTypeInfo#getFeatureTypeName()
featureTypeName}
+     * </blockquote>
+     *
+     * @return type of features in the CSV file.
+     */
+    @Override
+    public FeatureType getType() {
+        return ((Store) store).featureType;
+    }
+
+    /**
+     * Returns the stream of features.
+     *
+     * @param  parallel  {@code true} for a parallel stream, or {@code false} for a sequential
stream.
+     * @return a stream over all features in the CSV file.
+     * @throws DataStoreException if an error occurred while creating the feature stream.
+     */
+    @Override
+    public Stream<Feature> features(final boolean parallel) throws DataStoreException
{
+        return ((Store) store).features(parallel);
+    }
+}

Propchange: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java?rev=1804347&r1=1804346&r2=1804347&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
[UTF-8] Mon Aug  7 16:02:24 2017
@@ -45,17 +45,16 @@ import org.apache.sis.internal.referenci
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.internal.storage.MetadataBuilder;
 import org.apache.sis.internal.storage.io.IOUtilities;
-import org.apache.sis.internal.storage.FeatureStore;
 import org.apache.sis.internal.feature.Geometries;
 import org.apache.sis.internal.feature.MovingFeature;
 import org.apache.sis.internal.storage.Resources;
 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.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
 import org.apache.sis.storage.DataStoreReferencingException;
-import org.apache.sis.storage.IllegalNameException;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.setup.OptionKey;
 import org.apache.sis.util.ArraysExt;
@@ -84,7 +83,7 @@ import org.opengis.feature.AttributeType
  * @since   0.7
  * @module
  */
-public final class Store extends FeatureStore {
+public final class Store extends DataStore {
     /**
      * The character at the beginning of lines to ignore in the header.
      * Note that this is not part of OGC Moving Feature Specification.
@@ -605,36 +604,13 @@ public final class Store extends Feature
     }
 
     /**
-     * This implementation do not provide any resource yet.
-     */
-    @Override
-    public Resource getRootResource() throws DataStoreException {
-        return null;
-    }
-
-    /**
-     * Returns the feature type for the given name. The {@code name} argument should be the
-     * value specified at the following path (only one such value exists for a CSV data store):
-     *
-     * <blockquote>
-     * {@link #getMetadata()} /
-     * {@link org.apache.sis.metadata.iso.DefaultMetadata#getContentInfo() contentInfo} /
-     * {@link org.apache.sis.metadata.iso.content.DefaultFeatureCatalogueDescription#getFeatureTypeInfo()
featureTypes} /
-     * {@link org.apache.sis.metadata.iso.content.DefaultFeatureTypeInfo#getFeatureTypeName()
featureTypeName}
-     * </blockquote>
-     *
-     * @param  name  the name of the feature type to get.
-     * @return the feature type of the given name (never {@code null}).
-     * @throws IllegalNameException if the given name was not found.
+     * Returns the {@code FeatureSet} from which all features in this data store can be accessed.
      *
-     * @since 0.8
+     * @return the starting point of all features in this data store.
      */
     @Override
-    public FeatureType getFeatureType(String name) throws IllegalNameException {
-        if (featureType.getName().toString().equals(name)) {
-            return featureType;
-        }
-        throw new IllegalNameException(getLocale(), getDisplayName(), name);
+    public Resource getRootResource() {
+        return new FeatureAccess(this, listeners);
     }
 
     /**
@@ -647,8 +623,7 @@ public final class Store extends Feature
      * @todo Needs to reset the position when doing another pass on the features.
      * @todo If sequential order, publish Feature as soon as identifier changed.
      */
-    @Override
-    public synchronized Stream<Feature> features(final boolean parallel) throws DataStoreException
{
+    final synchronized Stream<Feature> features(final boolean parallel) throws DataStoreException
{
         /*
          * If the user asks for one feature instance per line, then we can return a FeatureIter
instance directly.
          * Since each feature is fully constructed from a single line and each line are read
atomically, we can

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java?rev=1804347&r1=1804346&r2=1804347&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
[UTF-8] Mon Aug  7 16:02:24 2017
@@ -203,10 +203,14 @@ public abstract class DataStore implemen
      * {@link org.apache.sis.metadata.iso.identification.AbstractIdentification#getCitation()
citation} /
      * {@link org.apache.sis.metadata.iso.citation.DefaultCitation#getIdentifiers() identifier}</blockquote>
      *
-     * The default implementation verifies the {@linkplain #getRootResource() root resource},
then iterates over
+     * Implementation may also accept aliases for convenience. For example if the full name
of a resource
+     * is {@code "foo:bar"}, then this method may accept {@code "bar"} as a synonymous of
{@code "foo:bar"}
+     * provided that it does not introduce ambiguity.
+     *
+     * <p>The default implementation verifies the {@linkplain #getRootResource() root
resource}, then iterates over
      * components of {@link Aggregate}s. If a match is found without ambiguity, the associated
resource is returned.
      * Otherwise an exception is thrown. Subclasses are encouraged to override this method
with a more efficient
-     * implementation.
+     * implementation.</p>
      *
      * @param  identifier  identifier of the resource to fetch. Must be non-null.
      * @return resource associated to the given identifier (never {@code null}).

Copied: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/FeatureAccess.java
(from r1804191, sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/FeatureAccess.java?p2=sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/FeatureAccess.java&p1=sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java&r1=1804191&r2=1804347&rev=1804347&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/FeatureAccess.java
[UTF-8] Mon Aug  7 16:02:24 2017
@@ -16,39 +16,20 @@
  */
 package org.apache.sis.internal.storage.gpx;
 
-import java.net.URISyntaxException;
-import org.opengis.util.NameFactory;
-import org.opengis.util.FactoryException;
 import org.opengis.metadata.Metadata;
-import org.opengis.metadata.distribution.Format;
-import org.apache.sis.storage.StorageConnector;
+import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.DataStoreContentException;
-import org.apache.sis.storage.ConcurrentReadException;
-import org.apache.sis.storage.IllegalNameException;
-import org.apache.sis.internal.system.DefaultFactories;
-import org.apache.sis.internal.storage.xml.stream.StaxDataStore;
-import org.apache.sis.util.collection.BackingStoreException;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.Version;
-import org.apache.sis.setup.OptionKey;
-import org.apache.sis.setup.GeometryLibrary;
-import org.apache.sis.util.iso.DefaultNameFactory;
-import org.apache.sis.util.iso.SimpleInternationalString;
-import org.apache.sis.metadata.iso.citation.DefaultCitation;
-import org.apache.sis.metadata.iso.distribution.DefaultFormat;
+import org.apache.sis.internal.storage.AbstractFeatureSet;
+import org.apache.sis.util.logging.WarningListeners;
 
 // Branch-dependent imports
 import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-import java.io.UncheckedIOException;
-import org.apache.sis.storage.Resource;
 import org.opengis.feature.Feature;
 import org.opengis.feature.FeatureType;
 
 
 /**
- * A data store backed by GPX files.
+ * Provides access to feature instances.
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
@@ -56,93 +37,12 @@ import org.opengis.feature.FeatureType;
  * @since   0.8
  * @module
  */
-public final class Store extends StaxDataStore {
+final class FeatureAccess extends AbstractFeatureSet {
     /**
-     * Version of the GPX file, or {@code null} if unknown.
+     * Creates a {@code FeatureSet} for the given GPX store.
      */
-    Version version;
-
-    /**
-     * The metadata, or {@code null} if not yet parsed.
-     */
-    private Metadata metadata;
-
-    /**
-     * If a reader has been created for parsing the {@linkplain #metadata} and has not yet
been used
-     * for iterating over the features, that reader. Otherwise {@code null}.
-     */
-    private Reader reader;
-
-    /**
-     * The {@link org.opengis.feature.FeatureType} for routes, tracks, way points, <i>etc</i>.
-     * Currently always {@link Types#DEFAULT}, but we use a field for keeping {@code Reader}
-     * and {@code Writer} ready to handle profiles or extensions.
-     */
-    final Types types;
-
-    /**
-     * Creates a new GPX store from the given file, URL or stream object.
-     * This constructor invokes {@link StorageConnector#closeAllExcept(Object)},
-     * keeping open only the needed resource.
-     *
-     * @param  provider   the provider of this data store, 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 GPX file.
-     */
-    public Store(final StoreProvider provider, final StorageConnector connector) throws DataStoreException
{
-        super(provider, connector);
-        final GeometryLibrary library = connector.getOption(OptionKey.GEOMETRY_LIBRARY);
-        if (library == null || Types.DEFAULT.geometries.library == library) {
-            types = Types.DEFAULT;
-        } else try {
-            types = new Types(DefaultFactories.forBuildin(NameFactory.class, DefaultNameFactory.class),
null, library);
-        } catch (FactoryException e) {
-            throw new DataStoreException(e);
-        }
-    }
-
-    /**
-     * Returns a more complete description of the GPX format.
-     * The format will be part of the metadata returned by {@link #getMetadata()}.
-     *
-     * @see StoreProvider#getFormat()
-     * @see org.apache.sis.internal.storage.gpx.Metadata#getResourceFormats()
-     */
-    final Format getFormat() {
-        assert Thread.holdsLock(this);
-        Format format = ((StoreProvider) provider).getFormat(listeners);
-        if (version != null) {
-            final DefaultFormat df = new DefaultFormat(format);
-            final DefaultCitation citation = new DefaultCitation(df.getFormatSpecificationCitation());
-            citation.setEdition(new SimpleInternationalString(version.toString()));
-            df.setFormatSpecificationCitation(citation);
-            format = df;
-        }
-        return format;
-    }
-
-    /**
-     * Returns the GPX file version.
-     *
-     * @return the GPX file version, or {@code null} if none.
-     * @throws DataStoreException if an error occurred while reading the metadata.
-     */
-    public synchronized Version getVersion() throws DataStoreException {
-        if (version == null) {
-            getMetadata();
-        }
-        return version;
-    }
-
-    /**
-     * Sets the version of the file to write.
-     *
-     * @param  version  the target GPX file format.
-     * @throws DataStoreException if an error occurred while setting the format.
-     */
-    public synchronized void setVersion(final Version version) throws DataStoreException
{
-        ArgumentChecks.ensureNonNull("version", version);
-        this.version = version;
+    FeatureAccess(final Store store, final WarningListeners<DataStore> listeners) {
+        super(store, listeners);
     }
 
     /**
@@ -152,40 +52,18 @@ public final class Store extends StaxDat
      * @throws DataStoreException if an error occurred while reading the metadata.
      */
     @Override
-    public synchronized Metadata getMetadata() throws DataStoreException {
-        if (metadata == null) try {
-            reader   = new Reader(this);
-            version  = reader.initialize(true);
-            metadata = reader.getMetadata();
-        } catch (DataStoreException e) {
-            throw e;
-        } catch (URISyntaxException | RuntimeException e) {
-            throw new DataStoreContentException(e);
-        } catch (Exception e) {
-            throw new DataStoreException(e);
-        }
-        return metadata;
-    }
-
-    /**
-     * This implementation do not provide any resource yet.
-     */
-    @Override
-    public Resource getRootResource() throws DataStoreException {
-        return null;
+    public Metadata getMetadata() throws DataStoreException {
+        return store.getMetadata();
     }
 
     /**
-     * Returns the feature type for the given name. The {@code name} argument should be the
result of calling
-     * {@link org.opengis.util.GenericName#toString()} on the name of one of the feature
types in this data store.
+     * Returns the base type of all GPX types.
      *
-     * @param  name  the name or alias of the feature type to get.
-     * @return the feature type of the given name or alias (never {@code null}).
-     * @throws IllegalNameException if the given name was not found or is ambiguous.
+     * @return base type of all GPX types.
      */
     @Override
-    public FeatureType getFeatureType(final String name) throws IllegalNameException {
-        return types.names.get(this, name);
+    public FeatureType getType() {
+        return ((Store) store).types.parent;
     }
 
     /**
@@ -196,89 +74,7 @@ public final class Store extends StaxDat
      * @throws DataStoreException if an error occurred while creating the feature stream.
      */
     @Override
-    public synchronized Stream<Feature> features(final boolean parallel) throws DataStoreException
{
-        Reader r = reader;
-        reader = null;
-        if (r == null) try {
-            r = new Reader(this);
-            version = r.initialize(false);
-        } catch (DataStoreException e) {
-            throw e;
-        } catch (URISyntaxException | RuntimeException e) {
-            throw new DataStoreContentException(e);
-        } catch (Exception e) {
-            throw new DataStoreException(e);
-        }
-        final Stream<Feature> features = StreamSupport.stream(r, false);
-        return features.onClose(r);
-    }
-
-    /**
-     * Replaces the content of this GPX file by the given metadata and features.
-     *
-     * @param  metadata  the metadata to write, or {@code null} if none.
-     * @param  features  the features to write, or {@code null} if none.
-     * @throws ConcurrentReadException if the {@code features} stream was provided by this
data store.
-     * @throws DataStoreException if an error occurred while writing the data.
-     */
-    public synchronized void write(final Metadata metadata, final Stream<? extends Feature>
features)
-            throws DataStoreException
-    {
-        try {
-            /*
-             * If we created a reader for reading metadata, we need to close that reader
now otherwise the call
-             * to 'new Writer(…)' will fail.  Note that if that reader was in use by someone
else, the 'reader'
-             * field would be null and the 'new Writer(…)' call should detect that a reader
is in use somewhere.
-             */
-            final Reader r = reader;
-            if (r != null) {
-                reader = null;
-                r.close();
-            }
-            /*
-             * Get the writer if no read or other write operation is in progress, then write
the data.
-             */
-            try (Writer writer = new Writer(this, org.apache.sis.internal.storage.gpx.Metadata.castOrCopy(metadata,
locale))) {
-                writer.writeStartDocument();
-                if (features != null) {
-                    features.forEachOrdered(writer);
-                }
-                writer.writeEndDocument();
-            }
-        } catch (BackingStoreException e) {
-            final Throwable cause = e.getCause();
-            if (cause instanceof DataStoreException) {
-                throw (DataStoreException) cause;
-            }
-            throw new DataStoreException(e.getLocalizedMessage(), cause);
-        } catch (Exception e) {
-            if (e instanceof UncheckedIOException) {
-                e = ((UncheckedIOException) e).getCause();
-            }
-            throw new DataStoreException(e);
-        }
-    }
-
-    /**
-     * Closes this data store and releases any underlying resources.
-     *
-     * @throws DataStoreException if an error occurred while closing this data store.
-     */
-    @Override
-    public synchronized void close() throws DataStoreException {
-        final Reader r = reader;
-        reader = null;
-        if (r != null) try {
-            r.close();
-        } catch (Exception e) {
-            final DataStoreException ds = new DataStoreException(e);
-            try {
-                super.close();
-            } catch (DataStoreException s) {
-                ds.addSuppressed(s.getCause());
-            }
-            throw ds;
-        }
-        super.close();
+    public Stream<Feature> features(final boolean parallel) throws DataStoreException
{
+        return ((Store) store).features();
     }
 }

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java?rev=1804347&r1=1804346&r2=1804347&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
[UTF-8] Mon Aug  7 16:02:24 2017
@@ -21,6 +21,7 @@ import org.opengis.util.NameFactory;
 import org.opengis.util.FactoryException;
 import org.opengis.metadata.Metadata;
 import org.opengis.metadata.distribution.Format;
+import org.apache.sis.storage.Resource;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
@@ -42,7 +43,6 @@ import org.apache.sis.metadata.iso.distr
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 import java.io.UncheckedIOException;
-import org.apache.sis.storage.Resource;
 import org.opengis.feature.Feature;
 import org.opengis.feature.FeatureType;
 
@@ -168,11 +168,13 @@ public final class Store extends StaxDat
     }
 
     /**
-     * This implementation do not provide any resource yet.
+     * Returns the {@code FeatureSet} from which all features in this data store can be accessed.
+     *
+     * @return the starting point of all features in this data store.
      */
     @Override
-    public Resource getRootResource() throws DataStoreException {
-        return null;
+    public Resource getRootResource() {
+        return new FeatureAccess(this, listeners);
     }
 
     /**
@@ -182,21 +184,22 @@ public final class Store extends StaxDat
      * @param  name  the name or alias of the feature type to get.
      * @return the feature type of the given name or alias (never {@code null}).
      * @throws IllegalNameException if the given name was not found or is ambiguous.
+     *
+     * @deprecated We are not sure yet if we will keep this method. Decision is pending acquisition
of
+     *             more experience with the API proposed by {@link org.apache.sis.storage.FeatureSet}.
      */
-    @Override
-    public FeatureType getFeatureType(final String name) throws IllegalNameException {
+    @Deprecated
+    final FeatureType getFeatureType(final String name) throws IllegalNameException {
         return types.names.get(this, name);
     }
 
     /**
      * Returns the stream of features.
      *
-     * @param  parallel  ignored in current implementation.
      * @return a stream over all features in the XML file.
      * @throws DataStoreException if an error occurred while creating the feature stream.
      */
-    @Override
-    public synchronized Stream<Feature> features(final boolean parallel) throws DataStoreException
{
+    final synchronized Stream<Feature> features() throws DataStoreException {
         Reader r = reader;
         reader = null;
         if (r == null) try {

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java?rev=1804347&r1=1804346&r2=1804347&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java
[UTF-8] Mon Aug  7 16:02:24 2017
@@ -64,6 +64,11 @@ import org.opengis.feature.FeatureType;
  */
 final class Types {
     /**
+     * The parent of all other feature types.
+     */
+    final FeatureType parent;
+
+    /**
      * Way point GPX feature type.
      */
     final FeatureType wayPoint;
@@ -91,7 +96,11 @@ final class Types {
     /**
      * Binding from names to feature type instances.
      * Shall not be modified after construction.
+     *
+     * @deprecated We are not sure yet if we will keep this field. Decision is pending acquisition
of
+     *             more experience with the API proposed by {@link org.apache.sis.storage.FeatureSet}.
      */
+    @Deprecated
     final FeatureNaming<FeatureType> names;
 
     /**
@@ -143,7 +152,7 @@ final class Types {
         final FeatureTypeBuilder builder = new FeatureTypeBuilder(factory, library, locale);
         builder.setNameSpace(Tags.PREFIX).setName("GPXEntity").setAbstract(true);
         builder.addAttribute(Integer.class).setName(AttributeConvention.IDENTIFIER_PROPERTY);
-        final FeatureType parent = builder.build();
+        parent = builder.build();
         /*
          * WayPoint ⇾ GPXEntity
          * ┌──────────────────┬────────────────┬────────────────────────┬─────────────┐

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java?rev=1804347&r1=1804346&r2=1804347&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
[UTF-8] Mon Aug  7 16:02:24 2017
@@ -38,7 +38,6 @@ import org.apache.sis.setup.OptionKey;
 import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.internal.storage.FeatureStore;
 import org.apache.sis.internal.storage.io.ChannelFactory;
 import org.apache.sis.internal.storage.io.IOUtilities;
 import org.apache.sis.internal.storage.io.Markable;
@@ -65,7 +64,7 @@ import org.apache.sis.util.Debug;
  * @since   0.8
  * @module
  */
-public abstract class StaxDataStore extends FeatureStore {
+public abstract class StaxDataStore extends DataStore {
     /**
      * The locale to use for locale-sensitive data (<strong>not</strong> for
logging or warning messages),
      * or {@code null} if unspecified.

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java?rev=1804347&r1=1804346&r2=1804347&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java
[UTF-8] Mon Aug  7 16:02:24 2017
@@ -224,7 +224,7 @@ public final strictfp class ReaderTest e
         try (Store reader = create("1.0/waypoint.xml")) {
             verifyAlmostEmptyMetadata((Metadata) reader.getMetadata());
             assertEquals("version", StoreProvider.V1_0, reader.getVersion());
-            try (Stream<Feature> features = reader.features(false)) {
+            try (Stream<Feature> features = reader.features()) {
                 final Iterator<Feature> it = features.iterator();
                 verifyPoint(it.next(), 0, false);
                 verifyPoint(it.next(), 1, false);
@@ -245,7 +245,7 @@ public final strictfp class ReaderTest e
         try (Store reader = create("1.1/waypoint.xml")) {
             verifyAlmostEmptyMetadata((Metadata) reader.getMetadata());
             assertEquals("version", StoreProvider.V1_1, reader.getVersion());
-            try (Stream<Feature> features = reader.features(false)) {
+            try (Stream<Feature> features = reader.features()) {
                 final Iterator<Feature> it = features.iterator();
                 verifyPoint(it.next(), 0, true);
                 verifyPoint(it.next(), 1, true);
@@ -266,7 +266,7 @@ public final strictfp class ReaderTest e
         try (Store reader = create("1.0/route.xml")) {
             verifyAlmostEmptyMetadata((Metadata) reader.getMetadata());
             assertEquals("version", StoreProvider.V1_0, reader.getVersion());
-            try (Stream<Feature> features = reader.features(false)) {
+            try (Stream<Feature> features = reader.features()) {
                 final Iterator<Feature> it = features.iterator();
                 verifyRoute(it.next(), false, 1);
                 verifyEmpty(it.next(), "rtept");
@@ -295,7 +295,7 @@ public final strictfp class ReaderTest e
      * This verification is shared by {@link #testRoute110()} and {@link #testSequentialReads()}.
      */
     static void verifyRoute110(final Store reader) throws DataStoreException {
-        try (Stream<Feature> features = reader.features(false)) {
+        try (Stream<Feature> features = reader.features()) {
             final Iterator<Feature> it = features.iterator();
             verifyRoute(it.next(), true, 3);
             verifyEmpty(it.next(), "rtept");
@@ -373,7 +373,7 @@ public final strictfp class ReaderTest e
         try (Store reader = create("1.0/track.xml")) {
             verifyAlmostEmptyMetadata((Metadata) reader.getMetadata());
             assertEquals("version", StoreProvider.V1_0, reader.getVersion());
-            try (Stream<Feature> features = reader.features(false)) {
+            try (Stream<Feature> features = reader.features()) {
                 final Iterator<Feature> it = features.iterator();
                 verifyTrack(it.next(), false, 1);
                 verifyEmpty(it.next(), "trkseg");
@@ -393,7 +393,7 @@ public final strictfp class ReaderTest e
         try (Store reader = create("1.1/track.xml")) {
             verifyAlmostEmptyMetadata((Metadata) reader.getMetadata());
             assertEquals("version", StoreProvider.V1_1, reader.getVersion());
-            try (Stream<Feature> features = reader.features(false)) {
+            try (Stream<Feature> features = reader.features()) {
                 final Iterator<Feature> it = features.iterator();
                 verifyTrack(it.next(), true, 3);
                 verifyEmpty(it.next(), "trkseg");
@@ -610,13 +610,13 @@ public final strictfp class ReaderTest e
     @DependsOnMethod("testSequentialReads")
     public void testConcurrentReads() throws DataStoreException {
         try (Store reader = createFromURL()) {
-            final Stream<Feature>   f1 = reader.features(false);
+            final Stream<Feature>   f1 = reader.features();
             final Iterator<Feature> i1 = f1.iterator();
             verifyRoute(i1.next(), true, 3);
-            final Stream<Feature>   f2 = reader.features(false);
+            final Stream<Feature>   f2 = reader.features();
             final Iterator<Feature> i2 = f2.iterator();
             verifyEmpty(i1.next(), "rtept");
-            final Stream<Feature>   f3 = reader.features(false);
+            final Stream<Feature>   f3 = reader.features();
             final Iterator<Feature> i3 = f3.iterator();
             verifyRoute(i2.next(), true, 3);
             verifyRoute(i3.next(), true, 3);



Mime
View raw message