NumberFormatProvider.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* NumberFormatProvider.java -- Providers of localized instances
  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.text.spi;
  32. import java.text.NumberFormat;
  33. import java.util.Locale;
  34. import java.util.spi.LocaleServiceProvider;
  35. /**
  36. * A {@link NumberFormatProvider} provides localized
  37. * instances of {@link java.text.NumberFormat}.
  38. *
  39. * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
  40. * @since 1.6
  41. */
  42. public abstract class NumberFormatProvider
  43. extends LocaleServiceProvider
  44. {
  45. /**
  46. * Constructs a new {@link NumberFormatProvider}.
  47. * Provided for implicit invocation by subclasses.
  48. */
  49. protected NumberFormatProvider()
  50. {
  51. }
  52. /**
  53. * Returns a {@link java.text.NumberFormat} instance
  54. * for monetary values in the specified
  55. * {@link java.util.Locale}.
  56. *
  57. * @param locale the desired locale.
  58. * @return the localized instance for monetary values.
  59. * @throws NullPointerException if the locale is null.
  60. * @throws IllegalArgumentException if the locale is not one
  61. * returned by
  62. * {@link getAvailableLocales()}
  63. * @see java.text.NumberFormat#getCurrencyInstance(java.util.Locale)
  64. */
  65. public abstract NumberFormat getCurrencyInstance(Locale locale);
  66. /**
  67. * Returns a {@link java.text.NumberFormat} instance
  68. * for integers in the specified {@link java.util.Locale}.
  69. * The returned instance should be configured to round
  70. * floating point numbers to the nearest integer using
  71. * {@link java.math.RoundingMode#HALF_EVEN} rounding,
  72. * and to parse only the integer part of a number.
  73. *
  74. * @param locale the desired locale.
  75. * @return the localized instance for integers.
  76. * @throws NullPointerException if the locale is null.
  77. * @throws IllegalArgumentException if the locale is not one
  78. * returned by
  79. * {@link getAvailableLocales()}
  80. * @see java.text.NumberFormat#getIntegerInstance(java.util.Locale)
  81. * @see java.math.RoundingMode#HALF_EVEN
  82. * @see java.text.NumberFormat#isParseIntegerOnly()
  83. */
  84. public abstract NumberFormat getIntegerInstance(Locale locale);
  85. /**
  86. * Returns a general-purpose {@link java.text.NumberFormat}
  87. * instance in the specified {@link java.util.Locale}.
  88. *
  89. * @param locale the desired locale.
  90. * @return a general-purpose localized instance.
  91. * @throws NullPointerException if the locale is null.
  92. * @throws IllegalArgumentException if the locale is not one
  93. * returned by
  94. * {@link getAvailableLocales()}
  95. * @see java.text.NumberFormat#getNumberInstance(java.util.Locale)
  96. */
  97. public abstract NumberFormat getNumberInstance(Locale locale);
  98. /**
  99. * Returns a {@link java.text.NumberFormat} instance
  100. * for percentage values in the specified
  101. * {@link java.util.Locale}.
  102. *
  103. * @param locale the desired locale.
  104. * @return the localized instance for percentage values.
  105. * @throws NullPointerException if the locale is null.
  106. * @throws IllegalArgumentException if the locale is not one
  107. * returned by
  108. * {@link getAvailableLocales()}
  109. * @see java.text.NumberFormat#getPercentInstance(java.util.Locale)
  110. */
  111. public abstract NumberFormat getPercentInstance(Locale locale);
  112. }