Class ResourceStreamLocator

  • All Implemented Interfaces:
    IResourceStreamLocator
    Direct Known Subclasses:
    OsgiResourceStreamLocator

    public class ResourceStreamLocator
    extends java.lang.Object
    implements IResourceStreamLocator
    Locates Wicket resources.

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

    Resource matches will be attempted in the following order:

    1. <path>_<variation>_<style>_<locale>.<extension>
    2. <path>_<style>_<locale>.<extension>
    3. <path>_<locale>.<extension>
    4. <path>_<style>.<extension>
    5. <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>

    Resources will be actually loaded by the IResourceFinders defined in the resource settings. By default there are finders that look in the classpath and in the classpath in META-INF/resources. You can add more by adding WebApplicationPaths or Paths to ResourceSettings.getResourceFinders().

    Author:
    Juergen Donnerstag, Jonathan Locke
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.wicket.util.resource.IResourceStream locate​(java.lang.Class<?> clazz, java.lang.String path)
      Locate a resource, given a path and class.
      org.apache.wicket.util.resource.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.
      IResourceNameIterator newResourceNameIterator​(java.lang.String path, java.util.Locale locale, java.lang.String style, java.lang.String variation, java.lang.Iterable<java.lang.String> extensions, boolean strict)  
      IResourceNameIterator 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​(org.apache.wicket.util.file.IResourceFinder... finders)
        Constructor
        Parameters:
        finders - resource finders. These will be tried in the given order.
      • ResourceStreamLocator

        public ResourceStreamLocator​(java.util.List<org.apache.wicket.util.file.IResourceFinder> finders)
        Constructor
        Parameters:
        finders - resource finders. These will be tried in the given order.
    • Method Detail

      • locate

        public org.apache.wicket.util.resource.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)
      • newResourceNameIterator

        public IResourceNameIterator newResourceNameIterator​(java.lang.String path,
                                                             java.util.Locale locale,
                                                             java.lang.String style,
                                                             java.lang.String variation,
                                                             java.lang.Iterable<java.lang.String> extensions,
                                                             boolean strict)