commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patch: File(URI) constructor.


From: Bryce McKinlay
Subject: Re: Patch: File(URI) constructor.
Date: Tue, 06 Jul 2004 11:54:51 -0400
User-agent: Mozilla Thunderbird 0.5 (X11/20040626)

Anthony Green wrote:

This patch adds the missing File(URI) constructor.  Ok?

AG

------------------------------------------------------------------------

2004-07-05  Anthony Green  <address@hidden>

        * 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]