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