sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1732233 [1/2] - in /sis/branches/JDK7: ./ application/sis-console/src/main/java/org/apache/sis/console/ application/sis-console/src/main/resources/org/apache/sis/console/ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ co...
Date Wed, 24 Feb 2016 22:38:54 GMT
Author: desruisseaux
Date: Wed Feb 24 22:38:53 2016
New Revision: 1732233

URL: http://svn.apache.org/viewvc?rev=1732233&view=rev
Log:
Merge bug fixes from the JDK8 branch: SIS-308 to SIS-313.

Added:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java
      - copied unchanged from r1732232, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java
      - copied unchanged from r1732232, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/
      - copied from r1732232, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
      - copied unchanged from r1732232, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java
      - copied unchanged from r1732232, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/StoreProvider.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/
      - copied from r1732232, sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/wkt/
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreProviderTest.java
      - copied unchanged from r1732232, sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreProviderTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java
      - copied unchanged from r1732232, sis/branches/JDK8/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java
Removed:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/DefaultMetadataTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ReferencingInMetadataTest.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/XMLStore.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/XMLStoreProvider.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/XMLStoreProviderTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/XMLStoreTest.java
Modified:
    sis/branches/JDK7/   (props changed)
    sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/AboutSC.java
    sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/Command.java
    sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/HelpSC.java
    sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java
    sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeSC.java
    sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/Option.java
    sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java
    sis/branches/JDK7/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties
    sis/branches/JDK7/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Warnings.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Version.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/package-info.java
    sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
    sis/branches/JDK7/storage/sis-storage/src/main/resources/META-INF/services/org.apache.sis.storage.DataStoreProvider
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/MimeTypeDetectorTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoresTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/StorageConnectorTest.java
    sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java

Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 24 22:38:53 2016
@@ -1,4 +1,4 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1731653
+/sis/branches/JDK8:1584960-1732232
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/AboutSC.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/AboutSC.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/AboutSC.java [UTF-8] (original)
+++ sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/AboutSC.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -68,7 +68,7 @@ final class AboutSC extends SubCommand {
      */
     AboutSC(final int commandIndex, final String... args) throws InvalidOptionException {
         super(commandIndex, args, EnumSet.of(Option.LOCALE, Option.TIMEZONE, Option.ENCODING,
-                Option.BRIEF, Option.VERBOSE, Option.HELP));
+                Option.BRIEF, Option.VERBOSE, Option.HELP, Option.DEBUG));
     }
 
     /**

Modified: sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/Command.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/Command.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/Command.java [UTF-8] (original)
+++ sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/Command.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -26,6 +26,7 @@ import java.io.IOException;
 import java.sql.SQLException;
 import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.logging.MonolineFormatter;
 
@@ -38,6 +39,7 @@ import org.apache.sis.util.logging.Monol
  * <tr><td>{@code about}    </td><td>Show information about Apache SIS and system configuration.</td></tr>
  * <tr><td>{@code mime-type}</td><td>Show MIME type for the given file.</td></tr>
  * <tr><td>{@code metadata} </td><td>Show metadata information for the given file.</td></tr>
+ * <tr><td>{@code crs}      </td><td>Show Coordinate Reference System information for the given file or code.</td></tr>
  * </table></blockquote>
  *
  * Each command can accepts an arbitrary amount of the following options:
@@ -50,6 +52,7 @@ import org.apache.sis.util.logging.Monol
  * <tr><td>{@code --colors}   </td><td>Whether colorized output shall be enabled.</td></tr>
  * <tr><td>{@code --brief}    </td><td>Whether the output should contains only brief information.</td></tr>
  * <tr><td>{@code --verbose}  </td><td>Whether the output should contains more detailed information.</td></tr>
+ * <tr><td>{@code --debug}    </td><td>Prints full stack trace in case of failure.</td></tr>
  * <tr><td>{@code --help}     </td><td>Lists the options available for a specific command.</td></tr>
  * </table></blockquote>
  *
@@ -60,11 +63,11 @@ import org.apache.sis.util.logging.Monol
  *
  * <div class="section">SIS installation on remote machines</div>
  * Some sub-commands can operate on SIS installation on remote machines, provided that remote access has been enabled
- * at the Java Virtual Machine startup time. See {@link org.apache.sis.console} package javadoc for more information.
+ * at the Java Virtual Machine startup time. See {@linkplain org.apache.sis.console package javadoc} for more information.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.6
+ * @version 0.7
  * @module
  */
 public final class Command {
@@ -211,16 +214,28 @@ public final class Command {
     /**
      * Prints the message of the given exception. This method is invoked only when the error occurred before
      * the {@link SubCommand} has been built, otherwise the {@link SubCommand#err} printer shall be used.
+     *
+     * @param args The command line arguments, used only for detecting if the {@code --debug} option was present.
      */
-    private static void error(final Exception e) {
+    private static void error(final String[] args, final Exception e) {
+        final boolean debug = ArraysExt.containsIgnoreCase(args, Option.PREFIX + "debug");
         final Console console = System.console();
         if (console != null) {
             final PrintWriter err = console.writer();
-            err.println(e.getLocalizedMessage());
+            if (debug) {
+                e.printStackTrace(err);
+            } else {
+                err.println(e.getLocalizedMessage());
+            }
             err.flush();
         } else {
+            @SuppressWarnings("UseOfSystemOutOrSystemErr")
             final PrintStream err = System.err;
-            err.println(e.getLocalizedMessage());
+            if (debug) {
+                e.printStackTrace(err);
+            } else {
+                err.println(e.getLocalizedMessage());
+            }
             err.flush();
         }
     }
@@ -253,11 +268,11 @@ public final class Command {
         try {
             c = new Command(args);
         } catch (InvalidCommandException e) {
-            error(e);
+            error(args, e);
             System.exit(INVALID_COMMAND_EXIT_CODE);
             return;
         } catch (InvalidOptionException e) {
-            error(e);
+            error(args, e);
             System.exit(INVALID_OPTION_EXIT_CODE);
             return;
         }

Modified: sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/HelpSC.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/HelpSC.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/HelpSC.java [UTF-8] (original)
+++ sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/HelpSC.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -56,7 +56,7 @@ final class HelpSC extends SubCommand {
      * Creates the {@code "help"} sub-command.
      */
     HelpSC(final int commandIndex, final String... args) throws InvalidOptionException {
-        super(commandIndex, args, EnumSet.of(Option.LOCALE, Option.ENCODING, Option.HELP));
+        super(commandIndex, args, EnumSet.of(Option.LOCALE, Option.ENCODING, Option.HELP, Option.DEBUG));
     }
 
     /**

Modified: sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java [UTF-8] (original)
+++ sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -46,7 +46,7 @@ import org.apache.sis.xml.XML;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.7
  * @module
  */
 final class MetadataSC extends SubCommand {
@@ -71,7 +71,7 @@ final class MetadataSC extends SubComman
      */
     MetadataSC(final boolean isCRS, final int commandIndex, final String... args) throws InvalidOptionException {
         super(commandIndex, args, EnumSet.of(Option.FORMAT, Option.LOCALE, Option.TIMEZONE, Option.ENCODING,
-                Option.COLORS, Option.HELP));
+                Option.COLORS, Option.HELP, Option.DEBUG));
         this.isCRS = isCRS;
     }
 
@@ -83,6 +83,7 @@ final class MetadataSC extends SubComman
      * @throws IOException Should never happen, since we are appending to a print writer.
      */
     @Override
+    @SuppressWarnings("UseOfSystemOutOrSystemErr")
     public int run() throws InvalidOptionException, DataStoreException, JAXBException, IOException {
         /*
          * Output format can be either "text" (the default) or "xml".
@@ -112,24 +113,31 @@ final class MetadataSC extends SubComman
         }
         /*
          * Read metadata from the data storage.
-         * If we are executing the "crs" sub-command, extract the first CRS.
          */
-        if (hasUnexpectedFileCount(1, 1)) {
-            return Command.INVALID_ARGUMENT_EXIT_CODE;
-        }
-        final Metadata metadata;
-        try (DataStore store = DataStores.open(files.get(0))) {
-            metadata = store.getMetadata();
+        Object metadata;
+        if (useStandardInput()) {
+            try (DataStore store = DataStores.open(System.in)) {
+                metadata = store.getMetadata();
+            }
+        } else {
+            if (hasUnexpectedFileCount(1, 1)) {
+                return Command.INVALID_ARGUMENT_EXIT_CODE;
+            }
+            try (DataStore store = DataStores.open(files.get(0))) {
+                metadata = store.getMetadata();
+            }
         }
         if (metadata == null) {
             return 0;
         }
-        Object object = metadata;
-        if (isCRS) {
+        /*
+         * If we are executing the "crs" sub-command, extract the first CRS.
+         */
+        if (isCRS && (metadata instanceof Metadata)) {
             boolean found = false;
-            for (final ReferenceSystem rs : metadata.getReferenceSystemInfo()) {
+            for (final ReferenceSystem rs : ((Metadata) metadata).getReferenceSystemInfo()) {
                 if (rs instanceof CoordinateReferenceSystem) {
-                    object = (CoordinateReferenceSystem) rs;
+                    metadata = rs;
                     found = true;
                     break;
                 }
@@ -158,7 +166,7 @@ final class MetadataSC extends SubComman
                 if (colors) {
                     f.setColors(Colors.DEFAULT);
                 }
-                f.format(object, out);
+                f.format(metadata, out);
                 out.println();
                 break;
             }
@@ -169,11 +177,11 @@ final class MetadataSC extends SubComman
                 marshaller.setProperty(XML.LOCALE,   locale);
                 marshaller.setProperty(XML.TIMEZONE, timezone);
                 if (isConsole()) {
-                    marshaller.marshal(object, out);
+                    marshaller.marshal(metadata, out);
                 } else {
                     out.flush();
                     marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding.name());
-                    marshaller.marshal(object, System.out); // Use OutputStream instead than Writer.
+                    marshaller.marshal(metadata, System.out);   // Intentionally use OutputStream instead than Writer.
                     System.out.flush();
                 }
                 break;
@@ -190,7 +198,7 @@ final class MetadataSC extends SubComman
      * {@code Writer} and let the marshaller apply the encoding itself.
      */
     private boolean isConsole() {
-        if (outputBuffer != null) return true; // Special case for JUnit tests only.
+        if (outputBuffer != null) return true;                      // Special case for JUnit tests only.
         final Console console = System.console();
         return (console != null) && console.writer() == out;
     }

Modified: sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeSC.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeSC.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeSC.java [UTF-8] (original)
+++ sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeSC.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -54,7 +54,7 @@ final class MimeTypeSC extends SubComman
      * Creates the {@code "mime-type"} sub-command.
      */
     MimeTypeSC(final int commandIndex, final String... args) throws InvalidOptionException {
-        super(commandIndex, args, EnumSet.of(Option.ENCODING, Option.HELP));
+        super(commandIndex, args, EnumSet.of(Option.ENCODING, Option.HELP, Option.DEBUG));
     }
 
     /**

Modified: sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/Option.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/Option.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/Option.java [UTF-8] (original)
+++ sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/Option.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -25,7 +25,7 @@ import org.apache.sis.util.resources.Err
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.7
  * @module
  */
 enum Option {
@@ -67,6 +67,12 @@ enum Option {
     VERBOSE(false),
 
     /**
+     * Whether to print the full stack trace in case of error.
+     * This option expects no value.
+     */
+    DEBUG(false),
+
+    /**
      * Lists the options accepted by a command.
      */
     HELP(false);

Modified: sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java [UTF-8] (original)
+++ sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/SubCommand.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -38,7 +38,7 @@ import org.apache.sis.internal.util.X364
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.7
  * @module
  */
 abstract class SubCommand {
@@ -88,6 +88,11 @@ abstract class SubCommand {
     protected final boolean colors;
 
     /**
+     * {@code true} for printing the full stack trace in case of failure.
+     */
+    protected final boolean debug;
+
+    /**
      * Output stream to the console. This output stream uses the encoding
      * specified by the {@code "--encoding"} argument, if presents.
      */
@@ -124,6 +129,7 @@ abstract class SubCommand {
         this.timezone     = parent.timezone;
         this.encoding     = parent.encoding;
         this.colors       = parent.colors;
+        this.debug        = parent.debug;
         this.out          = parent.out;
         this.err          = parent.err;
         this.outputBuffer = parent.outputBuffer;
@@ -141,6 +147,7 @@ abstract class SubCommand {
      * @param  validOptions The command-line options allowed by this sub-command.
      * @throws InvalidOptionException If an illegal option has been provided, or the option has an illegal value.
      */
+    @SuppressWarnings("UseOfSystemOutOrSystemErr")
     protected SubCommand(final int commandIndex, final String[] arguments, final EnumSet<Option> validOptions)
             throws InvalidOptionException
     {
@@ -188,6 +195,8 @@ abstract class SubCommand {
         final Console console;
         final boolean explicitEncoding;
         try {
+            debug = options.containsKey(option = Option.DEBUG);
+
             value = options.get(option = Option.LOCALE);
             locale = (value != null) ? Locales.parse(value) : Locale.getDefault(Locale.Category.DISPLAY);
 
@@ -202,7 +211,7 @@ abstract class SubCommand {
             console = System.console();
             colors = (value != null) ? Option.COLORS.parseBoolean(value) : (console != null) && X364.isAnsiSupported();
         } catch (RuntimeException e) {
-            @SuppressWarnings("null") // 'option' has been assigned in 'get' argument.
+            @SuppressWarnings("null")                                   // 'option' has been assigned in 'get' argument.
             final String name = option.name().toLowerCase(Locale.US);
             throw new InvalidOptionException(Errors.format(Errors.Keys.IllegalOptionValue_2, name, value), name);
         }
@@ -281,6 +290,13 @@ abstract class SubCommand {
     }
 
     /**
+     * Returns {@code true} if the command should use the standard input.
+     */
+    final boolean useStandardInput() {
+        return files.isEmpty() && System.console() == null;
+    }
+
+    /**
      * Prints the <cite>"Can not open …"</cite> error message followed by the message in the given exception.
      *
      * @param fileIndex Index in the {@link #files} list of the file that can not be opened.
@@ -298,7 +314,11 @@ abstract class SubCommand {
      */
     final void error(final String message, final Exception e) {
         out.flush();
-        err.println(Exceptions.formatChainedMessages(locale, message, e));
+        if (debug) {
+            e.printStackTrace(err);
+        } else {
+            err.println(Exceptions.formatChainedMessages(locale, message, e));
+        }
     }
 
     /**

Modified: sis/branches/JDK7/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties [ISO-8859-1] Wed Feb 24 22:38:53 2016
@@ -6,4 +6,5 @@ encoding=The encoding to use for the com
 colors=Whether colorized output shall be enabled.
 brief=Reduce the output to only brief information.
 verbose=Request the output to contain more detailed information.
+debug=Prints full stack trace in case of failure.
 help=Lists the options available for a specific command.

Modified: sis/branches/JDK7/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties [ISO-8859-1] Wed Feb 24 22:38:53 2016
@@ -6,4 +6,5 @@ encoding=L\u2019encodage des caractères
 colors=Indique si l\u2019affichage peut être en couleurs.
 brief=Indique que la sortie de la commande ne doit contenir que de brèves informations.
 verbose=Indique que la sortie de la commande doit contenir des informations plus détaillées.
+debug=Affiche la trace complète de l\u2019exception en cas d\u2019échec.
 help=Liste les options disponibles pour une commande spécifique.

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -19,6 +19,7 @@ package org.apache.sis.internal.metadata
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Locale;
+import javax.sql.DataSource;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Role;
 import org.opengis.metadata.citation.Citation;
@@ -27,12 +28,17 @@ import org.opengis.metadata.citation.Res
 import org.apache.sis.internal.simple.CitationConstant;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.internal.util.MetadataServices;
+import org.apache.sis.internal.metadata.sql.Initializer;
+import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.metadata.iso.ImmutableIdentifier;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.metadata.iso.citation.DefaultCitation;
 import org.apache.sis.metadata.iso.citation.DefaultOrganisation;
 import org.apache.sis.metadata.iso.citation.DefaultResponsibility;
+import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.iso.Types;
+import org.apache.sis.util.Exceptions;
+import org.apache.sis.util.Classes;
 
 import static java.util.Collections.singleton;
 
@@ -219,6 +225,37 @@ public final class ServicesForUtility ex
      */
     @Override
     public String getInformation(final String key, final Locale locale) {
+        switch (key) {
+            case "DataSource": {
+                Object server = null, database = null;
+                try {
+                    final DataSource ds = Initializer.getDataSource();
+                    if (ds != null) {
+                        final Class<?> type = ds.getClass();
+                        database = type.getMethod("getDatabaseName", (Class[]) null).invoke(ds, (Object[]) null);
+                        server   = type.getMethod("getServerName", (Class[]) null).invoke(ds, (Object[]) null);
+                    }
+                } catch (NoSuchMethodException e) {
+                    Logging.recoverableException(Logging.getLogger(Loggers.SYSTEM),
+                            MetadataServices.class, "getInformation", e);
+                } catch (Exception e) {
+                    // Leave the message alone if it contains at least 2 words.
+                    String message = Exceptions.getLocalizedMessage(e, locale);
+                    if (message == null || message.indexOf(' ') < 0) {
+                        message = Classes.getShortClassName(e) + ": " + message;
+                    }
+                    return message;
+                }
+                if (database != null) {
+                    if (server != null) {
+                        database = "//" + server + '/' + database;
+                    }
+                    return database.toString();
+                }
+                return null;
+            }
+            // More cases may be added in future SIS versions.
+        }
         return ReferencingServices.getInstance().getInformation(key, locale);
     }
 }

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTKeywords.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -163,6 +163,7 @@ public final class WKTKeywords extends S
      * Related to {@link org.apache.sis.referencing.operation.AbstractCoordinateOperation}.
      */
     public static final String
+            BoundCRS            = "BoundCRS",
             Method              = "Method",
             Formula             = "Formula",
             Projection          = "Projection",

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ScriptRunner.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -345,7 +345,7 @@ public class ScriptRunner implements Aut
     }
 
     /**
-     * Run the script from the given reader. Lines are read and grouped up to the
+     * Runs the script from the given reader. Lines are read and grouped up to the
      * terminal {@value #END_OF_STATEMENT} character, then sent to the database.
      *
      * @param  filename Name of the SQL script being executed. This is used only for error reporting.

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -36,6 +36,7 @@ import org.opengis.util.InternationalStr
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.internal.util.StandardDateFormat;
 import org.apache.sis.measure.Units;
+import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.logging.Logging;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -165,7 +166,7 @@ abstract class AbstractParser implements
         this.unitFormat  = unitFormat;
         this.errorLocale = errorLocale;
         if (Symbols.SCIENTIFIC_NOTATION && numberFormat instanceof DecimalFormat) {
-            final DecimalFormat decimalFormat = (DecimalFormat) ((DecimalFormat) numberFormat).clone();
+            final DecimalFormat decimalFormat = (DecimalFormat) numberFormat.clone();
             exponentSymbol = decimalFormat.getDecimalFormatSymbols().getExponentSeparator();
             String pattern = decimalFormat.toPattern();
             if (!pattern.contains("E0")) {
@@ -236,6 +237,7 @@ abstract class AbstractParser implements
     public Object parseObject(final String text, final ParsePosition position) throws ParseException {
         warnings = null;
         ignoredElements.clear();
+        ArgumentChecks.ensureNonEmpty("text", text);
         final Element element = new Element("<root>", new Element(this, text, position, null));
         final Object object = parseObject(element);
         element.close(ignoredElements);
@@ -292,7 +294,7 @@ abstract class AbstractParser implements
     final Unit<?> parseUnit(final String text) throws ParseException {
         if (unitFormat == null) {
             if (symbols.getLocale() == Locale.ROOT) {
-                return Units.valueOf(text); // Most common case, avoid the convolved code below.
+                return Units.valueOf(text);             // Most common case, avoid the convolved code below.
             }
             unitFormat = UnitFormat.getInstance(symbols.getLocale());
         }
@@ -314,28 +316,17 @@ abstract class AbstractParser implements
     /**
      * Reports a non-fatal warning that occurred while parsing a WKT.
      *
-     * @param parent  The parent element.
-     * @param element The element that we can not parse.
-     * @param ex      The non-fatal exception that occurred while parsing the element.
-     */
-    final void warning(final Element parent, final Element element, final Exception ex) {
-        if (warnings == null) {
-            warnings = new Warnings(errorLocale, true, ignoredElements);
-        }
-        warnings.add(null, ex, new String[] {parent.keyword, element.keyword});
-    }
-
-    /**
-     * Reports a non-fatal warning that occurred while parsing a WKT.
-     *
-     * @param message The message. Can not be {@code null}.
+     * @param parent  The parent element, or {@code null} if unknown.
+     * @param element The element that we can not parse, or {@code null} if unknown.
+     * @param message The message. Can be {@code null} only if {@code ex} is non-null.
      * @param ex      The non-fatal exception that occurred while parsing the element, or {@code null}.
      */
-    final void warning(final InternationalString message, final Exception ex) {
+    final void warning(final Element parent, final Element element, final InternationalString message, final Exception ex) {
         if (warnings == null) {
             warnings = new Warnings(errorLocale, true, ignoredElements);
         }
-        warnings.add(message, ex, null);
+        warnings.add(message, ex, (parent != null && element != null)
+                ? new String[] {parent.keyword, element.keyword} : null);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -178,7 +178,7 @@ final class Element implements Serializa
         final int length = text.length();
         int lower = skipLeadingWhitespaces(text, offset, length);
         { // This block is for keeping some variables local.
-            int c = text.codePointAt(lower);
+            int c = (lower < length) ? text.codePointAt(lower) : 0;
             if (!Character.isUnicodeIdentifierStart(c)) {
                 keyword = text;
                 position.setErrorIndex(lower);
@@ -636,7 +636,7 @@ final class Element implements Serializa
         final Iterator<Object> iterator = list.iterator();
         while (iterator.hasNext()) {
             final Object object = iterator.next();
-            if (object != null) {
+            if (object != null && !(object instanceof Element)) {
                 iterator.remove();
                 return object;
             }
@@ -722,7 +722,7 @@ final class Element implements Serializa
         final Iterator<Object> iterator = list.iterator();
         while (iterator.hasNext()) {
             final Object object = iterator.next();
-            if (type.isInstance(object)) {
+            if (type.isInstance(object) && !(object instanceof Element)) {
                 iterator.remove();
                 return (T) object;
             }

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -299,7 +299,7 @@ final class GeodeticObjectParser extends
                     else ex.addSuppressed(e);
                 }
                 if (verticalElements != null) {
-                    warning(Errors.formatInternational(Errors.Keys.CanNotAssignUnitToDimension_2,
+                    warning(null, null, Errors.formatInternational(Errors.Keys.CanNotAssignUnitToDimension_2,
                             WKTKeywords.VerticalExtent, verticalElements.unit), ex);
                 }
             }
@@ -411,7 +411,7 @@ final class GeodeticObjectParser extends
      * This include elements like {@code "SCOPE"}, {@code "ID"} (WKT 2) or {@code "AUTHORITY"} (WKT 1).
      * This WKT 1 element has the following pattern:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     AUTHORITY["<name>", "<code>"]
      * }
      *
@@ -435,8 +435,8 @@ final class GeodeticObjectParser extends
         Element element;
         while ((element = parent.pullElement(OPTIONAL, ID_KEYWORDS)) != null) {
             final String   codeSpace = element.pullString("codeSpace");
-            final String   code      = element.pullObject("code").toString();   // Accepts Integer as well as String.
-            final Object   version   = element.pullOptional(Object.class);      // Accepts Number as well as String.
+            final String   code      = element.pullObject("code").toString();       // Accepts Integer as well as String.
+            final Object   version   = element.pullOptional(Object.class);          // Accepts Number as well as String.
             final Element  citation  = element.pullElement(OPTIONAL, WKTKeywords.Citation);
             final String   authority;
             if (citation != null) {
@@ -505,8 +505,11 @@ final class GeodeticObjectParser extends
             while ((element = parent.pullElement(OPTIONAL, WKTKeywords.Area)) != null) {
                 final String area = element.pullString("area");
                 element.close(ignoredElements);
-                if (extent == null) extent = new DefaultExtent();
-                extent.getGeographicElements().add(new DefaultGeographicDescription(area));
+                if (extent == null) {
+                    extent = new DefaultExtent(area, null, null, null);
+                } else {
+                    extent.getGeographicElements().add(new DefaultGeographicDescription(area));
+                }
             }
             /*
              * Example: BBOX[51.43, 2.54, 55.77, 6.40]
@@ -549,7 +552,7 @@ final class GeodeticObjectParser extends
                     element.pullString("startTime");
                     element.pullString("endTime");
                     element.close(ignoredElements);
-                    warning(Errors.formatInternational(Errors.Keys.UnsupportedType_1, "TimeExtent[String,String]"), null);
+                    warning(parent, element, Errors.formatInternational(Errors.Keys.UnsupportedType_1, "TimeExtent[String,String]"), null);
                 } else {
                     final Date startTime = element.pullDate("startTime");
                     final Date endTime   = element.pullDate("endTime");
@@ -560,10 +563,13 @@ final class GeodeticObjectParser extends
                         if (extent == null) extent = new DefaultExtent();
                         extent.getTemporalElements().add(t);
                     } catch (UnsupportedOperationException e) {
-                        warning(parent, element, e);
+                        warning(parent, element, null, e);
                     }
                 }
             }
+            if (extent != null) {
+                properties.put(ReferenceSystem.DOMAIN_OF_VALIDITY_KEY, extent);
+            }
             /*
              * Example: REMARK["Замечание на русском языке"]
              */
@@ -595,7 +601,7 @@ final class GeodeticObjectParser extends
      * Parses an optional {@code "UNIT"} element of a known dimension.
      * This element has the following pattern:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     UNIT["<name>", <conversion factor> {,<authority>}]
      * }
      *
@@ -627,7 +633,7 @@ final class GeodeticObjectParser extends
             if (baseUnit.toSI().equals(unit.toSI())) {
                 return (Unit<Q>) unit;
             } else {
-                warning(Errors.formatInternational(Errors.Keys.IllegalUnitFor_2, keyword, unit), null);
+                warning(parent, element, Errors.formatInternational(Errors.Keys.IllegalUnitFor_2, keyword, unit), null);
             }
         }
         return Units.multiply(baseUnit, factor);
@@ -637,7 +643,7 @@ final class GeodeticObjectParser extends
      * Parses a {@code "CS"} element followed by all {@code "AXIS"} elements.
      * This element has the following pattern (simplified):
      *
-     * {@preformat text
+     * {@preformat wkt
      *     CS["<type>", dimension],
      *     AXIS["<name>", NORTH | SOUTH | EAST | WEST | UP | DOWN | OTHER],
      *     UNIT["<name>", <conversion factor>],
@@ -934,7 +940,7 @@ final class GeodeticObjectParser extends
                 return referencing.createAbstractCS(csProperties, axes);
             }
             default: {
-                warning(Errors.formatInternational(Errors.Keys.UnknownType_1, type), null);
+                warning(parent, null, Errors.formatInternational(Errors.Keys.UnknownType_1, type), null);
                 return referencing.createAbstractCS(csProperties, axes);
             }
         }
@@ -947,10 +953,16 @@ final class GeodeticObjectParser extends
      * Parses an {@code "AXIS"} element.
      * This element has the following pattern (simplified):
      *
-     * {@preformat text
+     * {@preformat wkt
      *     AXIS["<name (abbr.)>", NORTH | SOUTH | EAST | WEST | UP | DOWN | OTHER, ORDER[n], UNIT[…], ID[…]]
      * }
      *
+     * Abbreviation may be specified between parenthesis. Nested parenthesis are possible, as for example:
+     *
+     * {@preformat wkt
+     *     AXIS["Easting (E(X))", EAST]
+     * }
+     *
      * @param  mode        {@link #FIRST}, {@link #OPTIONAL} or {@link #MANDATORY}.
      * @param  parent      The parent element.
      * @param  csType      The coordinate system type (Cartesian | ellipsoidal | vertical | etc…), or null if unknown.
@@ -999,8 +1011,18 @@ final class GeodeticObjectParser extends
          * have to guess one since abbreviation is a mandatory part of axis.
          */
         String abbreviation;
-        final int start, end = name.length() - 1;
+        int start, end = name.length() - 1;
         if (end > 1 && name.charAt(end) == ')' && (start = name.lastIndexOf('(', end-1)) >= 0) {
+            // Abbreviation may have nested parenthesis (e.g. "Easting (E(X))").
+            for (int np = end; (--np >= 0) && name.charAt(np) == ')';) {
+                final int c = name.lastIndexOf('(', start - 1);
+                if (c < 0) {
+                    warning(parent, element, Errors.formatInternational(
+                            Errors.Keys.NonEquilibratedParenthesis_2, '(', name), null);
+                    break;
+                }
+                start = c;
+            }
             abbreviation = CharSequences.trimWhitespaces(name.substring(start + 1, end));
             name = CharSequences.trimWhitespaces(name.substring(0, start));
             if (name.isEmpty()) {
@@ -1074,7 +1096,7 @@ final class GeodeticObjectParser extends
      *
      * The legacy WKT 1 pattern was:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     PRIMEM["<name>", <longitude> {,<authority>}]
      * }
      *
@@ -1116,7 +1138,7 @@ final class GeodeticObjectParser extends
      * Parses an <strong>optional</strong> {@code "TOWGS84"} element.
      * This element is specific to WKT 1 and has the following pattern:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     TOWGS84[<dx>, <dy>, <dz>, <ex>, <ey>, <ez>, <ppm>]
      * }
      *
@@ -1148,7 +1170,7 @@ final class GeodeticObjectParser extends
      *
      * The legacy WKT 1 pattern was:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     SPHEROID["<name>", <semi-major axis>, <inverse flattening> {,<authority>}]
      * }
      *
@@ -1239,7 +1261,7 @@ final class GeodeticObjectParser extends
      *
      * The legacy WKT 1 specification was:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     PROJECTION["<name>" {,<authority>}]
      * }
      *
@@ -1313,7 +1335,7 @@ final class GeodeticObjectParser extends
      *
      * The legacy WKT 1 pattern was:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     DATUM["<name>", <spheroid> {,<to wgs84>} {,<authority>}]
      * }
      *
@@ -1353,7 +1375,7 @@ final class GeodeticObjectParser extends
      *
      * The legacy WKT 1 pattern was:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     VERT_DATUM["<name>", <datum type> {,<authority>}]
      * }
      *
@@ -1391,7 +1413,7 @@ final class GeodeticObjectParser extends
     /**
      * Parses a {@code "TimeDatum"} element. This element has the following pattern:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     TimeDatum["<name>", TimeOrigin[<time origin>] {,<authority>}]
      * }
      *
@@ -1422,7 +1444,7 @@ final class GeodeticObjectParser extends
      *
      * The legacy WKT 1 pattern was:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     LOCAL_DATUM["<name>", <datum type> {,<authority>}]
      * }
      *
@@ -1483,7 +1505,7 @@ final class GeodeticObjectParser extends
      *
      * The legacy WKT 1 pattern was:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     LOCAL_CS["<name>", <local datum>, <unit>, <axis>, {,<axis>}* {,<authority>}]
      * }
      *
@@ -1577,8 +1599,8 @@ final class GeodeticObjectParser extends
         try {
             cs = parseCoordinateSystem(element, WKTKeywords.Cartesian, 2, false, unit, datum);
             final Map<String,?> properties = parseMetadataAndClose(element, name, datum);
-            if (cs instanceof CartesianCS) {
-                return crsFactory.createImageCRS(properties, datum, (CartesianCS) cs);
+            if (cs instanceof AffineCS) {
+                return crsFactory.createImageCRS(properties, datum, (AffineCS) cs);
             }
         } catch (FactoryException exception) {
             throw element.parseFailed(exception);
@@ -1592,13 +1614,13 @@ final class GeodeticObjectParser extends
      *
      * The legacy WKT 1 specification had two elements for this:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     GEOGCS["<name>", <datum>, <prime meridian>, <angular unit>  {,<twin axes>} {,<authority>}]
      * }
      *
      * and
      *
-     * {@preformat text
+     * {@preformat wkt
      *     GEOCCS["<name>", <datum>, <prime meridian>, <linear unit> {,<axis> ,<axis> ,<axis>} {,<authority>}]
      * }
      *
@@ -1761,7 +1783,7 @@ final class GeodeticObjectParser extends
      *
      * The legacy WKT 1 pattern was:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     VERT_CS["<name>", <vert datum>, <linear unit>, {<axis>,} {,<authority>}]
      * }
      *
@@ -1808,7 +1830,7 @@ final class GeodeticObjectParser extends
                 baseCRS = parseVerticalCRS(MANDATORY, element, true);
             }
         }
-        if (baseCRS == null) {  // The most usual case.
+        if (baseCRS == null) {                                                              // The most usual case.
             datum = parseVerticalDatum(MANDATORY, element, isWKT1);
         }
         final CoordinateSystem cs;
@@ -1912,7 +1934,7 @@ final class GeodeticObjectParser extends
      *
      * The legacy WKT 1 specification was:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     PROJCS["<name>", <geographic cs>, <projection>, {<parameter>,}*,
      *            <linear unit> {,<twin axes>}{,<authority>}]
      * }
@@ -1994,7 +2016,7 @@ final class GeodeticObjectParser extends
      *
      * The legacy WKT 1 specification was:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     COMPD_CS["<name>", <head cs>, <tail cs> {,<authority>}]
      * }
      *
@@ -2026,7 +2048,7 @@ final class GeodeticObjectParser extends
      * Parses a {@code "FITTED_CS"} element.
      * This element has the following pattern:
      *
-     * {@preformat text
+     * {@preformat wkt
      *     FITTED_CS["<name>", <to base>, <base cs>]
      * }
      *

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -203,7 +203,7 @@ class MathTransformParser extends Abstra
         final Element element = parent.pullElement(OPTIONAL, ID_KEYWORDS);
         if (element != null) {
             final String codeSpace = element.pullString("codeSpace");
-            final Object code      = element.pullObject("code");   // Accepts Integer as well as String.
+            final Object code      = element.pullObject("code");            // Accepts Integer as well as String.
             element.close(ignoredElements);
             if (Constants.EPSG.equalsIgnoreCase(codeSpace)) try {
                 final int n;
@@ -214,7 +214,7 @@ class MathTransformParser extends Abstra
                 }
                 return Units.valueOfEPSG(n);
             } catch (NumberFormatException e) {
-                warning(parent, element, e);
+                warning(parent, element, null, e);
             }
         }
         return null;

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Warnings.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Warnings.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Warnings.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Warnings.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -185,13 +185,13 @@ public final class Warnings implements L
     final void add(final InternationalString message, final Exception cause, final String[] source) {
         assert (message != null) || (cause != null);
         if (messages == null) {
-            messages = new ArrayList<>(4);  // We expect few items.
+            messages = new ArrayList<>(4);                          // We expect few items.
         }
         messages.add(message);
         messages.add(cause);
         if (cause != null) {
             if (exceptionSources == null) {
-                exceptionSources = new LinkedHashMap<>(4);  // We expect few items.
+                exceptionSources = new LinkedHashMap<>(4);          // We expect few items.
             }
             exceptionSources.put(cause, source);
         }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -54,6 +54,7 @@ import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.io.wkt.ElementKind;
 import org.apache.sis.io.wkt.Transliterator;
 import org.apache.sis.io.wkt.FormattableObject;
+import org.apache.sis.io.wkt.UnformattableObjectException;
 
 import static java.lang.Double.doubleToLongBits;
 import static java.lang.Double.NEGATIVE_INFINITY;
@@ -92,7 +93,7 @@ import java.util.Objects;
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.6
+ * @version 0.7
  * @module
  *
  * @see AbstractCS
@@ -772,9 +773,13 @@ public class DefaultCoordinateSystemAxis
          * if the direction is of the kind "South along 90°N" for instance.
          */
         DirectionAlongMeridian meridian = null;
-        if (!isWKT1 && AxisDirections.isUserDefined(dir)) {
+        if (AxisDirections.isUserDefined(dir)) {
             meridian = DirectionAlongMeridian.parse(dir);
             if (meridian != null) {
+                if (isWKT1) {
+                    throw new UnformattableObjectException(Errors.format(
+                            Errors.Keys.CanNotRepresentInFormat_2, "WKT 1", meridian));
+                }
                 dir = meridian.baseDirection;
             }
         }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -60,7 +60,7 @@ import org.opengis.util.Factory;
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.7
  * @module
  */
 @DependsOn({
@@ -629,24 +629,16 @@ public final strictfp class GeodeticObje
                      "    DATUM[“Nouvelle Triangulation Française (Paris)”," +
                      "      SPHEROID[“Clarke 1880 (IGN)”, 6378249.2, 293.4660212936269]," +
                      "      TOWGS84[-168,-60,320,0,0,0,0]]," +
-                     "    PRIMEM[“Paris”, 2.5969213, AUTHORITY[“EPSG”, “8903”]]," +  // In grads.
+                     "    PRIMEM[“Paris”, 2.5969213, AUTHORITY[“EPSG”, “8903”]]," +  // In grades.
                      "    UNIT[“grad”, 0.01570796326794897]]," +
                      "  PROJECTION[“Lambert Conformal Conic (1SP)”]," +  // Intentional swapping of "Conformal" and "Conic".
-                     "  PARAMETER[“latitude_of_origin”, 52.0]," +        // In grads.
+                     "  PARAMETER[“latitude_of_origin”, 52.0]," +        // In grades.
                      "  PARAMETER[“scale_factor”, 0.99987742]," +
                      "  PARAMETER[“false_easting”, 600.0]," +
                      "  PARAMETER[“false_northing”, 2200.0]," +
-                     "  UNIT[“metre”,1000]]";
+                     "  UNIT[“km”,1000]]";
 
-        ProjectedCRS crs = parse(ProjectedCRS.class, wkt);
-        assertNameAndIdentifierEqual("NTF (Paris) / Lambert zone II", 0, crs);
-        verifyProjectedCS(crs.getCoordinateSystem(), SI.KILOMETRE);
-        PrimeMeridian pm = verifyNTF(crs.getDatum(), true);
-        assertEquals("angularUnit", NonSI.GRADE, pm.getAngularUnit());
-        assertEquals("greenwichLongitude", 2.5969213, pm.getGreenwichLongitude(), STRICT);
-        ParameterValue<?> param = verifyNTF(crs.getConversionFromBase().getParameterValues());
-        assertEquals("angularUnit", NonSI.GRADE, param.getUnit());
-        assertEquals("latitude_of_origin",  52.0, param.doubleValue(), STRICT);
+        validateParisFranceII(parse(ProjectedCRS.class, wkt), 0, true);
         /*
          * Parse again using Convention.WKT1_COMMON_UNITS and ignoring AXIS[…] elements.
          * See the comment in 'testGeographicWithParisMeridian' method for a discussion.
@@ -658,18 +650,69 @@ public final strictfp class GeodeticObje
         wkt = wkt.replace("600.0",     "600000");           // Convert unit in “false_easting” parameter.
         wkt = wkt.replace("2200.0",    "2200000");          // Convert unit in “false_northing” parameter.
         newParser(Convention.WKT1_IGNORE_AXES);
-        crs = parse(ProjectedCRS.class, wkt);
+        final ProjectedCRS crs = parse(ProjectedCRS.class, wkt);
         assertNameAndIdentifierEqual("NTF (Paris) / Lambert zone II", 0, crs);
         verifyProjectedCS(crs.getCoordinateSystem(), SI.KILOMETRE);
-        pm = verifyNTF(crs.getDatum(), true);
+        final PrimeMeridian pm = verifyNTF(crs.getDatum(), true);
         assertEquals("angularUnit", NonSI.DEGREE_ANGLE, pm.getAngularUnit());
         assertEquals("greenwichLongitude", 2.33722917, pm.getGreenwichLongitude(), STRICT);
-        param = verifyNTF(crs.getConversionFromBase().getParameterValues());
+        final ParameterValue<?> param = verifyNTF(crs.getConversionFromBase().getParameterValues());
         assertEquals("angularUnit", NonSI.DEGREE_ANGLE, param.getUnit());
         assertEquals("latitude_of_origin",  46.8, param.doubleValue(), STRICT);
     }
 
     /**
+     * Tests the same CRS than {@link #testProjectedWithGradUnits()}, but from a WKT 2 definition
+     * (except for inclusion of accented characters).
+     *
+     * @throws ParseException if the parsing failed.
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-309">SIS-309</a>
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-310">SIS-310</a>
+     */
+    @Test
+    @DependsOnMethod("testProjectedWithGradUnits")
+    public void testProjectedFromWKT2() throws ParseException {
+        String wkt = "ProjectedCRS[“NTF (Paris) / Lambert zone II”,\n" +
+                     "  BaseGeodCRS[“NTF (Paris)”,\n" +
+                     "    Datum[“Nouvelle Triangulation Française (Paris)”,\n" +
+                     "      Ellipsoid[“Clarke 1880 (IGN)”, 6378249.2, 293.4660212936269]],\n" +
+                     "      PrimeMeridian[“Paris”, 2.5969213, Unit[“grade”, 0.015707963267948967], Id[“EPSG”, 8903]],\n" +
+                     "    AngleUnit[“degree”, 0.017453292519943295]],\n" +
+                     "  Conversion[“Lambert zone II”,\n" +
+                     "    Method[“Lambert Conic Conformal (1SP)”],\n" +
+                     "    Parameter[“Latitude of natural origin”, 52.0, AngleUnit[“grade”, 0.015707963267948967]],\n" +
+                     "    Parameter[“Longitude of natural origin”, 0.0],\n" +
+                     "    Parameter[“Scale factor at natural origin”, 0.99987742],\n" +
+                     "    Parameter[“False easting”, 600.0],\n" +
+                     "    Parameter[“False northing”, 2200.0]],\n" +
+                     "  CS[Cartesian, 2],\n" +
+                     "    Axis[“Easting (E)”, east],\n" +
+                     "    Axis[“Northing (N)”, north],\n" +
+                     "    LengthUnit[“km”, 1000],\n" +
+                     "  Scope[“Large and medium scale topographic mapping and engineering survey.”],\n" +
+                     "  Id[“EPSG”, 27572, URI[“urn:ogc:def:crs:EPSG::27572”]]]";
+
+        final ProjectedCRS crs = parse(ProjectedCRS.class, wkt);
+        validateParisFranceII(crs, 27572, false);
+        assertNull("Identifier shall not have a version.", getSingleton(crs.getIdentifiers()).getVersion());
+    }
+
+    /**
+     * Verifies the parameters of a “NTF (Paris) / Lambert zone II” projection.
+     */
+    private static void validateParisFranceII(final ProjectedCRS crs, final int identifier, final boolean hasToWGS84) {
+        assertNameAndIdentifierEqual("NTF (Paris) / Lambert zone II", identifier, crs);
+        verifyProjectedCS(crs.getCoordinateSystem(), SI.KILOMETRE);
+        final PrimeMeridian pm = verifyNTF(crs.getDatum(), hasToWGS84);
+        assertEquals("angularUnit", NonSI.GRADE, pm.getAngularUnit());
+        assertEquals("greenwichLongitude", 2.5969213, pm.getGreenwichLongitude(), STRICT);
+        final ParameterValue<?> param = verifyNTF(crs.getConversionFromBase().getParameterValues());
+        assertEquals("angularUnit", NonSI.GRADE, param.getUnit());
+        assertEquals("latitude_of_origin",  52.0, param.doubleValue(), STRICT);
+    }
+
+    /**
      * Verifies the properties of a datum which is expected to be “Nouvelle Triangulation Française (Paris)”.
      * This is used by the methods in this class which test a CRS using less frequently used units and prime
      * meridian.

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -224,8 +224,8 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.operation.builder.LinearTransformBuilderTest.class,
     org.apache.sis.internal.referencing.ServicesForMetadataTest.class,
     org.apache.sis.test.integration.DatumShiftTest.class,
-    org.apache.sis.test.integration.ReferencingInMetadataTest.class,
-    org.apache.sis.test.integration.DefaultMetadataTest.class
+    org.apache.sis.test.integration.MetadataTest.class,
+    org.apache.sis.test.integration.ConsistencyTest.class
 })
 public final strictfp class ReferencingTestSuite extends TestSuite {
     /**

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -120,6 +120,7 @@ public class MetadataServices extends Op
      * <p>Current keys are:</p>
      * <ul>
      *   <li>{@code "EPSG"}: version of EPSG database.</li>
+     *   <li>{@code "DataSource"}: URL to the data source, or error message.</li>
      * </ul>
      *
      * @param  key A key identifying the information to return.

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -588,8 +588,8 @@ public class TableAppender extends Appen
      * row with the specified character. The subsequent writing operations will occur on a new
      * row.
      *
-     * <p>Calling {@code nextLine('-')} from the first column of a row is a convenient way
-     * to fill this row with a line separator.</p>
+     * <p>Calling {@code nextLine('-')} or {@code nextLine('═')} from the first column of a row
+     * is a convenient way to fill this row with a line separator.</p>
      *
      * @param fill Character filling the rest of the line (default to whitespace).
      *             This character may be use as a row separator.

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -416,19 +416,21 @@ public final class Units extends Static
             if (uom.equals("°")                      || equalsIgnorePlural(uom, "decimal_degree")) return NonSI.DEGREE_ANGLE;
             if (uom.equalsIgnoreCase("arcsec"))                                                    return NonSI.SECOND_ANGLE;
             if (uom.equalsIgnoreCase("rad")          || equalsIgnorePlural(uom, "radian"))         return SI.RADIAN;
-            if (equalsIgnorePlural(uom, "kilometer") || equalsIgnorePlural(uom, "kilometre"))      return SI.KILOMETRE;
             if (equalsIgnorePlural(uom, "meter")     || equalsIgnorePlural(uom, "metre"))          return SI.METRE;
-            if (equalsIgnorePlural(uom, "week"))   return NonSI.WEEK;
-            if (equalsIgnorePlural(uom, "day"))    return NonSI.DAY;
-            if (equalsIgnorePlural(uom, "hour"))   return NonSI.HOUR;
-            if (equalsIgnorePlural(uom, "minute")) return NonSI.MINUTE;
-            if (equalsIgnorePlural(uom, "second")) return SI   .SECOND;
-            if (equalsIgnorePlural(uom, "pixel"))  return NonSI.PIXEL;
-            if (isCelsius(uom))                    return SI.CELSIUS;
-            if (uom.isEmpty())                     return Unit.ONE;
-            if (uom.equalsIgnoreCase("ppm"))       return PPM;
-            if (uom.equalsIgnoreCase("psu"))       return PSU;
-            if (uom.equalsIgnoreCase("sigma"))     return SIGMA;
+            if (equalsIgnorePlural(uom, "kilometer") || equalsIgnorePlural(uom, "kilometre"))      return SI.KILOMETRE;
+            if (equalsIgnorePlural(uom, "week"))        return NonSI.WEEK;
+            if (equalsIgnorePlural(uom, "day"))         return NonSI.DAY;
+            if (equalsIgnorePlural(uom, "hour"))        return NonSI.HOUR;
+            if (equalsIgnorePlural(uom, "minute"))      return NonSI.MINUTE;
+            if (equalsIgnorePlural(uom, "second"))      return SI   .SECOND;
+            if (equalsIgnorePlural(uom, "pixel"))       return NonSI.PIXEL;
+            if (equalsIgnorePlural(uom, "grade"))       return NonSI.GRADE;
+            if (isCelsius(uom))                         return SI.CELSIUS;
+            if (uom.isEmpty())                          return Unit.ONE;
+            if (uom.equalsIgnoreCase("US survey foot")) return NonSI.FOOT_SURVEY_US;
+            if (uom.equalsIgnoreCase("ppm"))            return PPM;
+            if (uom.equalsIgnoreCase("psu"))            return PSU;
+            if (uom.equalsIgnoreCase("sigma"))          return SIGMA;
         }
         final Unit<?> unit;
         try {

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/setup/About.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -368,19 +368,26 @@ fill:   for (int i=0; ; i++) {
                 }
                 case 14: {
                     if (sections.contains(PATHS)) {
+                        nameKey = Vocabulary.Keys.DataBase;
+                        value = MetadataServices.getInstance().getInformation("DataSource", locale);
+                    }
+                    break;
+                }
+                case 15: {
+                    if (sections.contains(PATHS)) {
                         nameKey = Vocabulary.Keys.TemporaryFiles;
                         value = getProperty("java.io.tmpdir");
                     }
                     break;
                 }
-                case 15: {
+                case 16: {
                     if (sections.contains(PATHS)) {
                         nameKey = Vocabulary.Keys.JavaHome;
                         value = javaHome = getProperty("java.home");
                     }
                     break;
                 }
-                case 16: {
+                case 17: {
                     newSection = LIBRARIES;
                     if (sections.contains(LIBRARIES)) {
                         nameKey = Vocabulary.Keys.JavaExtensions;
@@ -388,7 +395,7 @@ fill:   for (int i=0; ; i++) {
                     }
                     break;
                 }
-                case 17: {
+                case 18: {
                     if (sections.contains(LIBRARIES)) {
                         nameKey = Vocabulary.Keys.Classpath;
                         value = classpath(getProperty("java.class.path"), false);

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Version.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Version.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Version.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Version.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -63,8 +63,8 @@ public class Version implements CharSequ
     public static final Version SIS = new Version(MAJOR_VERSION + "." + MINOR_VERSION + "-SNAPSHOT");
 
     /**
-     * A few commonly used version numbers. This list is based on SIS needs, e.g. in {@code DataStore}
-     * implementations. New constants are likely to be added in any future SIS versions.
+     * A few commonly used version numbers. This list is based on SIS needs, e.g. in {@code DataStore} implementations.
+     * New constants are likely to be added in any future SIS versions.
      *
      * @see #valueOf(int[])
      */
@@ -127,7 +127,7 @@ public class Version implements CharSequ
         final int major = components[0];
         if (components.length == 1) {
             if (major >= 1 && major <= CONSTANTS.length) {
-                return CONSTANTS[major-1];
+                return CONSTANTS[major - 1];
             } else {
                 version = new Version(Integer.toString(major));
             }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -151,6 +151,11 @@ public final class Vocabulary extends In
         public static final short CycleOmitted = 12;
 
         /**
+         * Database
+         */
+        public static final short DataBase = 96;
+
+        /**
          * Data directory
          */
         public static final short DataDirectory = 88;

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties [ISO-8859-1] Wed Feb 24 22:38:53 2016
@@ -33,6 +33,7 @@ Correlation             = Correlation
 CurrentDateTime         = Current date and time
 CurrentDirectory        = Current directory
 CycleOmitted            = Cycle omitted
+DataBase                = Database
 DataDirectory           = Data directory
 DaylightTime            = Daylight time
 DefaultValue            = Default value

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties [ISO-8859-1] Wed Feb 24 22:38:53 2016
@@ -40,6 +40,7 @@ Correlation             = Corr\u00e9lati
 CurrentDateTime         = Date et heure courantes
 CurrentDirectory        = R\u00e9pertoire courant
 CycleOmitted            = Cycle omit
+DataBase                = Base de donn\u00e9es
 DataDirectory           = R\u00e9pertoire des donn\u00e9es
 DaylightTime            = Heure normale
 DefaultValue            = Valeur par d\u00e9faut

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/MimeTypeDetector.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -273,7 +273,7 @@ abstract class MimeTypeDetector {
             if (insufficientBytes) {
                 return ProbeResult.INSUFFICIENT_BYTES;
             }
-            mimeType = XMLStoreProvider.MIME_TYPE;
+            mimeType = StoreProvider.MIME_TYPE;
         }
         return new ProbeResult(true, mimeType, null);
     }

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/package-info.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/package-info.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/package-info.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -18,11 +18,11 @@
 /**
  * {@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.internal.storage.xml.XMLStore} class.
+ * {@link org.apache.sis.internal.storage.xml.Store} class.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.7
  * @module
  */
 package org.apache.sis.internal.storage.xml;

Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -369,6 +369,11 @@ public class StorageConnector implements
         if (views != null) {
             final Object view = views.get(type);
             if (view != null) {
+                if (view == storage && view instanceof InputStream) try {
+                    resetInputStream();
+                } catch (IOException e) {
+                    throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, getStorageName()), e);
+                }
                 return (view != Void.TYPE) ? type.cast(view) : null;
             }
         } else {
@@ -388,7 +393,7 @@ public class StorageConnector implements
             } else if (type == DataInput.class) {
                 createDataInput();
                 done = true;
-            } else if (type == ChannelDataInput.class) { // Undocumented case (SIS internal)
+            } else if (type == ChannelDataInput.class) {                // Undocumented case (SIS internal)
                 createChannelDataInput(false);
                 done = true;
             }
@@ -416,6 +421,19 @@ public class StorageConnector implements
     }
 
     /**
+     * Assuming that {@link #storage} is an instance of {@link InputStream}, resets its position. This method
+     * is the converse of the marks performed at the beginning of {@link #createChannelDataInput(boolean)}.
+     */
+    private void resetInputStream() throws IOException {
+        final ChannelDataInput channel = getView(ChannelDataInput.class);
+        if (channel != null) {
+            ((InputStream) storage).reset();        // May throw an exception if mark is unsupported.
+            channel.buffer.limit(0);                // Must be after storage.reset().
+            channel.setStreamPosition(0);           // Must be after buffer.limit(0).
+        }
+    }
+
+    /**
      * 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.
      *
@@ -423,8 +441,22 @@ public class StorageConnector implements
      * @throws IOException If an error occurred while opening a channel for the input.
      */
     private void createChannelDataInput(final boolean asImageInputStream) throws IOException {
+        /*
+         * Before to try to open an InputStream, mark its position so we can rewind if the user asks for
+         * the InputStream directly. We need to reset because ChannelDataInput may have read some bytes.
+         * Note that if mark is unsupported, the default InputStream.mark() implementation does nothing.
+         * See above 'resetInputStream()' method.
+         */
+        if (storage instanceof InputStream) {
+            ((InputStream) storage).mark(DEFAULT_BUFFER_SIZE);
+        }
+        /*
+         * Following method call recognizes ReadableByteChannel, InputStream (with special case for FileInputStream),
+         * URL, URI, File, Path or other types that may be added in future SIS versions.
+         */
         final ReadableByteChannel channel = IOUtilities.open(storage,
                 getOption(OptionKey.URL_ENCODING), getOption(OptionKey.OPEN_OPTIONS));
+
         ChannelDataInput asDataInput = null;
         if (channel != null) {
             addViewToClose(channel, storage);
@@ -475,7 +507,7 @@ public class StorageConnector implements
                 // No call to 'addViewToClose' because the instance already exists.
             } else {
                 asDataInput = new ChannelImageInputStream(c);
-                if (views.put(ChannelDataInput.class, asDataInput) != c) { // Replace the previous instance.
+                if (views.put(ChannelDataInput.class, asDataInput) != c) {          // Replace the previous instance.
                     throw new ConcurrentModificationException();
                 }
                 addViewToClose(asDataInput, c.channel);
@@ -595,13 +627,19 @@ public class StorageConnector implements
             final DataInput input = getStorageAs(DataInput.class);
             return (input instanceof ImageInputStream) ? input : null;
         }
+        /*
+         * If the user asked an InputStream, we may return the storage as-is if it was already an InputStream.
+         * However before doing so, we may need to reset the InputStream position if the stream has been used
+         * by a ChannelDataInput.
+         */
         if (type == InputStream.class) {
             if (storage instanceof InputStream) {
+                resetInputStream();
                 return storage;
             }
             final DataInput input = getStorageAs(DataInput.class);
             if (input instanceof InputStream) {
-                return (InputStream) input;
+                return input;
             }
             if (input instanceof ImageInputStream) {
                 final InputStream c = new InputStreamAdapter((ImageInputStream) input);

Modified: sis/branches/JDK7/storage/sis-storage/src/main/resources/META-INF/services/org.apache.sis.storage.DataStoreProvider
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/resources/META-INF/services/org.apache.sis.storage.DataStoreProvider?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/resources/META-INF/services/org.apache.sis.storage.DataStoreProvider [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/resources/META-INF/services/org.apache.sis.storage.DataStoreProvider [UTF-8] Wed Feb 24 22:38:53 2016
@@ -1 +1,2 @@
-org.apache.sis.internal.storage.xml.XMLStoreProvider
+org.apache.sis.internal.storage.xml.StoreProvider
+org.apache.sis.internal.storage.wkt.StoreProvider

Modified: sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/MimeTypeDetectorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/MimeTypeDetectorTest.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/MimeTypeDetectorTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/MimeTypeDetectorTest.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -44,7 +44,7 @@ public final strictfp class MimeTypeDete
      */
     @Test
     public void testGMDFromString() throws IOException {
-        final StringReader in = new StringReader(XMLStoreTest.XML);
+        final StringReader in = new StringReader(StoreTest.XML);
         assertEquals('<', in.read());
         assertEquals('?', in.read());
         final MimeTypeDetector detector = new MimeTypeDetector() {

Modified: sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoresTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoresTest.java?rev=1732233&r1=1732232&r2=1732233&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoresTest.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoresTest.java [UTF-8] Wed Feb 24 22:38:53 2016
@@ -17,7 +17,7 @@
 package org.apache.sis.storage;
 
 import java.io.StringReader;
-import org.apache.sis.internal.storage.xml.XMLStoreTest;
+import org.apache.sis.internal.storage.xml.StoreTest;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
@@ -30,10 +30,10 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.7
  * @module
  */
-@DependsOn(XMLStoreTest.class)
+@DependsOn(StoreTest.class)
 public final strictfp class DataStoresTest extends TestCase {
     /**
      * Tests {@link DataStores#probeContentType(Object)}.
@@ -42,7 +42,7 @@ public final strictfp class DataStoresTe
      */
     @Test
     public void testProbeContentType() throws DataStoreException {
-        final String type = DataStores.probeContentType(new StringReader(XMLStoreTest.XML));
+        final String type = DataStores.probeContentType(new StringReader(StoreTest.XML));
         assertEquals("application/vnd.iso.19139+xml", type);
     }
 
@@ -53,7 +53,7 @@ public final strictfp class DataStoresTe
      */
     @Test
     public void testOpen() throws DataStoreException {
-        final DataStore store = DataStores.open(new StringReader(XMLStoreTest.XML));
+        final DataStore store = DataStores.open(new StringReader(StoreTest.XML));
         assertFalse(store.getMetadata().getContacts().isEmpty());
     }
 }




Mime
View raw message