sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1684671 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-metadata/src/test/java/org/apache/sis/io/wkt/ sis-referencing/src/test/java/org/apache/sis/io/wkt/
Date Wed, 10 Jun 2015 13:42:06 GMT
Author: desruisseaux
Date: Wed Jun 10 13:42:05 2015
New Revision: 1684671

URL: http://svn.apache.org/r1684671
Log:
WKT: GeodeticObjectParser should use the java.text.Format instances provided by WKTFormat.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1684671&r1=1684670&r2=1684671&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] Wed Jun 10 13:42:05 2015
@@ -22,6 +22,8 @@ import java.util.Locale;
 import java.util.HashMap;
 import java.util.ArrayList;
 import java.util.Date;
+import java.text.DateFormat;
+import java.text.NumberFormat;
 import java.text.ParsePosition;
 import java.text.ParseException;
 import javax.measure.unit.Unit;
@@ -156,7 +158,7 @@ final class GeodeticObjectParser extends
      * Creates a parser using the default set of symbols and factories.
      */
     public GeodeticObjectParser() {
-        this(Symbols.getDefault(), Convention.DEFAULT, false, null, null);
+        this(Symbols.getDefault(), null, null, Convention.DEFAULT, false, null, null);
     }
 
     /**
@@ -176,7 +178,7 @@ final class GeodeticObjectParser extends
     public GeodeticObjectParser(final Map<String,?> defaultProperties,
             final ObjectFactory factories, final MathTransformFactory mtFactory)
     {
-        super(Symbols.getDefault(), mtFactory, (Locale) defaultProperties.get(Errors.LOCALE_KEY));
+        super(Symbols.getDefault(), null, null, mtFactory, (Locale) defaultProperties.get(Errors.LOCALE_KEY));
         crsFactory    = (CRSFactory)   factories;
         csFactory     = (CSFactory)    factories;
         datumFactory  = (DatumFactory) factories;
@@ -188,17 +190,21 @@ final class GeodeticObjectParser extends
 
     /**
      * Constructs a parser for the specified set of symbols using the specified set of factories.
+     * This constructor is for {@link WKTFormat} usage only.
      *
      * @param symbols       The set of symbols to use.
+     * @param numberFormat  The number format provided by {@link WKTFormat}, or {@code null}
for a default format.
+     * @param dateFormat    The date format provided by {@link WKTFormat}, or {@code null}
for a default format.
      * @param convention    The WKT convention to use.
      * @param isAxisIgnored {@code true} if {@code AXIS} elements should be ignored.
      * @param errorLocale   The locale for error messages (not for parsing), or {@code null}
for the system default.
      * @param factories     On input, the factories to use. On output, the factories used.
Can be null.
      */
-    GeodeticObjectParser(final Symbols symbols, final Convention convention, final boolean
isAxisIgnored,
-            final Locale errorLocale, final Map<Class<?>,Factory> factories)
+    GeodeticObjectParser(final Symbols symbols, final NumberFormat numberFormat, final DateFormat
dateFormat,
+            final Convention convention, final boolean isAxisIgnored, final Locale errorLocale,
+            final Map<Class<?>,Factory> factories)
     {
-        super(symbols, getFactory(MathTransformFactory.class, factories), errorLocale);
+        super(symbols, numberFormat, dateFormat, getFactory(MathTransformFactory.class, factories),
errorLocale);
         crsFactory   = getFactory(CRSFactory.class,   factories);
         csFactory    = getFactory(CSFactory.class,    factories);
         datumFactory = getFactory(DatumFactory.class, factories);

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java?rev=1684671&r1=1684670&r2=1684671&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java
[UTF-8] Wed Jun 10 13:42:05 2015
@@ -17,6 +17,8 @@
 package org.apache.sis.io.wkt;
 
 import java.util.Locale;
+import java.text.DateFormat;
+import java.text.NumberFormat;
 import java.text.ParseException;
 import javax.measure.unit.Unit;
 import javax.measure.quantity.Angle;
@@ -92,18 +94,22 @@ class MathTransformParser extends Parser
      * @param mtFactory The factory to use to create {@link MathTransform} objects.
      */
     public MathTransformParser(final MathTransformFactory mtFactory) {
-        this(Symbols.getDefault(), mtFactory, null);
+        this(Symbols.getDefault(), null, null, mtFactory, null);
     }
 
     /**
      * Creates a parser using the specified set of symbols and factory.
      *
-     * @param symbols     The set of symbols to use.
-     * @param mtFactory   The factory to use to create {@link MathTransform} objects.
-     * @param errorLocale The locale for error messages (not for parsing), or {@code null}
for the system default.
-     */
-    public MathTransformParser(final Symbols symbols, final MathTransformFactory mtFactory,
final Locale errorLocale) {
-        super(symbols, errorLocale);
+     * @param symbols       The set of symbols to use.
+     * @param numberFormat  The number format provided by {@link WKTFormat}, or {@code null}
for a default format.
+     * @param dateFormat    The date format provided by {@link WKTFormat}, or {@code null}
for a default format.
+     * @param mtFactory     The factory to use to create {@link MathTransform} objects.
+     * @param errorLocale   The locale for error messages (not for parsing), or {@code null}
for the system default.
+     */
+    MathTransformParser(final Symbols symbols, final NumberFormat numberFormat, final DateFormat
dateFormat,
+            final MathTransformFactory mtFactory, final Locale errorLocale)
+    {
+        super(symbols, numberFormat, dateFormat, errorLocale);
         this.mtFactory = mtFactory;
         ensureNonNull("mtFactory", mtFactory);
     }

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java?rev=1684671&r1=1684670&r2=1684671&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java [UTF-8]
Wed Jun 10 13:42:05 2015
@@ -96,14 +96,20 @@ abstract class Parser implements WKTPars
     /**
      * Constructs a parser using the specified set of symbols.
      *
-     * @param symbols     The set of symbols to use.
-     * @param errorLocale The locale for error messages (not for parsing), or {@code null}
for the system default.
+     * @param symbols       The set of symbols to use.
+     * @param numberFormat  The number format provided by {@link WKTFormat}, or {@code null}
for a default format.
+     * @param dateFormat    The date format provided by {@link WKTFormat}, or {@code null}
for a default format.
+     * @param errorLocale   The locale for error messages (not for parsing), or {@code null}
for the system default.
      */
-    Parser(final Symbols symbols, final Locale errorLocale) {
-        this.errorLocale = errorLocale;
+    Parser(final Symbols symbols, NumberFormat numberFormat, final DateFormat dateFormat,
final Locale errorLocale) {
         ensureNonNull("symbols", symbols);
-        this.symbols = symbols;
-        numberFormat = symbols.createNumberFormat();
+        if (numberFormat == null) {
+            numberFormat = symbols.createNumberFormat();
+        }
+        this.symbols      = symbols;
+        this.numberFormat = numberFormat;
+        this.dateFormat   = dateFormat;
+        this.errorLocale  = errorLocale;
         if (SCIENTIFIC_NOTATION && numberFormat instanceof DecimalFormat) {
             final DecimalFormat decimalFormat = (DecimalFormat) numberFormat;
             exponentSymbol = decimalFormat.getDecimalFormatSymbols().getExponentSeparator();

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java?rev=1684671&r1=1684670&r2=1684671&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
[UTF-8] Wed Jun 10 13:42:05 2015
@@ -503,7 +503,10 @@ public class WKTFormat extends CompoundF
             if (factories == null) {
                 factories = new HashMap<>();
             }
-            parser = new GeodeticObjectParser(symbols, convention, false, getLocale(Locale.Category.DISPLAY),
factories);
+            parser = new GeodeticObjectParser(symbols,
+                    (NumberFormat) getFormat(Number.class),
+                    (DateFormat)   getFormat(Date.class),
+                    convention, false, getLocale(Locale.Category.DISPLAY), factories);
         }
         return parser.parseObject(text.toString(), pos);
     }

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java?rev=1684671&r1=1684670&r2=1684671&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java
[UTF-8] Wed Jun 10 13:42:05 2015
@@ -40,7 +40,7 @@ public final strictfp class ElementTest
     /**
      * A dummy parser to be given to the {@link Element} constructor.
      */
-    private final Parser parser = new Parser(Symbols.SQUARE_BRACKETS, Locale.ENGLISH) {
+    private final Parser parser = new Parser(Symbols.SQUARE_BRACKETS, null, null, Locale.ENGLISH)
{
         @Override Object parseObject(Element element) throws ParseException {
             throw new UnsupportedOperationException();
         }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java?rev=1684671&r1=1684670&r2=1684671&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
[UTF-8] Wed Jun 10 13:42:05 2015
@@ -87,7 +87,7 @@ public final strictfp class GeodeticObje
      */
     private void setConvention(final Convention convention, final boolean isAxisIgnored)
{
         final GeodeticObjectParser p = parser;
-        parser = new GeodeticObjectParser(p.symbols, convention, isAxisIgnored, p.errorLocale,
null);
+        parser = new GeodeticObjectParser(p.symbols, null, null, convention, isAxisIgnored,
p.errorLocale, null);
     }
 
     /**



Mime
View raw message