sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1822268 [7/7] - in /sis/trunk: ./ application/sis-console/src/main/java/org/apache/sis/console/ application/sis-javafx/ core/sis-build-helper/ core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/ core/sis-build-helper/src/ma...
Date Fri, 26 Jan 2018 10:48:29 GMT
Modified: sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamReader.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamReader.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamReader.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamReader.java
[UTF-8] Fri Jan 26 10:48:27 2018
@@ -43,12 +43,11 @@ import org.apache.sis.util.collection.Ba
 import org.apache.sis.util.resources.Errors;
 
 // Branch-dependent imports
-import org.apache.sis.internal.jdk8.Spliterator;
-import org.apache.sis.internal.jdk8.Consumer;
-import org.apache.sis.internal.jdk8.Predicate;
-import org.apache.sis.internal.jdk8.Temporal;
-import org.apache.sis.internal.jdk8.Instant;
-import java.text.ParseException;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.time.temporal.Temporal;
+import java.time.format.DateTimeParseException;
 import org.apache.sis.feature.AbstractFeature;
 
 
@@ -129,11 +128,6 @@ public abstract class StaxStreamReader e
     private Unmarshaller unmarshaller;
 
     /**
-     * Object to use for parsing dates. Created when first needed.
-     */
-    private transient StandardDateFormat dateFormat;
-
-    /**
      * Creates a new XML reader for the given data store.
      *
      * @param  owner  the data store for which this reader is created.
@@ -384,17 +378,11 @@ public abstract class StaxStreamReader e
      *
      * @return the current text element as a date, or {@code null} if empty.
      * @throws XMLStreamException if a text element can not be returned.
-     * @throws ParseException if the text can not be parsed as a date.
+     * @throws DateTimeParseException if the text can not be parsed as a date.
      */
-    protected final Date getElementAsDate() throws XMLStreamException, ParseException {
+    protected final Date getElementAsDate() throws XMLStreamException {
         final String text = getElementText();
-        if (text != null) {
-            if (dateFormat == null) {
-                dateFormat = new StandardDateFormat();
-            }
-            return dateFormat.parse(text);
-        }
-        return null;
+        return (text != null) ? StandardDateFormat.toDate(StandardDateFormat.FORMAT.parse(text))
: null;
     }
 
     /**
@@ -403,10 +391,10 @@ public abstract class StaxStreamReader e
      *
      * @return the current text element as a temporal object, or {@code null} if empty.
      * @throws XMLStreamException if a text element can not be returned.
-     * @throws ParseException if the text can not be parsed as a date.
+     * @throws DateTimeParseException if the text can not be parsed as a date.
      */
-    protected final Temporal getElementAsTemporal() throws XMLStreamException, ParseException
{
-        return Instant.create(getElementAsDate());
+    protected final Temporal getElementAsTemporal() throws XMLStreamException {
+        return StandardDateFormat.parseBest(getElementText());
     }
 
     /**

Modified: sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamWriter.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamWriter.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamWriter.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxStreamWriter.java
[UTF-8] Fri Jan 26 10:48:27 2018
@@ -32,9 +32,8 @@ import org.apache.sis.util.collection.Ba
 import org.apache.sis.util.resources.Errors;
 
 // Branch-dependent imports
-import org.apache.sis.internal.jdk8.UncheckedIOException;
-import org.apache.sis.internal.jdk8.Consumer;
-import org.apache.sis.internal.jdk8.Instant;
+import java.io.UncheckedIOException;
+import java.util.function.Consumer;
 import org.apache.sis.feature.AbstractFeature;
 
 
@@ -228,7 +227,7 @@ public abstract class StaxStreamWriter e
      */
     protected final void writeSingle(final String localName, final Date value) throws XMLStreamException
{
         if (value != null) {
-            writeSingleValue(localName, Instant.create(value));
+            writeSingleValue(localName, value.toInstant());
         }
     }
 

Modified: sis/trunk/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java
[UTF-8] Fri Jan 26 10:48:27 2018
@@ -39,8 +39,8 @@ import static org.apache.sis.test.TestUt
 import static org.apache.sis.test.TestUtilities.getSingleton;
 
 // Branch-dependent imports
-import org.apache.sis.internal.jdk8.Stream;
-import org.apache.sis.internal.jdk8.Instant;
+import java.time.Instant;
+import java.util.stream.Stream;
 import org.apache.sis.feature.AbstractFeature;
 import org.opengis.util.GenericName;
 

Modified: sis/trunk/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/WriterTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/WriterTest.java?rev=1822268&r1=1822267&r2=1822268&view=diff
==============================================================================
--- sis/trunk/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/WriterTest.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/WriterTest.java
[UTF-8] Fri Jan 26 10:48:27 2018
@@ -38,8 +38,7 @@ import org.junit.Test;
 import static org.apache.sis.test.Assert.*;
 
 // Branch-dependent imports
-import org.apache.sis.internal.jdk8.Instant;
-import org.apache.sis.internal.jdk8.Stream;
+import java.time.Instant;
 import org.apache.sis.feature.AbstractFeature;
 
 
@@ -352,7 +351,7 @@ public final strictfp class WriterTest e
         final Metadata metadata = new Metadata();
         metadata.bounds = bounds;
         metadata.creator = "DataProducer";
-        store.write(metadata, Stream.create(features));
+        store.write(metadata, features.stream());
     }
 
     /**



Mime
View raw message