sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1781503 [1/3] - in /sis/trunk: ./ application/sis-console/ application/sis-console/src/main/java/org/apache/sis/console/ application/sis-console/src/test/java/org/apache/sis/console/ core/sis-metadata/src/main/java/org/apache/sis/internal/...
Date Fri, 03 Feb 2017 08:01:03 GMT
Author: desruisseaux
Date: Fri Feb  3 08:01:02 2017
New Revision: 1781503

URL: http://svn.apache.org/viewvc?rev=1781503&view=rev
Log:
Merge from the JDK7 branch. Include formatting of XML output and addition of CoordinateFormat.

Added:
    sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/FormattedOutputCommand.java
      - copied unchanged from r1781502, sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/FormattedOutputCommand.java
    sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/OutputFormat.java
      - copied unchanged from r1781502, sis/branches/JDK7/application/sis-console/src/main/java/org/apache/sis/console/OutputFormat.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/CoordinateFormat.java
      - copied unchanged from r1781502, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/CoordinateFormat.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/geometry/CoordinateFormatTest.java
      - copied unchanged from r1781502, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/CoordinateFormatTest.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/Implementation.java
      - copied unchanged from r1781502, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Implementation.java
    sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/FormattedWriter.java
      - copied unchanged from r1781502, sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/FormattedWriter.java
Modified:
    sis/trunk/   (props changed)
    sis/trunk/application/sis-console/pom.xml
    sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/AboutCommand.java
    sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CRSCommand.java
    sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java
    sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CommandRunner.java
    sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/HelpCommand.java
    sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java
    sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java
    sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeCommand.java
    sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java
    sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/package-info.java
    sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/HelpCommandTest.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataTypes.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
    sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
    sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultProcessStepTest.java
    sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/lineage/ProcessStep.xml
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
    sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java
    sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Constants.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/StreamWriterDelegate.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/XPaths.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/DefaultFormat.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Latitude.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/LinearConverter.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Longitude.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/package-info.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Version.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/MarshallerPool.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/PooledTemplate.java
    sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/XPathsTest.java
    sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java
    sis/trunk/profiles/sis-french-profile/src/main/java/org/apache/sis/internal/profile/fra/ProfileTypes.java
    sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.java
    sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources.properties
    sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Resources_fr.properties
    sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureStore.java
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreProvider.java
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java
    sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStores.java
    sis/trunk/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/csv/StoreTest.java
    sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Metadata.java
    sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Reader.java
    sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java
    sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/StoreProvider.java
    sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Writer.java
    sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java
    sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamWriter.java
    sis/trunk/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java
    sis/trunk/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/WriterTest.java

Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb  3 08:01:02 2017
@@ -1,5 +1,5 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394364-1758914
-/sis/branches/JDK7:1394913-1779817
-/sis/branches/JDK8:1584960-1779788
+/sis/branches/JDK7:1394913-1781502
+/sis/branches/JDK8:1584960-1781501
 /sis/branches/JDK9:1773327-1773512

Modified: sis/trunk/application/sis-console/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/pom.xml?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/application/sis-console/pom.xml (original)
+++ sis/trunk/application/sis-console/pom.xml Fri Feb  3 08:01:02 2017
@@ -109,7 +109,7 @@ Console application.
       <groupId>org.apache.sis.storage</groupId>
       <artifactId>sis-xmlstore</artifactId>
       <version>${project.version}</version>
-      <scope>runtime</scope>
+      <scope>compile</scope>  <!-- Should be runtime after the hack in FormattedOutputCommand has been fixed. -->
     </dependency>
     <dependency>
       <groupId>org.apache.sis.storage</groupId>

Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/AboutCommand.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/AboutCommand.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/AboutCommand.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/AboutCommand.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -59,20 +59,27 @@ import org.apache.sis.internal.util.X364
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.7
+ * @version 0.8
  * @module
  */
 final class AboutCommand extends CommandRunner {
     /**
      * Creates the {@code "about"} sub-command.
+     *
+     * @param  commandIndex  index of the {@code arguments} element containing the {@code "about"} command name, or -1 if none.
+     * @param  arguments     the command-line arguments provided by the user.
+     * @throws InvalidOptionException if an illegal option has been provided, or the option has an illegal value.
      */
-    AboutCommand(final int commandIndex, final String... args) throws InvalidOptionException {
-        super(commandIndex, args, EnumSet.of(Option.LOCALE, Option.TIMEZONE, Option.ENCODING,
+    AboutCommand(final int commandIndex, final String... arguments) throws InvalidOptionException {
+        super(commandIndex, arguments, EnumSet.of(Option.LOCALE, Option.TIMEZONE, Option.ENCODING,
                 Option.BRIEF, Option.VERBOSE, Option.HELP, Option.DEBUG));
     }
 
     /**
      * Prints the information to the output stream.
+     *
+     * @return 0 on success, or an exit code if the command failed for a reason other than an uncaught Java exception.
+     * @throws Exception if an error occurred while executing the sub-command.
      */
     @Override
     public int run() throws Exception {

Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CRSCommand.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CRSCommand.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CRSCommand.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CRSCommand.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -16,14 +16,9 @@
  */
 package org.apache.sis.console;
 
-import java.io.IOException;
-import javax.xml.bind.JAXBException;
 import org.opengis.metadata.Metadata;
-import org.opengis.util.FactoryException;
 import org.opengis.referencing.ReferenceSystem;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.io.wkt.Convention;
 
 
 /**
@@ -32,32 +27,24 @@ import org.apache.sis.io.wkt.Convention;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.7
+ * @version 0.8
  * @module
  */
-final class CRSCommand extends MetadataCommand {
+final class CRSCommand extends FormattedOutputCommand {
     /**
      * Creates the {@code "crs"} sub-command.
      */
     CRSCommand(final int commandIndex, final String... args) throws InvalidOptionException {
-        super(commandIndex, args);
-
-        // Default output format.
-        outputFormat = Format.WKT;
-        convention = Convention.WKT2_SIMPLIFIED;
+        super(commandIndex, args, MetadataCommand.options(), OutputFormat.WKT, OutputFormat.XML);
     }
 
     /**
      * Prints metadata or CRS information.
      *
-     * @throws DataStoreException if an error occurred while reading the file.
-     * @throws JAXBException if an error occurred while producing the XML output.
-     * @throws FactoryException if an error occurred while looking for a CRS identifier.
-     * @throws IOException should never happen, since we are appending to a print writer.
+     * @return 0 on success, or an exit code if the command failed for a reason other than an uncaught Java exception.
      */
     @Override
-    public int run() throws InvalidOptionException, DataStoreException, JAXBException, FactoryException, IOException {
-        parseArguments();
+    public int run() throws Exception {
         final Object metadata = readMetadataOrCRS();
         if (hasUnexpectedFileCount) {
             return Command.INVALID_ARGUMENT_EXIT_CODE;

Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -71,7 +71,7 @@ import org.apache.sis.util.logging.Monol
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.7
+ * @version 0.8
  * @module
  */
 public final class Command {
@@ -115,11 +115,6 @@ public final class Command {
     public static final int OTHER_ERROR_EXIT_CODE = 199;
 
     /**
-     * The sub-command name.
-     */
-    private final String commandName;
-
-    /**
      * The sub-command to execute.
      */
     private final CommandRunner command;
@@ -153,8 +148,7 @@ public final class Command {
         if (commandName == null) {
             command = new HelpCommand(-1, args);
         } else {
-            commandName = commandName.toLowerCase(Locale.US);
-            switch (commandName) {
+            switch (commandName.toLowerCase(Locale.US)) {
                 case "help":       command = new HelpCommand      (commandIndex, args); break;
                 case "about":      command = new AboutCommand     (commandIndex, args); break;
                 case "mime-type":  command = new MimeTypeCommand  (commandIndex, args); break;
@@ -166,7 +160,6 @@ public final class Command {
                             Errors.Keys.UnknownCommand_1, commandName), commandName);
             }
         }
-        this.commandName = commandName;
         CommandRunner.instance = command;       // For ResourcesDownloader only.
     }
 
@@ -184,7 +177,7 @@ public final class Command {
             return INVALID_OPTION_EXIT_CODE;
         }
         if (command.options.containsKey(Option.HELP)) {
-            command.help(commandName);
+            command.help(command.commandName.toLowerCase(Locale.US));
         } else try {
             return command.run();
         } catch (Exception e) {

Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CommandRunner.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CommandRunner.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CommandRunner.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/CommandRunner.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -23,6 +23,7 @@ import java.util.EnumSet;
 import java.util.EnumMap;
 import java.util.TimeZone;
 import java.io.Console;
+import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.io.OutputStreamWriter;
@@ -34,11 +35,13 @@ import org.apache.sis.internal.util.X364
 
 
 /**
- * Base class of sub-commands.
+ * Base class of all sub-commands.
+ * A subclasses is initialized by the {@link Command} constructor,
+ * then the {@link #run()} method is invoked by {@link Command#run()}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.7
+ * @version 0.8
  * @module
  */
 abstract class CommandRunner {
@@ -58,6 +61,12 @@ abstract class CommandRunner {
     static CommandRunner instance;
 
     /**
+     * The name of this command, as specified by the user on the command-line.
+     * May contain a mix of lower-case and upper-case letters if the user specified the command that way.
+     */
+    protected final String commandName;
+
+    /**
      * The set of legal options for this command.
      *
      * @see #help(String)
@@ -70,8 +79,8 @@ abstract class CommandRunner {
     protected final EnumMap<Option,String> options;
 
     /**
-     * The locale specified by the {@code "--locale"} option. If no such option was
-     * provided, then this field is set to the {@linkplain Locale#getDefault() default locale}.
+     * The locale specified by the {@code "--locale"} option. If no such option was provided,
+     * then this field is set to the {@linkplain Locale#getDefault() default locale}.
      */
     protected final Locale locale;
 
@@ -130,6 +139,7 @@ abstract class CommandRunner {
      * only when a command needs to delegates part of its work to an other command.
      */
     CommandRunner(final CommandRunner parent) {
+        this.commandName  = parent.commandName;
         this.validOptions = parent.validOptions;
         this.options      = parent.options;
         this.locale       = parent.locale;
@@ -149,7 +159,7 @@ abstract class CommandRunner {
      * The argument at index {@code commandIndex} is the name of this command, and will be ignored except for
      * the special {@value #TEST} value which is used only at JUnit testing time.
      *
-     * @param  commandIndex  index of the {@code args} element containing the sub-command name.
+     * @param  commandIndex  index of the {@code arguments} element containing the sub-command name, or -1 if none.
      * @param  arguments     the command-line arguments provided by the user.
      * @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.
@@ -158,16 +168,15 @@ abstract class CommandRunner {
     protected CommandRunner(final int commandIndex, final String[] arguments, final EnumSet<Option> validOptions)
             throws InvalidOptionException
     {
-        boolean isTest = false;
+        commandName = (commandIndex >= 0) ? arguments[commandIndex] : null;
         this.validOptions = validOptions;
         options = new EnumMap<>(Option.class);
         files = new ArrayList<>(arguments.length);
-        for (int i=0; i<arguments.length; i++) {
-            final String arg = arguments[i];
+        for (int i=0; i < arguments.length; i++) {
             if (i == commandIndex) {
-                isTest = arg.equals(TEST);
                 continue;
             }
+            final String arg = arguments[i];
             if (arg.startsWith(Option.PREFIX)) {
                 final String name = arg.substring(Option.PREFIX.length());
                 final Option option = Option.forLabel(name);
@@ -222,7 +231,7 @@ abstract class CommandRunner {
          * output to a StringBuffer. Otherwise the output will be sent to the java.io.Console if possible,
          * or to the standard output stream otherwise.
          */
-        if (isTest) {
+        if (TEST.equals(commandName)) {
             final StringWriter s = new StringWriter();
             outputBuffer = s.getBuffer();
             out = new PrintWriter(s);
@@ -322,19 +331,22 @@ abstract class CommandRunner {
     }
 
     /**
-     * Shows the help instructions for a specific command. This method is invoked
-     * instead of {@link #run()} if the the user provided the {@code --help} option.
+     * Shows the help instructions for a specific command. This method is invoked instead of {@link #run()}
+     * if the the user provided the {@code --help} option. The default implementation builds a description
+     * from the texts associated to the given {@code resourceKey} in various resource bundles provided in
+     * this {@code sis-console} module. Subclasses can override if needed.
      *
-     * @param commandName  the command name converted to lower cases.
+     * @param  resourceKey  the key for the resource to print. This is usually {@link #commandName} in lower-cases.
+     * @throws IOException should never happen, because we are writing to a {@code PrintWriter}.
      */
-    protected void help(final String commandName) {
-        new HelpCommand(this).help(false, new String[] {commandName}, validOptions);
+    protected void help(final String resourceKey) throws IOException {
+        new HelpCommand(this).help(false, new String[] {resourceKey}, validOptions);
     }
 
     /**
      * Executes the sub-command.
      *
-     * @return 0 on success, or an exit code if the command failed for a reason other than a Java exception.
+     * @return 0 on success, or an exit code if the command failed for a reason other than an uncaught Java exception.
      * @throws Exception if an error occurred while executing the sub-command.
      */
     public abstract int run() throws Exception;

Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/HelpCommand.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/HelpCommand.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/HelpCommand.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/HelpCommand.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -28,7 +28,7 @@ import org.apache.sis.util.resources.Voc
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.7
+ * @version 0.8
  * @module
  */
 final class HelpCommand extends CommandRunner {
@@ -46,8 +46,8 @@ final class HelpCommand extends CommandR
     };
 
     /**
-     * Copies the configuration of the given sub-command. This constructor is used
-     * for printing help about an other command.
+     * Copies the configuration of the given sub-command.
+     * This constructor is used for printing help about another command.
      */
     HelpCommand(final CommandRunner parent) {
         super(parent);
@@ -55,16 +55,23 @@ final class HelpCommand extends CommandR
 
     /**
      * Creates the {@code "help"} sub-command.
+     *
+     * @param  commandIndex  index of the {@code arguments} element containing the {@code "help"} command name, or -1 if none.
+     * @param  arguments     the command-line arguments provided by the user.
+     * @throws InvalidOptionException if an illegal option has been provided, or the option has an illegal value.
      */
-    HelpCommand(final int commandIndex, final String... args) throws InvalidOptionException {
-        super(commandIndex, args, EnumSet.of(Option.LOCALE, Option.ENCODING, Option.HELP, Option.DEBUG));
+    HelpCommand(final int commandIndex, final String... arguments) throws InvalidOptionException {
+        super(commandIndex, arguments, EnumSet.of(Option.LOCALE, Option.ENCODING, Option.HELP, Option.DEBUG));
     }
 
     /**
      * Prints the help instructions.
+     *
+     * @return 0 on success, or an exit code if the command failed for a reason other than a Java exception.
+     * @throws IOException should never happen, because we are writing to a {@code PrintWriter}.
      */
     @Override
-    public int run() {
+    public int run() throws IOException {
         if (hasUnexpectedFileCount(0, 0)) {
             return Command.INVALID_ARGUMENT_EXIT_CODE;
         }
@@ -78,8 +85,9 @@ final class HelpCommand extends CommandR
      * @param  showHeader    {@code true} for printing the "Apache SIS" header.
      * @param  commandNames  the names of the commands to list.
      * @param  validOptions  the options to list.
+     * @throws IOException should never happen, because we are writing to a {@code PrintWriter}.
      */
-    void help(final boolean showHeader, final String[] commandNames, final EnumSet<Option> validOptions) {
+    void help(final boolean showHeader, final String[] commandNames, final EnumSet<Option> validOptions) throws IOException {
         final ResourceBundle commands = ResourceBundle.getBundle("org.apache.sis.console.Commands", locale);
         final ResourceBundle options  = ResourceBundle.getBundle("org.apache.sis.console.Options",  locale);
         final Vocabulary vocabulary = Vocabulary.getResources(locale);
@@ -91,34 +99,30 @@ final class HelpCommand extends CommandR
             out.print(vocabulary.getString(Vocabulary.Keys.Commands));
             out.println(':');
         }
-        try {
-            final TableAppender table = new TableAppender(out, "  ");
-            for (final String command : commandNames) {
-                if (showHeader) {
-                    table.append("  ");
-                }
-                table.append(command);
-                if (!showHeader) {
-                    table.append(':');
-                }
-                table.nextColumn();
-                table.append(commands.getString(command));
-                table.nextLine();
+        final TableAppender table = new TableAppender(out, "  ");
+        for (final String command : commandNames) {
+            if (showHeader) {
+                table.append("  ");
             }
-            table.flush();
-            out.println();
-            out.print(vocabulary.getString(Vocabulary.Keys.Options));
-            out.println(':');
-            for (final Option option : validOptions) {
-                final String name = option.label();
-                table.append("  ").append(Option.PREFIX).append(name);
-                table.nextColumn();
-                table.append(options.getString(name));
-                table.nextLine();
+            table.append(command);
+            if (!showHeader) {
+                table.append(':');
             }
-            table.flush();
-        } catch (IOException e) {
-            throw new AssertionError(e);            // Should never happen, because we are writing to a PrintWriter.
+            table.nextColumn();
+            table.append(commands.getString(command));
+            table.nextLine();
+        }
+        table.flush();
+        out.println();
+        out.print(vocabulary.getString(Vocabulary.Keys.Options));
+        out.println(':');
+        for (final Option option : validOptions) {
+            final String name = option.label();
+            table.append("  ").append(Option.PREFIX).append(name);
+            table.nextColumn();
+            table.append(options.getString(name));
+            table.nextLine();
         }
+        table.flush();
     }
 }

Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/IdentifierCommand.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -22,8 +22,6 @@ import java.util.Set;
 import java.util.EnumSet;
 import java.util.Collections;
 import java.util.ResourceBundle;
-import java.io.IOException;
-import javax.xml.bind.JAXBException;
 import org.opengis.metadata.Metadata;
 import org.opengis.metadata.Identifier;
 import org.opengis.referencing.NoSuchAuthorityCodeException;
@@ -32,10 +30,9 @@ import org.opengis.referencing.Reference
 import org.apache.sis.internal.util.X364;
 import org.apache.sis.referencing.CRS;
 import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.ComparisonMode;
-import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.Workaround;
 import org.apache.sis.util.resources.Vocabulary;
 
 // Branch-dependent imports
@@ -48,10 +45,10 @@ import org.apache.sis.metadata.iso.Defau
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.7
+ * @version 0.8
  * @module
  */
-final class IdentifierCommand extends MetadataCommand {
+final class IdentifierCommand extends FormattedOutputCommand {
     /**
      * The state to write in the left margin before the identifier.
      *
@@ -95,27 +92,31 @@ final class IdentifierCommand extends Me
     }
 
     /**
+     * Work around for RFE #4093999 in Sun's bug database
+     * ("Relax constraint on placement of this()/super() call in constructors").
+     */
+    @Workaround(library="JDK", version="1.7")
+    private static EnumSet<Option> options() {
+        final EnumSet<Option> options = MetadataCommand.options();
+        options.remove(Option.TIMEZONE);
+        options.remove(Option.FORMAT);
+        return options;
+    }
+
+    /**
      * Creates the {@code "identifier"} sub-command.
      */
     IdentifierCommand(final int commandIndex, final String... args) throws InvalidOptionException {
-        super(commandIndex, args);
+        super(commandIndex, args, options(), OutputFormat.TEXT);
     }
 
     /**
      * Prints identifier information.
      *
-     * @throws DataStoreException if an error occurred while reading the file.
-     * @throws JAXBException if an error occurred while producing the XML output.
-     * @throws FactoryException if an error occurred while looking for a CRS identifier.
-     * @throws IOException should never happen, since we are appending to a print writer.
+     * @return 0 on success, or an exit code if the command failed for a reason other than an uncaught Java exception.
      */
     @Override
-    public int run() throws InvalidOptionException, DataStoreException, JAXBException, FactoryException, IOException {
-        parseArguments();
-        if (outputFormat != Format.TEXT) {
-            final String format = outputFormat.name();
-            throw new InvalidOptionException(Errors.format(Errors.Keys.IncompatibleFormat_2, "identifier", format), format);
-        }
+    public int run() throws Exception {
         /*
          * Read metadata from the data storage only after we verified that the arguments are valid.
          * The input can be a file given on the command line, or the standard input stream.

Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataCommand.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -18,156 +18,46 @@ package org.apache.sis.console;
 
 import java.util.Collections;
 import java.util.EnumSet;
-import java.io.Console;
-import java.io.IOException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.JAXBException;
 import org.opengis.metadata.Metadata;
 import org.opengis.referencing.ReferenceSystem;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.util.FactoryException;
-import org.apache.sis.io.wkt.WKTFormat;
-import org.apache.sis.io.wkt.Convention;
-import org.apache.sis.io.wkt.Colors;
-import org.apache.sis.metadata.MetadataStandard;
-import org.apache.sis.metadata.ValueExistencePolicy;
 import org.apache.sis.metadata.iso.DefaultMetadata;
-import org.apache.sis.referencing.CRS;
-import org.apache.sis.storage.DataStore;
-import org.apache.sis.storage.DataStores;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.internal.storage.CodeType;
-import org.apache.sis.util.collection.TableColumn;
-import org.apache.sis.util.collection.TreeTable;
-import org.apache.sis.util.collection.TreeTableFormat;
-import org.apache.sis.util.resources.Errors;
-import org.apache.sis.xml.MarshallerPool;
-import org.apache.sis.xml.XML;
 
 
 /**
- * The "metadata" sub-command. This class is also used as the base class of other sub-commands
- * that perform most of their work on the basis of metadata information.
+ * The "metadata" sub-command.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
  * @version 0.8
  * @module
  */
-class MetadataCommand extends CommandRunner {
+final class MetadataCommand extends FormattedOutputCommand {
     /**
-     * The output format.
+     * Returns valid options for the {@code "metadata"} command.
      */
-    static enum Format {
-        TEXT, WKT, XML
+    static EnumSet<Option> options() {
+        return EnumSet.of(Option.FORMAT, Option.LOCALE, Option.TIMEZONE,
+                Option.ENCODING, Option.COLORS, Option.HELP, Option.DEBUG);
     }
 
     /**
-     * The output format. Default value can be overridden by {@link #parseArguments()}.
-     */
-    Format outputFormat = Format.TEXT;
-
-    /**
-     * The WKT convention, or {@code null} if it does not apply.
-     */
-    Convention convention;
-
-    /**
-     * Sets to {@code true} by {@link #readMetadata()} if the users provided an unexpected number of file arguments.
-     * In such case, the {@link #run()} should terminate with exit code {@link Command#INVALID_ARGUMENT_EXIT_CODE}.
-     */
-    boolean hasUnexpectedFileCount;
-
-    /**
      * Creates the {@code "metadata"} sub-command.
-     */
-    MetadataCommand(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.DEBUG));
-    }
-
-    /**
-     * Creates a new sub-command with the given command-line arguments.
-     * This constructor is for {@code MetadataCommand} subclasses only.
      *
-     * @param  commandIndex  index of the {@code args} element containing the sub-command name.
+     * @param  commandIndex  index of the {@code arguments} element containing the {@code "metadata"} command name, or -1 if none.
      * @param  arguments     the command-line arguments provided by the user.
-     * @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.
      */
-    MetadataCommand(final int commandIndex, final String[] args, final EnumSet<Option> validOptions)
-            throws InvalidOptionException
-    {
-        super(commandIndex, args, validOptions);
-    }
-
-    /**
-     * Parses the command-line arguments and initializes the {@link #outputFormat} and {@link #convention} fields
-     * accordingly.
-     */
-    final void parseArguments() throws InvalidOptionException {
-        /*
-         * Output format can be either "text" (the default) or "xml".
-         * In the case of "crs" sub-command, we accept also WKT variants.
-         */
-        final String format = options.get(Option.FORMAT);
-        if (format != null && !format.equalsIgnoreCase("text")) {
-            if (format.equalsIgnoreCase("wkt") || format.equalsIgnoreCase("wkt2")) {
-                outputFormat = Format.WKT;
-                convention = Convention.WKT2;
-            } else if (format.equalsIgnoreCase("wkt1")) {
-                outputFormat = Format.WKT;
-                convention = Convention.WKT1;
-            } else if (format.equalsIgnoreCase("xml")) {
-                outputFormat = Format.XML;
-            } else {
-                throw new InvalidOptionException(Errors.format(
-                        Errors.Keys.IllegalOptionValue_2, "format", format), format);
-            }
-        }
-    }
-
-    /**
-     * If the given argument seems to be an authority code ("URN", "EPSG", "CRS", "AUTO", <i>etc.</i>),
-     * delegates to {@link CRS#forCode(String)}. Otherwise reads the metadata using a datastore.
-     *
-     * @return a {@link Metadata} or {@link CoordinateReferenceSystem} instance, or {@code null} if none.
-     */
-    final Object readMetadataOrCRS() throws DataStoreException, FactoryException {
-        if (useStandardInput()) {
-            try (DataStore store = DataStores.open(System.in)) {
-                return store.getMetadata();
-            }
-        } else if (hasUnexpectedFileCount(1, 1)) {
-            hasUnexpectedFileCount = true;
-            return null;
-        } else {
-            final String file = files.get(0);
-            if (CodeType.guess(file).isCRS) {
-                return CRS.forCode(file);
-            } else {
-                try (DataStore store = DataStores.open(file)) {
-                    return store.getMetadata();
-                }
-            }
-        }
+    MetadataCommand(final int commandIndex, final String... arguments) throws InvalidOptionException {
+        super(commandIndex, arguments, options(), OutputFormat.TEXT, OutputFormat.XML, OutputFormat.GPX);
     }
 
     /**
      * Prints metadata or CRS information.
      *
-     * @throws DataStoreException if an error occurred while reading the file.
-     * @throws JAXBException if an error occurred while producing the XML output.
-     * @throws FactoryException if an error occurred while looking for a CRS identifier.
-     * @throws IOException should never happen, since we are appending to a print writer.
+     * @return 0 on success, or an exit code if the command failed for a reason other than an uncaught Java exception.
      */
     @Override
     public int run() throws Exception {
-        parseArguments();
-        if (convention != null) {
-            final String format = outputFormat.name();
-            throw new InvalidOptionException(Errors.format(Errors.Keys.IncompatibleFormat_2, "metadata", format), format);
-        }
         /*
          * Read metadata from the data storage only after we verified that the arguments are valid.
          * The input can be a file given on the command line, or the standard input stream.
@@ -186,65 +76,4 @@ class MetadataCommand extends CommandRun
         }
         return 0;
     }
-
-    /**
-     * Format the given metadata or CRS object to the standard output stream.
-     * The format is determined by {@link #outputFormat} and (in WKT case only) {@link #convention}.
-     */
-    @SuppressWarnings("UseOfSystemOutOrSystemErr")
-    final void format(final Object object) throws IOException, JAXBException {
-        switch (outputFormat) {
-            case TEXT: {
-                final TreeTable tree = MetadataStandard.ISO_19115.asTreeTable(object,
-                        (object instanceof Metadata) ? Metadata.class : null,
-                        ValueExistencePolicy.NON_EMPTY);
-                final TreeTableFormat tf = new TreeTableFormat(locale, timezone);
-                tf.setColumns(TableColumn.NAME, TableColumn.VALUE);
-                tf.format(tree, out);
-                break;
-            }
-
-            case WKT: {
-                final WKTFormat f = new WKTFormat(locale, timezone);
-                if (convention != null) {
-                    f.setConvention(convention);
-                }
-                if (colors) {
-                    f.setColors(Colors.DEFAULT);
-                }
-                f.format(object, out);
-                out.println();
-                break;
-            }
-
-            case XML: {
-                final MarshallerPool pool = new MarshallerPool(null);
-                final Marshaller marshaller = pool.acquireMarshaller();
-                marshaller.setProperty(XML.LOCALE,   locale);
-                marshaller.setProperty(XML.TIMEZONE, timezone);
-                if (isConsole()) {
-                    marshaller.marshal(object, out);
-                } else {
-                    out.flush();
-                    marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding.name());
-                    marshaller.marshal(object, System.out);     // Intentionally use OutputStream instead than Writer.
-                    System.out.flush();
-                }
-                break;
-            }
-        }
-        out.flush();
-    }
-
-    /**
-     * Returns {@code true} if {@link #out} is sending its output to the console.
-     * If not, then we are probably writing to a file or the user specified his own encoding.
-     * In such case, we will send the XML output to an {@code OutputStream} instead than to a
-     * {@code Writer} and let the marshaller apply the encoding itself.
-     */
-    private boolean isConsole() {
-        if (outputBuffer != null) return true;                      // Special case for JUnit tests only.
-        final Console console = System.console();
-        return (console != null) && console.writer() == out;
-    }
 }

Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeCommand.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeCommand.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeCommand.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MimeTypeCommand.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -18,14 +18,12 @@ package org.apache.sis.console;
 
 import java.net.URI;
 import java.util.EnumSet;
-import java.io.IOException;
 import java.net.URISyntaxException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.nio.file.NoSuchFileException;
 import java.nio.file.FileSystemNotFoundException;
 import org.apache.sis.storage.DataStores;
-import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.CharSequences;
 
@@ -41,7 +39,7 @@ import org.apache.sis.util.CharSequences
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.8
  * @module
  *
  * @see Files#probeContentType(Path)
@@ -50,18 +48,23 @@ import org.apache.sis.util.CharSequences
 final class MimeTypeCommand extends CommandRunner {
     /**
      * Creates the {@code "mime-type"} sub-command.
+     *
+     * @param  commandIndex  index of the {@code arguments} element containing the {@code "mime-type"} command name, or -1 if none.
+     * @param  arguments     the command-line arguments provided by the user.
+     * @throws InvalidOptionException if an illegal option has been provided, or the option has an illegal value.
      */
-    MimeTypeCommand(final int commandIndex, final String... args) throws InvalidOptionException {
-        super(commandIndex, args, EnumSet.of(Option.ENCODING, Option.HELP, Option.DEBUG));
+    MimeTypeCommand(final int commandIndex, final String... arguments) throws InvalidOptionException {
+        super(commandIndex, arguments, EnumSet.of(Option.ENCODING, Option.HELP, Option.DEBUG));
     }
 
     /**
      * Prints mime-type information.
      *
-     * @throws IOException if an error occurred while reading the file.
+     * @return 0 on success, or an exit code if the command failed for a reason other than an uncaught Java exception.
+     * @throws Exception if an error occurred while executing the sub-command.
      */
     @Override
-    public int run() throws InvalidOptionException, IOException, DataStoreException, URISyntaxException {
+    public int run() throws Exception {
         if (hasUnexpectedFileCount(1, Integer.MAX_VALUE)) {
             return Command.INVALID_ARGUMENT_EXIT_CODE;
         }

Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/TransformCommand.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -58,7 +58,6 @@ import org.apache.sis.internal.util.X364
 import org.apache.sis.io.LineAppender;
 import org.apache.sis.io.TableAppender;
 import org.apache.sis.io.wkt.Colors;
-import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.io.wkt.Transliterator;
 import org.apache.sis.io.wkt.WKTFormat;
 import org.apache.sis.io.wkt.Warnings;
@@ -81,10 +80,10 @@ import org.apache.sis.util.CharSequences
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.7
- * @version 0.7
+ * @version 0.8
  * @module
  */
-final class TransformCommand extends MetadataCommand {
+final class TransformCommand extends FormattedOutputCommand {
     /**
      * The coordinate operation from the given source CRS to target CRS.
      */
@@ -136,16 +135,19 @@ final class TransformCommand extends Met
     private NumberFormatException errorCause;
 
     /**
+     * Returns valid options for the {@code "transform"} commands.
+     */
+    private static EnumSet<Option> options() {
+        return EnumSet.of(Option.SOURCE_CRS, Option.TARGET_CRS, Option.VERBOSE,
+                Option.LOCALE, Option.TIMEZONE, Option.ENCODING, Option.COLORS, Option.HELP, Option.DEBUG);
+    }
+
+    /**
      * Creates the {@code "transform"} sub-command.
      */
     TransformCommand(final int commandIndex, final String... args) throws InvalidOptionException {
-        super(commandIndex, args, EnumSet.of(Option.SOURCE_CRS, Option.TARGET_CRS, Option.VERBOSE,
-                Option.LOCALE, Option.TIMEZONE, Option.ENCODING, Option.COLORS, Option.HELP, Option.DEBUG));
-
-        // Default output format for CRS.
-        outputFormat = Format.WKT;
-        convention   = Convention.WKT2_SIMPLIFIED;
-        resources    = Vocabulary.getResources(locale);
+        super(commandIndex, args, options(), OutputFormat.WKT, OutputFormat.TEXT);
+        resources = Vocabulary.getResources(locale);
     }
 
     /**
@@ -185,14 +187,11 @@ final class TransformCommand extends Met
 
     /**
      * Transforms coordinates from the files given in argument or from the standard input stream.
+     *
+     * @return 0 on success, or an exit code if the command failed for a reason other than an uncaught Java exception.
      */
     @Override
     public int run() throws Exception {
-        parseArguments();
-        if (outputFormat == Format.XML) {
-            final String format = outputFormat.name();
-            throw new InvalidOptionException(Errors.format(Errors.Keys.IncompatibleFormat_2, "transform", format), format);
-        }
         final CoordinateReferenceSystem sourceCRS = fetchCRS(Option.SOURCE_CRS);
         final CoordinateReferenceSystem targetCRS = fetchCRS(Option.TARGET_CRS);
         /*

Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/package-info.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/package-info.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/package-info.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -48,7 +48,7 @@
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.7
+ * @version 0.8
  * @module
  */
 package org.apache.sis.console;

Modified: sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/HelpCommandTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/HelpCommandTest.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/HelpCommandTest.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/HelpCommandTest.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.console;
 
+import java.io.IOException;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
@@ -28,7 +29,7 @@ import static org.junit.Assert.*;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.8
  * @module
  */
 @DependsOn(CommandRunnerTest.class)
@@ -37,9 +38,10 @@ public final strictfp class HelpCommandT
      * Tests the sub-command without option.
      *
      * @throws InvalidOptionException should never happen.
+     * @throws IOException should never happen, because we are writing to a {@code PrintWriter}.
      */
     @Test
-    public void testDefault() throws InvalidOptionException {
+    public void testDefault() throws InvalidOptionException, IOException {
         final HelpCommand test = new HelpCommand(0, CommandRunner.TEST);
         test.run();
         final String result = test.outputBuffer.toString();
@@ -57,9 +59,10 @@ public final strictfp class HelpCommandT
      * Shall contain only a subset of {@link #testDefault()}.
      *
      * @throws InvalidOptionException should never happen.
+     * @throws IOException should never happen, because we are writing to a {@code PrintWriter}.
      */
     @Test
-    public void testHelp() throws InvalidOptionException {
+    public void testHelp() throws InvalidOptionException, IOException {
         final HelpCommand test = new HelpCommand(0, CommandRunner.TEST, "--help");
         test.help("help");
         final String result = test.outputBuffer.toString();
@@ -76,9 +79,10 @@ public final strictfp class HelpCommandT
      * Tests the sub-command with the {@code --locale en} option.
      *
      * @throws InvalidOptionException should never happen.
+     * @throws IOException should never happen, because we are writing to a {@code PrintWriter}.
      */
     @Test
-    public void testEnglishLocale() throws InvalidOptionException {
+    public void testEnglishLocale() throws InvalidOptionException, IOException {
         final HelpCommand test = new HelpCommand(0, CommandRunner.TEST, "--help", "--locale", "en");
         test.help("help");
         final String result = test.outputBuffer.toString();
@@ -90,9 +94,10 @@ public final strictfp class HelpCommandT
      * Tests the sub-command with the {@code --locale fr} option.
      *
      * @throws InvalidOptionException should never happen.
+     * @throws IOException should never happen, because we are writing to a {@code PrintWriter}.
      */
     @Test
-    public void testFrenchLocale() throws InvalidOptionException {
+    public void testFrenchLocale() throws InvalidOptionException, IOException {
         final HelpCommand test = new HelpCommand(0, CommandRunner.TEST, "--help", "--locale", "fr");
         test.help("help");
         final String result = test.outputBuffer.toString();

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataTypes.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataTypes.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataTypes.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataTypes.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -17,8 +17,24 @@
 package org.apache.sis.internal.metadata;
 
 import java.util.Collection;
+import org.opengis.metadata.Metadata;
+import org.opengis.metadata.content.Band;
+import org.opengis.metadata.content.ImageDescription;
+import org.opengis.metadata.lineage.ProcessStep;
+import org.opengis.metadata.lineage.Source;
 import org.apache.sis.internal.jaxb.TypeRegistration;
+import org.apache.sis.internal.jaxb.gmi.LE_ProcessStep;
+import org.apache.sis.internal.jaxb.gmi.LE_Source;
+import org.apache.sis.internal.jaxb.gmi.MI_Band;
+import org.apache.sis.internal.jaxb.gmi.MI_CoverageDescription;
+import org.apache.sis.internal.jaxb.gmi.MI_Georectified;
+import org.apache.sis.internal.jaxb.gmi.MI_Georeferenceable;
+import org.apache.sis.internal.jaxb.gmi.MI_ImageDescription;
+import org.apache.sis.internal.jaxb.gmi.MI_Metadata;
 import org.apache.sis.metadata.iso.DefaultMetadata;
+import org.opengis.metadata.content.CoverageDescription;
+import org.opengis.metadata.spatial.Georectified;
+import org.opengis.metadata.spatial.Georeferenceable;
 
 
 /**
@@ -27,7 +43,7 @@ import org.apache.sis.metadata.iso.Defau
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.8
  * @module
  */
 public final class MetadataTypes extends TypeRegistration {
@@ -35,7 +51,45 @@ public final class MetadataTypes extends
      * Adds to the given collection the metadata types that should be given to the initial JAXB context.
      */
     @Override
-    public void getTypes(final Collection<Class<?>> addTo) {
+    protected void getTypes(final Collection<Class<?>> addTo) {
         addTo.add(DefaultMetadata.class);
     }
+
+    /**
+     * Notifies that the {@code sis-metadata} module can marshal arbitrary implementations of some metadata interfaces.
+     *
+     * @return {@code true}.
+     */
+    @Override
+    protected boolean canMarshalInterfaces() {
+        return true;
+    }
+
+    /**
+     * Ensures that the given value is an instance of a class that can be marshalled, or returns {@code null}
+     * if the type of the given value is not handled by this method. Current implementation handles all types
+     * that may need to be put in the ISO 19115-3 namespace; we have to do that ourself because those classes
+     * are not public. Other types may be added if needed, but we do not want to handle too many of them (for
+     * performance reasons). However the list or recognized types shall contain at least {@link Metadata}.
+     *
+     * @param  value  the value to marshal.
+     * @return the given value as a type that can be marshalled, or {@code null}.
+     */
+    @Override
+    public Object toImplementation(final Object value) {
+        /*
+         * Classes that are most likely to be used should be checked first.  If a type is a specialization
+         * of another type (e.g. ImageDescription extends CoverageDescription), the specialized type shall
+         * be before the more generic type.
+         */
+        if (value instanceof Metadata)            return MI_Metadata           .castOrCopy((Metadata)            value);
+        if (value instanceof ImageDescription)    return MI_ImageDescription   .castOrCopy((ImageDescription)    value);
+        if (value instanceof CoverageDescription) return MI_CoverageDescription.castOrCopy((CoverageDescription) value);
+        if (value instanceof Georectified)        return MI_Georectified       .castOrCopy((Georectified)        value);
+        if (value instanceof Georeferenceable)    return MI_Georeferenceable   .castOrCopy((Georeferenceable)    value);
+        if (value instanceof Band)                return MI_Band               .castOrCopy((Band)                value);
+        if (value instanceof ProcessStep)         return LE_ProcessStep        .castOrCopy((ProcessStep)         value);
+        if (value instanceof Source)              return LE_Source             .castOrCopy((Source)              value);
+        return null;
+    }
 }

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/FormattableObject.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlTran
 import org.apache.sis.util.Debug;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.internal.util.X364;
+import org.apache.sis.internal.util.Constants;
 
 
 /**
@@ -186,7 +187,7 @@ public abstract class FormattableObject
         formatter.configure(convention, null, colorize ? Colors.DEFAULT : null,
                 convention.toUpperCase           ? (byte) +1 : 0,
                 (convention.majorVersion() == 1) ? (byte) -1 : 0,
-                WKTFormat.DEFAULT_INDENTATION);
+                Constants.DEFAULT_INDENTATION);
         if (!strict) {
             formatter.transliterator = Transliterator.IDENTITY;
         }

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -321,7 +321,7 @@ public class Formatter implements Locali
      * Creates a new formatter instance with the default configuration.
      */
     public Formatter() {
-        this(Convention.DEFAULT, Symbols.getDefault(), WKTFormat.DEFAULT_INDENTATION);
+        this(Convention.DEFAULT, Symbols.getDefault(), Constants.DEFAULT_INDENTATION);
     }
 
     /**
@@ -364,7 +364,7 @@ public class Formatter implements Locali
         this.authority     = Convention.DEFAULT.getNameAuthority();
         this.symbols       = symbols;
         this.lineSeparator = this.symbols.lineSeparator();
-        this.indentation   = WKTFormat.DEFAULT_INDENTATION;
+        this.indentation   = Constants.DEFAULT_INDENTATION;
         this.numberFormat  = numberFormat;                      // No clone needed.
         this.dateFormat    = dateFormat;
         this.unitFormat    = unitFormat;

Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -44,6 +44,7 @@ import org.apache.sis.measure.UnitFormat
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.util.Constants;
 import org.apache.sis.internal.util.StandardDateFormat;
 
 // Branch-dependent imports
@@ -124,15 +125,14 @@ public class WKTFormat extends CompoundF
     /**
      * The indentation value to give to the {@link #setIndentation(int)}
      * method for formatting the complete object on a single line.
+     *
+     * @see #getIndentation()
+     * @see #setIndentation(int)
+     * @see org.apache.sis.setup.OptionKey#INDENTATION
      */
     public static final int SINGLE_LINE = -1;
 
     /**
-     * The default indentation value.
-     */
-    static final byte DEFAULT_INDENTATION = 2;
-
-    /**
      * The symbols to use for this formatter.
      * The same object is also referenced in the {@linkplain #parser} and {@linkplain #formatter}.
      * It appears here for serialization purpose.
@@ -243,7 +243,7 @@ public class WKTFormat extends CompoundF
         symbols      = Symbols.getDefault();
         keywordCase  = KeywordCase.DEFAULT;
         keywordStyle = KeywordStyle.DEFAULT;
-        indentation  = DEFAULT_INDENTATION;
+        indentation  = Constants.DEFAULT_INDENTATION;
     }
 
     /**
@@ -540,6 +540,8 @@ public class WKTFormat extends CompoundF
      * The {@value #SINGLE_LINE} value means that the whole WKT is to be formatted on a single line.
      *
      * @param  indentation  the new indentation to use.
+     *
+     * @see org.apache.sis.setup.OptionKey#INDENTATION
      */
     public void setIndentation(final int indentation) {
         ArgumentChecks.ensureBetween("indentation", SINGLE_LINE, Byte.MAX_VALUE, indentation);

Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultProcessStepTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultProcessStepTest.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultProcessStepTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/lineage/DefaultProcessStepTest.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -18,10 +18,11 @@ package org.apache.sis.metadata.iso.line
 
 import javax.xml.bind.JAXBException;
 import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.internal.jaxb.gmi.LE_ProcessStep;
 import org.apache.sis.test.XMLTestCase;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.opengis.test.Assert.*;
 
 
 /**
@@ -30,7 +31,7 @@ import static org.junit.Assert.*;
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.8
  * @module
  */
 public final strictfp class DefaultProcessStepTest extends XMLTestCase {
@@ -59,7 +60,13 @@ public final strictfp class DefaultProce
         assertMarshalEqualsFile(XML_FILE, processStep, "xlmns:*", "xsi:schemaLocation");
         /*
          * XML unmarshalling: ensure that we didn't lost any information.
+         * Note that since the XML uses the <gmi:…> namespace, we got an instance of LE_ProcessStep, which
+         * in SIS implementation does not carry any useful information; it is just a consequence of the way
+         * namespaces are managed. We will convert to the parent DefaultProcessStep type before comparison.
          */
-        assertEquals(processStep, unmarshalFile(DefaultProcessStep.class, XML_FILE));
+        DefaultProcessStep step = unmarshalFile(DefaultProcessStep.class, XML_FILE);
+        assertInstanceOf("The unmarshalled object is expected to be in GMI namespace.", LE_ProcessStep.class, step);
+        step = new DefaultProcessStep(step);
+        assertEquals(processStep, step);
     }
 }

Modified: sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/lineage/ProcessStep.xml
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/lineage/ProcessStep.xml?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/lineage/ProcessStep.xml (original)
+++ sis/trunk/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/lineage/ProcessStep.xml Fri Feb  3 08:01:02 2017
@@ -18,7 +18,7 @@
   under the License.
 -->
 
-<gmd:LI_ProcessStep
+<gmi:LE_ProcessStep
     xmlns:gmd = "http://www.isotc211.org/2005/gmd"
     xmlns:gco = "http://www.isotc211.org/2005/gco"
     xmlns:gmi = "http://www.isotc211.org/2005/gmi"
@@ -39,4 +39,4 @@
       </gmi:procedureDescription>
     </gmi:LE_Processing>
   </gmi:processingInformation>
-</gmd:LI_ProcessStep>
+</gmi:LE_ProcessStep>

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -1119,7 +1119,7 @@ public abstract class AbstractEnvelope i
      * @return this envelope as a {@code BOX} or {@code BOX3D} (most typical dimensions) element.
      *
      * @see GeneralEnvelope#GeneralEnvelope(CharSequence)
-     * @see org.apache.sis.measure.CoordinateFormat
+     * @see CoordinateFormat
      * @see org.apache.sis.io.wkt
      */
     static String toString(final Envelope envelope, final boolean isSimplePrecision) {

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -42,6 +42,7 @@ import static org.apache.sis.util.Argume
  *
  * @see DirectPosition2D
  * @see GeneralDirectPosition
+ * @see CoordinateFormat
  */
 public class DirectPosition1D extends AbstractDirectPosition implements Serializable, Cloneable {
     /**
@@ -99,7 +100,7 @@ public class DirectPosition1D extends Ab
      * @throws MismatchedDimensionException if the given point is not one-dimensional.
      *
      * @see #toString()
-     * @see org.apache.sis.measure.CoordinateFormat
+     * @see CoordinateFormat
      */
     public DirectPosition1D(final CharSequence wkt) throws IllegalArgumentException {
         final double[] ordinates = parse(wkt);

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -66,6 +66,7 @@ import static org.apache.sis.util.Argume
  * @see DirectPosition1D
  * @see GeneralDirectPosition
  * @see Point2D
+ * @see CoordinateFormat
  */
 public class DirectPosition2D extends Point2D.Double implements DirectPosition, Cloneable {
     /**
@@ -156,7 +157,7 @@ public class DirectPosition2D extends Po
      * @throws MismatchedDimensionException if the given point is not two-dimensional.
      *
      * @see #toString()
-     * @see org.apache.sis.measure.CoordinateFormat
+     * @see CoordinateFormat
      */
     public DirectPosition2D(final CharSequence wkt) throws IllegalArgumentException {
         final double[] ordinates = AbstractDirectPosition.parse(wkt);

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -57,6 +57,7 @@ import static org.apache.sis.util.Argume
  *
  * @see DirectPosition1D
  * @see DirectPosition2D
+ * @see CoordinateFormat
  */
 public class GeneralDirectPosition extends AbstractDirectPosition implements Serializable, Cloneable {
     /**
@@ -108,10 +109,16 @@ public class GeneralDirectPosition exten
      * Consequently, callers shall not recycle the same array for creating many instances.
      *
      * <div class="note"><b>Implementation note:</b>
-     * The array is not cloned because this is usually not needed, especially in the context of variable
+     * the array is not cloned because this is usually not needed, especially in the context of variable
      * argument lengths since the array is often created implicitly. Furthermore the {@link #ordinates}
      * field is public, so cloning the array would not protect the state of this object anyway.</div>
      *
+     * <p><b>Caution:</b> if only one number is specified, make sure that the number type is {@code double},
+     * {@code float} or {@code long} otherwise the {@link #GeneralDirectPosition(int)} constructor would be
+     * invoked with a very different meaning. For example for creating a one-dimensional coordinate initialized
+     * to the ordinate value 100, use <code>new GeneralDirectPosition(100<u>.0</u>)</code>, <strong>not</strong>
+     * {@code new GeneralDirectPosition(100)}, because the later would actually create a position with 100 dimensions.</p>
+     *
      * @param ordinates  the ordinate values. This array is <strong>not</strong> cloned.
      */
     public GeneralDirectPosition(final double... ordinates) {
@@ -145,7 +152,7 @@ public class GeneralDirectPosition exten
      * @throws IllegalArgumentException if the given string can not be parsed.
      *
      * @see #toString()
-     * @see org.apache.sis.measure.CoordinateFormat
+     * @see CoordinateFormat
      */
     public GeneralDirectPosition(final CharSequence wkt) throws IllegalArgumentException {
         if ((ordinates = parse(wkt)) == null) {

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -81,7 +81,7 @@
  *       than an inclusion area.</li>
  * </ul>
  *
- * @author Martin Desruisseaux (IRD, Geomatys)
+ * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3
  * @version 0.8
  * @module

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingTypes.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -21,6 +21,8 @@ import org.apache.sis.internal.jaxb.Type
 import org.apache.sis.parameter.DefaultParameterValue;
 import org.apache.sis.parameter.DefaultParameterValueGroup;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
+import org.apache.sis.referencing.AbstractReferenceSystem;
+import org.opengis.referencing.ReferenceSystem;
 
 
 /**
@@ -29,7 +31,7 @@ import org.apache.sis.referencing.Abstra
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.8
  * @module
  */
 public final class ReferencingTypes extends TypeRegistration {
@@ -37,9 +39,32 @@ public final class ReferencingTypes exte
      * Adds to the given collection the referencing types that should be given to the initial JAXB context.
      */
     @Override
-    public void getTypes(final Collection<Class<?>> addTo) {
+    protected void getTypes(final Collection<Class<?>> addTo) {
         addTo.add(AbstractIdentifiedObject.class);
         addTo.add(DefaultParameterValue.class);
         addTo.add(DefaultParameterValueGroup.class);
     }
+
+    /**
+     * Notifies that the {@code sis-referencing} module can marshal arbitrary implementations
+     * of some coordinate reference system interfaces.
+     *
+     * @return {@code true}.
+     */
+    @Override
+    protected boolean canMarshalInterfaces() {
+        return true;
+    }
+
+    /**
+     * Ensures that the given value is an instance of a class that can be marshalled,
+     * or returns {@code null} if the type is not handled by this method.
+     *
+     * @param  value  the value to marshal.
+     * @return the given value as a type that can be marshalled, or {@code null}.
+     */
+    @Override
+    public Object toImplementation(final Object value) {
+        return (value instanceof ReferenceSystem) ? AbstractReferenceSystem.castOrCopy((ReferenceSystem) value) : null;
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -915,9 +915,11 @@ check:  while (lower != 0 || upper != di
                     crs = components.get(i);
                     dimension = crs.getCoordinateSystem().getDimension();
                     if (lower < dimension) {
-                        // The requested dimensions may intersect the dimension of this CRS.
-                        // The outer loop will perform the verification, and eventually go
-                        // down again in the tree of sub-components.
+                        /*
+                         * The requested dimensions may intersect the dimension of this CRS.
+                         * The outer loop will perform the verification, and eventually go
+                         * down again in the tree of sub-components.
+                         */
                         continue check;
                     }
                     lower -= dimension;

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/HTMLGenerator.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -26,6 +26,7 @@ import java.io.BufferedWriter;
 import java.io.OutputStreamWriter;
 import java.io.Closeable;
 import org.opengis.util.InternationalString;
+import org.apache.sis.internal.util.Constants;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.Deprecable;
 
@@ -59,7 +60,7 @@ abstract strictfp class HTMLGenerator im
      * The number of space to add or remove in the {@linkplain #margin}
      * when new HTML elements are opened or closed.
      */
-    private static final int INDENTATION = 2;
+    private static final int INDENTATION = Constants.DEFAULT_INDENTATION;
 
     /**
      * Where to write the HTML page.

Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -222,6 +222,7 @@ import org.junit.BeforeClass;
     org.apache.sis.geometry.Shapes2DTest.class,                 // Simpler than EnvelopesTest.
     org.apache.sis.geometry.EnvelopesTest.class,
     org.apache.sis.internal.referencing.ServicesForMetadataTest.class,
+    org.apache.sis.geometry.CoordinateFormatTest.class,
 
     org.apache.sis.distance.LatLonPointRadiusTest.class,        // Pending refactoring in a geometry package.
 

Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java?rev=1781503&r1=1781502&r2=1781503&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java [UTF-8] Fri Feb  3 08:01:02 2017
@@ -132,7 +132,7 @@ public class ConverterRegistry {
      */
     @SuppressWarnings("unchecked")
     private <S,T> void put(ClassPair<S,T> key, final ObjectConverter<? super S, ? extends T> converter) {
-        assert key.getClass() == ClassPair.class; // See SystemConverter.equals(Object)
+        assert key.getClass() == ClassPair.class;                   // See SystemConverter.equals(Object)
         assert key.cast(converter) != null : converter;
         assert Thread.holdsLock(converters);
         if (converter instanceof SystemConverter<?,?> &&
@@ -269,7 +269,7 @@ public class ConverterRegistry {
              * for the place where to put the given converter in the hierarchy of converters.
              */
             if (!isInitialized) {
-                isInitialized = true; // Before 'initialize()' for preventing infinite recursivity.
+                isInitialized = true;           // Before 'initialize()' for preventing infinite recursivity.
                 initialize();
             }
             for (Class<? super T> i=targetClass; i!=null && i!=stopAt; i=i.getSuperclass()) {
@@ -354,7 +354,7 @@ public class ConverterRegistry {
              * its source is more specific:  the source of 'converter' is of type <S> while the
              * source of 'existing' is of type <? super S>.
              */
-            assert converter.getSourceClass() == key.sourceClass; // Enforced by parameterized type.
+            assert converter.getSourceClass() == key.sourceClass;       // Enforced by parameterized type.
             if (existing.getSourceClass() == key.sourceClass) {
                 final boolean oldIsExact = isExactlyFor(existing,  key.targetClass);
                 final boolean newIsExact = isExactlyFor(converter, key.targetClass);
@@ -374,7 +374,7 @@ public class ConverterRegistry {
                      * checked the source class in the above 'if' statement.
                      */
                     converter = FallbackConverter.merge((ObjectConverter<S, ? extends T>) existing, converter);
-                    assert key.targetClass.isAssignableFrom(converter.getTargetClass()) : converter; // See FallbackConverter.merge javadoc.
+                    assert key.targetClass.isAssignableFrom(converter.getTargetClass()) : converter;    // See FallbackConverter.merge javadoc.
                 }
             }
         }



Mime
View raw message