Package org.apache.tapestry5.ioc.util
Class LocalizedNameGenerator
- java.lang.Object
-
- org.apache.tapestry5.ioc.util.LocalizedNameGenerator
-
- All Implemented Interfaces:
java.lang.Iterable<java.lang.String>
,java.util.Iterator<java.lang.String>
public class LocalizedNameGenerator extends java.lang.Object implements java.util.Iterator<java.lang.String>, java.lang.Iterable<java.lang.String>
Generates name variations for a given file name or path and a locale. The name variations are provided in most-specific to least-specific order, so for a path of "Base.ext" and a Locale of "en_US", the generated names would be "Base_en_US.ext", "Base_en.ext", "Base.ext". Implements Iterable, so a LocalizedNameGenerator may be used directly in a for loop. This class is not threadsafe.- Since:
- 5.3
-
-
Constructor Summary
Constructors Constructor Description LocalizedNameGenerator(java.lang.String path, java.util.Locale locale)
Creates a new generator for the given path and locale.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Locale
getCurrentLocale()
boolean
hasNext()
Returns true if there are more name variants to be returned, false otherwise.java.util.Iterator<java.lang.String>
iterator()
So that LNG may be used with the for loop.java.lang.String
next()
Returns the next localized variant.void
remove()
-
-
-
Constructor Detail
-
LocalizedNameGenerator
public LocalizedNameGenerator(java.lang.String path, java.util.Locale locale)
Creates a new generator for the given path and locale.- Parameters:
path
- non-blank pathlocale
- non-null locale
-
-
Method Detail
-
hasNext
public boolean hasNext()
Returns true if there are more name variants to be returned, false otherwise.- Specified by:
hasNext
in interfacejava.util.Iterator<java.lang.String>
-
next
public java.lang.String next()
Returns the next localized variant.- Specified by:
next
in interfacejava.util.Iterator<java.lang.String>
- Throws:
java.util.NoSuchElementException
- if all variants have been returned.
-
getCurrentLocale
public java.util.Locale getCurrentLocale()
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<java.lang.String>
- Throws:
java.lang.UnsupportedOperationException
-
iterator
public java.util.Iterator<java.lang.String> iterator()
So that LNG may be used with the for loop.- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.String>
-
-