sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1778256 - in /sis/trunk: ./ core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/ core/sis-metadata/src/main/resources/org/apache/sis/metadata/sql/ core/sis-utility/src/test/java/org/apache/sis/test/mock/ storage/sis-storage/src/mai...
Date Wed, 11 Jan 2017 08:54:35 GMT
Author: desruisseaux
Date: Wed Jan 11 08:54:35 2017
New Revision: 1778256

URL: http://svn.apache.org/viewvc?rev=1778256&view=rev
Log:
Merge from the JDK7 branch.

Added:
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/AbstractProvider.java
      - copied unchanged from r1778248, sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/AbstractProvider.java
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/GeographicEnvelope.java
      - copied unchanged from r1778248, sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/GeographicEnvelope.java
Modified:
    sis/trunk/   (props changed)
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
    sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/metadata/sql/Create.sql
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/package-info.java
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/package-info.java
    sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/MimeTypeDetectorTest.java

Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 11 08:54:35 2017
@@ -1,5 +1,5 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394364-1758914
-/sis/branches/JDK7:1394913-1777943
-/sis/branches/JDK8:1584960-1777936
+/sis/branches/JDK7:1394913-1778248
+/sis/branches/JDK8:1584960-1778247
 /sis/branches/JDK9:1773327-1773512

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java?rev=1778256&r1=1778255&r2=1778256&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
[UTF-8] Wed Jan 11 08:54:35 2017
@@ -740,7 +740,7 @@ public class MetadataSource implements A
      *
      * @param  <T>         the parameterized type of the {@code type} argument.
      * @param  type        the interface to implement (e.g. {@link org.opengis.metadata.citation.Citation}),
-     *                     or the {@link CodeList} value.
+     *                     or the {@link CodeList} type.
      * @param  identifier  the identifier of the record for the metadata entity to be created.
      *                     This is usually the primary key of the record to search for.
      * @return an implementation of the required interface, or the code list element.

Modified: sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/metadata/sql/Create.sql
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/metadata/sql/Create.sql?rev=1778256&r1=1778255&r2=1778256&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/metadata/sql/Create.sql
[UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/resources/org/apache/sis/metadata/sql/Create.sql
[UTF-8] Wed Jan 11 08:54:35 2017
@@ -119,11 +119,13 @@ INSERT INTO metadata."CI_Citation" (ID,
   ('NetCDF',  'NetCDF',  'NetCDF Classic and 64-bit Offset Format'),
   ('PNG',     'PNG',     'PNG (Portable Network Graphics) Specification'),
   ('CSV',     'CSV',     'Common Format and MIME Type for Comma-Separated Values (CSV) Files'),
-  ('CSV-MF',  'CSV',     'OGC Moving Features Encoding Extension: Simple Comma-Separated
Values (CSV)');
+  ('CSV-MF',  'CSV',     'OGC Moving Features Encoding Extension: Simple Comma-Separated
Values (CSV)'),
+  ('GPX',     'GPX',     'GPS Exchange Format');
 
 INSERT INTO metadata."MD_Format" (ID, "name", "specification") VALUES
   ('GeoTIFF', 'GeoTIFF', 'GeoTIFF Coverage Encoding Profile'),
   ('NetCDF',  'NetCDF',  'NetCDF Classic and 64-bit Offset Format'),
   ('PNG',     'PNG',     'PNG (Portable Network Graphics) Specification'),
   ('CSV',     'CSV',     'Common Format and MIME Type for Comma-Separated Values (CSV) Files'),
-  ('CSV-MF',  'CSV',     'OGC Moving Features Encoding Extension: Simple Comma-Separated
Values (CSV)');
+  ('CSV-MF',  'CSV',     'OGC Moving Features Encoding Extension: Simple Comma-Separated
Values (CSV)'),
+  ('GPX',     'GPX',     'GPS Exchange Format');

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java?rev=1778256&r1=1778255&r2=1778256&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java [UTF-8]
(original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/mock/MetadataMock.java [UTF-8]
Wed Jan 11 08:54:35 2017
@@ -56,7 +56,7 @@ public final strictfp class MetadataMock
      * Creates an initially empty metadata with the given language.
      * Callers are free to assign new value to the {@link #language} field directly.
      *
-     * @param language The initial {@link #language} value (can be {@code null}).
+     * @param  language  the initial {@link #language} value (can be {@code null}).
      */
     public MetadataMock(final Locale language) {
         this.language = language;

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java?rev=1778256&r1=1778255&r2=1778256&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/StoreProvider.java
[UTF-8] Wed Jan 11 08:54:35 2017
@@ -37,7 +37,7 @@ import org.apache.sis.internal.storage.w
  * @version 0.8
  * @module
  */
-public class StoreProvider extends DataStoreProvider {
+public final class StoreProvider extends DataStoreProvider {
     /**
      * The object to use for verifying if the first keyword is the expected one.
      */

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java?rev=1778256&r1=1778255&r2=1778256&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/StoreProvider.java
[UTF-8] Wed Jan 11 08:54:35 2017
@@ -36,7 +36,7 @@ import org.apache.sis.util.Version;
  * @version 0.8
  * @module
  */
-public class StoreProvider extends DataStoreProvider {
+public final class StoreProvider extends DataStoreProvider {
     /**
      * The {@value} MIME type.
      */

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/package-info.java?rev=1778256&r1=1778255&r2=1778256&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/package-info.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/package-info.java
[UTF-8] Wed Jan 11 08:54:35 2017
@@ -20,7 +20,7 @@
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
- * @version 0.7
+ * @version 0.8
  * @module
  */
 package org.apache.sis.internal.storage.wkt;

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java?rev=1778256&r1=1778255&r2=1778256&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java
[UTF-8] Wed Jan 11 08:54:35 2017
@@ -17,12 +17,10 @@
 package org.apache.sis.internal.storage.xml;
 
 import java.util.Map;
-import java.util.HashMap;
 import java.util.Arrays;
 import java.io.IOException;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.ProbeResult;
-import org.apache.sis.xml.Namespaces;
 
 
 /**
@@ -38,7 +36,7 @@ import org.apache.sis.xml.Namespaces;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.8
  * @module
  */
 abstract class MimeTypeDetector {
@@ -46,13 +44,7 @@ abstract class MimeTypeDetector {
      * The mapping from XML namespace to MIME type.
      * This map shall be read-only, since we do not synchronize it.
      */
-    private static final Map<String,String> TYPES = new HashMap<>();
-    static {
-        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");
-        // More types to be added in future versions.
-    }
+    private final Map<String,String> types;
 
     /**
      * The {@code "xmlns"} string as a sequence of bytes.
@@ -86,8 +78,11 @@ abstract class MimeTypeDetector {
 
     /**
      * Creates a new instance.
+     *
+     * @param  types  the mapping from XML namespaces to MIME type.
      */
-    MimeTypeDetector() {
+    MimeTypeDetector(final Map<String,String> types) {
+        this.types = types;
     }
 
     /**
@@ -114,7 +109,7 @@ abstract class MimeTypeDetector {
      * Skips all bytes or characters up to {@code search}, then returns the character after
it.
      * Characters inside quotes will be ignored.
      *
-     * @param  search the byte or character to skip.
+     * @param  search  the byte or character to skip.
      * @return the byte or character after {@code search}, or -1 on EOF.
      * @throws IOException if an error occurred while reading the bytes or characters.
      */
@@ -255,7 +250,7 @@ abstract class MimeTypeDetector {
         /*
          * Done reading the "xmlns" attribute value.
          */
-        return TYPES.get(new String(buffer, 0, length, "US-ASCII"));
+        return types.get(new String(buffer, 0, length, "US-ASCII"));
     }
 
     /**

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java?rev=1778256&r1=1778255&r2=1778256&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
[UTF-8] Wed Jan 11 08:54:35 2017
@@ -63,7 +63,7 @@ final class Store extends DataStore {
 
     /**
      * The unmarshalled object, initialized only when first needed.
-     * May still {@code null} if the unmarshalling failed.
+     * May still be {@code null} if the unmarshalling failed.
      */
     private Object object;
 

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java?rev=1778256&r1=1778255&r2=1778256&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java
[UTF-8] Wed Jan 11 08:54:35 2017
@@ -16,14 +16,10 @@
  */
 package org.apache.sis.internal.storage.xml;
 
-import java.io.Reader;
-import java.io.IOException;
-import java.nio.ByteBuffer;
+import org.apache.sis.xml.Namespaces;
 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;
 
 
 /**
@@ -31,99 +27,19 @@ import org.apache.sis.storage.ProbeResul
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.7
+ * @version 0.8
  * @module
  */
-public class StoreProvider extends DataStoreProvider {
-    /**
-     * The {@value} MIME type, used only of {@link #probeContent(StorageConnector)} can not
determine
-     * a more accurate type.
-     */
-    public static final String MIME_TYPE = "application/xml";
-
-    /**
-     * The read-ahead limit when reading the XML document from a {@link Reader}.
-     */
-    private static final int READ_AHEAD_LIMIT = 2048;
-
-    /**
-     * The expected XML header. According XML specification, this declaration is required
to appear
-     * at the document beginning (no space allowed before the declaration).
-     */
-    private static final byte[] HEADER = {'<','?','x','m','l',' '};
-
+public final class StoreProvider extends AbstractProvider {
     /**
      * Creates a new provider.
      */
     public StoreProvider() {
-    }
-
-    /**
-     * Returns {@link ProbeResult#SUPPORTED} if the given storage appears to be supported
by {@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.
-     *
-     * @return {@link ProbeResult#SUPPORTED} if the given storage seems to be readable as
a XML file.
-     * @throws DataStoreException if an I/O or SQL error occurred.
-     */
-    @Override
-    public ProbeResult probeContent(final StorageConnector connector) throws DataStoreException
{
-        /*
-         * Usual case. This include InputStream, DataInput, File, Path, URL, URI.
-         */
-        final ByteBuffer buffer = connector.getStorageAs(ByteBuffer.class);
-        if (buffer != null) {
-            if (buffer.remaining() < HEADER.length) {
-                return ProbeResult.INSUFFICIENT_BYTES;
-            }
-            // Quick check for "<?xml " header.
-            for (int i=0; i<HEADER.length; i++) {
-                if (buffer.get(i) != HEADER[i]) {
-                    return ProbeResult.UNSUPPORTED_STORAGE;
-                }
-            }
-            // Now check for a more accurate MIME type.
-            buffer.position(HEADER.length);
-            final ProbeResult result = new MimeTypeDetector() {
-                @Override int read() {
-                    if (buffer.hasRemaining()) {
-                        return buffer.get();
-                    }
-                    insufficientBytes = (buffer.limit() != buffer.capacity());
-                    return -1;
-                }
-            }.probeContent();
-            buffer.position(0);
-            return result;
-        }
-        /*
-         * We should enter in this block only if the user gave us explicitely a Reader.
-         * A common case is a StringReader wrapping a String object.
-         */
-        final Reader reader = connector.getStorageAs(Reader.class);
-        if (reader != null) try {
-            // Quick check for "<?xml " header.
-            reader.mark(HEADER.length + READ_AHEAD_LIMIT);
-            for (int i=0; i<HEADER.length; i++) {
-                if (reader.read() != HEADER[i]) {
-                    reader.reset();
-                    return ProbeResult.UNSUPPORTED_STORAGE;
-                }
-            }
-            // Now check for a more accurate MIME type.
-            final ProbeResult result = new MimeTypeDetector() {
-                private int remaining = READ_AHEAD_LIMIT;
-                @Override int read() throws IOException {
-                    return (--remaining >= 0) ? reader.read() : -1;
-                }
-            }.probeContent();
-            reader.reset();
-            return result;
-        } catch (IOException e) {
-            throw new DataStoreException(e);
-        }
-        return ProbeResult.UNSUPPORTED_STORAGE;
+        super(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");
+        // More types to be added in future versions.
     }
 
     /**

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/package-info.java?rev=1778256&r1=1778255&r2=1778256&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/package-info.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/package-info.java
[UTF-8] Wed Jan 11 08:54:35 2017
@@ -16,13 +16,18 @@
  */
 
 /**
- * {@link org.apache.sis.storage.DataStore} implementation for XML files.
- * The kind of objects recognized by this package is listed in the
+ * {@link org.apache.sis.storage.DataStore} implementation for XML files that can be (un)marshalled
by the
+ * {@link org.apache.sis.xml.XML} class. The kind of objects recognized by this package is
listed in the
  * {@link org.apache.sis.internal.storage.xml.Store} class.
  *
+ * <p>This base package is designed for use with JAXB, which allows this package to
be very small since most of the
+ * XML (un)marshalling rules are specified in external classes designed for use with JAXB.
However some classes can
+ * also be used in other contexts. In particular, the {@link org.apache.sis.internal.storage.xml.stream}
package in
+ * the {@code sis-xmlstore} module extends this package with classes designed for use with
StAX cursor API.</p>
+ *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.7
+ * @version 0.8
  * @module
  */
 package org.apache.sis.internal.storage.xml;

Modified: sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/MimeTypeDetectorTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/MimeTypeDetectorTest.java?rev=1778256&r1=1778255&r2=1778256&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/MimeTypeDetectorTest.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/MimeTypeDetectorTest.java
[UTF-8] Wed Jan 11 08:54:35 2017
@@ -24,6 +24,8 @@ import org.apache.sis.test.DependsOnMeth
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
+import static java.util.Collections.singletonMap;
+import static org.apache.sis.xml.Namespaces.GMD;
 import static org.junit.Assert.*;
 
 
@@ -40,14 +42,14 @@ public final strictfp class MimeTypeDete
      * Tests a XML file in the {@value org.apache.sis.xml.Namespaces#GMD} namespace
      * read from a hard-coded string.
      *
-     * @throws IOException should never happen.
+     * @throws IOException if an error occurred while reading the bytes or characters.
      */
     @Test
     public void testGMDFromString() throws IOException {
         final StringReader in = new StringReader(StoreTest.XML);
         assertEquals('<', in.read());
         assertEquals('?', in.read());
-        final MimeTypeDetector detector = new MimeTypeDetector() {
+        final MimeTypeDetector detector = new MimeTypeDetector(singletonMap(GMD, "application/vnd.iso.19139+xml"))
{
             @Override int read() throws IOException {
                 return in.read();
             }
@@ -68,7 +70,7 @@ public final strictfp class MimeTypeDete
         final InputStream in = DefaultExtentTest.getResource("Extent.xml").openStream();
         assertEquals('<', in.read());
         assertEquals('?', in.read());
-        final MimeTypeDetector detector = new MimeTypeDetector() {
+        final MimeTypeDetector detector = new MimeTypeDetector(singletonMap(GMD, "application/vnd.iso.19139+xml"))
{
             @Override int read() throws IOException {
                 return in.read();
             }



Mime
View raw message