Package org.openquark.cal.services

Examples of org.openquark.cal.services.LocalizedResourceName


       
        if (featureName == null || locale == null) {
            throw new NullPointerException();
        }
       
        this.resourceName = new LocalizedResourceName(featureName, locale);
    }
View Full Code Here


     * @param featureName the feature to check
     * @param locale the locale to check.
     * @return whether metadata exists for the given feature.
     */
    public boolean hasMetadata(CALFeatureName featureName, Locale locale) {
        return metadataStore.hasFeature(new LocalizedResourceName(featureName, locale));
    }
View Full Code Here

     * @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);
View Full Code Here

     * @param saveStatus
     * @return true if metadata was saved, false otherwise
     */
    boolean saveMetadata(CALFeatureMetadata metadata, CALFeatureName metadataName, Locale locale, Status saveStatus) {
       
        LocalizedResourceName resourceName = new LocalizedResourceName(metadataName, locale);
       
        // Create an output stream for the metadata.
        OutputStream metadataOutputStream = metadataStore.getOutputStream(resourceName, saveStatus);
        if (metadataOutputStream == null) {
            return false;
View Full Code Here

    void removeModule(ModuleName moduleName) {
        // For now, there is nothing for it but to iterate over all the entries in the cache.
        for (Iterator<Map.Entry<LocalizedResourceName, MetadataCacheEntry>> it = dataCache.entrySet().iterator(); it.hasNext(); ) {
            Map.Entry<LocalizedResourceName, MetadataCacheEntry> mapEntry = it.next();

            LocalizedResourceName cacheEntryKey = mapEntry.getKey();
            CALFeatureName cacheEntryFeatureName = (CALFeatureName)cacheEntryKey.getFeatureName();
            if (cacheEntryFeatureName.hasModuleName() && cacheEntryFeatureName.toModuleName().equals(moduleName)) {
                it.remove();
            }
        }
    }
View Full Code Here

            int lastDotInStrippedFileName = strippedFileName.lastIndexOf('.');
            if (lastDotInStrippedFileName == -1) {
                // no locale
                String featureString = FileSystemResourceHelper.fromFileSystemName(strippedFileName);
               
                return new LocalizedResourceName(getFeatureNameFromFeatureString(moduleName, featureType, featureString), LocaleUtilities.INVARIANT_LOCALE);
               
            } else {
                String maybeLocaleString = strippedFileName.substring(lastDotInStrippedFileName + 1);
               
                if (maybeLocaleString.startsWith(METADATA_LOCALE_PREFIX)) {
                    String localeString = maybeLocaleString.substring(METADATA_LOCALE_PREFIX.length());
                    Locale locale = LocaleUtilities.localeFromCanonicalString(localeString);
                   
                    String featureString = FileSystemResourceHelper.fromFileSystemName(strippedFileName.substring(0, lastDotInStrippedFileName));
                   
                    return new LocalizedResourceName(getFeatureNameFromFeatureString(moduleName, featureType, featureString), locale);
                   
                } else {
                    // no locale
                    String featureString = FileSystemResourceHelper.fromFileSystemName(strippedFileName);
                   
                    return new LocalizedResourceName(getFeatureNameFromFeatureString(moduleName, featureType, featureString), LocaleUtilities.INVARIANT_LOCALE);
                }
            }
        }
       
        return null;
View Full Code Here

TOP

Related Classes of org.openquark.cal.services.LocalizedResourceName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.