org.apache.wicket.resource.loader
Class ClassStringResourceLoader

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

public class ClassStringResourceLoader
extends ComponentStringResourceLoader

This string resource loader attempts to find a single resource bundle that has the same name and location as the clazz provided in the constructor. If the bundle is found than strings are obtained from here. This implementation is fully aware of both locale and style values when trying to obtain the appropriate bundle.

An instance of this loader is registered with the Application by default.

Author:
Chris Turner, Juergen Donnerstag

Constructor Summary
ClassStringResourceLoader(java.lang.Class clazz)
          Create and initialize the resource loader.
 
Method Summary
 java.lang.String loadStringResource(java.lang.Class clazz, java.lang.String key, java.util.Locale locale, java.lang.String style)
          Get the string resource for the given combination of class, key, locale and style.
 java.lang.String loadStringResource(Component component, java.lang.String key)
          Get the string resource for the given combination of component and resource key.
 
Methods inherited from class org.apache.wicket.resource.loader.ComponentStringResourceLoader
isStopResourceSearch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassStringResourceLoader

public ClassStringResourceLoader(java.lang.Class clazz)
Create and initialize the resource loader.

Parameters:
clazz - The class that this resource loader is associated with
Method Detail

loadStringResource

public java.lang.String loadStringResource(java.lang.Class clazz,
                                           java.lang.String key,
                                           java.util.Locale locale,
                                           java.lang.String style)
Description copied from class: ComponentStringResourceLoader
Get the string resource for the given combination of class, key, locale and style. The information is obtained from a resource bundle associated with the provided Class (or one of its super classes).

Specified by:
loadStringResource in interface IStringResourceLoader
Overrides:
loadStringResource in class ComponentStringResourceLoader
Parameters:
clazz - The Class to find resources to be loaded
key - The key to obtain the string for
locale - The locale identifying the resource set to select the strings from
style - The (optional) style identifying the resource set to select the strings from (see Session)
Returns:
The string resource value or null if resource not found
See Also:
ComponentStringResourceLoader.loadStringResource(java.lang.Class, java.lang.String, java.util.Locale, java.lang.String)

loadStringResource

public java.lang.String loadStringResource(Component component,
                                           java.lang.String key)
Description copied from interface: IStringResourceLoader
Get the string resource for the given combination of component and resource key. 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
Overrides:
loadStringResource in class ComponentStringResourceLoader
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
Returns:
The string resource value or null if the resource could not be loaded by this loader
See Also:
ComponentStringResourceLoader.loadStringResource(org.apache.wicket.Component, java.lang.String)


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.