1 29 30 package com.caucho.i18n; 31 32 import com.caucho.config.ConfigException; 33 import com.caucho.loader.EnvironmentLocal; 34 import com.caucho.util.L10N; 35 import com.caucho.vfs.Encoding; 36 37 import javax.annotation.PostConstruct; 38 39 42 public class CharacterEncoding { 43 private static final L10N L = new L10N(CharacterEncoding.class); 44 45 private static final EnvironmentLocal<String > _localEncoding = 46 new EnvironmentLocal<String >("caucho.i18n.encoding"); 47 48 private String _encoding; 49 50 53 public void setValue(String name) 54 { 55 _encoding = Encoding.getMimeName(name); 56 } 57 58 public static String getLocalEncoding() 59 { 60 return _localEncoding.get(); 61 } 62 63 66 @PostConstruct 67 public void init() 68 throws Exception 69 { 70 if (_encoding == null) 71 throw new ConfigException(L.l("character-encoding requires a 'value' attribute with the character encoding.")); 72 73 _localEncoding.set(_encoding); 74 } 75 76 public String toString() 77 { 78 return "CharacterEncoding[" + _encoding + "]"; 79 } 80 } 81 82 | Popular Tags |