protected void parseString()

in geronimo-mail_2.1_spec/src/main/java/jakarta/mail/URLName.java [47:96]


    protected void parseString(final String url) {
        URI uri;
        try {
            if (url == null) {
                uri = null;
            } else {
                uri = new URI(url);
            }
        } catch (final URISyntaxException e) {
            uri = null;
        }
        if (uri == null) {
            protocol = null;
            host = null;
            port = -1;
            file = null;
            ref = null;
            username = null;
            password = null;
            return;
        }

        protocol = checkBlank(uri.getScheme());
        host = checkBlank(uri.getHost());
        port = uri.getPort();
        file = checkBlank(uri.getPath());
        // if the file starts with "/", we need to strip that off. 
        // URL and URLName do not have the same behavior when it comes 
        // to keeping that there. 
        if (file != null && file.length() > 1 && file.startsWith("/")) {
            file = checkBlank(file.substring(1)); 
        }
        
        ref = checkBlank(uri.getFragment());
        final String userInfo = checkBlank(uri.getUserInfo());
        if (userInfo == null) {
            username = null;
            password = null;
        } else {
            final int pos = userInfo.indexOf(':');
            if (pos == -1) {
                username = userInfo;
                password = null;
            } else {
                username = userInfo.substring(0, pos);
                password = userInfo.substring(pos + 1);
            }
        }
        updateFullURL();
    }