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 10:10:44 -0000
@@ -134,17 +134,52 @@
         return fullURL.hashCode();
     }
     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());
+        int colon = name.indexOf(":");
+        _protocol = name.substring(0,colon);
+        colon++;
+        // If it starts with /, assume it starts with // and move the cursor two positions
+        if (name.charAt(colon) == '/') {
+            colon += 2;
         }
+        int slash = name.indexOf("/",colon);
+        if (slash == -1) {
+            slash = name.length();
+        } else {
+            String fileref = name.substring(slash);
+            int hash = fileref.indexOf("#");
+            if (hash == -1) {
+                _file = fileref;
+            } else {
+                _file = fileref.substring(0, hash);
+                _ref = fileref.substring(hash+1);
+            }
+        }
+        String userpwhost = name.substring(colon,slash);
+        int at = userpwhost.indexOf("@");
+        if (at == -1) {
+            _host = userpwhost;
+        } else {
+            colon = userpwhost.indexOf(":");
+            if (colon == -1) {
+                _username = userpwhost.substring(0,at);
+                _host = userpwhost.substring(at+1);
+            } else if (colon > at) {
+                // colon is port, not password
+                _username = userpwhost.substring(0,at);
+                _host = userpwhost.substring(at+1);                    
+            } else {
+                _username = userpwhost.substring(0,colon);
+                _password = userpwhost.substring(colon+1,at);
+                _host = userpwhost.substring(at+1);                    
+            }
+        }
+        // Fix up the host to remove any port
+        colon = _host.indexOf(":");
+        if (colon != -1) {
+            _port = Integer.parseInt(_host.substring(colon+1));
+            _host = _host.substring(0,colon);
+        }
+        updateFullURL();
     }
     private void parseURL(URL url) {
         _file = checkBlank(url.getFile());
