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]

Patch: URL.getFile() tweak and doc improvements


This patch was discovered by Mark Wielaard while getting Eclipse 3 to
run.  I added the javadoc clarifications.  Ok for HEAD (and Classpath)?


2004-07-03  Mark Wielaard  <mark@klomp.org>
            Anthony Green  <green@redhat.com>

	* java/net/URL.java (getFile): Clarify return value doc.
	(getPath): Return null if file is empty - not empty String.


Index: java/net/URL.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URL.java,v
retrieving revision 1.37
diff -c -u -p -r1.37 URL.java
--- java/net/URL.java	3 May 2004 20:23:26 -0000	1.37
+++ java/net/URL.java	3 Jul 2004 14:30:42 -0000
@@ -512,7 +513,7 @@ public final class URL implements Serial
    * Defined as <code>path[?query]</code>.
    * Returns the empty string if there is no file portion.
    *
-   * @return The filename specified in this URL.
+   * @return The filename specified in this URL, or an empty string if empty.
    */
   public String getFile()
   {
@@ -523,13 +524,15 @@ public final class URL implements Serial
    * Returns the path of the URL. This is the part of the file before any '?'
    * character.
    *
-   * @return The path specified in this URL.
+   * @return The path specified in this URL, or null if empty.
    *
    * @since 1.3
    */
   public String getPath()
   {
-    int quest = (file == null) ? -1 : file.indexOf('?');
+    if (file == null)
+      return null;
+    int quest = file.indexOf('?');
     return quest < 0 ? getFile() : file.substring(0, quest);
   }
 



-- 
Anthony Green <green@redhat.com>
Red Hat, Inc.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]