This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
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))
+ throw new IllegalArgumentException ("URI must have a 'file' scheme");normalizePath() will do the separatorChar replacement already.
+ 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);
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |