Class ResourceNameIterator
- java.lang.Object
-
- org.apache.wicket.core.util.resource.locator.ResourceNameIterator
-
- All Implemented Interfaces:
java.util.Iterator<java.lang.String>
,IResourceNameIterator
- Direct Known Subclasses:
EmptyResourceNameIterator
public class ResourceNameIterator extends java.lang.Object implements IResourceNameIterator
Contains the logic to locate a resource based on a path, style (seeSession
), 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. <path>_<style>_<locale>.<extension>
- 2. <path>_<locale>.<extension>
- 3. <path>_<style>.<extension>
- 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:
- locale.toString() see javadoc for Locale for more details
- <language>_<country>
- <language>
- Author:
- Juergen Donnerstag
-
-
Constructor Summary
Constructors Constructor Description ResourceNameIterator(java.lang.String path, java.lang.String style, java.lang.String variation, java.util.Locale locale, java.lang.Iterable<java.lang.String> extensions, boolean strict)
Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getExtension()
Get the exact filename extension used for the latest resource path.java.util.Locale
getLocale()
Get the exact Locale which has been used for the latest resource path.java.lang.String
getStyle()
Get the exact Style which has been used for the latest resource path.java.lang.String
getVariation()
Get the exact Variation which has been used for the latest resource path.boolean
hasNext()
protected ExtensionResourceNameIterator
newExtensionResourceNameIterator(java.lang.Iterable<java.lang.String> extensions)
protected LocaleResourceNameIterator
newLocaleResourceNameIterator(java.util.Locale locale, boolean strict)
protected StyleAndVariationResourceNameIterator
newStyleAndVariationResourceNameIterator(java.lang.String style, java.lang.String variation)
java.lang.String
next()
void
remove()
java.lang.String
toString()
-
-
-
Constructor Detail
-
ResourceNameIterator
public ResourceNameIterator(java.lang.String path, java.lang.String style, java.lang.String variation, java.util.Locale locale, java.lang.Iterable<java.lang.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 (seeSession
)variation
- The component's variation (of the style)locale
- The Locale to applyextensions
- the filename's extensionsstrict
- If false, weaker combinations of style, locale, etc. are tested as well
-
-
Method Detail
-
getLocale
public final java.util.Locale getLocale()
Get the exact Locale which has been used for the latest resource path.- Specified by:
getLocale
in interfaceIResourceNameIterator
- Returns:
- current Locale
-
getStyle
public final java.lang.String getStyle()
Get the exact Style which has been used for the latest resource path.- Specified by:
getStyle
in interfaceIResourceNameIterator
- Returns:
- current Style
-
getVariation
public final java.lang.String getVariation()
Get the exact Variation which has been used for the latest resource path.- Specified by:
getVariation
in interfaceIResourceNameIterator
- Returns:
- current Variation
-
getExtension
public final java.lang.String getExtension()
Get the exact filename extension used for the latest resource path.- Specified by:
getExtension
in interfaceIResourceNameIterator
- Returns:
- current filename extension
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<java.lang.String>
- See Also:
Iterator.hasNext()
-
next
public java.lang.String next()
- Specified by:
next
in interfacejava.util.Iterator<java.lang.String>
- See Also:
Iterator.next()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
newLocaleResourceNameIterator
protected LocaleResourceNameIterator newLocaleResourceNameIterator(java.util.Locale locale, boolean strict)
- Parameters:
locale
-strict
-- Returns:
- New iterator
-
newStyleAndVariationResourceNameIterator
protected StyleAndVariationResourceNameIterator newStyleAndVariationResourceNameIterator(java.lang.String style, java.lang.String variation)
- Parameters:
style
-variation
-- Returns:
- new iterator
-
newExtensionResourceNameIterator
protected ExtensionResourceNameIterator newExtensionResourceNameIterator(java.lang.Iterable<java.lang.String> extensions)
- Parameters:
extensions
-- Returns:
- New iterator
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<java.lang.String>
- See Also:
Iterator.remove()
-
-