LocaleNameProvider.java 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* LocaleNameProvider.java -- Providers of localized locale names
  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 LocaleNameProvider} provides localized
  35. * versions of the names that represent a particular
  36. * locale. Note that a <code>null</code> value may
  37. * be returned, which should be treated as a lack of
  38. * support for the specified {@link Locale}.
  39. *
  40. * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
  41. * @since 1.6
  42. */
  43. public abstract class LocaleNameProvider
  44. extends LocaleServiceProvider
  45. {
  46. /**
  47. * Constructs a new {@link LocaleNameProvider}.
  48. * Provided for implicit invocation by subclasses.
  49. */
  50. protected LocaleNameProvider()
  51. {
  52. }
  53. /**
  54. * Returns the localized name for the specified ISO 3166
  55. * country in the supplied {@link java.util.Locale}.
  56. * For example, if the country code is <code>"DE"</code>,
  57. * this method will return <code>"Germany"</code> for
  58. * {@link Locale.ENGLISH} but <code>"Deutschland"</code>
  59. * for {@link Locale.GERMANY}. If the name of the country
  60. * in the given locale is not supported, <code>null</code>
  61. * is returned.
  62. *
  63. * @param countryCode the ISO 3166 country code, consisting
  64. * of two uppercase letters from 'A' to 'Z'
  65. * @param locale the locale to express the country in.
  66. * @return the country name, or <code>null</code> if one is
  67. * not available.
  68. * @throws NullPointerException if the locale is null.
  69. * @throws IllegalArgumentException if the country code is
  70. * not in the correct format
  71. * or the locale is not one
  72. * returned by
  73. * {@link getAvailableLocales()}
  74. * @see java.util.Locale#getDisplayCountry(java.util.Locale)
  75. */
  76. public abstract String getDisplayCountry(String countryCode,
  77. Locale locale);
  78. /**
  79. * Returns the localized name for the specified ISO 639
  80. * language in the supplied {@link java.util.Locale}.
  81. * For example, if the language code is <code>"de"</code>,
  82. * this method will return <code>"German"</code> for
  83. * {@link Locale.ENGLISH} but <code>"Deutsch"</code>
  84. * for {@link Locale.GERMANY}. If the name of the language
  85. * in the given locale is not supported, <code>null</code>
  86. * is returned.
  87. *
  88. * @param langCode the ISO 639 language code, consisting
  89. * of two lowercase letters from 'a' to 'z'
  90. * @param locale the locale to express the language in.
  91. * @return the country name, or <code>null</code> if one is
  92. * not available.
  93. * @throws NullPointerException if the locale is null.
  94. * @throws IllegalArgumentException if the language code is
  95. * not in the correct format
  96. * or the locale is not one
  97. * returned by
  98. * {@link getAvailableLocales()}
  99. * @see java.util.Locale#getDisplayLanguage(java.util.Locale)
  100. */
  101. public abstract String getDisplayLanguage(String langCode,
  102. Locale locale);
  103. /**
  104. * Returns the localized name for the specified variant
  105. * in the supplied {@link java.util.Locale}. If the name
  106. * of the variant in the given locale is not supported,
  107. * <code>null</code> is returned.
  108. *
  109. * @param variant the variant.
  110. * @param locale the locale to express the variant in.
  111. * @return the localized variant, or <code>null</code> if one is
  112. * not available.
  113. * @throws NullPointerException if the locale is null.
  114. * @throws IllegalArgumentException if the locale is not one
  115. * returned by
  116. * {@link getAvailableLocales()}
  117. * @see java.util.Locale#getDisplayVariant(java.util.Locale)
  118. */
  119. public abstract String getDisplayVariant(String variant,
  120. Locale locale);
  121. }