Class DefaultCurrencyData

  • All Implemented Interfaces:
    CurrencyData

    public class DefaultCurrencyData
    extends java.lang.Object
    implements CurrencyData
    A default CurrencyData implementation, so new methods can be added to the interface without breaking implementors if a reasonable default is available.
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultCurrencyData​(java.lang.String currencyCode, java.lang.String currencySymbol)
      Create a default default CurrencyData instance, returning false for all isFoo methods, having 2 fractional digits by default, and using the standard symbol for the portable symbol.
      DefaultCurrencyData​(java.lang.String currencyCode, java.lang.String currencySymbol, int fractionDigits)
      Create a default default CurrencyData instance, returning false for all isFoo methods and using the standard symbol for the portable symbol.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getCurrencyCode()
      Returns the ISO4217 code for this currency.
      java.lang.String getCurrencySymbol()
      Returns the default symbol to use for this currency.
      int getDefaultFractionDigits()
      Returns the default number of decimal positions for this currency.
      java.lang.String getPortableCurrencySymbol()
      Returns the default symbol to use for this currency, intended to be recognizable in most locales.
      java.lang.String getSimpleCurrencySymbol()
      Returns the simplest symbol to use for this currency, which is not guaranteed to be unique -- for example, this might return "$" for both USD and CAD.
      boolean isDeprecated()
      Returns true if this currency is deprecated and should not be returned by default in currency lists.
      boolean isSpaceForced()
      Returns true if there should always be a space between the currency symbol and the number, false if there should be no space.
      boolean isSpacingFixed()
      Returns true if the spacing between the currency symbol and the number is fixed regardless of locale defaults.
      boolean isSymbolPositionFixed()
      Returns true if the position of the currency symbol relative to the number is fixed regardless of locale defaults.
      boolean isSymbolPrefix()
      Returns true if the currency symbol should go before the number, false if it should go after the number.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultCurrencyData

        public DefaultCurrencyData​(java.lang.String currencyCode,
                                   java.lang.String currencySymbol)
        Create a default default CurrencyData instance, returning false for all isFoo methods, having 2 fractional digits by default, and using the standard symbol for the portable symbol.
        Parameters:
        currencyCode - ISO 4217 currency code
        currencySymbol - symbol to use for this currency
      • DefaultCurrencyData

        public DefaultCurrencyData​(java.lang.String currencyCode,
                                   java.lang.String currencySymbol,
                                   int fractionDigits)
        Create a default default CurrencyData instance, returning false for all isFoo methods and using the standard symbol for the portable symbol.
        Parameters:
        currencyCode - ISO 4217 currency code
        currencySymbol - symbol to use for this currency
        fractionDigits - default number of fraction digits
    • Method Detail

      • getCurrencyCode

        public java.lang.String getCurrencyCode()
        Description copied from interface: CurrencyData
        Returns the ISO4217 code for this currency.
        Specified by:
        getCurrencyCode in interface CurrencyData
      • getCurrencySymbol

        public java.lang.String getCurrencySymbol()
        Description copied from interface: CurrencyData
        Returns the default symbol to use for this currency.
        Specified by:
        getCurrencySymbol in interface CurrencyData
      • getDefaultFractionDigits

        public int getDefaultFractionDigits()
        Description copied from interface: CurrencyData
        Returns the default number of decimal positions for this currency.
        Specified by:
        getDefaultFractionDigits in interface CurrencyData
      • getPortableCurrencySymbol

        public java.lang.String getPortableCurrencySymbol()
        Description copied from interface: CurrencyData
        Returns the default symbol to use for this currency, intended to be recognizable in most locales. If such a symbol is not available, it is acceptable to return the same value as CurrencyData.getCurrencySymbol().
        Specified by:
        getPortableCurrencySymbol in interface CurrencyData
      • getSimpleCurrencySymbol

        public java.lang.String getSimpleCurrencySymbol()
        Description copied from interface: CurrencyData
        Returns the simplest symbol to use for this currency, which is not guaranteed to be unique -- for example, this might return "$" for both USD and CAD. It is acceptable to return the same value as CurrencyData.getCurrencySymbol().
        Specified by:
        getSimpleCurrencySymbol in interface CurrencyData
      • isDeprecated

        public boolean isDeprecated()
        Description copied from interface: CurrencyData
        Returns true if this currency is deprecated and should not be returned by default in currency lists.
        Specified by:
        isDeprecated in interface CurrencyData
      • isSpaceForced

        public boolean isSpaceForced()
        Description copied from interface: CurrencyData
        Returns true if there should always be a space between the currency symbol and the number, false if there should be no space. Ignored unless CurrencyData.isSpacingFixed() returns true.
        Specified by:
        isSpaceForced in interface CurrencyData
      • isSpacingFixed

        public boolean isSpacingFixed()
        Description copied from interface: CurrencyData
        Returns true if the spacing between the currency symbol and the number is fixed regardless of locale defaults. In this case, spacing will be determined by CurrencyData.isSpaceForced().
        Specified by:
        isSpacingFixed in interface CurrencyData
      • isSymbolPositionFixed

        public boolean isSymbolPositionFixed()
        Description copied from interface: CurrencyData
        Returns true if the position of the currency symbol relative to the number is fixed regardless of locale defaults. In this case, the position will be determined by CurrencyData.isSymbolPrefix().
        Specified by:
        isSymbolPositionFixed in interface CurrencyData