You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2017/01/04 09:17:27 UTC
svn commit: r1777269 [2/2] - in /sis/branches/JDK7: ./
core/sis-feature/src/main/java/org/apache/sis/feature/
core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/
core/sis-metadata/src/main/java/org/apache/sis/metadata/
core/sis-metadata/s...
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -18,6 +18,7 @@ package org.apache.sis.util.iso;
import java.util.List;
import java.util.Locale;
+import java.util.Objects;
import java.util.Iterator;
import java.util.ConcurrentModificationException;
import java.io.Serializable;
@@ -31,9 +32,6 @@ import org.opengis.util.InternationalStr
import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.util.resources.Errors;
-// Branch-dependent imports
-import java.util.Objects;
-
/**
* Base class for sequence of identifiers rooted within the context of a {@linkplain DefaultNameSpace namespace}.
@@ -50,7 +48,7 @@ import java.util.Objects;
* This class has a natural ordering that is inconsistent with {@link #equals(Object)}.
* See {@link #compareTo(GenericName)} for more information.
*
- * <div class="section">Note for implemetors</div>
+ * <div class="section">Note for implementors</div>
* Subclasses need only to implement the following methods:
* <ul>
* <li>{@link #scope()}</li>
@@ -64,10 +62,15 @@ import java.util.Objects;
* @since 0.3
* @version 0.5
* @module
+ *
+ * @see org.apache.sis.referencing.NamedIdentifier
+ * @see org.apache.sis.storage.FeatureNaming
+ * @see org.apache.sis.feature.AbstractIdentifiedType#getName()
+ * @see org.apache.sis.referencing.AbstractIdentifiedObject#getAlias()
*/
/*
- * JAXB annotation would be @XmlType(name ="CodeType"), but this can not be used here
+ * JAXB annotation would be @XmlType(name = "CodeType"), but this can not be used here
* since "CodeType" is used for various classes (including LocalName and ScopedName).
*/
@XmlTransient
@@ -116,8 +119,8 @@ public abstract class AbstractName imple
* {@link DefaultNameFactory#createGenericName(NameSpace, CharSequence[])} method.</li>
* </ul>
*
- * @param object The object to get as a SIS implementation, or {@code null} if none.
- * @return A SIS implementation containing the values of the given object (may be the
+ * @param object the object to get as a SIS implementation, or {@code null} if none.
+ * @return a SIS implementation containing the values of the given object (may be the
* given object itself), or {@code null} if the argument was null.
*/
public static AbstractName castOrCopy(final GenericName object) {
@@ -159,7 +162,7 @@ public abstract class AbstractName imple
* global scope instance (i.e. an instance for which {@link DefaultNameSpace#isGlobal()}
* returns {@code true}) which is unique and named {@code "global"}.</p>
*
- * @return The scope of this name.
+ * @return the scope of this name.
*/
@Override
public abstract NameSpace scope();
@@ -168,7 +171,7 @@ public abstract class AbstractName imple
* Indicates the number of levels specified by this name. The default implementation returns
* the size of the list returned by the {@link #getParsedNames()} method.
*
- * @return The depth of this name.
+ * @return the depth of this name.
*/
@Override
public int depth() {
@@ -189,7 +192,7 @@ public abstract class AbstractName imple
* The length of this sequence is the {@linkplain #depth() depth}. It does not include the
* {@linkplain #scope() scope}.
*
- * @return The local names making this generic name, without the {@linkplain #scope() scope}.
+ * @return the local names making this generic name, without the {@linkplain #scope() scope}.
* Shall never be {@code null} neither empty.
*/
@Override
@@ -203,7 +206,7 @@ public abstract class AbstractName imple
* If {@code this} name is {@code "org.opengis.util.Record"}
* (no matter its scope, then this method returns {@code "org"}.</div>
*
- * @return The first element in the list of {@linkplain #getParsedNames() parsed names}.
+ * @return the first element in the list of {@linkplain #getParsedNames() parsed names}.
*/
@Override
public LocalName head() {
@@ -218,7 +221,7 @@ public abstract class AbstractName imple
* If {@code this} name is {@code "org.opengis.util.Record"}
* (no matter its scope, then this method returns {@code "Record"}.</div>
*
- * @return The last element in the list of {@linkplain #getParsedNames() parsed names}.
+ * @return the last element in the list of {@linkplain #getParsedNames() parsed names}.
*/
@Override
public LocalName tip() {
@@ -231,7 +234,7 @@ public abstract class AbstractName imple
* of a fully qualified name is {@linkplain DefaultNameSpace#isGlobal() global}.
* If the scope of this name is already global, then this method returns {@code this}.
*
- * @return The fully-qualified name (never {@code null}).
+ * @return the fully-qualified name (never {@code null}).
*/
@Override
public synchronized GenericName toFullyQualifiedName() {
@@ -255,8 +258,8 @@ public abstract class AbstractName imple
* {@code "org.opengis"}, then {@code this.push(scope)} shall return
* {@code "org.opengis.util.Record"}.
*
- * @param scope The name to use as prefix.
- * @return A concatenation of the given scope with this name.
+ * @param scope the name to use as prefix.
+ * @return a concatenation of the given scope with this name.
*/
@Override
public ScopedName push(final GenericName scope) {
@@ -269,8 +272,8 @@ public abstract class AbstractName imple
* We really want {@link DefaultNameSpace#headSeparator}, not {@link DefaultNameSpace#separator}.
* See {@link DefaultNameSpace#child(CharSequence)} for details.
*
- * @param name The name after which to write a separator.
- * @return The separator to write after the given name.
+ * @param name the name after which to write a separator.
+ * @return the separator to write after the given name.
*/
static String separator(final GenericName name) {
if (name != null) {
@@ -296,7 +299,7 @@ public abstract class AbstractName imple
* any scope.</li>
* </ul>
*
- * @return A local-independent string representation of this name.
+ * @return a local-independent string representation of this name.
*/
@Override
public synchronized String toString() {
@@ -325,7 +328,7 @@ public abstract class AbstractName imple
* If no international string is available, then this method returns an implementation mapping
* to {@link #toString()} for all locales.
*
- * @return A localizable string representation of this name.
+ * @return a localizable string representation of this name.
*/
@Override
public synchronized InternationalString toInternationalString() {
@@ -359,8 +362,8 @@ public abstract class AbstractName imple
/**
* Constructs a new international string from the specified {@link AbstractName} fields.
*
- * @param asString The string representation of the enclosing abstract name.
- * @param parsedNames The value returned by {@link AbstractName#getParsedNames()}.
+ * @param asString the string representation of the enclosing abstract name.
+ * @param parsedNames the value returned by {@link AbstractName#getParsedNames()}.
*/
International(final String asString, final List<? extends LocalName> parsedNames) {
super(asString);
@@ -424,7 +427,7 @@ public abstract class AbstractName imple
* <li>Otherwise, returns 0.</li>
* </ul>
*
- * @param name The other name to compare with this name.
+ * @param name the other name to compare with this name.
* @return -1 if this name precedes the given one, +1 if it follows, 0 if equals.
*/
@Override
@@ -454,7 +457,7 @@ public abstract class AbstractName imple
* The default implementation returns {@code true} if the {@linkplain #scope() scopes}
* and the lists of {@linkplain #getParsedNames() parsed names} are equal.
*
- * @param object The object to compare with this name for equality.
+ * @param object the object to compare with this name for equality.
* @return {@code true} if the given object is equal to this name.
*/
@Override
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -166,6 +166,11 @@ public final class Errors extends Indexe
public static final short CloneNotSupported_1 = 20;
/**
+ * Cross references are not supported.
+ */
+ public static final short CrossReferencesNotSupported = 167;
+
+ /**
* Database error while creating a \u2018{0}\u2019 object for the \u201c{1}\u201d identifier.
*/
public static final short DatabaseError_2 = 21;
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] Wed Jan 4 09:17:26 2017
@@ -44,6 +44,7 @@ CanNotWriteFile_2 = Can
CircularReference = Circular reference.
ClassNotFinal_1 = Class \u2018{0}\u2019 is not final.
CloneNotSupported_1 = Can not clone an object of type \u2018{0}\u2019.
+CrossReferencesNotSupported = Cross references are not supported.
DatabaseError_2 = Database error while creating a \u2018{0}\u2019 object for the \u201c{1}\u201d identifier.
DeadThread_1 = Thread \u201c{0}\u201d is dead.
DisposedInstanceOf_1 = This instance of \u2018{0}\u2019 has been disposed.
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] Wed Jan 4 09:17:26 2017
@@ -41,6 +41,7 @@ CanNotWriteFile_2 = Ne p
CircularReference = R\u00e9f\u00e9rence circulaire.
ClassNotFinal_1 = La classe \u2018{0}\u2019 n\u2019est pas finale.
CloneNotSupported_1 = Un objet de type \u2018{0}\u2019 ne peut pas \u00eatre clon\u00e9.
+CrossReferencesNotSupported = Les r\u00e9f\u00e9rences crois\u00e9es ne sont pas support\u00e9es.
DatabaseError_2 = Erreur de base de donn\u00e9es lors de la cr\u00e9ation d\u2019un objet \u2018{0}\u2019 pour l\u2019identifiant \u00ab\u202f{1}\u202f\u00bb.
DeadThread_1 = La t\u00e2che \u00ab\u202f{0}\u202f\u00bb est morte.
DisposedInstanceOf_1 = Cette instance de \u2018{0}\u2019 a \u00e9t\u00e9 dispos\u00e9e.
Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -178,8 +178,8 @@ public final class TestRunner extends Bl
/**
* Creates a new test runner for the given class.
*
- * @param testClass The class to run.
- * @throws InitializationError If the test class is malformed.
+ * @param testClass the class to run.
+ * @throws InitializationError if the test class is malformed.
*/
public TestRunner(final Class<?> testClass) throws InitializationError {
super(testClass);
@@ -190,7 +190,7 @@ public final class TestRunner extends Bl
* verification documented in {@link BlockJUnit4ClassRunner#validateTestMethods(List)},
* then ensures that all {@link DependsOnMethod} annotations refer to an existing method.
*
- * @param errors The list where to report any problem found.
+ * @param errors the list where to report any problem found.
*/
@Override
protected void validateTestMethods(final List<Throwable> errors) {
@@ -217,7 +217,7 @@ public final class TestRunner extends Bl
/**
* Returns the test methods to be executed, with dependencies sorted before dependant tests.
*
- * @return The test method to be executed in dependencies order.
+ * @return the test methods to be executed in dependencies order.
*/
@Override
public List<FrameworkMethod> getChildren() {
@@ -227,7 +227,7 @@ public final class TestRunner extends Bl
/**
* Returns the test methods to be executed, with dependencies sorted before dependant tests.
*
- * @return The test method to be executed in dependencies order.
+ * @return the test methods to be executed in dependencies order.
*/
@SuppressWarnings("ReturnOfCollectionOrArrayField")
private FrameworkMethod[] getFilteredChildren() {
@@ -244,7 +244,7 @@ public final class TestRunner extends Bl
* conform to the sorter specification, since this method will ensure that dependencies
* are still sorted before dependant tests.
*
- * @param sorter The sorter to use for sorting tests.
+ * @param sorter the sorter to use for sorting tests.
*/
@Override
public void sort(final Sorter sorter) {
@@ -265,7 +265,7 @@ public final class TestRunner extends Bl
/**
* Sorts the given array of methods in dependencies order.
*
- * @param methods The methods to sort.
+ * @param methods the methods to sort.
*/
private static void sortDependantTestsLast(final FrameworkMethod[] methods) {
final Set<String> dependencies = new HashSet<>();
@@ -302,8 +302,8 @@ public final class TestRunner extends Bl
/**
* Removes tests that don't pass the parameter {@code filter}.
*
- * @param filter The filter to apply.
- * @throws NoTestsRemainException If all tests are filtered out.
+ * @param filter the filter to apply.
+ * @throws NoTestsRemainException if all tests are filtered out.
*/
@Override
public void filter(final Filter filter) throws NoTestsRemainException {
@@ -329,8 +329,8 @@ public final class TestRunner extends Bl
* Returns the {@link Statement} which will execute all the tests in the class given
* to the {@linkplain #TestRunner(Class) constructor}.
*
- * @param notifier The object to notify about test results.
- * @return The statement to execute for running the tests.
+ * @param notifier the object to notify about test results.
+ * @return the statement to execute for running the tests.
*/
@Override
protected Statement childrenInvoker(final RunNotifier notifier) {
@@ -353,8 +353,8 @@ public final class TestRunner extends Bl
* Before to delegate to the {@linkplain BlockJUnit4ClassRunner#runChild default implementation},
* check if a dependency of the given method failed. In such case, the test will be ignored.
*
- * @param method The test method to execute.
- * @param notifier The object to notify about test results.
+ * @param method the test method to execute.
+ * @param notifier the object to notify about test results.
*/
@Override
protected void runChild(final FrameworkMethod method, final RunNotifier notifier) {
@@ -381,7 +381,7 @@ public final class TestRunner extends Bl
* Declares that the given method failed.
* Other methods depending on this method will be ignored.
*
- * @param methodName The name of the method that failed.
+ * @param methodName the name of the method that failed.
*/
final void addDependencyFailure(final String methodName) {
if (methodDependencyFailures == null) {
Modified: sis/branches/JDK7/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatReader.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatReader.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatReader.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -446,7 +446,7 @@ final class LandsatReader {
case "ORIGIN": {
final Matcher m = CREDIT.matcher(value);
if (m.find()) {
- metadata.newParty(MetadataBuilder.ORGANISATION);
+ metadata.newParty(MetadataBuilder.PartyType.ORGANISATION);
metadata.addAuthor(value.substring(m.end()));
}
metadata.addCredits(value);
@@ -889,7 +889,7 @@ final class LandsatReader {
* @throws FactoryException if an error occurred while creating the Coordinate Reference System.
*/
final Metadata getMetadata() throws FactoryException {
- metadata.add(Locale.ENGLISH);
+ metadata.add(Locale.ENGLISH, MetadataBuilder.Scope.METADATA);
metadata.add(ScopeCode.COVERAGE);
try {
flushSceneTime();
Modified: sis/branches/JDK7/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -66,11 +66,6 @@ import org.apache.sis.util.Debug;
*/
public class LandsatStore extends DataStore {
/**
- * The file name.
- */
- private final String name;
-
- /**
* The reader, or {@code null} if closed.
*/
private Reader source;
@@ -91,7 +86,6 @@ public class LandsatStore extends DataSt
*/
public LandsatStore(final LandsatStoreProvider provider, final StorageConnector connector) throws DataStoreException {
super(provider, connector);
- name = connector.getStorageName();
source = connector.getStorageAs(Reader.class);
connector.closeAllExcept(source);
if (source == null) {
@@ -113,7 +107,7 @@ public class LandsatStore extends DataSt
if (metadata == null && source != null) try {
try (BufferedReader reader = (source instanceof BufferedReader) ? (BufferedReader) source : new LineNumberReader(source)) {
source = null; // Will be closed at the end of this try-catch block.
- final LandsatReader parser = new LandsatReader(name, listeners);
+ final LandsatReader parser = new LandsatReader(getDisplayName(), listeners);
parser.read(reader);
metadata = parser.getMetadata();
}
@@ -144,6 +138,6 @@ public class LandsatStore extends DataSt
@Debug
@Override
public String toString() {
- return getClass().getSimpleName() + '[' + name + ']';
+ return getClass().getSimpleName() + '[' + getDisplayName() + ']';
}
}
Modified: sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -110,7 +110,7 @@ public class GeoTiffStore extends DataSt
} catch (MetadataStoreException e) {
warning(null, e);
}
- builder.add(encoding);
+ builder.add(encoding, MetadataBuilder.Scope.METADATA);
builder.add(ScopeCode.COVERAGE);
final Locale locale = getLocale();
int n = 0;
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureStore.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureStore.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureStore.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -19,10 +19,12 @@ import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.StorageConnector;
import org.apache.sis.storage.DataStoreProvider;
import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.IllegalNameException;
// Branch-dependent imports
import org.apache.sis.internal.jdk8.Stream;
import org.opengis.feature.Feature;
+import org.opengis.feature.FeatureType;
/**
@@ -49,9 +51,38 @@ public abstract class FeatureStore exten
}
/**
- * Returns the stream of features.
+ * 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.
+ * The list of feature type names can be obtained from the {@linkplain #getMetadata() metadata} like below:
*
- * @return a stream over all features in the file.
+ * {@preformat java
+ * for (ContentInformation c : metadata.getContentInfo()) {
+ * if (c instanceof FeatureCatalogueDescription) {
+ * for (FeatureTypeInfo info : ((FeatureCatalogueDescription) c).getFeatureTypeInfo()) {
+ * GenericName name = info.getFeatureTypeName();
+ * // ... add the name to some list ...
+ * }
+ * }
+ * }
+ * }
+ *
+ * Implementation may also accept aliases for convenience. For example if the full name of a feature type
+ * 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.
+ *
+ * @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.
+ * @throws DataStoreException if another kind of error occurred while searching for feature types.
+ */
+ public abstract FeatureType getFeatureType(String name) throws DataStoreException;
+
+ /**
+ * Returns the stream of all features found in the data store.
+ * If a checked exception occurs during consumption of the returned stream, that exception will
+ * be wrapped in a unchecked {@link org.apache.sis.util.collection.BackingStoreException}.
+ *
+ * @return a stream over all features in the data store.
* @throws DataStoreException if an error occurred while creating the feature stream.
*/
public abstract Stream<Feature> getFeatures() throws DataStoreException;
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.nio.charset.Charset;
+import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Role;
@@ -76,6 +77,7 @@ import org.apache.sis.metadata.iso.linea
import org.apache.sis.metadata.iso.lineage.DefaultProcessing;
import org.apache.sis.metadata.sql.MetadataStoreException;
import org.apache.sis.metadata.sql.MetadataSource;
+import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.iso.Types;
@@ -102,24 +104,6 @@ import org.opengis.feature.FeatureType;
*/
public class MetadataBuilder {
/**
- * Instructs {@link #newParty(byte)} that the next party to create should be an instance of
- * {@link DefaultIndividual}.
- *
- * @see #partyType
- * @see #newParty(byte)
- */
- public static final byte INDIVIDUAL = 1;
-
- /**
- * Instructs {@link #newParty(byte)} that the next party to create should be an instance of
- * {@link DefaultOrganisation}.
- *
- * @see #partyType
- * @see #newParty(byte)
- */
- public static final byte ORGANISATION = 2;
-
- /**
* The metadata created by this reader, or {@code null} if none.
*/
private DefaultMetadata metadata;
@@ -216,14 +200,10 @@ public class MetadataBuilder {
/**
* Whether the next party to create should be an instance of {@link DefaultIndividual} or {@link DefaultOrganisation}.
- * Value can be {@link #INDIVIDUAL}, {@link #ORGANISATION} or 0 if unknown, in which case an {@link AbstractParty}
- * will be created.
*
- * @see #INDIVIDUAL
- * @see #ORGANISATION
- * @see #newParty(byte)
+ * @see #newParty(PartyType)
*/
- private byte partyType;
+ private PartyType partyType = PartyType.UNKNOWN;
/**
* {@code true} if the next {@code CoverageDescription} to create will be a description of measurements
@@ -265,6 +245,28 @@ public class MetadataBuilder {
}
/**
+ * The type of party to create (individual, organization or unknown).
+ */
+ public static enum PartyType {
+ /**
+ * Instructs {@link #newParty(PartyType)} that the next party to create should be an instance of
+ * {@link DefaultIndividual}.
+ */
+ INDIVIDUAL,
+
+ /**
+ * Instructs {@link #newParty(PartyType)} that the next party to create should be an instance of
+ * {@link DefaultOrganisation}.
+ */
+ ORGANISATION,
+
+ /**
+ * Instructs {@link #newParty(PartyType)} that the next party to create if of unknown type.
+ */
+ UNKNOWN
+ }
+
+ /**
* Commits all pending information under the "responsible party" node (author, address, <i>etc</i>).
* If there is no pending party information, then invoking this method has no effect
* except setting the {@code type} flag.
@@ -273,9 +275,10 @@ public class MetadataBuilder {
* <p>This method does not need to be invoked unless a new "responsible party" node,
* separated from the previous one, is desired.</p>
*
- * @param type {@link #INDIVIDUAL}, {@link #ORGANISATION} or 0 if unknown.
+ * @param type whether the party to create is an individual or an organization.
*/
- public final void newParty(final byte type) {
+ public final void newParty(final PartyType type) {
+ ArgumentChecks.ensureNonNull("type", type);
if (party != null) {
addIfNotPresent(responsibility().getParties(), party);
party = null;
@@ -295,7 +298,7 @@ public class MetadataBuilder {
/*
* Construction shall be ordered from children to parents.
*/
- newParty((byte) 0);
+ newParty(PartyType.UNKNOWN);
if (responsibility != null) {
addIfNotPresent(citation().getCitedResponsibleParties(), responsibility);
responsibility = null;
@@ -485,9 +488,10 @@ public class MetadataBuilder {
private AbstractParty party() {
if (party == null) {
switch (partyType) {
+ case UNKNOWN: party = new AbstractParty(); break;
case INDIVIDUAL: party = new DefaultIndividual(); break;
case ORGANISATION: party = new DefaultOrganisation(); break;
- default: party = new AbstractParty(); break;
+ default: throw new AssertionError(partyType);
}
}
return party;
@@ -654,32 +658,64 @@ public class MetadataBuilder {
}
/**
- * Adds a language used for documenting metadata.
- * Storage location is:
+ * Specify if an information apply to data, to metadata or to both.
+ */
+ public static enum Scope {
+ /**
+ * Information applies only to data.
+ */
+ DATA,
+
+ /**
+ * Information applies only to metadata.
+ */
+ METADATA,
+
+ /**
+ * Information applies to both data and metadata.
+ */
+ ALL
+ }
+
+ /**
+ * Adds a language used for documenting data and/or metadata.
+ * Storage locations are:
*
- * <pre>metadata/language</pre>
+ * <table class="compact" summary="Storage locations.">
+ * <tr><td>Metadata</td> <td>{@code metadata/language}</td></tr>
+ * <tr><td>Data</td> <td>{@code metadata/identificationInfo/language}</td></tr>
+ * </table>
*
- * @param language a language used for documenting metadata.
+ * @param language a language used for documenting data and/or metadata.
+ * @param scope whether the language applies to data, to metadata or to both.
*/
- public final void add(final Locale language) {
+ public final void add(final Locale language, final Scope scope) {
+ ArgumentChecks.ensureNonNull("scope", scope);
if (language != null) {
// No need to use 'addIfNotPresent(\u2026)' because Locale collection is a Set by default.
- metadata().getLanguages().add(language);
+ if (scope != Scope.DATA) metadata().getLanguages().add(language);
+ if (scope != Scope.METADATA) identification().getLanguages().add(language);
}
}
/**
- * Adds the given character encoding to the metadata.
- * Storage location is:
+ * Adds a character set used for encoding the data and/or metadata.
+ * Storage locations are:
*
- * <pre>metadata/characterSet</pre>
+ * <table class="compact" summary="Storage locations.">
+ * <tr><td>Metadata</td> <td>{@code metadata/characterSet}</td></tr>
+ * <tr><td>Data</td> <td>{@code metadata/identificationInfo/characterSet}</td></tr>
+ * </table>
*
- * @param encoding the character encoding to add.
+ * @param encoding the character set used for encoding data and/or metadata.
+ * @param scope whether the encoding applies to data, to metadata or to both.
*/
- public final void add(final Charset encoding) {
+ public final void add(final Charset encoding, final Scope scope) {
+ ArgumentChecks.ensureNonNull("scope", scope);
if (encoding != null) {
// No need to use 'addIfNotPresent(\u2026)' because Charset collection is a Set by default.
- metadata().getCharacterSets().add(encoding);
+ if (scope != Scope.DATA) metadata().getCharacterSets().add(encoding);
+ if (scope != Scope.METADATA) identification().getCharacterSets().add(encoding);
}
}
@@ -704,17 +740,29 @@ public class MetadataBuilder {
*
* <pre>metadata/contentInfo/featureTypes/featureTypeName</pre>
*
+ * This method returns the feature name for more convenient chaining with
+ * {@link org.apache.sis.storage.FeatureNaming#add FeatureNaming.add(\u2026)}.
+ * Note that the {@link FeatureCatalogBuilder} subclasses can also be used for that chaining.
+ *
* @param type the feature type to add, or {@code null}.
- * @param occurrences number of instances of the given features, or {@code null} if unknown.
+ * @param occurrences number of instances of the given feature type, or {@code null} if unknown.
+ * @return the name of the added feature, or {@code null} if none.
+ *
+ * @see FeatureCatalogBuilder#define(FeatureType)
*/
- public final void add(final FeatureType type, final Integer occurrences) {
+ public final GenericName add(final FeatureType type, final Integer occurrences) {
if (type != null) {
- final DefaultFeatureTypeInfo info = new DefaultFeatureTypeInfo(type.getName());
- if (occurrences != null) {
- info.setFeatureInstanceCount(shared(occurrences));
+ final GenericName name = type.getName();
+ if (name != null) {
+ final DefaultFeatureTypeInfo info = new DefaultFeatureTypeInfo(name);
+ if (occurrences != null) {
+ info.setFeatureInstanceCount(shared(occurrences));
+ }
+ addIfNotPresent(featureDescription().getFeatureTypeInfo(), info);
+ return name;
}
- addIfNotPresent(featureDescription().getFeatureTypeInfo(), info);
}
+ return null;
}
/**
@@ -1565,7 +1613,7 @@ parse: for (int i = 0; i < length;)
* If {@code freeze} is {@code true}, then the returned metadata instance can not be modified.
*
* @param freeze {@code true} if this method should {@linkplain DefaultMetadata#freeze() freeze}
- * the metadata instance before to return it.
+ * the metadata instance before to return it.
* @return the metadata, or {@code null} if none.
*/
public final DefaultMetadata build(final boolean freeze) {
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -61,6 +61,12 @@ public final class Resources extends Ind
}
/**
+ * Name \u201c{3}\u201d is ambiguous because it can be understood as either \u201c{1}\u201d or \u201c{2}\u201d in the context
+ * of \u201c{0}\u201d data.
+ */
+ public static final short AmbiguousName_4 = 15;
+
+ /**
* Can not read \u201c{1}\u201d as a file in the {0} format.
*/
public static final short CanNotReadFile_2 = 1;
@@ -92,6 +98,16 @@ public final class Resources extends Ind
public static final short ExcessiveStringSize_3 = 6;
/**
+ * A feature named \u201c{1}\u201d is already present in the \u201c{0}\u201d data store.
+ */
+ public static final short FeatureAlreadyPresent_2 = 16;
+
+ /**
+ * Feature \u201c{1}\u201d has not been found in the \u201c{0}\u201d data store.
+ */
+ public static final short FeatureNotFound_2 = 17;
+
+ /**
* The {0} data store does not accept features of type \u201c{1}\u201d.
*/
public static final short IllegalFeatureType_2 = 7;
@@ -107,9 +123,10 @@ public final class Resources extends Ind
public static final short IllegalOutputTypeForWriter_2 = 9;
/**
- * Components of the \u201c{0}\u201d name are inconsistent with those of the name that was added.
+ * Components of the \u201c{1}\u201d name are inconsistent with those of the name previously binded in
+ * \u201c{0}\u201d data store.
*/
- public static final short InconsistentNameComponents_1 = 10;
+ public static final short InconsistentNameComponents_2 = 10;
/**
* Missing scheme in \u201c{0}\u201d URI.
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties [ISO-8859-1] Wed Jan 4 09:17:26 2017
@@ -19,16 +19,19 @@
# Resources in this file are for "sis-netcdf" usage only and should not be used by any other module.
# For resources shared by all modules in the Apache SIS project, see "org.apache.sis.util.resources" package.
#
+AmbiguousName_4 = Name \u201c{3}\u201d is ambiguous because it can be understood as either \u201c{1}\u201d or \u201c{2}\u201d in the context of \u201c{0}\u201d data.
CanNotReadFile_2 = Can not read \u201c{1}\u201d as a file in the {0} format.
CanNotReadFile_3 = Can not read line {2} of \u201c{1}\u201d as part of a file in the {0} format.
CanNotReadFile_4 = Can not read line {2} (after column {3}) of \u201c{1}\u201d as part of a file in the {0} format.
ClosedReader_1 = This {0} reader is closed.
ClosedWriter_1 = This {0} writer is closed.
+FeatureAlreadyPresent_2 = A feature named \u201c{1}\u201d is already present in the \u201c{0}\u201d data store.
+FeatureNotFound_2 = Feature \u201c{1}\u201d has not been found in the \u201c{0}\u201d data store.
ExcessiveStringSize_3 = Character string in the \u201c{0}\u201d file is too long. The string has {2} characters while the limit is {1}.
IllegalFeatureType_2 = The {0} data store does not accept features of type \u201c{1}\u201d.
IllegalInputTypeForReader_2 = The {0} reader does not accept inputs of type \u2018{1}\u2019.
IllegalOutputTypeForWriter_2 = The {0} writer does not accept outputs of type \u2018{1}\u2019.
-InconsistentNameComponents_1 = Components of the \u201c{0}\u201d name are inconsistent with those of the name that was added.
+InconsistentNameComponents_2 = Components of the \u201c{1}\u201d name are inconsistent with those of the name previously binded in \u201c{0}\u201d data store.
MissingSchemeInURI_1 = Missing scheme in \u201c{0}\u201d URI.
ProcessingExecutedOn_1 = Processing executed on {0}.
StreamIsForwardOnly_1 = Can not move backward in the \u201c{0}\u201d stream.
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties [ISO-8859-1] Wed Jan 4 09:17:26 2017
@@ -24,16 +24,19 @@
# U+202F NARROW NO-BREAK SPACE before ; ! and ?
# U+00A0 NO-BREAK SPACE before :
#
+AmbiguousName_4 = Le nom \u00ab\u202f{3}\u202f\u00bb est ambigu\u00eb car il peut \u00eatre interpr\u00e9t\u00e9 aussi bien comme \u00ab\u202f{1}\u202f\u00bb ou \u00ab\u202f{2}\u202f\u00bb dans le contexte des donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
CanNotReadFile_2 = Ne peut pas lire \u00ab\u202f{1}\u202f\u00bb comme un fichier au format {0}.
CanNotReadFile_3 = Ne peut pas lire la ligne {2} de \u00ab\u202f{1}\u202f\u00bb comme une partie d\u2019un fichier au format {0}.
CanNotReadFile_4 = Ne peut pas lire la ligne {2} (apr\u00e8s la colonne {3}) de \u00ab\u202f{1}\u202f\u00bb comme une partie d\u2019un fichier au format {0}.
ClosedReader_1 = Ce lecteur {0} est ferm\u00e9.
ClosedWriter_1 = Cet encodeur {0} est ferm\u00e9.
ExcessiveStringSize_3 = La cha\u00eene de caract\u00e8res dans le fichier \u00ab\u202f{0}\u202f\u00bb est trop longue. La cha\u00eene fait {2} caract\u00e8res alors que la limite est {1}.
+FeatureAlreadyPresent_2 = Une entit\u00e9 nomm\u00e9e \u00ab\u202f{1}\u202f\u00bb est d\u00e9j\u00e0 pr\u00e9sente dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
+FeatureNotFound_2 = L\u2019entit\u00e9 \u00ab\u202f{1}\u202f\u00bb n\u2019est pas \u00e9t\u00e9 trouv\u00e9e dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
IllegalFeatureType_2 = Le format {0} ne stocke pas de donn\u00e9es de type \u00ab\u202f{1}\u202f\u00bb.
IllegalInputTypeForReader_2 = Le lecteur {0} n\u2019accepte pas des entr\u00e9s de type \u2018{1}\u2019.
IllegalOutputTypeForWriter_2 = Le l\u2019encodeur {0} n\u2019accepte pas des sorties de type \u2018{1}\u2019.
-InconsistentNameComponents_1 = Les \u00e9l\u00e9ments qui composent le nom \u00ab\u202f{0}\u202f\u00bb ne sont pas coh\u00e9rents avec ceux du nom qui avait \u00e9t\u00e9 ajout\u00e9.
+InconsistentNameComponents_2 = Les \u00e9l\u00e9ments qui composent le nom \u00ab\u202f{1}\u202f\u00bb ne sont pas coh\u00e9rents avec ceux du nom qui avait \u00e9t\u00e9 pr\u00e9c\u00e9demment li\u00e9 dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb.
MissingSchemeInURI_1 = Il manque le sch\u00e9ma dans l\u2019URI \u00ab\u202f{0}\u202f\u00bb.
ProcessingExecutedOn_1 = Traitement ex\u00e9cut\u00e9 sur {0}.
StreamIsForwardOnly_1 = Ne peut pas reculer dans le flux de donn\u00e9es \u00ab\u202f{0}\u202f\u00bb.
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -51,6 +51,7 @@ import org.apache.sis.internal.storage.F
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;
@@ -117,11 +118,6 @@ public final class Store extends Feature
private static final String TYPE_PREFIX = "xsd:";
/**
- * The file name, used for reporting error messages.
- */
- private final String filename;
-
- /**
* The reader, set by the constructor and cleared when no longer needed.
*/
private BufferedReader source;
@@ -183,11 +179,10 @@ public final class Store extends Feature
*/
public Store(final StoreProvider provider, final StorageConnector connector) throws DataStoreException {
super(provider, connector);
- filename = connector.getStorageName();
final Reader r = connector.getStorageAs(Reader.class);
connector.closeAllExcept(r);
if (r == null) {
- throw new DataStoreException(Errors.format(Errors.Keys.CanNotOpen_1, filename));
+ throw new DataStoreException(Errors.format(Errors.Keys.CanNotOpen_1, super.getDisplayName()));
}
source = (r instanceof BufferedReader) ? (BufferedReader) r : new LineNumberReader(r);
GeneralEnvelope envelope = null;
@@ -240,11 +235,11 @@ public final class Store extends Feature
}
source.reset();
} catch (IOException e) {
- throw new DataStoreException(getLocale(), "CSV", filename, source).initCause(e);
+ throw new DataStoreException(getLocale(), "CSV", super.getDisplayName(), source).initCause(e);
} catch (FactoryException e) {
- throw new DataStoreReferencingException(getLocale(), "CSV", filename, source).initCause(e);
+ throw new DataStoreReferencingException(getLocale(), "CSV", super.getDisplayName(), source).initCause(e);
} catch (IllegalArgumentException | DateTimeException e) {
- throw new DataStoreContentException(getLocale(), "CSV", filename, source).initCause(e);
+ throw new DataStoreContentException(getLocale(), "CSV", super.getDisplayName(), source).initCause(e);
}
this.encoding = connector.getOption(OptionKey.ENCODING);
this.envelope = envelope;
@@ -447,7 +442,7 @@ public final class Store extends Feature
}
properties.add(createProperty(name, type, minOccurrence));
}
- String name = filename;
+ String name = super.getDisplayName();
final int s = name.lastIndexOf('.');
if (s > 0) { // Exclude 0 because shall not be the first character.
name = name.substring(0, s);
@@ -497,12 +492,12 @@ public final class Store extends Feature
} catch (MetadataStoreException e) {
listeners.warning(null, e);
}
- builder.add(encoding);
+ builder.add(encoding, MetadataBuilder.Scope.ALL);
builder.add(ScopeCode.DATASET);
try {
builder.addExtent(envelope);
} catch (TransformException e) {
- throw new DataStoreReferencingException(getLocale(), "CSV", filename, source).initCause(e);
+ throw new DataStoreReferencingException(getLocale(), "CSV", getDisplayName(), source).initCause(e);
} catch (UnsupportedOperationException e) {
// Failed to set the temporal components if the sis-temporal module was
// not on the classpath, but the other dimensions still have been set.
@@ -515,6 +510,31 @@ public final class Store extends Feature
}
/**
+ * 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.
+ *
+ * @since 0.8
+ */
+ @Override
+ public FeatureType getFeatureType(String name) throws IllegalNameException {
+ if (featureType.getName().toString().equals(name)) {
+ return featureType;
+ }
+ throw new IllegalNameException(getLocale(), getDisplayName(), name);
+ }
+
+ /**
* Returns the stream of features.
*
* @return a stream over all features in the CSV file.
@@ -768,7 +788,7 @@ public final class Store extends Feature
* The error message will contain the line number if available.
*/
final String canNotParseFile() {
- final Object[] parameters = IOUtilities.errorMessageParameters("CSV", filename, source);
+ final Object[] parameters = IOUtilities.errorMessageParameters("CSV", getDisplayName(), source);
return errors().getString(IOUtilities.errorMessageKey(parameters), parameters);
}
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -58,11 +58,6 @@ final class Store extends DataStore {
private static final int SIZE_LIMIT = 1000000;
/**
- * The file name.
- */
- private final String name;
-
- /**
* The reader, set by the constructor and cleared when no longer needed.
*/
private Reader source;
@@ -88,11 +83,10 @@ final class Store extends DataStore {
public Store(final StoreProvider provider, final StorageConnector connector) throws DataStoreException {
super(provider, connector);
objects = new ArrayList<>();
- name = connector.getStorageName();
source = connector.getStorageAs(Reader.class);
connector.closeAllExcept(source);
if (source == null) {
- throw new DataStoreException(Errors.format(Errors.Keys.CanNotOpen_1, name));
+ throw new DataStoreException(Errors.format(Errors.Keys.CanNotOpen_1, super.getDisplayName()));
}
}
@@ -115,7 +109,7 @@ final class Store extends DataStore {
if ((length += n) >= buffer.length) {
if (n >= SIZE_LIMIT) {
throw new DataStoreContentException(Resources.format(
- Resources.Keys.ExcessiveStringSize_3, name, SIZE_LIMIT, n));
+ Resources.Keys.ExcessiveStringSize_3, getDisplayName(), SIZE_LIMIT, n));
}
buffer = Arrays.copyOf(buffer, n << 1);
}
@@ -138,9 +132,9 @@ final class Store extends DataStore {
}
} while (pos.getIndex() < wkt.length());
} catch (ParseException e) {
- throw new DataStoreContentException(getLocale(), "WKT", name, in).initCause(e);
+ throw new DataStoreContentException(getLocale(), "WKT", getDisplayName(), in).initCause(e);
} catch (IOException e) {
- throw new DataStoreException(getLocale(), "WKT", name, in).initCause(e);
+ throw new DataStoreException(getLocale(), "WKT", getDisplayName(), in).initCause(e);
}
}
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -57,11 +57,6 @@ import static java.util.Collections.sing
*/
final class Store extends DataStore {
/**
- * The file name.
- */
- private final String name;
-
- /**
* The input stream or reader, set by the constructor and cleared when no longer needed.
*/
private StreamSource source;
@@ -86,7 +81,6 @@ final class Store extends DataStore {
*/
public Store(final StoreProvider provider, final StorageConnector connector) throws DataStoreException {
super(provider, connector);
- name = connector.getStorageName();
final InputStream in = connector.getStorageAs(InputStream.class);
if (in != null) {
source = new StreamSource(in);
@@ -99,7 +93,7 @@ final class Store extends DataStore {
final Closeable c = input(source);
connector.closeAllExcept(c);
if (c == null) {
- throw new DataStoreException(Errors.format(Errors.Keys.CanNotOpen_1, name));
+ throw new DataStoreException(Errors.format(Errors.Keys.CanNotOpen_1, super.getDisplayName()));
}
}
@@ -154,7 +148,7 @@ final class Store extends DataStore {
in.close();
}
} catch (JAXBException | IOException e) {
- throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, name), e);
+ throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, getDisplayName()), e);
}
}
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -51,6 +51,14 @@ public abstract class DataStore implemen
protected final DataStoreProvider provider;
/**
+ * The store name (typically filename) for formatting error messages, or {@code null} if unknown.
+ * Shall <strong>not</strong> be used as an identifier.
+ *
+ * @see #getDisplayName()
+ */
+ private final String name;
+
+ /**
* The locale to use for formatting warnings.
* This is not the locale for formatting data in the storage.
*
@@ -69,6 +77,7 @@ public abstract class DataStore implemen
*/
protected DataStore() {
provider = null;
+ name = null;
locale = Locale.getDefault(Locale.Category.DISPLAY);
listeners = new WarningListeners<>(this);
}
@@ -87,17 +96,44 @@ public abstract class DataStore implemen
protected DataStore(final DataStoreProvider provider, final StorageConnector connector) throws DataStoreException {
ArgumentChecks.ensureNonNull("connector", connector);
this.provider = provider;
+ this.name = connector.getStorageName();
this.locale = Locale.getDefault(Locale.Category.DISPLAY);
this.listeners = new WarningListeners<>(this);
/*
- * A future version could fetch some information from the StorageConnector.
- * For now we do not, not even OptionKey.LOCALE because we are not talking
- * about the same locale (the one in this DataStore is for warning messages,
- * not for data).
+ * Above locale is NOT OptionKey.LOCALE because we are not talking about the same locale.
+ * The one in this DataStore is for warning and exception messages, not for parsing data.
*/
}
/**
+ * Returns a short name or label for this data store.
+ * The returned name can be used in user interfaces or in error messages.
+ * It may be a title in natural language, but should be relatively short.
+ * The name may be localized in the language specified by the value of {@link #getLocale()}
+ * if this data store is capable to produce a name in various languages.
+ *
+ * <p>This name should not be used as an identifier since there is no guarantee that the name
+ * is unique among data stores, and no guarantee that the name is the same in all locales.
+ * The name may also contain any Unicode characters, including characters usually not allowed
+ * in identifiers like white spaces.</p>
+ *
+ * <p>This method should never throw an exception since it may be invoked for producing error
+ * messages, in which case throwing an exception here would mask the original exception.</p>
+ *
+ * <p>Default implementation returns the {@link StorageConnector#getStorageName()} value,
+ * or {@code null} if this data store has been created by the no-argument constructor.
+ * Note that this default value may change in any future SIS version. Subclasses should
+ * override this method if they can provide a better name.</p>
+ *
+ * @return a short name of label for this data store, or {@code null} if unknown.
+ *
+ * @since 0.8
+ */
+ public String getDisplayName() {
+ return name;
+ }
+
+ /**
* The locale to use for formatting warnings and other messages. This locale if for user interfaces
* only \u2013 it has no effect on the data to be read or written from/to the data store.
*
Copied: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureNaming.java (from r1777268, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureNaming.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureNaming.java?p2=sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureNaming.java&p1=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureNaming.java&r1=1777268&r2=1777269&rev=1777269&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureNaming.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureNaming.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -28,6 +28,9 @@ import org.apache.sis.util.resources.Voc
import org.apache.sis.internal.util.CollectionsExt;
import org.apache.sis.internal.storage.Resources;
+// Branch-dependent imports
+import org.apache.sis.internal.jdk8.JDK8;
+
/**
* Helper class for mapping {@link GenericName} instances and their shortened names to features.
@@ -184,7 +187,7 @@ public class FeatureNaming<E> {
ArgumentChecks.ensureNonNull("name", name);
ArgumentChecks.ensureNonNull("value", value);
final String key = name.toString();
- if (values.putIfAbsent(key, value) != null) {
+ if (JDK8.putIfAbsent(values, key, value) != null) {
throw new IllegalNameException(locale(store), Resources.Keys.FeatureAlreadyPresent_2, name(store), key);
}
while (name instanceof ScopedName) {
@@ -242,7 +245,7 @@ public class FeatureNaming<E> {
} else if (remaining.size() == 1) {
final String select = remaining.get(0);
assert !select.equals(key) : select; // Should have been removed by removeFromMultiValuesMap(\u2026).
- error |= (values.putIfAbsent(alias, values.get(select)) != null);
+ error |= (JDK8.putIfAbsent(values, alias, values.get(select)) != null);
}
}
if (error) {
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalNameException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalNameException.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalNameException.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/IllegalNameException.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -16,6 +16,10 @@
*/
package org.apache.sis.storage;
+import java.util.Locale;
+import org.apache.sis.internal.storage.Resources;
+import org.apache.sis.util.resources.Vocabulary;
+
/**
* Thrown when an invalid name is used for identifying a coverage, a feature or other kind of element in a data store.
@@ -70,4 +74,27 @@ public class IllegalNameException extend
public IllegalNameException(final String message, final Throwable cause) {
super(message, cause);
}
+
+ /**
+ * Creates a new exception with a message saying that the feature of the given name has not been found.
+ *
+ * @param locale the locale for the message to be returned by {@link #getLocalizedMessage()}.
+ * @param store name of the data store for which the feature has not been found, or {@code null} if unknown.
+ * @param feature name of the feature that has not been found.
+ */
+ public IllegalNameException(final Locale locale, final String store, final String feature) {
+ super(locale, Resources.Keys.FeatureNotFound_2, (store != null) ? store
+ : Vocabulary.formatInternational(Vocabulary.Keys.Unnamed), feature);
+ }
+
+ /**
+ * Creates a new exception which will format a localized message in the given locale.
+ *
+ * @param locale the locale for the message to be returned by {@link #getLocalizedMessage()}.
+ * @param key one of {@link Resources.Keys} constants.
+ * @param parameters parameters to use for formatting the messages.
+ */
+ IllegalNameException(final Locale locale, final short key, final Object... parameters) {
+ super(locale, key, parameters);
+ }
}
Modified: sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java?rev=1777269&r1=1777268&r2=1777269&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java [UTF-8] Wed Jan 4 09:17:26 2017
@@ -30,7 +30,6 @@ import org.junit.BeforeClass;
* @module
*/
@Suite.SuiteClasses({
- org.apache.sis.internal.storage.GenericNameMapTest.class,
org.apache.sis.internal.storage.CodeTypeTest.class,
org.apache.sis.internal.storage.IOUtilitiesTest.class,
org.apache.sis.internal.storage.ChannelDataInputTest.class,
@@ -39,6 +38,7 @@ import org.junit.BeforeClass;
org.apache.sis.internal.storage.ChannelImageOutputStreamTest.class,
org.apache.sis.internal.storage.HyperRectangleReaderTest.class,
org.apache.sis.internal.storage.MetadataBuilderTest.class,
+ org.apache.sis.storage.FeatureNamingTest.class,
org.apache.sis.storage.ProbeResultTest.class,
org.apache.sis.storage.StorageConnectorTest.class,
org.apache.sis.internal.storage.xml.MimeTypeDetectorTest.class,