• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.unicode.cldr.util;
2 
3 import java.util.EnumSet;
4 import java.util.HashMap;
5 import java.util.Map;
6 import java.util.Set;
7 
8 import com.google.common.collect.ImmutableSet;
9 
10 /**
11  * This list needs updating as a new organizations are added; that's by design
12  * so that we know when new ones show up.
13  */
14 public enum Organization {
15     // Please update Locales.txt for default coverage when adding an organization here.
16     adlam("Winden Jangen Adlam"),
17     adobe("Adobe"),
18     afghan_csa("Afghan CSA"),
19     afghan_mcit("Afghan MCIT"),
20     afrigen("Afrigen"),
21     apple("Apple"),
22     bangladesh("Bangladesh", "Bangladesh Computer Council"),
23     bangor_univ("Bangor Univ."),
24     bhutan("Bhutan DDC"),
25     breton("Office of Breton Lang"),
26     cherokee("Cherokee Nation"),
27     cldr("Cldr"),
28     gaeilge("Foras na Gaeilge"),
29     georgia_isi("Georgia ISI"),
30     gnome("Gnome Foundation"),
31     google("Google"),
32     guest("Guest (Unicode)"),
33     ibm("IBM"),
34     india("India MIT"),
35     iran_hci("Iran HCI"),
36     kendra("Kendra (Nepal)"),
37     kotoistus("Kotoistus (Finnish IT Ctr)"),
38     kunsill_malti("Il-Kunsill Nazzjonali tal-Ilsien Malti", "National Council for the Maltese Language", "malta", "malti"),
39     lakota_lc("Lakota LC"),
40     lao_dpt("Lao Posts/Telecom??"),
41     longnow("The Long Now Foundation", "Long Now", "PanLex", "Utilka Foundation"),
42     meta("Meta", "Facebook"),
43     microsoft("Microsoft"),
44     mozilla("Mozilla"),
45     netflix("Netflix"),
46     nyiakeng_puachue_hmong("Nyiakeng Puachue Hmong"),
47     openinstitute("Open Inst (Cambodia)"),
48     openoffice_org("Open Office"),
49     oracle("Oracle", "sun", "Sun Micro"),
50     pakistan("Pakistan"),
51     rodakych("Rodakych", "Nigerian Pidgin"),
52     rohingyazuban("Rohingya Language Council", "RLC", "Rohingya Zuban"),
53     rumantscha("Lia Rumantscha"),
54     sardware("Sardware", "Sardware"),
55     sil("SIL", "SIL International"),
56     special("High Coverage and Generated"),
57     srilanka("Sri Lanka ICTA", "Sri Lanka"),
58     surveytool("Survey Tool"),
59     venetian("VeC - Lengua Veneta"),
60     welsh_lc("Welsh LC"),
61     wikimedia("Wikimedia Foundation"),
62     wod_nko("WOD N’ko", "World Organization for the Development of N’ko", "WODN"),
63     yahoo("Yahoo"),
64     ;
65 
66     private final static Set<Organization> TC_ORGS = ImmutableSet.copyOf(EnumSet.of(google, apple, microsoft));
67 
68     /**
69      * Get a list of the TC Organizations
70      * @return
71      */
getTCOrgs()72     public static Set<Organization> getTCOrgs() {
73         return TC_ORGS;
74     }
75 
76     /**
77      * Is this organization a TC Org?
78      * @return
79      */
isTCOrg()80     public boolean isTCOrg() {
81         return getTCOrgs().contains(this);
82     }
83 
84     public final String displayName;
85     private final String[] names;
86 
fromString(String name)87     public static Organization fromString(String name) {
88         if (name == null) {
89             throw new NullPointerException("Organization.fromString(null) called");
90         }
91         if (name.contains("Government of Pakistan")) {
92             /*
93              * "Government of Pakistan - National Language Authority"
94              * occurs in the cldr_users table; avoid problems with hyphen
95              */
96             return Organization.pakistan;
97         } else if (name.contains("Utilika")) {
98             /*
99              * "Utilika" and "Utilika Foundation" occur in the cldr_users table.
100              * Compare "Utilka Foundation", one of the variants for Organization.longnow
101              */
102             return Organization.longnow;
103         }
104         name = name.toLowerCase().replace('-', '_').replace('.', '_');
105         Organization org = OrganizationNameMap.get(name);
106         return org;
107     }
108 
getDisplayName()109     public String getDisplayName() {
110         return displayName;
111     }
112 
113     static Map<String, Organization> OrganizationNameMap;
114     static {
115         OrganizationNameMap = new HashMap<>();
116         for (Organization x : values()) {
117             OrganizationNameMap.put(x.displayName.toLowerCase().replace('-', '_').replace('.', '_'), x);
118             for (String name : x.names) {
119                 OrganizationNameMap.put(name.toLowerCase().replace('-', '_').replace('.', '_'), x);
120             }
121             OrganizationNameMap.put(x.name().toLowerCase().replace('-', '_').replace('.', '_'), x);
122         }
123     }
124 
125     /**
126      * @param displayName Preferred display name for the organization
127      * @param names Alternate aliases for this organization
128      */
Organization(String displayName, String... names)129     private Organization(String displayName, String... names) {
130         this.displayName = displayName;
131         this.names = names;
132     }
133 
134     private LocaleSet localeSet = null;
135 
getCoveredLocales()136     public LocaleSet getCoveredLocales() {
137         if (localeSet == null) {
138             final Set<String> localeNameSet = StandardCodes.make().getLocaleCoverageLocales(this);
139             if (localeNameSet.contains(LocaleNormalizer.ALL_LOCALES)) {
140                 localeSet = LocaleNormalizer.ALL_LOCALES_SET;
141             } else {
142                 localeSet = new LocaleSet(localeNameSet);
143             }
144         }
145         return localeSet;
146     }
147 }
148