org.apache.wicket.resource.loader
Class BundleStringResourceLoader

java.lang.Object
  extended by org.apache.wicket.resource.loader.BundleStringResourceLoader
All Implemented Interfaces:
IStringResourceLoader

public class BundleStringResourceLoader
extends java.lang.Object
implements IStringResourceLoader

Implementation of a string resource loader that sits on top of the ordinary Java resource bundle mechanism. When created this loader must be given the name of the resource bundle that it is to sit on top of. Note that this implementation does not make use of any style or component specific knowledge - it utilizes just the bundle name, the resource key and the locale.

Author:
Chris Turner

Constructor Summary
BundleStringResourceLoader(java.lang.String bundleName)
          Create the loader with the name of the given Java resource bundle.
 
Method Summary
 java.lang.String loadStringResource(java.lang.Class<?> clazz, java.lang.String key, java.util.Locale locale, java.lang.String style, java.lang.String variation)
          Get the value via a Java ResourceBundle
 java.lang.String loadStringResource(Component component, java.lang.String key, java.util.Locale locale, java.lang.String style, java.lang.String variation)
          Get the requested string resource from the underlying resource bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BundleStringResourceLoader

public BundleStringResourceLoader(java.lang.String bundleName)
Create the loader with the name of the given Java resource bundle.

Parameters:
bundleName - The name of the resource bundle
Method Detail

loadStringResource

public final java.lang.String loadStringResource(java.lang.Class<?> clazz,
                                                 java.lang.String key,
                                                 java.util.Locale locale,
                                                 java.lang.String style,
                                                 java.lang.String variation)
Get the value via a Java ResourceBundle

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

loadStringResource

public final java.lang.String loadStringResource(Component component,
                                                 java.lang.String key,
                                                 java.util.Locale locale,
                                                 java.lang.String style,
                                                 java.lang.String variation)
Get the requested string resource from the underlying resource bundle. The bundle is selected by locale and the string obtained from the best matching bundle.

Specified by:
loadStringResource in interface IStringResourceLoader
Parameters:
component - Used to get the locale
key - The key to obtain the string for
locale - If != null, it supersedes the component's locale
style - ignored
variation - ignored
Returns:
The string resource value or null if resource not found


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.