CurrencyNameProvider.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* CurrencyNameProvider.java -- Providers of localized currency symbols
  2. Copyright (C) 2007 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.util.spi;
  32. import java.util.Locale;
  33. /**
  34. * A {@link CurrencyNameProvider} provides localized
  35. * versions of the symbols that represent a particular
  36. * currency. Note that currency symbols are regarded
  37. * as names, and thus a <code>null</code> value may
  38. * be returned, which should be treated as a lack of
  39. * support for the specified {@link Locale}.
  40. *
  41. * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
  42. * @since 1.6
  43. */
  44. public abstract class CurrencyNameProvider
  45. extends LocaleServiceProvider
  46. {
  47. /**
  48. * Constructs a new {@link CurrencyNameProvider}.
  49. * Provided for implicit invocation by subclasses.
  50. */
  51. protected CurrencyNameProvider()
  52. {
  53. }
  54. /**
  55. * <p>
  56. * This method returns the symbol which precedes or follows a
  57. * value in this particular currency. The returned value is
  58. * the symbol used to denote the currency in the specified locale.
  59. * </p>
  60. * <p>
  61. * For example, a supplied locale may specify a different symbol
  62. * for the currency, due to conflicts with its own currency.
  63. * This would be the case with the American currency, the dollar.
  64. * Locales that also use a dollar-based currency (e.g. Canada, Australia)
  65. * need to differentiate the American dollar using 'US$' rather than '$'.
  66. * So, supplying one of these locales to <code>getSymbol()</code> would
  67. * return this value, rather than the standard '$'.
  68. * </p>
  69. * <p>
  70. * In cases where there is no such symbol for a particular currency,
  71. * <code>null</code> should be returned.
  72. * </p>
  73. *
  74. * @param currencyCode the ISO 4217 currency code, consisting
  75. * of three uppercase letters from 'A' to 'Z'
  76. * @param locale the locale to express the symbol in.
  77. * @return the currency symbol, or <code>null</code> if one is
  78. * unavailable.
  79. * @throws NullPointerException if the locale is null.
  80. * @throws IllegalArgumentException if the currency code is
  81. * not in the correct format
  82. * or the locale is not one
  83. * returned by
  84. * {@link getAvailableLocales()}
  85. * @see java.util.Currency#getSymbol(java.util.Locale)
  86. */
  87. public abstract String getSymbol(String currencyCode, Locale locale);
  88. }