1 29 30 package nextapp.echo2.app; 31 32 import java.io.Serializable ; 33 import java.util.Collection ; 34 import java.util.Collections ; 35 import java.util.HashSet ; 36 import java.util.Locale ; 37 38 42 public class LayoutDirection 43 implements Serializable { 44 45 private static final Collection RTL_LANGUAGES; 46 static { 47 Collection rtlLanguages = new HashSet (); 48 rtlLanguages.add("ar"); rtlLanguages.add("fa"); rtlLanguages.add("iw"); rtlLanguages.add("ur"); RTL_LANGUAGES = Collections.unmodifiableCollection(rtlLanguages); 53 } 54 55 public static final LayoutDirection LTR = new LayoutDirection(true); 56 public static final LayoutDirection RTL = new LayoutDirection(false); 57 58 65 public static LayoutDirection forLocale(Locale locale) { 66 return RTL_LANGUAGES.contains(locale.getLanguage()) ? RTL : LTR; 67 } 68 69 private boolean leftToRight; 70 71 77 private LayoutDirection(boolean leftToRight) { 78 super(); 79 this.leftToRight = leftToRight; 80 } 81 82 87 public boolean isLeftToRight() { 88 return leftToRight; 89 } 90 91 94 public String toString() { 95 return leftToRight ? "LTR" : "RTL"; 96 } 97 } 98 | Popular Tags |