Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 17 18 package org.apache.catalina.util; 19 20 21 import java.io.InputStream ; 22 import java.util.Locale ; 23 import java.util.Properties ; 24 25 26 27 38 39 public class CharsetMapper { 40 41 42 44 45 48 public static final String DEFAULT_RESOURCE = 49 "/org/apache/catalina/util/CharsetMapperDefault.properties"; 50 51 52 54 55 58 public CharsetMapper() { 59 this(DEFAULT_RESOURCE); 60 } 61 62 63 71 public CharsetMapper(String name) { 72 try { 73 InputStream stream = 74 this.getClass().getResourceAsStream(name); 75 map.load(stream); 76 stream.close(); 77 } catch (Throwable t) { 78 throw new IllegalArgumentException (t.toString()); 79 } 80 } 81 82 83 85 86 90 private Properties map = new Properties (); 91 92 93 95 96 103 public String getCharset(Locale locale) { 104 String charset = map.getProperty(locale.toString()); 107 if (charset == null) { 108 charset = map.getProperty(locale.getLanguage() + "_" 109 + locale.getCountry()); 110 if (charset == null) { 111 charset = map.getProperty(locale.getLanguage()); 112 } 113 } 114 return (charset); 115 } 116 117 118 127 public void addCharsetMappingFromDeploymentDescriptor(String locale, String charset) { 128 map.put(locale, charset); 129 } 130 131 132 } 133
| Popular Tags
|