if (extensions == null) {
Iterator<String> kwitr = getKeywords();
if (kwitr == null) {
extensions = LocaleExtensions.EMPTY_EXTENSIONS;
} else {
InternalLocaleBuilder intbld = new InternalLocaleBuilder();
while (kwitr.hasNext()) {
String key = kwitr.next();
if (key.equals(LOCALE_ATTRIBUTE_KEY)) {
// special keyword used for representing Unicode locale attributes
String[] uattributes = getKeywordValue(key).split("[-_]");
for (String uattr : uattributes) {
try {
intbld.addUnicodeLocaleAttribute(uattr);
} catch (LocaleSyntaxException e) {
// ignore and fall through
}
}
} else if (key.length() >= 2) {
String bcpKey = ldmlKeyToBCP47(key);
String bcpType = ldmlTypeToBCP47(key, getKeywordValue(key));
if (bcpKey != null && bcpType != null) {
try {
intbld.setUnicodeLocaleKeyword(bcpKey, bcpType);
} catch (LocaleSyntaxException e) {
// ignore and fall through
}
}
} else if (key.length() == 1 && (key.charAt(0) != UNICODE_LOCALE_EXTENSION)) {
try {
intbld.setExtension(key.charAt(0), getKeywordValue(key).replace("_", LanguageTag.SEP));
} catch (LocaleSyntaxException e) {
// ignore and fall through
}
}
}
extensions = intbld.getLocaleExtensions();
}
}
return extensions;
}