Package org.apache.james.mime4j.util
Class CharsetUtil
- java.lang.Object
-
- org.apache.james.mime4j.util.CharsetUtil
-
public class CharsetUtil extends java.lang.ObjectUtility class for working with character sets.
-
-
Constructor Summary
Constructors Constructor Description CharsetUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisASCII(char ch)Returnstrueif the specified character falls into the US ASCII character set (Unicode range 0000 to 007f).static booleanisASCII(java.lang.String s)Returnstrueif 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 booleanisWhitespace(java.lang.String s)Returnstrueif the specified string consists entirely of whitespace characters.static java.nio.charset.Charsetlookup(java.lang.String name)Returns aCharsetinstance if character set with the given name is recognized and supported by Java runtime.
-
-
-
Field Detail
-
CRLF
public static final java.lang.String CRLF
carriage return - line feed sequence- See Also:
- Constant Field Values
-
CR
public static final int CR
US-ASCII CR, carriage return (13)- See Also:
- Constant Field Values
-
LF
public static final int LF
US-ASCII LF, line feed (10)- See Also:
- Constant Field Values
-
SP
public static final int SP
US-ASCII SP, space (32)- See Also:
- Constant Field Values
-
HT
public static final int HT
US-ASCII HT, horizontal-tab (9)- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public static boolean isASCII(ByteSequence raw)
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
public static boolean isASCII(java.lang.String s)
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
public static boolean isWhitespace(java.lang.String s)
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
public static java.nio.charset.Charset lookup(java.lang.String name)
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.
-
-