Class DefaultCommonI18NService
- java.lang.Object
-
- de.hybris.platform.servicelayer.internal.service.AbstractService
-
- de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
-
- de.hybris.platform.servicelayer.i18n.impl.DefaultCommonI18NService
-
- All Implemented Interfaces:
CommonI18NService
,java.io.Serializable
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
,org.springframework.beans.factory.InitializingBean
public class DefaultCommonI18NService extends AbstractBusinessService implements CommonI18NService
Default implementation of theCommonI18NService
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
AbstractService.SerializableDTO
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
modelService, sessionService, txManager
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
tenant
-
-
Constructor Summary
Constructors Constructor Description DefaultCommonI18NService()
-
Method Summary
All Methods Instance Methods Concrete 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 isoCode)
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 country, 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
setConversionStrategy(ConversionStrategy conversionStrategy)
void
setCountryDao(CountryDao countryDao)
void
setCurrencyDao(CurrencyDao currencyDao)
void
setCurrentCurrency(CurrencyModel currency)
Sets the current currency to the session.void
setCurrentLanguage(LanguageModel language)
Sets the current language to the session.void
setLanguageDao(LanguageDao dao)
void
setRegionDao(RegionDao regionDao)
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManager
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
afterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplace
-
-
-
-
Method Detail
-
setConversionStrategy
public void setConversionStrategy(ConversionStrategy conversionStrategy)
-
getLocaleForLanguage
public java.util.Locale getLocaleForLanguage(LanguageModel languageModel)
Description copied from interface:CommonI18NService
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);
- Specified by:
getLocaleForLanguage
in interfaceCommonI18NService
-
getLocaleForIsoCode
public java.util.Locale getLocaleForIsoCode(java.lang.String isoCode)
Description copied from interface:CommonI18NService
Returns aLocale
for ISO code.- Specified by:
getLocaleForIsoCode
in interfaceCommonI18NService
-
getAllLanguages
public java.util.List<LanguageModel> getAllLanguages()
Description copied from interface:CommonI18NService
Gets all languages.- Specified by:
getAllLanguages
in interfaceCommonI18NService
- Returns:
- all languages in the system
-
getLanguage
public LanguageModel getLanguage(java.lang.String isocode)
Description copied from interface:CommonI18NService
Gets the language for the given isocode.- Specified by:
getLanguage
in interfaceCommonI18NService
- Parameters:
isocode
- the isocode a language is searched for- Returns:
- language for searched isocode
-
setCurrentLanguage
public void setCurrentLanguage(LanguageModel language)
Description copied from interface:CommonI18NService
Sets the current language to the session.- Specified by:
setCurrentLanguage
in interfaceCommonI18NService
- Parameters:
language
- the new language
-
getCurrentLanguage
public LanguageModel getCurrentLanguage()
Description copied from interface:CommonI18NService
Gets current session language.- Specified by:
getCurrentLanguage
in interfaceCommonI18NService
- Returns:
- current session language or null if not set
-
getAllCountries
public java.util.List<CountryModel> getAllCountries()
Description copied from interface:CommonI18NService
Return a set of all CountryModels.- Specified by:
getAllCountries
in interfaceCommonI18NService
- Returns:
- the countries
-
getCountry
public CountryModel getCountry(java.lang.String isocode)
Description copied from interface:CommonI18NService
Returns a country by its isocode.- Specified by:
getCountry
in interfaceCommonI18NService
- Parameters:
isocode
- the isocode- Returns:
- the country
-
setCurrentCurrency
public void setCurrentCurrency(CurrencyModel currency)
Description copied from interface:CommonI18NService
Sets the current currency to the session.- Specified by:
setCurrentCurrency
in interfaceCommonI18NService
- Parameters:
currency
- the new currency
-
getCurrentCurrency
public CurrencyModel getCurrentCurrency()
Description copied from interface:CommonI18NService
Gets session currency.- Specified by:
getCurrentCurrency
in interfaceCommonI18NService
- Returns:
- session currency or
null
if not set
-
getAllCurrencies
public java.util.List<CurrencyModel> getAllCurrencies()
Description copied from interface:CommonI18NService
Return a set of allCurrencyModel
.- Specified by:
getAllCurrencies
in interfaceCommonI18NService
- Returns:
- the currencies
-
getBaseCurrency
public CurrencyModel getBaseCurrency()
Description copied from interface:CommonI18NService
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.- Specified by:
getBaseCurrency
in interfaceCommonI18NService
- Returns:
- the base
CurrencyModel
ornull
if no base currency is set
-
getCurrency
public CurrencyModel getCurrency(java.lang.String isoCode)
Description copied from interface:CommonI18NService
Returns a currency by its code.- Specified by:
getCurrency
in interfaceCommonI18NService
- Parameters:
isoCode
- the code- Returns:
- the currency
-
getAllRegions
public java.util.List<RegionModel> getAllRegions()
Description copied from interface:CommonI18NService
Return a set of all RegionModel.- Specified by:
getAllRegions
in interfaceCommonI18NService
- Returns:
- the regions
-
getRegion
public RegionModel getRegion(CountryModel country, java.lang.String code)
Description copied from interface:CommonI18NService
Returns a region by its isocode within the country.- Specified by:
getRegion
in interfaceCommonI18NService
- Parameters:
country
- the country modelcode
- the region code- Returns:
- the region
-
convertAndRoundCurrency
public double convertAndRoundCurrency(double sourceFactor, double targetFactor, int digits, double value)
Description copied from interface:CommonI18NService
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.- Specified by:
convertAndRoundCurrency
in interfaceCommonI18NService
- 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
public double convertCurrency(double sourceFactor, double targetFactor, double value)
Description copied from interface:CommonI18NService
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 withCommonI18NService.roundCurrency(double, int)
to achieve this, or just useCommonI18NService.convertAndRoundCurrency(double, double, int, double)
- Specified by:
convertCurrency
in interfaceCommonI18NService
- Parameters:
sourceFactor
- the conversionFactor of the source currencytargetFactor
- the conversionFactor of the target currencyvalue
- the source value- Returns:
- converted value
-
roundCurrency
public double roundCurrency(double value, int digits)
Description copied from interface:CommonI18NService
Rounds a price value according to this currency's number of digits.- Specified by:
roundCurrency
in interfaceCommonI18NService
- Parameters:
value
- the currency value which should be rounded.digits
- currency's number of digits- Returns:
- the rounded currency value
-
setLanguageDao
public void setLanguageDao(LanguageDao dao)
-
setCountryDao
public void setCountryDao(CountryDao countryDao)
-
setCurrencyDao
public void setCurrencyDao(CurrencyDao currencyDao)
-
setRegionDao
public void setRegionDao(RegionDao regionDao)
-
-