question: public static int validate ( String hostname , String port , String exclList ) { Matcher match = HOSTNAME_PATTERN . matcher ( hostname ) ; String exclListArray [ ] = exclList . split ( "," ) ; if ( ! match . matches ( ) ) return R . string . proxy_error_invalid_host ; for ( String excl : exclListArray ) { Matcher m = EXCLUSION_PATTERN . matcher ( excl ) ; if ( ! m . matches ( ) ) return R . string . proxy_error_invalid_exclusion_list ; } if ( hostname . length ( ) > 0 && port . length ( ) == 0 ) { return R . string . proxy_error_empty_port ; } if ( port . length ( ) > 0 ) { if ( hostname . length ( ) == 0 ) { return R . string . proxy_error_empty_host_set_port ; } int portVal = - 1 ; try { portVal = Integer . parseInt ( port ) ; } catch ( NumberFormatException ex ) { return R . string . proxy_error_invalid_port ; } if ( portVal <= 0 || portVal > 0xFFFF ) { return R . string . proxy_error_invalid_port ; } } return 0 ; }
target:  validate syntax of hostname and port entries