2004-07-05 Anthony Green
* 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 newFile
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))
+ 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);
+ path = normalizePath (path);
+ }
+
// Remove duplicate and redundant separator characters.
private String normalizePath(String p)
{