public static boolean isToken ( String str ) { // token := 1*<any (US-ASCII) CHAR except SPACE, CTLs, or tspecials> // tspecials := "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / // <"> / "/" / "[" / "]" / "?" / "=" // CTL := 0.- 31., 127. final int length = str . length ( ) ; if ( length == 0 ) return false ; for ( int idx = 0 ; idx < length ; idx ++ ) { char ch = str . charAt ( idx ) ; if ( ! TOKEN_CHARS . get ( ch ) ) return false ; } return true ; }
Tests whether the specified string is a token as defined in RFC 2045 section 5 . 1 .