org.apache.james.mime4j.util
Class CharsetUtil

java.lang.Object
  extended by org.apache.james.mime4j.util.CharsetUtil

public class CharsetUtil
extends java.lang.Object

Utility class for working with character sets.


Field Summary
static int CR
          US-ASCII CR, carriage return (13)
static java.lang.String CRLF
          carriage return - line feed sequence
static java.nio.charset.Charset DEFAULT_CHARSET
           
static int HT
          US-ASCII HT, horizontal-tab (9)
static java.nio.charset.Charset ISO_8859_1
           
static int LF
          US-ASCII LF, line feed (10)
static int SP
          US-ASCII SP, space (32)
static java.nio.charset.Charset US_ASCII
           
static java.nio.charset.Charset UTF_8
           
 
Constructor Summary
CharsetUtil()
           
 
Method Summary
static boolean isASCII(char ch)
          Returns true if the specified character falls into the US ASCII character set (Unicode range 0000 to 007f).
static boolean isASCII(java.lang.String s)
          Returns true if the specified string consists entirely of US ASCII characters.
static boolean isWhitespace(char ch)
          Returns true if the specified character is a whitespace character (CR, LF, SP or HT).
static boolean isWhitespace(java.lang.String s)
          Returns true if the specified string consists entirely of whitespace characters.
static java.nio.charset.Charset lookup(java.lang.String name)
          Returns a Charset instance if character set with the given name is recognized and supported by Java runtime.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

US_ASCII

public static final java.nio.charset.Charset US_ASCII

ISO_8859_1

public static final java.nio.charset.Charset ISO_8859_1

UTF_8

public static final java.nio.charset.Charset UTF_8

DEFAULT_CHARSET

public static final java.nio.charset.Charset DEFAULT_CHARSET
Constructor Detail

CharsetUtil

public CharsetUtil()
Method Detail

isASCII

public static boolean isASCII(char ch)
Returns true if the specified character falls into the US ASCII character set (Unicode range 0000 to 007f).

Parameters:
ch - character to test.
Returns:
true if the specified character falls into the US ASCII character set, false otherwise.

isASCII

public static boolean isASCII(java.lang.String s)
Returns true if the specified string consists entirely of US ASCII characters.

Parameters:
s - string to test.
Returns:
true if the specified string consists entirely of US ASCII characters, false otherwise.

isWhitespace

public static boolean isWhitespace(char ch)
Returns true if the specified character is a whitespace character (CR, LF, SP or HT).

Parameters:
ch - character to test.
Returns:
true if the specified character is a whitespace character, false otherwise.

isWhitespace

public static boolean isWhitespace(java.lang.String s)
Returns true if the specified string consists entirely of whitespace characters.

Parameters:
s - string to test.
Returns:
true if the specified string consists entirely of whitespace characters, false otherwise.

lookup

public static java.nio.charset.Charset lookup(java.lang.String name)
Returns a Charset instance if character set with the given name is recognized and supported by Java runtime. Returns null otherwise.

This method is a wrapper around Charset.forName(String) method that catches IllegalCharsetNameException and UnsupportedCharsetException and returns null.



Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.