sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1454587 - /sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
Date Fri, 08 Mar 2013 21:33:38 GMT
Author: desruisseaux
Date: Fri Mar  8 21:33:38 2013
New Revision: 1454587

URL: http://svn.apache.org/r1454587
Log:
Added converter to java.nio.file.Path (JDK7 only).

Modified:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java?rev=1454587&r1=1454586&r2=1454587&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/StringConverter.java
Fri Mar  8 21:33:38 2013
@@ -23,6 +23,7 @@ import java.io.ObjectStreamException;
 import java.nio.charset.UnsupportedCharsetException;
 import java.net.URISyntaxException;
 import java.net.MalformedURLException;
+import java.nio.file.InvalidPathException;
 import net.jcip.annotations.Immutable;
 
 import org.apache.sis.math.FunctionProperty;
@@ -446,6 +447,29 @@ abstract class StringConverter<T> extend
     }
 
     /**
+     * Converter from {@link String} to {@link java.nio.file.Path}.
+     */
+    @Immutable
+    static final class Path extends StringConverter<java.nio.file.Path> {
+        /** Cross-version compatibility. */ static final long serialVersionUID = -5227120925547132828L;
+        /** The unique, shared instance. */ static final Path INSTANCE = new Path();
+        /** For {@link #INSTANCE} only.  */ private Path() {}
+
+        @Override public Class<java.nio.file.Path> getTargetClass() {
+            return java.nio.file.Path.class;
+        }
+
+        @Override java.nio.file.Path doConvert(String source) throws InvalidPathException
{
+            return java.nio.file.Paths.get(source);
+        }
+
+        /** Returns the singleton instance on deserialization. */
+        Object readResolve() throws ObjectStreamException {
+            return INSTANCE;
+        }
+    }
+
+    /**
      * Converter from {@link String} to {@link java.net.URI}.
      */
     @Immutable



Mime
View raw message