Patch: File(URI) constructor.
Bryce McKinlay
mckinlay@redhat.com
Tue Jul 6 15:54:00 GMT 2004
Anthony Green wrote:
>This patch adds the missing File(URI) constructor. Ok?
>
>AG
>
>
>
>------------------------------------------------------------------------
>
>2004-07-05 Anthony Green <green@redhat.com>
>
> * java/io/File.java (File(URI)): New constructor.
>
>
>Index: java/io/File.java
>===================================================================
>RCS file: /cvs/gcc/gcc/libjava/java/io/File.java,v
>retrieving revision 1.39
>diff -u -r1.39 File.java
>--- java/io/File.java 6 Jul 2004 02:52:54 -0000 1.39
>+++ java/io/File.java 6 Jul 2004 03:12:46 -0000
>@@ -285,6 +285,34 @@
> path = normalizePath (name);
> }
>
>+ /**
>+ * This method initializes a new <code>File</code> object to represent
>+ * a file with the specified URI.
>+ *
>+ * @param name The URI for this file.
>+ */
>+ public File(URI uri)
>+ {
>+ if (! uri.isAbsolute ())
>+ throw new IllegalArgumentException ("URI must be absolute");
>+ String scheme = uri.getScheme ();
>+ if (scheme == null || ! "file".equals (scheme))
>
>
Should this use equalsIgnoreCase() ?
>+ throw new IllegalArgumentException ("URI must have a 'file' scheme");
>+ String path = uri.getPath ();
>+ if (path == null || "".equals (path))
>+ throw new IllegalArgumentException ("URI cannot have an empty path component");
>+ if (uri.getAuthority () != null)
>+ throw new IllegalArgumentException ("URI cannot have an authority component");
>+ if (uri.getFragment () != null)
>+ throw new IllegalArgumentException ("URI cannot have a fragment component");
>+ if (uri.getQuery () != null)
>+ throw new IllegalArgumentException ("URI cannot have a query component");
>+
>+ if (separatorChar != '/')
>+ path = path.replace ('/', separatorChar);
>
>
normalizePath() will do the separatorChar replacement already.
Otherwise OK
Bryce
More information about the Java-patches
mailing list