Package org.nuiton.i18n.bundle
Class I18nBundle
java.lang.Object
org.nuiton.i18n.bundle.I18nBundle
- All Implemented Interfaces:
java.lang.Iterable<I18nBundleEntry>
public class I18nBundle extends java.lang.Object implements java.lang.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 property
bundlePrefix is the equals order property.
The property entries contains all entries defined for this bundle.
The method getEntries(Locale) filter entries for a given locale,
including scope inclusive property.
The method getEntries(I18nBundleScope) filter entries for a given
scope, with no inclusive logi.
Thoses filter methods return result in the order defines in I18nBundleEntry, e.g
XXX.properties XXX-fr.properties XXX-fr_FR.propertiesIn 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 java.lang.StringbundlePrefixle nom du bundle encapsulé (correspond au prefix de l'url de chargement)protected java.util.List<I18nBundleEntry>entriesles entrés du bundle -
Constructor Summary
Constructors Constructor Description I18nBundle(java.lang.String bundlePrefix) -
Method Summary
Modifier and Type Method Description booleanaddEntry(I18nBundleEntry entry)java.lang.StringgetBundlePrefix()protected java.util.List<I18nBundleEntry>getEntries()I18nBundleEntry[]getEntries(java.util.Locale locale)Obtain the entries for a given locale, with a inclusive scope search.I18nBundleEntry[]getEntries(I18nBundleScope scope)Obtain the entries for a givenscopewith no incluvie logic.java.util.Iterator<I18nBundleEntry>iterator()protected booleanmatchLocale(java.util.Locale locale)intsize()java.lang.StringtoString()
-
Field Details
-
entries
les entrés du bundle -
bundlePrefix
protected final java.lang.String bundlePrefixle nom du bundle encapsulé (correspond au prefix de l'url de chargement)
-
-
Constructor Details
-
I18nBundle
public I18nBundle(java.lang.String bundlePrefix)
-
-
Method Details
-
getBundlePrefix
public java.lang.String getBundlePrefix() -
getEntries
Obtain the entries for a given locale, with a inclusive scope search. The order of result respectI18nBundleEntryorder.- Parameters:
locale- the required locale- Returns:
- the array of entries matching extacly the locale or one of the lesser scope one.
-
getEntries
Obtain the entries for a givenscopewith no incluvie logic. The order of result respectI18nBundleEntryorder.- 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
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
getEntries
-
matchLocale
protected boolean matchLocale(java.util.Locale locale) -
addEntry
-
iterator
- Specified by:
iteratorin interfacejava.lang.Iterable<I18nBundleEntry>
-