sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1807784 - in /sis/branches/JDK8: core/sis-utility/src/main/java/org/apache/sis/util/logging/ storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ storage/sis...
Date Fri, 08 Sep 2017 16:52:48 GMT
Author: desruisseaux
Date: Fri Sep  8 16:52:48 2017
New Revision: 1807784

URL: http://svn.apache.org/viewvc?rev=1807784&view=rev
Log:
Avoid the reflection hack in AbstractResource.
Make netCDF FeatureSet accessible from public API.

Removed:
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractDataSet.java
Modified:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/FeaturesInfo.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/FeaturesWrapper.java
    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/folder/FolderAggregate.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStore.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java?rev=1807784&r1=1807783&r2=1807784&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
[UTF-8] Fri Sep  8 16:52:48 2017
@@ -120,6 +120,18 @@ public class WarningListeners<S> impleme
     }
 
     /**
+     * Returns the source declared source of warnings.
+     * This value is specified at construction time.
+     *
+     * @return the declared source of warnings.
+     *
+     * @since 0.8
+     */
+    public S getSource() {
+        return source;
+    }
+
+    /**
      * The locale to use for formatting warning messages, or {@code null} for the default
locale.
      * If the {@code source} object given to the constructor implements the {@link Localized}
interface,
      * then this method delegates to its {@code getLocale()} method. Otherwise this method
returns {@code null}.

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java?rev=1807784&r1=1807783&r2=1807784&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/DiscreteSampling.java
[UTF-8] Fri Sep  8 16:52:48 2017
@@ -16,12 +16,13 @@
  */
 package org.apache.sis.internal.netcdf;
 
+import org.opengis.metadata.Metadata;
+import org.apache.sis.storage.DataStore;
 import org.apache.sis.setup.GeometryLibrary;
 import org.apache.sis.internal.feature.Geometries;
-
-// Branch-dependent imports
-import java.util.stream.Stream;
-import org.opengis.feature.Feature;
+import org.apache.sis.internal.storage.AbstractFeatureSet;
+import org.apache.sis.util.logging.WarningListeners;
+import org.apache.sis.util.resources.Errors;
 
 
 /**
@@ -35,7 +36,7 @@ import org.opengis.feature.Feature;
  * @since   0.8
  * @module
  */
-public abstract class DiscreteSampling {
+public abstract class DiscreteSampling extends AbstractFeatureSet {
     /**
      * The factory to use for creating geometries.
      */
@@ -44,17 +45,33 @@ public abstract class DiscreteSampling {
     /**
      * Creates a new discrete sampling parser.
      *
-     * @param  library  the library for geometric objects, or {@code null} for the default.
+     * @param  library    the library for geometric objects, or {@code null} for the default.
+     * @param  listeners  the set of registered warning listeners for the data store.
      * @throws IllegalArgumentException if the given library is non-null but not available.
      */
-    protected DiscreteSampling(final GeometryLibrary library) {
+    protected DiscreteSampling(final GeometryLibrary library, final WarningListeners<DataStore>
listeners) {
+        super(listeners);
         factory = Geometries.implementation(library);
     }
 
     /**
-     * Returns the stream of features.
+     * Returns information about this resource.
+     *
+     * @return information about this resource, or {@code null} if none.
+     *
+     * @todo Not yet implemented.
+     */
+    @Override
+    public Metadata getMetadata() {
+        return null;
+    }
+
+    /**
+     * Returns the error message for a file that can not be read.
      *
-     * @return the stream of features.
+     * @return default error message to use in exceptions.
      */
-    public abstract Stream<Feature> features();
+    protected final String canNotReadFile() {
+        return Errors.getResources(getLocale()).getString(Errors.Keys.CanNotRead_1, getStoreName());
+    }
 }

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/FeaturesInfo.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/FeaturesInfo.java?rev=1807784&r1=1807783&r2=1807784&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/FeaturesInfo.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/FeaturesInfo.java
[UTF-8] Fri Sep  8 16:52:48 2017
@@ -28,10 +28,12 @@ import org.apache.sis.internal.netcdf.Da
 import org.apache.sis.internal.netcdf.DiscreteSampling;
 import org.apache.sis.internal.netcdf.Resources;
 import org.apache.sis.internal.feature.MovingFeature;
+import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.feature.DefaultFeatureType;
 import org.apache.sis.feature.DefaultAttributeType;
 import org.apache.sis.util.collection.BackingStoreException;
+import org.apache.sis.util.logging.WarningListeners;
 import org.apache.sis.setup.GeometryLibrary;
 import ucar.nc2.constants.CF;
 
@@ -94,14 +96,15 @@ final class FeaturesInfo extends Discret
      * @param  counts       the count of instances per feature.
      * @param  identifiers  the feature identifiers.
      * @param  library      the library for geometric objects, or {@code null} for the default.
+     * @param  listeners    the set of registered warning listeners for the data store.
      * @throws IllegalArgumentException if the given library is non-null but not available.
      */
     @SuppressWarnings("rawtypes")                               // Because of generic array
creation.
     private FeaturesInfo(final Vector counts, final VariableInfo identifiers, final VariableInfo
time,
             final Collection<VariableInfo> coordinates, final Collection<VariableInfo>
properties,
-            final GeometryLibrary library)
+            final GeometryLibrary library, final WarningListeners<DataStore> listeners)
     {
-        super(library);
+        super(library, listeners);
         this.counts      = counts;
         this.identifiers = identifiers;
         this.coordinates = coordinates.toArray(new VariableInfo[coordinates.size()]);
@@ -270,8 +273,8 @@ search: for (final VariableInfo counts :
                     }
                     final VariableInfo time = coordinates.remove("T");
                     if (time != null) {
-                        features.add(new FeaturesInfo(counts.read().compress(0), identifiers,
-                                time, coordinates.values(), properties, decoder.geomlib));
+                        features.add(new FeaturesInfo(counts.read(), identifiers, time, coordinates.values(),
+                                properties, decoder.geomlib, decoder.listeners));
                     }
                 }
             }
@@ -280,15 +283,25 @@ search: for (final VariableInfo counts :
     }
 
     /**
+     * Returns the type of all features to be read by this {@code FeaturesInfo}.
+     */
+    @Override
+    public FeatureType getType() {
+        return type;
+    }
+
+    /**
      * Returns the stream of features.
+     *
+     * @param  parallel  ignored, since current version does not support parallelism.
      */
     @Override
-    public Stream<Feature> features() {
+    public Stream<Feature> features(boolean parallel) {
         return StreamSupport.stream(new Iter(), false);
     }
 
     /**
-     * Implementation of the iterator returned by {@link #features()}.
+     * Implementation of the iterator returned by {@link #features(boolean)}.
      */
     private final class Iter implements Spliterator<Feature> {
         /**
@@ -382,11 +395,4 @@ search: for (final VariableInfo counts :
             return ORDERED | NONNULL | IMMUTABLE | SIZED;
         }
     }
-
-    /**
-     * Returns the error message for a file that can not be read.
-     */
-    final String canNotReadFile() {
-        return null;    // TODO
-    }
 }

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java?rev=1807784&r1=1807783&r2=1807784&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java
[UTF-8] Fri Sep  8 16:52:48 2017
@@ -385,10 +385,14 @@ final class VariableInfo extends Variabl
                 throw new DataStoreContentException(unknownType());
             }
             long length = 1;
+            boolean overflow = false;
             for (final Dimension dimension : dimensions) {
                 length *= dimension.length();
+                if (length > Integer.MAX_VALUE) {
+                    overflow = true;
+                }
             }
-            if (length > Integer.MAX_VALUE) {
+            if (overflow) {
                 throw new DataStoreContentException(Errors.format(Errors.Keys.ExcessiveListSize_2,
name, length));
             }
             final int dimension = dimensions.length;

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java?rev=1807784&r1=1807783&r2=1807784&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
[UTF-8] Fri Sep  8 16:52:48 2017
@@ -380,7 +380,7 @@ public final class DecoderWrapper extend
         final FeaturesWrapper[] wrappers = new FeaturesWrapper[(fc != null) ? fc.size() :
0];
         try {
             for (int i=0; i<wrappers.length; i++) {
-                wrappers[i] = new FeaturesWrapper(fc.get(i), geomlib);
+                wrappers[i] = new FeaturesWrapper(fc.get(i), geomlib, listeners);
             }
         } catch (IllegalArgumentException e) {
             throw new DataStoreException(e.getLocalizedMessage(), e);

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/FeaturesWrapper.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/FeaturesWrapper.java?rev=1807784&r1=1807783&r2=1807784&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/FeaturesWrapper.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/FeaturesWrapper.java
[UTF-8] Fri Sep  8 16:52:48 2017
@@ -16,13 +16,16 @@
  */
 package org.apache.sis.internal.netcdf.ucar;
 
+import org.apache.sis.storage.DataStore;
 import org.apache.sis.setup.GeometryLibrary;
 import org.apache.sis.internal.netcdf.DiscreteSampling;
+import org.apache.sis.util.logging.WarningListeners;
 import ucar.nc2.ft.FeatureCollection;
 
 // Branch-dependent imports
 import java.util.stream.Stream;
 import org.opengis.feature.Feature;
+import org.opengis.feature.FeatureType;
 
 
 /**
@@ -42,20 +45,25 @@ final class FeaturesWrapper extends Disc
     /**
      * Creates a new discrete sampling parser.
      *
-     * @param  factory  the library for geometric objects, or {@code null} for the default.
+     * @param  factory    the library for geometric objects, or {@code null} for the default.
+     * @param  listeners  the set of registered warning listeners for the data store.
      * @throws IllegalArgumentException if the given library is non-null but not available.
      */
-    FeaturesWrapper(final FeatureCollection features, final GeometryLibrary factory) {
-        super(factory);
+    FeaturesWrapper(final FeatureCollection features, final GeometryLibrary factory, final
WarningListeners<DataStore> listeners) {
+        super(factory, listeners);
         this.features = features;
     }
 
+    @Override
+    public FeatureType getType() {
+        throw new UnsupportedOperationException();      // TODO
+    }
 
     /**
      * Returns the stream of features.
      */
     @Override
-    public Stream<Feature> features() {
+    public Stream<Feature> features(boolean parallel) {
         throw new UnsupportedOperationException();      // TODO
     }
 }

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=1807784&r1=1807783&r2=1807784&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] Fri Sep  8 16:52:48 2017
@@ -18,6 +18,7 @@ package org.apache.sis.storage.netcdf;
 
 import java.io.IOException;
 import java.net.URI;
+import java.util.List;
 import java.util.Collection;
 import org.opengis.metadata.Metadata;
 import org.opengis.parameter.ParameterValueGroup;
@@ -29,6 +30,7 @@ import org.apache.sis.storage.StorageCon
 import org.apache.sis.storage.Aggregate;
 import org.apache.sis.internal.netcdf.Decoder;
 import org.apache.sis.internal.storage.URIDataStore;
+import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.metadata.ModifiableMetadata;
 import org.apache.sis.setup.OptionKey;
 import org.apache.sis.storage.Resource;
@@ -67,6 +69,13 @@ public class NetcdfStore extends DataSto
     private Metadata metadata;
 
     /**
+     * The data (raster or features) found in the netCDF file. This list is created when
first needed.
+     *
+     * @see #components()
+     */
+    private List<Resource> components;
+
+    /**
      * Creates a new NetCDF store from the given file, URL, stream or {@link ucar.nc2.NetcdfFile}
object.
      * This constructor invokes {@link StorageConnector#closeAllExcept(Object)}, keeping
open only the
      * needed resource.
@@ -172,8 +181,14 @@ public class NetcdfStore extends DataSto
      * @since 0.8
      */
     @Override
-    public Collection<Resource> components() throws DataStoreException {
-        throw new UnsupportedOperationException("Not supported yet."); //To change body of
generated methods, choose Tools | Templates.
+    @SuppressWarnings("ReturnOfCollectionOrArrayField")
+    public synchronized Collection<Resource> components() throws DataStoreException
{
+        if (components == null) try {
+            components = UnmodifiableArrayList.wrap(decoder.getDiscreteSampling());
+        } catch (IOException e) {
+            throw new DataStoreException(e);
+        }
+        return components;
     }
 
     /**

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=1807784&r1=1807783&r2=1807784&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] Fri Sep  8 16:52:48 2017
@@ -18,6 +18,7 @@ package org.apache.sis.internal.storage;
 
 import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.FeatureSet;
+import org.apache.sis.util.logging.WarningListeners;
 
 
 /**
@@ -28,13 +29,13 @@ import org.apache.sis.storage.FeatureSet
  * @since   0.8
  * @module
  */
-public abstract class AbstractFeatureSet extends AbstractDataSet implements FeatureSet {
+public abstract class AbstractFeatureSet extends AbstractResource implements FeatureSet {
     /**
      * Creates a new 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 store) {
-        super(store);
+    protected AbstractFeatureSet(final WarningListeners<DataStore> listeners) {
+        super(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=1807784&r1=1807783&r2=1807784&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] Fri Sep  8 16:52:48 2017
@@ -16,10 +16,19 @@
  */
 package org.apache.sis.internal.storage;
 
-import java.lang.reflect.Field;
+import java.util.Locale;
+import org.opengis.geometry.Envelope;
+import org.opengis.metadata.Metadata;
+import org.opengis.metadata.extent.Extent;
+import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.opengis.metadata.extent.GeographicExtent;
+import org.opengis.metadata.identification.Identification;
+import org.apache.sis.geometry.GeneralEnvelope;
+import org.apache.sis.util.Localized;
+import org.apache.sis.util.logging.WarningListeners;
 import org.apache.sis.storage.Resource;
 import org.apache.sis.storage.DataStore;
-import org.apache.sis.util.logging.WarningListeners;
+import org.apache.sis.storage.DataStoreException;
 
 
 /**
@@ -30,46 +39,86 @@ import org.apache.sis.util.logging.Warni
  * @since   0.8
  * @module
  */
-public abstract class AbstractResource implements Resource {
+public abstract class AbstractResource implements Resource, Localized {
     /**
-     * An accessor to the {@code DataStore.listeners} protected field.
-     * This hack will be removed if we move {@code AbstractResource} to the {@code org.apache.sis.storage}
package.
+     * The set of registered warning listeners for the data store.
      */
-    private static final Field LISTENERS;
-    static {
-        try {
-            LISTENERS = DataStore.class.getDeclaredField("listeners");
-        } catch (NoSuchFieldException e) {
-            throw new AssertionError(e);
-        }
-        LISTENERS.setAccessible(true);
+    protected final WarningListeners<DataStore> listeners;
+
+    /**
+     * Creates a new resource.
+     *
+     * @param listeners  the set of registered warning listeners for the data store.
+     */
+    protected AbstractResource(final WarningListeners<DataStore> listeners) {
+        this.listeners = listeners;
     }
 
     /**
-     * The data store which contains this resource.
+     * Returns the locale for error messages or warnings.
+     * Returns {@code null} if no locale is explicitly defined.
+     *
+     * @return the locale, or {@code null} if not explicitly defined.
      */
-    protected final DataStore store;
+    @Override
+    public final Locale getLocale() {
+        return (listeners != null) ? listeners.getLocale() : null;
+    }
 
     /**
-     * Creates a new resource.
+     * Returns the display name of the data store, or {@code null} if none.
+     * This is a convenience method for formatting error messages in subclasses.
+     *
+     * @return the data store display name, or {@code null}.
+     *
+     * @see DataStore#getDisplayName()
+     */
+    protected final String getStoreName() {
+        return (listeners != null) ? listeners.getSource().getDisplayName() : null;
+    }
+
+    /**
+     * Returns the spatio-temporal envelope of this resource.
+     * The default implementation computes the union of all {@link GeographicBoundingBox}
in the resource metadata,
+     * assuming the {@linkplain org.apache.sis.referencing.CommonCRS#defaultGeographic()
default geographic CRS}
+     * (usually WGS 84).
      *
-     * @param store  the data store which contains this resource.
+     * @return the spatio-temporal resource extent, or {@code null} if none.
+     * @throws DataStoreException if an error occurred while reading or computing the envelope.
      */
-    protected AbstractResource(final DataStore store) {
-        this.store = store;
+    public Envelope getEnvelope() throws DataStoreException {
+        return envelope(getMetadata());
     }
 
     /**
-     * Returns the set of registered warning listeners for the data store.
+     * Implementation of {@link #getEnvelope()}, provided as a separated method for
+     * {@link org.apache.sis.storage.DataSet} implementations that do not extend {@code AbstractResource}.
      *
-     * @return the registered warning listeners for the data store.
+     * @param  metadata  the metadata from which to compute the envelope, or {@code null}.
+     * @return the spatio-temporal resource extent, or {@code null} if none.
      */
-    @SuppressWarnings("unchecked")
-    protected final WarningListeners<DataStore> listeners() {
-        try {
-            return (WarningListeners<DataStore>) LISTENERS.get(store);
-        } catch (IllegalAccessException e) {
-            throw new AssertionError(e);        // Should never happen since we have made
the field accessible.
+    public static Envelope envelope(final Metadata metadata) {
+        GeneralEnvelope bounds = null;
+        if (metadata != null) {
+            for (final Identification identification : metadata.getIdentificationInfo())
{
+                if (identification != null) {                                           
   // Paranoiac check.
+                    for (final Extent extent : identification.getExtents()) {
+                        if (extent != null) {                                           
   // Paranoiac check.
+                            for (final GeographicExtent ge : extent.getGeographicElements())
{
+                                if (ge instanceof GeographicBoundingBox) {
+                                    final GeneralEnvelope env = new GeneralEnvelope((GeographicBoundingBox)
ge);
+                                    if (bounds == null) {
+                                        bounds = env;
+                                    } else {
+                                        bounds.add(env);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
         }
+        return bounds;
     }
 }

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderAggregate.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderAggregate.java?rev=1807784&r1=1807783&r2=1807784&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderAggregate.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderAggregate.java
[UTF-8] Fri Sep  8 16:52:48 2017
@@ -34,6 +34,7 @@ import org.apache.sis.storage.DataStoreE
 import org.apache.sis.storage.DataStores;
 import org.apache.sis.storage.ReadOnlyStorageException;
 import org.apache.sis.storage.Resource;
+import org.apache.sis.util.logging.WarningListeners;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.Metadata;
 import org.opengis.metadata.citation.Citation;
@@ -73,15 +74,19 @@ class FolderAggregate extends AbstractRe
         }
     };
 
-    private final FolderStore store;
+    /**
+     * The set of registered warning listeners for the folder data store.
+     */
+    private final WarningListeners<DataStore> listeners;
+
     private final FolderAggregate parent;
     private final Path path;
     private final Metadata metadata;
     private List<Resource> resources;
 
-    FolderAggregate(FolderStore store, FolderAggregate parent, Path path) {
-        super(store);
-        this.store = store;
+    FolderAggregate(final WarningListeners<DataStore> listeners, FolderAggregate parent,
Path path) {
+        super(listeners);
+        this.listeners = listeners;
         this.parent = parent;
         this.path = path;
 
@@ -105,7 +110,7 @@ class FolderAggregate extends AbstractRe
                 while (ite.hasNext()) {
                     final Path candidate = ite.next();
                     if (Files.isDirectory(candidate)) {
-                        resources.add(new FolderAggregate(store, this, candidate));
+                        resources.add(new FolderAggregate(listeners, this, candidate));
                     } else {
                         //test it
                         try {

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStore.java?rev=1807784&r1=1807783&r2=1807784&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStore.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/FolderStore.java
[UTF-8] Fri Sep  8 16:52:48 2017
@@ -64,7 +64,7 @@ public class FolderStore extends DataSto
     public FolderStore(ParameterValueGroup params) {
         this.params = params;
         final URI uri = URI.class.cast(params.parameter(DataStoreProvider.LOCATION).getValue());
-        root = new FolderAggregate(this, null, Paths.get(uri));
+        root = new FolderAggregate(listeners, null, Paths.get(uri));
     }
 
     private static ParameterValueGroup toParameters(final URI uri) {

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java?rev=1807784&r1=1807783&r2=1807784&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
[UTF-8] Fri Sep  8 16:52:48 2017
@@ -1371,8 +1371,9 @@ public class StorageConnector implements
             op.setValue(TableColumn.NAME,  "options");
             op.setValue(TableColumn.VALUE,  options);
         }
-        if (views != null) {
-            views.get(null).append(root.newChild(), views);
+        final Coupled c = getView(null);
+        if (c != null) {
+            c.append(root.newChild(), views);
         }
         return table.toString();
     }

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=1807784&r1=1807783&r2=1807784&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] Fri Sep  8 16:52:48 2017
@@ -29,7 +29,7 @@ import org.apache.sis.storage.DataStoreC
 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.AbstractDataSet;
+import org.apache.sis.internal.storage.AbstractResource;
 import org.apache.sis.internal.storage.xml.stream.StaxDataStore;
 import org.apache.sis.util.collection.BackingStoreException;
 import org.apache.sis.util.ArgumentChecks;
@@ -177,7 +177,7 @@ public final class Store extends StaxDat
      */
     @Override
     public Envelope getEnvelope() throws DataStoreException {
-        return AbstractDataSet.envelope(getMetadata());
+        return AbstractResource.envelope(getMetadata());
     }
 
     /**



Mime
View raw message