< prev index next >

src/jdk.charsets/share/classes/sun/nio/cs/ext/AbstractCharsetProvider.java

Print this page




 131         SoftReference<Charset> sr = cache.get(csn);
 132         if (sr != null) {
 133             Charset cs = sr.get();
 134             if (cs != null)
 135                 return cs;
 136         }
 137 
 138         // Do we even support this charset?
 139         String cln = classMap.get(csn);
 140 
 141         if (cln == null)
 142             return null;
 143 
 144         // Instantiate the charset and cache it
 145         try {
 146 
 147             Class<?> c = Class.forName(packagePrefix + "." + cln,
 148                                        true,
 149                                        this.getClass().getClassLoader());
 150 

 151             Charset cs = (Charset)c.newInstance();
 152             cache.put(csn, new SoftReference<Charset>(cs));
 153             return cs;
 154         } catch (ClassNotFoundException x) {
 155             return null;
 156         } catch (IllegalAccessException x) {
 157             return null;
 158         } catch (InstantiationException x) {
 159             return null;
 160         }
 161     }
 162 
 163     public final Charset charsetForName(String charsetName) {
 164         synchronized (this) {
 165             init();
 166             return lookup(canonicalize(charsetName));
 167         }
 168     }
 169 
 170     public final Iterator<Charset> charsets() {




 131         SoftReference<Charset> sr = cache.get(csn);
 132         if (sr != null) {
 133             Charset cs = sr.get();
 134             if (cs != null)
 135                 return cs;
 136         }
 137 
 138         // Do we even support this charset?
 139         String cln = classMap.get(csn);
 140 
 141         if (cln == null)
 142             return null;
 143 
 144         // Instantiate the charset and cache it
 145         try {
 146 
 147             Class<?> c = Class.forName(packagePrefix + "." + cln,
 148                                        true,
 149                                        this.getClass().getClassLoader());
 150 
 151             @SuppressWarnings("deprecation")
 152             Charset cs = (Charset)c.newInstance();
 153             cache.put(csn, new SoftReference<Charset>(cs));
 154             return cs;
 155         } catch (ClassNotFoundException x) {
 156             return null;
 157         } catch (IllegalAccessException x) {
 158             return null;
 159         } catch (InstantiationException x) {
 160             return null;
 161         }
 162     }
 163 
 164     public final Charset charsetForName(String charsetName) {
 165         synchronized (this) {
 166             init();
 167             return lookup(canonicalize(charsetName));
 168         }
 169     }
 170 
 171     public final Iterator<Charset> charsets() {


< prev index next >