Class CharsetUtil
java.lang.Object
org.apache.james.mime4j.util.CharsetUtil
Utility class for working with character sets.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisASCII(char ch) Returnstrueif the specified character falls into the US ASCII character set (Unicode range 0000 to 007f).static booleanReturnstrueif the specified string consists entirely of US ASCII characters.static booleanisASCII(ByteSequence raw) Returnstrueif the specified byte array consists entirely of US ASCII characters.static booleanisWhitespace(char ch) Returnstrueif the specified character is a whitespace character (CR, LF, SP or HT).static booleanReturnstrueif the specified string consists entirely of whitespace characters.static CharsetReturns aCharsetinstance if character set with the given name is recognized and supported by Java runtime.
-
Field Details
-
CRLF
-
CR
public static final int CRUS-ASCII CR, carriage return (13)- See Also:
-
LF
public static final int LFUS-ASCII LF, line feed (10)- See Also:
-
SP
public static final int SPUS-ASCII SP, space (32)- See Also:
-
HT
public static final int HTUS-ASCII HT, horizontal-tab (9)- See Also:
-
-
Constructor Details
-
CharsetUtil
public CharsetUtil()
-
-
Method Details
-
isASCII
public static boolean isASCII(char ch) Returnstrueif the specified character falls into the US ASCII character set (Unicode range 0000 to 007f).- Parameters:
ch- character to test.- Returns:
trueif the specified character falls into the US ASCII character set,falseotherwise.
-
isASCII
Returnstrueif the specified byte array consists entirely of US ASCII characters.- Parameters:
raw- byte array to test.- Returns:
trueif the specified string consists entirely of US ASCII characters,falseotherwise.
-
isASCII
Returnstrueif the specified string consists entirely of US ASCII characters.- Parameters:
s- string to test.- Returns:
trueif the specified string consists entirely of US ASCII characters,falseotherwise.
-
isWhitespace
public static boolean isWhitespace(char ch) Returnstrueif the specified character is a whitespace character (CR, LF, SP or HT).- Parameters:
ch- character to test.- Returns:
trueif the specified character is a whitespace character,falseotherwise.
-
isWhitespace
Returnstrueif the specified string consists entirely of whitespace characters.- Parameters:
s- string to test.- Returns:
trueif the specified string consists entirely of whitespace characters,falseotherwise.
-
lookup
Returns a
Charsetinstance if character set with the given name is recognized and supported by Java runtime. Returnsnullotherwise.This method is a wrapper around
Charset.forName(String)method that catchesIllegalCharsetNameExceptionandUnsupportedCharsetExceptionand returnsnull.
-