Package org.nuiton.i18n.bundle
Class I18nBundle
- java.lang.Object
-
- org.nuiton.i18n.bundle.I18nBundle
-
- All Implemented Interfaces:
Iterable<I18nBundleEntry>
public class I18nBundle extends Object implements Iterable<I18nBundleEntry>
Class to represent a i18n Bundle. A bundle is defined by a resource prefix (eg /tmp/bundle.properties), and a list of locale implemented entries. The propertybundlePrefix
is the equals order property. The propertyentries
contains all entries defined for this bundle. The methodgetEntries(Locale)
filter entries for a given locale, including scope inclusive property. The methodgetEntries(I18nBundleScope)
filter entries for a given scope, with no inclusive logi. Thoses filter methods return result in the order defines inI18nBundleEntry
, e.gXXX.properties XXX-fr.properties XXX-fr_FR.properties
In that way, we can load resource in the good order : load before more general scope to more specialized.- Author:
- Tony Chemit - chemit@codelutin.com
- See Also:
I18nBundleScope
,I18nBundleEntry
-
-
Field Summary
Fields Modifier and Type Field Description protected String
bundlePrefix
le nom du bundle encapsulé (correspond au prefix de l'url de chargement)protected List<I18nBundleEntry>
entries
les entrés du bundle
-
Constructor Summary
Constructors Constructor Description I18nBundle(String bundlePrefix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addEntry(I18nBundleEntry entry)
String
getBundlePrefix()
protected List<I18nBundleEntry>
getEntries()
I18nBundleEntry[]
getEntries(Locale locale)
Obtain the entries for a given locale, with a inclusive scope search.I18nBundleEntry[]
getEntries(I18nBundleScope scope)
Obtain the entries for a givenscope
with no incluvie logic.Iterator<I18nBundleEntry>
iterator()
protected boolean
matchLocale(Locale locale)
int
size()
String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
entries
protected List<I18nBundleEntry> entries
les entrés du bundle
-
bundlePrefix
protected final String bundlePrefix
le nom du bundle encapsulé (correspond au prefix de l'url de chargement)
-
-
Constructor Detail
-
I18nBundle
public I18nBundle(String bundlePrefix)
-
-
Method Detail
-
getBundlePrefix
public String getBundlePrefix()
-
getEntries
public I18nBundleEntry[] getEntries(Locale locale)
Obtain the entries for a given locale, with a inclusive scope search. The order of result respectI18nBundleEntry
order.- Parameters:
locale
- the required locale- Returns:
- the array of entries matching extacly the locale or one of the lesser scope one.
-
getEntries
public I18nBundleEntry[] getEntries(I18nBundleScope scope)
Obtain the entries for a givenscope
with no incluvie logic. The order of result respectI18nBundleEntry
order.- Parameters:
scope
- the required scope- Returns:
- the list of entries matching exactly the given scope
-
size
public int size()
- Returns:
- number of entries in bundle
-
getEntries
protected List<I18nBundleEntry> getEntries()
-
matchLocale
protected boolean matchLocale(Locale locale)
-
addEntry
public boolean addEntry(I18nBundleEntry entry)
-
iterator
public Iterator<I18nBundleEntry> iterator()
- Specified by:
iterator
in interfaceIterable<I18nBundleEntry>
-
-