2
|
1 |
/*
|
|
2 |
* Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package java.util.spi;
|
|
27 |
|
|
28 |
import java.util.Currency;
|
|
29 |
import java.util.Locale;
|
|
30 |
|
|
31 |
/**
|
|
32 |
* An abstract class for service providers that
|
|
33 |
* provide localized currency symbols and display names for the
|
|
34 |
* {@link java.util.Currency Currency} class.
|
|
35 |
* Note that currency symbols are considered names when determining
|
|
36 |
* behaviors described in the
|
|
37 |
* {@link java.util.spi.LocaleServiceProvider LocaleServiceProvider}
|
|
38 |
* specification.
|
|
39 |
*
|
|
40 |
* @since 1.6
|
|
41 |
*/
|
|
42 |
public abstract class CurrencyNameProvider extends LocaleServiceProvider {
|
|
43 |
|
|
44 |
/**
|
|
45 |
* Sole constructor. (For invocation by subclass constructors, typically
|
|
46 |
* implicit.)
|
|
47 |
*/
|
|
48 |
protected CurrencyNameProvider() {
|
|
49 |
}
|
|
50 |
|
|
51 |
/**
|
|
52 |
* Gets the symbol of the given currency code for the specified locale.
|
|
53 |
* For example, for "USD" (US Dollar), the symbol is "$" if the specified
|
|
54 |
* locale is the US, while for other locales it may be "US$". If no
|
|
55 |
* symbol can be determined, null should be returned.
|
|
56 |
*
|
|
57 |
* @param currencyCode the ISO 4217 currency code, which
|
|
58 |
* consists of three upper-case letters between 'A' (U+0041) and
|
|
59 |
* 'Z' (U+005A)
|
|
60 |
* @param locale the desired locale
|
|
61 |
* @return the symbol of the given currency code for the specified locale, or null if
|
|
62 |
* the symbol is not available for the locale
|
|
63 |
* @exception NullPointerException if <code>currencyCode</code> or
|
|
64 |
* <code>locale</code> is null
|
|
65 |
* @exception IllegalArgumentException if <code>currencyCode</code> is not in
|
|
66 |
* the form of three upper-case letters, or <code>locale</code> isn't
|
|
67 |
* one of the locales returned from
|
|
68 |
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
|
|
69 |
* getAvailableLocales()}.
|
|
70 |
* @see java.util.Currency#getSymbol(java.util.Locale)
|
|
71 |
*/
|
|
72 |
public abstract String getSymbol(String currencyCode, Locale locale);
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Returns a name for the currency that is appropriate for display to the
|
|
76 |
* user. The default implementation returns null.
|
|
77 |
*
|
|
78 |
* @param currencyCode the ISO 4217 currency code, which
|
|
79 |
* consists of three upper-case letters between 'A' (U+0041) and
|
|
80 |
* 'Z' (U+005A)
|
|
81 |
* @param locale the desired locale
|
|
82 |
* @return the name for the currency that is appropriate for display to the
|
|
83 |
* user, or null if the name is not available for the locale
|
|
84 |
* @exception IllegalArgumentException if <code>currencyCode</code> is not in
|
|
85 |
* the form of three upper-case letters, or <code>locale</code> isn't
|
|
86 |
* one of the locales returned from
|
|
87 |
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
|
|
88 |
* getAvailableLocales()}.
|
|
89 |
* @exception NullPointerException if <code>currencyCode</code> or
|
|
90 |
* <code>locale</code> is <code>null</code>
|
|
91 |
* @since 1.7
|
|
92 |
*/
|
|
93 |
public String getDisplayName(String currencyCode, Locale locale) {
|
|
94 |
if (currencyCode == null || locale == null) {
|
|
95 |
throw new NullPointerException();
|
|
96 |
}
|
|
97 |
|
|
98 |
return null;
|
|
99 |
}
|
|
100 |
}
|