sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1778461 - in /sis/branches/JDK8: core/sis-utility/src/main/java/org/apache/sis/internal/simple/ core/sis-utility/src/main/java/org/apache/sis/setup/ core/sis-utility/src/main/java/org/apache/sis/util/resources/ storage/sis-earth-observatio...
Date Thu, 12 Jan 2017 19:30:49 GMT
Author: desruisseaux
Date: Thu Jan 12 19:30:48 2017
New Revision: 1778461

URL: http://svn.apache.org/viewvc?rev=1778461&view=rev
Log:
Allow the command-line tools to list available data stores.

Added:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleFormat.java   (with props)
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DocumentedStoreProvider.java   (with props)
Modified:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
    sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStoreProvider.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/AbstractProvider.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Metadata.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/StoreProvider.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStoreProvider.java

Added: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleFormat.java?rev=1778461&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleFormat.java (added)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleFormat.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.simple;
+
+import java.util.Collection;
+import java.util.Collections;
+import org.apache.sis.util.Debug;
+import org.opengis.util.InternationalString;
+import org.opengis.metadata.citation.Citation;
+import org.opengis.metadata.distribution.Distributor;
+import org.opengis.metadata.distribution.Format;
+import org.opengis.metadata.distribution.Medium;
+
+
+/**
+ * A trivial implementation of {@link Format} containing only the format name.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.8
+ * @version 0.8
+ * @module
+ */
+public class SimpleFormat extends SimpleCitation implements Format {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = 2673642991031129520L;
+
+    /**
+     * Creates a new format of the given short name or abbreviation.
+     *
+     * @param  name  a short name or abbreviation for the format.
+     */
+    public SimpleFormat(final String name) {
+        super(name);
+    }
+
+    /**
+     * Returns the format specification title, which is {@code null} by default.
+     *
+     * @return the format specification.
+     */
+    @Override
+    public InternationalString getTitle() {
+        return null;
+    }
+
+    /**
+     * Returns the format name given at construction time.
+     *
+     * @return the name given at construction time.
+     */
+    @Override
+    public Collection<InternationalString> getAlternateTitles() {
+        return Collections.singletonList(super.getTitle());
+    }
+
+    /**
+     * Citation / URL of the specification format.
+     *
+     * @return citation / URL of the specification format.
+     */
+    @Override
+    public Citation getFormatSpecificationCitation() {
+        return this;
+    }
+
+    /**
+     * @deprecated Replaced by {@link #getTitle()}
+     *
+     * @return name of a subset, profile, or product specification of the format, or {@code null}.
+     */
+    @Override
+    @Deprecated
+    public InternationalString getSpecification() {
+        return getTitle();
+    }
+
+    /**
+     * @deprecated Replaced by {@link #getAlternateTitles()}
+     *
+     * @return name of the data transfer format(s).
+     */
+    @Override
+    @Deprecated
+    public InternationalString getName() {
+        return super.getTitle();
+    }
+
+    /**
+     * @deprecated Replaced by {@link #getEdition()}
+     *
+     * @return version of the format.
+     */
+    @Override
+    @Deprecated
+    public InternationalString getVersion() {
+        return getEdition();
+    }
+
+    /**
+     * Amendment number of the format version.
+     *
+     * @return amendment number of the format version, or {@code null}.
+     */
+    @Override
+    public InternationalString getAmendmentNumber() {
+        return null;
+    }
+
+    /**
+     * Recommendations of algorithms or processes that can be applied to read
+     * or expand resources to which compression techniques have been applied.
+     *
+     * @return processes that can be applied to read resources to which compression techniques have been applied,
+     *         or {@code null}.
+     */
+    @Override
+    public InternationalString getFileDecompressionTechnique() {
+        return null;
+    }
+
+    /**
+     * Media used by the format.
+     *
+     * @return media used by the format.
+     */
+    @Override
+    public Collection<? extends Medium> getMedia() {
+        return Collections.emptyList();
+    }
+
+    /**
+     * Provides information about the distributor's format.
+     *
+     * @return information about the distributor's format.
+     */
+    @Override
+    public Collection<? extends Distributor> getFormatDistributors() {
+        return Collections.emptyList();
+    }
+
+    /**
+     * Returns a string representation of this format for debugging purpose.
+     */
+    @Debug
+    @Override
+    public String toString() {
+        return "Format[“" + title + "”]";
+    }
+}

Propchange: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleFormat.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleFormat.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -22,6 +22,7 @@ import java.util.Set;
 import java.util.EnumSet;
 import java.util.Map;
 import java.util.LinkedHashMap;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Date;
@@ -37,9 +38,12 @@ import java.io.IOException;
 import java.text.Format;
 import java.text.DateFormat;
 import java.text.FieldPosition;
+import java.nio.file.Path;
 import java.nio.charset.Charset;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import org.opengis.metadata.citation.Citation;
+import org.opengis.util.InternationalString;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.Version;
@@ -62,9 +66,6 @@ import static org.apache.sis.util.collec
 import static org.apache.sis.util.collection.TableColumn.VALUE_AS_TEXT;
 import static org.apache.sis.internal.util.StandardDateFormat.UTC;
 
-// Branch-dependent imports
-import java.nio.file.Path;
-
 
 /**
  * Provides information about the Apache SIS running environment.
@@ -83,7 +84,7 @@ import java.nio.file.Path;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.7
+ * @version 0.8
  * @module
  */
 public enum About {
@@ -95,6 +96,7 @@ public enum About {
      *   <li>Apache SIS version</li>
      *   <li>Java runtime version and vendor</li>
      *   <li>Operation system name and version</li>
+     *   <li>EPSG geodetic dataset in use</li>
      * </ul>
      */
     VERSIONS(Vocabulary.Keys.Versions),
@@ -113,6 +115,18 @@ public enum About {
     LOCALIZATION(Vocabulary.Keys.Localization),
 
     /**
+     * Information about available plugins.
+     * This section includes:
+     *
+     * <ul>
+     *   <li>List of data store implementations</li>
+     * </ul>
+     *
+     * @since 0.8
+     */
+    PLUGINS(Vocabulary.Keys.Plugins),
+
+    /**
      * Information about logging.
      */
     LOGGING(Vocabulary.Keys.Logging),
@@ -312,6 +326,28 @@ fill:   for (int i=0; ; i++) {
                     break;
                 }
                 case 9: {
+                    newSection = PLUGINS;
+                    if (sections.contains(PLUGINS)) try {
+                        final Collection<?> formats = (Collection<?>) Class.forName("org.apache.sis.storage.DataStores")
+                                                          .getMethod("formats", (Class[]) null).invoke((Object[]) null);
+                        final int count = formats.size();
+                        children = new String[count * 2];
+                        final String read = resources.getString(Vocabulary.Keys.Read);
+                        int j = 0;
+                        for (final Object f : formats) {
+                            children[j++] = read;
+                            children[j++] = titleAndName(((org.opengis.metadata.distribution.Format) f).getFormatSpecificationCitation(), locale);
+                        }
+                        value = resources.getString(Vocabulary.Keys.EntryCount_1, count);
+                    } catch (ClassNotFoundException e) {
+                        // sis-storage module not in the classpath - ignore.
+                    } catch (ReflectiveOperationException e) {
+                        value = e.toString();
+                    }
+                    nameKey = Vocabulary.Keys.DataFormats;
+                    break;
+                }
+                case 10: {
                     newSection = LOGGING;
                     if (sections.contains(LOGGING)) {
                         nameKey = Vocabulary.Keys.Implementation;
@@ -320,7 +356,7 @@ fill:   for (int i=0; ; i++) {
                     }
                     break;
                 }
-                case 10: {
+                case 11: {
                     if (sections.contains(LOGGING)) {
                         nameKey = Vocabulary.Keys.Level;
                         final Level level = Logging.getLogger("").getLevel();   // Root logger level.
@@ -337,7 +373,7 @@ fill:   for (int i=0; ; i++) {
                     }
                     break;
                 }
-                case 11: {
+                case 12: {
                     newSection = PATHS;
                     if (sections.contains(PATHS)) {
                         nameKey = Vocabulary.Keys.UserHome;
@@ -345,14 +381,14 @@ fill:   for (int i=0; ; i++) {
                     }
                     break;
                 }
-                case 12: {
+                case 13: {
                     if (sections.contains(PATHS)) {
                         nameKey = Vocabulary.Keys.CurrentDirectory;
                         value = getProperty("user.dir");
                     }
                     break;
                 }
-                case 13: {
+                case 14: {
                     if (sections.contains(PATHS)) {
                         nameKey = Vocabulary.Keys.DataDirectory;
                         try {
@@ -373,28 +409,28 @@ fill:   for (int i=0; ; i++) {
                     }
                     break;
                 }
-                case 14: {
+                case 15: {
                     if (sections.contains(PATHS)) {
                         nameKey = Vocabulary.Keys.DataBase;
                         value = MetadataServices.getInstance().getInformation("DataSource", locale);
                     }
                     break;
                 }
-                case 15: {
+                case 16: {
                     if (sections.contains(PATHS)) {
                         nameKey = Vocabulary.Keys.TemporaryFiles;
                         value = getProperty("java.io.tmpdir");
                     }
                     break;
                 }
-                case 16: {
+                case 17: {
                     if (sections.contains(PATHS)) {
                         nameKey = Vocabulary.Keys.JavaHome;
                         value = javaHome = getProperty("java.home");
                     }
                     break;
                 }
-                case 17: {
+                case 18: {
                     newSection = LIBRARIES;
                     if (sections.contains(LIBRARIES)) {
                         nameKey = Vocabulary.Keys.JavaExtensions;
@@ -402,7 +438,7 @@ fill:   for (int i=0; ; i++) {
                     }
                     break;
                 }
-                case 18: {
+                case 19: {
                     if (sections.contains(LIBRARIES)) {
                         nameKey = Vocabulary.Keys.Classpath;
                         value = classpath(getProperty("java.class.path"), false);
@@ -448,8 +484,7 @@ fill:   for (int i=0; ; i++) {
              * Special case for values of kind Map<File,String>.
              * They are extension paths or application class paths.
              */
-            @SuppressWarnings("unchecked")
-            final Map<File,String> paths = (Map<File,String>) value;
+            final Map<?,?> paths = (Map<?,?>) value;
 pathTree:   for (int j=0; ; j++) {
                 TreeTable.Node directory = null;
                 final String home;
@@ -466,9 +501,9 @@ pathTree:   for (int j=0; ; j++) {
                     continue;
                 }
                 final File homeDirectory = home.isEmpty() ? null : new File(home);
-                for (final Iterator<Map.Entry<File,String>> it=paths.entrySet().iterator(); it.hasNext();) {
-                    final Map.Entry<File,String> entry = it.next();
-                    File file = entry.getKey();
+                for (final Iterator<? extends Map.Entry<?,?>> it=paths.entrySet().iterator(); it.hasNext();) {
+                    final Map.Entry<?,?> entry = it.next();
+                    File file = (File) entry.getKey();
                     if (homeDirectory != null) {
                         file = relativize(homeDirectory, file);
                         if (file == null) continue;
@@ -477,9 +512,9 @@ pathTree:   for (int j=0; ; j++) {
                         directory = node.newChild();
                         directory.setValue(NAME, parenthesis(resources.getString(homeKey)));
                     }
-                    CharSequence title = entry.getValue();
+                    CharSequence title = (CharSequence) entry.getValue();
                     if (title == null || title.length() == 0) {
-                        title = parenthesis(resources.getString(entry.getKey().isDirectory() ?
+                        title = parenthesis(resources.getString(file.isDirectory() ?
                                 Vocabulary.Keys.Directory : Vocabulary.Keys.Untitled).toLowerCase(locale));
                     }
                     TreeTables.nodeForPath(directory, NAME, file).setValue(VALUE_AS_TEXT, title);
@@ -496,6 +531,33 @@ pathTree:   for (int j=0; ; j++) {
     }
 
     /**
+     * Returns the title or alternate title of the given citation, or "untitled" if none.
+     *
+     * @param  pt  {@code true} for preferring the title over alternate titles, or {@code false} for the opposite.
+     */
+    private static InternationalString title(final Citation ci, final boolean pt) {
+        final InternationalString title = ci.getTitle();
+        if (pt && title != null) return title;
+        for (final InternationalString t : ci.getAlternateTitles()) {
+            if (t != null) return t;
+        }
+        if (title != null) return title;
+        return Vocabulary.formatInternational(Vocabulary.Keys.Untitled);
+    }
+
+    /**
+     * Returns the title together with the abbreviation in parenthesis, if it exists and is different than the title.
+     */
+    private static String titleAndName(final Citation ci, final Locale locale) {
+        String title = title(ci, true).toString(locale);
+        final String abbreviation = title(ci, false).toString(locale);
+        if (!abbreviation.equals(title)) {
+            title = title + " (" + abbreviation + ')';
+        }
+        return title;
+    }
+
+    /**
      * Returns a map of all JAR files or class directories found in the given paths,
      * associated to a description obtained from their {@code META-INF/MANIFEST.MF}.
      *

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -177,6 +177,11 @@ public final class Vocabulary extends In
         public static final short DataDirectory = 24;
 
         /**
+         * Data formats
+         */
+        public static final short DataFormats = 119;
+
+        /**
          * Datum
          */
         public static final short Datum = 25;
@@ -262,6 +267,11 @@ public final class Vocabulary extends In
         public static final short EllipsoidalHeight = 41;
 
         /**
+         * {0} entr{0,choice,0#y|2#ies}
+         */
+        public static final short EntryCount_1 = 121;
+
+        /**
          * Geocentric
          */
         public static final short Geocentric = 42;
@@ -487,11 +497,21 @@ public final class Vocabulary extends In
         public static final short Paths = 86;
 
         /**
+         * Plug-ins
+         */
+        public static final short Plugins = 120;
+
+        /**
          * “{0}”
          */
         public static final short Quoted_1 = 87;
 
         /**
+         * Read
+         */
+        public static final short Read = 122;
+
+        /**
          * Remarks
          */
         public static final short Remarks = 88;
@@ -645,6 +665,11 @@ public final class Vocabulary extends In
          * World
          */
         public static final short World = 118;
+
+        /**
+         * Write
+         */
+        public static final short Write = 123;
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties [ISO-8859-1] Thu Jan 12 19:30:48 2017
@@ -38,6 +38,7 @@ CurrentDirectory        = Current direct
 CycleOmitted            = Cycle omitted
 DataBase                = Database
 DataDirectory           = Data directory
+DataFormats             = Data formats
 Datum                   = Datum
 DatumShift              = Datum shift
 DaylightTime            = Daylight time
@@ -55,6 +56,7 @@ DublinJulian            = Dublin Julian
 Ellipsoid               = Ellipsoid
 EllipsoidChange         = Ellipsoid change
 EllipsoidalHeight       = Ellipsoidal height
+EntryCount_1            = {0} entr{0,choice,0#y|2#ies}
 Geocentric              = Geocentric
 GeocentricRadius        = Geocentric radius
 GeocentricConversion    = Geocentric conversion
@@ -100,7 +102,9 @@ Options                 = Options
 Others                  = Others
 OtherSurface            = Other surface
 Paths                   = Paths
+Plugins                 = Plug-ins
 Quoted_1                = \u201c{0}\u201d
+Read                    = Read
 Remarks                 = Remarks
 RemoteConfiguration     = Remote configuration
 Root                    = Root
@@ -132,3 +136,4 @@ Versions                = Versions
 Vertical                = Vertical
 Warnings                = Warnings
 World                   = World
+Write                   = Write

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties [ISO-8859-1] Thu Jan 12 19:30:48 2017
@@ -45,6 +45,7 @@ CurrentDirectory        = R\u00e9pertoir
 CycleOmitted            = Cycle omit
 DataBase                = Base de donn\u00e9es
 DataDirectory           = R\u00e9pertoire des donn\u00e9es
+DataFormats             = Formats de donn\u00e9es
 Datum                   = R\u00e9f\u00e9rentiel
 DatumShift              = Changement de r\u00e9f\u00e9rentiel
 DaylightTime            = Heure normale
@@ -62,6 +63,7 @@ DublinJulian            = Julien Dublin
 Ellipsoid               = Ellipso\u00efde
 EllipsoidChange         = Changement d\u2019ellipso\u00efde
 EllipsoidalHeight       = Hauteur ellipso\u00efdale
+EntryCount_1            = {0} entr\u00e9e{0,choice,0#|2#s}
 Geocentric              = G\u00e9ocentrique
 GeocentricRadius        = Rayon g\u00e9ocentrique
 GeocentricConversion    = Conversion g\u00e9ocentrique
@@ -107,7 +109,9 @@ Options                 = Options
 Others                  = Autres
 OtherSurface            = Autre surface
 Paths                   = Chemins
+Plugins                 = Modules d\u2019extension
 Quoted_1                = \u00ab\u202f{0}\u202f\u00bb
+Read                    = Lecture
 Remarks                 = Remarques
 RemoteConfiguration     = Configuration distante
 Root                    = Racine
@@ -139,3 +143,4 @@ Versions                = Versions
 Vertical                = Vertical
 Warnings                = Avertissements
 World                   = Monde
+Write                   = \u00c9criture

Modified: sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStoreProvider.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStoreProvider.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -123,6 +123,16 @@ public class LandsatStoreProvider extend
     }
 
     /**
+     * Returns a generic name for this data store, used mostly in warnings or error messages.
+     *
+     * @return a short name or abbreviation for the data format.
+     */
+    @Override
+    public String getShortName() {
+        return "Landsat";
+    }
+
+    /**
      * Returns {@link ProbeResult#SUPPORTED} if the given storage appears to be supported by {@link LandsatStore}.
      * Returning {@code SUPPORTED} from this method does not guarantee that reading or writing will succeed, only
      * that there appears to be a reasonable chance of success based on a brief inspection of the storage header.

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStoreProvider.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -59,6 +59,16 @@ public class GeoTiffStoreProvider extend
     }
 
     /**
+     * Returns a generic name for this data store, used mostly in warnings or error messages.
+     *
+     * @return a short name or abbreviation for the data format.
+     */
+    @Override
+    public String getShortName() {
+        return "GeoTIFF";
+    }
+
+    /**
      * Returns {@link ProbeResult#SUPPORTED} if the given storage appears to be supported by {@link GeoTiffStore}.
      * Returning {@code SUPPORTED} from this method does not guarantee that reading or writing will succeed,
      * only that there appears to be a reasonable chance of success based on a brief inspection of the

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -113,6 +113,16 @@ public class NetcdfStoreProvider extends
     }
 
     /**
+     * Returns a generic name for this data store, used mostly in warnings or error messages.
+     *
+     * @return a short name or abbreviation for the data format.
+     */
+    @Override
+    public String getShortName() {
+        return "NetCDF";
+    }
+
+    /**
      * Returns {@link ProbeResult#SUPPORTED} if the given storage appears to be supported by {@link NetcdfStore}.
      * Returning {@code SUPPORTED} from this method does not guarantee that reading or writing will succeed,
      * only that there appears to be a reasonable chance of success based on a brief inspection of the

Added: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DocumentedStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DocumentedStoreProvider.java?rev=1778461&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DocumentedStoreProvider.java (added)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DocumentedStoreProvider.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.storage;
+
+import java.util.logging.Logger;
+import org.opengis.metadata.distribution.Format;
+import org.apache.sis.metadata.sql.MetadataSource;
+import org.apache.sis.metadata.sql.MetadataStoreException;
+import org.apache.sis.storage.DataStore;
+import org.apache.sis.storage.DataStoreProvider;
+import org.apache.sis.util.logging.Logging;
+import org.apache.sis.util.logging.WarningListeners;
+import org.apache.sis.internal.system.Modules;
+
+
+/**
+ * Base class of data store provider having an entry in the metadata SQL database.
+ * The primary key in the {@code MD_Format} table must be the name given at construction time.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.8
+ * @version 0.8
+ * @module
+ */
+public abstract class DocumentedStoreProvider extends DataStoreProvider {
+    /**
+     * The primary key to use for searching in the {@code MD_Format} table, or {@code null} if none.
+     * This primary name is also the value returned by {@link #getShortName()} default implementation.
+     */
+    private final String name;
+
+    /**
+     * {@code true} if the call to {@link #getFormat()} caught an exception. In such case,
+     * we log a warning only the first time and use a finer logging level the other times.
+     * The intend is to avoid polluting the logs with too many warnings.
+     */
+    private volatile boolean logged;
+
+    /**
+     * Creates a new provider.
+     * The primary key given in argument is also the value returned by {@link #getShortName()} default implementation.
+     * If this is not the desired value for the format short name, then subclass should override {@code getShortName()}.
+     *
+     * @param  name  the primary key to use for searching in the {@code MD_Format} table, or {@code null} if none.
+     */
+    protected DocumentedStoreProvider(final String name) {
+        this.name = name;
+    }
+
+    /**
+     * Returns a short name or abbreviation for the data format.
+     * The default implementation returns the primary key given at construction time.
+     * If that primary key is not an appropriate format short name, then subclass should override this method.
+     *
+     * @return a short name or abbreviation for the data format.
+     */
+    @Override
+    public String getShortName() {
+        return name;
+    }
+
+    /**
+     * Returns a more complete description of the format.
+     *
+     * @return a description of the data format.
+     */
+    @Override
+    public final Format getFormat() {
+        return getFormat(null);
+    }
+
+    /**
+     * Returns a more complete description of the format, sending warnings to the given listeners if non-null.
+     *
+     * @param  listeners  where to report the warning in case of error, or {@code null} if none.
+     * @return a description of the data format.
+     */
+    public final Format getFormat(final WarningListeners<DataStore> listeners) {
+        /*
+         * Note: this method does not cache the format because such caching is already done by MetadataSource.
+         */
+        if (name != null) try {
+            return MetadataSource.getProvided().lookup(Format.class, name);
+        } catch (MetadataStoreException e) {
+            if (listeners != null) {
+                listeners.warning(null, e);
+            } else {
+                final Logger logger = Logging.getLogger(Modules.STORAGE);
+                if (!logged) {
+                    logged = true;      // Not atomic - not a big deal if we use warning level twice.
+                    Logging.unexpectedException(logger, getClass(), "getFormat", e);
+                } else {
+                    Logging.recoverableException(logger, getClass(), "getFormat", e);
+                }
+            }
+        }
+        return super.getFormat();
+    }
+}

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

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

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -99,6 +99,16 @@ public final class StoreProvider extends
     }
 
     /**
+     * Returns a generic name for this data store, used mostly in warnings or error messages.
+     *
+     * @return a short name or abbreviation for the data format.
+     */
+    @Override
+    public String getShortName() {
+        return "CSV";
+    }
+
+    /**
      * Returns {@link ProbeResult#SUPPORTED} if the given storage appears to be supported by CSV {@link Store}.
      * Returning {@code SUPPORTED} from this method does not guarantee that reading or writing will succeed, only
      * that there appears to be a reasonable chance of success based on a brief inspection of the storage header.

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -143,6 +143,16 @@ public final class StoreProvider extends
     }
 
     /**
+     * Returns a generic name for this data store, used mostly in warnings or error messages.
+     *
+     * @return a short name or abbreviation for the data format.
+     */
+    @Override
+    public String getShortName() {
+        return "WKT";
+    }
+
+    /**
      * Returns {@link ProbeResult#SUPPORTED} if the given storage appears to be supported by WKT {@link Store}.
      * Returning {@code SUPPORTED} from this method does not guarantee that reading or writing will succeed,
      * only that there appears to be a reasonable chance of success based on a brief inspection of the storage

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/AbstractProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/AbstractProvider.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/AbstractProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/AbstractProvider.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -22,10 +22,10 @@ import java.io.Reader;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import org.apache.sis.storage.DataStore;
-import org.apache.sis.storage.DataStoreProvider;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.ProbeResult;
+import org.apache.sis.internal.storage.DocumentedStoreProvider;
 
 
 /**
@@ -38,7 +38,7 @@ import org.apache.sis.storage.ProbeResul
  * @version 0.8
  * @module
  */
-public abstract class AbstractProvider extends DataStoreProvider {
+public abstract class AbstractProvider extends DocumentedStoreProvider {
     /**
      * The {@value} MIME type, used only if {@link #probeContent(StorageConnector)} can not determine
      * a more accurate type.
@@ -73,9 +73,11 @@ public abstract class AbstractProvider e
      * Creates a new provider. Subclasses shall populate the {@link #types} map with a mapping
      * from their namespace to the MIME type to declare.
      *
+     * @param  name  the primary key to use for searching in the {@code MD_Format} table, or {@code null} if none.
      * @param  initialCapacity  initial capacity of the hash map to create.
      */
-    protected AbstractProvider(final int initialCapacity) {
+    protected AbstractProvider(final String name, final int initialCapacity) {
+        super(name);
         types = new HashMap<>(initialCapacity);
     }
 

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -35,7 +35,7 @@ public final class StoreProvider extends
      * Creates a new provider.
      */
     public StoreProvider() {
-        super(8);
+        super(null, 8);
         types.put(Namespaces.GML, "application/gml+xml");
         types.put(Namespaces.GMD, "application/vnd.iso.19139+xml");
         types.put(Namespaces.CSW, "application/vnd.ogc.csw_xml");
@@ -43,6 +43,16 @@ public final class StoreProvider extends
     }
 
     /**
+     * Returns a generic name for this data store, used mostly in warnings or error messages.
+     *
+     * @return a short name or abbreviation for the data format.
+     */
+    @Override
+    public String getShortName() {
+        return "XML";
+    }
+
+    /**
      * Returns a {@link Store} implementation associated with this provider.
      *
      * @param  connector  information about the storage (URL, stream, <i>etc</i>).

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -16,6 +16,11 @@
  */
 package org.apache.sis.storage;
 
+import org.opengis.metadata.distribution.Format;
+import org.apache.sis.internal.simple.SimpleFormat;
+import org.apache.sis.metadata.iso.citation.DefaultCitation;
+import org.apache.sis.metadata.iso.distribution.DefaultFormat;
+
 
 /**
  * Provides information about a specific {@link DataStore} implementation.
@@ -46,7 +51,7 @@ package org.apache.sis.storage;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.8
  * @module
  */
 public abstract class DataStoreProvider {
@@ -57,6 +62,61 @@ public abstract class DataStoreProvider
     }
 
     /**
+     * Returns a short name or abbreviation for the data format.
+     * This name is used in some warnings or exception messages.
+     * It may contain any characters, including white spaces
+     * (i.e. this short name is <strong>not</strong> a format identifier).
+     *
+     * <div class="note"><b>Examples:</b>
+     * {@code "CSV"}, {@code "GeoTIFF"}, {@code "GML"}, {@code "GPX"}, {@code "JPEG"}, {@code "JPEG 2000"},
+     * {@code "NetCDF"}, {@code "PNG"}, {@code "Shapefile"}.
+     * </div>
+     *
+     * For a more comprehensive format name, see {@link #getFormat()}.
+     *
+     * @return a short name or abbreviation for the data format.
+     *
+     * @see #getFormat()
+     *
+     * @since 0.8
+     */
+    public abstract String getShortName();
+
+    /**
+     * Returns a description of the data format. The description should contain (if available):
+     *
+     * <ul>
+     *   <li>A reference to the {@linkplain DefaultFormat#getFormatSpecificationCitation()
+     *       format specification citation}, including:
+     *     <ul>
+     *       <li>a format specification {@linkplain DefaultCitation#getTitle() title}
+     *           (example: <cite>“PNG (Portable Network Graphics) Specification”</cite>),</li>
+     *       <li>the format {@linkplain #getShortName() short name} as a citation
+     *           {@linkplain DefaultCitation#getAlternateTitles() alternate title}
+     *           (example: <cite>“PNG”</cite>),</li>
+     *       <li>the format version as the citation {@linkplain DefaultCitation#getEdition() edition},</li>
+     *       <li>link to an {@linkplain DefaultCitation#getOnlineResources() online} version of the specification.</li>
+     *     </ul>
+     *   </li>
+     *   <li>The title of the {@linkplain DefaultFormat#getFileDecompressionTechnique() file decompression technique}
+     *       used for reading the data.</li>
+     * </ul>
+     *
+     * The default implementation returns a format containing only the value returned by {@link #getShortName()}.
+     * Subclasses are encouraged to override this method for providing a more complete description, if available.
+     *
+     * @return a description of the data format.
+     *
+     * @see #getShortName()
+     * @see DefaultFormat
+     *
+     * @since 0.8
+     */
+    public Format getFormat() {
+        return new SimpleFormat(getShortName());
+    }
+
+    /**
      * Indicates if the given storage appears to be supported by the {@code DataStore}s created by this provider.
      * The most typical return values are:
      *

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -18,10 +18,13 @@ package org.apache.sis.storage;
 
 import java.util.List;
 import java.util.LinkedList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.ServiceLoader;
+import org.opengis.metadata.distribution.Format;
 import org.apache.sis.internal.storage.Resources;
 import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.internal.util.LazySet;
 import org.apache.sis.util.ArgumentChecks;
 
 
@@ -52,6 +55,11 @@ final class DataStoreRegistry {
     private final ServiceLoader<DataStoreProvider> loader;
 
     /**
+     * Immutable set of available formats, created when first needed.
+     */
+    private Collection<Format> formats;
+
+    /**
      * Creates a new registry which will look for data stores accessible to the default class loader.
      * The default is the current thread {@linkplain Thread#getContextClassLoader() context class loader},
      * provided that it can access at least the Apache SIS stores.
@@ -216,4 +224,37 @@ search:         while (!deferred.isEmpty
         }
         return selected;
     }
+
+    /**
+     * Returns the list of data formats available at this method invocation time.
+     * More data may be added later if new modules are added on the classpath.
+     *
+     * @return descriptions of available data formats.
+     *
+     * @since 0.8
+     */
+    @SuppressWarnings("ReturnOfCollectionOrArrayField")
+    public Collection<Format> formats() {
+        synchronized (loader) {
+            if (formats == null) {
+                final Iterator<DataStoreProvider> providers = loader.iterator();
+                formats = new LazySet<>(new Iterator<Format>() {
+                    @Override public boolean hasNext() {
+                        synchronized (loader) {
+                            return providers.hasNext();
+                        }
+                    }
+
+                    @Override public Format next() {
+                        final DataStoreProvider provider;
+                        synchronized (loader) {
+                            provider = providers.next();
+                        }
+                        return provider.getFormat();
+                    }
+                });
+            }
+            return formats;
+        }
+    }
 }

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -16,6 +16,8 @@
  */
 package org.apache.sis.storage;
 
+import java.util.Collection;
+import org.opengis.metadata.distribution.Format;
 import org.apache.sis.util.Static;
 import org.apache.sis.internal.system.Modules;
 import org.apache.sis.internal.system.SystemListener;
@@ -28,7 +30,7 @@ import org.apache.sis.internal.system.Sy
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.8
  * @module
  */
 public final class DataStores extends Static {
@@ -110,4 +112,16 @@ public final class DataStores extends St
     public static DataStore open(final Object storage) throws UnsupportedStorageException, DataStoreException {
         return registry().open(storage);
     }
+
+    /**
+     * Returns the set of data formats available at this method invocation time.
+     * More data may be added later if new modules are added on the classpath.
+     *
+     * @return descriptions of available data formats.
+     *
+     * @since 0.8
+     */
+    public static Collection<Format> formats() {
+        return registry().formats();
+    }
 }

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Metadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Metadata.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Metadata.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Metadata.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -169,6 +169,13 @@ public final class Metadata extends Simp
     public Bounds bounds;
 
     /**
+     * The format returned by {@link #getResourceFormats()}, created when first needed.
+     *
+     * @see #getResourceFormats()
+     */
+    private Format format;
+
+    /**
      * Creates an initially empty metadata object.
      */
     public Metadata() {
@@ -375,6 +382,7 @@ public final class Metadata extends Simp
      */
     @Override
     public Collection<ContentInformation> getContentInfo() {
+        final Store store = this.store;
         return (store != null) ? store.types.metadata : super.getContentInfo();
     }
 
@@ -385,12 +393,16 @@ public final class Metadata extends Simp
      * @return description of the format of the resource(s).
      */
     @Override
-    public synchronized Collection<Format> getResourceFormats() {
+    public Collection<Format> getResourceFormats() {
+        final Store store = this.store;
         if (store != null) {
-            final Format f = store.getFormat();
-            if (f != null) {
-                return Collections.singletonList(f);
+            Format f;
+            synchronized (store) {
+                if ((f = format) == null) {
+                    format = f = store.getFormat();
+                }
             }
+            return Collections.singletonList(f);
         }
         return super.getResourceFormats();
     }

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=1778461&r1=1778460&r2=1778461&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] Thu Jan 12 19:30:48 2017
@@ -28,8 +28,9 @@ import org.apache.sis.internal.storage.x
 import org.apache.sis.util.collection.BackingStoreException;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Version;
-import org.apache.sis.metadata.sql.MetadataSource;
-import org.apache.sis.metadata.sql.MetadataStoreException;
+import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.metadata.iso.citation.DefaultCitation;
+import org.apache.sis.metadata.iso.distribution.DefaultFormat;
 
 // Branch-dependent imports
 import java.util.stream.Stream;
@@ -97,25 +98,23 @@ public final class Store extends StaxDat
     }
 
     /**
-     * Returns the short name (abbreviation) of the format being read or written.
+     * Returns a more complete description of the GPX format.
+     * The format will be part of the metadata returned by {@link #getMetadata()}.
      *
-     * @return {@code "GPX"}.
-     */
-    @Override
-    public String getFormatName() {
-        return "GPX";
-    }
-
-    /**
-     * Returns a more complete description of the GPX format, or {@code null} if not available.
+     * @see StoreProvider#getFormat()
+     * @see org.apache.sis.internal.storage.gpx.Metadata#getResourceFormats()
      */
     final Format getFormat() {
-        try {
-            return MetadataSource.getProvided().lookup(Format.class, "GPX");
-        } catch (MetadataStoreException e) {
-            listeners.warning(null, e);
+        assert Thread.holdsLock(this);
+        Format format = ((StoreProvider) provider).getFormat(listeners);
+        if (version != null) {
+            final DefaultFormat df = new DefaultFormat(format);
+            final DefaultCitation citation = new DefaultCitation(df.getFormatSpecificationCitation());
+            citation.setEdition(new SimpleInternationalString(version.toString()));
+            df.setFormatSpecificationCitation(citation);
+            format = df;
         }
-        return null;
+        return format;
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/StoreProvider.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/StoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/StoreProvider.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -39,7 +39,7 @@ public final class StoreProvider extends
      * Creates a new GPX store provider.
      */
     public StoreProvider() {
-        super(4);
+        super("GPX", 4);
         types.put(Tags.NAMESPACE_V10, "application/gpx+xml");
         types.put(Tags.NAMESPACE_V11, "application/gpx+xml");
     }

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -355,8 +355,12 @@ public abstract class StaxDataStore exte
      * This is used for error messages.
      *
      * @return short name of format being read or written.
+     *
+     * @see StaxDataStoreProvider#getShortName()
      */
-    public abstract String getFormatName();
+    public final String getFormatName() {
+        return provider.getShortName();
+    }
 
     /**
      * Returns the factory for StAX readers. The same instance is returned for all {@code StaxDataStore} lifetime.

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStoreProvider.java?rev=1778461&r1=1778460&r2=1778461&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStoreProvider.java [UTF-8] Thu Jan 12 19:30:48 2017
@@ -43,10 +43,11 @@ public abstract class StaxDataStoreProvi
      * Creates a new provider. Subclasses shall populate the {@link #types} map with a mapping
      * from their namespace to the MIME type to declare.
      *
+     * @param  name  the primary key to use for searching in the {@code MD_Format} table, or {@code null} if none.
      * @param  initialCapacity  initial capacity of the hash map to create.
      */
-    protected StaxDataStoreProvider(final int initialCapacity) {
-        super(initialCapacity);
+    protected StaxDataStoreProvider(final String name, final int initialCapacity) {
+        super(name, initialCapacity);
     }
 
     /**



Mime
View raw message