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

java.lang.Object
  extended by org.apache.wicket.util.resource.locator.ResourceNameIterator
All Implemented Interfaces:
java.util.Iterator<java.lang.String>

public class ResourceNameIterator
extends java.lang.Object
implements java.util.Iterator<java.lang.String>

Contains the logic to locate a resource based on a path, a style (see Session), a locale and a extension strings. 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>

Extensions may be a comma separated list of extensions, e.g. "properties,xml"

Author:
Juergen Donnerstag

Constructor Summary
ResourceNameIterator(java.lang.String path, java.lang.String style, java.lang.String variation, java.util.Locale locale, java.lang.String extensions, boolean strict)
          Construct.
 
Method Summary
 java.util.Locale getLocale()
          Get the exact Locale which has been used for the latest resource path.
protected  java.lang.String getLocaleFromFilename(java.lang.String path)
          Extract the locale from the filename in case where the user
 boolean hasNext()
           
 java.lang.String next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceNameIterator

public ResourceNameIterator(java.lang.String path,
                            java.lang.String style,
                            java.lang.String variation,
                            java.util.Locale locale,
                            java.lang.String extensions,
                            boolean strict)
Construct.

Parameters:
path - The path of the resource without extension
style - A theme or style (see Session)
variation - The component's variation (of the style)
locale - The Locale to apply
extensions - the filname's extensions (comma separated)
strict - whether other combinations should be tried
Method Detail

getLocaleFromFilename

protected java.lang.String getLocaleFromFilename(java.lang.String path)
Extract the locale from the filename in case where the user

Parameters:
path - The file path
Returns:
The updated path, without the locale

getLocale

public final java.util.Locale getLocale()
Get the exact Locale which has been used for the latest resource path.

Returns:
current Locale

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<java.lang.String>
See Also:
Iterator.hasNext()

next

public java.lang.String next()
Specified by:
next in interface java.util.Iterator<java.lang.String>
See Also:
Iterator.next()

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<java.lang.String>
See Also:
Iterator.remove()


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