sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1733379 [4/4] - in /sis/branches/JDK6: ./ application/sis-console/src/main/artifact/bin/ application/sis-console/src/main/artifact/conf/ application/sis-console/src/main/artifact/data/ application/sis-console/src/main/artifact/lib/ applica...
Date Wed, 02 Mar 2016 22:05:07 GMT
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/io/IO.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/io/IO.java?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/io/IO.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/io/IO.java [UTF-8] Wed
Mar  2 22:05:05 2016
@@ -46,8 +46,8 @@ public final class IO extends Static {
      * of wrappers defined in this package around a flushable object, invokes the
      * {@link Flushable#flush() flush()} method on that object. Otherwise do nothing.
      *
-     * <p>Chains of wrappers are followed until a {@code Flushable}
-     * instance is found, if any. The search stops at the first occurrence found.</p>
+     * <p>Chains of wrappers are followed until a {@code Flushable} instance is found,
if any.
+     * The search stops at the first occurrence found.</p>
      *
      * @param  out The stream or buffer to flush, or {@code null}.
      * @throws IOException if an error occurred while flushing the given stream.
@@ -67,10 +67,10 @@ public final class IO extends Static {
      * of wrappers defined in this package around a closeable object, invokes the
      * {@link Closeable#close() close()} method on that object. Otherwise do nothing.
      *
-     * <p>Chains of wrappers are followed until a {@code Closeable}
-     * instance is found, if any. The first {@link Flushable} instance found <em>before</em>
the
-     * {@code Closeable} one, if any, is {@linkplain Flushable#flush() flushed}. The search
stops
-     * at the first {@code Closeable} occurrence found.</p>
+     * <p>Chains of wrappers are followed until a {@code Closeable} instance is found,
if any.
+     * The first {@link Flushable} instance found <em>before</em> the {@code
Closeable} one,
+     * if any, is {@linkplain Flushable#flush() flushed}.
+     * The search stops at the first {@code Closeable} occurrence found.</p>
      *
      * @param  out The stream or buffer to close, or {@code null}.
      * @throws IOException if an error occurred while closing the given stream.

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java
[UTF-8] Wed Mar  2 22:05:05 2016
@@ -20,7 +20,7 @@
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.7
  * @module
  */
 package org.apache.sis.setup;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
[UTF-8] Wed Mar  2 22:05:05 2016
@@ -170,6 +170,9 @@ public final class Logging extends Stati
         String name = classe.getName();
         final int separator = name.lastIndexOf('.');
         name = (separator >= 1) ? name.substring(0, separator) : "";
+        if (name.startsWith("org.apache.sis.internal.")) {
+            name = "org.apache.sis" + name.substring(23);       // Remove the "internal"
part from SIS package name.
+        }
         return getLogger(name);
     }
 

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
[UTF-8] Wed Mar  2 22:05:05 2016
@@ -111,7 +111,7 @@ import org.apache.sis.internal.jdk7.JDK7
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.7
  * @module
  *
  * @see SimpleFormatter
@@ -544,6 +544,7 @@ loop:   for (int i=0; ; i++) {
     /**
      * Returns the {@link #colors} map, creating it if needed.
      */
+    @SuppressWarnings("ReturnOfCollectionOrArrayField")
     private SortedMap<Level,X364> colors() {
         if (colors == null) {
             colors = new TreeMap<Level,X364>(COMPARATOR);
@@ -642,19 +643,17 @@ loop:   for (int i=0; ; i++) {
              * This level will be formatted with a colorized background if ANSI escape sequences
are enabled.
              */
             int margin = buffer.length();
+            String levelColor = "", levelReset = "";
             if (SHOW_LEVEL) {
                 if (colors) {
-                    buffer.append(colorAt(level));
+                    levelColor = colorAt(level);
+                    levelReset = X364.BACKGROUND_DEFAULT.sequence();
                 }
-                final int offset = buffer.length();
+                final int offset = buffer.append(levelColor).length();
                 buffer.append(level.getLocalizedName())
                       .append(CharSequences.spaces(levelWidth - (buffer.length() - offset)));
                 margin += buffer.length() - offset;
-                if (colors) {
-                    buffer.append(X364.BACKGROUND_DEFAULT.sequence());
-                }
-                buffer.append(' ');
-                margin++;
+                buffer.append(levelReset).append(' ');
             }
             /*
              * Appends the logger name or source class name, in long of short form.
@@ -692,8 +691,8 @@ loop:   for (int i=0; ; i++) {
              */
             String bodyLineSeparator = writer.getLineSeparator();
             final String lineSeparator = JDK7.lineSeparator();
-            if (bodyLineSeparator.length() != lineSeparator.length() + margin) {
-                bodyLineSeparator = lineSeparator + CharSequences.spaces(margin);
+            if (bodyLineSeparator.length() != lineSeparator.length() + margin + 1) {
+                bodyLineSeparator = lineSeparator + levelColor + CharSequences.spaces(margin)
+ levelReset + ' ';
                 writer.setLineSeparator(bodyLineSeparator);
             }
             if (colors && !emphase) {

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
[UTF-8] Wed Mar  2 22:05:05 2016
@@ -181,6 +181,11 @@ public final class Errors extends Indexe
         public static final short CanNotTransformEnvelopeToGeodetic = 174;
 
         /**
+         * Can not use the {0} geodetic parameters: {1}
+         */
+        public static final short CanNotUseGeodeticParameters_2 = 218;
+
+        /**
          * Circular reference.
          */
         public static final short CircularReference = 52;
@@ -474,6 +479,11 @@ public final class Errors extends Indexe
         public static final short IncompatibleDatum_2 = 186;
 
         /**
+         * Can not use the “{1}” format with “{0}”.
+         */
+        public static final short IncompatibleFormat_2 = 217;
+
+        /**
          * Property “{0}” has an incompatible value.
          */
         public static final short IncompatiblePropertyValue_1 = 45;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
[ISO-8859-1] Wed Mar  2 22:05:05 2016
@@ -47,6 +47,7 @@ CanNotSetParameterValue_1         = Can
 CanNotSetPropertyValue_1          = Can not set a value for property \u201c{0}\u201d.
 CanNotTransformEnvelope           = Can not transform envelope.
 CanNotTransformEnvelopeToGeodetic = Can not transform envelope to a geodetic CRS.
+CanNotUseGeodeticParameters_2     = Can not use the {0} geodetic parameters: {1}
 CircularReference                 = Circular reference.
 ClassNotFinal_1                   = Class \u2018{0}\u2019 is not final.
 CloneNotSupported_1               = Can not clone an object of type \u2018{0}\u2019.
@@ -104,6 +105,7 @@ IllegalUnicodeCodePoint_2         = Valu
 IllegalUnitFor_2                  = Unit of measurement \u201c{1}\u201d is not valid for
\u201c{0}\u201d values.
 IncompatibleCoordinateSystemTypes = Incompatible coordinate system types.
 IncompatibleDatum_2               = Datum of \u201c{1}\u201d shall be \u201c{0}\u201d.
+IncompatibleFormat_2              = Can not use the \u201c{1}\u201d format with \u201c{0}\u201d.
 IncompatiblePropertyValue_1       = Property \u201c{0}\u201d has an incompatible value.
 IncompatibleUnit_1                = Unit \u201c{0}\u201d is incompatible with current value.
 IncompatibleUnits_2               = Units \u201c{0}\u201d and \u201c{1}\u201d are incompatible.

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
[ISO-8859-1] Wed Mar  2 22:05:05 2016
@@ -44,6 +44,7 @@ CanNotSetParameterValue_1         = Ne p
 CanNotSetPropertyValue_1          = Ne peut pas d\u00e9finir une valeur pour la propri\u00e9t\u00e9
\u00ab\u202f{0}\u202f\u00bb.
 CanNotTransformEnvelope           = Ne peut pas transformer l\u2019enveloppe.
 CanNotTransformEnvelopeToGeodetic = Ne peut pas transformer l\u2019enveloppe vers un syst\u00e8me
g\u00e9od\u00e9sique.
+CanNotUseGeodeticParameters_2     = Ne peut pas utiliser les param\u00e8tres g\u00e9od\u00e9siques
{0}\u202f: {1}
 CircularReference                 = R\u00e9f\u00e9rence circulaire.
 ClassNotFinal_1                   = La classe \u2018{0}\u2019 n\u2019est pas finale.
 CloneNotSupported_1               = Un objet de type \u2018{0}\u2019 ne peut pas \u00eatre
clon\u00e9.
@@ -101,6 +102,7 @@ IllegalUnicodeCodePoint_2         = La v
 IllegalUnitFor_2                  = L\u2019unit\u00e9 de mesure \u00ab\u202f{1}\u202f\u00bb
n\u2019est pas valide pour les valeurs de \u00ab\u202f{0}\u202f\u00bb.
 IncompatibleCoordinateSystemTypes = Types de syst\u00e8mes de coordonn\u00e9es incompatibles.
 IncompatibleDatum_2               = Le r\u00e9f\u00e9rentiel de \u00ab\u202f{1}\u202f\u00bb
doit \u00eatre \u00ab\u202f{0}\u202f\u00bb.
+IncompatibleFormat_2              = Le format \u00ab\u202f{1}\u202f\u00bb ne s\u2019applique
pas \u00e0 \u00ab\u202f{0}\u202f\u00bb.
 IncompatiblePropertyValue_1       = La valeur de la propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb
n\u2019est pas compatible.
 IncompatibleUnit_1                = L\u2019unit\u00e9 \u00ab\u202f{0}\u202f\u00bb n\u2019est
pas compatible avec la valeur actuelle.
 IncompatibleUnits_2               = Les unit\u00e9s \u00ab\u202f{0}\u202f\u00bb et \u00ab\u202f{1}\u202f\u00bb
ne sont pas compatibles.

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
[UTF-8] Wed Mar  2 22:05:05 2016
@@ -440,7 +440,7 @@ public class IndexedResourceBundle exten
     private static Class<?> getPublicType(Class<?> c) {
         while (!Modifier.isPublic(c.getModifiers())) {
             for (final Class<?> type : c.getInterfaces()) {
-                if (Modifier.isPublic(type.getModifiers())) {
+                if (Modifier.isPublic(type.getModifiers()) && !type.getName().startsWith("java"))
{
                     return type;
                 }
             }

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
[UTF-8] Wed Mar  2 22:05:05 2016
@@ -266,6 +266,11 @@ public final class Vocabulary extends In
         public static final short Latitude = 26;
 
         /**
+         * Legend
+         */
+        public static final short Legend = 97;
+
+        /**
          * Level
          */
         public static final short Level = 94;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
[ISO-8859-1] Wed Mar  2 22:05:05 2016
@@ -57,6 +57,7 @@ JavaHome                = Java home dire
 Julian                  = Julian
 Latitude                = Latitude
 Longitude               = Longitude
+Legend                  = Legend
 Level                   = Level
 Libraries               = Libraries
 LocalConfiguration      = Local configuration

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
[ISO-8859-1] Wed Mar  2 22:05:05 2016
@@ -64,6 +64,7 @@ JavaHome                = R\u00e9pertoir
 Julian                  = Julien
 Latitude                = Latitude
 Longitude               = Longitude
+Legend                  = L\u00e9gende
 Level                   = Niveau
 Libraries               = Biblioth\u00e8ques
 LocalConfiguration      = Configuration locale

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8]
(original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/Assert.java [UTF-8]
Wed Mar  2 22:05:05 2016
@@ -33,6 +33,8 @@ import org.xml.sax.SAXException;
 import org.apache.sis.util.Utilities;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.util.Exceptions;
+import org.apache.sis.util.Classes;
 
 // Branch-dependent imports
 import org.apache.sis.internal.jdk7.Objects;
@@ -100,6 +102,35 @@ public strictfp class Assert extends org
     }
 
     /**
+     * Asserts that the two given arrays contains objects that are equal ignoring metadata.
+     * See {@link ComparisonMode#IGNORE_METADATA} for more information.
+     *
+     * @param expected  The expected objects (array can be {@code null}).
+     * @param actual    The actual objects (array can be {@code null}).
+     *
+     * @since 0.7
+     */
+    public static void assertArrayEqualsIgnoreMetadata(final Object[] expected, final Object[]
actual) {
+        if (expected != actual) {
+            if (expected == null) {
+                assertNull("Expected null array.", actual);
+            } else {
+                assertNotNull("Expected non-null array.", actual);
+                final int length = StrictMath.min(expected.length, actual.length);
+                for (int i=0; i<length; i++) try {
+                    assertEqualsIgnoreMetadata(expected[i], actual[i]);
+                } catch (AssertionError e) {
+                    final AssertionError ne = new AssertionError(Exceptions.formatChainedMessages(null,
+                            "Comparison failure at index " + i + " (a " + Classes.getShortClassName(actual[i])
+ ").", e));
+                    ne.initCause(e);
+                    throw ne;
+                }
+                assertEquals("Unexpected array length.", expected.length, actual.length);
+            }
+        }
+    }
+
+    /**
      * Asserts that two strings are equal, ignoring the differences in EOL characters.
      * The comparisons is performed one a line-by-line basis. For each line, trailing
      * spaces (but not leading spaces) are ignored.

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/logging/EmptyWarningListeners.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/logging/EmptyWarningListeners.java?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/logging/EmptyWarningListeners.java
[UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/logging/EmptyWarningListeners.java
[UTF-8] Wed Mar  2 22:05:05 2016
@@ -51,21 +51,12 @@ public final strictfp class EmptyWarning
      * Creates a new instance for the given locale and logger.
      *
      * @param locale The locale to be returned by {@link #getLocale()}. Can be {@code null}.
-     * @param logger The logger to be returned by {@link #getLogger()}.
+     * @param logger The name of the logger to be returned by {@link #getLogger()}.
      */
-    public EmptyWarningListeners(final Locale locale, final Logger logger) {
+    public EmptyWarningListeners(final Locale locale, final String logger) {
         ArgumentChecks.ensureNonNull("logger", logger);
         this.locale = locale;
-        this.logger = logger;
-    }
-
-    /**
-     * Convenience constructor for an instance with null locale and the logger of the given
name.
-     *
-     * @param logger The name of the logger to be returned by {@link #getLogger()}.
-     */
-    public EmptyWarningListeners(final String logger) {
-        this(null, Logging.getLogger(logger));
+        this.logger = Logging.getLogger(logger);
     }
 
     /** Returns the value given at construction time. */ @Override public Locale getLocale()
{return locale;}

Modified: sis/branches/JDK6/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/TestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/TestCase.java?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/TestCase.java
[UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/TestCase.java
[UTF-8] Wed Mar  2 22:05:05 2016
@@ -46,8 +46,7 @@ public abstract strictfp class TestCase
     /**
      * A dummy list of listeners which can be given to the {@link Decoder} constructor.
      */
-    public static EmptyWarningListeners<Decoder> LISTENERS =
-            new EmptyWarningListeners<Decoder>(Modules.NETCDF);
+    public static EmptyWarningListeners<Decoder> LISTENERS = new EmptyWarningListeners<Decoder>(null,
Modules.NETCDF);
 
     /**
      * The {@code searchPath} argument value to be given to the {@link Decoder#setSearchPath(String[])}

Modified: sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
[UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java
[UTF-8] Wed Mar  2 22:05:05 2016
@@ -16,21 +16,27 @@
  */
 package org.apache.sis.internal.storage.wkt;
 
+import java.util.List;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
 import java.io.Reader;
 import java.io.IOException;
+import java.text.ParsePosition;
+import java.text.ParseException;
 import org.opengis.metadata.Metadata;
 import org.opengis.referencing.ReferenceSystem;
-import org.opengis.util.FactoryException;
+import org.apache.sis.io.wkt.WKTFormat;
+import org.apache.sis.io.wkt.Warnings;
 import org.apache.sis.storage.DataStore;
 import org.apache.sis.storage.StorageConnector;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.metadata.iso.DefaultMetadata;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.CharSequences;
 import org.apache.sis.referencing.CRS;
 
-import static java.util.Collections.singleton;
-
 
 /**
  * A data store which creates data objects from a WKT definition.
@@ -53,10 +59,10 @@ final class Store extends DataStore {
     private Reader source;
 
     /**
-     * The parsed object, initialized only when first needed.
-     * May still {@code null} if the parsing failed.
+     * The parsed objects, filled only when first needed.
+     * May still be empty if the parsing failed.
      */
-    private Object object;
+    private final List<Object> objects;
 
     /**
      * The metadata object, created when first needed.
@@ -70,8 +76,9 @@ final class Store extends DataStore {
      * @throws DataStoreException If an error occurred while opening the stream.
      */
     public Store(final StorageConnector connector) throws DataStoreException {
-        name = connector.getStorageName();
-        source = connector.getStorageAs(Reader.class);
+        objects = new ArrayList<Object>();
+        name    = connector.getStorageName();
+        source  = connector.getStorageAs(Reader.class);
         connector.closeAllExcept(source);
         if (source == null) {
             throw new DataStoreException(Errors.format(Errors.Keys.CanNotOpen_1, name));
@@ -79,44 +86,72 @@ final class Store extends DataStore {
     }
 
     /**
-     * Parses the object, if not already done. Note that {@link #object} may still be null
+     * Parses the objects, if not already done. Note that {@link #objects} may still be empty
      * if an exception has been thrown at this invocation time or in previous invocation.
      *
-     * @return The metadata associated to the parsed object, or {@code null} if none.
-     * @throws DataStoreException If an error occurred during the parsing process.
+     * @throws DataStoreException if an error occurred during the parsing process.
      */
-    @Override
-    public Metadata getMetadata() throws DataStoreException {
-        if (metadata == null) {
-            final Reader in = source;
-            source = null;                      // Cleared first in case of error.
-            if (in != null) try {
+    private void parse() throws DataStoreException {
+        final Reader in = source;
+        if (in != null) try {
+            source = null;                                                  // Cleared first
in case of error.
+            final String wkt;
+            try {
                 char[] buffer = new char[StoreProvider.READ_AHEAD_LIMIT];
                 int length = 0;
-                try {
-                    int n;
-                    while ((n = in.read(buffer, length, buffer.length - length)) >= 0)
{
-                        if ((length += n) >= buffer.length) {
-                            if (n >= Integer.MAX_VALUE / 1024) {     // Arbitrary size
limit.
-                                throw new DataStoreException(Errors.format(Errors.Keys.ExcessiveStringSize));
-                            }
-                            buffer = Arrays.copyOf(buffer, n << 1);
+                int n;
+                while ((n = in.read(buffer, length, buffer.length - length)) >= 0) {
+                    if ((length += n) >= buffer.length) {
+                        if (n >= Integer.MAX_VALUE / 1024) {     // Arbitrary size limit.
+                            throw new DataStoreException(Errors.format(Errors.Keys.ExcessiveStringSize));
                         }
+                        buffer = Arrays.copyOf(buffer, n << 1);
                     }
-                } finally {
-                    in.close();
                 }
-                object = CRS.fromWKT(String.valueOf(buffer, 0, length));
-            } catch (IOException e) {
-                throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, name),
e);
-            } catch (FactoryException e) {
-                throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, name),
e);
+                wkt = String.valueOf(buffer, 0, length);
+            } finally {
+                in.close();
             }
-            if (object instanceof ReferenceSystem) {
-                final DefaultMetadata d = new DefaultMetadata();
-                d.setReferenceSystemInfo(singleton((ReferenceSystem) object));
-                metadata = d;
+            final ParsePosition pos = new ParsePosition(0);
+            final WKTFormat parser = new WKTFormat(null, null);
+            do {
+                objects.add(parser.parse(wkt, pos));
+                pos.setIndex(CharSequences.skipLeadingWhitespaces(wkt, pos.getIndex(), wkt.length()));
+                final Warnings warnings = parser.getWarnings();
+                if (warnings != null) {
+                    final LogRecord record = new LogRecord(Level.WARNING, warnings.toString());
+                    record.setSourceClassName(Store.class.getName());
+                    record.setSourceMethodName("getMetadata");          // Public facade
for this method.
+                    listeners.warning(record);
+                }
+            } while (pos.getIndex() < wkt.length());
+        } catch (IOException e) {                                       // Multi-catch on
the JDK7 branch.
+            throw new DataStoreException(Errors.format(Errors.Keys.CanNotParseFile_2, "WKT",
name), e);
+        } catch (ParseException e) {
+            throw new DataStoreException(Errors.format(Errors.Keys.CanNotParseFile_2, "WKT",
name), e);
+        }
+    }
+
+    /**
+     * Returns the metadata associated to the parsed objects, or {@code null} if none.
+     * The current implementation retains only instances of {@link ReferenceSystem}
+     * and ignore other cases.
+     *
+     * @return The metadata associated to the parsed object, or {@code null} if none.
+     * @throws DataStoreException if an error occurred during the parsing process.
+     */
+    @Override
+    public Metadata getMetadata() throws DataStoreException {
+        if (metadata == null) {
+            parse();
+            DefaultMetadata d = null;
+            for (final Object object : objects) {
+                if (object instanceof ReferenceSystem) {
+                    if (d == null) d = new DefaultMetadata();
+                    d.getReferenceSystemInfo().add((ReferenceSystem) object);
+                }
             }
+            metadata = d;
         }
         return metadata;
     }
@@ -130,7 +165,7 @@ final class Store extends DataStore {
     public void close() throws DataStoreException {
         final Reader s = source;
         source = null;                  // Cleared first in case of failure.
-        object = null;
+        objects.clear();
         if (s != null) try {
             s.close();
         } catch (IOException e) {

Modified: sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java?rev=1733379&r1=1733378&r2=1733379&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
[UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
[UTF-8] Wed Mar  2 22:05:05 2016
@@ -81,7 +81,7 @@ final class Store extends DataStore {
      * Creates a new XML store from the given file, URL or stream.
      *
      * @param  connector Information about the storage (URL, stream, <i>etc</i>).
-     * @throws DataStoreException If an error occurred while opening the stream.
+     * @throws DataStoreException if an error occurred while opening the stream.
      */
     public Store(final StorageConnector connector) throws DataStoreException {
         name = connector.getStorageName();
@@ -139,7 +139,7 @@ final class Store extends DataStore {
      * Unmarshal the object, if not already done. Note that {@link #object} may still be
null
      * if an exception has been thrown at this invocation time or in previous invocation.
      *
-     * @throws DataStoreException If an error occurred during the unmarshalling process.
+     * @throws DataStoreException if an error occurred during the unmarshalling process.
      */
     private void unmarshal() throws DataStoreException {
         final StreamSource s = source;
@@ -164,12 +164,14 @@ final class Store extends DataStore {
      *
      * <ul>
      *   <li>If the unmarshalled object implements the {@link Metadata} interface,
then it is returned directly.</li>
+     *   <li>Otherwise if the unmarshalled object implements {@link ReferenceSystem},
then it is wrapped in the
+     *       <cite>"reference system info"</cite> property of a new {@link DefaultMetadata}
instance.</li>
      * </ul>
      *
      * Other cases may be added in any future SIS version.
      *
      * @return The metadata associated to the unmarshalled object, or {@code null} if none.
-     * @throws DataStoreException If an error occurred during the unmarshalling process.
+     * @throws DataStoreException if an error occurred during the unmarshalling process.
      */
     @Override
     public Metadata getMetadata() throws DataStoreException {
@@ -189,7 +191,7 @@ final class Store extends DataStore {
     /**
      * Closes this data store and releases any underlying resources.
      *
-     * @throws DataStoreException If an error occurred while closing this data store.
+     * @throws DataStoreException if an error occurred while closing this data store.
      */
     @Override
     public void close() throws DataStoreException {



Mime
View raw message