Index: URLName.java
===================================================================
RCS file: /home/cvspublic/incubator-geronimo/specs/javamail/src/java/javax/mail/URLName.java,v
retrieving revision 1.2
diff -u -r1.2 URLName.java
--- URLName.java	16 Aug 2003 04:29:52 -0000	1.2
+++ URLName.java	18 Aug 2003 17:07:57 -0000
@@ -60,6 +60,8 @@
 //
 package javax.mail;
 import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 /**
  * @version $Revision: 1.2 $ $Date: 2003/08/16 04:29:52 $
@@ -99,6 +101,15 @@
     public URLName(URL url) {
         parseURL(url);
     }
+    private String checkBlank(String target) {
+        if (target == null) {
+            return target;
+        } else if (target.equals("")) {
+            return null;
+        } else {
+            return target;
+        }
+    }
     public boolean equals(Object other) {
         if (other == null || other.getClass() != this.getClass()) {
             return false;
@@ -135,15 +146,29 @@
     }
     protected void parseString(String name) {
         try {
-            // TODO Implement this not using URL
-            // The URL doesn't handle unknown protocol
-            // types, at least, without registering ahandler
-            // first of all -- and it may not like user:pw@host
-            // either
-            URL url = new URL(name);
-            parseURL(url);
-        } catch (MalformedURLException e) {
-            throw new IllegalArgumentException(e.getMessage());
+            URI uri = new URI(name);
+            _protocol = checkBlank(uri.getScheme());
+            _host = checkBlank(uri.getHost());
+            String authority = uri.getAuthority();
+            _port = uri.getPort();
+            _ref = checkBlank(uri.getFragment());
+            _file = checkBlank(uri.getPath());
+            if (authority != null) {
+                int colon = authority.indexOf(":");
+                int at = authority.indexOf("@");
+                if (at != -1) {
+                    if (colon == -1) {
+                        _username = checkBlank(authority.substring(0, at));
+                    } else {
+                        _username = checkBlank(authority.substring(0, colon));
+                        _password =
+                            checkBlank(authority.substring(colon + 1, at));
+                    }
+                }
+            }
+            updateFullURL();
+        } catch (URISyntaxException e) {
+            throw new RuntimeException(e);
         }
     }
     private void parseURL(URL url) {
@@ -155,20 +180,10 @@
         _username = checkBlank(url.getUserInfo());
         updateFullURL();
     }
-    private String checkBlank(String target) {
-        if (target == null) {
-            return target;
-        } else if (target.equals("")) {
-            return null;
-        } else {
-            return target;
-        }
-    }
     public String toString() {
         return fullURL;
     }
     private void updateFullURL() {
-        // what happens with user/password? Are they needed here?
         fullURL =
             _protocol
                 + "://"
