in ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java [384:449]
private int parseHost( char[] chars, int pos )
{
int start = pos;
if ( pos >= chars.length )
{
return INVALID;
}
// The host will be followed by a '/' or a ':', or by nothing if it's
// the end.
// We will search the end of the host part, and we will check some
// elements.
switch ( chars[pos] )
{
case '[':
// This is an IP Literal address
return parseIpLiteral( chars, pos + 1 );
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
// Probably an IPV4 address, but may be a reg-name
// try to parse an IPV4 address first
int currentPos = parseIPV4( chars, pos );
if ( currentPos != INVALID )
{
host = new String( chars, start, currentPos - start );
return currentPos;
}
//fallback to reg-name
case 'a' : case 'b' : case 'c' : case 'd' : case 'e' :
case 'A' : case 'B' : case 'C' : case 'D' : case 'E' :
case 'f' : case 'g' : case 'h' : case 'i' : case 'j' :
case 'F' : case 'G' : case 'H' : case 'I' : case 'J' :
case 'k' : case 'l' : case 'm' : case 'n' : case 'o' :
case 'K' : case 'L' : case 'M' : case 'N' : case 'O' :
case 'p' : case 'q' : case 'r' : case 's' : case 't' :
case 'P' : case 'Q' : case 'R' : case 'S' : case 'T' :
case 'u' : case 'v' : case 'w' : case 'x' : case 'y' :
case 'U' : case 'V' : case 'W' : case 'X' : case 'Y' :
case 'z' : case 'Z' : case '-' : case '.' : case '_' :
case '~' : case '%' : case '!' : case '$' : case '&' :
case '\'' : case '(' : case ')' : case '*' : case '+' :
case ',' : case ';' : case '=' :
// A reg-name
return parseRegName( chars, pos );
default:
break;
}
host = new String( chars, start, pos - start );
return pos;
}