Author: desruisseaux
Date: Wed Sep 6 18:58:14 2017
New Revision: 1807518
URL: http://svn.apache.org/viewvc?rev=1807518&view=rev
Log:
Javadoc and minor refactoring in Store.getEnvelope() and getOpenParameters()
method.
Added:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ReadOnlyStorageException.java
- copied, changed from r1807517,
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ReadOnlyDataStoreException.java
Removed:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ReadOnlyDataStoreException.java
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractDataSet.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/Resources.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
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/internal/storage/wkt/Store.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Aggregate.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataSet.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ForwardOnlyStorageException.java
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Resource.java
sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractDataSet.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractDataSet.java?rev=1807518&r1=1807517&r2=1807518&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractDataSet.java
(original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/AbstractDataSet.java
Wed Sep 6 18:58:14 2017
@@ -16,28 +16,29 @@
*/
package org.apache.sis.internal.storage;
-import org.apache.sis.geometry.GeneralEnvelope;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.DataSet;
-import org.apache.sis.storage.DataStore;
-import org.apache.sis.util.logging.WarningListeners;
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.storage.DataStoreException;
+import org.apache.sis.storage.DataSet;
+import org.apache.sis.storage.DataStore;
+import org.apache.sis.util.logging.WarningListeners;
+
/**
* Base implementation of data sets contained in data stores.
*
- * @author Johann Sorel (Geomatys)
+ * @author Johann Sorel (Geomatys)
* @version 0.8
* @since 0.8
* @module
*/
public abstract class AbstractDataSet extends AbstractResource implements
DataSet {
- /**
+ /**
* Creates a new resource.
*
* @param store the data store which contains this resource.
@@ -53,12 +54,22 @@ public abstract class AbstractDataSet ex
* assuming the {@linkplain
org.apache.sis.referencing.CommonCRS#defaultGeographic() default geographic CRS}
* (usually WGS 84).
*
- * @return the spatio-temporal resource extent.
+ * @return the spatio-temporal resource extent, or {@code null}Â if none.
* @throws DataStoreException if an error occurred while reading or
computing the envelope.
*/
@Override
public Envelope getEnvelope() throws DataStoreException {
- final Metadata metadata = getMetadata();
+ return envelope(getMetadata());
+ }
+
+ /**
+ * Implementation of {@link #getEnvelope()}, provided as a separated
method for {@link DataSet}
+ * implementations that do not extend {@code AbstractDataSet}.
+ *
+ * @param metadata the metadata from which to compute the envelope, or
{@code null}.
+ * @return the spatio-temporal resource extent, or {@code null}Â if none.
+ */
+ public static Envelope envelope(final Metadata metadata) {
GeneralEnvelope bounds = null;
if (metadata != null) {
for (final Identification identification :
metadata.getIdentificationInfo()) {
@@ -82,5 +93,4 @@ public abstract class AbstractDataSet ex
}
return bounds;
}
-
}
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=1807518&r1=1807517&r2=1807518&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] Wed Sep 6 18:58:14 2017
@@ -28,8 +28,6 @@ import org.apache.sis.util.logging.Warni
* @version 0.8
* @since 0.8
* @module
- *
- * @todo this class may be removed if we refactor {@link FeatureSet} as an
abstract class.
*/
public abstract class AbstractFeatureSet extends AbstractDataSet implements
FeatureSet {
/**
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=1807518&r1=1807517&r2=1807518&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] Wed Sep 6 18:58:14 2017
@@ -28,8 +28,6 @@ import org.apache.sis.util.logging.Warni
* @version 0.8
* @since 0.8
* @module
- *
- * @todo this class may be removed if we refactor {@link Resource} as an
abstract class.
*/
public abstract class AbstractResource implements Resource {
/**
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java?rev=1807518&r1=1807517&r2=1807518&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
[UTF-8] Wed Sep 6 18:58:14 2017
@@ -164,7 +164,7 @@ public final class Resources extends Ind
public static final short ShallBeDeclaredBefore_2 = 22;
/**
- * Writing operations not supported.
+ * Write operations are not supported.
*/
public static final short StoreIsReadOnly = 28;
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties?rev=1807518&r1=1807517&r2=1807518&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
[ISO-8859-1] Wed Sep 6 18:58:14 2017
@@ -39,6 +39,7 @@ ProcessingExecutedOn_1 = Proc
ResourceIdentifierCollision_2 = More than one resource have the
\u201c{1}\u201d identifier in the \u201c{0}\u201d data store.
ResourceNotFound_2 = No resource found for the \u201c{1}\u201d
identifier in the \u201c{0}\u201d data store.
ShallBeDeclaredBefore_2 = The \u201c{1}\u201d element must be
declared before \u201c{0}\u201d.
+StoreIsReadOnly = Write operations are not supported.
StreamIsForwardOnly_1 = Can not move backward in the
\u201c{0}\u201d stream.
StreamIsNotReadable_1 = Stream \u201c{0}\u201d is not readable.
StreamIsNotWritable_1 = Stream \u201c{0}\u201d is not writable.
@@ -46,4 +47,3 @@ StreamIsReadOnce_1 = The
StreamIsWriteOnce_1 = Can not modify previously written data in
\u201c{0}\u201d.
UndefinedParameter_2 = Can not open {0} data store without
\u201c{1}\u201d parameter.
UnknownFormatFor_1 = Format of \u201c{0}\u201d is not
recognized.
-StoreIsReadOnly = Writing operations not supported.
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties?rev=1807518&r1=1807517&r2=1807518&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
[ISO-8859-1] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
[ISO-8859-1] Wed Sep 6 18:58:14 2017
@@ -44,6 +44,7 @@ ProcessingExecutedOn_1 = Trai
ResourceIdentifierCollision_2 = Plusieurs ressources utilisent
l\u2019identifiant \u00ab\u202f{1}\u202f\u00bb dans les donn\u00e9es de
\u00ab\u202f{0}\u202f\u00bb.
ResourceNotFound_2 = Aucune ressource n\u2019a \u00e9t\u00e9
trouv\u00e9e pour l\u2019identifiant \u00ab\u202f{1}\u202f\u00bb dans les
donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
ShallBeDeclaredBefore_2 = L\u2019\u00e9l\u00e9ment
\u00ab\u202f{1}\u202f\u00bb doit \u00eatre d\u00e9clar\u00e9 avant
\u00ab\u202f{0}\u202f\u00bb.
+StoreIsReadOnly = Les op\u00e9rations d\u2019\u00e9criture
ne sont pas support\u00e9es.
StreamIsForwardOnly_1 = Ne peut pas reculer dans le flux de
donn\u00e9es \u00ab\u202f{0}\u202f\u00bb.
StreamIsNotReadable_1 = Les donn\u00e9es de
\u00ab\u202f{0}\u202f\u00bb ne sont pas accessibles en lecture.
StreamIsNotWritable_1 = Le flux de donn\u00e9es
\u00ab\u202f{0}\u202f\u00bb ne g\u00e8re pas les \u00e9critures.
@@ -51,4 +52,3 @@ StreamIsReadOnce_1 = Les
StreamIsWriteOnce_1 = Ne peut pas revenir sur les donn\u00e9es
d\u00e9j\u00e0 \u00e9crites dans \u00ab\u202f{0}\u202f\u00bb.
UndefinedParameter_2 = Ne peut pas ouvrir une source de
donn\u00e9es {0} sans le param\u00e8tre \u00ab\u202f{1}\u202f\u00bb.
UnknownFormatFor_1 = Le format de \u00ab\u202f{0}\u202f\u00bb
n\u2019est pas reconnu.
-StoreIsReadOnly = Les op\u00e9rations d'\u00e9criture ne
sont pas support\u00e9es.
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=1807518&r1=1807517&r2=1807518&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] Wed Sep 6 18:58:14 2017
@@ -32,6 +32,7 @@ import java.nio.charset.Charset;
import javax.measure.Unit;
import javax.measure.quantity.Time;
import org.opengis.util.FactoryException;
+import org.opengis.geometry.Envelope;
import org.opengis.metadata.Metadata;
import org.opengis.metadata.maintenance.ScopeCode;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
@@ -50,6 +51,7 @@ import org.apache.sis.internal.feature.G
import org.apache.sis.internal.feature.MovingFeature;
import org.apache.sis.internal.storage.Resources;
import org.apache.sis.geometry.GeneralEnvelope;
+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.DataStore;
@@ -58,7 +60,7 @@ import org.apache.sis.storage.DataStoreC
import org.apache.sis.storage.DataStoreReferencingException;
import org.apache.sis.storage.UnsupportedStorageException;
import org.apache.sis.storage.StorageConnector;
-import org.apache.sis.parameter.Parameters;
+import org.apache.sis.storage.FeatureSet;
import org.apache.sis.setup.OptionKey;
import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.CharSequences;
@@ -70,13 +72,10 @@ import java.time.Instant;
import java.time.DateTimeException;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
-import org.apache.sis.geometry.ImmutableEnvelope;
-import org.apache.sis.storage.FeatureSet;
import org.opengis.feature.Feature;
import org.opengis.feature.FeatureType;
import org.opengis.feature.PropertyType;
import org.opengis.feature.AttributeType;
-import org.opengis.geometry.Envelope;
/**
@@ -159,8 +158,9 @@ public final class Store extends DataSto
* and a temporal component if the CSV file contains a start time and end
time.
*
* @see #parseEnvelope(List)
+ * @see #getEnvelope()
*/
- private final GeneralEnvelope envelope;
+ private final ImmutableEnvelope envelope;
/**
* Description of the columns found in the CSV file.
@@ -310,7 +310,7 @@ public final class Store extends DataSto
throw new DataStoreContentException(getLocale(),
StoreProvider.NAME, super.getDisplayName(), source).initCause(e);
}
this.encoding = connector.getOption(OptionKey.ENCODING);
- this.envelope = envelope;
+ this.envelope = new ImmutableEnvelope(envelope);
this.featureType = featureType;
this.foliation = foliation;
this.dissociate |= (timeEncoding == null);
@@ -631,22 +631,24 @@ public final class Store extends DataSto
}
/**
- * {@inheritDoc }
+ * Returns the spatio-temporal extent of CSV data in coordinate reference
system of the CSV file.
*/
@Override
public Envelope getEnvelope() throws DataStoreException {
- return new ImmutableEnvelope(envelope);
+ return envelope;
}
/**
- * {@inheritDoc }
+ * Returns the parameters used to open this data store.
+ *
+ * @return parameters used for opening this {@code DataStore}, or {@code
null} if not available.
*/
@Override
public ParameterValueGroup getOpenParameters() {
- if (sourceUri==null) return null;
- final Parameters parameters =
Parameters.castOrWrap(StoreProvider.OPEN_DESCRIPTOR.createValue());
-
parameters.getOrCreate(StoreProvider.PARAM_LOCATION).setValue(sourceUri);
- return parameters;
+ if (sourceUri == null) return null;
+ final ParameterValueGroup pg =
StoreProvider.OPEN_DESCRIPTOR.createValue();
+ pg.parameter(StoreProvider.LOCATION).setValue(sourceUri);
+ return pg;
}
/**
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java?rev=1807518&r1=1807517&r2=1807518&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
[UTF-8] Wed Sep 6 18:58:14 2017
@@ -35,7 +35,6 @@ import org.apache.sis.internal.storage.R
import org.apache.sis.internal.system.Loggers;
import org.apache.sis.io.wkt.WKTFormat;
import org.apache.sis.io.wkt.Warnings;
-import org.apache.sis.storage.Resource;
import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.StorageConnector;
import org.apache.sis.storage.DataStoreException;
@@ -43,7 +42,6 @@ import org.apache.sis.storage.DataStoreC
import org.apache.sis.storage.UnsupportedStorageException;
import org.apache.sis.internal.referencing.DefinitionVerifier;
import org.apache.sis.internal.storage.MetadataBuilder;
-import org.apache.sis.parameter.Parameters;
import org.apache.sis.setup.OptionKey;
import org.apache.sis.util.CharSequences;
@@ -205,14 +203,16 @@ final class Store extends DataStore {
}
/**
- * {@inheritDoc }
+ * Returns the parameters used to open this data store.
+ *
+ * @return parameters used for opening this {@code DataStore}, or {@code
null} if not available.
*/
@Override
public ParameterValueGroup getOpenParameters() {
- if (sourceUri==null) return null;
- final Parameters parameters =
Parameters.castOrWrap(StoreProvider.OPEN_DESCRIPTOR.createValue());
-
parameters.getOrCreate(StoreProvider.PARAM_LOCATION).setValue(sourceUri);
- return parameters;
+ if (sourceUri == null) return null;
+ final ParameterValueGroup pg =
StoreProvider.OPEN_DESCRIPTOR.createValue();
+ pg.parameter(StoreProvider.LOCATION).setValue(sourceUri);
+ return pg;
}
/**
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java?rev=1807518&r1=1807517&r2=1807518&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
[UTF-8] Wed Sep 6 18:58:14 2017
@@ -32,7 +32,6 @@ import org.opengis.referencing.Reference
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.parameter.ParameterValueGroup;
import org.apache.sis.xml.XML;
-import org.apache.sis.storage.Resource;
import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.StorageConnector;
import org.apache.sis.storage.DataStoreException;
@@ -43,7 +42,6 @@ import org.apache.sis.util.resources.Err
import org.apache.sis.internal.system.Loggers;
import org.apache.sis.internal.storage.MetadataBuilder;
import org.apache.sis.internal.referencing.DefinitionVerifier;
-import org.apache.sis.parameter.Parameters;
import org.apache.sis.setup.OptionKey;
@@ -221,14 +219,16 @@ final class Store extends DataStore {
}
/**
- * {@inheritDoc }
+ * Returns the parameters used to open this data store.
+ *
+ * @return parameters used for opening this {@code DataStore}, or {@code
null} if not available.
*/
@Override
public ParameterValueGroup getOpenParameters() {
- if (sourceUri==null) return null;
- final Parameters parameters =
Parameters.castOrWrap(StoreProvider.OPEN_DESCRIPTOR.createValue());
-
parameters.getOrCreate(StoreProvider.PARAM_LOCATION).setValue(sourceUri);
- return parameters;
+ if (sourceUri == null) return null;
+ final ParameterValueGroup pg =
StoreProvider.OPEN_DESCRIPTOR.createValue();
+ pg.parameter(StoreProvider.LOCATION).setValue(sourceUri);
+ return pg;
}
/**
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Aggregate.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Aggregate.java?rev=1807518&r1=1807517&r2=1807518&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Aggregate.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Aggregate.java
[UTF-8] Wed Sep 6 18:58:14 2017
@@ -17,9 +17,9 @@
package org.apache.sis.storage;
import java.util.Collection;
-import org.apache.sis.internal.storage.Resources;
import org.opengis.metadata.Metadata;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.internal.storage.Resources;
/**
@@ -45,7 +45,7 @@ import org.opengis.referencing.crs.Coord
*
* The same resource may be part of more than one aggregate. For example the
same resource could be part of
* a <cite>production series</cite> and a <cite>transfer aggregate</cite>. In
Apache SIS implementation,
- * those two kinds of aggregate will usually be created by different {@link
DataStore} instances.
+ * those two kinds of aggregate will usually be implemented by different
{@link DataStore} instances.
*
* <div class="section">Metadata</div>
* Aggregates should have {@link #getMetadata() metadata} /
@@ -87,46 +87,45 @@ public interface Aggregate extends Resou
Collection<Resource> components() throws DataStoreException;
/**
- * Add a new {@link Resource} in this {@link Aggregate}.
- * The given {@link Resource} will be copied and the newly created one
- * returned.
- *
- * <p>It is important to be warned that copying informations between stores
- * may produce differences on many aspects, the range of changes depends
- * both on the original {@link Resource} format and the target {@link
Resource} format.
- * If the differences are too great, then this {@link Aggregate} may throw
- * an exception.
- * </p>
- *
- * The possible changes may include the followings but not only :
+ * Adds a new {@code Resource} in this {@code Aggregate}.
+ * The given {@link Resource} will be copied, and the <cite>effectively
added</cite> resource returned.
+ * The effectively added resource may differ from the given resource in
many aspects.
+ * The possible changes may include the followings but not only:
* <ul>
* <li>types and properties names</li>
* <li>{@link CoordinateReferenceSystem}</li>
* <li>{@link Metadata}</li>
* </ul>
*
- *
- * @param resource {@link Resource} to copy in this {@link Aggregate}
- * @return newly created resource
- * @throws DataStoreException if given resource can not be stored in this
{@link Aggregate} or the copy operation failed.
- * @throws ReadOnlyDataStoreException if this instance does not support
writing operations
+ * <div class="note"><b>Warning:</b>
+ * copying informations between stores may produce differences in many
aspects.
+ * The range of changes depends both on the original {@link Resource}
structure
+ * and the target {@code Resource} structure. If the differences are too
large,
+ * then this {@code Aggregate} may throw an exception.
+ * </div>
+ *
+ * <p>The default implementation throws {@link
ReadOnlyStorageException}.</p>
+ *
+ * @param resource the resource to copy in this {@code Aggregate}.
+ * @return the effectively added resource. May be {@code resource} itself
if it has been added verbatim.
+ * @throws ReadOnlyStorageException if this instance does not support
write operations.
+ * @throws DataStoreException if the given resource can not be stored in
this {@code Aggregate} for another reason.
*/
- default Resource add(Resource resource) throws DataStoreException,
ReadOnlyDataStoreException {
- throw new ReadOnlyDataStoreException(null,
Resources.Keys.StoreIsReadOnly);
+ default Resource add(Resource resource) throws ReadOnlyStorageException,
DataStoreException {
+ throw new ReadOnlyStorageException(this,
Resources.Keys.StoreIsReadOnly);
}
/**
- * Remove a {@link Resource} from this {@link Aggregate}.
+ * Removes a {@code Resource} from this {@code Aggregate}.
+ * This operation is destructive: the {@link Resource} and it's related
data will be removed.
*
- * <p>This operation is destructive, the {@link Resource} and it's related
- * datas will be removed.</p>
+ * <p>The default implementation throws {@link
ReadOnlyStorageException}.</p>
*
- * @param resource child {@link Resource} to remove, should not be null
- * @throws DataStoreException if the {@link Resource} could not be removed
- * @throws ReadOnlyDataStoreException if this instance does not support
writing operations
+ * @param resource child resource to remove, should not be null.
+ * @throws ReadOnlyStorageException if this instance does not support
write operations.
+ * @throws DataStoreException if the given resource could not be removed
for another reason.
*/
- default void remove(Resource resource) throws DataStoreException,
ReadOnlyDataStoreException {
- throw new ReadOnlyDataStoreException(null,
Resources.Keys.StoreIsReadOnly);
+ default void remove(Resource resource) throws ReadOnlyStorageException,
DataStoreException {
+ throw new ReadOnlyStorageException(this,
Resources.Keys.StoreIsReadOnly);
}
-
}
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataSet.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataSet.java?rev=1807518&r1=1807517&r2=1807518&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataSet.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataSet.java
[UTF-8] Wed Sep 6 18:58:14 2017
@@ -47,7 +47,6 @@ import org.opengis.geometry.Envelope;
* @module
*/
public interface DataSet extends Resource {
-
/**
* Returns the spatio-temporal extent of this resource in its most natural
coordinate reference system.
* The following relationship to {@linkplain #getMetadata()} should hold:
@@ -72,5 +71,4 @@ public interface DataSet extends Resourc
* @throws DataStoreException if an error occurred while reading or
computing the envelope.
*/
Envelope getEnvelope() throws DataStoreException;
-
}
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=1807518&r1=1807517&r2=1807518&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] Wed Sep 6 18:58:14 2017
@@ -236,8 +236,10 @@ public abstract class DataStore implemen
* 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.
+ * <p>The default implementation verifies if above criterion matches to
this {@code DataStore}
+ * (which is itself a resource), then iterates recursively over {@link
Aggregate} components
+ * if this data store is an aggregate.
+ * 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.</p>
*
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java?rev=1807518&r1=1807517&r2=1807518&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java
[UTF-8] Wed Sep 6 18:58:14 2017
@@ -16,12 +16,13 @@
*/
package org.apache.sis.storage;
-// Branch-dependent imports
import java.util.Iterator;
+import org.apache.sis.internal.storage.Resources;
+
+// Branch-dependent imports
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
import java.util.stream.Stream;
-import org.apache.sis.internal.storage.Resources;
import org.opengis.feature.Feature;
import org.opengis.feature.FeatureType;
@@ -107,53 +108,60 @@ public interface FeatureSet extends Data
Stream<Feature> features(boolean parallel) throws DataStoreException;
/**
- * Insert new features in the {@link FeatureSet}.
+ * Inserts new features in this {@code FeatureSet}.
* Any feature already present in the {@link FeatureSet} will remain
unmodified.
*
- * <p>The method expect an {@link Iterator} rather then a Stream to ease
the user
- * mapping work with various API. Implementing a custom {@link Iterator}
require
- * considerably less efforts then a {@link Stream}. On the other side if
the user
- * has a {@link Stream}, obtaining an {@link Iterator} can be done by a
single
- * call to {@link Stream#iterator() }.</p>
- *
- * @param features features to append in the {@link FeatureSet}
- * @throws DataStoreException if an error occurred while storing new
features.
+ * <div class="note"><b>API note:</b>
+ * this method expects an {@link Iterator} rather then a {@link
java.util.stream.Stream} for easing
+ * inter-operability with various API. Implementing a custom {@link
Iterator} requires less effort
+ * than implementing a {@link Stream}. On the other side if the user has a
{@link Stream},
+ * obtaining an {@link Iterator} can be done by a call to {@link
Stream#iterator()}.</div>
+ *
+ * <p>The default implementation throws {@link
ReadOnlyStorageException}.</p>
+ *
+ * @param features features to insert in this {@code FeatureSet}.
+ * @throws ReadOnlyStorageException if this instance does not support
write operations.
+ * @throws DataStoreException if another error occurred while storing new
features.
*/
- default void add(Iterator<? extends Feature> features) throws
DataStoreException {
- throw new
ReadOnlyDataStoreException(null,Resources.Keys.StoreIsReadOnly);
+ default void add(Iterator<? extends Feature> features) throws
ReadOnlyStorageException, DataStoreException {
+ throw new ReadOnlyStorageException(this,
Resources.Keys.StoreIsReadOnly);
}
/**
- * Remove all {@link Feature} from the {@link FeatureSet} which match
- * the given predicate.
+ * Removes all features from this {@code FeatureSet} which matches the
given predicate.
+ *
+ * <p>The default implementation throws {@link
ReadOnlyStorageException}.</p>
*
- * @param predicate matching predicate
- * @return true if any elements were removed
- * @throws DataStoreException if an error occurred while removing features.
+ * @param filter a predicate which returns true for resources to be
removed.
+ * @return {@code true} if any elements were removed.
+ * @throws ReadOnlyStorageException if this instance does not support
write operations.
+ * @throws DataStoreException if another error occurred while removing
features.
*/
- default boolean removeIf(Predicate<? super Feature> predicate) throws
DataStoreException {
- throw new
ReadOnlyDataStoreException(null,Resources.Keys.StoreIsReadOnly);
+ default boolean removeIf(Predicate<? super Feature> filter) throws
ReadOnlyStorageException, DataStoreException {
+ throw new ReadOnlyStorageException(this,
Resources.Keys.StoreIsReadOnly);
}
/**
- * Update all {@link Feature} from the {@link FeatureSet} which match
- * the given predicate.
- *
- * <p>For each {@link Feature} matching the {@link Predicate} the {@link
UnaryOperator}
- * will be called. Two behaviors are possible.</p>
+ * Updates all features from this {@code FeatureSet} which matches the
given predicate.
+ * For each {@link Feature} instance matching the given {@link Predicate},
+ * the <code>{@linkplain UnaryOperator#apply
UnaryOperator.apply(Feature)}</code> method
+ * will be invoked. Two behaviors are possible:
* <ul>
- * <li>If it returns the {@link Feature}, then the updated feature is
store with
- * all the modifications.</li>
- * <li> If it returns a null, then the feature will be removed from the
- * {@link FeatureSet}.</li>
+ * <li>If the operator returns a non-null {@link Feature}, then the
modified feature is stored
+ * in replacement of the previous feature. There is no guarantee
that order is preserved.</li>
+ * <li>If the operator returns {@code null}, then the feature will be
removed from the {@code FeatureSet}.</li>
* </ul>
*
- * @param predicate matching predicate
- * @param updater operation called for each matching {@link Feature}
- * @throws DataStoreException
+ * <p>The default implementation throws {@link
ReadOnlyStorageException}.</p>
+ *
+ * @param filter a predicate which returns true for resources to be
updated.
+ * @param updater operation called for each matching {@link Feature}.
+ * @throws ReadOnlyStorageException if this instance does not support
write operations.
+ * @throws DataStoreException if another error occurred while replacing
features.
*/
- default void replaceIf(Predicate<? super Feature> predicate,
UnaryOperator<Feature> updater) throws DataStoreException {
- throw new
ReadOnlyDataStoreException(null,Resources.Keys.StoreIsReadOnly);
+ default void replaceIf(Predicate<? super Feature> filter,
UnaryOperator<Feature> updater)
+ throws ReadOnlyStorageException, DataStoreException
+ {
+ throw new ReadOnlyStorageException(this,
Resources.Keys.StoreIsReadOnly);
}
-
}
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ForwardOnlyStorageException.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ForwardOnlyStorageException.java?rev=1807518&r1=1807517&r2=1807518&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ForwardOnlyStorageException.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ForwardOnlyStorageException.java
[UTF-8] Wed Sep 6 18:58:14 2017
@@ -35,6 +35,8 @@ import org.apache.sis.internal.storage.i
* @version 0.8
* @since 0.8
* @module
+ *
+ * @see ReadOnlyStorageException
*/
public class ForwardOnlyStorageException extends DataStoreException {
/**
Copied:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ReadOnlyStorageException.java
(from r1807517,
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ReadOnlyDataStoreException.java)
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ReadOnlyStorageException.java?p2=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ReadOnlyStorageException.java&p1=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ReadOnlyDataStoreException.java&r1=1807517&r2=1807518&rev=1807518&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ReadOnlyDataStoreException.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/ReadOnlyStorageException.java
[UTF-8] Wed Sep 6 18:58:14 2017
@@ -16,24 +16,35 @@
*/
package org.apache.sis.storage;
-import java.util.Locale;
+import org.apache.sis.util.Localized;
+
/**
- * Thrown when a writing operation on a {@code DataStore} is not supported.
+ * Thrown when a {@code DataStore} can not perform a write operations.
+ * This exception may occur either because:
+ *
+ * <ul>
+ * <li>the data store does not support write operations, or</li>
+ * <li>write operations are supported but the channel is read-only.</li>
+ * </ul>
*
- * @author Johann Sorel (Geomatys)
+ * @author Johann Sorel (Geomatys)
* @version 0.8
* @since 0.8
* @module
+ *
+ * @see ForwardOnlyStorageException
*/
-public class ReadOnlyDataStoreException extends DataStoreException {
-
+public class ReadOnlyStorageException extends DataStoreException {
+ /**
+ * For cross-version compatibility.
+ */
private static final long serialVersionUID = 5710116172772560023L;
/**
* Creates an exception with no cause and no details message.
*/
- public ReadOnlyDataStoreException() {
+ public ReadOnlyStorageException() {
}
/**
@@ -41,7 +52,7 @@ public class ReadOnlyDataStoreException
*
* @param message the detail message.
*/
- public ReadOnlyDataStoreException(final String message) {
+ public ReadOnlyStorageException(final String message) {
super(message);
}
@@ -50,7 +61,7 @@ public class ReadOnlyDataStoreException
*
* @param cause the cause for this exception.
*/
- public ReadOnlyDataStoreException(final Throwable cause) {
+ public ReadOnlyStorageException(final Throwable cause) {
super(cause);
}
@@ -60,18 +71,18 @@ public class ReadOnlyDataStoreException
* @param message the detail message.
* @param cause the cause for this exception.
*/
- public ReadOnlyDataStoreException(final String message, final Throwable
cause) {
+ public ReadOnlyStorageException(final String message, final Throwable
cause) {
super(message, cause);
}
/**
- * Creates a new exception which will format a localized message in the
given locale.
+ * Creates a new exception which will format a localized message in the
resource locale.
*
- * @param locale the locale for the message to be returned by {@link
#getLocalizedMessage()}.
+ * @param originator the instance throwing this exception, or {@code
null} if unknown.
* @param key one of {@link
org.apache.sis.internal.storage.Resources.Keys} constants.
* @param parameters parameters to use for formatting the messages.
*/
- ReadOnlyDataStoreException(final Locale locale, final short key, final
Object... parameters) {
- super(locale, key, parameters);
+ ReadOnlyStorageException(final Resource originator, final short key, final
Object... parameters) {
+ super((originator instanceof Localized) ? ((Localized)
originator).getLocale() : null, key, parameters);
}
}
Modified:
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Resource.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Resource.java?rev=1807518&r1=1807517&r2=1807518&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Resource.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Resource.java
[UTF-8] Wed Sep 6 18:58:14 2017
@@ -27,8 +27,8 @@ import org.opengis.metadata.Metadata;
* organization, in which case only metadata are provided. If the resource is
digital, then {@code Resource}s
* should be instances of sub-types like {@link Aggregate} or {@link
FeatureSet}.
*
- * <p>The resources contained in a data store can be obtained by a call to
{@link DataStore#getRootResource()}.
- * If the data store contains resources for many feature types or coverages,
then the root resource will be an
+ * <p>{@code DataStore}s are themselves closeable resources.
+ * If the data store contains resources for many feature types or coverages,
then the data store will be an
* instance of {@link Aggregate}. The {@linkplain Aggregate#components()
components} of an aggregate can be
* themselves other aggregates, thus forming a tree.</p>
*
@@ -36,14 +36,13 @@ import org.opengis.metadata.Metadata;
* this type is closely related to the {@code DS_Resource} type defined by ISO
19115.
* The Apache SIS type differs from the ISO type by being more closely related
to data extraction,
* as can been seen from the checked {@link DataStoreException} thrown by most
methods.
- * Convenience methods for frequently requested information – for example
{@link #getEnvelope()} – were added.
+ * Convenience methods for frequently requested information – for example
{@link DataSet#getEnvelope()} – were added.
* The sub-types performing the actual data extraction – for example {@link
FeatureSet} – are specific to Apache SIS.
* </div>
*
* @author Johann Sorel (Geomatys)
* @version 0.8
*
- * @see DataStore#getRootResource()
* @see Aggregate#components()
*
* @since 0.8
@@ -52,8 +51,6 @@ import org.opengis.metadata.Metadata;
public interface Resource {
/**
* Returns information about this resource.
- * If this resource is the {@linkplain DataStore#getRootResource() data
store root resource},
- * then this method may return the same metadata instance than {@link
DataStore#getMetadata()}.
* If this resource is an {@link Aggregate}, then the metadata may
enumerate characteristics
* (spatio-temporal extents, feature types, range dimensions, <i>etc.</i>)
of all
* {@linkplain Aggregate#components() components} in the aggregate, or
summarize them (for example by omitting
@@ -106,5 +103,4 @@ public interface Resource {
* @see DataStore#getMetadata()
*/
Metadata getMetadata() throws DataStoreException;
-
}
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=1807518&r1=1807517&r2=1807518&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] Wed Sep 6 18:58:14 2017
@@ -19,14 +19,18 @@ package org.apache.sis.internal.storage.
import java.net.URISyntaxException;
import org.opengis.util.NameFactory;
import org.opengis.util.FactoryException;
+import org.opengis.geometry.Envelope;
+import org.opengis.parameter.ParameterValueGroup;
import org.opengis.metadata.Metadata;
import org.opengis.metadata.distribution.Format;
+import org.apache.sis.storage.FeatureSet;
import org.apache.sis.storage.StorageConnector;
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.AbstractDataSet;
import org.apache.sis.internal.storage.xml.stream.StaxDataStore;
import org.apache.sis.util.collection.BackingStoreException;
import org.apache.sis.util.ArgumentChecks;
@@ -42,17 +46,8 @@ 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.geometry.GeneralEnvelope;
-import org.apache.sis.parameter.Parameters;
-import org.apache.sis.storage.FeatureSet;
import org.opengis.feature.Feature;
import org.opengis.feature.FeatureType;
-import org.opengis.geometry.Envelope;
-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.opengis.parameter.ParameterValueGroup;
/**
@@ -177,49 +172,26 @@ public final class Store extends StaxDat
/**
* 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).
*
* @return the spatio-temporal resource extent.
* @throws DataStoreException if an error occurred while reading or
computing the envelope.
*/
@Override
public Envelope getEnvelope() throws DataStoreException {
- final Metadata metadata = getMetadata();
- 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;
+ return AbstractDataSet.envelope(getMetadata());
}
/**
- * {@inheritDoc }
+ * Returns the parameters used to open this data store.
+ *
+ * @return parameters used for opening this {@code DataStore}, or {@code
null} if not available.
*/
@Override
public ParameterValueGroup getOpenParameters() {
- if (sourceUri==null) return null;
- final Parameters parameters =
Parameters.castOrWrap(StoreProvider.OPEN_DESCRIPTOR.createValue());
-
parameters.getOrCreate(StoreProvider.PARAM_LOCATION).setValue(sourceUri);
- return parameters;
+ if (sourceUri == null) return null;
+ final ParameterValueGroup pg =
StoreProvider.OPEN_DESCRIPTOR.createValue();
+ pg.parameter(StoreProvider.LOCATION).setValue(sourceUri);
+ return pg;
}
/**
@@ -251,9 +223,11 @@ public final class Store extends StaxDat
/**
* 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 final synchronized Stream<Feature> features(boolean parallel)
throws DataStoreException {
Reader r = reader;
reader = null;