FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java/src/main/java/com/jsoniter/CodegenAccess.java at master · WorkAllDayi/java · GitHub
WorkAllDayi
/
java
Public
forked from
json-iterator/java
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java
/
src
/
main
/
java
/
com
/
jsoniter
/
CodegenAccess.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
200 lines (164 loc) · 6.38 KB
Breadcrumbs
java
/
src
/
main
/
java
/
com
/
jsoniter
/
CodegenAccess.java
Copy path
File metadata and controls
200 lines (164 loc) · 6.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package
com
.
jsoniter
;
import
com
.
jsoniter
.
spi
.*;
import
java
.
io
.
IOException
;
import
java
.
util
.
Collection
;
import
java
.
util
.
List
;
// only uesd by generated code to access decoder
public
class
CodegenAccess
{
public
static
void
addMissingField
(
List
missingFields
,
long
tracker
,
long
mask
,
String
fieldName
) {
if
((
tracker
&
mask
) ==
0
) {
missingFields
.
add
(
fieldName
);
}
}
public
static
<
T
extends
Collection
>
T
reuseCollection
(
T
col
) {
col
.
clear
();
return
col
;
}
public
static
Object
existingObject
(
JsonIterator
iter
) {
return
iter
.
existingObject
;
}
public
static
Object
resetExistingObject
(
JsonIterator
iter
) {
Object
obj
=
iter
.
existingObject
;
iter
.
existingObject
=
null
;
return
obj
;
}
public
static
void
setExistingObject
(
JsonIterator
iter
,
Object
obj
) {
iter
.
existingObject
=
obj
;
}
public
final
static
boolean
nextTokenIsComma
(
final
JsonIterator
iter
)
throws
IOException
{
byte
c
=
readByte
(
iter
);
if
(
c
==
','
) {
return
true
;
}
return
nextTokenIsCommaSlowPath
(
iter
,
c
);
}
private
static
boolean
nextTokenIsCommaSlowPath
(
JsonIterator
iter
,
byte
c
)
throws
IOException
{
switch
(
c
) {
case
' '
:
case
'\n'
:
case
'\r'
:
case
'\t'
:
break
;
default
:
return
false
;
}
return
nextToken
(
iter
) ==
','
;
}
public
static
byte
nextToken
(
JsonIterator
iter
)
throws
IOException
{
return
IterImpl
.
nextToken
(
iter
);
}
public
static
final
boolean
readBoolean
(
String
cacheKey
,
JsonIterator
iter
)
throws
IOException
{
return
((
Decoder
.
BooleanDecoder
)
JsoniterSpi
.
getDecoder
(
cacheKey
)).
decodeBoolean
(
iter
);
}
public
static
final
short
readShort
(
String
cacheKey
,
JsonIterator
iter
)
throws
IOException
{
return
((
Decoder
.
ShortDecoder
)
JsoniterSpi
.
getDecoder
(
cacheKey
)).
decodeShort
(
iter
);
}
public
static
final
int
readInt
(
String
cacheKey
,
JsonIterator
iter
)
throws
IOException
{
return
((
Decoder
.
IntDecoder
)
JsoniterSpi
.
getDecoder
(
cacheKey
)).
decodeInt
(
iter
);
}
public
static
final
long
readLong
(
String
cacheKey
,
JsonIterator
iter
)
throws
IOException
{
return
((
Decoder
.
LongDecoder
)
JsoniterSpi
.
getDecoder
(
cacheKey
)).
decodeLong
(
iter
);
}
public
static
final
float
readFloat
(
String
cacheKey
,
JsonIterator
iter
)
throws
IOException
{
return
((
Decoder
.
FloatDecoder
)
JsoniterSpi
.
getDecoder
(
cacheKey
)).
decodeFloat
(
iter
);
}
public
static
final
double
readDouble
(
String
cacheKey
,
JsonIterator
iter
)
throws
IOException
{
return
((
Decoder
.
DoubleDecoder
)
JsoniterSpi
.
getDecoder
(
cacheKey
)).
decodeDouble
(
iter
);
}
public
static
final
<
T
>
T
read
(
String
cacheKey
,
JsonIterator
iter
)
throws
IOException
{
return
(
T
)
Codegen
.
getDecoder
(
cacheKey
,
null
).
decode
(
iter
);
}
public
static
boolean
readArrayStart
(
JsonIterator
iter
)
throws
IOException
{
byte
c
=
IterImpl
.
nextToken
(
iter
);
if
(
c
==
'['
) {
c
=
IterImpl
.
nextToken
(
iter
);
if
(
c
==
']'
) {
return
false
;
}
iter
.
unreadByte
();
return
true
;
}
throw
iter
.
reportError
(
"readArrayStart"
,
"expect [ or n"
);
}
public
static
boolean
readObjectStart
(
JsonIterator
iter
)
throws
IOException
{
byte
c
=
IterImpl
.
nextToken
(
iter
);
if
(
c
==
'{'
) {
c
=
IterImpl
.
nextToken
(
iter
);
if
(
c
==
'}'
) {
return
false
;
}
iter
.
unreadByte
();
return
true
;
}
throw
iter
.
reportError
(
"readObjectStart"
,
"expect { or n, found: "
+ (
char
)
c
);
}
public
static
void
reportIncompleteObject
(
JsonIterator
iter
) {
throw
iter
.
reportError
(
"genObject"
,
"expect }"
);
}
public
static
void
reportIncompleteArray
(
JsonIterator
iter
) {
throw
iter
.
reportError
(
"genArray"
,
"expect ]"
);
}
public
static
final
String
readObjectFieldAsString
(
JsonIterator
iter
)
throws
IOException
{
String
field
=
iter
.
readString
();
if
(
IterImpl
.
nextToken
(
iter
) !=
':'
) {
throw
iter
.
reportError
(
"readObjectFieldAsString"
,
"expect :"
);
}
return
field
;
}
public
static
final
int
readObjectFieldAsHash
(
JsonIterator
iter
)
throws
IOException
{
return
IterImpl
.
readObjectFieldAsHash
(
iter
);
}
public
static
final
Slice
readObjectFieldAsSlice
(
JsonIterator
iter
)
throws
IOException
{
return
IterImpl
.
readObjectFieldAsSlice
(
iter
);
}
public
static
final
Slice
readSlice
(
JsonIterator
iter
)
throws
IOException
{
return
IterImpl
.
readSlice
(
iter
);
}
public
static
final
Object
readMapKey
(
String
cacheKey
,
JsonIterator
iter
)
throws
IOException
{
Decoder
mapKeyDecoder
=
JsoniterSpi
.
getMapKeyDecoder
(
cacheKey
);
Object
key
=
mapKeyDecoder
.
decode
(
iter
);
if
(
IterImpl
.
nextToken
(
iter
) !=
':'
) {
throw
iter
.
reportError
(
"readMapKey"
,
"expect :"
);
}
return
key
;
}
final
static
boolean
skipWhitespacesWithoutLoadMore
(
JsonIterator
iter
)
throws
IOException
{
for
(
int
i
=
iter
.
head
;
i
<
iter
.
tail
;
i
++) {
byte
c
=
iter
.
buf
[
i
];
switch
(
c
) {
case
' '
:
case
'\n'
:
case
'\t'
:
case
'\r'
:
continue
;
}
iter
.
head
=
i
;
return
false
;
}
return
true
;
}
public
static
void
staticGenDecoders
(
TypeLiteral
[]
typeLiterals
,
StaticCodegenTarget
staticCodegenTarget
) {
Codegen
.
staticGenDecoders
(
typeLiterals
,
staticCodegenTarget
);
}
public
static
int
head
(
JsonIterator
iter
) {
return
iter
.
head
;
}
public
static
void
unreadByte
(
JsonIterator
iter
)
throws
IOException
{
iter
.
unreadByte
();
}
public
static
byte
readByte
(
JsonIterator
iter
)
throws
IOException
{
return
IterImpl
.
readByte
(
iter
);
}
public
static
int
calcHash
(
String
str
) {
return
CodegenImplObjectHash
.
calcHash
(
str
);
}
public
static
void
skipFixedBytes
(
JsonIterator
iter
,
int
n
)
throws
IOException
{
IterImpl
.
skipFixedBytes
(
iter
,
n
);
}
public
static
class
StaticCodegenTarget
{
public
String
outputDir
;
public
StaticCodegenTarget
(
String
outputDir
) {
this
.
outputDir
=
outputDir
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL