Speed up compilation when locales are not used

This commit is contained in:
konsoletyper 2014-06-27 16:10:51 +04:00
parent b94d711732
commit 54e0c43fb2
2 changed files with 21 additions and 2 deletions

View File

@ -100,6 +100,7 @@
<argument>java.lang.reflect</argument>
<argument>java.io</argument>
<argument>java.net</argument>
<argument>java.text</argument>
<argument>java.util</argument>
<argument>java.util.logging</argument>
<argument>java.util.concurrent</argument>

View File

@ -38,10 +38,21 @@ public class CLDRReader {
private Set<String> availableLocales = new LinkedHashSet<>();
private Set<String> availableLanguages = new LinkedHashSet<>();
private Set<String> availableCountries = new LinkedHashSet<>();
private boolean initialized;
private Properties properties;
private ClassLoader classLoader;
public CLDRReader(Properties properties, ClassLoader classLoader) {
findAvailableLocales(properties);
readCLDR(classLoader);
this.properties = properties;
this.classLoader = classLoader;
}
private synchronized void ensureInitialized() {
if (!initialized) {
initialized = true;
findAvailableLocales(properties);
readCLDR(classLoader);
}
}
private void findAvailableLocales(Properties properties) {
@ -278,30 +289,37 @@ public class CLDRReader {
}
public Map<String, CLDRLocale> getKnownLocales() {
ensureInitialized();
return Collections.unmodifiableMap(knownLocales);
}
public Set<String> getAvailableLocales() {
ensureInitialized();
return Collections.unmodifiableSet(availableLocales);
}
public Set<String> getAvailableLanguages() {
ensureInitialized();
return Collections.unmodifiableSet(availableLanguages);
}
public Set<String> getAvailableCountries() {
ensureInitialized();
return Collections.unmodifiableSet(availableCountries);
}
public Map<String, Integer> getMinDaysMap() {
ensureInitialized();
return Collections.unmodifiableMap(minDaysMap);
}
public Map<String, Integer> getFirstDayMap() {
ensureInitialized();
return Collections.unmodifiableMap(firstDayMap);
}
public Map<String, String> getLikelySubtags() {
ensureInitialized();
return Collections.unmodifiableMap(likelySubtags);
}
}