question: static String toLowerCase ( String s ) { int len = s . length ( ) ; StringBuilder sb = null ; for ( int i = 0 ; i < len ; i ++ ) { char c = s . charAt ( i ) ; if ( ( c >= 'a' && c <= 'z' ) || ( c == '.' ) ) { if ( sb != null ) sb . append ( c ) ; } else if ( ( c >= '0' && c <= '9' ) || ( c == '-' ) ) { if ( sb != null ) sb . append ( c ) ; } else if ( c >= 'A' && c <= 'Z' ) { if ( sb == null ) { sb = new StringBuilder ( len ) ; sb . append ( s , 0 , i ) ; } sb . append ( ( char ) ( c - CASE_DIFF ) ) ; } else { throw new IllegalArgumentException ( "Invalid characters in hostname" ) ; } } return sb == null ? s : sb . toString ( ) ; }
target:  Convert to lower case, and check that all chars are ascii alphanumeric, '-' or '.' only.