Package org.apache.tapestry5.ioc.util
Class LocalizedNameGenerator
- java.lang.Object
-
- org.apache.tapestry5.ioc.util.LocalizedNameGenerator
-
public class LocalizedNameGenerator extends Object implements Iterator<String>, Iterable<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(String path, 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 LocalegetCurrentLocale()booleanhasNext()Returns true if there are more name variants to be returned, false otherwise.Iterator<String>iterator()So that LNG may be used with the for loop.Stringnext()Returns the next localized variant.voidremove()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
LocalizedNameGenerator
public LocalizedNameGenerator(String path, 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.
-
next
public String next()
Returns the next localized variant.- Specified by:
nextin interfaceIterator<String>- Throws:
NoSuchElementException- if all variants have been returned.
-
getCurrentLocale
public Locale getCurrentLocale()
-
remove
public void remove()
- Specified by:
removein interfaceIterator<String>- Throws:
UnsupportedOperationException
-
-