You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2021/04/23 08:20:46 UTC

[groovy] branch master updated (a299f5b -> 80320e5)

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from a299f5b  GROOVY-9628: Initial support for reproducible builds (apply to zips too)
     new e8bf150  GROOVY-10050: Add additional NamedParam annotations in ResourceGroovyMethods
     new 4f14e19  GROOVY-10050: Add additional NamedParam annotations in NioExtensions
     new 80320e5  GROOVY-10050: Add additional NamedParam annotations in JsonSlurper

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../groovy/runtime/ResourceGroovyMethods.java      | 90 +++++++++++++++++-----
 .../src/main/java/groovy/json/JsonSlurper.java     | 21 ++++-
 .../groovy/nio/extensions/NioExtensions.java       | 64 +++++++++++----
 3 files changed, 135 insertions(+), 40 deletions(-)

[groovy] 03/03: GROOVY-10050: Add additional NamedParam annotations in JsonSlurper

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 80320e5e164943860f7edfbce6933646ed74b4af
Author: Paul King <pa...@asert.com.au>
AuthorDate: Thu Apr 22 14:10:26 2021 +1000

    GROOVY-10050: Add additional NamedParam annotations in JsonSlurper
---
 .../src/main/java/groovy/json/JsonSlurper.java      | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/subprojects/groovy-json/src/main/java/groovy/json/JsonSlurper.java b/subprojects/groovy-json/src/main/java/groovy/json/JsonSlurper.java
index b635f47..c325c8e 100644
--- a/subprojects/groovy-json/src/main/java/groovy/json/JsonSlurper.java
+++ b/subprojects/groovy-json/src/main/java/groovy/json/JsonSlurper.java
@@ -18,6 +18,7 @@
  */
 package groovy.json;
 
+import groovy.transform.NamedParam;
 import org.apache.groovy.json.internal.JsonFastParser;
 import org.apache.groovy.json.internal.JsonParserCharArray;
 import org.apache.groovy.json.internal.JsonParserLax;
@@ -419,11 +420,27 @@ public class JsonSlurper {
      * @return a data structure of lists and maps
      * @since 2.2.0
      */
-    public Object parse(Map params, URL url) {
+    public Object parse(
+            @NamedParam(value = "connectTimeout", type = Integer.class)
+            @NamedParam(value = "readTimeout", type = Integer.class)
+            @NamedParam(value = "useCaches", type = Boolean.class)
+            @NamedParam(value = "allowUserInteraction", type = Boolean.class)
+            @NamedParam(value = "requestProperties", type = Map.class)
+            Map<String, ?> params,
+            URL url
+    ) {
         return parseURL(url, params);
     }
 
-    private Object parseURL(URL url, Map params) {
+    private Object parseURL(
+            URL url,
+            @NamedParam(value = "connectTimeout", type = Integer.class)
+            @NamedParam(value = "readTimeout", type = Integer.class)
+            @NamedParam(value = "useCaches", type = Boolean.class)
+            @NamedParam(value = "allowUserInteraction", type = Boolean.class)
+            @NamedParam(value = "requestProperties", type = Map.class)
+            Map<String, ?> params
+    ) {
         Reader reader = null;
         try {
             if (params == null || params.isEmpty()) {

[groovy] 01/03: GROOVY-10050: Add additional NamedParam annotations in ResourceGroovyMethods

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit e8bf15095e91e31685ef72e3850a945049836bf1
Author: Paul King <pa...@asert.com.au>
AuthorDate: Thu Apr 22 13:10:54 2021 +1000

    GROOVY-10050: Add additional NamedParam annotations in ResourceGroovyMethods
---
 .../groovy/runtime/ResourceGroovyMethods.java      | 90 +++++++++++++++++-----
 1 file changed, 69 insertions(+), 21 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
index 5f7bcaa..038f92f 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
@@ -621,7 +621,15 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport {
      * @throws IOException if an IOException occurs.
      * @since 1.8.1
      */
-    public static String getText(URL url, Map parameters) throws IOException {
+    public static String getText(
+            URL url,
+            @NamedParam(value = "connectTimeout", type = Integer.class)
+            @NamedParam(value = "readTimeout", type = Integer.class)
+            @NamedParam(value = "useCaches", type = Boolean.class)
+            @NamedParam(value = "allowUserInteraction", type = Boolean.class)
+            @NamedParam(value = "requestProperties", type = Map.class)
+            Map<String, ?> parameters
+    ) throws IOException {
         return getText(url, parameters, CharsetToolkit.getDefaultSystemCharset().name());
     }
 
@@ -653,7 +661,16 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport {
      * @see java.net.URLConnection#getInputStream()
      * @since 1.8.1
      */
-    public static String getText(URL url, Map parameters, String charset) throws IOException {
+    public static String getText(
+            URL url,
+            @NamedParam(value = "connectTimeout", type = Integer.class)
+            @NamedParam(value = "readTimeout", type = Integer.class)
+            @NamedParam(value = "useCaches", type = Boolean.class)
+            @NamedParam(value = "allowUserInteraction", type = Boolean.class)
+            @NamedParam(value = "requestProperties", type = Map.class)
+            Map<String, ?> parameters,
+            String charset
+    ) throws IOException {
         BufferedReader reader = newReader(url, parameters, charset);
         return IOGroovyMethods.getText(reader);
     }
@@ -700,7 +717,15 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport {
      * @throws IOException if an IOException occurs.
      * @since 2.4.4
      */
-    public static byte[] getBytes(URL url, Map parameters) throws IOException {
+    public static byte[] getBytes(
+            URL url,
+            @NamedParam(value = "connectTimeout", type = Integer.class)
+            @NamedParam(value = "readTimeout", type = Integer.class)
+            @NamedParam(value = "useCaches", type = Boolean.class)
+            @NamedParam(value = "allowUserInteraction", type = Boolean.class)
+            @NamedParam(value = "requestProperties", type = Map.class)
+            Map<String, ?> parameters
+    ) throws IOException {
         return IOGroovyMethods.getBytes(configuredInputStream(parameters, url));
     }
 
@@ -1317,10 +1342,10 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport {
             @NamedParam(value = "postRoot", type = Boolean.class)
             @NamedParam(value = "visitRoot", type = Boolean.class)
             @NamedParam(value = "maxDepth", type = Integer.class)
-            @NamedParam(value = "filter", type = Object.class)
-            @NamedParam(value = "nameFilter", type = Object.class)
-            @NamedParam(value = "excludeFilter", type = Object.class)
-            @NamedParam(value = "excludeNameFilter", type = Object.class)
+            @NamedParam(value = "filter")
+            @NamedParam(value = "nameFilter")
+            @NamedParam(value = "excludeFilter")
+            @NamedParam(value = "excludeNameFilter")
             @NamedParam(value = "sort", type = Closure.class)
             final Map<String, ?> options,
             @ClosureParams(value = SimpleType.class, options = "java.io.File")
@@ -1415,7 +1440,7 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport {
      */
     public static void traverse(final File self, @ClosureParams(value = SimpleType.class, options = "java.io.File") final Closure closure)
             throws FileNotFoundException, IllegalArgumentException {
-        traverse(self, new HashMap<String, Object>(), closure);
+        traverse(self, new HashMap<>(), closure);
     }
 
     /**
@@ -1439,10 +1464,10 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport {
             @NamedParam(value = "postRoot", type = Boolean.class)
             @NamedParam(value = "visitRoot", type = Boolean.class)
             @NamedParam(value = "maxDepth", type = Integer.class)
-            @NamedParam(value = "filter", type = Object.class)
-            @NamedParam(value = "nameFilter", type = Object.class)
-            @NamedParam(value = "excludeFilter", type = Object.class)
-            @NamedParam(value = "excludeNameFilter", type = Object.class)
+            @NamedParam(value = "filter")
+            @NamedParam(value = "nameFilter")
+            @NamedParam(value = "excludeFilter")
+            @NamedParam(value = "excludeNameFilter")
             @NamedParam(value = "sort", type = Closure.class)
             final Map<String, ?> options)
                 throws FileNotFoundException, IllegalArgumentException {
@@ -2195,7 +2220,7 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport {
      * @throws IOException if an I/O error occurs while creating the input stream
      * @since 1.8.1
      */
-    private static InputStream configuredInputStream(Map parameters, URL url) throws IOException {
+    private static InputStream configuredInputStream(Map<String, ?> parameters, URL url) throws IOException {
         final URLConnection connection = url.openConnection();
         if (parameters != null) {
             if (parameters.containsKey("connectTimeout")) {
@@ -2227,11 +2252,10 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport {
      *
      * @param url a URL
      * @return a BufferedInputStream for the URL
-     * @throws MalformedURLException is thrown if the URL is not well formed
      * @throws IOException           if an I/O error occurs while creating the input stream
      * @since 1.5.2
      */
-    public static BufferedInputStream newInputStream(URL url) throws MalformedURLException, IOException {
+    public static BufferedInputStream newInputStream(URL url) throws IOException {
         return new BufferedInputStream(configuredInputStream(null, url));
     }
 
@@ -2250,11 +2274,18 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport {
      * @param url        a URL
      * @param parameters connection parameters
      * @return a BufferedInputStream for the URL
-     * @throws MalformedURLException is thrown if the URL is not well formed
      * @throws IOException           if an I/O error occurs while creating the input stream
      * @since 1.8.1
      */
-    public static BufferedInputStream newInputStream(URL url, Map parameters) throws MalformedURLException, IOException {
+    public static BufferedInputStream newInputStream(
+            URL url,
+            @NamedParam(value = "connectTimeout", type = Integer.class)
+            @NamedParam(value = "readTimeout", type = Integer.class)
+            @NamedParam(value = "useCaches", type = Boolean.class)
+            @NamedParam(value = "allowUserInteraction", type = Boolean.class)
+            @NamedParam(value = "requestProperties", type = Map.class)
+            Map<String, ?> parameters
+    ) throws IOException {
         return new BufferedInputStream(configuredInputStream(parameters, url));
     }
 
@@ -2267,7 +2298,7 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport {
      * @throws IOException           if an I/O error occurs while creating the input stream
      * @since 1.5.5
      */
-    public static BufferedReader newReader(URL url) throws MalformedURLException, IOException {
+    public static BufferedReader newReader(URL url) throws IOException {
         return IOGroovyMethods.newReader(configuredInputStream(null, url));
     }
 
@@ -2290,7 +2321,15 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport {
      * @throws IOException           if an I/O error occurs while creating the input stream
      * @since 1.8.1
      */
-    public static BufferedReader newReader(URL url, Map parameters) throws MalformedURLException, IOException {
+    public static BufferedReader newReader(
+            URL url,
+            @NamedParam(value = "connectTimeout", type = Integer.class)
+            @NamedParam(value = "readTimeout", type = Integer.class)
+            @NamedParam(value = "useCaches", type = Boolean.class)
+            @NamedParam(value = "allowUserInteraction", type = Boolean.class)
+            @NamedParam(value = "requestProperties", type = Map.class)
+            Map<String, ?> parameters
+    ) throws IOException {
         return IOGroovyMethods.newReader(configuredInputStream(parameters, url));
     }
 
@@ -2304,7 +2343,7 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport {
      * @throws IOException           if an I/O error occurs while creating the input stream
      * @since 1.5.5
      */
-    public static BufferedReader newReader(URL url, String charset) throws MalformedURLException, IOException {
+    public static BufferedReader newReader(URL url, String charset) throws IOException {
         return new BufferedReader(new InputStreamReader(configuredInputStream(null, url), charset));
     }
 
@@ -2319,7 +2358,16 @@ public class ResourceGroovyMethods extends DefaultGroovyMethodsSupport {
      * @throws IOException           if an I/O error occurs while creating the input stream
      * @since 1.8.1
      */
-    public static BufferedReader newReader(URL url, Map parameters, String charset) throws MalformedURLException, IOException {
+    public static BufferedReader newReader(
+            URL url,
+            @NamedParam(value = "connectTimeout", type = Integer.class)
+            @NamedParam(value = "readTimeout", type = Integer.class)
+            @NamedParam(value = "useCaches", type = Boolean.class)
+            @NamedParam(value = "allowUserInteraction", type = Boolean.class)
+            @NamedParam(value = "requestProperties", type = Map.class)
+            Map<String, ?> parameters,
+            String charset
+    ) throws IOException {
         return new BufferedReader(new InputStreamReader(configuredInputStream(parameters, url), charset));
     }
 

[groovy] 02/03: GROOVY-10050: Add additional NamedParam annotations in NioExtensions

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 4f14e19f89a83acc7b9ef061ea6b79772e3c6b27
Author: Paul King <pa...@asert.com.au>
AuthorDate: Thu Apr 22 13:41:13 2021 +1000

    GROOVY-10050: Add additional NamedParam annotations in NioExtensions
---
 .../groovy/nio/extensions/NioExtensions.java       | 64 ++++++++++++++++------
 1 file changed, 47 insertions(+), 17 deletions(-)

diff --git a/subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java b/subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java
index 733e540..1786fda 100644
--- a/subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java
+++ b/subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java
@@ -24,6 +24,7 @@ import groovy.io.GroovyPrintWriter;
 import groovy.lang.Closure;
 import groovy.lang.MetaClass;
 import groovy.lang.Writable;
+import groovy.transform.NamedParam;
 import groovy.transform.stc.ClosureParams;
 import groovy.transform.stc.FromString;
 import groovy.transform.stc.PickFirstResolver;
@@ -66,9 +67,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.regex.Pattern;
 
+import static java.lang.Boolean.FALSE;
 import static java.nio.file.StandardOpenOption.APPEND;
 import static java.nio.file.StandardOpenOption.CREATE;
-import static org.codehaus.groovy.runtime.DefaultGroovyMethods.get;
 
 /**
  * This class defines new groovy methods for Readers, Writers, InputStreams and
@@ -887,7 +888,7 @@ public class NioExtensions extends DefaultGroovyMethodsSupport {
      * @see #eachFile(Path, groovy.io.FileType, groovy.lang.Closure)
      * @since 2.3.0
      */
-    public static void eachFile(final Path self, final Closure closure) throws IOException { // throws FileNotFoundException, IllegalArgumentException {
+    public static void eachFile(final Path self, final Closure closure) throws IOException {
         eachFile(self, FileType.ANY, closure);
     }
 
@@ -902,7 +903,7 @@ public class NioExtensions extends DefaultGroovyMethodsSupport {
      * @see #eachFile(Path, groovy.io.FileType, groovy.lang.Closure)
      * @since 2.3.0
      */
-    public static void eachDir(Path self, @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path") Closure closure) throws IOException { // throws FileNotFoundException, IllegalArgumentException {
+    public static void eachDir(Path self, @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path") Closure closure) throws IOException {
         eachFile(self, FileType.DIRECTORIES, closure);
     }
 
@@ -920,7 +921,7 @@ public class NioExtensions extends DefaultGroovyMethodsSupport {
      * @throws IllegalArgumentException      if the provided Path object does not represent a directory
      * @since 2.3.0
      */
-    public static void eachFileRecurse(final Path self, final FileType fileType, @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path") final Closure closure) throws IOException { // throws FileNotFoundException, IllegalArgumentException {
+    public static void eachFileRecurse(final Path self, final FileType fileType, @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path") final Closure closure) throws IOException {
         // throws FileNotFoundException, IllegalArgumentException {
         checkDir(self);
         try (DirectoryStream<Path> stream = Files.newDirectoryStream(self)) {
@@ -994,14 +995,29 @@ public class NioExtensions extends DefaultGroovyMethodsSupport {
      * @see groovy.io.FileType
      * @since 2.3.0
      */
-    public static void traverse(final Path self, final Map<String, Object> options, @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path") final Closure closure)
-            throws IOException {
-        // throws FileNotFoundException, IllegalArgumentException {
+    public static void traverse(
+            final Path self,
+            @NamedParam(value = "type", type = FileType.class)
+            @NamedParam(value = "preDir", type = Closure.class)
+            @NamedParam(value = "preRoot", type = Boolean.class)
+            @NamedParam(value = "postDir", type = Closure.class)
+            @NamedParam(value = "postRoot", type = Boolean.class)
+            @NamedParam(value = "visitRoot", type = Boolean.class)
+            @NamedParam(value = "maxDepth", type = Integer.class)
+            @NamedParam(value = "filter")
+            @NamedParam(value = "nameFilter")
+            @NamedParam(value = "excludeFilter")
+            @NamedParam(value = "excludeNameFilter")
+            @NamedParam(value = "sort", type = Closure.class)
+            final Map<String, Object> options,
+            @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path")
+            final Closure closure
+    ) throws IOException {
         Number maxDepthNumber = DefaultGroovyMethods.asType(options.remove("maxDepth"), Number.class);
         int maxDepth = maxDepthNumber == null ? -1 : maxDepthNumber.intValue();
-        Boolean visitRoot = DefaultGroovyMethods.asType(get(options, "visitRoot", false), Boolean.class);
-        Boolean preRoot = DefaultGroovyMethods.asType(get(options, "preRoot", false), Boolean.class);
-        Boolean postRoot = DefaultGroovyMethods.asType(get(options, "postRoot", false), Boolean.class);
+        Boolean visitRoot = DefaultGroovyMethods.asType(options.getOrDefault("visitRoot", FALSE), Boolean.class);
+        Boolean preRoot = DefaultGroovyMethods.asType(options.getOrDefault("preRoot", FALSE), Boolean.class);
+        Boolean postRoot = DefaultGroovyMethods.asType(options.getOrDefault("postRoot", FALSE), Boolean.class);
         final Closure pre = (Closure) options.get("preDir");
         final Closure post = (Closure) options.get("postDir");
         final FileType type = (FileType) options.get("type");
@@ -1090,8 +1106,22 @@ public class NioExtensions extends DefaultGroovyMethodsSupport {
      * @see #traverse(Path, java.util.Map, groovy.lang.Closure)
      * @since 2.3.0
      */
-    public static void traverse(final Path self, final Map<String, Object> options)
-            throws IOException {
+    public static void traverse(
+            final Path self,
+            @NamedParam(value = "type", type = FileType.class)
+            @NamedParam(value = "preDir", type = Closure.class)
+            @NamedParam(value = "preRoot", type = Boolean.class)
+            @NamedParam(value = "postDir", type = Closure.class)
+            @NamedParam(value = "postRoot", type = Boolean.class)
+            @NamedParam(value = "visitRoot", type = Boolean.class)
+            @NamedParam(value = "maxDepth", type = Integer.class)
+            @NamedParam(value = "filter")
+            @NamedParam(value = "nameFilter")
+            @NamedParam(value = "excludeFilter")
+            @NamedParam(value = "excludeNameFilter")
+            @NamedParam(value = "sort", type = Closure.class)
+            final Map<String, Object> options
+    ) throws IOException {
         final Closure visit = (Closure) options.remove("visit");
         traverse(self, options, visit);
     }
@@ -1170,7 +1200,7 @@ public class NioExtensions extends DefaultGroovyMethodsSupport {
      * @see #eachFileRecurse(Path, groovy.io.FileType, groovy.lang.Closure)
      * @since 2.3.0
      */
-    public static void eachFileRecurse(Path self, @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path") Closure closure) throws IOException { // throws FileNotFoundException, IllegalArgumentException {
+    public static void eachFileRecurse(Path self, @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path") Closure closure) throws IOException {
         eachFileRecurse(self, FileType.ANY, closure);
     }
 
@@ -1187,7 +1217,7 @@ public class NioExtensions extends DefaultGroovyMethodsSupport {
      * @see #eachFileRecurse(Path, groovy.io.FileType, groovy.lang.Closure)
      * @since 2.3.0
      */
-    public static void eachDirRecurse(final Path self, @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path") final Closure closure) throws IOException { //throws FileNotFoundException, IllegalArgumentException {
+    public static void eachDirRecurse(final Path self, @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path") final Closure closure) throws IOException {
         eachFileRecurse(self, FileType.DIRECTORIES, closure);
     }
 
@@ -1269,7 +1299,7 @@ public class NioExtensions extends DefaultGroovyMethodsSupport {
      * @see #eachFileMatch(Path, groovy.io.FileType, Object, groovy.lang.Closure)
      * @since 2.3.0
      */
-    public static void eachDirMatch(final Path self, final Object nameFilter, @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path") final Closure closure) throws IOException {  // throws FileNotFoundException, IllegalArgumentException {
+    public static void eachDirMatch(final Path self, final Object nameFilter, @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path") final Closure closure) throws IOException {
         eachFileMatch(self, FileType.DIRECTORIES, nameFilter, closure);
     }
 
@@ -1793,7 +1823,7 @@ public class NioExtensions extends DefaultGroovyMethodsSupport {
      * @throws java.io.FileNotFoundException if the file is not found.
      * @since 2.3.0
      */
-    public static BufferedInputStream newInputStream(Path self) throws IOException { // throws FileNotFoundException {
+    public static BufferedInputStream newInputStream(Path self) throws IOException {
         return new BufferedInputStream(Files.newInputStream(self));
     }
 
@@ -1805,7 +1835,7 @@ public class NioExtensions extends DefaultGroovyMethodsSupport {
      * @throws java.io.FileNotFoundException if the file is not found.
      * @since 2.3.0
      */
-    public static DataInputStream newDataInputStream(Path self) throws IOException { // throws FileNotFoundException {
+    public static DataInputStream newDataInputStream(Path self) throws IOException {
         return new DataInputStream(Files.newInputStream(self));
     }