public static CharsetPreference valueOf(final String str) {
    """
	Create a charset preference that matches the following grammar:
	
	<pre>
	{@code
	CHAR           = <any US-ASCII character (octets 0 - 127)>
	DIGIT          = <any US-ASCII digit "0".."9">
	CTL            = <any US-ASCII control character
	(octets 0 - 31) and DEL (127)>
	SP             = <US-ASCII SP, space (32)>
	HT             = <US-ASCII HT, horizontal-tab (9)>
	<">            = <US-ASCII double-quote mark (34)>
	token          = 1*<any CHAR except CTLs or separators>
	separators     = "(" | ")" | "<" | ">" | "@"
	| "," | ";" | ":" | "\" | <">
	| "/" | "[" | "]" | "?" | "="
	| "{" | "}" | SP | HT
	charset        = token
	qvalue         = ( "0" [ "." 0*3DIGIT ] )
	| ( "1" [ "." 0*3("0") ] )
	preference     = ( charset | "*" )[ ";" "q" "=" qvalue ]}
	</pre>
	
	@param str
	a charset specifier
	@return the matching chartset preference, or {@code null} if no one could
	be found
    """
		final String[] parts = str.split(";");
		if(parts.length<=2) {
			final String charsetName =parts[0].trim();
			if("*".equals(charsetName) || TOKEN_MATCHER.matchesAllOf(charsetName)) {
				int weight=MAX_WEIGHT;
				if(parts.length==2) {
					final String weightValue=parts[1].trim();
					final Matcher matcher = QUALITY_PATTERN.matcher(weightValue);
					if(!matcher.matches()) {
						return null;
					}
					if(weightValue.charAt(2)=='0') {
						weight=Integer.parseInt(Strings.padEnd(weightValue.substring(4),3,'0'));
					}
				}
				return new CharsetPreference(charsetName,weight);
			}
		}
		return null;
	}
public static CharsetPreference valueOf(final String str) {
		final String[] parts = str.split(";");
		if(parts.length<=2) {
			final String charsetName =parts[0].trim();
			if("*".equals(charsetName) || TOKEN_MATCHER.matchesAllOf(charsetName)) {
				int weight=MAX_WEIGHT;
				if(parts.length==2) {
					final String weightValue=parts[1].trim();
					final Matcher matcher = QUALITY_PATTERN.matcher(weightValue);
					if(!matcher.matches()) {
						return null;
					}
					if(weightValue.charAt(2)=='0') {
						weight=Integer.parseInt(Strings.padEnd(weightValue.substring(4),3,'0'));
					}
				}
				return new CharsetPreference(charsetName,weight);
			}
		}
		return null;
	}
public static CharsetPreference valueOf ( final String str ) { final String [ ] parts = str . split ( ";" ) ; if ( parts . length <= 2 ) { final String charsetName = parts [ 0 ] . trim ( ) ; if ( "*" . equals ( charsetName ) || TOKEN_MATCHER . matchesAllOf ( charsetName ) ) { int weight = MAX_WEIGHT ; if ( parts . length == 2 ) { final String weightValue = parts [ 1 ] . trim ( ) ; final Matcher matcher = QUALITY_PATTERN . matcher ( weightValue ) ; if ( ! matcher . matches ( ) ) { return null ; } if ( weightValue . charAt ( 2 ) == ' ' ) { weight = Integer . parseInt ( Strings . padEnd ( weightValue . substring ( 4 ) , 3 , ' ' ) ) ; } } return new CharsetPreference ( charsetName , weight ) ; } } return null ; }
Create a charset preference that matches the following grammar:

<pre>
{@code
CHAR           = <any US-ASCII character (octets 0 - 127)>
DIGIT          = <any US-ASCII digit "0".."9">
CTL            = <any US-ASCII control character
(octets 0 - 31) and DEL (127)>
SP             = <US-ASCII SP, space (32)>
HT             = <US-ASCII HT, horizontal-tab (9)>
<">            = <US-ASCII double-quote mark (34)>
token          = 1*<any CHAR except CTLs or separators>
separators     = "(" | ")" | "<" | ">" | "@"
| "," | ";" | ":" | "\" | <">
| "/" | "[" | "]" | "?" | "="
| "{" | "}" | SP | HT
charset        = token
qvalue         = ( "0" [ "." 0*3DIGIT ] )
| ( "1" [ "." 0*3("0") ] )
preference     = ( charset | "*" )[ ";" "q" "=" qvalue ]}
</pre>

@param str
a charset specifier
@return the matching chartset preference, or {@code null} if no one could
be found
Create a charset preference that matches the following grammar :