* @return the metadata for the feature. If the feature has no metadata, then default
* metadata is returned.
*/
public CALFeatureMetadata getMetadata(CALFeatureName featureName, Locale locale) {
LocalizedResourceName resourceName = new LocalizedResourceName(featureName, locale);
InputStream metadataInputStream;
Status loadStatus = null;
CALFeatureMetadata metadata;
// Keep track of the originally requested locale
Locale originalLocale = locale;
synchronized (cacheLock) {
// Check if we already have this cached
MetadataCacheEntry cacheEntry = metadataCache.get(resourceName);
if (cacheEntry != null) {
return cacheEntry.getMetadata();
}
// Get the input stream for the metadata, and use this to load.
metadataInputStream = metadataStore.getInputStream(resourceName);
// go through the fallback mechanism if necessary
// variant-specific locale not found, fallback to country-specific locale
if (metadataInputStream == null && locale.getVariant().length() > 0) {
locale = new Locale(locale.getLanguage(), locale.getCountry());
resourceName = new LocalizedResourceName(featureName, locale);
metadataInputStream = metadataStore.getInputStream(resourceName);
}
// country-specific locale not found, fallback to language-specific locale
if (metadataInputStream == null && locale.getCountry().length() > 0) {
locale = new Locale(locale.getLanguage());
resourceName = new LocalizedResourceName(featureName, locale);
metadataInputStream = metadataStore.getInputStream(resourceName);
}
// language-specific locale not found, fallback to neutral locale
if (metadataInputStream == null) {
locale = LocaleUtilities.INVARIANT_LOCALE;
resourceName = new LocalizedResourceName(featureName, locale);
metadataInputStream = metadataStore.getInputStream(resourceName);
}
if (metadataInputStream == null) {
metadata = getEmptyMetadata(featureName, originalLocale);