Class NestedStringResourceLoader

  • All Implemented Interfaces:
    IStringResourceLoader

    public class NestedStringResourceLoader
    extends Object
    implements IStringResourceLoader
    Creates a nested string resource loader which resolves nested keys.

    Example:
     
     List loaders = getResourceSettings().getStringResourceLoaders();
     // Add more loaders here
     NestedStringResourceLoader element = new NestedStringResourceLoader(loaders,Pattern.compile("#\\(([^ ]*?)\\)"));
     loaders.clear();
     loaders.add(element);
     
     
    Author:
    Sven Meier, Tobias Soloschenko
    • Constructor Detail

      • NestedStringResourceLoader

        public NestedStringResourceLoader​(List<IStringResourceLoader> loaders,
                                          Pattern pattern)
        Creates a nested string resource loader
        Parameters:
        loaders - the loaders to be added in a chain
        pattern - the pattern for nested keys. Example for #(key) is the pattern: Pattern.compile("#\\(([^ ]*?)\\)");
    • Method Detail

      • loadStringResource

        public String loadStringResource​(Component component,
                                         String key,
                                         Locale locale,
                                         String style,
                                         String variation)
        Description copied from interface: IStringResourceLoader
        Get the string resource for the given combination of component, resource key, locale and style. The component provided is used to allow implementation of component specific resource loading (e.g. per page or per reusable component). The key should be a String containing a lookup key into a resource bundle. The Locale and the style will be taken from the Component provided.
        Specified by:
        loadStringResource in interface IStringResourceLoader
        Parameters:
        component - The component to get the string resource for
        key - The key should be a String containing a lookup key into a resource bundle
        locale - Will be preset with the appropriate value. You shall ignore the component's locale.
        style - Will be preset with the appropriate value. You shall ignore the component's style.
        variation - Will be preset with the appropriate value. You shall ignore the component's variation.
        Returns:
        The string resource value or null if the resource could not be loaded by this loader
      • loadStringResource

        public String loadStringResource​(Class<?> clazz,
                                         String key,
                                         Locale locale,
                                         String style,
                                         String variation)
        Description copied from interface: IStringResourceLoader
        Get the string resource for the given combination of component class, resource key, locale and style. The component class provided is used to allow implementation of component specific resource loading (e.g. per page or per reusable component). The key should be a String containing a lookup key into a resource bundle. The locale should contain the locale of the current operation so that the appropriate set of resources can be selected. The style allows the set of resources to select to be varied by skin/brand.
        Specified by:
        loadStringResource in interface IStringResourceLoader
        Parameters:
        clazz - The class to get the string resource for
        key - The key should be a String containing a lookup key into a resource bundle
        locale - The locale should contain the locale of the current operation so that the appropriate set of resources can be selected
        style - The style identifying the resource set to select the strings from (see Session)
        variation - The components variation (of the style)
        Returns:
        The string resource value or null if the resource could not be loaded by this loader