-
Notifications
You must be signed in to change notification settings - Fork 6.5k
/
ImageGenDecoder.java
181 lines (151 loc) · 5.82 KB
/
ImageGenDecoder.java
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
package data.media;
import java.lang.reflect.Type;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.JSONLexerBase;
import com.alibaba.fastjson.parser.ParseContext;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
public class ImageGenDecoder extends JavaBeanDeserializer implements ObjectDeserializer {
private char[] size_gen_prefix__ = "\"size\":".toCharArray();
private char[] uri_gen_prefix__ = "\"uri\":".toCharArray();
private char[] title_gen_prefix__ = "\"title\":".toCharArray();
private char[] width_gen_prefix__ = "\"width\":".toCharArray();
private char[] height_gen_prefix__ = "\"height\":".toCharArray();
private ObjectDeserializer uri_gen_deser__;
private ObjectDeserializer title_gen_deser__;
public ImageGenDecoder (ParserConfig config, Class clazz) {
super(config, clazz);
}
public Object createInstance(DefaultJSONParser parser, Type type) {
return new Image();
}
public Object deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexerBase lexer = (JSONLexerBase) parser.getLexer();
if (!lexer.isEnabled(Feature.SortFeidFastMatch)) {
return super.deserialze(parser, type, fieldName);
}
if (lexer.isEnabled(Feature.SupportArrayToBean)) {
// deserialzeArrayMapping
}
if (lexer.scanType("Department") == JSONLexerBase.NOT_MATCH) {
return super.deserialze(parser, type, fieldName);
}
ParseContext mark_context = parser.getContext();
int matchedCount = 0;
Image instance = new Image();
ParseContext context = parser.getContext();
ParseContext childContext = parser.setContext(context, instance, fieldName);
if (lexer.matchStat == JSONLexerBase.END) {
return instance;
}
int matchStat = 0;
int _asm_flag_0 = 0;
int height_gen = 0;
data.media.Image.Size size_gen = null;
String title_gen;
if (lexer.isEnabled(Feature.InitStringFieldAsEmpty)) {
title_gen = lexer.stringDefaultValue();
_asm_flag_0 |= 4;
} else {
title_gen = null;
}
String uri_gen;
if (lexer.isEnabled(Feature.InitStringFieldAsEmpty)) {
uri_gen = lexer.stringDefaultValue();
_asm_flag_0 |= 8;
} else {
uri_gen = null;
}
int width_gen = 0;
boolean endFlag = false, restFlag = false;
if ((!endFlag) && (!restFlag)) {
height_gen = lexer.scanFieldInt(height_gen_prefix__);
if(lexer.matchStat > 0) {
_asm_flag_0 |= 1;
matchedCount++;
}
if(lexer.matchStat == JSONLexerBase.NOT_MATCH) {
restFlag = true;
}
if(lexer.matchStat == JSONLexerBase.END) {
endFlag = true;
}
}
if ((!endFlag) && (!restFlag)) {
String size_gen_enum_name = lexer.scanFieldSymbol(size_gen_prefix__, parser.getSymbolTable());
if (size_gen_enum_name == null) {
size_gen = data.media.Image.Size.valueOf(size_gen_enum_name);
}
if(lexer.matchStat > 0) {
_asm_flag_0 |= 2;
matchedCount++;
}
if(lexer.matchStat == JSONLexerBase.NOT_MATCH) {
restFlag = true;
}
if(lexer.matchStat == JSONLexerBase.END) {
endFlag = true;
}
}
if ((!endFlag) && (!restFlag)) {
title_gen = lexer.scanFieldString(title_gen_prefix__);
if(lexer.matchStat > 0) {
_asm_flag_0 |= 4;
matchedCount++;
}
if(lexer.matchStat == JSONLexerBase.NOT_MATCH) {
restFlag = true;
}
if(lexer.matchStat == JSONLexerBase.END) {
endFlag = true;
}
}
if ((!endFlag) && (!restFlag)) {
uri_gen = lexer.scanFieldString(uri_gen_prefix__);
if(lexer.matchStat > 0) {
_asm_flag_0 |= 8;
matchedCount++;
}
if(lexer.matchStat == JSONLexerBase.NOT_MATCH) {
restFlag = true;
}
if(lexer.matchStat == JSONLexerBase.END) {
endFlag = true;
}
}
if ((!endFlag) && (!restFlag)) {
width_gen = lexer.scanFieldInt(width_gen_prefix__);
if(lexer.matchStat > 0) {
_asm_flag_0 |= 16;
matchedCount++;
}
if(lexer.matchStat == JSONLexerBase.NOT_MATCH) {
restFlag = true;
}
if(lexer.matchStat != JSONLexerBase.END) {
restFlag = true;
}
}
if ((_asm_flag_0 & 1) != 0) {
instance.setHeight(height_gen);
}
if ((_asm_flag_0 & 2) != 0) {
instance.setSize(size_gen);
}
if ((_asm_flag_0 & 4) != 0) {
instance.setTitle(title_gen);
}
if ((_asm_flag_0 & 8) != 0) {
instance.setUri(uri_gen);
}
if ((_asm_flag_0 & 16) != 0) {
instance.setWidth(width_gen);
}
if (restFlag) {
return super.parseRest(parser, type, fieldName, instance);
}
return instance;
}
}