org.apache.wicket.util.resource.locator
Class ResourceStreamLocator

java.lang.Object
  extended by org.apache.wicket.util.resource.locator.ResourceStreamLocator
All Implemented Interfaces:
IResourceStreamLocator
Direct Known Subclasses:
OsgiResourceStreamLocator

public class ResourceStreamLocator
extends Object
implements IResourceStreamLocator

Locate Wicket resource.

Contains the logic to locate a resource based on a path, a style (see Session), a locale and an extension string. The full filename will be built like: <path>_<style>_<locale>.<extension>.

Resource matches will be attempted in the following order:

  1. 1. <path>_<style>_<locale>.<extension>
  2. 2. <path>_<locale>.<extension>
  3. 3. <path>_<style>.<extension>
  4. 4. <path>.<extension>

Locales may contain a language, a country and a region or variant. Combinations of these components will be attempted in the following order:

  1. locale.toString() see javadoc for Locale for more details
  2. <language>_<country>
  3. <language>

Author:
Juergen Donnerstag, Jonathan Locke

Constructor Summary
ResourceStreamLocator()
          Constructor
ResourceStreamLocator(IResourceFinder finder)
          Constructor
 
Method Summary
 IResourceStream locate(Class<?> clazz, String path)
          Loads a resource, given a path and class.
 IResourceStream locate(Class<?> clazz, String path, String style, Locale locale, String extension)
          Loads a resource, given a path, style, locale and extension.
protected  IResourceStream locateByClassLoader(Class<?> clazz, String path)
          Search the the resource my means of the various classloaders available
protected  IResourceStream locateByResourceFinder(Class<?> clazz, String path)
          Search the resource by means of the application registered resource finder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceStreamLocator

public ResourceStreamLocator()
Constructor


ResourceStreamLocator

public ResourceStreamLocator(IResourceFinder finder)
Constructor

Parameters:
finder - resource finder
Method Detail

locate

public IResourceStream locate(Class<?> clazz,
                              String path)
Description copied from interface: IResourceStreamLocator
Loads a resource, given a path and class. Typically this method is either called by external clients if they are not interested in a lookup that takes the style and locale into account, or it is called by the implementation of IResourceStreamLocator.locate(Class, String, String, Locale, String) where the latter just takes care of trying out the different combinations for the provided style and locale and uses this method to actually load the resource stream.

Specified by:
locate in interface IResourceStreamLocator
Parameters:
clazz - The class loader for delegating the loading of the resource
path - The path of the resource
Returns:
The resource or null
See Also:
IResourceStreamLocator.locate(java.lang.Class, java.lang.String)

locate

public IResourceStream locate(Class<?> clazz,
                              String path,
                              String style,
                              Locale locale,
                              String extension)
Description copied from interface: IResourceStreamLocator
Loads a resource, given a path, style, locale and extension.

Specified by:
locate in interface IResourceStreamLocator
Parameters:
clazz - The class loader for delegating the loading of the resource
path - The path of the resource
style - Any resource style, such as a skin style (see Session)
locale - The locale of the resource to load
extension - The extension of the resource
Returns:
The resource or null
See Also:
IResourceStreamLocator.locate(java.lang.Class, java.lang.String, java.lang.String, java.util.Locale, java.lang.String)

locateByClassLoader

protected IResourceStream locateByClassLoader(Class<?> clazz,
                                              String path)
Search the the resource my means of the various classloaders available

Parameters:
clazz -
path -
Returns:
resource stream

locateByResourceFinder

protected IResourceStream locateByResourceFinder(Class<?> clazz,
                                                 String path)
Search the resource by means of the application registered resource finder

Parameters:
clazz -
path -
Returns:
resource stream


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