1 package com.sslexplorer.language; 2 3 import java.util.Locale ; 4 5 11 public class Language implements Comparable { 12 13 15 private String code; 16 private String description; 17 private Locale locale; 18 private LanguagePackDefinition pack; 19 20 31 public Language(LanguagePackDefinition pack, String code, String description) { 32 this.code = code; 33 this.pack = pack; 34 this.description = description; 35 String language = code; 36 String country = ""; 37 String variant = ""; 38 int idx = language.indexOf('_'); 39 if (idx != -1) { 40 country = language.substring(idx + 1); 41 language = language.substring(0, idx); 42 } 43 idx = country.indexOf('_'); 44 if (idx != -1) { 45 variant = country.substring(idx + 1); 46 country = country.substring(0, idx); 47 } 48 locale = new Locale (language, country, variant); 49 } 50 51 57 public LanguagePackDefinition getPack() { 58 return pack; 59 } 60 61 66 public Locale getLocale() { 67 return locale; 68 } 69 70 75 public String getCode() { 76 return code; 77 } 78 79 84 public String getDescription() { 85 return description; 86 } 87 88 93 public int compareTo(Object o) { 94 return getDescription().compareTo(((Language) o).getDescription()); 95 } 96 97 102 public boolean equals(Object o) { 103 return getCode().equals(((Language) o).getCode()); 104 } 105 106 114 public boolean isLocale(Locale locale) { 115 return getLocale().equals(locale); 116 } 117 } | Popular Tags |