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

588 lines
18 KiB
Smali

.class public final Lcom/alibaba/fastjson/serializer/FieldSerializer;
.super Ljava/lang/Object;
.source "FieldSerializer.java"
# interfaces
.implements Ljava/lang/Comparable;
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;
}
.end annotation
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/lang/Object;",
"Ljava/lang/Comparable<",
"Lcom/alibaba/fastjson/serializer/FieldSerializer;",
">;"
}
.end annotation
# instance fields
.field protected final features:I
.field public final fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
.field protected final format:Ljava/lang/String;
.field protected name_chars:[C
.field private runtimeInfo:Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;
.field protected final writeNull:Z
# direct methods
.method public constructor <init>(Lcom/alibaba/fastjson/util/FieldInfo;)V
.locals 10
.line 38
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
iput-object p1, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
.line 42
invoke-virtual {p1}, Lcom/alibaba/fastjson/util/FieldInfo;->getAnnotation()Lcom/alibaba/fastjson/annotation/JSONField;
move-result-object v0
const/4 v1, 0x1
const/4 v2, 0x0
const/4 v3, 0x0
if-eqz v0, :cond_3
.line 45
invoke-interface {v0}, Lcom/alibaba/fastjson/annotation/JSONField;->serialzeFeatures()[Lcom/alibaba/fastjson/serializer/SerializerFeature;
move-result-object v4
array-length v5, v4
move v6, v2
move v7, v6
:goto_0
if-ge v6, v5, :cond_1
aget-object v8, v4, v6
.line 46
sget-object v9, Lcom/alibaba/fastjson/serializer/SerializerFeature;->WriteMapNullValue:Lcom/alibaba/fastjson/serializer/SerializerFeature;
if-ne v8, v9, :cond_0
move v7, v1
:cond_0
add-int/lit8 v6, v6, 0x1
goto :goto_0
.line 51
:cond_1
invoke-interface {v0}, Lcom/alibaba/fastjson/annotation/JSONField;->format()Ljava/lang/String;
move-result-object v4
.line 53
invoke-virtual {v4}, Ljava/lang/String;->trim()Ljava/lang/String;
move-result-object v4
.line 54
invoke-virtual {v4}, Ljava/lang/String;->length()I
move-result v5
if-nez v5, :cond_2
goto :goto_1
:cond_2
move-object v3, v4
.line 58
:goto_1
invoke-interface {v0}, Lcom/alibaba/fastjson/annotation/JSONField;->serialzeFeatures()[Lcom/alibaba/fastjson/serializer/SerializerFeature;
move-result-object v0
invoke-static {v0}, Lcom/alibaba/fastjson/serializer/SerializerFeature;->of([Lcom/alibaba/fastjson/serializer/SerializerFeature;)I
move-result v0
iput v0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->features:I
goto :goto_2
:cond_3
iput v2, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->features:I
move v7, v2
:goto_2
iput-boolean v7, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->writeNull:Z
iput-object v3, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->format:Ljava/lang/String;
.line 65
iget-object p1, p1, Lcom/alibaba/fastjson/util/FieldInfo;->name:Ljava/lang/String;
.line 66
invoke-virtual {p1}, Ljava/lang/String;->length()I
move-result v0
add-int/lit8 v3, v0, 0x3
.line 67
new-array v3, v3, [C
iput-object v3, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->name_chars:[C
.line 68
invoke-virtual {p1}, Ljava/lang/String;->length()I
move-result v3
iget-object v4, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->name_chars:[C
invoke-virtual {p1, v2, v3, v4, v1}, Ljava/lang/String;->getChars(II[CI)V
iget-object p0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->name_chars:[C
const/16 p1, 0x22
.line 69
aput-char p1, p0, v2
add-int/lit8 v1, v0, 0x1
.line 70
aput-char p1, p0, v1
add-int/lit8 v0, v0, 0x2
const/16 p1, 0x3a
.line 71
aput-char p1, p0, v0
return-void
.end method
# virtual methods
.method public compareTo(Lcom/alibaba/fastjson/serializer/FieldSerializer;)I
.locals 0
iget-object p0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
.line 166
iget-object p1, p1, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
invoke-virtual {p0, p1}, Lcom/alibaba/fastjson/util/FieldInfo;->compareTo(Lcom/alibaba/fastjson/util/FieldInfo;)I
move-result p0
return p0
.end method
.method public bridge synthetic compareTo(Ljava/lang/Object;)I
.locals 0
.line 29
check-cast p1, Lcom/alibaba/fastjson/serializer/FieldSerializer;
invoke-virtual {p0, p1}, Lcom/alibaba/fastjson/serializer/FieldSerializer;->compareTo(Lcom/alibaba/fastjson/serializer/FieldSerializer;)I
move-result p0
return p0
.end method
.method public getPropertyValue(Ljava/lang/Object;)Ljava/lang/Object;
.locals 3
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/lang/Exception;
}
.end annotation
:try_start_0
iget-object v0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
.line 92
invoke-virtual {v0, p1}, Lcom/alibaba/fastjson/util/FieldInfo;->get(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p0
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
return-object p0
:catch_0
move-exception p1
iget-object v0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
.line 94
iget-object v0, v0, Lcom/alibaba/fastjson/util/FieldInfo;->method:Ljava/lang/reflect/Method;
iget-object p0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
if-eqz v0, :cond_0
iget-object p0, p0, Lcom/alibaba/fastjson/util/FieldInfo;->method:Ljava/lang/reflect/Method;
goto :goto_0
:cond_0
iget-object p0, p0, Lcom/alibaba/fastjson/util/FieldInfo;->field:Ljava/lang/reflect/Field;
:goto_0
check-cast p0, Ljava/lang/reflect/Member;
.line 98
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
invoke-interface {p0}, Ljava/lang/reflect/Member;->getDeclaringClass()Ljava/lang/Class;
move-result-object v1
invoke-virtual {v1}, Ljava/lang/Class;->getName()Ljava/lang/String;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
const-string v1, "."
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
invoke-interface {p0}, Ljava/lang/reflect/Member;->getName()Ljava/lang/String;
move-result-object p0
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object p0
invoke-virtual {p0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
.line 100
new-instance v0, Lcom/alibaba/fastjson/JSONException;
new-instance v1, Ljava/lang/StringBuilder;
const-string v2, "get property error\u3002 "
invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object p0
invoke-virtual {p0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p0
invoke-direct {v0, p0, p1}, Lcom/alibaba/fastjson/JSONException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v0
.end method
.method public writePrefix(Lcom/alibaba/fastjson/serializer/JSONSerializer;)V
.locals 3
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 75
iget-object p1, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->out:Lcom/alibaba/fastjson/serializer/SerializeWriter;
.line 77
iget v0, p1, Lcom/alibaba/fastjson/serializer/SerializeWriter;->features:I
.line 79
sget-object v1, Lcom/alibaba/fastjson/serializer/SerializerFeature;->QuoteFieldNames:Lcom/alibaba/fastjson/serializer/SerializerFeature;
iget v1, v1, Lcom/alibaba/fastjson/serializer/SerializerFeature;->mask:I
and-int/2addr v1, v0
const/4 v2, 0x1
if-eqz v1, :cond_1
.line 80
sget-object v1, Lcom/alibaba/fastjson/serializer/SerializerFeature;->UseSingleQuotes:Lcom/alibaba/fastjson/serializer/SerializerFeature;
iget v1, v1, Lcom/alibaba/fastjson/serializer/SerializerFeature;->mask:I
and-int/2addr v0, v1
if-eqz v0, :cond_0
iget-object p0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
.line 81
iget-object p0, p0, Lcom/alibaba/fastjson/util/FieldInfo;->name:Ljava/lang/String;
invoke-virtual {p1, p0, v2}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->writeFieldName(Ljava/lang/String;Z)V
goto :goto_0
:cond_0
iget-object p0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->name_chars:[C
const/4 v0, 0x0
.line 83
array-length v1, p0
invoke-virtual {p1, p0, v0, v1}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->write([CII)V
goto :goto_0
:cond_1
iget-object p0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
.line 86
iget-object p0, p0, Lcom/alibaba/fastjson/util/FieldInfo;->name:Ljava/lang/String;
invoke-virtual {p1, p0, v2}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->writeFieldName(Ljava/lang/String;Z)V
:goto_0
return-void
.end method
.method public writeValue(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;)V
.locals 3
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/lang/Exception;
}
.end annotation
iget-object v0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->format:Ljava/lang/String;
if-eqz v0, :cond_0
.line 106
invoke-virtual {p1, p2, v0}, Lcom/alibaba/fastjson/serializer/JSONSerializer;->writeWithFormat(Ljava/lang/Object;Ljava/lang/String;)V
return-void
:cond_0
iget-object v0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->runtimeInfo:Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;
if-nez v0, :cond_2
if-nez p2, :cond_1
iget-object v0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
.line 114
iget-object v0, v0, Lcom/alibaba/fastjson/util/FieldInfo;->fieldClass:Ljava/lang/Class;
goto :goto_0
.line 116
:cond_1
invoke-virtual {p2}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
move-result-object v0
.line 119
:goto_0
iget-object v1, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->config:Lcom/alibaba/fastjson/serializer/SerializeConfig;
invoke-virtual {v1, v0}, Lcom/alibaba/fastjson/serializer/SerializeConfig;->get(Ljava/lang/Class;)Lcom/alibaba/fastjson/serializer/ObjectSerializer;
move-result-object v1
.line 120
new-instance v2, Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;
invoke-direct {v2, v1, v0}, Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;-><init>(Lcom/alibaba/fastjson/serializer/ObjectSerializer;Ljava/lang/Class;)V
iput-object v2, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->runtimeInfo:Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;
:cond_2
iget-object v0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->runtimeInfo:Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;
if-nez p2, :cond_6
iget p2, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->features:I
.line 126
sget-object v1, Lcom/alibaba/fastjson/serializer/SerializerFeature;->WriteNullNumberAsZero:Lcom/alibaba/fastjson/serializer/SerializerFeature;
iget v1, v1, Lcom/alibaba/fastjson/serializer/SerializerFeature;->mask:I
and-int/2addr p2, v1
if-eqz p2, :cond_3
const-class p2, Ljava/lang/Number;
iget-object v1, v0, Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;->runtimeFieldClass:Ljava/lang/Class;
.line 127
invoke-virtual {p2, v1}, Ljava/lang/Class;->isAssignableFrom(Ljava/lang/Class;)Z
move-result p2
if-eqz p2, :cond_3
.line 128
iget-object p0, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->out:Lcom/alibaba/fastjson/serializer/SerializeWriter;
const/16 p1, 0x30
invoke-virtual {p0, p1}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->write(I)V
return-void
:cond_3
iget p2, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->features:I
.line 130
sget-object v1, Lcom/alibaba/fastjson/serializer/SerializerFeature;->WriteNullBooleanAsFalse:Lcom/alibaba/fastjson/serializer/SerializerFeature;
iget v1, v1, Lcom/alibaba/fastjson/serializer/SerializerFeature;->mask:I
and-int/2addr p2, v1
if-eqz p2, :cond_4
const-class p2, Ljava/lang/Boolean;
iget-object v1, v0, Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;->runtimeFieldClass:Ljava/lang/Class;
if-ne p2, v1, :cond_4
.line 132
iget-object p0, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->out:Lcom/alibaba/fastjson/serializer/SerializeWriter;
const-string p1, "false"
invoke-virtual {p0, p1}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->write(Ljava/lang/String;)V
return-void
:cond_4
iget p2, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->features:I
.line 134
sget-object v1, Lcom/alibaba/fastjson/serializer/SerializerFeature;->WriteNullListAsEmpty:Lcom/alibaba/fastjson/serializer/SerializerFeature;
iget v1, v1, Lcom/alibaba/fastjson/serializer/SerializerFeature;->mask:I
and-int/2addr p2, v1
if-eqz p2, :cond_5
const-class p2, Ljava/util/Collection;
iget-object v1, v0, Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;->runtimeFieldClass:Ljava/lang/Class;
.line 135
invoke-virtual {p2, v1}, Ljava/lang/Class;->isAssignableFrom(Ljava/lang/Class;)Z
move-result p2
if-eqz p2, :cond_5
.line 136
iget-object p0, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->out:Lcom/alibaba/fastjson/serializer/SerializeWriter;
const-string p1, "[]"
invoke-virtual {p0, p1}, Lcom/alibaba/fastjson/serializer/SerializeWriter;->write(Ljava/lang/String;)V
return-void
.line 140
:cond_5
iget-object p2, v0, Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;->fieldSerializer:Lcom/alibaba/fastjson/serializer/ObjectSerializer;
iget-object p0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
iget-object p0, p0, Lcom/alibaba/fastjson/util/FieldInfo;->name:Ljava/lang/String;
iget-object v0, v0, Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;->runtimeFieldClass:Ljava/lang/Class;
const/4 v1, 0x0
invoke-interface {p2, p1, v1, p0, v0}, Lcom/alibaba/fastjson/serializer/ObjectSerializer;->write(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/reflect/Type;)V
return-void
.line 144
:cond_6
invoke-virtual {p2}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
move-result-object v1
.line 145
iget-object v2, v0, Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;->runtimeFieldClass:Ljava/lang/Class;
if-ne v1, v2, :cond_7
.line 146
iget-object v0, v0, Lcom/alibaba/fastjson/serializer/FieldSerializer$RuntimeSerializerInfo;->fieldSerializer:Lcom/alibaba/fastjson/serializer/ObjectSerializer;
iget-object v1, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
iget-object v1, v1, Lcom/alibaba/fastjson/util/FieldInfo;->name:Ljava/lang/String;
iget-object p0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
iget-object p0, p0, Lcom/alibaba/fastjson/util/FieldInfo;->fieldType:Ljava/lang/reflect/Type;
invoke-interface {v0, p1, p2, v1, p0}, Lcom/alibaba/fastjson/serializer/ObjectSerializer;->write(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/reflect/Type;)V
return-void
.line 150
:cond_7
iget-object v0, p1, Lcom/alibaba/fastjson/serializer/JSONSerializer;->config:Lcom/alibaba/fastjson/serializer/SerializeConfig;
invoke-virtual {v0, v1}, Lcom/alibaba/fastjson/serializer/SerializeConfig;->get(Ljava/lang/Class;)Lcom/alibaba/fastjson/serializer/ObjectSerializer;
move-result-object v0
iget-object v1, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
.line 151
iget-object v1, v1, Lcom/alibaba/fastjson/util/FieldInfo;->name:Ljava/lang/String;
iget-object p0, p0, Lcom/alibaba/fastjson/serializer/FieldSerializer;->fieldInfo:Lcom/alibaba/fastjson/util/FieldInfo;
iget-object p0, p0, Lcom/alibaba/fastjson/util/FieldInfo;->fieldType:Ljava/lang/reflect/Type;
invoke-interface {v0, p1, p2, v1, p0}, Lcom/alibaba/fastjson/serializer/ObjectSerializer;->write(Lcom/alibaba/fastjson/serializer/JSONSerializer;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/reflect/Type;)V
return-void
.end method