Interface CommonI18NService
-
- All Known Implementing Classes:
DefaultCommonI18NService
,DummyI18NService
public interface CommonI18NService
Service covering country, currency, language area in the platform. Provides a methods to accessCountryModel
,CurrencyModel
,LanguageModel
.- Since:
- 4.3
- Spring Bean ID:
- commonI18NService
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description double
convertAndRoundCurrency(double sourceFactor, double targetFactor, int digits, double value)
Converts a (price) value of this currency into a value for the specified target currency and rounds the result according to the target currency's digits.double
convertCurrency(double sourceFactor, double targetFactor, double value)
Used to converts a numeric price value from one currency to another.java.util.List<CountryModel>
getAllCountries()
Return a set of all CountryModels.java.util.List<CurrencyModel>
getAllCurrencies()
Return a set of allCurrencyModel
.java.util.List<LanguageModel>
getAllLanguages()
Gets all languages.java.util.List<RegionModel>
getAllRegions()
Return a set of all RegionModel.CurrencyModel
getBaseCurrency()
Returns the base currency (CurrencyModel.getBase()
) of this system ornull
if no base currency is set.CountryModel
getCountry(java.lang.String isocode)
Returns a country by its isocode.CurrencyModel
getCurrency(java.lang.String code)
Returns a currency by its code.CurrencyModel
getCurrentCurrency()
Gets session currency.LanguageModel
getCurrentLanguage()
Gets current session language.LanguageModel
getLanguage(java.lang.String isocode)
Gets the language for the given isocode.java.util.Locale
getLocaleForIsoCode(java.lang.String isoCode)
Returns aLocale
for ISO code.java.util.Locale
getLocaleForLanguage(LanguageModel languageModel)
Returns aLocale
according language (ISO code), country (ISO code) and vendor id.RegionModel
getRegion(CountryModel model, java.lang.String code)
Returns a region by its isocode within the country.double
roundCurrency(double value, int digits)
Rounds a price value according to this currency's number of digits.void
setCurrentCurrency(CurrencyModel currency)
Sets the current currency to the session.void
setCurrentLanguage(LanguageModel language)
Sets the current language to the session.
-
-
-
Method Detail
-
getLocaleForLanguage
java.util.Locale getLocaleForLanguage(LanguageModel languageModel)
Returns aLocale
according language (ISO code), country (ISO code) and vendor id. The three parameters are passed as a isocode of the LanguageModel instance. Supported delimiters are: _ , . ;LanguageModel languageModel = new LanguageModel();
languageModel.setIsocode("de_DE_WIN");
getLocaleForLanguage(languageModel);
languageModel.setIsocode("en,AT,");
getLocaleForLanguage(languageModel);
-
getLocaleForIsoCode
java.util.Locale getLocaleForIsoCode(java.lang.String isoCode)
Returns aLocale
for ISO code.
-
getLanguage
LanguageModel getLanguage(java.lang.String isocode)
Gets the language for the given isocode.- Parameters:
isocode
- the isocode a language is searched for- Returns:
- language for searched isocode
- Throws:
UnknownIdentifierException
- if the language with given isocode is not found
-
getAllLanguages
java.util.List<LanguageModel> getAllLanguages()
Gets all languages.- Returns:
- all languages in the system
-
getCurrentLanguage
LanguageModel getCurrentLanguage()
Gets current session language.- Returns:
- current session language or null if not set
-
setCurrentLanguage
void setCurrentLanguage(LanguageModel language)
Sets the current language to the session.- Parameters:
language
- the new language
-
getCountry
CountryModel getCountry(java.lang.String isocode)
Returns a country by its isocode.- Parameters:
isocode
- the isocode- Returns:
- the country
- Throws:
UnknownIdentifierException
- in case no country can be found
-
getAllCountries
java.util.List<CountryModel> getAllCountries()
Return a set of all CountryModels.- Returns:
- the countries
-
getRegion
RegionModel getRegion(CountryModel model, java.lang.String code)
Returns a region by its isocode within the country.- Parameters:
model
- the country modelcode
- the region code- Returns:
- the region
- Throws:
UnknownIdentifierException
- in case no country can be found
-
getAllRegions
java.util.List<RegionModel> getAllRegions()
Return a set of all RegionModel.- Returns:
- the regions
-
getCurrency
CurrencyModel getCurrency(java.lang.String code)
Returns a currency by its code.- Parameters:
code
- the code- Returns:
- the currency
- Throws:
UnknownIdentifierException
- in case no currency can be found
-
setCurrentCurrency
void setCurrentCurrency(CurrencyModel currency)
Sets the current currency to the session.- Parameters:
currency
- the new currency
-
getCurrentCurrency
CurrencyModel getCurrentCurrency()
Gets session currency.- Returns:
- session currency or
null
if not set
-
getBaseCurrency
CurrencyModel getBaseCurrency()
Returns the base currency (CurrencyModel.getBase()
) of this system ornull
if no base currency is set. There should be always one suchCurrency
in the hybris Platform. The base currency should be the most likely-to-us currency.- Returns:
- the base
CurrencyModel
ornull
if no base currency is set
-
getAllCurrencies
java.util.List<CurrencyModel> getAllCurrencies()
Return a set of allCurrencyModel
.- Returns:
- the currencies
-
convertAndRoundCurrency
double convertAndRoundCurrency(double sourceFactor, double targetFactor, int digits, double value)
Converts a (price) value of this currency into a value for the specified target currency and rounds the result according to the target currency's digits.- Parameters:
sourceFactor
- the conversionFactor of the source currencytargetFactor
- the conversionFactor of the target currencydigits
- currency's number of digitsvalue
- the value which should be converted- Returns:
- the converted and rounded value
-
convertCurrency
double convertCurrency(double sourceFactor, double targetFactor, double value)
Used to converts a numeric price value from one currency to another. Please note that this method does no rounding. You can use it in connection withroundCurrency(double, int)
to achieve this, or just useconvertAndRoundCurrency(double, double, int, double)
- Parameters:
sourceFactor
- the conversionFactor of the source currencytargetFactor
- the conversionFactor of the target currencyvalue
- the source value- Returns:
- converted value
-
roundCurrency
double roundCurrency(double value, int digits)
Rounds a price value according to this currency's number of digits.- Parameters:
value
- the currency value which should be rounded.digits
- currency's number of digits- Returns:
- the rounded currency value
-
-