JsonWriter.smali 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306
  1. .class public Lcom/google/gson/stream/JsonWriter;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # interfaces
  5. .implements Ljava/io/Closeable;
  6. .implements Ljava/io/Flushable;
  7. # static fields
  8. .field private static final HTML_SAFE_REPLACEMENT_CHARS:[Ljava/lang/String;
  9. .field private static final REPLACEMENT_CHARS:[Ljava/lang/String;
  10. # instance fields
  11. .field private deferredName:Ljava/lang/String;
  12. .field private htmlSafe:Z
  13. .field private indent:Ljava/lang/String;
  14. .field private lenient:Z
  15. .field private final out:Ljava/io/Writer;
  16. .field private separator:Ljava/lang/String;
  17. .field private serializeNulls:Z
  18. .field private stack:[I
  19. .field private stackSize:I
  20. # direct methods
  21. .method static constructor <clinit>()V
  22. .locals 5
  23. const/16 v0, 0x80
  24. new-array v0, v0, [Ljava/lang/String;
  25. sput-object v0, Lcom/google/gson/stream/JsonWriter;->REPLACEMENT_CHARS:[Ljava/lang/String;
  26. const/4 v0, 0x0
  27. const/4 v1, 0x0
  28. :goto_0
  29. const/16 v2, 0x1f
  30. if-gt v1, v2, :cond_0
  31. sget-object v2, Lcom/google/gson/stream/JsonWriter;->REPLACEMENT_CHARS:[Ljava/lang/String;
  32. const/4 v3, 0x1
  33. new-array v3, v3, [Ljava/lang/Object;
  34. invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  35. move-result-object v4
  36. aput-object v4, v3, v0
  37. const-string v4, "\\u%04x"
  38. invoke-static {v4, v3}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
  39. move-result-object v3
  40. aput-object v3, v2, v1
  41. add-int/lit8 v1, v1, 0x1
  42. goto :goto_0
  43. :cond_0
  44. sget-object v0, Lcom/google/gson/stream/JsonWriter;->REPLACEMENT_CHARS:[Ljava/lang/String;
  45. const/16 v1, 0x22
  46. const-string v2, "\\\""
  47. aput-object v2, v0, v1
  48. const/16 v1, 0x5c
  49. const-string v2, "\\\\"
  50. aput-object v2, v0, v1
  51. const/16 v1, 0x9
  52. const-string v2, "\\t"
  53. aput-object v2, v0, v1
  54. const/16 v1, 0x8
  55. const-string v2, "\\b"
  56. aput-object v2, v0, v1
  57. const/16 v1, 0xa
  58. const-string v2, "\\n"
  59. aput-object v2, v0, v1
  60. const/16 v1, 0xd
  61. const-string v2, "\\r"
  62. aput-object v2, v0, v1
  63. const/16 v1, 0xc
  64. const-string v2, "\\f"
  65. aput-object v2, v0, v1
  66. invoke-virtual {v0}, [Ljava/lang/String;->clone()Ljava/lang/Object;
  67. move-result-object v0
  68. check-cast v0, [Ljava/lang/String;
  69. sput-object v0, Lcom/google/gson/stream/JsonWriter;->HTML_SAFE_REPLACEMENT_CHARS:[Ljava/lang/String;
  70. sget-object v0, Lcom/google/gson/stream/JsonWriter;->HTML_SAFE_REPLACEMENT_CHARS:[Ljava/lang/String;
  71. const/16 v1, 0x3c
  72. const-string v2, "\\u003c"
  73. aput-object v2, v0, v1
  74. const/16 v1, 0x3e
  75. const-string v2, "\\u003e"
  76. aput-object v2, v0, v1
  77. const/16 v1, 0x26
  78. const-string v2, "\\u0026"
  79. aput-object v2, v0, v1
  80. const/16 v1, 0x3d
  81. const-string v2, "\\u003d"
  82. aput-object v2, v0, v1
  83. const/16 v1, 0x27
  84. const-string v2, "\\u0027"
  85. aput-object v2, v0, v1
  86. return-void
  87. .end method
  88. .method public constructor <init>(Ljava/io/Writer;)V
  89. .locals 1
  90. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  91. const/16 v0, 0x20
  92. new-array v0, v0, [I
  93. iput-object v0, p0, Lcom/google/gson/stream/JsonWriter;->stack:[I
  94. const/4 v0, 0x0
  95. iput v0, p0, Lcom/google/gson/stream/JsonWriter;->stackSize:I
  96. const/4 v0, 0x6
  97. invoke-direct {p0, v0}, Lcom/google/gson/stream/JsonWriter;->push(I)V
  98. const-string v0, ":"
  99. iput-object v0, p0, Lcom/google/gson/stream/JsonWriter;->separator:Ljava/lang/String;
  100. const/4 v0, 0x1
  101. iput-boolean v0, p0, Lcom/google/gson/stream/JsonWriter;->serializeNulls:Z
  102. if-eqz p1, :cond_0
  103. iput-object p1, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  104. return-void
  105. :cond_0
  106. new-instance p1, Ljava/lang/NullPointerException;
  107. const-string v0, "out == null"
  108. invoke-direct {p1, v0}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
  109. throw p1
  110. .end method
  111. .method private beforeName()V
  112. .locals 2
  113. .annotation system Ldalvik/annotation/Throws;
  114. value = {
  115. Ljava/io/IOException;
  116. }
  117. .end annotation
  118. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->peek()I
  119. move-result v0
  120. const/4 v1, 0x5
  121. if-ne v0, v1, :cond_0
  122. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  123. const/16 v1, 0x2c
  124. invoke-virtual {v0, v1}, Ljava/io/Writer;->write(I)V
  125. goto :goto_0
  126. :cond_0
  127. const/4 v1, 0x3
  128. if-ne v0, v1, :cond_1
  129. :goto_0
  130. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->newline()V
  131. const/4 v0, 0x4
  132. invoke-direct {p0, v0}, Lcom/google/gson/stream/JsonWriter;->replaceTop(I)V
  133. return-void
  134. :cond_1
  135. new-instance v0, Ljava/lang/IllegalStateException;
  136. const-string v1, "Nesting problem."
  137. invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  138. throw v0
  139. .end method
  140. .method private beforeValue()V
  141. .locals 3
  142. .annotation system Ldalvik/annotation/Throws;
  143. value = {
  144. Ljava/io/IOException;
  145. }
  146. .end annotation
  147. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->peek()I
  148. move-result v0
  149. const/4 v1, 0x1
  150. const/4 v2, 0x2
  151. if-eq v0, v1, :cond_5
  152. if-eq v0, v2, :cond_4
  153. const/4 v1, 0x4
  154. if-eq v0, v1, :cond_3
  155. const/4 v1, 0x6
  156. const/4 v2, 0x7
  157. if-eq v0, v1, :cond_2
  158. if-ne v0, v2, :cond_1
  159. iget-boolean v0, p0, Lcom/google/gson/stream/JsonWriter;->lenient:Z
  160. if-eqz v0, :cond_0
  161. goto :goto_0
  162. :cond_0
  163. new-instance v0, Ljava/lang/IllegalStateException;
  164. const-string v1, "JSON must have only one top-level value."
  165. invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  166. throw v0
  167. :cond_1
  168. new-instance v0, Ljava/lang/IllegalStateException;
  169. const-string v1, "Nesting problem."
  170. invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  171. throw v0
  172. :cond_2
  173. :goto_0
  174. invoke-direct {p0, v2}, Lcom/google/gson/stream/JsonWriter;->replaceTop(I)V
  175. goto :goto_2
  176. :cond_3
  177. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  178. iget-object v1, p0, Lcom/google/gson/stream/JsonWriter;->separator:Ljava/lang/String;
  179. invoke-virtual {v0, v1}, Ljava/io/Writer;->append(Ljava/lang/CharSequence;)Ljava/io/Writer;
  180. const/4 v0, 0x5
  181. invoke-direct {p0, v0}, Lcom/google/gson/stream/JsonWriter;->replaceTop(I)V
  182. goto :goto_2
  183. :cond_4
  184. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  185. const/16 v1, 0x2c
  186. invoke-virtual {v0, v1}, Ljava/io/Writer;->append(C)Ljava/io/Writer;
  187. goto :goto_1
  188. :cond_5
  189. invoke-direct {p0, v2}, Lcom/google/gson/stream/JsonWriter;->replaceTop(I)V
  190. :goto_1
  191. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->newline()V
  192. :goto_2
  193. return-void
  194. .end method
  195. .method private close(IILjava/lang/String;)Lcom/google/gson/stream/JsonWriter;
  196. .locals 1
  197. .annotation system Ldalvik/annotation/Throws;
  198. value = {
  199. Ljava/io/IOException;
  200. }
  201. .end annotation
  202. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->peek()I
  203. move-result v0
  204. if-eq v0, p2, :cond_1
  205. if-ne v0, p1, :cond_0
  206. goto :goto_0
  207. :cond_0
  208. new-instance p1, Ljava/lang/IllegalStateException;
  209. const-string p2, "Nesting problem."
  210. invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  211. throw p1
  212. :cond_1
  213. :goto_0
  214. iget-object p1, p0, Lcom/google/gson/stream/JsonWriter;->deferredName:Ljava/lang/String;
  215. if-nez p1, :cond_3
  216. iget p1, p0, Lcom/google/gson/stream/JsonWriter;->stackSize:I
  217. add-int/lit8 p1, p1, -0x1
  218. iput p1, p0, Lcom/google/gson/stream/JsonWriter;->stackSize:I
  219. if-ne v0, p2, :cond_2
  220. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->newline()V
  221. :cond_2
  222. iget-object p1, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  223. invoke-virtual {p1, p3}, Ljava/io/Writer;->write(Ljava/lang/String;)V
  224. return-object p0
  225. :cond_3
  226. new-instance p1, Ljava/lang/IllegalStateException;
  227. new-instance p2, Ljava/lang/StringBuilder;
  228. invoke-direct {p2}, Ljava/lang/StringBuilder;-><init>()V
  229. const-string p3, "Dangling name: "
  230. invoke-virtual {p2, p3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  231. iget-object p3, p0, Lcom/google/gson/stream/JsonWriter;->deferredName:Ljava/lang/String;
  232. invoke-virtual {p2, p3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  233. invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  234. move-result-object p2
  235. invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  236. throw p1
  237. .end method
  238. .method private newline()V
  239. .locals 4
  240. .annotation system Ldalvik/annotation/Throws;
  241. value = {
  242. Ljava/io/IOException;
  243. }
  244. .end annotation
  245. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->indent:Ljava/lang/String;
  246. if-nez v0, :cond_0
  247. return-void
  248. :cond_0
  249. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  250. const-string v1, "\n"
  251. invoke-virtual {v0, v1}, Ljava/io/Writer;->write(Ljava/lang/String;)V
  252. iget v0, p0, Lcom/google/gson/stream/JsonWriter;->stackSize:I
  253. const/4 v1, 0x1
  254. :goto_0
  255. if-ge v1, v0, :cond_1
  256. iget-object v2, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  257. iget-object v3, p0, Lcom/google/gson/stream/JsonWriter;->indent:Ljava/lang/String;
  258. invoke-virtual {v2, v3}, Ljava/io/Writer;->write(Ljava/lang/String;)V
  259. add-int/lit8 v1, v1, 0x1
  260. goto :goto_0
  261. :cond_1
  262. return-void
  263. .end method
  264. .method private open(ILjava/lang/String;)Lcom/google/gson/stream/JsonWriter;
  265. .locals 0
  266. .annotation system Ldalvik/annotation/Throws;
  267. value = {
  268. Ljava/io/IOException;
  269. }
  270. .end annotation
  271. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->beforeValue()V
  272. invoke-direct {p0, p1}, Lcom/google/gson/stream/JsonWriter;->push(I)V
  273. iget-object p1, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  274. invoke-virtual {p1, p2}, Ljava/io/Writer;->write(Ljava/lang/String;)V
  275. return-object p0
  276. .end method
  277. .method private peek()I
  278. .locals 2
  279. iget v0, p0, Lcom/google/gson/stream/JsonWriter;->stackSize:I
  280. if-eqz v0, :cond_0
  281. iget-object v1, p0, Lcom/google/gson/stream/JsonWriter;->stack:[I
  282. add-int/lit8 v0, v0, -0x1
  283. aget v0, v1, v0
  284. return v0
  285. :cond_0
  286. new-instance v0, Ljava/lang/IllegalStateException;
  287. const-string v1, "JsonWriter is closed."
  288. invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  289. throw v0
  290. .end method
  291. .method private push(I)V
  292. .locals 4
  293. iget v0, p0, Lcom/google/gson/stream/JsonWriter;->stackSize:I
  294. iget-object v1, p0, Lcom/google/gson/stream/JsonWriter;->stack:[I
  295. array-length v2, v1
  296. if-ne v0, v2, :cond_0
  297. mul-int/lit8 v2, v0, 0x2
  298. new-array v2, v2, [I
  299. const/4 v3, 0x0
  300. invoke-static {v1, v3, v2, v3, v0}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
  301. iput-object v2, p0, Lcom/google/gson/stream/JsonWriter;->stack:[I
  302. :cond_0
  303. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->stack:[I
  304. iget v1, p0, Lcom/google/gson/stream/JsonWriter;->stackSize:I
  305. add-int/lit8 v2, v1, 0x1
  306. iput v2, p0, Lcom/google/gson/stream/JsonWriter;->stackSize:I
  307. aput p1, v0, v1
  308. return-void
  309. .end method
  310. .method private replaceTop(I)V
  311. .locals 2
  312. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->stack:[I
  313. iget v1, p0, Lcom/google/gson/stream/JsonWriter;->stackSize:I
  314. add-int/lit8 v1, v1, -0x1
  315. aput p1, v0, v1
  316. return-void
  317. .end method
  318. .method private string(Ljava/lang/String;)V
  319. .locals 8
  320. .annotation system Ldalvik/annotation/Throws;
  321. value = {
  322. Ljava/io/IOException;
  323. }
  324. .end annotation
  325. iget-boolean v0, p0, Lcom/google/gson/stream/JsonWriter;->htmlSafe:Z
  326. if-eqz v0, :cond_0
  327. sget-object v0, Lcom/google/gson/stream/JsonWriter;->HTML_SAFE_REPLACEMENT_CHARS:[Ljava/lang/String;
  328. goto :goto_0
  329. :cond_0
  330. sget-object v0, Lcom/google/gson/stream/JsonWriter;->REPLACEMENT_CHARS:[Ljava/lang/String;
  331. :goto_0
  332. iget-object v1, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  333. const-string v2, "\""
  334. invoke-virtual {v1, v2}, Ljava/io/Writer;->write(Ljava/lang/String;)V
  335. invoke-virtual {p1}, Ljava/lang/String;->length()I
  336. move-result v1
  337. const/4 v3, 0x0
  338. const/4 v4, 0x0
  339. :goto_1
  340. if-ge v3, v1, :cond_6
  341. invoke-virtual {p1, v3}, Ljava/lang/String;->charAt(I)C
  342. move-result v5
  343. const/16 v6, 0x80
  344. if-ge v5, v6, :cond_1
  345. aget-object v5, v0, v5
  346. if-nez v5, :cond_3
  347. goto :goto_3
  348. :cond_1
  349. const/16 v6, 0x2028
  350. if-ne v5, v6, :cond_2
  351. const-string v5, "\\u2028"
  352. goto :goto_2
  353. :cond_2
  354. const/16 v6, 0x2029
  355. if-ne v5, v6, :cond_5
  356. const-string v5, "\\u2029"
  357. :cond_3
  358. :goto_2
  359. if-ge v4, v3, :cond_4
  360. iget-object v6, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  361. sub-int v7, v3, v4
  362. invoke-virtual {v6, p1, v4, v7}, Ljava/io/Writer;->write(Ljava/lang/String;II)V
  363. :cond_4
  364. iget-object v4, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  365. invoke-virtual {v4, v5}, Ljava/io/Writer;->write(Ljava/lang/String;)V
  366. add-int/lit8 v4, v3, 0x1
  367. :cond_5
  368. :goto_3
  369. add-int/lit8 v3, v3, 0x1
  370. goto :goto_1
  371. :cond_6
  372. if-ge v4, v1, :cond_7
  373. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  374. sub-int/2addr v1, v4
  375. invoke-virtual {v0, p1, v4, v1}, Ljava/io/Writer;->write(Ljava/lang/String;II)V
  376. :cond_7
  377. iget-object p1, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  378. invoke-virtual {p1, v2}, Ljava/io/Writer;->write(Ljava/lang/String;)V
  379. return-void
  380. .end method
  381. .method private writeDeferredName()V
  382. .locals 1
  383. .annotation system Ldalvik/annotation/Throws;
  384. value = {
  385. Ljava/io/IOException;
  386. }
  387. .end annotation
  388. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->deferredName:Ljava/lang/String;
  389. if-eqz v0, :cond_0
  390. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->beforeName()V
  391. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->deferredName:Ljava/lang/String;
  392. invoke-direct {p0, v0}, Lcom/google/gson/stream/JsonWriter;->string(Ljava/lang/String;)V
  393. const/4 v0, 0x0
  394. iput-object v0, p0, Lcom/google/gson/stream/JsonWriter;->deferredName:Ljava/lang/String;
  395. :cond_0
  396. return-void
  397. .end method
  398. # virtual methods
  399. .method public beginArray()Lcom/google/gson/stream/JsonWriter;
  400. .locals 2
  401. .annotation system Ldalvik/annotation/Throws;
  402. value = {
  403. Ljava/io/IOException;
  404. }
  405. .end annotation
  406. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->writeDeferredName()V
  407. const/4 v0, 0x1
  408. const-string v1, "["
  409. invoke-direct {p0, v0, v1}, Lcom/google/gson/stream/JsonWriter;->open(ILjava/lang/String;)Lcom/google/gson/stream/JsonWriter;
  410. move-result-object v0
  411. return-object v0
  412. .end method
  413. .method public beginObject()Lcom/google/gson/stream/JsonWriter;
  414. .locals 2
  415. .annotation system Ldalvik/annotation/Throws;
  416. value = {
  417. Ljava/io/IOException;
  418. }
  419. .end annotation
  420. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->writeDeferredName()V
  421. const/4 v0, 0x3
  422. const-string v1, "{"
  423. invoke-direct {p0, v0, v1}, Lcom/google/gson/stream/JsonWriter;->open(ILjava/lang/String;)Lcom/google/gson/stream/JsonWriter;
  424. move-result-object v0
  425. return-object v0
  426. .end method
  427. .method public close()V
  428. .locals 3
  429. .annotation system Ldalvik/annotation/Throws;
  430. value = {
  431. Ljava/io/IOException;
  432. }
  433. .end annotation
  434. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  435. invoke-virtual {v0}, Ljava/io/Writer;->close()V
  436. iget v0, p0, Lcom/google/gson/stream/JsonWriter;->stackSize:I
  437. const/4 v1, 0x1
  438. if-gt v0, v1, :cond_1
  439. if-ne v0, v1, :cond_0
  440. iget-object v2, p0, Lcom/google/gson/stream/JsonWriter;->stack:[I
  441. sub-int/2addr v0, v1
  442. aget v0, v2, v0
  443. const/4 v1, 0x7
  444. if-ne v0, v1, :cond_1
  445. :cond_0
  446. const/4 v0, 0x0
  447. iput v0, p0, Lcom/google/gson/stream/JsonWriter;->stackSize:I
  448. return-void
  449. :cond_1
  450. new-instance v0, Ljava/io/IOException;
  451. const-string v1, "Incomplete document"
  452. invoke-direct {v0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
  453. throw v0
  454. .end method
  455. .method public endArray()Lcom/google/gson/stream/JsonWriter;
  456. .locals 3
  457. .annotation system Ldalvik/annotation/Throws;
  458. value = {
  459. Ljava/io/IOException;
  460. }
  461. .end annotation
  462. const/4 v0, 0x1
  463. const/4 v1, 0x2
  464. const-string v2, "]"
  465. invoke-direct {p0, v0, v1, v2}, Lcom/google/gson/stream/JsonWriter;->close(IILjava/lang/String;)Lcom/google/gson/stream/JsonWriter;
  466. move-result-object v0
  467. return-object v0
  468. .end method
  469. .method public endObject()Lcom/google/gson/stream/JsonWriter;
  470. .locals 3
  471. .annotation system Ldalvik/annotation/Throws;
  472. value = {
  473. Ljava/io/IOException;
  474. }
  475. .end annotation
  476. const/4 v0, 0x3
  477. const/4 v1, 0x5
  478. const-string v2, "}"
  479. invoke-direct {p0, v0, v1, v2}, Lcom/google/gson/stream/JsonWriter;->close(IILjava/lang/String;)Lcom/google/gson/stream/JsonWriter;
  480. move-result-object v0
  481. return-object v0
  482. .end method
  483. .method public flush()V
  484. .locals 2
  485. .annotation system Ldalvik/annotation/Throws;
  486. value = {
  487. Ljava/io/IOException;
  488. }
  489. .end annotation
  490. iget v0, p0, Lcom/google/gson/stream/JsonWriter;->stackSize:I
  491. if-eqz v0, :cond_0
  492. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  493. invoke-virtual {v0}, Ljava/io/Writer;->flush()V
  494. return-void
  495. :cond_0
  496. new-instance v0, Ljava/lang/IllegalStateException;
  497. const-string v1, "JsonWriter is closed."
  498. invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  499. throw v0
  500. .end method
  501. .method public final getSerializeNulls()Z
  502. .locals 1
  503. iget-boolean v0, p0, Lcom/google/gson/stream/JsonWriter;->serializeNulls:Z
  504. return v0
  505. .end method
  506. .method public final isHtmlSafe()Z
  507. .locals 1
  508. iget-boolean v0, p0, Lcom/google/gson/stream/JsonWriter;->htmlSafe:Z
  509. return v0
  510. .end method
  511. .method public isLenient()Z
  512. .locals 1
  513. iget-boolean v0, p0, Lcom/google/gson/stream/JsonWriter;->lenient:Z
  514. return v0
  515. .end method
  516. .method public jsonValue(Ljava/lang/String;)Lcom/google/gson/stream/JsonWriter;
  517. .locals 1
  518. .annotation system Ldalvik/annotation/Throws;
  519. value = {
  520. Ljava/io/IOException;
  521. }
  522. .end annotation
  523. if-nez p1, :cond_0
  524. invoke-virtual {p0}, Lcom/google/gson/stream/JsonWriter;->nullValue()Lcom/google/gson/stream/JsonWriter;
  525. move-result-object p1
  526. return-object p1
  527. :cond_0
  528. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->writeDeferredName()V
  529. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->beforeValue()V
  530. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  531. invoke-virtual {v0, p1}, Ljava/io/Writer;->append(Ljava/lang/CharSequence;)Ljava/io/Writer;
  532. return-object p0
  533. .end method
  534. .method public name(Ljava/lang/String;)Lcom/google/gson/stream/JsonWriter;
  535. .locals 1
  536. .annotation system Ldalvik/annotation/Throws;
  537. value = {
  538. Ljava/io/IOException;
  539. }
  540. .end annotation
  541. if-eqz p1, :cond_2
  542. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->deferredName:Ljava/lang/String;
  543. if-nez v0, :cond_1
  544. iget v0, p0, Lcom/google/gson/stream/JsonWriter;->stackSize:I
  545. if-eqz v0, :cond_0
  546. iput-object p1, p0, Lcom/google/gson/stream/JsonWriter;->deferredName:Ljava/lang/String;
  547. return-object p0
  548. :cond_0
  549. new-instance p1, Ljava/lang/IllegalStateException;
  550. const-string v0, "JsonWriter is closed."
  551. invoke-direct {p1, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  552. throw p1
  553. :cond_1
  554. new-instance p1, Ljava/lang/IllegalStateException;
  555. invoke-direct {p1}, Ljava/lang/IllegalStateException;-><init>()V
  556. throw p1
  557. :cond_2
  558. new-instance p1, Ljava/lang/NullPointerException;
  559. const-string v0, "name == null"
  560. invoke-direct {p1, v0}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
  561. throw p1
  562. .end method
  563. .method public nullValue()Lcom/google/gson/stream/JsonWriter;
  564. .locals 2
  565. .annotation system Ldalvik/annotation/Throws;
  566. value = {
  567. Ljava/io/IOException;
  568. }
  569. .end annotation
  570. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->deferredName:Ljava/lang/String;
  571. if-eqz v0, :cond_1
  572. iget-boolean v0, p0, Lcom/google/gson/stream/JsonWriter;->serializeNulls:Z
  573. if-eqz v0, :cond_0
  574. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->writeDeferredName()V
  575. goto :goto_0
  576. :cond_0
  577. const/4 v0, 0x0
  578. iput-object v0, p0, Lcom/google/gson/stream/JsonWriter;->deferredName:Ljava/lang/String;
  579. return-object p0
  580. :cond_1
  581. :goto_0
  582. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->beforeValue()V
  583. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  584. const-string v1, "null"
  585. invoke-virtual {v0, v1}, Ljava/io/Writer;->write(Ljava/lang/String;)V
  586. return-object p0
  587. .end method
  588. .method public final setHtmlSafe(Z)V
  589. .locals 0
  590. iput-boolean p1, p0, Lcom/google/gson/stream/JsonWriter;->htmlSafe:Z
  591. return-void
  592. .end method
  593. .method public final setIndent(Ljava/lang/String;)V
  594. .locals 1
  595. invoke-virtual {p1}, Ljava/lang/String;->length()I
  596. move-result v0
  597. if-nez v0, :cond_0
  598. const/4 p1, 0x0
  599. iput-object p1, p0, Lcom/google/gson/stream/JsonWriter;->indent:Ljava/lang/String;
  600. const-string p1, ":"
  601. goto :goto_0
  602. :cond_0
  603. iput-object p1, p0, Lcom/google/gson/stream/JsonWriter;->indent:Ljava/lang/String;
  604. const-string p1, ": "
  605. :goto_0
  606. iput-object p1, p0, Lcom/google/gson/stream/JsonWriter;->separator:Ljava/lang/String;
  607. return-void
  608. .end method
  609. .method public final setLenient(Z)V
  610. .locals 0
  611. iput-boolean p1, p0, Lcom/google/gson/stream/JsonWriter;->lenient:Z
  612. return-void
  613. .end method
  614. .method public final setSerializeNulls(Z)V
  615. .locals 0
  616. iput-boolean p1, p0, Lcom/google/gson/stream/JsonWriter;->serializeNulls:Z
  617. return-void
  618. .end method
  619. .method public value(D)Lcom/google/gson/stream/JsonWriter;
  620. .locals 3
  621. .annotation system Ldalvik/annotation/Throws;
  622. value = {
  623. Ljava/io/IOException;
  624. }
  625. .end annotation
  626. invoke-static {p1, p2}, Ljava/lang/Double;->isNaN(D)Z
  627. move-result v0
  628. if-nez v0, :cond_0
  629. invoke-static {p1, p2}, Ljava/lang/Double;->isInfinite(D)Z
  630. move-result v0
  631. if-nez v0, :cond_0
  632. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->writeDeferredName()V
  633. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->beforeValue()V
  634. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  635. invoke-static {p1, p2}, Ljava/lang/Double;->toString(D)Ljava/lang/String;
  636. move-result-object p1
  637. invoke-virtual {v0, p1}, Ljava/io/Writer;->append(Ljava/lang/CharSequence;)Ljava/io/Writer;
  638. return-object p0
  639. :cond_0
  640. new-instance v0, Ljava/lang/IllegalArgumentException;
  641. new-instance v1, Ljava/lang/StringBuilder;
  642. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  643. const-string v2, "Numeric values must be finite, but was "
  644. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  645. invoke-virtual {v1, p1, p2}, Ljava/lang/StringBuilder;->append(D)Ljava/lang/StringBuilder;
  646. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  647. move-result-object p1
  648. invoke-direct {v0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  649. throw v0
  650. .end method
  651. .method public value(J)Lcom/google/gson/stream/JsonWriter;
  652. .locals 1
  653. .annotation system Ldalvik/annotation/Throws;
  654. value = {
  655. Ljava/io/IOException;
  656. }
  657. .end annotation
  658. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->writeDeferredName()V
  659. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->beforeValue()V
  660. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  661. invoke-static {p1, p2}, Ljava/lang/Long;->toString(J)Ljava/lang/String;
  662. move-result-object p1
  663. invoke-virtual {v0, p1}, Ljava/io/Writer;->write(Ljava/lang/String;)V
  664. return-object p0
  665. .end method
  666. .method public value(Ljava/lang/Boolean;)Lcom/google/gson/stream/JsonWriter;
  667. .locals 1
  668. .annotation system Ldalvik/annotation/Throws;
  669. value = {
  670. Ljava/io/IOException;
  671. }
  672. .end annotation
  673. if-nez p1, :cond_0
  674. invoke-virtual {p0}, Lcom/google/gson/stream/JsonWriter;->nullValue()Lcom/google/gson/stream/JsonWriter;
  675. move-result-object p1
  676. return-object p1
  677. :cond_0
  678. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->writeDeferredName()V
  679. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->beforeValue()V
  680. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  681. invoke-virtual {p1}, Ljava/lang/Boolean;->booleanValue()Z
  682. move-result p1
  683. if-eqz p1, :cond_1
  684. const-string p1, "true"
  685. goto :goto_0
  686. :cond_1
  687. const-string p1, "false"
  688. :goto_0
  689. invoke-virtual {v0, p1}, Ljava/io/Writer;->write(Ljava/lang/String;)V
  690. return-object p0
  691. .end method
  692. .method public value(Ljava/lang/Number;)Lcom/google/gson/stream/JsonWriter;
  693. .locals 3
  694. .annotation system Ldalvik/annotation/Throws;
  695. value = {
  696. Ljava/io/IOException;
  697. }
  698. .end annotation
  699. if-nez p1, :cond_0
  700. invoke-virtual {p0}, Lcom/google/gson/stream/JsonWriter;->nullValue()Lcom/google/gson/stream/JsonWriter;
  701. move-result-object p1
  702. return-object p1
  703. :cond_0
  704. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->writeDeferredName()V
  705. invoke-virtual {p1}, Ljava/lang/Object;->toString()Ljava/lang/String;
  706. move-result-object v0
  707. iget-boolean v1, p0, Lcom/google/gson/stream/JsonWriter;->lenient:Z
  708. if-nez v1, :cond_2
  709. const-string v1, "-Infinity"
  710. invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
  711. move-result v1
  712. if-nez v1, :cond_1
  713. const-string v1, "Infinity"
  714. invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
  715. move-result v1
  716. if-nez v1, :cond_1
  717. const-string v1, "NaN"
  718. invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
  719. move-result v1
  720. if-nez v1, :cond_1
  721. goto :goto_0
  722. :cond_1
  723. new-instance v0, Ljava/lang/IllegalArgumentException;
  724. new-instance v1, Ljava/lang/StringBuilder;
  725. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  726. const-string v2, "Numeric values must be finite, but was "
  727. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  728. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
  729. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  730. move-result-object p1
  731. invoke-direct {v0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  732. throw v0
  733. :cond_2
  734. :goto_0
  735. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->beforeValue()V
  736. iget-object p1, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  737. invoke-virtual {p1, v0}, Ljava/io/Writer;->append(Ljava/lang/CharSequence;)Ljava/io/Writer;
  738. return-object p0
  739. .end method
  740. .method public value(Ljava/lang/String;)Lcom/google/gson/stream/JsonWriter;
  741. .locals 0
  742. .annotation system Ldalvik/annotation/Throws;
  743. value = {
  744. Ljava/io/IOException;
  745. }
  746. .end annotation
  747. if-nez p1, :cond_0
  748. invoke-virtual {p0}, Lcom/google/gson/stream/JsonWriter;->nullValue()Lcom/google/gson/stream/JsonWriter;
  749. move-result-object p1
  750. return-object p1
  751. :cond_0
  752. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->writeDeferredName()V
  753. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->beforeValue()V
  754. invoke-direct {p0, p1}, Lcom/google/gson/stream/JsonWriter;->string(Ljava/lang/String;)V
  755. return-object p0
  756. .end method
  757. .method public value(Z)Lcom/google/gson/stream/JsonWriter;
  758. .locals 1
  759. .annotation system Ldalvik/annotation/Throws;
  760. value = {
  761. Ljava/io/IOException;
  762. }
  763. .end annotation
  764. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->writeDeferredName()V
  765. invoke-direct {p0}, Lcom/google/gson/stream/JsonWriter;->beforeValue()V
  766. iget-object v0, p0, Lcom/google/gson/stream/JsonWriter;->out:Ljava/io/Writer;
  767. if-eqz p1, :cond_0
  768. const-string p1, "true"
  769. goto :goto_0
  770. :cond_0
  771. const-string p1, "false"
  772. :goto_0
  773. invoke-virtual {v0, p1}, Ljava/io/Writer;->write(Ljava/lang/String;)V
  774. return-object p0
  775. .end method