FileDocCategorySizeDatePackage
CodeSetCache.javaAPI DocJava SE 5 API2681Fri Aug 26 14:54:20 BST 2005com.sun.corba.se.impl.encoding

CodeSetCache

public class CodeSetCache extends Object
Thread local cache of sun.io code set converters for performance. The thread local class contains a single reference to a Map[] containing two WeakHashMaps. One for CharsetEncoders and one for CharsetDecoders. Constants are defined for indexing. This is used internally by CodeSetConversion.

Fields Summary
private ThreadLocal
converterCaches
The ThreadLocal data is a 2 element Map array indexed by BTC_CACHE_MAP and CTB_CACHE_MAP.
private static final int
BTC_CACHE_MAP
Index in the thread local converterCaches array for the byte to char converter Map. A key is the Java name corresponding to the desired code set.
private static final int
CTB_CACHE_MAP
Index in the thread local converterCaches array for the char to byte converter Map. A key is the Java name corresponding to the desired code set.
Constructors Summary
Methods Summary
java.nio.charset.CharsetDecodergetByteToCharConverter(java.lang.Object key)
Retrieve a CharsetDecoder from the Map using the given key.


                   
       
        Map btcMap = ((Map[])converterCaches.get())[BTC_CACHE_MAP];
        
        return (CharsetDecoder)btcMap.get(key);
    
java.nio.charset.CharsetEncodergetCharToByteConverter(java.lang.Object key)
Retrieve a CharsetEncoder from the Map using the given key.

        Map ctbMap = ((Map[])converterCaches.get())[CTB_CACHE_MAP];

        return (CharsetEncoder)ctbMap.get(key);
    
java.nio.charset.CharsetDecodersetConverter(java.lang.Object key, java.nio.charset.CharsetDecoder converter)
Stores the given CharsetDecoder in the thread local cache, and returns the same converter.

        Map btcMap = ((Map[])converterCaches.get())[BTC_CACHE_MAP];

        btcMap.put(key, converter);

        return converter;
    
java.nio.charset.CharsetEncodersetConverter(java.lang.Object key, java.nio.charset.CharsetEncoder converter)
Stores the given CharsetEncoder in the thread local cache, and returns the same converter.


        Map ctbMap = ((Map[])converterCaches.get())[CTB_CACHE_MAP];

        ctbMap.put(key, converter);

        return converter;