author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 58288 | 48e480e56aad |
permissions | -rw-r--r-- |
2 | 1 |
/* |
58242
94bb65cb37d3
8230648: Replace @exception tag with @throws in java.base
jboes
parents:
52869
diff
changeset
|
2 |
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.text.spi; |
|
27 |
||
28 |
import java.text.NumberFormat; |
|
29 |
import java.util.Locale; |
|
30 |
import java.util.spi.LocaleServiceProvider; |
|
31 |
||
32 |
/** |
|
33 |
* An abstract class for service providers that |
|
34 |
* provide concrete implementations of the |
|
35 |
* {@link java.text.NumberFormat NumberFormat} class. |
|
36 |
* |
|
37 |
* @since 1.6 |
|
38 |
*/ |
|
39 |
public abstract class NumberFormatProvider extends LocaleServiceProvider { |
|
40 |
||
41 |
/** |
|
42 |
* Sole constructor. (For invocation by subclass constructors, typically |
|
43 |
* implicit.) |
|
44 |
*/ |
|
45 |
protected NumberFormatProvider() { |
|
46 |
} |
|
47 |
||
48 |
/** |
|
58288
48e480e56aad
8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents:
58242
diff
changeset
|
49 |
* Returns a new {@code NumberFormat} instance which formats |
2 | 50 |
* monetary values for the specified locale. |
51 |
* |
|
52 |
* @param locale the desired locale. |
|
58288
48e480e56aad
8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents:
58242
diff
changeset
|
53 |
* @throws NullPointerException if {@code locale} is null |
48e480e56aad
8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents:
58242
diff
changeset
|
54 |
* @throws IllegalArgumentException if {@code locale} isn't |
2 | 55 |
* one of the locales returned from |
56 |
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() |
|
57 |
* getAvailableLocales()}. |
|
58 |
* @return a currency formatter |
|
59 |
* @see java.text.NumberFormat#getCurrencyInstance(java.util.Locale) |
|
60 |
*/ |
|
61 |
public abstract NumberFormat getCurrencyInstance(Locale locale); |
|
62 |
||
63 |
/** |
|
58288
48e480e56aad
8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents:
58242
diff
changeset
|
64 |
* Returns a new {@code NumberFormat} instance which formats |
2 | 65 |
* integer values for the specified locale. |
66 |
* The returned number format is configured to |
|
67 |
* round floating point numbers to the nearest integer using |
|
68 |
* half-even rounding (see {@link java.math.RoundingMode#HALF_EVEN HALF_EVEN}) |
|
69 |
* for formatting, and to parse only the integer part of |
|
70 |
* an input string (see {@link |
|
71 |
* java.text.NumberFormat#isParseIntegerOnly isParseIntegerOnly}). |
|
72 |
* |
|
73 |
* @param locale the desired locale |
|
58288
48e480e56aad
8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents:
58242
diff
changeset
|
74 |
* @throws NullPointerException if {@code locale} is null |
48e480e56aad
8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents:
58242
diff
changeset
|
75 |
* @throws IllegalArgumentException if {@code locale} isn't |
2 | 76 |
* one of the locales returned from |
77 |
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() |
|
78 |
* getAvailableLocales()}. |
|
79 |
* @return a number format for integer values |
|
80 |
* @see java.text.NumberFormat#getIntegerInstance(java.util.Locale) |
|
81 |
*/ |
|
82 |
public abstract NumberFormat getIntegerInstance(Locale locale); |
|
83 |
||
84 |
/** |
|
58288
48e480e56aad
8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents:
58242
diff
changeset
|
85 |
* Returns a new general-purpose {@code NumberFormat} instance for |
2 | 86 |
* the specified locale. |
87 |
* |
|
88 |
* @param locale the desired locale |
|
58288
48e480e56aad
8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents:
58242
diff
changeset
|
89 |
* @throws NullPointerException if {@code locale} is null |
48e480e56aad
8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents:
58242
diff
changeset
|
90 |
* @throws IllegalArgumentException if {@code locale} isn't |
2 | 91 |
* one of the locales returned from |
92 |
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() |
|
93 |
* getAvailableLocales()}. |
|
94 |
* @return a general-purpose number formatter |
|
95 |
* @see java.text.NumberFormat#getNumberInstance(java.util.Locale) |
|
96 |
*/ |
|
97 |
public abstract NumberFormat getNumberInstance(Locale locale); |
|
98 |
||
99 |
/** |
|
58288
48e480e56aad
8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents:
58242
diff
changeset
|
100 |
* Returns a new {@code NumberFormat} instance which formats |
2 | 101 |
* percentage values for the specified locale. |
102 |
* |
|
103 |
* @param locale the desired locale |
|
58288
48e480e56aad
8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents:
58242
diff
changeset
|
104 |
* @throws NullPointerException if {@code locale} is null |
48e480e56aad
8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents:
58242
diff
changeset
|
105 |
* @throws IllegalArgumentException if {@code locale} isn't |
2 | 106 |
* one of the locales returned from |
107 |
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() |
|
108 |
* getAvailableLocales()}. |
|
109 |
* @return a percent formatter |
|
110 |
* @see java.text.NumberFormat#getPercentInstance(java.util.Locale) |
|
111 |
*/ |
|
112 |
public abstract NumberFormat getPercentInstance(Locale locale); |
|
52869 | 113 |
|
114 |
/** |
|
115 |
* Returns a new {@code NumberFormat} instance which formats |
|
116 |
* a number in its compact form for the specified |
|
117 |
* {@code locale} and {@code formatStyle}. |
|
118 |
* |
|
119 |
* @implSpec The default implementation of this method throws |
|
120 |
* {@code UnSupportedOperationException}. Overriding the implementation |
|
121 |
* of this method returns the compact number formatter instance |
|
122 |
* of the given {@code locale} with specified {@code formatStyle}. |
|
123 |
* |
|
124 |
* @param locale the desired locale |
|
125 |
* @param formatStyle the style for formatting a number |
|
126 |
* @throws NullPointerException if {@code locale} or {@code formatStyle} |
|
127 |
* is {@code null} |
|
128 |
* @throws IllegalArgumentException if {@code locale} is not |
|
129 |
* one of the locales returned from |
|
130 |
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() |
|
131 |
* getAvailableLocales()}. |
|
132 |
* @return a compact number formatter |
|
133 |
* |
|
134 |
* @see java.text.NumberFormat#getCompactNumberInstance(Locale, |
|
135 |
* NumberFormat.Style) |
|
136 |
* @since 12 |
|
137 |
*/ |
|
138 |
public NumberFormat getCompactNumberInstance(Locale locale, |
|
139 |
NumberFormat.Style formatStyle) { |
|
140 |
throw new UnsupportedOperationException( |
|
141 |
"The " + this.getClass().getName() + " should override this" |
|
142 |
+ " method to return compact number format instance of " |
|
143 |
+ locale + " locale and " + formatStyle + " style."); |
|
144 |
} |
|
145 |
||
2 | 146 |
} |