[kaffe] CVS kaffe (kaz): java/io/File.java:

Kaffe CVS Kaffe Mailing List <kaffe@kaffe.org>
Fri Sep 12 16:31:01 2003


PatchSet 4028 
Date: 2003/09/12 23:27:55
Author: kaz
Branch: HEAD
Tag: (none) 
Log:
2003-09-12  Ito Kazumitsu <kaz@maczuka.gcd.org>
	* java/io/File.java:
	added missing 1.4 features (toURI() and File(URI)) once implemented
	in kaffe but lost when GNU Classpath's File.java was imported.

Members: 
	ChangeLog:1.1624->1.1625 
	libraries/javalib/java/io/File.java:1.36->1.37 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1624 kaffe/ChangeLog:1.1625
--- kaffe/ChangeLog:1.1624	Thu Sep 11 22:34:45 2003
+++ kaffe/ChangeLog	Fri Sep 12 23:27:55 2003
@@ -1,3 +1,8 @@
+2003-09-12  Ito Kazumitsu <kaz@maczuka.gcd.org>
+	* java/io/File.java:
+	added missing 1.4 features (toURI() and File(URI)) once implemented
+	in kaffe but lost when GNU Classpath's File.java was imported.
+
 2003-09-11  Ito Kazumitsu <kaz@maczuka.gcd.org>
 	* java/util/GregorianCalendar.java:
 	(getLinearTime) corrected a bug of counting leap days twice.
Index: kaffe/libraries/javalib/java/io/File.java
diff -u kaffe/libraries/javalib/java/io/File.java:1.36 kaffe/libraries/javalib/java/io/File.java:1.37
--- kaffe/libraries/javalib/java/io/File.java:1.36	Sun Aug 31 17:16:50 2003
+++ kaffe/libraries/javalib/java/io/File.java	Fri Sep 12 23:27:57 2003
@@ -39,7 +39,9 @@
 package java.io;
 
 import java.net.MalformedURLException;
+import java.net.URISyntaxException;
 import java.net.URL;
+import java.net.URI;
 import gnu.classpath.Configuration;
 import gnu.java.io.PlatformHelper;
 import java.util.LinkedList;
@@ -292,6 +294,24 @@
     return existsInternal (path);
   }
 
+//  File(URI) copied from Kaffe's File.java
+  /**
+   * This method initializes a new <code>File</code> object to represent
+   * a file with the specified URI.
+   *
+   * @param uri The URI of the file
+   */
+
+public File(URI uri) {
+	if (uri == null) {
+		throw new NullPointerException();
+	}
+	this.path = uri.getPath();
+	if (this.path == null) {
+		throw new IllegalArgumentException();
+	}
+}
+
   /**
    * This method initializes a new <code>File</code> object to represent
    * a file with the specified path.
@@ -866,6 +886,29 @@
     
     return new URL (url_string);
   }
+
+// toURI() copied from Kaffe's File.java
+/**
+ * @since 1.4
+ */
+public URI toURI() {
+	try {
+		return new URI("file",
+			       null,
+			       (isDirectory() ?                               
+				getAbsolutePath() + separator
+				: getAbsolutePath()),
+			       null,
+			       null);
+	}
+	catch (URISyntaxException e) {
+		throw (IllegalArgumentException) 
+			new IllegalArgumentException("Couldn't convert "
+						     + toString()
+						     + " to an URI")
+			.initCause(e);
+	}
+}
 
   /*
    * This native method actually creates the directory