sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1774013 [1/2] - in /sis/branches/JDK8: core/sis-utility/src/main/java/org/apache/sis/internal/system/ core/sis-utility/src/main/java/org/apache/sis/util/resources/ core/sis-utility/src/main/java/org/apache/sis/xml/ core/sis-utility/src/tes...
Date Tue, 13 Dec 2016 13:38:26 GMT
Author: desruisseaux
Date: Tue Dec 13 13:38:26 2016
New Revision: 1774013

URL: http://svn.apache.org/viewvc?rev=1774013&view=rev
Log:
Cleanup StaxStreamWriter. Skeleton of StaxDataStore.

Added:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/InputFactory.java
      - copied, changed from r1774012, sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/XMLInputFactory.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/OutputFactory.java
      - copied, changed from r1774012, sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/XMLOutputFactory.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/xml/NamespacesTest.java   (with props)
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxDataStore.java
      - copied, changed from r1773750, sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/XMLStoreProvider.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxDataStoreProvider.java
      - copied, changed from r1774012, sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/XMLStoreProvider.java
Removed:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/XMLInputFactory.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/XMLOutputFactory.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/XMLStoreProvider.java
Modified:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
    sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/UnsupportedStorageException.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXReader.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXStore.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXWriter100.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXWriter110.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxStream.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxStreamReader.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/xml/StaxStreamWriter.java
    sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/GPXReaderTest.java
    sis/branches/JDK8/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/gpx/GPXWriterTest.java

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -166,6 +166,11 @@ public final class Errors extends Indexe
         public static final short ClosedReader_1 = 19;
 
         /**
+         * This {0} writer is closed.
+         */
+        public static final short ClosedWriter_1 = 166;
+
+        /**
          * Database error while creating a ‘{0}’ object for the “{1}” identifier.
          */
         public static final short DatabaseError_2 = 20;
@@ -358,6 +363,11 @@ public final class Errors extends Indexe
         public static final short IllegalOrdinateRange_3 = 57;
 
         /**
+         * The {0} writer does not accept outputs of type ‘{1}’.
+         */
+        public static final short IllegalOutputTypeForWriter_2 = 165;
+
+        /**
          * Property “{0}” does not accept instances of ‘{1}’.
          */
         public static final short IllegalPropertyValueClass_2 = 58;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] Tue Dec 13 13:38:26 2016
@@ -44,6 +44,7 @@ CircularReference                 = Circ
 ClassNotFinal_1                   = Class \u2018{0}\u2019 is not final.
 CloneNotSupported_1               = Can not clone an object of type \u2018{0}\u2019.
 ClosedReader_1                    = This {0} reader is closed.
+ClosedWriter_1                    = This {0} writer is closed.
 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.
@@ -78,6 +79,7 @@ IllegalCRSType_1                  = Coor
 IllegalFormatPatternForClass_2    = The \u201c{1}\u201d pattern can not be applied to formating of objects of type \u2018{0}\u2019.
 IllegalIdentifierForCodespace_2   = \u201c{1}\u201d is not a valid identifier for the \u201c{0}\u201d code space.
 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.
 IllegalLanguageCode_1             = The \u201c{0}\u201d language is not recognized.
 IllegalMemberType_2               = Member \u201c{0}\u201d can not be associated to type \u201c{1}\u201d.
 IllegalOptionValue_2              = Option \u2018{0}\u2019 can not take the \u201c{1}\u201d value.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] Tue Dec 13 13:38:26 2016
@@ -41,6 +41,7 @@ CircularReference                 = R\u0
 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.
 ClosedReader_1                    = Ce lecteur {0} est ferm\u00e9.
+ClosedWriter_1                    = Cet encodeur {0} est ferm\u00e9.
 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.
@@ -75,6 +76,7 @@ IllegalCRSType_1                  = Le s
 IllegalFormatPatternForClass_2    = Le mod\u00e8le \u00ab\u202f{1}\u202f\u00bb ne peut pas \u00eatre appliqu\u00e9 au formatage d\u2019objets de type \u2018{0}\u2019.
 IllegalIdentifierForCodespace_2   = \u00ab\u202f{1}\u202f\u00bb n\u2019est pas un identifiant valide pour l\u2019espace de codes \u00ab\u202f{0}\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.
 IllegalLanguageCode_1             = Le code de langue \u00ab\u202f{0}\u202f\u00bb n\u2019est pas reconnu.
 IllegalMemberType_2               = Le membre \u00ab\u202f{0}\u202f\u00bb ne peut pas \u00eatre associ\u00e9 au type \u00ab\u202f{1}\u202f\u00bb.
 IllegalOptionValue_2              = L\u2019option \u2018{0}\u2019 n\u2019accepte pas la valeur \u00ab\u202f{1}\u202f\u00bb.

Copied: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/InputFactory.java (from r1774012, sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/XMLInputFactory.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/InputFactory.java?p2=sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/InputFactory.java&p1=sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/XMLInputFactory.java&r1=1774012&r2=1774013&rev=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/XMLInputFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/InputFactory.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -14,11 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.system;
+package org.apache.sis.xml;
 
 import java.io.Reader;
 import java.io.InputStream;
 import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.Source;
@@ -31,61 +32,36 @@ import org.apache.sis.util.Static;
 
 
 /**
- * Provides access to {@link javax.xml.stream.XMLInputFactory} methods as static methods working on
- * a SIS-wide instance. This convenience is provided in a separated class in order to allow the JVM
- * to instantiate the factory only when first needed, when initializing this class.
+ * Provides access to {@link XMLInputFactory} methods as static methods working on a SIS-wide instance.
+ * This convenience is provided in a separated class in order to allow the JVM to instantiate the factory
+ * only when first needed, when initializing this class.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
  * @version 0.8
  * @module
  */
-public final class XMLInputFactory extends Static {
+final class InputFactory extends Static {
     /**
      * The SIS-wide factory.
      */
-    private static final javax.xml.stream.XMLInputFactory FACTORY = javax.xml.stream.XMLInputFactory.newInstance();
+    private static final XMLInputFactory FACTORY = XMLInputFactory.newInstance();
 
     /**
      * Do not allow instantiation of this class.
      */
-    private XMLInputFactory() {
-    }
-
-    /**
-     * Creates a new reader for the given object. The given object should be one of the types
-     * expected by a {@code createXMLStreamReader(…)} method defined in this class.
-     *
-     * <p>Note that this method does <strong>not</strong> open streams from files, paths or URLs.
-     * Creating input streams and closing them after usage are caller's responsibility.</p>
-     *
-     * @param  in where to read from.
-     * @return the reader, or {@code null} if the given file where not recognized.
-     * @throws XMLStreamException if the type of the given input is one recognized types,
-     *         but despite that the reader can not be created.
-     *
-     * @since 0.8
-     */
-    public static XMLStreamReader createFromAny(final Object in) throws XMLStreamException {
-        if (in instanceof XMLStreamReader) return                      ((XMLStreamReader) in);
-        if (in instanceof XMLEventReader)  return createXMLStreamReader((XMLEventReader)  in);
-        if (in instanceof InputSource)     return createXMLStreamReader((InputSource)     in);
-        if (in instanceof InputStream)     return createXMLStreamReader((InputStream)     in);
-        if (in instanceof Reader)          return createXMLStreamReader((Reader)          in);
-        if (in instanceof Source)          return createXMLStreamReader((Source)          in);
-        if (in instanceof Node)            return createXMLStreamReader((Node)            in);
-        return null;
+    private InputFactory() {
     }
 
     /*
      * Do not provide convenience method for java.io.File, because the caller needs to close the created
-     * input stream himself (this is not done by XMLInputFactory.close(), despite its method name).
+     * input stream himself (this is not done by XMLStreamReader.close(), despite its method name).
      */
 
     /**
      * Creates a new reader for the given stream.
      *
-     * @param  in where to read from.
+     * @param  in  where to read from.
      * @return the reader.
      * @throws XMLStreamException if the reader can not be created.
      */
@@ -96,7 +72,7 @@ public final class XMLInputFactory exten
     /**
      * Creates a new reader for the given stream.
      *
-     * @param  in where to read from.
+     * @param  in  where to read from.
      * @return the reader.
      * @throws XMLStreamException if the reader can not be created.
      */
@@ -107,7 +83,7 @@ public final class XMLInputFactory exten
     /**
      * Creates a new reader for the given source.
      *
-     * @param  in where to read from.
+     * @param  in  where to read from.
      * @return the reader.
      * @throws XMLStreamException if the reader can not be created.
      */
@@ -118,7 +94,7 @@ public final class XMLInputFactory exten
     /**
      * Creates a new reader for the given source.
      *
-     * @param  in where to read from.
+     * @param  in  where to read from.
      * @return the reader.
      * @throws XMLStreamException if the reader can not be created.
      */
@@ -129,7 +105,7 @@ public final class XMLInputFactory exten
     /**
      * Creates a new reader for the given source.
      *
-     * @param  in where to read from.
+     * @param  in  where to read from.
      * @return the reader.
      * @throws XMLStreamException if the reader can not be created.
      */
@@ -140,7 +116,7 @@ public final class XMLInputFactory exten
     /**
      * Creates a new reader for the given source.
      *
-     * @param  in where to read from.
+     * @param  in  where to read from.
      * @return the reader.
      * @throws XMLStreamException if the reader can not be created.
      */

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -222,12 +222,11 @@ public final class Namespaces extends St
     /**
      * Returns the preferred prefix for the given namespace URI.
      *
-     * @param  namespace    The namespace URI for which the prefix needs to be found.
-     *                      Can not be {@code null}.
-     * @param  defaultValue The default prefix to returned if the given {@code namespace}
-     *                      is not recognized, or {@code null}.
-     * @return The prefix inferred from the namespace URI, or {@code null} if the given namespace
-     *         is unrecognized and the {@code defaultValue} is null.
+     * @param  namespace     the namespace URI for which the prefix needs to be found. Can not be {@code null}.
+     * @param  defaultValue  the default prefix to returned if the given {@code namespace} is not recognized,
+     *                       or {@code null}.
+     * @return the prefix inferred from the namespace URI, or {@code null} if the given namespace is unrecognized
+     *         and the {@code defaultValue} is null.
      */
     public static String getPreferredPrefix(String namespace, final String defaultValue) {
         ArgumentChecks.ensureNonNull("namespace", namespace);

Copied: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/OutputFactory.java (from r1774012, sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/XMLOutputFactory.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/OutputFactory.java?p2=sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/OutputFactory.java&p1=sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/XMLOutputFactory.java&r1=1774012&r2=1774013&rev=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/XMLOutputFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/OutputFactory.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -14,11 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.system;
+package org.apache.sis.xml;
 
 import java.io.OutputStream;
 import java.io.Writer;
 import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.Result;
@@ -31,25 +32,25 @@ import org.apache.sis.util.Static;
 
 
 /**
- * Provides access to {@link javax.xml.stream.XMLOutputFactory} methods as static methods working on
- * a SIS-wide instance. This convenience is provided in a separated class in order to allow the JVM
- * to instantiate the factory only when first needed, when initializing this class.
+ * Provides access to {@link XMLOutputFactory} methods as static methods working on a SIS-wide instance.
+ * This convenience is provided in a separated class in order to allow the JVM to instantiate the factory
+ * only when first needed, when initializing this class.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.8
  * @module
  */
-public final class XMLOutputFactory extends Static {
+final class OutputFactory extends Static {
     /**
      * The SIS-wide factory.
      */
-    private static final javax.xml.stream.XMLOutputFactory FACTORY = javax.xml.stream.XMLOutputFactory.newInstance();
+    private static final XMLOutputFactory FACTORY = XMLOutputFactory.newInstance();
 
     /**
      * Do not allow instantiation of this class.
      */
-    private XMLOutputFactory() {
+    private OutputFactory() {
     }
 
     /*
@@ -60,10 +61,10 @@ public final class XMLOutputFactory exte
     /**
      * Creates a new writer for the given stream.
      *
-     * @param  out Where to write to.
-     * @param  encoding The document encoding (usually {@code "UTF-8"}).
-     * @return The writer.
-     * @throws XMLStreamException If the writer can not be created.
+     * @param  out       where to write to.
+     * @param  encoding  the document encoding (usually {@code "UTF-8"}).
+     * @return the writer.
+     * @throws XMLStreamException if the writer can not be created.
      */
     public static XMLStreamWriter createXMLStreamWriter(OutputStream out, String encoding) throws XMLStreamException {
         return FACTORY.createXMLStreamWriter(out, encoding);
@@ -72,9 +73,9 @@ public final class XMLOutputFactory exte
     /**
      * Creates a new writer for the given stream.
      *
-     * @param  out Where to write to.
-     * @return The writer.
-     * @throws XMLStreamException If the writer can not be created.
+     * @param  out  where to write to.
+     * @return the writer.
+     * @throws XMLStreamException if the writer can not be created.
      */
     public static XMLStreamWriter createXMLStreamWriter(final Writer out) throws XMLStreamException {
         return FACTORY.createXMLStreamWriter(out);
@@ -84,9 +85,9 @@ public final class XMLOutputFactory exte
      * Creates a new writer for the JAXP result.
      * Note that this method is identified as <em>optional</em> in JSE javadoc.
      *
-     * @param  out Where to write to.
-     * @return The writer.
-     * @throws XMLStreamException If the writer can not be created.
+     * @param  out  where to write to.
+     * @return the writer.
+     * @throws XMLStreamException if the writer can not be created.
      */
     public static XMLStreamWriter createXMLStreamWriter(final ContentHandler out) throws XMLStreamException {
         return FACTORY.createXMLStreamWriter(new SAXResult(out));
@@ -96,9 +97,9 @@ public final class XMLOutputFactory exte
      * Creates a new writer for the JAXP result.
      * Note that this method is identified as <em>optional</em> in JSE javadoc.
      *
-     * @param  out Where to write to.
-     * @return The writer.
-     * @throws XMLStreamException If the writer can not be created.
+     * @param  out  where to write to.
+     * @return the writer.
+     * @throws XMLStreamException if the writer can not be created.
      */
     public static XMLStreamWriter createXMLStreamWriter(final Node out) throws XMLStreamException {
         return FACTORY.createXMLStreamWriter(new DOMResult(out));
@@ -108,9 +109,9 @@ public final class XMLOutputFactory exte
      * Creates a new writer for the JAXP result.
      * Note that this method is identified as <em>optional</em> in JSE javadoc.
      *
-     * @param  out Where to write to.
-     * @return The writer.
-     * @throws XMLStreamException If the writer can not be created.
+     * @param  out  where to write to.
+     * @return the writer.
+     * @throws XMLStreamException if the writer can not be created.
      */
     public static XMLStreamWriter createXMLStreamWriter(final XMLEventWriter out) throws XMLStreamException {
         return FACTORY.createXMLStreamWriter(new StAXResult(out));
@@ -120,9 +121,9 @@ public final class XMLOutputFactory exte
      * Creates a new writer for the JAXP result.
      * Note that this method is identified as <em>optional</em> in JSE javadoc.
      *
-     * @param  out Where to write to.
-     * @return The writer.
-     * @throws XMLStreamException If the writer can not be created.
+     * @param  out  where to write to.
+     * @return the writer.
+     * @throws XMLStreamException if the writer can not be created.
      */
     public static XMLStreamWriter createXMLStreamWriter(final Result out) throws XMLStreamException {
         return FACTORY.createXMLStreamWriter(out);

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -36,7 +36,6 @@ import javax.xml.validation.Schema;
 import org.xml.sax.ContentHandler;
 import org.w3c.dom.Node;
 import org.apache.sis.internal.jaxb.Context;
-import org.apache.sis.internal.system.XMLOutputFactory;
 
 
 /**
@@ -144,7 +143,7 @@ final class PooledMarshaller extends Poo
     public void marshal(final Object object, final Result output) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            marshal(object, XMLOutputFactory.createXMLStreamWriter(output), version);
+            marshal(object, OutputFactory.createXMLStreamWriter(output), version);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {
@@ -165,7 +164,7 @@ final class PooledMarshaller extends Poo
     public void marshal(final Object object, final OutputStream output) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            marshal(object, XMLOutputFactory.createXMLStreamWriter(output, getEncoding()), version);
+            marshal(object, OutputFactory.createXMLStreamWriter(output, getEncoding()), version);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {
@@ -187,7 +186,7 @@ final class PooledMarshaller extends Poo
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
             try (OutputStream s = new BufferedOutputStream(new FileOutputStream(output))) {
-                marshal(object, XMLOutputFactory.createXMLStreamWriter(s, getEncoding()), version);
+                marshal(object, OutputFactory.createXMLStreamWriter(s, getEncoding()), version);
             }
         } catch (IOException | XMLStreamException e) {
             throw new JAXBException(e);
@@ -209,7 +208,7 @@ final class PooledMarshaller extends Poo
     public void marshal(final Object object, final Writer output) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            marshal(object, XMLOutputFactory.createXMLStreamWriter(output), version);
+            marshal(object, OutputFactory.createXMLStreamWriter(output), version);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {
@@ -230,7 +229,7 @@ final class PooledMarshaller extends Poo
     public void marshal(final Object object, final ContentHandler output) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            marshal(object, XMLOutputFactory.createXMLStreamWriter(output), version);
+            marshal(object, OutputFactory.createXMLStreamWriter(output), version);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {
@@ -251,7 +250,7 @@ final class PooledMarshaller extends Poo
     public void marshal(final Object object, final Node output) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            marshal(object, XMLOutputFactory.createXMLStreamWriter(output), version);
+            marshal(object, OutputFactory.createXMLStreamWriter(output), version);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {
@@ -289,7 +288,7 @@ final class PooledMarshaller extends Poo
     public void marshal(final Object object, final XMLEventWriter output) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            marshal(object, XMLOutputFactory.createXMLStreamWriter(output), version);
+            marshal(object, OutputFactory.createXMLStreamWriter(output), version);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -39,7 +39,6 @@ import javax.xml.validation.Schema;
 import org.w3c.dom.Node;
 import org.xml.sax.InputSource;
 import org.apache.sis.internal.jaxb.Context;
-import org.apache.sis.internal.system.XMLInputFactory;
 
 
 /**
@@ -62,7 +61,7 @@ import org.apache.sis.internal.system.XM
  */
 final class PooledUnmarshaller extends Pooled implements Unmarshaller {
     /**
-     * The wrapper marshaller which does the real work.
+     * The wrapped marshaller which does the real work.
      */
     private final Unmarshaller unmarshaller;
 
@@ -70,9 +69,9 @@ final class PooledUnmarshaller extends P
      * Creates a pooled unmarshaller wrapping the given one.
      * Callers shall invoke {@link #reset(Pooled)} after construction for completing the initialization.
      *
-     * @param  unmarshaller The unmarshaller to use for the actual work.
-     * @param  template The {@link PooledTemplate} from which to get the initial values.
-     * @throws JAXBException If an error occurred while setting a property.
+     * @param  unmarshaller  the unmarshaller to use for the actual work.
+     * @param  template      the {@link PooledTemplate} from which to get the initial values.
+     * @throws JAXBException if an error occurred while setting a property.
      */
     PooledUnmarshaller(final Unmarshaller unmarshaller, final Pooled template) throws JAXBException {
         super(template);
@@ -84,9 +83,9 @@ final class PooledUnmarshaller extends P
      * Resets the given unmarshaller property to its initial state.
      * This method is invoked automatically by {@link #reset(Pooled)}.
      *
-     * @param  key   The property to reset.
-     * @param  value The saved initial value to give to the property.
-     * @throws JAXBException If an error occurred while restoring a property.
+     * @param  key    the property to reset.
+     * @param  value  the saved initial value to give to the property.
+     * @throws JAXBException if an error occurred while restoring a property.
      */
     @Override
     @SuppressWarnings({"unchecked","rawtypes","deprecation"})
@@ -114,8 +113,8 @@ final class PooledUnmarshaller extends P
      * than the one supported natively by SIS, i.e. when {@link #getFilterVersion()} returns a
      * non-null value.
      *
-     * @param  input   The reader created by SIS (<b>not</b> the reader given by the user).
-     * @param  version Identify the namespace substitutions to perform.
+     * @param  input    the reader created by SIS (<b>not</b> the reader given by the user).
+     * @param  version  identify the namespace substitutions to perform.
      * @return The unmarshalled object.
      */
     private Object unmarshal(XMLStreamReader input, final FilterVersion version)
@@ -129,7 +128,7 @@ final class PooledUnmarshaller extends P
         } finally {
             context.finish();
         }
-        input.close(); // Despite its name, this method does not close the underlying input stream.
+        input.close();              // Despite its name, this method does not close the underlying input stream.
         return object;
     }
 
@@ -148,7 +147,7 @@ final class PooledUnmarshaller extends P
         } finally {
             context.finish();
         }
-        input.close(); // Despite its name, this method does not close the underlying input stream.
+        input.close();              // Despite its name, this method does not close the underlying input stream.
         return object;
     }
 
@@ -159,7 +158,7 @@ final class PooledUnmarshaller extends P
     public Object unmarshal(final InputStream input) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            return unmarshal(XMLInputFactory.createXMLStreamReader(input), version);
+            return unmarshal(InputFactory.createXMLStreamReader(input), version);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {
@@ -180,7 +179,7 @@ final class PooledUnmarshaller extends P
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
             try (final InputStream s = input.openStream()) {
-                return unmarshal(XMLInputFactory.createXMLStreamReader(s), version);
+                return unmarshal(InputFactory.createXMLStreamReader(s), version);
             }
         } catch (IOException | XMLStreamException e) {
             throw new JAXBException(e);
@@ -202,7 +201,7 @@ final class PooledUnmarshaller extends P
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
             try (final InputStream s = new BufferedInputStream(new FileInputStream(input))) {
-                return unmarshal(XMLInputFactory.createXMLStreamReader(s), version);
+                return unmarshal(InputFactory.createXMLStreamReader(s), version);
             }
         } catch (IOException | XMLStreamException e) {
             throw new JAXBException(e);
@@ -223,7 +222,7 @@ final class PooledUnmarshaller extends P
     public Object unmarshal(final Reader input) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            return unmarshal(XMLInputFactory.createXMLStreamReader(input), version);
+            return unmarshal(InputFactory.createXMLStreamReader(input), version);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {
@@ -243,7 +242,7 @@ final class PooledUnmarshaller extends P
     public Object unmarshal(final InputSource input) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            return unmarshal(XMLInputFactory.createXMLStreamReader(input), version);
+            return unmarshal(InputFactory.createXMLStreamReader(input), version);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {
@@ -263,7 +262,7 @@ final class PooledUnmarshaller extends P
     public Object unmarshal(final Node input) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            return unmarshal(XMLInputFactory.createXMLStreamReader(input), version);
+            return unmarshal(InputFactory.createXMLStreamReader(input), version);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {
@@ -283,7 +282,7 @@ final class PooledUnmarshaller extends P
     public <T> JAXBElement<T> unmarshal(final Node input, final Class<T> declaredType) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            return unmarshal(XMLInputFactory.createXMLStreamReader(input), version, declaredType);
+            return unmarshal(InputFactory.createXMLStreamReader(input), version, declaredType);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {
@@ -303,7 +302,7 @@ final class PooledUnmarshaller extends P
     public Object unmarshal(final Source input) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            return unmarshal(XMLInputFactory.createXMLStreamReader(input), version);
+            return unmarshal(InputFactory.createXMLStreamReader(input), version);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {
@@ -323,7 +322,7 @@ final class PooledUnmarshaller extends P
     public <T> JAXBElement<T> unmarshal(final Source input, final Class<T> declaredType) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            return unmarshal(XMLInputFactory.createXMLStreamReader(input), version, declaredType);
+            return unmarshal(InputFactory.createXMLStreamReader(input), version, declaredType);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {
@@ -377,7 +376,7 @@ final class PooledUnmarshaller extends P
     public Object unmarshal(final XMLEventReader input) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            return unmarshal(XMLInputFactory.createXMLStreamReader(input), version);
+            return unmarshal(InputFactory.createXMLStreamReader(input), version);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {
@@ -397,7 +396,7 @@ final class PooledUnmarshaller extends P
     public <T> JAXBElement<T> unmarshal(final XMLEventReader input, final Class<T> declaredType) throws JAXBException {
         final FilterVersion version = getFilterVersion();
         if (version != null) try {
-            return unmarshal(XMLInputFactory.createXMLStreamReader(input), version, declaredType);
+            return unmarshal(InputFactory.createXMLStreamReader(input), version, declaredType);
         } catch (XMLStreamException e) {
             throw new JAXBException(e);
         } else {

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -140,6 +140,7 @@ import org.junit.BeforeClass;
     org.apache.sis.internal.converter.NumberConverterTest.class,        // Shall be after SystemRegistryTest.
 
     // XML most basic types.
+    org.apache.sis.xml.NamespacesTest.class,
     org.apache.sis.xml.XLinkTest.class,
     org.apache.sis.xml.NilReasonTest.class,
     org.apache.sis.xml.LegacyCodesTest.class,

Added: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/xml/NamespacesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/xml/NamespacesTest.java?rev=1774013&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/xml/NamespacesTest.java (added)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/xml/NamespacesTest.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -0,0 +1,41 @@
+/*
+ * 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.xml;
+
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests the {@link Namespaces} class.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.8
+ * @version 0.8
+ * @module
+ */
+public final strictfp class NamespacesTest extends TestCase {
+    /**
+     * Tests {@link Namespaces#getPreferredPrefix(String, String)}.
+     */
+    @Test
+    public void testGetPreferredPrefix() {
+        assertEquals("gml", Namespaces.getPreferredPrefix("http://www.opengis.net/gml/3.2", null));
+    }
+}

Propchange: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/xml/NamespacesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/xml/NamespacesTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-earth-observation/src/main/java/org/apache/sis/storage/earthobservation/LandsatStore.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -25,9 +25,11 @@ import org.opengis.util.FactoryException
 import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreReferencingException;
+import org.apache.sis.storage.UnsupportedStorageException;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.Classes;
 import org.apache.sis.util.Debug;
 
 
@@ -94,7 +96,8 @@ public class LandsatStore extends DataSt
         source = connector.getStorageAs(Reader.class);
         connector.closeAllExcept(source);
         if (source == null) {
-            throw new DataStoreException(Errors.format(Errors.Keys.CanNotOpen_1, name));
+            throw new UnsupportedStorageException(errors().getString(Errors.Keys.IllegalInputTypeForReader_2,
+                    "Landsat", Classes.getClass(connector.getStorage())));
         }
     }
 
@@ -134,6 +137,14 @@ public class LandsatStore extends DataSt
     }
 
     /**
+     * Returns the error resources in the current locale.
+     */
+    private Errors errors() {
+        // Must use "super" because LandsatStore construction may not be finished.
+        return Errors.getResources(super.getLocale());
+    }
+
+    /**
      * Returns a string representation of this Landsat store for debugging purpose.
      * The content of the string returned by this method may change in any future SIS version.
      *

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoTiffStore.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -29,6 +29,7 @@ import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.DataStoreContentException;
+import org.apache.sis.storage.UnsupportedStorageException;
 import org.apache.sis.internal.storage.ChannelDataInput;
 import org.apache.sis.internal.storage.MetadataBuilder;
 import org.apache.sis.metadata.sql.MetadataStoreException;
@@ -70,19 +71,19 @@ public class GeoTiffStore extends DataSt
      * This constructor invokes {@link StorageConnector#closeAllExcept(Object)},
      * keeping open only the needed resource.
      *
-     * @param  storage  information about the storage (URL, stream, <i>etc</i>).
+     * @param  connector  information about the storage (URL, stream, <i>etc</i>).
      * @throws DataStoreException if an error occurred while opening the GeoTIFF file.
      */
-    public GeoTiffStore(final StorageConnector storage) throws DataStoreException {
-        ArgumentChecks.ensureNonNull("storage", storage);
-        final Charset encoding = storage.getOption(OptionKey.ENCODING);
+    public GeoTiffStore(final StorageConnector connector) throws DataStoreException {
+        ArgumentChecks.ensureNonNull("connector", connector);
+        final Charset encoding = connector.getOption(OptionKey.ENCODING);
         this.encoding = (encoding != null) ? encoding : StandardCharsets.US_ASCII;
-        final ChannelDataInput input = storage.getStorageAs(ChannelDataInput.class);
+        final ChannelDataInput input = connector.getStorageAs(ChannelDataInput.class);
         if (input == null) {
-            throw new DataStoreException(Errors.format(Errors.Keys.IllegalInputTypeForReader_2,
-                    "TIFF", Classes.getClass(storage.getStorage())));
+            throw new UnsupportedStorageException(errors().getString(Errors.Keys.IllegalInputTypeForReader_2,
+                    "TIFF", Classes.getClass(connector.getStorage())));
         }
-        storage.closeAllExcept(input);
+        connector.closeAllExcept(input);
         try {
             reader = new Reader(this, input);
         } catch (IOException e) {
@@ -118,7 +119,7 @@ public class GeoTiffStore extends DataSt
                 }
                 metadata = builder.build(true);
             } catch (IOException e) {
-                throw new DataStoreException(reader.errors().getString(Errors.Keys.CanNotRead_1, reader.input.filename), e);
+                throw new DataStoreException(errors().getString(Errors.Keys.CanNotRead_1, reader.input.filename), e);
             } catch (FactoryException | ArithmeticException e) {
                 throw new DataStoreContentException(reader.canNotDecode(), e);
             }
@@ -143,6 +144,14 @@ public class GeoTiffStore extends DataSt
     }
 
     /**
+     * Returns the error resources in the current locale.
+     */
+    final Errors errors() {
+        // Must use "super" because GeoTiffStore construction may not be finished.
+        return Errors.getResources(super.getLocale());
+    }
+
+    /**
      * Reports a warning represented by the given message and exception.
      * At least one of {@code message} and {@code exception} shall be non-null.
      *

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Reader.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -177,8 +177,8 @@ final class Reader extends GeoTIFF {
                 }
             }
         }
-        // Do not invoke errors() yet because GeoTiffStore construction may not be finished.
-        throw new DataStoreContentException(Errors.format(Errors.Keys.UnexpectedFileFormat_2, "TIFF", input.filename));
+        // Do not invoke this.errors() yet because GeoTiffStore construction may not be finished. Owner.error() is okay.
+        throw new DataStoreContentException(owner.errors().getString(Errors.Keys.UnexpectedFileFormat_2, "TIFF", input.filename));
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Decoder.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -17,6 +17,7 @@
 package org.apache.sis.internal.netcdf;
 
 import java.util.Date;
+import java.util.Objects;
 import java.io.Closeable;
 import java.io.IOException;
 import javax.measure.Unit;
@@ -25,9 +26,6 @@ import org.apache.sis.measure.Units;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.util.logging.WarningListeners;
 
-// Branch-dependent imports
-import java.util.Objects;
-
 
 /**
  * The API used internally by Apache SIS for fetching variables and attribute values from a NetCDF file.

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -24,7 +24,7 @@ import org.apache.sis.util.ArgumentCheck
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.DataStoreContentException;
+import org.apache.sis.storage.UnsupportedStorageException;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.internal.netcdf.Decoder;
 import org.apache.sis.metadata.ModifiableMetadata;
@@ -72,7 +72,7 @@ public class NetcdfStore extends DataSto
             throw new DataStoreException(e);
         }
         if (decoder == null) {
-            throw new DataStoreContentException(Errors.format(Errors.Keys.IllegalInputTypeForReader_2,
+            throw new UnsupportedStorageException(errors().getString(Errors.Keys.IllegalInputTypeForReader_2,
                     "NetCDF", Classes.getClass(connector.getStorage())));
         }
     }
@@ -134,6 +134,14 @@ public class NetcdfStore extends DataSto
     }
 
     /**
+     * Returns the error resources in the current locale.
+     */
+    private Errors errors() {
+        // Must use "super" because NetcdfStore construction may not be finished.
+        return Errors.getResources(super.getLocale());
+    }
+
+    /**
      * Returns a string representation of this NetCDF store for debugging purpose.
      * The content of the string returned by this method may change in any future SIS version.
      *

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -31,16 +31,6 @@ import java.net.URL;
 import java.net.URLDecoder;
 import java.net.URISyntaxException;
 import java.net.MalformedURLException;
-import java.nio.channels.Channels;
-import java.nio.channels.ReadableByteChannel;
-import org.apache.sis.util.logging.Logging;
-import org.apache.sis.util.CharSequences;
-import org.apache.sis.util.Exceptions;
-import org.apache.sis.util.Static;
-import org.apache.sis.util.resources.Errors;
-import org.apache.sis.internal.system.Modules;
-
-// Branch-dependent imports
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.Files;
@@ -48,7 +38,15 @@ import java.nio.file.InvalidPathExceptio
 import java.nio.file.FileSystemNotFoundException;
 import java.nio.file.OpenOption;
 import java.nio.file.StandardOpenOption;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
 import java.nio.charset.StandardCharsets;
+import org.apache.sis.util.logging.Logging;
+import org.apache.sis.util.CharSequences;
+import org.apache.sis.util.Exceptions;
+import org.apache.sis.util.Static;
+import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.system.Modules;
 
 
 /**
@@ -85,8 +83,8 @@ public final class IOUtilities extends S
      * dedicated API like {@link Path#getFileName()}. Otherwise this method gets a string representation of the path
      * and returns the part after the last {@code '/'} or platform-dependent name separator character, if any.
      *
-     * @param  path The path as an instance of one of the above-cited types, or {@code null}.
-     * @return The filename in the given path, or {@code null} if the given object is null or of unknown type.
+     * @param  path  the path as an instance of one of the above-cited types, or {@code null}.
+     * @return the filename in the given path, or {@code null} if the given object is null or of unknown type.
      */
     public static String filename(final Object path) {
         return part(path, false);
@@ -97,8 +95,8 @@ public final class IOUtilities extends S
      * {@link CharSequence} instance. If no extension is found, returns an empty string. If the given
      * object is of unknown type, return {@code null}.
      *
-     * @param  path The path as an instance of one of the above-cited types, or {@code null}.
-     * @return The extension in the given path, or an empty string if none, or {@code null}
+     * @param  path  the path as an instance of one of the above-cited types, or {@code null}.
+     * @return the extension in the given path, or an empty string if none, or {@code null}
      *         if the given object is null or of unknown type.
      */
     public static String extension(final Object path) {
@@ -147,8 +145,8 @@ public final class IOUtilities extends S
      * Returns a string representation of the given path, or {@code null} if none. The current implementation
      * recognizes only the {@link Path}, {@link File}, {@link URL}, {@link URI} or {@link CharSequence} types.
      *
-     * @param  path The path for which to return a string representation.
-     * @return The string representation, or {@code null} if none.
+     * @param  path  the path for which to return a string representation.
+     * @return the string representation, or {@code null} if none.
      */
     public static String toString(final Object path) {
         // For the following types, the string that we want can be obtained only by toString(),
@@ -175,8 +173,8 @@ public final class IOUtilities extends S
      * and the {@code %} character. Future versions may replace more characters as we learn
      * from experience.</p>
      *
-     * @param  path The path to encode, or {@code null}.
-     * @return The encoded path, or {@code null} if and only if the given path was null.
+     * @param  path  the path to encode, or {@code null}.
+     * @return the encoded path, or {@code null} if and only if the given path was null.
      */
     public static String encodeURI(final String path) {
         if (path == null) {
@@ -227,11 +225,11 @@ public final class IOUtilities extends S
      *   <li>Converts various exceptions into subclasses of {@link IOException}.</li>
      * </ul>
      *
-     * @param  url The URL to convert, or {@code null}.
-     * @param  encoding If the URL is encoded in a {@code application/x-www-form-urlencoded}
-     *         MIME format, the character encoding (normally {@code "UTF-8"}). If the URL is
-     *         not encoded, then {@code null}.
-     * @return The URI for the given URL, or {@code null} if the given URL was null.
+     * @param  url       the URL to convert, or {@code null}.
+     * @param  encoding  if the URL is encoded in a {@code application/x-www-form-urlencoded} MIME format,
+     *                   the character encoding (normally {@code "UTF-8"}). If the URL is not encoded,
+     *                   then {@code null}.
+     * @return the URI for the given URL, or {@code null} if the given URL was null.
      * @throws IOException if the URL can not be converted to a URI.
      *
      * @see URI#URI(String)
@@ -276,11 +274,11 @@ public final class IOUtilities extends S
      *   <li>Converts various exceptions into subclasses of {@link IOException}.</li>
      * </ul>
      *
-     * @param  url The URL to convert, or {@code null}.
-     * @param  encoding If the URL is encoded in a {@code application/x-www-form-urlencoded}
-     *         MIME format, the character encoding (normally {@code "UTF-8"}). If the URL is
-     *         not encoded, then {@code null}.
-     * @return The file for the given URL, or {@code null} if the given URL was null.
+     * @param  url       the URL to convert, or {@code null}.
+     * @param  encoding  if the URL is encoded in a {@code application/x-www-form-urlencoded} MIME format,
+     *                   the character encoding (normally {@code "UTF-8"}). If the URL is not encoded,
+     *                   then {@code null}.
+     * @return the file for the given URL, or {@code null} if the given URL was null.
      * @throws IOException if the URL can not be converted to a file.
      *
      * @see File#File(URI)
@@ -318,11 +316,11 @@ public final class IOUtilities extends S
      *   <li>Converts various exceptions into subclasses of {@link IOException}.</li>
      * </ul>
      *
-     * @param  url The URL to convert, or {@code null}.
-     * @param  encoding If the URL is encoded in a {@code application/x-www-form-urlencoded}
-     *         MIME format, the character encoding (normally {@code "UTF-8"}). If the URL is
-     *         not encoded, then {@code null}.
-     * @return The path for the given URL, or {@code null} if the given URL was null.
+     * @param  url       the URL to convert, or {@code null}.
+     * @param  encoding  if the URL is encoded in a {@code application/x-www-form-urlencoded} MIME format,
+     *                   the character encoding (normally {@code "UTF-8"}). If the URL is not encoded,
+     *                   then {@code null}.
+     * @return the path for the given URL, or {@code null} if the given URL was null.
      * @throws IOException if the URL can not be converted to a path.
      *
      * @see Paths#get(URI)
@@ -363,13 +361,13 @@ public final class IOUtilities extends S
      * A URL can represent a file, but {@link URL#openStream()} appears to return a {@code BufferedInputStream}
      * wrapping the {@link FileInputStream}, which is not a desirable feature when we want to obtain a channel.
      *
-     * @param  path The path to convert, or {@code null}.
-     * @param  encoding If the URL is encoded in a {@code application/x-www-form-urlencoded}
-     *         MIME format, the character encoding (normally {@code "UTF-8"}). If the URL is
-     *         not encoded, then {@code null}. This argument is ignored if the given path does
-     *         not need to be converted from URL to {@code File}.
-     * @return The path as a {@link File} if possible, or a {@link URL} otherwise.
-     * @throws IOException If the given path is not a file and can't be parsed as a URL.
+     * @param  path      the path to convert, or {@code null}.
+     * @param  encoding  if the URL is encoded in a {@code application/x-www-form-urlencoded} MIME format,
+     *                   the character encoding (normally {@code "UTF-8"}). If the URL is not encoded,
+     *                   then {@code null}. This argument is ignored if the given path does not need
+     *                   to be converted from URL to {@code File}.
+     * @return the path as a {@link File} if possible, or a {@link URL} otherwise.
+     * @throws IOException if the given path is not a file and can't be parsed as a URL.
      */
     public static Object toFileOrURL(final String path, final String encoding) throws IOException {
         if (path == null) {
@@ -428,13 +426,13 @@ public final class IOUtilities extends S
      * would alter significatively the channel behavior depending on whether we have been able to
      * honor the options or not.</p>
      *
-     * @param  input The file to open, or {@code null}.
-     * @param  encoding If the input is an encoded URL, the character encoding (normally {@code "UTF-8"}).
-     *         If the URL is not encoded, then {@code null}. This argument is ignored if the given input
-     *         does not need to be converted from URL to {@code File}.
-     * @param  options The options to use for creating a new byte channel. Can be null or empty for read-only.
-     * @return The channel for the given input, or {@code null} if the given input is of unknown type.
-     * @throws IOException If an error occurred while opening the given file.
+     * @param  input     the file to open, or {@code null}.
+     * @param  encoding  if the input is an encoded URL, the character encoding (normally {@code "UTF-8"}).
+     *                   If the URL is not encoded, then {@code null}. This argument is ignored if the given
+     *                   input does not need to be converted from URL to {@code File}.
+     * @param  options   the options to use for creating a new byte channel. Can be null or empty for read-only.
+     * @return the channel for the given input, or {@code null} if the given input is of unknown type.
+     * @throws IOException if an error occurred while opening the given file.
      */
     public static ReadableByteChannel open(Object input, final String encoding, OpenOption... options) throws IOException {
         /*

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -170,7 +170,7 @@ public class StorageConnector implements
      * Creates a new data store connection wrapping the given input/output object.
      * The object can be of any type, but the class javadoc lists the most typical ones.
      *
-     * @param storage The input/output object as a URL, file, image input stream, <i>etc.</i>.
+     * @param storage  the input/output object as a URL, file, image input stream, <i>etc.</i>.
      */
     public StorageConnector(final Object storage) {
         ArgumentChecks.ensureNonNull("storage", storage);
@@ -180,9 +180,9 @@ public class StorageConnector implements
     /**
      * Returns the option value for the given key, or {@code null} if none.
      *
-     * @param  <T> The type of option value.
-     * @param  key The option for which to get the value.
-     * @return The current value for the given option, or {@code null} if none.
+     * @param  <T>  the type of option value.
+     * @param  key  the option for which to get the value.
+     * @return the current value for the given option, or {@code null} if none.
      */
     public <T> T getOption(final OptionKey<T> key) {
         ArgumentChecks.ensureNonNull("key", key);
@@ -199,9 +199,9 @@ public class StorageConnector implements
      *   <li>{@link OptionKey#BYTE_BUFFER}  for allowing users to control the byte buffer to be created.</li>
      * </ul>
      *
-     * @param <T>   The type of option value.
-     * @param key   The option for which to set the value.
-     * @param value The new value for the given option, or {@code null} for removing the value.
+     * @param <T>    the type of option value.
+     * @param key    the option for which to set the value.
+     * @param value  the new value for the given option, or {@code null} for removing the value.
      */
     public <T> void setOption(final OptionKey<T> key, final T value) {
         ArgumentChecks.ensureNonNull("key", key);
@@ -212,7 +212,7 @@ public class StorageConnector implements
      * Returns the input/output object given at construction time.
      * The object can be of any type, but the class javadoc lists the most typical ones.
      *
-     * @return The input/output object as a URL, file, image input stream, <i>etc.</i>.
+     * @return the input/output object as a URL, file, image input stream, <i>etc.</i>.
      *
      * @see #getStorageAs(Class)
      */
@@ -233,7 +233,7 @@ public class StorageConnector implements
      *       Note that the string representation of unknown types may change in any future SIS version.</li>
      * </ul>
      *
-     * @return A short name of the storage object.
+     * @return a short name of the storage object.
      */
     public String getStorageName() {
         if (name == null) {
@@ -257,8 +257,8 @@ public class StorageConnector implements
      *   <li>For instances of unknown type, this method returns {@code null}.</li>
      * </ul>
      *
-     * @return The filename extension, or an empty string if none, or {@code null} if the storage
-     *         is an object of unknown type.
+     * @return the filename extension, or an empty string if none,
+     *         or {@code null} if the storage is an object of unknown type.
      */
     public String getFileExtension() {
         if (extension == null) {
@@ -355,10 +355,10 @@ public class StorageConnector implements
      * database connection returned by this method. In addition, those {@code probeContent(StorageConnector)}
      * methods are responsible for restoring the stream or byte buffer to its original position on return.
      *
-     * @param  <T>  The compile-time type of the {@code type} argument.
-     * @param  type The desired type as one of {@code ByteBuffer}, {@code DataInput}, {@code Connection}
-     *         class or other type supported by {@code StorageConnector} subclasses.
-     * @return The storage as a view of the given type, or {@code null} if no view can be created for the given type.
+     * @param  <T>   the compile-time type of the {@code type} argument.
+     * @param  type  the desired type as one of {@code ByteBuffer}, {@code DataInput}, {@code Connection}
+     *               class or other type supported by {@code StorageConnector} subclasses.
+     * @return the storage as a view of the given type, or {@code null} if no view can be created for the given type.
      * @throws IllegalArgumentException if the given {@code type} argument is not a supported type.
      * @throws DataStoreException if an error occurred while opening a stream or database connection.
      *
@@ -438,7 +438,7 @@ public class StorageConnector implements
      * Creates a view for the input as a {@link ChannelDataInput} if possible.
      * If the view can not be created, remember that fact in order to avoid new attempts.
      *
-     * @param  asImageInputStream If the {@code ChannelDataInput} needs to be {@link ChannelImageInputStream} subclass.
+     * @param  asImageInputStream  whether the {@code ChannelDataInput} needs to be {@link ChannelImageInputStream} subclass.
      * @throws IOException if an error occurred while opening a channel for the input.
      */
     private void createChannelDataInput(final boolean asImageInputStream) throws IOException {
@@ -553,7 +553,7 @@ public class StorageConnector implements
                 if (n >= 1) {
                     asByteBuffer = ByteBuffer.wrap(buffer).order(in.getByteOrder());
                     asByteBuffer.limit(n);
-                    // Can't invoke asReadOnly() because 'prefetch()' need to be able to write in it.
+                    // Can not invoke asReadOnly() because 'prefetch()' need to be able to write in it.
                 }
             }
         }
@@ -602,10 +602,11 @@ public class StorageConnector implements
 
     /**
      * Creates a storage view of the given type if possible, or returns {@code null} otherwise.
-     * This method is invoked by {@link #getStorageAs(Class)} when first needed, and the result is cached.
+     * This method is invoked by {@link #getStorageAs(Class)} when first needed, and the result
+     * is cached by the caller.
      *
-     * @param  type The type of the view to create.
-     * @return The storage as a view of the given type, or {@code null} if no view can be created for the given type.
+     * @param  type  the type of the view to create.
+     * @return the storage as a view of the given type, or {@code null} if no view can be created for the given type.
      * @throws IllegalArgumentException if the given {@code type} argument is not a supported type.
      * @throws Exception if an error occurred while opening a stream or database connection.
      */
@@ -680,9 +681,9 @@ public class StorageConnector implements
     /**
      * Adds the given view in the cache.
      *
-     * @param <T>   The compile-time type of the {@code type} argument.
-     * @param type  The view type.
-     * @param view  The view, or {@code null} if none.
+     * @param  <T>   the compile-time type of the {@code type} argument.
+     * @param  type  the view type.
+     * @param  view  the view, or {@code null} if none.
      */
     private <T> void addView(final Class<T> type, final T view) {
         if (views.put(type, (view != null) ? view : Void.TYPE) != null) {
@@ -693,9 +694,9 @@ public class StorageConnector implements
     /**
      * Returns the view for the given type from the cache.
      *
-     * @param <T>   The compile-time type of the {@code type} argument.
-     * @param type  The view type.
-     * @return      The view, or {@code null} if none.
+     * @param  <T>   the compile-time type of the {@code type} argument.
+     * @param  type  the view type.
+     * @return the view, or {@code null} if none.
      */
     private <T> T getView(final Class<T> type) {
         final Object view = views.get(type);
@@ -707,8 +708,8 @@ public class StorageConnector implements
      * The {@code input} argument is always a new instance wrapping, directly or indirectly, the {@link #storage}.
      * Callers must specify the wrapped object in the {@code delegate} argument.
      *
-     * @param input    The newly created object which will need to be closed.
-     * @param delegate The object wrapped by the given {@code input}.
+     * @param  input     the newly created object which will need to be closed.
+     * @param  delegate  the object wrapped by the given {@code input}.
      */
     private void addViewToClose(final Object input, final Object delegate) {
         if (viewsToClose == null) {
@@ -731,7 +732,7 @@ public class StorageConnector implements
      *
      * <p>This {@code StorageConnector} instance shall not be used anymore after invocation of this method.</p>
      *
-     * @param  view The view to leave open, or {@code null} if none.
+     * @param  view  the view to leave open, or {@code null} if none.
      * @throws DataStoreException if an error occurred while closing the stream or database connection.
      *
      * @see #getStorageAs(Class)

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/UnsupportedStorageException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/UnsupportedStorageException.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/UnsupportedStorageException.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/UnsupportedStorageException.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -19,6 +19,8 @@ package org.apache.sis.storage;
 
 /**
  * Thrown when no {@link DataStoreProvider} is found for a given storage object.
+ * May also be thrown if a {@code DataStore} is instantiated directly (without {@code DataStoreProvider}
+ * for verifying the input) but the data store can not handle the given input or output object.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXReader.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXReader.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXReader.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -16,7 +16,10 @@
  */
 package org.apache.sis.internal.gpx;
 
+import java.util.List;
+import java.util.ArrayList;
 import java.io.IOException;
+import java.io.EOFException;
 import java.net.URISyntaxException;
 import java.time.Instant;
 import java.time.LocalDate;
@@ -26,8 +29,6 @@ import java.time.format.DateTimeParseExc
 import java.time.temporal.Temporal;
 import java.time.temporal.TemporalAccessor;
 import java.time.temporal.UnsupportedTemporalTypeException;
-import java.util.ArrayList;
-import java.util.List;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import com.esri.core.geometry.Point;
@@ -38,41 +39,45 @@ import org.apache.sis.storage.StorageCon
 import org.apache.sis.internal.xml.StaxStreamReader;
 import org.apache.sis.util.Version;
 
-import static javax.xml.stream.XMLStreamReader.*;
-
 // Branch-dependent imports
 import org.opengis.feature.Feature;
 
 
 /**
- * Stax reader class for GPX 1.0 and 1.1 files.
- *
- * Usage :<br>
- * <pre>
- * {@code
- * final GPXReader reader = new GPXReader();
- * reader.setInput(gpxInput);
- *
- * final GPXVersion version = reader.getVersion();
- * final Metadata metadata = reader.getMetadata();
- *
- * while(reader.hasNext()) {
- *     Feature feature = reader.next();
- * }
+ * Reader for GPX 1.0 and 1.1 files.
+ * Usage:
  *
+ * {@preformat java
+ *     final Reader    reader   = new Reader(dataStore, gpxInput, null);
+ *     final Version   version  = reader.getVersion();
+ *     final Metadata  metadata = reader.getMetadata();
+ *     while(reader.hasNext()) {
+ *         Feature feature = reader.next();
+ *     }
  * }
- * </pre>
  *
- * @author Johann Sorel (Geomatys)
+ * @author  Johann Sorel (Geomatys)
  * @since   0.8
  * @version 0.8
  * @module
  */
 public class GPXReader extends StaxStreamReader {
-
+    /**
+     * The {@link org.opengis.feature.FeatureType} for routes, tracks, way points, <i>etc</i>.
+     */
     private final Types types;
+
+    /**
+     * The metadata (ISO 19115 compatible), or {@code null} if none.
+     */
     private Metadata metadata;
+
+    /**
+     * The feature to be returned by {@link #next()}.
+     * This field is updated during iteration.
+     */
     private Feature current;
+
     private int wayPointInc = 0;
     private int routeInc = 0;
     private int trackInc = 0;
@@ -84,11 +89,12 @@ public class GPXReader extends StaxStrea
      * {@inheritDoc }
      *
      * @param input input object
-     * @throws IOException if input failed to be opened for any IO reason
      * @throws XMLStreamException if input is not a valid XML stream
      */
-    public GPXReader(final Object input, final StorageConnector storage) throws DataStoreException, IOException, XMLStreamException {
-        super(input, storage);
+    public GPXReader(final GPXStore owner, final Object input, final StorageConnector storage)
+            throws DataStoreException, XMLStreamException, EOFException
+    {
+        super(owner, input, storage);
         types = Types.DEFAULT;
         final XMLStreamReader reader = getReader();
 
@@ -127,7 +133,7 @@ searchLoop:
                     } else if (Tags.METADATA.equalsIgnoreCase(typeName)) {
                         metadata = parseMetadata110();
                         break searchLoop;
-                    } else if (  Tags.WAY_POINT.equalsIgnoreCase(typeName)
+                    } else if (Tags.WAY_POINT.equalsIgnoreCase(typeName)
                             || Tags.TRACKS.equalsIgnoreCase(typeName)
                             || Tags.ROUTES.equalsIgnoreCase(typeName)) {
                         //there is no metadata tag
@@ -178,7 +184,7 @@ searchLoop:
      * @throws XMLStreamException if xml parser encounter an invalid element
      *         or underlying stream caused an exception
      */
-    public boolean hasNext() throws IOException, XMLStreamException {
+    public boolean hasNext() throws XMLStreamException {
         findNext();
         return current != null;
     }
@@ -190,7 +196,7 @@ searchLoop:
      * @throws XMLStreamException if xml parser encounter an invalid element
      *         or underlying stream caused an exception
      */
-    public Feature next() throws IOException, XMLStreamException {
+    public Feature next() throws XMLStreamException {
         findNext();
         final Feature ele = current;
         current = null;
@@ -201,7 +207,7 @@ searchLoop:
      * Search for the next feature in the stax stream.
      * This method will set the current local property if there is one.
      */
-    private void findNext() throws IOException, XMLStreamException {
+    private void findNext() throws XMLStreamException {
         final XMLStreamReader reader = getReader();
         if (current != null) return;
 
@@ -234,15 +240,13 @@ searchLoop:
      * Parse current metadata element.
      * The stax reader must be placed to the start element of the metadata.
      */
-    private Metadata parseMetadata100() throws IOException, XMLStreamException {
+    private Metadata parseMetadata100() throws XMLStreamException, EOFException {
         final XMLStreamReader reader = getReader();
         final Metadata metadata = new Metadata();
 
 searchLoop:
         while (reader.hasNext()) {
-            final int type = reader.next();
-
-            switch (type) {
+            switch (reader.next()) {
                 case START_ELEMENT: {
                     final String localName = reader.getLocalName();
                     if (Tags.NAME.equalsIgnoreCase(localName)) {
@@ -269,7 +273,7 @@ searchLoop:
                         metadata.keywords = reader.getElementText();
                     } else if (Tags.BOUNDS.equalsIgnoreCase(localName)) {
                         metadata.bounds = parseBound();
-                    } else if (  Tags.WAY_POINT.equalsIgnoreCase(localName)
+                    } else if (Tags.WAY_POINT.equalsIgnoreCase(localName)
                             || Tags.TRACKS.equalsIgnoreCase(localName)
                             || Tags.ROUTES.equalsIgnoreCase(localName)) {
                         //there is no more metadata tags
@@ -286,7 +290,7 @@ searchLoop:
      * Parse current metadata element.
      * The stax reader must be placed to the start element of the metadata.
      */
-    private Metadata parseMetadata110() throws IOException, XMLStreamException {
+    private Metadata parseMetadata110() throws XMLStreamException, EOFException {
         final XMLStreamReader reader = getReader();
         final Metadata metadata = new Metadata();
 
@@ -329,7 +333,7 @@ searchLoop:
      * Parse current copyright element.
      * The stax reader must be placed to the start element of the copyright.
      */
-    private Copyright parseCopyright() throws IOException, XMLStreamException {
+    private Copyright parseCopyright() throws XMLStreamException {
         final XMLStreamReader reader = getReader();
         final Copyright copyright = new Copyright();
         copyright.author = reader.getAttributeValue(null, Constants.ATT_COPYRIGHT_AUTHOR);
@@ -364,7 +368,7 @@ searchLoop:
      * Parse current URI element.
      * The stax reader must be placed to the start element.
      */
-    private Link parseLink() throws IOException, XMLStreamException {
+    private Link parseLink() throws XMLStreamException {
         final XMLStreamReader reader = getReader();
         String text = reader.getAttributeValue(null, Constants.ATT_LINK_HREF);
         String mime = null;
@@ -400,7 +404,7 @@ searchLoop:
      * Parse current Person element.
      * The stax reader must be placed to the start element.
      */
-    private Person parsePerson() throws IOException, XMLStreamException {
+    private Person parsePerson() throws XMLStreamException {
         final XMLStreamReader reader = getReader();
         final Person person = new Person();
 
@@ -433,7 +437,7 @@ searchLoop:
      * Parse current Envelope element.
      * The stax reader must be placed to the start element.
      */
-    private GeographicBoundingBox parseBound() throws IOException, XMLStreamException {
+    private GeographicBoundingBox parseBound() throws XMLStreamException, EOFException {
         final XMLStreamReader reader = getReader();
         final String xmin = reader.getAttributeValue(null, Constants.ATT_BOUNDS_MINLON);
         final String xmax = reader.getAttributeValue(null, Constants.ATT_BOUNDS_MAXLON);
@@ -457,7 +461,7 @@ searchLoop:
      * Parse way point type feature element.
      * The stax reader must be placed to the start element.
      */
-    private Feature parseWayPoint(final int index) throws IOException, XMLStreamException {
+    private Feature parseWayPoint(final int index) throws XMLStreamException {
         final XMLStreamReader reader = getReader();
         final Feature feature = types.wayPoint.newInstance();
         feature.setPropertyValue("@identifier", index);
@@ -546,7 +550,7 @@ searchLoop:
      * Parse route type feature element.
      * The stax reader must be placed to the start element.
      */
-    private Feature parseRoute(final int index) throws IOException, XMLStreamException {
+    private Feature parseRoute(final int index) throws XMLStreamException {
         final XMLStreamReader reader = getReader();
         final Feature feature = types.route.newInstance();
         feature.setPropertyValue("@identifier", index);
@@ -606,7 +610,7 @@ searchLoop:
      * Parse track segment type feature element.
      * The stax reader must be placed to the start element.
      */
-    private Feature parseTrackSegment(final int index) throws IOException, XMLStreamException {
+    private Feature parseTrackSegment(final int index) throws XMLStreamException {
         final XMLStreamReader reader = getReader();
         final Feature feature = types.trackSegment.newInstance();
         feature.setPropertyValue("@identifier", index);
@@ -640,7 +644,7 @@ searchLoop:
      * Parse track type feature element.
      * The stax reader must be placed to the start element.
      */
-    private Feature parseTrack(final int index) throws IOException, XMLStreamException {
+    private Feature parseTrack(final int index) throws XMLStreamException {
         final XMLStreamReader reader = getReader();
         final Feature feature = types.track.newInstance();
         feature.setPropertyValue("@identifier", index);
@@ -697,7 +701,7 @@ searchLoop:
 
     /**
      * Parse date or date time from string.
-     * The method support only ISO 8601 Date and DateTime formats.
+     * Dates and times in GPX files are Coordinated Universal Time (UTC) using ISO 8601 format.
      *
      * @param dateStr date in ISO date or data time format
      */

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXStore.java?rev=1774013&r1=1774012&r2=1774013&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXStore.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/gpx/GPXStore.java [UTF-8] Tue Dec 13 13:38:26 2016
@@ -16,12 +16,19 @@
  */
 package org.apache.sis.internal.gpx;
 
-import org.apache.sis.storage.DataStore;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import org.apache.sis.internal.xml.StaxDataStore;
+import org.apache.sis.setup.OptionKey;
+import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.StorageConnector;
+import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Version;
+import org.opengis.metadata.Metadata;
 
 
 /**
- * A data store backed by GeoTIFF files.
+ * A data store backed by GPX files.
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
@@ -29,7 +36,7 @@ import org.apache.sis.util.Version;
  * @version 0.8
  * @module
  */
-abstract class GPXStore extends DataStore {
+public class GPXStore extends StaxDataStore {
     /**
      * The "1.0" version.
      */
@@ -39,4 +46,43 @@ abstract class GPXStore extends DataStor
      * The "1.1" version.
      */
     static final Version V1_1 = new Version("1.1");
+
+    /**
+     * The file encoding. Actually used only by the writer; ignored by the reader.
+     */
+    final Charset encoding;
+
+    /**
+     * Creates a new GPX store from the given file, URL or stream object.
+     * This constructor invokes {@link StorageConnector#closeAllExcept(Object)},
+     * keeping open only the needed resource.
+     *
+     * @param  connector  information about the storage (URL, stream, <i>etc</i>).
+     * @throws DataStoreException if an error occurred while opening the GPX file.
+     */
+    public GPXStore(final StorageConnector connector) throws DataStoreException {
+        ArgumentChecks.ensureNonNull("connector", connector);
+        final Charset encoding = connector.getOption(OptionKey.ENCODING);
+        this.encoding = (encoding != null) ? encoding : StandardCharsets.UTF_8;
+    }
+
+    /**
+     * Returns the short name (abbreviation) of the format being read or written.
+     *
+     * @return {@code "GPX"}.
+     */
+    @Override
+    public String getFormatName() {
+        return "GPX";
+    }
+
+    @Override
+    public Metadata getMetadata() throws DataStoreException {
+        return null;    // TODO
+    }
+
+    @Override
+    public void close() throws DataStoreException {
+        // TODO
+    }
 }



Mime
View raw message