Package org.nuiton.i18n.bundle
Class I18nBundleEntry
java.lang.Object
org.nuiton.i18n.bundle.I18nBundleEntry
- All Implemented Interfaces:
java.lang.Comparable<I18nBundleEntry>
public class I18nBundleEntry extends java.lang.Object implements java.lang.Comparable<I18nBundleEntry>
A class to represent an entry in a bundle.
The object matches exactly one resource file in a given scope.
The object has three properties :
-
path: the path to resource file where to find transaltion for the entry. -
locale: the locale of the entry - {link #scope} ; the scope of the entry
path.
This object is Comparable, the order relation is defined like this :
- sort first on
scope, in the scope order (seeI18nBundleScope), - if scopes are equals, sort on
localestring representation.
- Author:
- Tony Chemit - chemit@codelutin.com
- See Also:
I18nBundleScope
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Localelocalelocal of the entry, can be null if general scopeprotected java.net.URLpathpath to resource fileprotected I18nBundleScopescopescope of the entry -
Constructor Summary
Constructors Constructor Description I18nBundleEntry(java.net.URL path, java.util.Locale locale, I18nBundleScope scope)Constructor if an bundle entry. -
Method Summary
Modifier and Type Method Description intcompareTo(I18nBundleEntry o)booleanequals(java.lang.Object o)java.util.LocalegetLocale()java.net.URLgetPath()I18nBundleScopegetScope()inthashCode()voidload(java.util.Properties resource)Deprecated.since 2.4 useload(Properties, Charset)instead, charset must be provided to avoid encoding problemsvoidload(java.util.Properties resource, java.nio.charset.Charset encoding)For a given language, load the resource file of this entry into theresourceproperties object.booleanmatchLocale(java.util.Locale locale, I18nBundleScope scope)Method to match or not a bundle entry for a given scope and locale.java.lang.StringtoString()
-
Field Details
-
Constructor Details
-
I18nBundleEntry
Constructor if an bundle entry. It is defined by apathof the resource file, a scope and a locale.- Parameters:
path- the path of the resource file fo the bundle entrylocale- the given locale of the bundle entryscope- the scope of the given entry
-
-
Method Details
-
getPath
public java.net.URL getPath() -
getLocale
public java.util.Locale getLocale() -
getScope
-
matchLocale
Method to match or not a bundle entry for a given scope and locale. We use the inclusive property of scope, means that we accept all entries on the path to the generalest entry for a givne locale.- Parameters:
locale- the locale to matchscope- the highest scope to match- Returns:
trueif the entry match the scope and locale *
-
load
@Deprecated public void load(java.util.Properties resource) throws java.io.IOExceptionDeprecated.since 2.4 useload(Properties, Charset)instead, charset must be provided to avoid encoding problemsFor a given language, load the resource file of this entry into theresourceproperties object.- Parameters:
resource- the save of resources already loaded- Throws:
java.io.IOException- if any pb while reading resource file
-
load
public void load(java.util.Properties resource, java.nio.charset.Charset encoding) throws java.io.IOExceptionFor a given language, load the resource file of this entry into theresourceproperties object. Usecharsetto load properties. It could be different from resulting properties store.- Parameters:
resource- the save of resources already loadedencoding- Charset used to store the properties- Throws:
java.io.IOException- if any pb while reading resource file- Since:
- 2.4
-
compareTo
- Specified by:
compareToin interfacejava.lang.Comparable<I18nBundleEntry>
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-