1 16 package cintoo.messages.locale; 17 18 import java.util.Locale ; 19 20 28 public class ThreadLocale { 29 private boolean thread = true; 31 32 private Locale locale; 33 34 private ThreadLocal <Locale > threadLocal = new ThreadLocal <Locale >() { 38 protected Locale initialValue() { 39 return Locale.getDefault(); 40 } 41 }; 42 43 48 public void setThread(boolean thread) { 49 this.thread = thread; 50 } 51 52 58 public Locale get() { 59 if (thread) { 60 return threadLocal.get(); 61 } else { 62 return locale; 63 } 64 } 65 66 72 public void set(Locale locale) { 73 if (thread) { 74 threadLocal.set(locale); 75 } else { 76 this.locale = locale; 77 } 78 } 79 } 80 | Popular Tags |