src/main/java/org/wymiwyg/commons/util/URI.java
private void initializeAuthority(String p_uriSpec)
		throws MalformedURIException {
		int index = 0;
		int start = 0;
		int end = p_uriSpec.length();
		char testChar = '\0';
		String userinfo = null;

		// userinfo is everything up @
		if (p_uriSpec.indexOf('@', start) != -1) {
			while (index < end) {
				testChar = p_uriSpec.charAt(index);
				if (testChar == '@') {
					break;
				}
				index++;
			}
			userinfo = p_uriSpec.substring(start, index);
			index++;
		}

		// host is everything up to ':'
		String host = null;
		start = index;
		while (index < end) {
			testChar = p_uriSpec.charAt(index);
			if (testChar == ':') {
				break;
			}
			index++;
		}
		host = p_uriSpec.substring(start, index);
		int port = -1;
		if (host.length() > 0) {
			// port
			if (testChar == ':') {
				index++;
				start = index;
				while (index < end) {
					index++;
				}
				String portStr = p_uriSpec.substring(start, index);
				if (portStr.length() > 0) {
					for (int i = 0; i < portStr.length(); i++) {
						if (!isDigit(portStr.charAt(i))) {
							throw new MalformedURIException(
								portStr
									+ " is invalid. Port should only contain digits!");
						}
					}
					try {
						port = Integer.parseInt(portStr);
						m_port = portStr;
					} catch (NumberFormatException nfe) {
						// can't happen
					}
				}
			}
		}
		setHost(host);
		setPort(port);
		setUserinfo(userinfo);
	}
private void initializeAuthority(String p_uriSpec)
		throws MalformedURIException {
		int index = 0;
		int start = 0;
		int end = p_uriSpec.length();
		char testChar = '\0';
		String userinfo = null;

		// userinfo is everything up @
		if (p_uriSpec.indexOf('@', start) != -1) {
			while (index < end) {
				testChar = p_uriSpec.charAt(index);
				if (testChar == '@') {
					break;
				}
				index++;
			}
			userinfo = p_uriSpec.substring(start, index);
			index++;
		}

		// host is everything up to ':'
		String host = null;
		start = index;
		while (index < end) {
			testChar = p_uriSpec.charAt(index);
			if (testChar == ':') {
				break;
			}
			index++;
		}
		host = p_uriSpec.substring(start, index);
		int port = -1;
		if (host.length() > 0) {
			// port
			if (testChar == ':') {
				index++;
				start = index;
				while (index < end) {
					index++;
				}
				String portStr = p_uriSpec.substring(start, index);
				if (portStr.length() > 0) {
					for (int i = 0; i < portStr.length(); i++) {
						if (!isDigit(portStr.charAt(i))) {
							throw new MalformedURIException(
								portStr
									+ " is invalid. Port should only contain digits!");
						}
					}
					try {
						port = Integer.parseInt(portStr);
						m_port = portStr;
					} catch (NumberFormatException nfe) {
						// can't happen
					}
				}
			}
		}
		setHost(host);
		setPort(port);
		setUserinfo(userinfo);
	}
private void initializeAuthority ( String p_uriSpec ) throws MalformedURIException { int index = 0 ; int start = 0 ; int end = p_uriSpec . length ( ) ; char testChar = ' ' ; String userinfo = null ; // userinfo is everything up @
 if ( p_uriSpec . indexOf ( ' ' , start ) != - 1 ) { while ( index < end ) { testChar = p_uriSpec . charAt ( index ) ; if ( testChar == ' ' ) { break ; } index ++ ; } userinfo = p_uriSpec . substring ( start , index ) ; index ++ ; } // host is everything up to ':'
 String host = null ; start = index ; while ( index < end ) { testChar = p_uriSpec . charAt ( index ) ; if ( testChar == ' ' ) { break ; } index ++ ; } host = p_uriSpec . substring ( start , index ) ; int port = - 1 ; if ( host . length ( ) > 0 ) { // port
 if ( testChar == ' ' ) { index ++ ; start = index ; while ( index < end ) { index ++ ; } String portStr = p_uriSpec . substring ( start , index ) ; if ( portStr . length ( ) > 0 ) { for ( int i = 0 ; i < portStr . length ( ) ; i ++ ) { if ( ! isDigit ( portStr . charAt ( i ) ) ) { throw new MalformedURIException ( portStr + " is invalid. Port should only contain digits!" ) ; } } try { port = Integer . parseInt ( portStr ) ; m_port = portStr ; } catch ( NumberFormatException nfe ) { // can't happen
 } } } } setHost ( host ) ; setPort ( port ) ; setUserinfo ( userinfo ) ; }
Initialize the authority (userinfo, host and port) for this
URI from a URI string spec.

@param p_uriSpec the URI specification (cannot be null)

@exception MalformedURIException if p_uriSpec violates syntax rules
Initialize the authority ( userinfo host and port ) for this URI from a URI string spec .