Rabbit-R1/android (non root)/smali/smali_classes2/com/alibaba/fastjson/serializer/ArrayCodec.smali
2024-05-21 17:08:36 -04:00

550 lines
14 KiB
Smali

.class public final Lcom/alibaba/fastjson/serializer/ArrayCodec;
.super Ljava/lang/Object;
.source "ArrayCodec.java"
# interfaces
.implements Lcom/alibaba/fastjson/serializer/ObjectSerializer;
.implements Lcom/alibaba/fastjson/parser/deserializer/ObjectDeserializer;
# static fields
.field public static final instance:Lcom/alibaba/fastjson/serializer/ArrayCodec;
# direct methods
.method static constructor <clinit>()V
.locals 1
.line 35
new-instance v0, Lcom/alibaba/fastjson/serializer/ArrayCodec;
invoke-direct {v0}, Lcom/alibaba/fastjson/serializer/ArrayCodec;-><init>()V
sput-object v0, Lcom/alibaba/fastjson/serializer/ArrayCodec;->instance:Lcom/alibaba/fastjson/serializer/ArrayCodec;
return-void
.end method
.method private constructor <init>()V
.locals 0
.line 37
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method private toObjectArray(Lcom/alibaba/fastjson/parser/DefaultJSONParser;Ljava/lang/Class;Lcom/alibaba/fastjson/JSONArray;)Ljava/lang/Object;
.locals 5
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Lcom/alibaba/fastjson/parser/DefaultJSONParser;",
"Ljava/lang/Class<",
"*>;",
"Lcom/alibaba/fastjson/JSONArray;",
")TT;"
}
.end annotation
if-nez p3, :cond_0
const/4 p0, 0x0
return-object p0
.line 179
:cond_0
invoke-virtual {p3}, Lcom/alibaba/fastjson/JSONArray;->size()I
move-result v0
.line 181
invoke-static {p2, v0}, Ljava/lang/reflect/Array;->newInstance(Ljava/lang/Class;I)Ljava/lang/Object;
move-result-object v1
const/4 v2, 0x0
:goto_0
if-ge v2, v0, :cond_4
.line 183
invoke-virtual {p3, v2}, Lcom/alibaba/fastjson/JSONArray;->get(I)Ljava/lang/Object;
move-result-object v3
if-ne v3, p3, :cond_1
.line 186
invoke-static {v1, v2, v1}, Ljava/lang/reflect/Array;->set(Ljava/lang/Object;ILjava/lang/Object;)V
goto :goto_2
.line 191
:cond_1
invoke-virtual {p2}, Ljava/lang/Class;->isArray()Z
move-result v4
if-eqz v4, :cond_3
.line 192
invoke-virtual {p2, v3}, Ljava/lang/Class;->isInstance(Ljava/lang/Object;)Z
move-result v4
if-eqz v4, :cond_2
goto :goto_1
.line 195
:cond_2
check-cast v3, Lcom/alibaba/fastjson/JSONArray;
invoke-direct {p0, p1, p2, v3}, Lcom/alibaba/fastjson/serializer/ArrayCodec;->toObjectArray(Lcom/alibaba/fastjson/parser/DefaultJSONParser;Ljava/lang/Class;Lcom/alibaba/fastjson/JSONArray;)Ljava/lang/Object;
move-result-object v3
goto :goto_1
.line 198
:cond_3
iget-object v4, p1, Lcom/alibaba/fastjson/parser/DefaultJSONParser;->config:Lcom/alibaba/fastjson/parser/ParserConfig;
invoke-static {v3, p2, v4}, Lcom/alibaba/fastjson/util/TypeUtils;->cast(Ljava/lang/Object;Ljava/lang/Class;Lcom/alibaba/fastjson/parser/ParserConfig;)Ljava/lang/Object;
move-result-object v3
.line 200
:goto_1
invoke-static {v1, v2, v3}, Ljava/lang/reflect/Array;->set(Ljava/lang/Object;ILjava/lang/Object;)V
:goto_2
add-int/lit8 v2, v2, 0x1
goto :goto_0
.line 203
:cond_4
invoke-virtual {p3, v1}, Lcom/alibaba/fastjson/JSONArray;->setRelatedArray(Ljava/lang/Object;)V
.line 204
invoke-virtual {p3, p2}, Lcom/alibaba/fastjson/JSONArray;->setComponentType(Ljava/lang/reflect/Type;)V
return-object v1
.end method
# virtual methods
.method public deserialze(Lcom/alibaba/fastjson/parser/DefaultJSONParser;Ljava/lang/reflect/Type;Ljava/lang/Object;)Ljava/lang/Object;
.locals 5
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Lcom/alibaba/fastjson/parser/DefaultJSONParser;",
"Ljava/lang/reflect/Type;",
"Ljava/lang/Object;",
")TT;"
}
.end annotation
.line 134
iget-object v0, p1, Lcom/alibaba/fastjson/parser/DefaultJSONParser;->lexer:Lcom/alibaba/fastjson/parser/JSONLexer;
.line 136
invoke-virtual {v0}, Lcom/alibaba/fastjson/parser/JSONLexer;->token()I
move-result v1
const/16 v2, 0x8
const/16 v3, 0x10
if-ne v1, v2, :cond_0
.line 138
invoke-virtual {v0, v3}, Lcom/alibaba/fastjson/parser/JSONLexer;->nextToken(I)V
const/4 p0, 0x0
return-object p0
:cond_0
const-class v2, [C
const/4 v4, 0x4
if-ne p2, v2, :cond_3
if-ne v1, v4, :cond_1
.line 144
invoke-virtual {v0}, Lcom/alibaba/fastjson/parser/JSONLexer;->stringVal()Ljava/lang/String;
move-result-object p0
.line 145
invoke-virtual {v0, v3}, Lcom/alibaba/fastjson/parser/JSONLexer;->nextToken(I)V
.line 146
invoke-virtual {p0}, Ljava/lang/String;->toCharArray()[C
move-result-object p0
return-object p0
:cond_1
const/4 p0, 0x2
if-ne v1, p0, :cond_2
.line 150
invoke-virtual {v0}, Lcom/alibaba/fastjson/parser/JSONLexer;->integerValue()Ljava/lang/Number;
move-result-object p0
.line 151
invoke-virtual {v0, v3}, Lcom/alibaba/fastjson/parser/JSONLexer;->nextToken(I)V
.line 152
invoke-virtual {p0}, Ljava/lang/Object;->toString()Ljava/lang/String;
move-result-object p0
invoke-virtual {p0}, Ljava/lang/String;->toCharArray()[C
move-result-object p0
return-object p0
.line 155
:cond_2
invoke-virtual {p1}, Lcom/alibaba/fastjson/parser/DefaultJSONParser;->parse()Ljava/lang/Object;
move-result-object p0
.line 156
invoke-static {p0}, Lcom/alibaba/fastjson/JSON;->toJSONString(Ljava/lang/Object;)Ljava/lang/String;
move-result-object p0
invoke-virtual {p0}, Ljava/lang/String;->toCharArray()[C
move-result-object p0
return-object p0
:cond_3
if-ne v1, v4, :cond_4
.line 160
invoke-virtual {v0}, Lcom/alibaba/fastjson/parser/JSONLexer;->bytesValue()[B
move-result-object p0
.line 161
invoke-virtual {v0, v3}, Lcom/alibaba/fastjson/parser/JSONLexer;->nextToken(I)V
return-object p0
.line 165
:cond_4
check-cast p2, Ljava/lang/Class;
.line 166
invoke-virtual {p2}, Ljava/lang/Class;->getComponentType()Ljava/lang/Class;
move-result-object p2
.line 167
new-instance v0, Lcom/alibaba/fastjson/JSONArray;
invoke-direct {v0}, Lcom/alibaba/fastjson/JSONArray;-><init>()V
.line 168
invoke-virtual {p1, p2, v0, p3}, Lcom/alibaba/fastjson/parser/DefaultJSONParser;->parseArray(Ljava/lang/reflect/Type;Ljava/util/Collection;Ljava/lang/Object;)V
.line 170
invoke-direct {p0, p1, p2, v0}, Lcom/alibaba/fastjson/serializer/ArrayCodec;->toObjectArray(Lcom/alibaba/fastjson/parser/DefaultJSONParser;Ljava/lang/Class;Lcom/alibaba/fastjson/JSONArray;)Ljava/lang/Object;
move-result-object p0
return-object p0
.end method
.method public final write(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/reflect/Type;)V
.locals 8
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 45
iget-object p0, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->out:Lcom/alibaba/fastjson/serializer/SerializeWriter;
.line 47
move-object p4, p2
check-cast p4, [Ljava/lang/Object;
check-cast p4, [Ljava/lang/Object;
const-string v0, "[]"
if-nez p2, :cond_1
.line 50
iget p1, p0, Lcom/alibaba/fastjson/serializer/SerializeWriter;->features:I
sget-object p2, Lcom/alibaba/fastjson/serializer/SerializerFeature;->WriteNullListAsEmpty:Lcom/alibaba/fastjson/serializer/SerializerFeature;
iget p2, p2, Lcom/alibaba/fastjson/serializer/SerializerFeature;->mask:I
and-int/2addr p1, p2
if-eqz p1, :cond_0
.line 51
invoke-virtual {p0, v0}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->write(Ljava/lang/String;)V
goto :goto_0
.line 53
:cond_0
invoke-virtual {p0}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->writeNull()V
:goto_0
return-void
.line 58
:cond_1
array-length v1, p4
add-int/lit8 v2, v1, -0x1
const/4 v3, -0x1
if-ne v2, v3, :cond_2
.line 63
invoke-virtual {p0, v0}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->append(Ljava/lang/CharSequence;)Lcom/alibaba/fastjson/serializer/SerializeWriter;
return-void
.line 67
:cond_2
iget-object v0, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->context:Lcom/alibaba/fastjson/serializer/SerialContext;
const/4 v3, 0x0
.line 68
invoke-virtual {p1, v0, p2, p3, v3}, Lcom/alibaba/fastjson/serializer/JSONSerializer;->setContext(Lcom/alibaba/fastjson/serializer/SerialContext;Ljava/lang/Object;Ljava/lang/Object;I)V
const/16 p2, 0x5b
.line 73
:try_start_0
invoke-virtual {p0, p2}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->write(I)V
.line 75
iget p2, p0, Lcom/alibaba/fastjson/serializer/SerializeWriter;->features:I
sget-object p3, Lcom/alibaba/fastjson/serializer/SerializerFeature;->PrettyFormat:Lcom/alibaba/fastjson/serializer/SerializerFeature;
iget p3, p3, Lcom/alibaba/fastjson/serializer/SerializerFeature;->mask:I
and-int/2addr p2, p3
const/16 p3, 0x5d
const/16 v4, 0x2c
if-eqz p2, :cond_5
.line 76
invoke-virtual {p1}, Lcom/alibaba/fastjson/serializer/JSONSerializer;->incrementIndent()V
.line 77
invoke-virtual {p1}, Lcom/alibaba/fastjson/serializer/JSONSerializer;->println()V
:goto_1
if-ge v3, v1, :cond_4
if-eqz v3, :cond_3
.line 80
invoke-virtual {p0, v4}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->write(I)V
.line 81
invoke-virtual {p1}, Lcom/alibaba/fastjson/serializer/JSONSerializer;->println()V
.line 83
:cond_3
aget-object p2, p4, v3
invoke-virtual {p1, p2}, Lcom/alibaba/fastjson/serializer/JSONSerializer;->write(Ljava/lang/Object;)V
add-int/lit8 v3, v3, 0x1
goto :goto_1
.line 85
:cond_4
invoke-virtual {p1}, Lcom/alibaba/fastjson/serializer/JSONSerializer;->decrementIdent()V
.line 86
invoke-virtual {p1}, Lcom/alibaba/fastjson/serializer/JSONSerializer;->println()V
.line 87
invoke-virtual {p0, p3}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->write(I)V
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
.line 128
iput-object v0, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->context:Lcom/alibaba/fastjson/serializer/SerialContext;
return-void
:cond_5
const/4 p2, 0x0
move-object v1, p2
move-object v5, v1
:goto_2
if-ge v3, v2, :cond_9
.line 92
:try_start_1
aget-object v6, p4, v3
if-nez v6, :cond_6
const-string v6, "null,"
.line 95
invoke-virtual {p0, v6}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->append(Ljava/lang/CharSequence;)Lcom/alibaba/fastjson/serializer/SerializeWriter;
goto :goto_4
.line 97
:cond_6
iget-object v7, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->references:Ljava/util/IdentityHashMap;
if-eqz v7, :cond_7
iget-object v7, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->references:Ljava/util/IdentityHashMap;
invoke-virtual {v7, v6}, Ljava/util/IdentityHashMap;->containsKey(Ljava/lang/Object;)Z
move-result v7
if-eqz v7, :cond_7
.line 98
invoke-virtual {p1, v6}, Lcom/alibaba/fastjson/serializer/JSONSerializer;->writeReference(Ljava/lang/Object;)V
goto :goto_3
.line 100
:cond_7
invoke-virtual {v6}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
move-result-object v7
if-ne v7, v1, :cond_8
.line 103
invoke-interface {v5, p1, v6, p2, p2}, Lcom/alibaba/fastjson/serializer/ObjectSerializer;->write(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/reflect/Type;)V
goto :goto_3
.line 106
:cond_8
iget-object v1, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->config:Lcom/alibaba/fastjson/serializer/SerializeConfig;
invoke-virtual {v1, v7}, Lcom/alibaba/fastjson/serializer/SerializeConfig;->get(Ljava/lang/Class;)Lcom/alibaba/fastjson/serializer/ObjectSerializer;
move-result-object v5
.line 108
invoke-interface {v5, p1, v6, p2, p2}, Lcom/alibaba/fastjson/serializer/ObjectSerializer;->write(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/reflect/Type;)V
move-object v1, v7
.line 111
:goto_3
invoke-virtual {p0, v4}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->write(I)V
:goto_4
add-int/lit8 v3, v3, 0x1
goto :goto_2
.line 115
:cond_9
aget-object p2, p4, v2
if-nez p2, :cond_a
const-string p2, "null]"
.line 118
invoke-virtual {p0, p2}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->append(Ljava/lang/CharSequence;)Lcom/alibaba/fastjson/serializer/SerializeWriter;
goto :goto_6
.line 120
:cond_a
iget-object p4, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->references:Ljava/util/IdentityHashMap;
if-eqz p4, :cond_b
iget-object p4, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->references:Ljava/util/IdentityHashMap;
invoke-virtual {p4, p2}, Ljava/util/IdentityHashMap;->containsKey(Ljava/lang/Object;)Z
move-result p4
if-eqz p4, :cond_b
.line 121
invoke-virtual {p1, p2}, Lcom/alibaba/fastjson/serializer/JSONSerializer;->writeReference(Ljava/lang/Object;)V
goto :goto_5
.line 123
:cond_b
invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object p4
invoke-virtual {p1, p2, p4}, Lcom/alibaba/fastjson/serializer/JSONSerializer;->writeWithFieldName(Ljava/lang/Object;Ljava/lang/Object;)V
.line 125
:goto_5
invoke-virtual {p0, p3}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->write(I)V
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_0
.line 128
:goto_6
iput-object v0, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->context:Lcom/alibaba/fastjson/serializer/SerialContext;
return-void
:catchall_0
move-exception p0
iput-object v0, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->context:Lcom/alibaba/fastjson/serializer/SerialContext;
.line 129
throw p0
.end method