BigDecimalCodec.smali
6.4 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
.class public Lnet/json/fastjson/serializer/BigDecimalCodec;
.super Ljava/lang/Object;
.source "BigDecimalCodec.java"
# interfaces
.implements Lnet/json/fastjson/serializer/ObjectSerializer;
.implements Lnet/json/fastjson/parser/deserializer/ObjectDeserializer;
# static fields
.field public static final instance:Lnet/json/fastjson/serializer/BigDecimalCodec;
# direct methods
.method static constructor <clinit>()V
.locals 1
.line 1
new-instance v0, Lnet/json/fastjson/serializer/BigDecimalCodec;
invoke-direct {v0}, Lnet/json/fastjson/serializer/BigDecimalCodec;-><init>()V
sput-object v0, Lnet/json/fastjson/serializer/BigDecimalCodec;->instance:Lnet/json/fastjson/serializer/BigDecimalCodec;
return-void
.end method
.method private constructor <init>()V
.locals 0
.line 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
# virtual methods
.method public deserialze(Lnet/json/fastjson/parser/DefaultJSONParser;Ljava/lang/reflect/Type;Ljava/lang/Object;)Ljava/lang/Object;
.locals 3
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Lnet/json/fastjson/parser/DefaultJSONParser;",
"Ljava/lang/reflect/Type;",
"Ljava/lang/Object;",
")TT;"
}
.end annotation
.line 1
iget-object p3, p1, Lnet/json/fastjson/parser/DefaultJSONParser;->lexer:Lnet/json/fastjson/parser/JSONLexer;
.line 3
invoke-virtual {p3}, Lnet/json/fastjson/parser/JSONLexer;->token()I
move-result v0
const/16 v1, 0x10
const/4 v2, 0x2
if-ne v0, v2, :cond_1
.line 5
const-class p1, Ljava/math/BigInteger;
if-ne p2, p1, :cond_0
.line 6
invoke-virtual {p3}, Lnet/json/fastjson/parser/JSONLexer;->numberString()Ljava/lang/String;
move-result-object p1
.line 7
invoke-virtual {p3, v1}, Lnet/json/fastjson/parser/JSONLexer;->nextToken(I)V
.line 8
new-instance p2, Ljava/math/BigInteger;
const/16 p3, 0xa
invoke-direct {p2, p1, p3}, Ljava/math/BigInteger;-><init>(Ljava/lang/String;I)V
return-object p2
.line 10
:cond_0
invoke-virtual {p3}, Lnet/json/fastjson/parser/JSONLexer;->decimalValue()Ljava/math/BigDecimal;
move-result-object p1
.line 11
invoke-virtual {p3, v1}, Lnet/json/fastjson/parser/JSONLexer;->nextToken(I)V
return-object p1
:cond_1
const/4 v2, 0x3
if-ne v0, v2, :cond_4
.line 17
invoke-virtual {p3}, Lnet/json/fastjson/parser/JSONLexer;->decimalValue()Ljava/math/BigDecimal;
move-result-object p1
.line 18
invoke-virtual {p3, v1}, Lnet/json/fastjson/parser/JSONLexer;->nextToken(I)V
.line 20
const-class p3, Ljava/math/BigInteger;
if-ne p2, p3, :cond_3
.line 21
invoke-virtual {p1}, Ljava/math/BigDecimal;->scale()I
move-result p2
const/16 p3, -0x64
if-lt p2, p3, :cond_2
const/16 p3, 0x64
if-gt p2, p3, :cond_2
.line 25
invoke-virtual {p1}, Ljava/math/BigDecimal;->toBigInteger()Ljava/math/BigInteger;
move-result-object p1
return-object p1
.line 26
:cond_2
new-instance p1, Ljava/lang/NumberFormatException;
invoke-direct {p1}, Ljava/lang/NumberFormatException;-><init>()V
throw p1
:cond_3
return-object p1
.line 34
:cond_4
invoke-virtual {p1}, Lnet/json/fastjson/parser/DefaultJSONParser;->parse()Ljava/lang/Object;
move-result-object p1
if-nez p1, :cond_5
const/4 p1, 0x0
return-object p1
.line 40
:cond_5
const-class p3, Ljava/math/BigInteger;
if-ne p2, p3, :cond_6
.line 41
invoke-static {p1}, Lnet/json/fastjson/util/TypeUtils;->castToBigInteger(Ljava/lang/Object;)Ljava/math/BigInteger;
move-result-object p1
return-object p1
.line 44
:cond_6
invoke-static {p1}, Lnet/json/fastjson/util/TypeUtils;->castToBigDecimal(Ljava/lang/Object;)Ljava/math/BigDecimal;
move-result-object p1
return-object p1
.end method
.method public write(Lnet/json/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/reflect/Type;)V
.locals 1
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
iget-object p1, p1, Lnet/json/fastjson/serializer/JSONSerializer;->out:Lnet/json/fastjson/serializer/SerializeWriter;
if-nez p2, :cond_1
.line 4
iget p2, p1, Lnet/json/fastjson/serializer/SerializeWriter;->features:I
sget-object p3, Lnet/json/fastjson/serializer/SerializerFeature;->WriteNullNumberAsZero:Lnet/json/fastjson/serializer/SerializerFeature;
iget p3, p3, Lnet/json/fastjson/serializer/SerializerFeature;->mask:I
and-int/2addr p2, p3
if-eqz p2, :cond_0
const/16 p2, 0x30
.line 5
invoke-virtual {p1, p2}, Lnet/json/fastjson/serializer/SerializeWriter;->write(I)V
goto :goto_0
.line 7
:cond_0
invoke-virtual {p1}, Lnet/json/fastjson/serializer/SerializeWriter;->writeNull()V
:goto_0
return-void
.line 12
:cond_1
instance-of p3, p2, Ljava/math/BigInteger;
if-eqz p3, :cond_2
.line 13
check-cast p2, Ljava/math/BigInteger;
.line 14
invoke-virtual {p2}, Ljava/math/BigInteger;->toString()Ljava/lang/String;
move-result-object p2
invoke-virtual {p1, p2}, Lnet/json/fastjson/serializer/SerializeWriter;->write(Ljava/lang/String;)V
return-void
.line 18
:cond_2
check-cast p2, Ljava/math/BigDecimal;
.line 19
invoke-virtual {p2}, Ljava/math/BigDecimal;->toString()Ljava/lang/String;
move-result-object p3
invoke-virtual {p1, p3}, Lnet/json/fastjson/serializer/SerializeWriter;->write(Ljava/lang/String;)V
.line 21
iget p3, p1, Lnet/json/fastjson/serializer/SerializeWriter;->features:I
sget-object v0, Lnet/json/fastjson/serializer/SerializerFeature;->WriteClassName:Lnet/json/fastjson/serializer/SerializerFeature;
iget v0, v0, Lnet/json/fastjson/serializer/SerializerFeature;->mask:I
and-int/2addr p3, v0
if-eqz p3, :cond_3
const-class p3, Ljava/math/BigDecimal;
if-eq p4, p3, :cond_3
invoke-virtual {p2}, Ljava/math/BigDecimal;->scale()I
move-result p2
if-nez p2, :cond_3
const/16 p2, 0x2e
.line 22
invoke-virtual {p1, p2}, Lnet/json/fastjson/serializer/SerializeWriter;->write(I)V
:cond_3
return-void
.end method