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

java.lang.Object
  extended by org.apache.wicket.core.util.resource.locator.ResourceNameIterator
All Implemented Interfaces:
Iterator<String>, IResourceNameIterator
Direct Known Subclasses:
EmptyResourceNameIterator

public class ResourceNameIterator
extends Object
implements IResourceNameIterator

Contains the logic to locate a resource based on a path, style (see Session), variation, locale and extension strings. The full filename will be built like: <path>_<variation>_<_<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

Constructor Summary
ResourceNameIterator(String path, String style, String variation, Locale locale, Iterable<String> extensions, boolean strict)
          Construct.
 
Method Summary
 String getExtension()
          Get the exact filename extension used for the latest resource path.
 Locale getLocale()
          Get the exact Locale which has been used for the latest resource path.
 String getStyle()
          Get the exact Style which has been used for the latest resource path.
 String getVariation()
          Get the exact Variation which has been used for the latest resource path.
 boolean hasNext()
           
protected  ExtensionResourceNameIterator newExtensionResourceNameIterator(Iterable<String> extensions)
           
protected  LocaleResourceNameIterator newLocaleResourceNameIterator(Locale locale, boolean strict)
           
protected  StyleAndVariationResourceNameIterator newStyleAndVariationResourceNameIterator(String style, String variation)
           
 String next()
           
 void remove()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceNameIterator

public ResourceNameIterator(String path,
                            String style,
                            String variation,
                            Locale locale,
                            Iterable<String> extensions,
                            boolean strict)
Construct.

Parameters:
path - The path of the resource. In case the parameter 'extensions' is null, the path will be checked and if a filename extension is present, it'll be used instead.
style - A theme or style (see Session)
variation - The component's variation (of the style)
locale - The Locale to apply
extensions - the filename's extensions
strict - If false, weaker combinations of style, locale, etc. are tested as well
Method Detail

getLocale

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

Specified by:
getLocale in interface IResourceNameIterator
Returns:
current Locale

getStyle

public final String getStyle()
Get the exact Style which has been used for the latest resource path.

Specified by:
getStyle in interface IResourceNameIterator
Returns:
current Style

getVariation

public final String getVariation()
Get the exact Variation which has been used for the latest resource path.

Specified by:
getVariation in interface IResourceNameIterator
Returns:
current Variation

getExtension

public final String getExtension()
Get the exact filename extension used for the latest resource path.

Specified by:
getExtension in interface IResourceNameIterator
Returns:
current filename extension

hasNext

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

next

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

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

newLocaleResourceNameIterator

protected LocaleResourceNameIterator newLocaleResourceNameIterator(Locale locale,
                                                                   boolean strict)
Parameters:
locale -
strict -
Returns:
New iterator

newStyleAndVariationResourceNameIterator

protected StyleAndVariationResourceNameIterator newStyleAndVariationResourceNameIterator(String style,
                                                                                         String variation)
Parameters:
style -
variation -
Returns:
new iterator

newExtensionResourceNameIterator

protected ExtensionResourceNameIterator newExtensionResourceNameIterator(Iterable<String> extensions)
Parameters:
extensions -
Returns:
New iterator

remove

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


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