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 java.lang.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(java.lang.Class<?> clazz, java.lang.String path)
          Locate a resource, given a path and class.
 IResourceStream locate(java.lang.Class<?> clazz, java.lang.String path, java.lang.String style, java.lang.String variation, java.util.Locale locale, java.lang.String extension, boolean strict)
          Locate a resource by combining the given path, style, variation, locale and extension parameters.
protected  IResourceStream locateByClassLoader(java.lang.Class<?> clazz, java.lang.String path)
          Search the the resource my means of the various classloaders available
protected  IResourceStream locateByResourceFinder(java.lang.Class<?> clazz, java.lang.String path)
          Search the resource by means of the application registered resource finder
 ResourceNameIterator newResourceNameIterator(java.lang.String path, java.util.Locale locale, java.lang.String style, java.lang.String variation, java.lang.String extension, boolean strict)
          Markup resources and Properties files both need to iterate over different combinations of locale, style, etc..
 
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(java.lang.Class<?> clazz,
                              java.lang.String path)
Description copied from interface: IResourceStreamLocator
Locate 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 #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(java.lang.Class<?> clazz,
                              java.lang.String path,
                              java.lang.String style,
                              java.lang.String variation,
                              java.util.Locale locale,
                              java.lang.String extension,
                              boolean strict)
Description copied from interface: IResourceStreamLocator
Locate a resource by combining the given path, style, variation, locale and extension parameters. The exact search order depends on the implementation.

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)
variation - The component's variation (of the style)
locale - The locale of the resource to load
extension - A comma separate list of extensions
strict - whether the specified attributes must match exactly
Returns:
The resource or null
See Also:
IResourceStreamLocator.locate(java.lang.Class, java.lang.String, java.lang.String, java.lang.String, java.util.Locale, java.lang.String, boolean)

locateByClassLoader

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

Parameters:
clazz -
path -
Returns:
resource stream

locateByResourceFinder

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

Parameters:
clazz -
path -
Returns:
resource stream

newResourceNameIterator

public ResourceNameIterator newResourceNameIterator(java.lang.String path,
                                                    java.util.Locale locale,
                                                    java.lang.String style,
                                                    java.lang.String variation,
                                                    java.lang.String extension,
                                                    boolean strict)
Description copied from interface: IResourceStreamLocator
Markup resources and Properties files both need to iterate over different combinations of locale, style, etc.. And though no single locate(..) method exists which is used by both, they both use ResourceNameIterators.

Specified by:
newResourceNameIterator in interface IResourceStreamLocator
Parameters:
path - The path of the resource
locale - The locale of the resource to load
style - Any resource style, such as a skin style (see Session)
variation - The component's variation (of the style)
extension - A comma separate list of extensions
strict - whether the specified attributes must match exactly
Returns:
resource name iterator
See Also:
IResourceStreamLocator.newResourceNameIterator(java.lang.String, java.util.Locale, java.lang.String, java.lang.String, java.lang.String, boolean)


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