Class DefaultPriceDataFactory

  • All Implemented Interfaces:
    PriceDataFactory

    public class DefaultPriceDataFactory
    extends java.lang.Object
    implements PriceDataFactory
    Factory that creates PriceData instances for a price values. Includes a formatted price value.
    • Constructor Detail

      • DefaultPriceDataFactory

        public DefaultPriceDataFactory()
    • Method Detail

      • setCommerceCommonI18NService

        public void setCommerceCommonI18NService​(CommerceCommonI18NService commerceCommonI18NService)
      • getI18NService

        protected I18NService getI18NService()
      • setI18NService

        public void setI18NService​(I18NService i18NService)
      • setCommonI18NService

        public void setCommonI18NService​(CommonI18NService commonI18NService)
      • create

        public PriceData create​(PriceDataType priceType,
                                java.math.BigDecimal value,
                                java.lang.String currencyIso)
        Description copied from interface: PriceDataFactory
        Creates a PriceData object with a formatted currency string based on the price type and currency ISO code.
        Specified by:
        create in interface PriceDataFactory
        Parameters:
        priceType - The price type
        value - The price amount
        currencyIso - The currency ISO code
        Returns:
        the price data
      • create

        public PriceData create​(PriceDataType priceType,
                                java.math.BigDecimal value,
                                CurrencyModel currency)
        Description copied from interface: PriceDataFactory
        Creates a PriceData object with a formatted currency string based on the price type and currency.
        Specified by:
        create in interface PriceDataFactory
        Parameters:
        priceType - The price type
        value - The price amount
        currency - The currency
        Returns:
        the price data
      • formatPrice

        protected java.lang.String formatPrice​(java.math.BigDecimal value,
                                               CurrencyModel currency)
      • createCurrencyFormat

        protected java.text.NumberFormat createCurrencyFormat​(java.util.Locale locale,
                                                              CurrencyModel currency)
        Parameters:
        locale -
        currency -
        Returns:
        A clone of NumberFormat from the instance in the local cache, if the cache does not contain an instance of a NumberFormat for a given locale and currency one would be added.
      • createNumberFormat

        protected java.text.NumberFormat createNumberFormat​(java.util.Locale locale,
                                                            CurrencyModel currency)
      • adjustDigits

        protected java.text.DecimalFormat adjustDigits​(java.text.DecimalFormat format,
                                                       CurrencyModel currencyModel)
        Adjusts DecimalFormat's fraction digits according to given CurrencyModel.
      • adjustSymbol

        protected java.text.DecimalFormat adjustSymbol​(java.text.DecimalFormat format,
                                                       CurrencyModel currencyModel)
        Adjusts DecimalFormat's symbol according to given CurrencyModel.
      • createPriceData

        protected PriceData createPriceData()