NumberFormat.java
8.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.agl.text;
import com.adobe.agl.impl.ICUResourceBundle;
import com.adobe.agl.text.UFormat;
import com.adobe.agl.util.Currency;
import com.adobe.agl.util.CurrencyAmount;
import com.adobe.agl.util.ULocale;
import com.adobe.agl.util.UResourceBundle;
import java.io.InvalidObjectException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.FieldPosition;
import java.text.Format;
import java.text.ParsePosition;
public abstract class NumberFormat
extends UFormat {
private boolean groupingUsed = true;
private byte maxIntegerDigits = 40;
private byte minIntegerDigits = 1;
private byte maxFractionDigits = 3;
private byte minFractionDigits = 0;
private boolean parseIntegerOnly = false;
private int maximumIntegerDigits = 40;
private int minimumIntegerDigits = 1;
private int maximumFractionDigits = 3;
private int minimumFractionDigits = 0;
private Currency currency;
private int serialVersionOnStream = 1;
private boolean parseStrict;
public StringBuffer format(Object number, StringBuffer toAppendTo, FieldPosition pos) {
if (number instanceof Long) {
return this.format((Long)number, toAppendTo, pos);
}
if (number instanceof BigInteger) {
return this.format((BigInteger)number, toAppendTo, pos);
}
if (number instanceof BigDecimal) {
return this.format((BigDecimal)number, toAppendTo, pos);
}
if (number instanceof com.adobe.agl.math.BigDecimal) {
return this.format((com.adobe.agl.math.BigDecimal)number, toAppendTo, pos);
}
if (number instanceof CurrencyAmount) {
return this.format((CurrencyAmount)number, toAppendTo, pos);
}
if (number instanceof Number) {
return this.format(((Number)number).doubleValue(), toAppendTo, pos);
}
throw new IllegalArgumentException("Cannot format given Object as a Number");
}
public final Object parseObject(String source, ParsePosition parsePosition) {
return this.parse(source, parsePosition);
}
public abstract StringBuffer format(double var1, StringBuffer var3, FieldPosition var4);
public abstract StringBuffer format(long var1, StringBuffer var3, FieldPosition var4);
public abstract StringBuffer format(BigInteger var1, StringBuffer var2, FieldPosition var3);
public abstract StringBuffer format(BigDecimal var1, StringBuffer var2, FieldPosition var3);
public abstract StringBuffer format(com.adobe.agl.math.BigDecimal var1, StringBuffer var2, FieldPosition var3);
public StringBuffer format(CurrencyAmount currAmt, StringBuffer toAppendTo, FieldPosition pos) {
Currency save = this.getCurrency();
Currency curr = currAmt.getCurrency();
boolean same = curr.equals(save);
if (!same) {
this.setCurrency(curr);
}
this.format(currAmt.getNumber(), toAppendTo, pos);
if (!same) {
this.setCurrency(save);
}
return toAppendTo;
}
public abstract Number parse(String var1, ParsePosition var2);
public boolean isParseIntegerOnly() {
return this.parseIntegerOnly;
}
public boolean isParseStrict() {
return this.parseStrict;
}
public int hashCode() {
return this.maximumIntegerDigits * 37 + this.maxFractionDigits;
}
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (this == obj) {
return true;
}
if (this.getClass() != obj.getClass()) {
return false;
}
NumberFormat other = (NumberFormat)obj;
return this.maximumIntegerDigits == other.maximumIntegerDigits && this.minimumIntegerDigits == other.minimumIntegerDigits && this.maximumFractionDigits == other.maximumFractionDigits && this.minimumFractionDigits == other.minimumFractionDigits && this.groupingUsed == other.groupingUsed && this.parseIntegerOnly == other.parseIntegerOnly && this.parseStrict == other.parseStrict;
}
public Object clone() {
NumberFormat other = (NumberFormat)super.clone();
return other;
}
public boolean isGroupingUsed() {
return this.groupingUsed;
}
public void setGroupingUsed(boolean newValue) {
this.groupingUsed = newValue;
}
public int getMaximumIntegerDigits() {
return this.maximumIntegerDigits;
}
public void setMaximumIntegerDigits(int newValue) {
this.maximumIntegerDigits = Math.max(0, newValue);
if (this.minimumIntegerDigits > this.maximumIntegerDigits) {
this.minimumIntegerDigits = this.maximumIntegerDigits;
}
}
public int getMinimumIntegerDigits() {
return this.minimumIntegerDigits;
}
public void setMinimumIntegerDigits(int newValue) {
this.minimumIntegerDigits = Math.max(0, newValue);
if (this.minimumIntegerDigits > this.maximumIntegerDigits) {
this.maximumIntegerDigits = this.minimumIntegerDigits;
}
}
public int getMaximumFractionDigits() {
return this.maximumFractionDigits;
}
public void setMaximumFractionDigits(int newValue) {
this.maximumFractionDigits = Math.max(0, newValue);
if (this.maximumFractionDigits < this.minimumFractionDigits) {
this.minimumFractionDigits = this.maximumFractionDigits;
}
}
public int getMinimumFractionDigits() {
return this.minimumFractionDigits;
}
public void setMinimumFractionDigits(int newValue) {
this.minimumFractionDigits = Math.max(0, newValue);
if (this.maximumFractionDigits < this.minimumFractionDigits) {
this.maximumFractionDigits = this.minimumFractionDigits;
}
}
public void setCurrency(Currency theCurrency) {
this.currency = theCurrency;
}
public Currency getCurrency() {
return this.currency;
}
protected static String getPattern(ULocale forLocale, int choice) {
if (choice == 3) {
return "#E0";
}
ICUResourceBundle rb = (ICUResourceBundle)UResourceBundle.getBundleInstance("com/adobe/agl/impl/data/icudt40b", forLocale);
String[] numberPatterns = rb.getStringArray("NumberPatterns");
int entry = choice == 4 ? 0 : choice;
return numberPatterns[entry];
}
public static class Field
extends Format.Field {
public static final Field SIGN = new Field("sign");
public static final Field INTEGER = new Field("integer");
public static final Field FRACTION = new Field("fraction");
public static final Field EXPONENT = new Field("exponent");
public static final Field EXPONENT_SIGN = new Field("exponent sign");
public static final Field EXPONENT_SYMBOL = new Field("exponent symbol");
public static final Field DECIMAL_SEPARATOR = new Field("decimal separator");
public static final Field GROUPING_SEPARATOR = new Field("grouping separator");
public static final Field PERCENT = new Field("percent");
public static final Field PERMILLE = new Field("per mille");
public static final Field CURRENCY = new Field("currency");
protected Field(String fieldName) {
super(fieldName);
}
protected Object readResolve() throws InvalidObjectException {
if (this.getName().equals(INTEGER.getName())) {
return INTEGER;
}
if (this.getName().equals(FRACTION.getName())) {
return FRACTION;
}
if (this.getName().equals(EXPONENT.getName())) {
return EXPONENT;
}
if (this.getName().equals(EXPONENT_SIGN.getName())) {
return EXPONENT_SIGN;
}
if (this.getName().equals(EXPONENT_SYMBOL.getName())) {
return EXPONENT_SYMBOL;
}
if (this.getName().equals(CURRENCY.getName())) {
return CURRENCY;
}
if (this.getName().equals(DECIMAL_SEPARATOR.getName())) {
return DECIMAL_SEPARATOR;
}
if (this.getName().equals(GROUPING_SEPARATOR.getName())) {
return GROUPING_SEPARATOR;
}
if (this.getName().equals(PERCENT.getName())) {
return PERCENT;
}
if (this.getName().equals(PERMILLE.getName())) {
return PERMILLE;
}
if (this.getName().equals(SIGN.getName())) {
return SIGN;
}
throw new InvalidObjectException("An invalid object.");
}
}
}