java.lang.Object
org.glassfish.grizzly.utils.Charsets
Charset utility class.
- Author:
- Alexey Stashok
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidRemove all preloaded charsets.static CharsetDecodergetCharsetDecoder(Charset charset) Return theCharset'sCharsetDecoder.static CharsetEncodergetCharsetEncoder(Charset charset) Return theCharset'sCharsetEncoder.static CharsetlookupCharset(String charsetName) Lookup aCharsetby name.static voidPreloads allCharsets available to the JMV, which makes charset searching faster (at the cost of memory).
-
Field Details
-
DEFAULT_CHARACTER_ENCODING
The default character encoding of this Java virtual machine. -
ASCII_CHARSET
-
UTF8_CHARSET
-
DEFAULT_CHARSET
Returns the default charset of this Java virtual machine.- See Also:
-
CODECS_CACHE_SIZE
public static final int CODECS_CACHE_SIZE- See Also:
-
-
Constructor Details
-
Charsets
public Charsets()
-
-
Method Details
-
lookupCharset
Lookup aCharsetby name. Fixes Charset concurrency issue (http://paul.vox.com/library/post/the-mysteries-of-java-character-set-performance.html)- Parameters:
charsetName-- Returns:
Charset
-
preloadAllCharsets
public static void preloadAllCharsets()Preloads allCharsets available to the JMV, which makes charset searching faster (at the cost of memory). The speed gain is most noticable in the case of non-existing charsets as it allows us to avoid an expensive call toCharset.forName(java.lang.String). -
drainAllCharsets
public static void drainAllCharsets()Remove all preloaded charsets. -
getCharsetDecoder
Return theCharset'sCharsetDecoder. The Charsets class maintains theCharsetDecoderthread-local cache. Be aware - this shouldn't be used by multiple threads.- Parameters:
charset-Charset.- Returns:
- the
Charset'sCharsetDecoder.
-
getCharsetEncoder
Return theCharset'sCharsetEncoder. The Charsets class maintains theCharsetEncoderthread-local cache. Be aware - this shouldn't be used by multiple threads.- Parameters:
charset-Charset.- Returns:
- the
Charset'sCharsetEncoder.
-