sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1785839 - in /sis/branches/JDK8/core: sis-feature/src/main/java/org/apache/sis/feature/ sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/ sis-ref...
Date Tue, 07 Mar 2017 13:54:06 GMT
Author: desruisseaux
Date: Tue Mar  7 13:54:06 2017
New Revision: 1785839

URL: http://svn.apache.org/viewvc?rev=1785839&view=rev
Log:
Fix LocationFormat parent class and improve documentation.

Modified:
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationFormat.java
    sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/OptionalDependency.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java?rev=1785839&r1=1785838&r2=1785839&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
[UTF-8] Tue Mar  7 13:54:06 2017
@@ -73,8 +73,11 @@ import org.apache.sis.util.Characters;
  *   └────────────┴─────────┴─────────────┴───────────┘
  * }</div>
  *
+ * Like most {@link java.text.Format} implementations, this class is not thread-safe.
+ * Each thread should use its own {@code FeatureFormat} instance or apply synchronization.
+ *
  * <div class="warning"><b>Limitation:</b>
- * Current implementation supports only formatting, not parsing.
+ * the current implementation can only format features — parsing is not yet implemented.
  * </div>
  *
  * @author  Martin Desruisseaux (Geomatys)

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java?rev=1785839&r1=1785838&r2=1785839&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] Tue Mar  7 13:54:06 2017
@@ -19,6 +19,8 @@ package org.apache.sis.internal.metadata
 import java.util.Map;
 import java.util.Collections;
 import java.util.Locale;
+import java.util.TimeZone;
+import java.text.Format;
 import javax.measure.Unit;
 import javax.measure.quantity.Length;
 import org.opengis.geometry.Envelope;
@@ -518,6 +520,19 @@ public class ReferencingServices extends
     }
 
     /**
+     * Creates a format for {@link DirectPosition} instances.
+     *
+     * @param  locale    the locale for the new {@code Format}, or {@code null} for {@code
Locale.ROOT}.
+     * @param  timezone  the timezone, or {@code null} for UTC.
+     * @return a {@link org.apache.sis.geometry.CoordinateFormat}.
+     *
+     * @since 0.8
+     */
+    public Format createCoordinateFormat(final Locale locale, final TimeZone timezone) {
+        throw moduleNotFound();
+    }
+
+    /**
      * Returns an axis direction from a pole along a meridian.
      * The given meridian is usually, but not necessarily, relative to the Greenwich meridian.
      *

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java?rev=1785839&r1=1785838&r2=1785839&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ServicesForUtility.java
[UTF-8] Tue Mar  7 13:54:06 2017
@@ -16,9 +16,11 @@
  */
 package org.apache.sis.internal.metadata;
 
+import java.text.Format;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Locale;
+import java.util.TimeZone;
 import javax.sql.DataSource;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Role;
@@ -48,7 +50,7 @@ import static java.util.Collections.sing
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
- * @version 0.7
+ * @version 0.8
  * @module
  */
 public final class ServicesForUtility extends MetadataServices {
@@ -258,4 +260,18 @@ public final class ServicesForUtility ex
         }
         return ReferencingServices.getInstance().getInformation(key, locale);
     }
+
+    /**
+     * Creates a format for {@link org.opengis.geometry.DirectPosition} instances.
+     *
+     * @param  locale    the locale for the new {@code Format}, or {@code null} for {@code
Locale.ROOT}.
+     * @param  timezone  the timezone, or {@code null} for UTC.
+     * @return a {@link org.apache.sis.geometry.CoordinateFormat}.
+     *
+     * @since 0.8
+     */
+    @Override
+    public Format createCoordinateFormat(final Locale locale, final TimeZone timezone) {
+        return ReferencingServices.getInstance().createCoordinateFormat(locale, timezone);
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationFormat.java?rev=1785839&r1=1785838&r2=1785839&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/LocationFormat.java
[UTF-8] Tue Mar  7 13:54:06 2017
@@ -42,7 +42,7 @@ import org.opengis.metadata.citation.Par
 import org.opengis.geometry.Envelope;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.geometry.coordinate.Position;
-import org.apache.sis.io.CompoundFormat;
+import org.apache.sis.io.TabularFormat;
 import org.apache.sis.io.TableAppender;
 import org.apache.sis.measure.UnitFormat;
 import org.apache.sis.measure.Range;
@@ -87,9 +87,11 @@ import org.apache.sis.util.resources.Voc
  * }
  * </div>
  *
+ * Like most {@link java.text.Format} implementations, this class is not thread-safe.
+ * Each thread should use its own {@code LocationFormat} instance or apply synchronization.
+ *
  * <div class="warning"><b>Limitation:</b>
- * Current implementation supports only formatting, not parsing.
- * This class is not thread-safe.
+ * the current implementation can only format locations — parsing is not yet implemented.
  * </div>
  *
  * @author  Martin Desruisseaux (Geomatys)
@@ -97,7 +99,7 @@ import org.apache.sis.util.resources.Voc
  * @version 0.8
  * @module
  */
-public class LocationFormat extends CompoundFormat<Location> {
+public class LocationFormat extends TabularFormat<Location> {
     /**
      * For cross-version compatibility.
      */
@@ -206,7 +208,7 @@ public class LocationFormat extends Comp
         ArgumentChecks.ensureNonNull("location", location);
         final Locale locale = getLocale(Locale.Category.DISPLAY);
         final Vocabulary vocabulary = Vocabulary.getResources(locale);
-        final TableAppender table = new TableAppender(toAppendTo, "│ ", " ", " │");
+        final TableAppender table = new TableAppender(toAppendTo, "│ ", columnSeparator,
" │");
         table.setMultiLinesCells(true);
         /*
          * Location type.
@@ -224,11 +226,11 @@ public class LocationFormat extends Comp
         if (alt != null && !alt.isEmpty()) {
             boolean isFirst = true;
             vocabulary.appendLabel(Vocabulary.Keys.AlternativeIdentifiers, table);
-            table.nextColumn();
+            nextColumn(table);
             for (final InternationalString id : alt) {
                 if (!isFirst) {
                     isFirst = false;
-                    table.append(System.lineSeparator());
+                    table.append(lineSeparator);
                 }
                 table.append(id);
             }
@@ -399,7 +401,7 @@ public class LocationFormat extends Comp
                 final String g = (geographic != null) ? geographic[i] : "";
                 if (!p.isEmpty() || !g.isEmpty()) {
                     vocabulary.appendLabel(BOUND_KEY[i], table);
-                    table.nextColumn();
+                    nextColumn(table);
                     table.append(CharSequences.spaces(maxProjLength - p.length())).append(p);
                     table.append(CharSequences.spaces(maxUnitLength - u.length())).append(u).append(separator);
                     table.append(CharSequences.spaces(maxGeogLength - g.length())).append(g);
@@ -421,7 +423,7 @@ public class LocationFormat extends Comp
         table.flush();
         if (warning != null) {
             vocabulary.appendLabel(Vocabulary.Keys.Warnings, toAppendTo);
-            toAppendTo.append(warning.toString()).append(System.lineSeparator());
+            toAppendTo.append(warning.toString()).append(lineSeparator);
         }
     }
 
@@ -454,17 +456,24 @@ public class LocationFormat extends Comp
      * @param key          key of the label to append.
      * @param value        value to append, or {@code null} if none.
      */
-    private static void append(final TableAppender table, final Vocabulary vocabulary, final
short key,
-            final String value) throws IOException
+    private void append(final TableAppender table, final Vocabulary vocabulary, final short
key, final String value)
+            throws IOException
     {
         if (value != null) {
             vocabulary.appendLabel(key, table);
-            table.nextColumn();
+            nextColumn(table);
             table.append(value).nextLine();
         }
     }
 
     /**
+     * Moves to the next column.
+     */
+    private void nextColumn(final TableAppender table) {
+        table.append(beforeFill).nextColumn(fillCharacter);
+    }
+
+    /**
      * Unsupported operation.
      *
      * @param  text  the character sequence for the location to parse.

Modified: sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java?rev=1785839&r1=1785838&r2=1785839&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing-by-identifiers/src/main/java/org/apache/sis/referencing/gazetteer/MilitaryGridReferenceSystem.java
[UTF-8] Tue Mar  7 13:54:06 2017
@@ -78,9 +78,10 @@ import org.opengis.referencing.gazetteer
  *         └─<b>Grid coordinate</b>      (example: “12345 67890”)<br>
  * </blockquote>
  *
- * <p>Conversions between MGRS references and spatial coordinates can be performed
by the {@link Coder Coder}
- * inner class. The result of decoding a MGRS reference is an envelope rather than a point,
- * but a representative point can be obtained.</p>
+ * <p>Conversions between MGRS references and spatial coordinates can be performed
by the {@link Coder Coder} inner class.
+ * The result of decoding a MGRS reference is an envelope rather than a point, but a representative
point can be obtained.
+ * The encoding and decoding processes take in account Norway and Svalbard special cases
(they have wider UTM zones for
+ * historical reasons).</p>
  *
  * <div class="note"><b>Example:</b>
  * the following code:
@@ -120,6 +121,7 @@ import org.opengis.referencing.gazetteer
  * @version 0.8
  * @module
  *
+ * @see CommonCRS#universal(double, double)
  * @see <a href="https://en.wikipedia.org/wiki/Military_Grid_Reference_System">Military
Grid Reference System on Wikipedia</a>
  */
 public class MilitaryGridReferenceSystem extends ReferencingByIdentifiers {

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java?rev=1785839&r1=1785838&r2=1785839&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
[UTF-8] Tue Mar  7 13:54:06 2017
@@ -22,6 +22,8 @@ import java.util.Iterator;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Locale;
+import java.util.TimeZone;
+import java.text.Format;
 import javax.measure.Unit;
 import javax.measure.quantity.Length;
 
@@ -62,6 +64,7 @@ import org.opengis.geometry.Envelope;
 
 import org.apache.sis.geometry.Envelopes;
 import org.apache.sis.geometry.DirectPosition2D;
+import org.apache.sis.geometry.CoordinateFormat;
 import org.apache.sis.referencing.CRS;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.referencing.IdentifiedObjects;
@@ -575,6 +578,20 @@ public final class ServicesForMetadata e
     }
 
     /**
+     * Creates a format for {@link DirectPosition} instances.
+     *
+     * @param  locale    the locale for the new {@code Format}, or {@code null} for {@code
Locale.ROOT}.
+     * @param  timezone  the timezone, or {@code null} for UTC.
+     * @return a {@link org.apache.sis.geometry.CoordinateFormat}.
+     *
+     * @since 0.8
+     */
+    @Override
+    public Format createCoordinateFormat(final Locale locale, final TimeZone timezone) {
+        return new CoordinateFormat(locale, timezone);
+    }
+
+    /**
      * Returns an axis direction from a pole along a meridian.
      * The given meridian is usually, but not necessarily, relative to the Greenwich meridian.
      *

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java?rev=1785839&r1=1785838&r2=1785839&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
[UTF-8] Tue Mar  7 13:54:06 2017
@@ -97,9 +97,11 @@ import static org.apache.sis.util.collec
  *   <tr><td><code>{@linkplain IdentifiedObject}[]</code></td><td>Accepted
only for {@link ContentLevel#NAME_SUMMARY}.</td></tr>
  * </table>
  *
+ * Like most {@link java.text.Format} implementations, this class is not thread-safe.
+ * Each thread should use its own {@code ParameterFormat} instance or apply synchronization.
+ *
  * <div class="warning"><b>Limitation:</b>
- * Current implementation supports only formatting, not parsing.
- * This class is not thread-safe.
+ * the current implementation can only format parameters — parsing is not yet implemented.
  * </div>
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/OptionalDependency.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/OptionalDependency.java?rev=1785839&r1=1785838&r2=1785839&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/OptionalDependency.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/OptionalDependency.java
[UTF-8] Tue Mar  7 13:54:06 2017
@@ -46,6 +46,7 @@ public abstract class OptionalDependency
      * @param dependency  the Maven artifact name (<strong>not</strong> a name
from the {@link Modules} class)
      *        of the optional module on which the {@code module} depend.
      */
+    @SuppressWarnings("ThisEscapedInObjectConstruction")
     protected OptionalDependency(final String module, final String dependency) {
         super(module);
         this.dependency = dependency;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java?rev=1785839&r1=1785838&r2=1785839&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/MetadataServices.java
[UTF-8] Tue Mar  7 13:54:06 2017
@@ -16,7 +16,9 @@
  */
 package org.apache.sis.internal.util;
 
+import java.text.Format;
 import java.util.Locale;
+import java.util.TimeZone;
 import org.opengis.metadata.citation.Citation;
 import org.apache.sis.internal.simple.CitationConstant;
 import org.apache.sis.internal.system.Modules;
@@ -30,7 +32,7 @@ import org.apache.sis.internal.system.Op
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
- * @version 0.7
+ * @version 0.8
  * @module
  */
 public class MetadataServices extends OptionalDependency {
@@ -132,4 +134,17 @@ public class MetadataServices extends Op
     public String getInformation(String key, Locale locale) {
         return null;
     }
+
+    /**
+     * Creates a format for {@link org.opengis.geometry.DirectPosition} instances.
+     *
+     * @param  locale    the locale for the new {@code Format}, or {@code null} for {@code
Locale.ROOT}.
+     * @param  timezone  the timezone, or {@code null} for UTC.
+     * @return a {@link org.apache.sis.geometry.CoordinateFormat}.
+     *
+     * @since 0.8
+     */
+    public Format createCoordinateFormat(final Locale locale, final TimeZone timezone) {
+        throw moduleNotFound();
+    }
 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java?rev=1785839&r1=1785838&r2=1785839&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
[UTF-8] Tue Mar  7 13:54:06 2017
@@ -32,6 +32,7 @@ import java.text.SimpleDateFormat;
 import javax.measure.Unit;
 
 import org.opengis.referencing.IdentifiedObject;
+import org.opengis.geometry.DirectPosition;
 import org.apache.sis.measure.Angle;
 import org.apache.sis.measure.AngleFormat;
 import org.apache.sis.measure.Range;
@@ -40,6 +41,7 @@ import org.apache.sis.measure.UnitFormat
 import org.apache.sis.util.Localized;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.internal.util.MetadataServices;
 import org.apache.sis.internal.util.LocalizedParseException;
 
 import static org.apache.sis.internal.util.StandardDateFormat.UTC;
@@ -54,22 +56,38 @@ import java.io.UncheckedIOException;
  * large blocks of data, for example a metadata tree or a <cite>Well Known Text</cite>
(WKT).
  * Those blocks of data usually contain smaller elements like numbers and dates, whose parsing
  * and formatting can be delegated to {@link NumberFormat} and {@link DateFormat} respectively.
+ * Subclasses can obtain instances of those formats by call to {@link #getFormat(Class)}
where
+ * the argument is the type of the value to parse or format.
+ * {@code CompoundFormat} supports at least the following value types, but subclasses may
add more types:
  *
- * <p>Since {@code CompoundFormat} may work on larger texts than the usual {@code Format}
classes,
+ * <table class="sis">
+ *   <caption>Supported value types</caption>
+ *   <tr><th>Value type</th>              <th>Format type</th>
                                     <th>Remarks</th></tr>
+ *   <tr><td>{@link DirectPosition}</td>  <td>{@link org.apache.sis.geometry.CoordinateFormat}</td>
<td>Requires {@code sis-referencing} module.</td></tr>
+ *   <tr><td>{@link Angle}</td>           <td>{@link AngleFormat}</td>
                             <td></td></tr>
+ *   <tr><td>{@link Date}</td>            <td>{@link DateFormat}</td>
                              <td>Timezone specified by {@link #getTimeZone()}.</td></tr>
+ *   <tr><td>{@link Number}</td>          <td>{@link NumberFormat}</td>
                            <td></td></tr>
+ *   <tr><td>{@link Unit}</td>            <td>{@link UnitFormat}</td>
                              <td></td></tr>
+ *   <tr><td>{@link Range}</td>           <td>{@link RangeFormat}</td>
                             <td></td></tr>
+ *   <tr><td>{@link Class}</td>           <td>(internal)</td>
                                      <td></td></tr>
+ * </table>
+ *
+ * <div class="section">Sources and destinations</div>
+ * Since {@code CompoundFormat} may work on larger texts than the usual {@code Format} classes,
  * it defines {@code parse} and {@code format} methods working with arbitrary {@link CharSequence}
  * and {@link Appendable} instances. The standard {@code Format} methods redirect to the
above-cited
- * methods.</p>
- *
- * <p>The abstract methods to be defined by subclasses are:</p>
+ * methods.
  *
+ * <div class="section">Sub-classing</div>
+ * The abstract methods to be defined by subclasses are:
  * <ul>
- *   <li>{@link #getValueType()} returns the {@code <T>} class or a subclass.</li>
- *   <li>{@link #parse(CharSequence, ParsePosition)} may throws {@code ParseException}.</li>
- *   <li>{@link #format(Object, Appendable)} may throws {@code IOException}.</li>
+ *   <li>{@link #getValueType()}</li>
+ *   <li>{@link #format(Object, Appendable)}</li>
+ *   <li>{@link #parse(CharSequence, ParsePosition)}</li>
  * </ul>
  *
  * <div class="note"><b>API note:</b>
- * In the standard {@link Format} class, the {@code parse} methods either accept a {@link
ParsePosition} argument
+ * in the standard {@link Format} class, the {@code parse} methods either accept a {@link
ParsePosition} argument
  * and returns {@code null} on error, or does not take position argument and throws a {@link
ParseException} on error.
  * In this {@code CompoundFormat} class, the {@code parse} method both takes a {@code ParsePosition}
argument and
  * throws a {@code ParseException} on error. This allows both substring parsing and more
accurate exception message
@@ -213,13 +231,14 @@ public abstract class CompoundFormat<T>
      *     <ul>
      *       <li>this method returns {@code null}, or</li>
      *       <li>a {@code ParseException} is thrown with an {@linkplain ParseException#getErrorOffset()
error offset}
-     *           set to the index of the first unparsable character. This is usually the
same information than the
-     *           above-cited {@code pos} error index, but implementations are free to adopt
a slightly different policy.</li>
+     *           set to the index of the first unparsable character.</li>
      *     </ul>
      *   </li>
      * </ul>
      *
-     * <div class="note"><b>Example:</b>
+     * <div class="note"><b>Note:</b>
+     * if a {@code ParseException} is thrown, its error offset is usually the same than the
{@code ParsePosition}
+     * error index, but implementations are free to adopt a slightly different policy. For
example
      * if parsing of the {@code "30.0 40,0"} coordinate fails on the coma in the last number,
then the {@code pos}
      * {@linkplain ParsePosition#getErrorIndex() error index} may be set to 5 (the beginning
of the {@code "40.0"}
      * character sequence) or to 7 (the coma position), depending on the implementation.</div>
@@ -230,6 +249,7 @@ public abstract class CompoundFormat<T>
      *
      * @param  text  the character sequence for the object to parse.
      * @param  pos   the position where to start the parsing.
+     *               On return, the position where the parsing stopped or where an error
occurred.
      * @return the parsed object, or {@code null} if the text is not recognized.
      * @throws ParseException if an error occurred while parsing the object.
      */
@@ -399,18 +419,18 @@ public abstract class CompoundFormat<T>
      * Creates a new format to use for parsing and formatting values of the given type.
      * This method is invoked by {@link #getFormat(Class)} the first time that a format
      * is needed for the given type.
-     *
-     * <p>The default implementation creates the following formats:</p>
+     * The class given in argument can be any of the classes listed in the "Value type" column
below:
      *
      * <table class="sis">
-     *   <caption>Supported formats by type</caption>
-     *   <tr><th>Value type</th>     <th>Format</th></tr>
-     *   <tr><td>{@link Angle}</td>  <td>{@link AngleFormat}</td></tr>
-     *   <tr><td>{@link Date}</td>   <td>{@link DateFormat}</td></tr>
-     *   <tr><td>{@link Number}</td> <td>{@link NumberFormat}</td></tr>
-     *   <tr><td>{@link Unit}</td>   <td>{@link UnitFormat}</td></tr>
-     *   <tr><td>{@link Range}</td>  <td>{@link RangeFormat}</td></tr>
-     *   <tr><td>{@link Class}</td>  <td>(internal)</td></tr>
+     *   <caption>Supported value types</caption>
+     *   <tr><th>Value type</th>              <th>Format type</th></tr>
+     *   <tr><td>{@link DirectPosition}</td>  <td>{@link org.apache.sis.geometry.CoordinateFormat}</td></tr>
+     *   <tr><td>{@link Angle}</td>           <td>{@link AngleFormat}</td></tr>
+     *   <tr><td>{@link Date}</td>            <td>{@link DateFormat}</td></tr>
+     *   <tr><td>{@link Number}</td>          <td>{@link NumberFormat}</td></tr>
+     *   <tr><td>{@link Unit}</td>            <td>{@link UnitFormat}</td></tr>
+     *   <tr><td>{@link Range}</td>           <td>{@link RangeFormat}</td></tr>
+     *   <tr><td>{@link Class}</td>           <td>(internal)</td></tr>
      * </table>
      *
      * Subclasses can override this method for adding more types, or for configuring the
@@ -453,6 +473,8 @@ public abstract class CompoundFormat<T>
             return new UnitFormat(locale);
         } else if (valueType == Range.class) {
             return new RangeFormat(locale);
+        } else if (valueType == DirectPosition.class) {
+            return MetadataServices.getInstance().createCoordinateFormat(locale, getTimeZone());
         } else if (valueType == Class.class) {
             return ClassFormat.INSTANCE;
         } else {

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java?rev=1785839&r1=1785838&r2=1785839&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java
[UTF-8] Tue Mar  7 13:54:06 2017
@@ -41,16 +41,32 @@ import static java.lang.Math.*;
 /**
  * Formats a {@link Statistics} object.
  * By default, newly created {@code StatisticsFormat} instances will format statistical values
- * in a tabular format using spaces as the column separator. This default configuration matches
- * the {@link Statistics#toString()} format.
+ * in a tabular format using spaces as the column separator.
  *
- * <div class="section">Limitations</div>
- * The current implementation can only format statistics - parsing is not yet implemented.
+ * <div class="note"><b>Example:</b>
+ * {@preformat text
+ *     Number of values:     8726
+ *     Minimum value:       6.853
+ *     Maximum value:       8.259
+ *     Mean value:          7.421
+ *     Root Mean Square:    7.846
+ *     Standard deviation:  6.489
+ * }
+ * </div>
+ *
+ * Like most {@link java.text.Format} implementations, this class is not thread-safe.
+ * Each thread should use its own {@code StatisticsFormat} instance or apply synchronization.
+ *
+ * <div class="warning"><b>Limitation:</b>
+ * the current implementation can only format statistics — parsing is not yet implemented.
+ * </div>
  *
  * @author  Martin Desruisseaux (MPO, IRD, Geomatys)
  * @since   0.3
  * @version 0.8
  * @module
+ *
+ * @see Statistics#toString()
  */
 public class StatisticsFormat extends TabularFormat<Statistics> {
     /**



Mime
View raw message