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 doubleconvertAndRoundCurrency(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.doubleconvertCurrency(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.CurrencyModelgetBaseCurrency()Returns the base currency (CurrencyModel.getBase()) of this system ornullif no base currency is set.CountryModelgetCountry(java.lang.String isocode)Returns a country by its isocode.CurrencyModelgetCurrency(java.lang.String isoCode)Returns a currency by its code.CurrencyModelgetCurrentCurrency()Gets session currency.LanguageModelgetCurrentLanguage()Gets current session language.LanguageModelgetLanguage(java.lang.String isocode)Gets the language for the given isocode.java.util.LocalegetLocaleForIsoCode(java.lang.String isoCode)Returns aLocalefor ISO code.java.util.LocalegetLocaleForLanguage(LanguageModel languageModel)Returns aLocaleaccording language (ISO code), country (ISO code) and vendor id.RegionModelgetRegion(CountryModel country, java.lang.String code)Returns a region by its isocode within the country.doubleroundCurrency(double value, int digits)Rounds a price value according to this currency's number of digits.voidsetConversionStrategy(ConversionStrategy conversionStrategy)voidsetCountryDao(CountryDao countryDao)voidsetCurrencyDao(CurrencyDao currencyDao)voidsetCurrentCurrency(CurrencyModel currency)Sets the current currency to the session.voidsetCurrentLanguage(LanguageModel language)Sets the current language to the session.voidsetLanguageDao(LanguageDao dao)voidsetRegionDao(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:CommonI18NServiceReturns aLocaleaccording 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:
getLocaleForLanguagein interfaceCommonI18NService
-
getLocaleForIsoCode
public java.util.Locale getLocaleForIsoCode(java.lang.String isoCode)
Description copied from interface:CommonI18NServiceReturns aLocalefor ISO code.- Specified by:
getLocaleForIsoCodein interfaceCommonI18NService
-
getAllLanguages
public java.util.List<LanguageModel> getAllLanguages()
Description copied from interface:CommonI18NServiceGets all languages.- Specified by:
getAllLanguagesin interfaceCommonI18NService- Returns:
- all languages in the system
-
getLanguage
public LanguageModel getLanguage(java.lang.String isocode)
Description copied from interface:CommonI18NServiceGets the language for the given isocode.- Specified by:
getLanguagein 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:CommonI18NServiceSets the current language to the session.- Specified by:
setCurrentLanguagein interfaceCommonI18NService- Parameters:
language- the new language
-
getCurrentLanguage
public LanguageModel getCurrentLanguage()
Description copied from interface:CommonI18NServiceGets current session language.- Specified by:
getCurrentLanguagein interfaceCommonI18NService- Returns:
- current session language or null if not set
-
getAllCountries
public java.util.List<CountryModel> getAllCountries()
Description copied from interface:CommonI18NServiceReturn a set of all CountryModels.- Specified by:
getAllCountriesin interfaceCommonI18NService- Returns:
- the countries
-
getCountry
public CountryModel getCountry(java.lang.String isocode)
Description copied from interface:CommonI18NServiceReturns a country by its isocode.- Specified by:
getCountryin interfaceCommonI18NService- Parameters:
isocode- the isocode- Returns:
- the country
-
setCurrentCurrency
public void setCurrentCurrency(CurrencyModel currency)
Description copied from interface:CommonI18NServiceSets the current currency to the session.- Specified by:
setCurrentCurrencyin interfaceCommonI18NService- Parameters:
currency- the new currency
-
getCurrentCurrency
public CurrencyModel getCurrentCurrency()
Description copied from interface:CommonI18NServiceGets session currency.- Specified by:
getCurrentCurrencyin interfaceCommonI18NService- Returns:
- session currency or
nullif not set
-
getAllCurrencies
public java.util.List<CurrencyModel> getAllCurrencies()
Description copied from interface:CommonI18NServiceReturn a set of allCurrencyModel.- Specified by:
getAllCurrenciesin interfaceCommonI18NService- Returns:
- the currencies
-
getBaseCurrency
public CurrencyModel getBaseCurrency()
Description copied from interface:CommonI18NServiceReturns the base currency (CurrencyModel.getBase()) of this system ornullif no base currency is set. There should be always one suchCurrencyin the hybris Platform. The base currency should be the most likely-to-us currency.- Specified by:
getBaseCurrencyin interfaceCommonI18NService- Returns:
- the base
CurrencyModelornullif no base currency is set
-
getCurrency
public CurrencyModel getCurrency(java.lang.String isoCode)
Description copied from interface:CommonI18NServiceReturns a currency by its code.- Specified by:
getCurrencyin interfaceCommonI18NService- Parameters:
isoCode- the code- Returns:
- the currency
-
getAllRegions
public java.util.List<RegionModel> getAllRegions()
Description copied from interface:CommonI18NServiceReturn a set of all RegionModel.- Specified by:
getAllRegionsin interfaceCommonI18NService- Returns:
- the regions
-
getRegion
public RegionModel getRegion(CountryModel country, java.lang.String code)
Description copied from interface:CommonI18NServiceReturns a region by its isocode within the country.- Specified by:
getRegionin 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:CommonI18NServiceConverts 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:
convertAndRoundCurrencyin 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:CommonI18NServiceUsed 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:
convertCurrencyin 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:CommonI18NServiceRounds a price value according to this currency's number of digits.- Specified by:
roundCurrencyin 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)
-
-