PageRenderTime 75ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/QingTingFanBianYi/src/com/alibaba/fastjson/serializer/SerializeWriter.java

https://gitlab.com/qt-prometheus/qt-prometheus
Java | 2016 lines | 2003 code | 13 blank | 0 comment | 118 complexity | bb4a8551449d3a43ad1c9dc9937810f1 MD5 | raw file
  1. package com.alibaba.fastjson.serializer;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONException;
  4. import com.alibaba.fastjson.parser.CharTypes;
  5. import com.alibaba.fastjson.util.Base64;
  6. import com.alibaba.fastjson.util.IOUtils;
  7. import java.io.IOException;
  8. import java.io.OutputStream;
  9. import java.io.Writer;
  10. import java.lang.ref.SoftReference;
  11. import java.math.BigDecimal;
  12. import java.nio.charset.Charset;
  13. public final class SerializeWriter extends Writer
  14. {
  15. private static final ThreadLocal<SoftReference<char[]>> bufLocal = new ThreadLocal();
  16. protected char[] buf;
  17. protected int count;
  18. private int features;
  19. private final Writer writer;
  20. public SerializeWriter()
  21. {
  22. this((Writer)null);
  23. }
  24. public SerializeWriter(int paramInt)
  25. {
  26. this(null, paramInt);
  27. }
  28. public SerializeWriter(Writer paramWriter)
  29. {
  30. this.writer = paramWriter;
  31. this.features = JSON.DEFAULT_GENERATE_FEATURE;
  32. paramWriter = (SoftReference)bufLocal.get();
  33. if (paramWriter != null)
  34. {
  35. this.buf = ((char[])paramWriter.get());
  36. bufLocal.set(null);
  37. }
  38. if (this.buf == null)
  39. this.buf = new char[1024];
  40. }
  41. public SerializeWriter(Writer paramWriter, int paramInt)
  42. {
  43. this.writer = paramWriter;
  44. if (paramInt <= 0)
  45. throw new IllegalArgumentException("Negative initial size: " + paramInt);
  46. this.buf = new char[paramInt];
  47. }
  48. public SerializeWriter(Writer paramWriter, SerializerFeature[] paramArrayOfSerializerFeature)
  49. {
  50. this.writer = paramWriter;
  51. paramWriter = (SoftReference)bufLocal.get();
  52. if (paramWriter != null)
  53. {
  54. this.buf = ((char[])paramWriter.get());
  55. bufLocal.set(null);
  56. }
  57. if (this.buf == null)
  58. this.buf = new char[1024];
  59. int j = 0;
  60. int k = paramArrayOfSerializerFeature.length;
  61. int i = 0;
  62. while (i < k)
  63. {
  64. j |= paramArrayOfSerializerFeature[i].getMask();
  65. i += 1;
  66. }
  67. this.features = j;
  68. }
  69. public SerializeWriter(SerializerFeature[] paramArrayOfSerializerFeature)
  70. {
  71. this(null, paramArrayOfSerializerFeature);
  72. }
  73. static final boolean isSpecial(char paramChar, int paramInt)
  74. {
  75. if (paramChar == ' ');
  76. do
  77. {
  78. return false;
  79. if ((paramChar == '/') && (SerializerFeature.isEnabled(paramInt, SerializerFeature.WriteSlashAsSpecial)))
  80. return true;
  81. }
  82. while (((paramChar > '#') && (paramChar != '\\')) || ((paramChar > '\r') && (paramChar != '\\') && (paramChar != '"')));
  83. return true;
  84. }
  85. private void writeFieldValueStringWithDoubleQuote(char paramChar, String paramString1, String paramString2, boolean paramBoolean)
  86. {
  87. int k = paramString1.length();
  88. int i = this.count;
  89. int j;
  90. if (paramString2 == null)
  91. {
  92. j = 4;
  93. i += k + 8;
  94. }
  95. while (i > this.buf.length)
  96. if (this.writer != null)
  97. {
  98. write(paramChar);
  99. writeStringWithDoubleQuote(paramString1, ':', paramBoolean);
  100. writeStringWithDoubleQuote(paramString2, '\000', paramBoolean);
  101. return;
  102. j = paramString2.length();
  103. i += k + j + 6;
  104. }
  105. else
  106. {
  107. expandCapacity(i);
  108. }
  109. this.buf[this.count] = paramChar;
  110. int m = this.count + 2;
  111. int n = m + k;
  112. this.buf[(this.count + 1)] = '"';
  113. paramString1.getChars(0, k, this.buf, m);
  114. this.count = i;
  115. this.buf[n] = '"';
  116. m = n + 1;
  117. paramString1 = this.buf;
  118. k = m + 1;
  119. paramString1[m] = 58;
  120. if (paramString2 == null)
  121. {
  122. paramString1 = this.buf;
  123. i = k + 1;
  124. paramString1[k] = 110;
  125. paramString1 = this.buf;
  126. j = i + 1;
  127. paramString1[i] = 117;
  128. paramString1 = this.buf;
  129. i = j + 1;
  130. paramString1[j] = 108;
  131. this.buf[i] = 'l';
  132. return;
  133. }
  134. paramString1 = this.buf;
  135. int i5 = k + 1;
  136. paramString1[k] = 34;
  137. int i6 = i5 + j;
  138. paramString2.getChars(0, j, this.buf, i5);
  139. int i1;
  140. int i2;
  141. if ((paramBoolean) && (!isEnabled(SerializerFeature.DisableCheckSpecialChar)))
  142. {
  143. i1 = 0;
  144. i2 = -1;
  145. k = -1;
  146. m = 0;
  147. j = i5;
  148. int i4 = i;
  149. i = j;
  150. j = k;
  151. if (i < i6)
  152. {
  153. paramChar = this.buf[i];
  154. k = j;
  155. int i3 = i4;
  156. n = i1;
  157. int i7;
  158. if (paramChar == '
')
  159. {
  160. i7 = i1 + 1;
  161. i1 = i;
  162. int i8 = paramChar;
  163. i4 += 4;
  164. k = j;
  165. m = i8;
  166. i2 = i1;
  167. i3 = i4;
  168. n = i7;
  169. if (j == -1)
  170. {
  171. k = i;
  172. n = i7;
  173. i3 = i4;
  174. i2 = i1;
  175. m = i8;
  176. }
  177. }
  178. if (paramChar >= ']')
  179. {
  180. i1 = n;
  181. j = k;
  182. }
  183. while (true)
  184. {
  185. i += 1;
  186. i4 = i3;
  187. break;
  188. j = k;
  189. i1 = n;
  190. if (isSpecial(paramChar, this.features))
  191. {
  192. i4 = n + 1;
  193. n = i;
  194. i7 = paramChar;
  195. j = k;
  196. m = i7;
  197. i2 = n;
  198. i1 = i4;
  199. if (k == -1)
  200. {
  201. j = i;
  202. m = i7;
  203. i2 = n;
  204. i1 = i4;
  205. }
  206. }
  207. }
  208. }
  209. if (i1 > 0)
  210. {
  211. i = i4 + i1;
  212. if (i > this.buf.length)
  213. expandCapacity(i);
  214. this.count = i;
  215. if (i1 != 1)
  216. break label760;
  217. if (m != 8232)
  218. break label707;
  219. System.arraycopy(this.buf, i2 + 1, this.buf, i2 + 6, i6 - i2 - 1);
  220. this.buf[i2] = '\\';
  221. paramString1 = this.buf;
  222. i = i2 + 1;
  223. paramString1[i] = 117;
  224. paramString1 = this.buf;
  225. i += 1;
  226. paramString1[i] = 50;
  227. paramString1 = this.buf;
  228. i += 1;
  229. paramString1[i] = 48;
  230. paramString1 = this.buf;
  231. i += 1;
  232. paramString1[i] = 50;
  233. this.buf[(i + 1)] = '8';
  234. }
  235. }
  236. label707: label760:
  237. while (i1 <= 1)
  238. while (true)
  239. {
  240. this.buf[(this.count - 1)] = '"';
  241. return;
  242. System.arraycopy(this.buf, i2 + 1, this.buf, i2 + 2, i6 - i2 - 1);
  243. this.buf[i2] = '\\';
  244. this.buf[(i2 + 1)] = CharTypes.replaceChars[m];
  245. }
  246. i = j;
  247. j -= i5;
  248. k = i6;
  249. label781: if (j < paramString2.length())
  250. {
  251. paramChar = paramString2.charAt(j);
  252. if (((paramChar >= CharTypes.specicalFlags_doubleQuotes.length) || (CharTypes.specicalFlags_doubleQuotes[paramChar] == 0)) && ((paramChar != '/') || (!isEnabled(SerializerFeature.WriteSlashAsSpecial))))
  253. break label881;
  254. paramString1 = this.buf;
  255. m = i + 1;
  256. paramString1[i] = 92;
  257. paramString1 = this.buf;
  258. i = m + 1;
  259. paramString1[m] = CharTypes.replaceChars[paramChar];
  260. k += 1;
  261. }
  262. while (true)
  263. {
  264. j += 1;
  265. break label781;
  266. break;
  267. label881: this.buf[i] = paramChar;
  268. i += 1;
  269. }
  270. }
  271. private void writeKeyWithDoubleQuoteIfHasSpecial(String paramString)
  272. {
  273. boolean[] arrayOfBoolean = CharTypes.specicalFlags_doubleQuotes;
  274. int n = paramString.length();
  275. int i4 = this.count + n + 1;
  276. int m;
  277. int k;
  278. if (i4 > this.buf.length)
  279. {
  280. if (this.writer != null)
  281. {
  282. if (n == 0)
  283. {
  284. write('"');
  285. write('"');
  286. write(':');
  287. return;
  288. }
  289. m = 0;
  290. k = 0;
  291. j = m;
  292. label118: int i;
  293. if (k < n)
  294. {
  295. j = paramString.charAt(k);
  296. if ((j < arrayOfBoolean.length) && (arrayOfBoolean[j] != 0))
  297. j = 1;
  298. }
  299. else
  300. {
  301. if (j != 0)
  302. write('"');
  303. k = 0;
  304. if (k >= n)
  305. break label185;
  306. i = paramString.charAt(k);
  307. if ((i >= arrayOfBoolean.length) || (arrayOfBoolean[i] == 0))
  308. break label177;
  309. write('\\');
  310. write(CharTypes.replaceChars[i]);
  311. }
  312. while (true)
  313. {
  314. k += 1;
  315. break label118;
  316. k += 1;
  317. break;
  318. label177: write(i);
  319. }
  320. label185: if (j != 0)
  321. write('"');
  322. write(':');
  323. return;
  324. }
  325. expandCapacity(i4);
  326. }
  327. if (n == 0)
  328. {
  329. if (this.count + 3 > this.buf.length)
  330. expandCapacity(this.count + 3);
  331. paramString = this.buf;
  332. j = this.count;
  333. this.count = (j + 1);
  334. paramString[j] = 34;
  335. paramString = this.buf;
  336. j = this.count;
  337. this.count = (j + 1);
  338. paramString[j] = 34;
  339. paramString = this.buf;
  340. j = this.count;
  341. this.count = (j + 1);
  342. paramString[j] = 58;
  343. return;
  344. }
  345. int i5 = this.count;
  346. int i1 = i5 + n;
  347. paramString.getChars(0, n, this.buf, i5);
  348. this.count = i4;
  349. int i2 = 0;
  350. int j = i5;
  351. if (j < i1)
  352. {
  353. int i6 = this.buf[j];
  354. m = i1;
  355. int i3 = i2;
  356. n = j;
  357. k = i4;
  358. if (i6 < arrayOfBoolean.length)
  359. {
  360. m = i1;
  361. i3 = i2;
  362. n = j;
  363. k = i4;
  364. if (arrayOfBoolean[i6] != 0)
  365. {
  366. if (i2 != 0)
  367. break label579;
  368. k = i4 + 3;
  369. if (k > this.buf.length)
  370. expandCapacity(k);
  371. this.count = k;
  372. System.arraycopy(this.buf, j + 1, this.buf, j + 3, i1 - j - 1);
  373. System.arraycopy(this.buf, 0, this.buf, 1, j);
  374. this.buf[i5] = '"';
  375. paramString = this.buf;
  376. j += 1;
  377. paramString[j] = 92;
  378. paramString = this.buf;
  379. n = j + 1;
  380. paramString[n] = CharTypes.replaceChars[i6];
  381. m = i1 + 2;
  382. this.buf[(this.count - 2)] = '"';
  383. }
  384. }
  385. for (i3 = 1; ; i3 = i2)
  386. {
  387. j = n + 1;
  388. i1 = m;
  389. i2 = i3;
  390. i4 = k;
  391. break;
  392. label579: k = i4 + 1;
  393. if (k > this.buf.length)
  394. expandCapacity(k);
  395. this.count = k;
  396. System.arraycopy(this.buf, j + 1, this.buf, j + 2, i1 - j);
  397. this.buf[j] = '\\';
  398. paramString = this.buf;
  399. n = j + 1;
  400. paramString[n] = CharTypes.replaceChars[i6];
  401. m = i1 + 1;
  402. }
  403. }
  404. this.buf[(this.count - 1)] = ':';
  405. }
  406. private void writeKeyWithSingleQuoteIfHasSpecial(String paramString)
  407. {
  408. boolean[] arrayOfBoolean = CharTypes.specicalFlags_singleQuotes;
  409. int n = paramString.length();
  410. int i4 = this.count + n + 1;
  411. int m;
  412. int k;
  413. if (i4 > this.buf.length)
  414. {
  415. if (this.writer != null)
  416. {
  417. if (n == 0)
  418. {
  419. write('\'');
  420. write('\'');
  421. write(':');
  422. return;
  423. }
  424. m = 0;
  425. k = 0;
  426. j = m;
  427. label118: int i;
  428. if (k < n)
  429. {
  430. j = paramString.charAt(k);
  431. if ((j < arrayOfBoolean.length) && (arrayOfBoolean[j] != 0))
  432. j = 1;
  433. }
  434. else
  435. {
  436. if (j != 0)
  437. write('\'');
  438. k = 0;
  439. if (k >= n)
  440. break label185;
  441. i = paramString.charAt(k);
  442. if ((i >= arrayOfBoolean.length) || (arrayOfBoolean[i] == 0))
  443. break label177;
  444. write('\\');
  445. write(CharTypes.replaceChars[i]);
  446. }
  447. while (true)
  448. {
  449. k += 1;
  450. break label118;
  451. k += 1;
  452. break;
  453. label177: write(i);
  454. }
  455. label185: if (j != 0)
  456. write('\'');
  457. write(':');
  458. return;
  459. }
  460. expandCapacity(i4);
  461. }
  462. if (n == 0)
  463. {
  464. if (this.count + 3 > this.buf.length)
  465. expandCapacity(this.count + 3);
  466. paramString = this.buf;
  467. j = this.count;
  468. this.count = (j + 1);
  469. paramString[j] = 39;
  470. paramString = this.buf;
  471. j = this.count;
  472. this.count = (j + 1);
  473. paramString[j] = 39;
  474. paramString = this.buf;
  475. j = this.count;
  476. this.count = (j + 1);
  477. paramString[j] = 58;
  478. return;
  479. }
  480. int i5 = this.count;
  481. int i1 = i5 + n;
  482. paramString.getChars(0, n, this.buf, i5);
  483. this.count = i4;
  484. int i2 = 0;
  485. int j = i5;
  486. if (j < i1)
  487. {
  488. int i6 = this.buf[j];
  489. m = i1;
  490. int i3 = i2;
  491. n = j;
  492. k = i4;
  493. if (i6 < arrayOfBoolean.length)
  494. {
  495. m = i1;
  496. i3 = i2;
  497. n = j;
  498. k = i4;
  499. if (arrayOfBoolean[i6] != 0)
  500. {
  501. if (i2 != 0)
  502. break label579;
  503. k = i4 + 3;
  504. if (k > this.buf.length)
  505. expandCapacity(k);
  506. this.count = k;
  507. System.arraycopy(this.buf, j + 1, this.buf, j + 3, i1 - j - 1);
  508. System.arraycopy(this.buf, 0, this.buf, 1, j);
  509. this.buf[i5] = '\'';
  510. paramString = this.buf;
  511. j += 1;
  512. paramString[j] = 92;
  513. paramString = this.buf;
  514. n = j + 1;
  515. paramString[n] = CharTypes.replaceChars[i6];
  516. m = i1 + 2;
  517. this.buf[(this.count - 2)] = '\'';
  518. }
  519. }
  520. for (i3 = 1; ; i3 = i2)
  521. {
  522. j = n + 1;
  523. i1 = m;
  524. i2 = i3;
  525. i4 = k;
  526. break;
  527. label579: k = i4 + 1;
  528. if (k > this.buf.length)
  529. expandCapacity(k);
  530. this.count = k;
  531. System.arraycopy(this.buf, j + 1, this.buf, j + 2, i1 - j);
  532. this.buf[j] = '\\';
  533. paramString = this.buf;
  534. n = j + 1;
  535. paramString[n] = CharTypes.replaceChars[i6];
  536. m = i1 + 1;
  537. }
  538. }
  539. this.buf[(i4 - 1)] = ':';
  540. }
  541. private void writeStringWithDoubleQuote(String paramString, char paramChar)
  542. {
  543. writeStringWithDoubleQuote(paramString, paramChar, true);
  544. }
  545. private void writeStringWithDoubleQuote(String paramString, char paramChar, boolean paramBoolean)
  546. {
  547. if (paramString == null)
  548. {
  549. writeNull();
  550. if (paramChar != 0)
  551. write(paramChar);
  552. }
  553. int m;
  554. do
  555. {
  556. return;
  557. n = paramString.length();
  558. m = this.count + n + 2;
  559. k = m;
  560. if (paramChar != 0)
  561. k = m + 1;
  562. if (k <= this.buf.length)
  563. break label410;
  564. if (this.writer == null)
  565. break;
  566. write('"');
  567. k = 0;
  568. if (k < paramString.length())
  569. {
  570. int i = paramString.charAt(k);
  571. if (isEnabled(SerializerFeature.BrowserCompatible))
  572. if ((i == 8) || (i == 12) || (i == 10) || (i == 13) || (i == 9) || (i == 34) || (i == 47) || (i == 92))
  573. {
  574. write('\\');
  575. write(CharTypes.replaceChars[i]);
  576. }
  577. while (true)
  578. {
  579. k += 1;
  580. break;
  581. if (i < 32)
  582. {
  583. write('\\');
  584. write('u');
  585. write('0');
  586. write('0');
  587. write(CharTypes.ASCII_CHARS[(i * 2)]);
  588. write(CharTypes.ASCII_CHARS[(i * 2 + 1)]);
  589. }
  590. else if (i >= 127)
  591. {
  592. write('\\');
  593. write('u');
  594. write(CharTypes.digits[(i >>> 12 & 0xF)]);
  595. write(CharTypes.digits[(i >>> 8 & 0xF)]);
  596. write(CharTypes.digits[(i >>> 4 & 0xF)]);
  597. write(CharTypes.digits[(i & 0xF)]);
  598. continue;
  599. if (((i < CharTypes.specicalFlags_doubleQuotes.length) && (CharTypes.specicalFlags_doubleQuotes[i] != 0)) || ((i == 47) && (isEnabled(SerializerFeature.WriteSlashAsSpecial))))
  600. {
  601. write('\\');
  602. write(CharTypes.replaceChars[i]);
  603. }
  604. }
  605. else
  606. {
  607. write(i);
  608. }
  609. }
  610. }
  611. write('"');
  612. }
  613. while (paramChar == 0);
  614. write(paramChar);
  615. return;
  616. expandCapacity(k);
  617. label410: int i8 = this.count + 1;
  618. int i9 = i8 + n;
  619. this.buf[this.count] = '"';
  620. paramString.getChars(0, n, this.buf, i8);
  621. this.count = k;
  622. int j;
  623. if (isEnabled(SerializerFeature.BrowserCompatible))
  624. {
  625. m = -1;
  626. n = i8;
  627. i1 = k;
  628. k = n;
  629. if (k < i9)
  630. {
  631. i2 = this.buf[k];
  632. if ((i2 == 34) || (i2 == 47) || (i2 == 92))
  633. {
  634. m = k;
  635. n = i1 + 1;
  636. }
  637. while (true)
  638. {
  639. k += 1;
  640. i1 = n;
  641. break;
  642. if ((i2 == 8) || (i2 == 12) || (i2 == 10) || (i2 == 13) || (i2 == 9))
  643. {
  644. m = k;
  645. n = i1 + 1;
  646. }
  647. else if (i2 < 32)
  648. {
  649. m = k;
  650. n = i1 + 5;
  651. }
  652. else
  653. {
  654. n = i1;
  655. if (i2 >= 127)
  656. {
  657. m = k;
  658. n = i1 + 5;
  659. }
  660. }
  661. }
  662. }
  663. if (i1 > this.buf.length)
  664. expandCapacity(i1);
  665. this.count = i1;
  666. if (m >= i8)
  667. {
  668. j = this.buf[m];
  669. if ((j == 8) || (j == 12) || (j == 10) || (j == 13) || (j == 9))
  670. {
  671. System.arraycopy(this.buf, m + 1, this.buf, m + 2, i9 - m - 1);
  672. this.buf[m] = '\\';
  673. this.buf[(m + 1)] = CharTypes.replaceChars[j];
  674. k = i9 + 1;
  675. }
  676. while (true)
  677. {
  678. m -= 1;
  679. i9 = k;
  680. break;
  681. if ((j == 34) || (j == 47) || (j == 92))
  682. {
  683. System.arraycopy(this.buf, m + 1, this.buf, m + 2, i9 - m - 1);
  684. this.buf[m] = '\\';
  685. this.buf[(m + 1)] = j;
  686. k = i9 + 1;
  687. }
  688. else if (j < 32)
  689. {
  690. System.arraycopy(this.buf, m + 1, this.buf, m + 6, i9 - m - 1);
  691. this.buf[m] = '\\';
  692. this.buf[(m + 1)] = 'u';
  693. this.buf[(m + 2)] = '0';
  694. this.buf[(m + 3)] = '0';
  695. this.buf[(m + 4)] = CharTypes.ASCII_CHARS[(j * 2)];
  696. this.buf[(m + 5)] = CharTypes.ASCII_CHARS[(j * 2 + 1)];
  697. k = i9 + 5;
  698. }
  699. else
  700. {
  701. k = i9;
  702. if (j >= 127)
  703. {
  704. System.arraycopy(this.buf, m + 1, this.buf, m + 6, i9 - m - 1);
  705. this.buf[m] = '\\';
  706. this.buf[(m + 1)] = 'u';
  707. this.buf[(m + 2)] = CharTypes.digits[(j >>> 12 & 0xF)];
  708. this.buf[(m + 3)] = CharTypes.digits[(j >>> 8 & 0xF)];
  709. this.buf[(m + 4)] = CharTypes.digits[(j >>> 4 & 0xF)];
  710. this.buf[(m + 5)] = CharTypes.digits[(j & 0xF)];
  711. k = i9 + 5;
  712. }
  713. }
  714. }
  715. }
  716. if (paramChar != 0)
  717. {
  718. this.buf[(this.count - 2)] = '"';
  719. this.buf[(this.count - 1)] = paramChar;
  720. return;
  721. }
  722. this.buf[(this.count - 1)] = '"';
  723. return;
  724. }
  725. int i10 = 0;
  726. int i1 = 0;
  727. int i5 = -1;
  728. int n = -1;
  729. int i3 = 0;
  730. int i7 = 0;
  731. int i2 = n;
  732. int i4 = i5;
  733. int i6 = k;
  734. if (paramBoolean)
  735. {
  736. i2 = i8;
  737. m = k;
  738. k = i2;
  739. i2 = n;
  740. i3 = i7;
  741. i4 = i5;
  742. i6 = m;
  743. i10 = i1;
  744. if (k < i9)
  745. {
  746. int i11 = this.buf[k];
  747. if (i11 >= 93)
  748. {
  749. i6 = n;
  750. i2 = i7;
  751. i3 = i5;
  752. i10 = m;
  753. i4 = i1;
  754. if (i11 == 8232)
  755. {
  756. i5 = i1 + 1;
  757. i1 = k;
  758. m += 4;
  759. i6 = n;
  760. i2 = i11;
  761. i3 = i1;
  762. i10 = m;
  763. i4 = i5;
  764. if (n == -1)
  765. {
  766. i6 = k;
  767. i4 = i5;
  768. i10 = m;
  769. i3 = i1;
  770. i2 = i11;
  771. }
  772. }
  773. }
  774. while (true)
  775. {
  776. k += 1;
  777. n = i6;
  778. i7 = i2;
  779. i5 = i3;
  780. m = i10;
  781. i1 = i4;
  782. break;
  783. i6 = n;
  784. i2 = i7;
  785. i3 = i5;
  786. i10 = m;
  787. i4 = i1;
  788. if (i11 != 32)
  789. if (i11 >= 48)
  790. {
  791. i6 = n;
  792. i2 = i7;
  793. i3 = i5;
  794. i10 = m;
  795. i4 = i1;
  796. if (i11 != 92);
  797. }
  798. else if ((i11 >= CharTypes.specicalFlags_doubleQuotes.length) || (CharTypes.specicalFlags_doubleQuotes[i11] == 0))
  799. {
  800. i6 = n;
  801. i2 = i7;
  802. i3 = i5;
  803. i10 = m;
  804. i4 = i1;
  805. if (i11 == 47)
  806. {
  807. i6 = n;
  808. i2 = i7;
  809. i3 = i5;
  810. i10 = m;
  811. i4 = i1;
  812. if (!isEnabled(SerializerFeature.WriteSlashAsSpecial));
  813. }
  814. }
  815. else
  816. {
  817. i5 = i1 + 1;
  818. i1 = k;
  819. i6 = n;
  820. i2 = i11;
  821. i3 = i1;
  822. i10 = m;
  823. i4 = i5;
  824. if (n == -1)
  825. {
  826. i6 = k;
  827. i2 = i11;
  828. i3 = i1;
  829. i10 = m;
  830. i4 = i5;
  831. }
  832. }
  833. }
  834. }
  835. }
  836. int k = i6 + i10;
  837. if (k > this.buf.length)
  838. expandCapacity(k);
  839. this.count = k;
  840. if (i10 == 1)
  841. if (i3 == 8232)
  842. {
  843. System.arraycopy(this.buf, i4 + 1, this.buf, i4 + 6, i9 - i4 - 1);
  844. this.buf[i4] = '\\';
  845. paramString = this.buf;
  846. k = i4 + 1;
  847. paramString[k] = 117;
  848. paramString = this.buf;
  849. k += 1;
  850. paramString[k] = 50;
  851. paramString = this.buf;
  852. k += 1;
  853. paramString[k] = 48;
  854. paramString = this.buf;
  855. k += 1;
  856. paramString[k] = 50;
  857. this.buf[(k + 1)] = '8';
  858. }
  859. while (paramChar != 0)
  860. {
  861. this.buf[(this.count - 2)] = '"';
  862. this.buf[(this.count - 1)] = paramChar;
  863. return;
  864. System.arraycopy(this.buf, i4 + 1, this.buf, i4 + 2, i9 - i4 - 1);
  865. this.buf[i4] = '\\';
  866. this.buf[(i4 + 1)] = CharTypes.replaceChars[i3];
  867. continue;
  868. if (i10 > 1)
  869. {
  870. k = i2;
  871. m = i2 - i8;
  872. label1823: if (m < paramString.length())
  873. {
  874. j = paramString.charAt(m);
  875. if (((j >= CharTypes.specicalFlags_doubleQuotes.length) || (CharTypes.specicalFlags_doubleQuotes[j] == 0)) && ((j != 47) || (!isEnabled(SerializerFeature.WriteSlashAsSpecial))))
  876. break label1932;
  877. char[] arrayOfChar = this.buf;
  878. n = k + 1;
  879. arrayOfChar[k] = '\\';
  880. arrayOfChar = this.buf;
  881. k = n + 1;
  882. arrayOfChar[n] = CharTypes.replaceChars[j];
  883. i9 += 1;
  884. }
  885. while (true)
  886. {
  887. m += 1;
  888. break label1823;
  889. break;
  890. label1932: this.buf[k] = j;
  891. k += 1;
  892. }
  893. }
  894. }
  895. this.buf[(this.count - 1)] = '"';
  896. }
  897. private void writeStringWithSingleQuote(String paramString)
  898. {
  899. if (paramString == null)
  900. {
  901. i = this.count + 4;
  902. if (i > this.buf.length)
  903. expandCapacity(i);
  904. "null".getChars(0, 4, this.buf, this.count);
  905. this.count = i;
  906. return;
  907. }
  908. int i = paramString.length();
  909. int i6 = this.count + i + 2;
  910. if (i6 > this.buf.length)
  911. {
  912. if (this.writer != null)
  913. {
  914. write('\'');
  915. i = 0;
  916. if (i < paramString.length())
  917. {
  918. char c = paramString.charAt(i);
  919. if ((c <= '\r') || (c == '\\') || (c == '\'') || ((c == '/') && (isEnabled(SerializerFeature.WriteSlashAsSpecial))))
  920. {
  921. write('\\');
  922. write(CharTypes.replaceChars[c]);
  923. }
  924. while (true)
  925. {
  926. i += 1;
  927. break;
  928. write(c);
  929. }
  930. }
  931. write('\'');
  932. return;
  933. }
  934. expandCapacity(i6);
  935. }
  936. int i3 = this.count + 1;
  937. int i5 = i3 + i;
  938. this.buf[this.count] = '\'';
  939. paramString.getChars(0, i, this.buf, i3);
  940. this.count = i6;
  941. int j = 0;
  942. int m = -1;
  943. int k = 0;
  944. i = i3;
  945. while (i < i5)
  946. {
  947. int i4 = this.buf[i];
  948. int i2;
  949. int i1;
  950. int n;
  951. if ((i4 > 13) && (i4 != 92) && (i4 != 39))
  952. {
  953. i2 = k;
  954. i1 = m;
  955. n = j;
  956. if (i4 == 47)
  957. {
  958. i2 = k;
  959. i1 = m;
  960. n = j;
  961. if (!isEnabled(SerializerFeature.WriteSlashAsSpecial));
  962. }
  963. }
  964. else
  965. {
  966. n = j + 1;
  967. i1 = i;
  968. i2 = i4;
  969. }
  970. i += 1;
  971. k = i2;
  972. m = i1;
  973. j = n;
  974. }
  975. i = i6 + j;
  976. if (i > this.buf.length)
  977. expandCapacity(i);
  978. this.count = i;
  979. if (j == 1)
  980. {
  981. System.arraycopy(this.buf, m + 1, this.buf, m + 2, i5 - m - 1);
  982. this.buf[m] = '\\';
  983. this.buf[(m + 1)] = CharTypes.replaceChars[k];
  984. }
  985. while (true)
  986. {
  987. this.buf[(this.count - 1)] = '\'';
  988. return;
  989. if (j > 1)
  990. {
  991. System.arraycopy(this.buf, m + 1, this.buf, m + 2, i5 - m - 1);
  992. this.buf[m] = '\\';
  993. paramString = this.buf;
  994. i = m + 1;
  995. paramString[i] = CharTypes.replaceChars[k];
  996. j = i5 + 1;
  997. i -= 2;
  998. while (i >= i3)
  999. {
  1000. m = this.buf[i];
  1001. if ((m > 13) && (m != 92) && (m != 39))
  1002. {
  1003. k = j;
  1004. if (m == 47)
  1005. {
  1006. k = j;
  1007. if (!isEnabled(SerializerFeature.WriteSlashAsSpecial));
  1008. }
  1009. }
  1010. else
  1011. {
  1012. System.arraycopy(this.buf, i + 1, this.buf, i + 2, j - i - 1);
  1013. this.buf[i] = '\\';
  1014. this.buf[(i + 1)] = CharTypes.replaceChars[m];
  1015. k = j + 1;
  1016. }
  1017. i -= 1;
  1018. j = k;
  1019. }
  1020. }
  1021. }
  1022. }
  1023. public SerializeWriter append(char paramChar)
  1024. {
  1025. write(paramChar);
  1026. return this;
  1027. }
  1028. public SerializeWriter append(CharSequence paramCharSequence)
  1029. {
  1030. if (paramCharSequence == null);
  1031. for (paramCharSequence = "null"; ; paramCharSequence = paramCharSequence.toString())
  1032. {
  1033. write(paramCharSequence, 0, paramCharSequence.length());
  1034. return this;
  1035. }
  1036. }
  1037. public SerializeWriter append(CharSequence paramCharSequence, int paramInt1, int paramInt2)
  1038. {
  1039. Object localObject = paramCharSequence;
  1040. if (paramCharSequence == null)
  1041. localObject = "null";
  1042. paramCharSequence = ((CharSequence)localObject).subSequence(paramInt1, paramInt2).toString();
  1043. write(paramCharSequence, 0, paramCharSequence.length());
  1044. return this;
  1045. }
  1046. public void close()
  1047. {
  1048. if ((this.writer != null) && (this.count > 0))
  1049. flush();
  1050. if (this.buf.length <= 8192)
  1051. bufLocal.set(new SoftReference(this.buf));
  1052. this.buf = null;
  1053. }
  1054. public void config(SerializerFeature paramSerializerFeature, boolean paramBoolean)
  1055. {
  1056. if (paramBoolean)
  1057. {
  1058. this.features |= paramSerializerFeature.getMask();
  1059. return;
  1060. }
  1061. this.features &= (paramSerializerFeature.getMask() ^ 0xFFFFFFFF);
  1062. }
  1063. public void expandCapacity(int paramInt)
  1064. {
  1065. int j = this.buf.length * 3 / 2 + 1;
  1066. int i = j;
  1067. if (j < paramInt)
  1068. i = paramInt;
  1069. char[] arrayOfChar = new char[i];
  1070. System.arraycopy(this.buf, 0, arrayOfChar, 0, this.count);
  1071. this.buf = arrayOfChar;
  1072. }
  1073. public void flush()
  1074. {
  1075. if (this.writer == null)
  1076. return;
  1077. try
  1078. {
  1079. this.writer.write(this.buf, 0, this.count);
  1080. this.writer.flush();
  1081. this.count = 0;
  1082. return;
  1083. }
  1084. catch (IOException localIOException)
  1085. {
  1086. throw new JSONException(localIOException.getMessage(), localIOException);
  1087. }
  1088. }
  1089. public int getBufferLength()
  1090. {
  1091. return this.buf.length;
  1092. }
  1093. public boolean isEnabled(SerializerFeature paramSerializerFeature)
  1094. {
  1095. return SerializerFeature.isEnabled(this.features, paramSerializerFeature);
  1096. }
  1097. public void reset()
  1098. {
  1099. this.count = 0;
  1100. }
  1101. public int size()
  1102. {
  1103. return this.count;
  1104. }
  1105. public byte[] toBytes(String paramString)
  1106. {
  1107. if (this.writer != null)
  1108. throw new UnsupportedOperationException("writer not null");
  1109. String str = paramString;
  1110. if (paramString == null)
  1111. str = "UTF-8";
  1112. return new SerialWriterStringEncoder(Charset.forName(str)).encode(this.buf, 0, this.count);
  1113. }
  1114. public char[] toCharArray()
  1115. {
  1116. if (this.writer != null)
  1117. throw new UnsupportedOperationException("writer not null");
  1118. char[] arrayOfChar = new char[this.count];
  1119. System.arraycopy(this.buf, 0, arrayOfChar, 0, this.count);
  1120. return arrayOfChar;
  1121. }
  1122. public String toString()
  1123. {
  1124. return new String(this.buf, 0, this.count);
  1125. }
  1126. public void write(char paramChar)
  1127. {
  1128. int j = this.count + 1;
  1129. int i = j;
  1130. if (j > this.buf.length)
  1131. {
  1132. if (this.writer != null)
  1133. break label48;
  1134. expandCapacity(j);
  1135. }
  1136. for (i = j; ; i = 1)
  1137. {
  1138. this.buf[this.count] = paramChar;
  1139. this.count = i;
  1140. return;
  1141. label48: flush();
  1142. }
  1143. }
  1144. public void write(int paramInt)
  1145. {
  1146. int j = this.count + 1;
  1147. int i = j;
  1148. if (j > this.buf.length)
  1149. {
  1150. if (this.writer != null)
  1151. break label49;
  1152. expandCapacity(j);
  1153. }
  1154. for (i = j; ; i = 1)
  1155. {
  1156. this.buf[this.count] = ((char)paramInt);
  1157. this.count = i;
  1158. return;
  1159. label49: flush();
  1160. }
  1161. }
  1162. public void write(String paramString)
  1163. {
  1164. if (paramString == null)
  1165. {
  1166. writeNull();
  1167. return;
  1168. }
  1169. write(paramString, 0, paramString.length());
  1170. }
  1171. public void write(String paramString, int paramInt1, int paramInt2)
  1172. {
  1173. int m = this.count + paramInt2;
  1174. int i = m;
  1175. int j = paramInt1;
  1176. int k = paramInt2;
  1177. if (m > this.buf.length)
  1178. {
  1179. i = paramInt1;
  1180. j = paramInt2;
  1181. if (this.writer != null)
  1182. break label83;
  1183. expandCapacity(m);
  1184. k = paramInt2;
  1185. j = paramInt1;
  1186. i = m;
  1187. }
  1188. while (true)
  1189. {
  1190. paramString.getChars(j, j + k, this.buf, this.count);
  1191. this.count = i;
  1192. return;
  1193. label83:
  1194. do
  1195. {
  1196. paramInt2 = this.buf.length - this.count;
  1197. paramString.getChars(i, i + paramInt2, this.buf, this.count);
  1198. this.count = this.buf.length;
  1199. flush();
  1200. paramInt1 = j - paramInt2;
  1201. paramInt2 = i + paramInt2;
  1202. i = paramInt2;
  1203. j = paramInt1;
  1204. }
  1205. while (paramInt1 > this.buf.length);
  1206. i = paramInt1;
  1207. j = paramInt2;
  1208. k = paramInt1;
  1209. }
  1210. }
  1211. public void write(boolean paramBoolean)
  1212. {
  1213. if (paramBoolean)
  1214. {
  1215. write("true");
  1216. return;
  1217. }
  1218. write("false");
  1219. }
  1220. public void write(char[] paramArrayOfChar, int paramInt1, int paramInt2)
  1221. {
  1222. if ((paramInt1 < 0) || (paramInt1 > paramArrayOfChar.length) || (paramInt2 < 0) || (paramInt1 + paramInt2 > paramArrayOfChar.length) || (paramInt1 + paramInt2 < 0))
  1223. throw new IndexOutOfBoundsException();
  1224. if (paramInt2 == 0)
  1225. return;
  1226. int m = this.count + paramInt2;
  1227. int i = m;
  1228. int j = paramInt1;
  1229. int k = paramInt2;
  1230. if (m > this.buf.length)
  1231. {
  1232. i = paramInt1;
  1233. j = paramInt2;
  1234. if (this.writer != null)
  1235. break label121;
  1236. expandCapacity(m);
  1237. k = paramInt2;
  1238. j = paramInt1;
  1239. i = m;
  1240. }
  1241. while (true)
  1242. {
  1243. System.arraycopy(paramArrayOfChar, j, this.buf, this.count, k);
  1244. this.count = i;
  1245. return;
  1246. label121:
  1247. do
  1248. {
  1249. paramInt2 = this.buf.length - this.count;
  1250. System.arraycopy(paramArrayOfChar, i, this.buf, this.count, paramInt2);
  1251. this.count = this.buf.length;
  1252. flush();
  1253. paramInt1 = j - paramInt2;
  1254. paramInt2 = i + paramInt2;
  1255. i = paramInt2;
  1256. j = paramInt1;
  1257. }
  1258. while (paramInt1 > this.buf.length);
  1259. i = paramInt1;
  1260. j = paramInt2;
  1261. k = paramInt1;
  1262. }
  1263. }
  1264. public void writeBooleanAndChar(boolean paramBoolean, char paramChar)
  1265. {
  1266. if (paramBoolean)
  1267. {
  1268. if (paramChar == ',')
  1269. {
  1270. write("true,");
  1271. return;
  1272. }
  1273. if (paramChar == ']')
  1274. {
  1275. write("true]");
  1276. return;
  1277. }
  1278. write("true");
  1279. write(paramChar);
  1280. return;
  1281. }
  1282. if (paramChar == ',')
  1283. {
  1284. write("false,");
  1285. return;
  1286. }
  1287. if (paramChar == ']')
  1288. {
  1289. write("false]");
  1290. return;
  1291. }
  1292. write("false");
  1293. write(paramChar);
  1294. }
  1295. public void writeByteArray(byte[] paramArrayOfByte)
  1296. {
  1297. int k = paramArrayOfByte.length;
  1298. if (k == 0)
  1299. {
  1300. write("\"\"");
  1301. return;
  1302. }
  1303. char[] arrayOfChar1 = Base64.CA;
  1304. int m = k / 3 * 3;
  1305. int j = (k - 1) / 3;
  1306. int i = this.count;
  1307. int n = this.count + (j + 1 << 2) + 2;
  1308. if (n > this.buf.length)
  1309. {
  1310. if (this.writer != null)
  1311. {
  1312. write('"');
  1313. i = 0;
  1314. while (i < m)
  1315. {
  1316. j = i + 1;
  1317. n = paramArrayOfByte[i];
  1318. i = j + 1;
  1319. j = (n & 0xFF) << 16 | (paramArrayOfByte[j] & 0xFF) << 8 | paramArrayOfByte[i] & 0xFF;
  1320. write(arrayOfChar1[(j >>> 18 & 0x3F)]);
  1321. write(arrayOfChar1[(j >>> 12 & 0x3F)]);
  1322. write(arrayOfChar1[(j >>> 6 & 0x3F)]);
  1323. write(arrayOfChar1[(j & 0x3F)]);
  1324. i += 1;
  1325. }
  1326. j = k - m;
  1327. if (j > 0)
  1328. {
  1329. m = paramArrayOfByte[m];
  1330. if (j != 2)
  1331. break label312;
  1332. i = (paramArrayOfByte[(k - 1)] & 0xFF) << 2;
  1333. i = (m & 0xFF) << 10 | i;
  1334. write(arrayOfChar1[(i >> 12)]);
  1335. write(arrayOfChar1[(i >>> 6 & 0x3F)]);
  1336. if (j != 2)
  1337. break label318;
  1338. }
  1339. label312: label318: for (c = arrayOfChar1[(i & 0x3F)]; ; c = '=')
  1340. {
  1341. write(c);
  1342. write('=');
  1343. write('"');
  1344. return;
  1345. i = 0;
  1346. break;
  1347. }
  1348. }
  1349. expandCapacity(n);
  1350. }
  1351. this.count = n;
  1352. this.buf[i] = '"';
  1353. i += 1;
  1354. j = 0;
  1355. while (j < m)
  1356. {
  1357. int i1 = j + 1;
  1358. int i2 = paramArrayOfByte[j];
  1359. j = i1 + 1;
  1360. i1 = (i2 & 0xFF) << 16 | (paramArrayOfByte[i1] & 0xFF) << 8 | paramArrayOfByte[j] & 0xFF;
  1361. char[] arrayOfChar2 = this.buf;
  1362. i2 = i + 1;
  1363. arrayOfChar2[i] = arrayOfChar1[(i1 >>> 18 & 0x3F)];
  1364. arrayOfChar2 = this.buf;
  1365. i = i2 + 1;
  1366. arrayOfChar2[i2] = arrayOfChar1[(i1 >>> 12 & 0x3F)];
  1367. arrayOfChar2 = this.buf;
  1368. i2 = i + 1;
  1369. arrayOfChar2[i] = arrayOfChar1[(i1 >>> 6 & 0x3F)];
  1370. arrayOfChar2 = this.buf;
  1371. i = i2 + 1;
  1372. arrayOfChar2[i2] = arrayOfChar1[(i1 & 0x3F)];
  1373. j += 1;
  1374. }
  1375. j = k - m;
  1376. if (j > 0)
  1377. {
  1378. m = paramArrayOfByte[m];
  1379. if (j != 2)
  1380. break label661;
  1381. i = (paramArrayOfByte[(k - 1)] & 0xFF) << 2;
  1382. i = (m & 0xFF) << 10 | i;
  1383. this.buf[(n - 5)] = arrayOfChar1[(i >> 12)];
  1384. this.buf[(n - 4)] = arrayOfChar1[(i >>> 6 & 0x3F)];
  1385. paramArrayOfByte = this.buf;
  1386. if (j != 2)
  1387. break label667;
  1388. }
  1389. label661: label667: for (char c = arrayOfChar1[(i & 0x3F)]; ; c = '=')
  1390. {
  1391. paramArrayOfByte[(n - 3)] = c;
  1392. this.buf[(n - 2)] = '=';
  1393. this.buf[(n - 1)] = '"';
  1394. return;
  1395. i = 0;
  1396. break;
  1397. }
  1398. }
  1399. public void writeCharacterAndChar(char paramChar1, char paramChar2)
  1400. {
  1401. writeString(Character.toString(paramChar1));
  1402. write(paramChar2);
  1403. }
  1404. public void writeDoubleAndChar(double paramDouble, char paramChar)
  1405. {
  1406. String str2 = Double.toString(paramDouble);
  1407. String str1 = str2;
  1408. if (str2.endsWith(".0"))
  1409. str1 = str2.substring(0, str2.length() - 2);
  1410. write(str1);
  1411. write(paramChar);
  1412. }
  1413. public void writeEnum(Enum<?> paramEnum, char paramChar)
  1414. {
  1415. if (paramEnum == null)
  1416. {
  1417. writeNull();
  1418. write(',');
  1419. return;
  1420. }
  1421. if (isEnabled(SerializerFeature.WriteEnumUsingToString))
  1422. {
  1423. if (isEnabled(SerializerFeature.UseSingleQuotes))
  1424. {
  1425. write('\'');
  1426. write(paramEnum.name());
  1427. write('\'');
  1428. write(paramChar);
  1429. return;
  1430. }
  1431. write('"');
  1432. write(paramEnum.name());
  1433. write('"');
  1434. write(paramChar);
  1435. return;
  1436. }
  1437. writeIntAndChar(paramEnum.ordinal(), paramChar);
  1438. }
  1439. public void writeFieldEmptyList(char paramChar, String paramString)
  1440. {
  1441. write(paramChar);
  1442. writeFieldName(paramString);
  1443. write("[]");
  1444. }
  1445. public void writeFieldName(String paramString)
  1446. {
  1447. writeFieldName(paramString, false);
  1448. }
  1449. public void writeFieldName(String paramString, boolean paramBoolean)
  1450. {
  1451. if (paramString == null)
  1452. {
  1453. write("null:");
  1454. return;
  1455. }
  1456. if (isEnabled(SerializerFeature.UseSingleQuotes))
  1457. {
  1458. if (isEnabled(SerializerFeature.QuoteFieldNames))
  1459. {
  1460. writeStringWithSingleQuote(paramString);
  1461. write(':');
  1462. return;
  1463. }
  1464. writeKeyWithSingleQuoteIfHasSpecial(paramString);
  1465. return;
  1466. }
  1467. if (isEnabled(SerializerFeature.QuoteFieldNames))
  1468. {
  1469. writeStringWithDoubleQuote(paramString, ':', paramBoolean);
  1470. return;
  1471. }
  1472. writeKeyWithDoubleQuoteIfHasSpecial(paramString);
  1473. }
  1474. public void writeFieldNull(char paramChar, String paramString)
  1475. {
  1476. write(paramChar);
  1477. writeFieldName(paramString);
  1478. writeNull();
  1479. }
  1480. public void writeFieldNullBoolean(char paramChar, String paramString)
  1481. {
  1482. write(paramChar);
  1483. writeFieldName(paramString);
  1484. if (isEnabled(SerializerFeature.WriteNullBooleanAsFalse))
  1485. {
  1486. write("false");
  1487. return;
  1488. }
  1489. writeNull();
  1490. }
  1491. public void writeFieldNullList(char paramChar, String paramString)
  1492. {
  1493. write(paramChar);
  1494. writeFieldName(paramString);
  1495. if (isEnabled(SerializerFeature.WriteNullListAsEmpty))
  1496. {
  1497. write("[]");
  1498. return;
  1499. }
  1500. writeNull();
  1501. }
  1502. public void writeFieldNullNumber(char paramChar, String paramString)
  1503. {
  1504. write(paramChar);
  1505. writeFieldName(paramString);
  1506. if (isEnabled(SerializerFeature.WriteNullNumberAsZero))
  1507. {
  1508. write('0');
  1509. return;
  1510. }
  1511. writeNull();
  1512. }
  1513. public void writeFieldNullString(char paramChar, String paramString)
  1514. {
  1515. write(paramChar);
  1516. writeFieldName(paramString);
  1517. if (isEnabled(SerializerFeature.WriteNullStringAsEmpty))
  1518. {
  1519. writeString("");
  1520. return;
  1521. }
  1522. writeNull();
  1523. }
  1524. public void writeFieldValue(char paramChar1, String paramString, char paramChar2)
  1525. {
  1526. write(paramChar1);
  1527. writeFieldName(paramString);
  1528. if (paramChar2 == 0)
  1529. {
  1530. writeString("");
  1531. return;
  1532. }
  1533. writeString(Character.toString(paramChar2));
  1534. }
  1535. public void writeFieldValue(char paramChar, String paramString, double paramDouble)
  1536. {
  1537. write(paramChar);
  1538. writeFieldName(paramString);
  1539. if (paramDouble == 0.0D)
  1540. {
  1541. write('0');
  1542. return;
  1543. }
  1544. if (Double.isNaN(paramDouble))
  1545. {
  1546. writeNull();
  1547. return;
  1548. }
  1549. if (Double.isInfinite(paramDouble))
  1550. {
  1551. writeNull();
  1552. return;
  1553. }
  1554. String str = Double.toString(paramDouble);
  1555. paramString = str;
  1556. if (str.endsWith(".0"))
  1557. paramString = str.substring(0, str.length() - 2);
  1558. write(paramString);
  1559. }
  1560. public void writeFieldValue(char paramChar, String paramString, float paramFloat)
  1561. {
  1562. write(paramChar);
  1563. writeFieldName(paramString);
  1564. if (paramFloat == 0.0F)
  1565. {
  1566. write('0');
  1567. return;
  1568. }
  1569. if (Float.isNaN(paramFloat))
  1570. {
  1571. writeNull();
  1572. return;
  1573. }
  1574. if (Float.isInfinite(paramFloat))
  1575. {
  1576. writeNull();
  1577. return;
  1578. }
  1579. String str = Float.toString(paramFloat);
  1580. paramString = str;
  1581. if (str.endsWith(".0"))
  1582. paramString = str.substring(0, str.length() - 2);
  1583. write(paramString);
  1584. }
  1585. public void writeFieldValue(char paramChar, String paramString, int paramInt)
  1586. {
  1587. if ((paramInt == -2147483648) || (!isEnabled(SerializerFeature.QuoteFieldNames)))
  1588. {
  1589. writeFieldValue1(paramChar, paramString, paramInt);
  1590. return;
  1591. }
  1592. int i;
  1593. if (isEnabled(SerializerFeature.UseSingleQuotes))
  1594. {
  1595. i = 39;
  1596. if (paramInt >= 0)
  1597. break label104;
  1598. }
  1599. int k;
  1600. label104: for (int j = IOUtils.stringSize(-paramInt) + 1; ; j = IOUtils.stringSize(paramInt))
  1601. {
  1602. k = paramString.length();
  1603. m = this.count + k + 4 + j;
  1604. if (m <= this.buf.length)
  1605. break label119;
  1606. if (this.writer == null)
  1607. break label113;
  1608. writeFieldValue1(paramChar, paramString, paramInt);
  1609. return;
  1610. i = 34;
  1611. break;
  1612. }
  1613. label113: expandCapacity(m);
  1614. label119: j = this.count;
  1615. this.count = m;
  1616. this.buf[j] = paramChar;
  1617. int m = j + k + 1;
  1618. this.buf[(j + 1)] = i;
  1619. paramString.getChars(0, k, this.buf, j + 2);
  1620. this.buf[(m + 1)] = i;
  1621. this.buf[(m + 2)] = ':';
  1622. IOUtils.getChars(paramInt, this.count, this.buf);
  1623. }
  1624. public void writeFieldValue(char paramChar, String paramString, long paramLong)
  1625. {
  1626. if ((paramLong == -9223372036854775808L) || (!isEnabled(SerializerFeature.QuoteFieldNames)))
  1627. {
  1628. writeFieldValue1(paramChar, paramString, paramLong);
  1629. return;
  1630. }
  1631. int i;
  1632. if (isEnabled(SerializerFeature.UseSingleQuotes))
  1633. {
  1634. i = 39;
  1635. if (paramLong >= 0L)
  1636. break label115;
  1637. }
  1638. int k;
  1639. label115: for (int j = IOUtils.stringSize(-paramLong) + 1; ; j = IOUtils.stringSize(paramLong))
  1640. {
  1641. k = paramString.length();
  1642. m = this.count + k + 4 + j;
  1643. if (m <= this.buf.length)
  1644. break label130;
  1645. if (this.writer == null)
  1646. break label124;
  1647. write(paramChar);
  1648. writeFieldName(paramString);
  1649. writeLong(paramLong);
  1650. return;
  1651. i = 34;
  1652. break;
  1653. }
  1654. label124: expandCapacity(m);
  1655. label130: j = this.count;
  1656. this.count = m;
  1657. this.buf[j] = paramChar;
  1658. int m = j + k + 1;
  1659. this.buf[(j + 1)] = i;
  1660. paramString.getChars(0, k, this.buf, j + 2);
  1661. this.buf[(m + 1)] = i;
  1662. this.buf[(m + 2)] = ':';
  1663. IOUtils.getChars(paramLong, this.count, this.buf);
  1664. }
  1665. public void writeFieldValue(char paramChar, String paramString, Enum<?> paramEnum)
  1666. {
  1667. if (paramEnum == null)
  1668. {
  1669. write(paramChar);
  1670. writeFieldName(paramString);
  1671. writeNull();
  1672. return;
  1673. }
  1674. if (isEnabled(SerializerFeature.WriteEnumUsingToString))
  1675. {
  1676. if (isEnabled(SerializerFeature.UseSingleQuotes))
  1677. {
  1678. writeFieldValue(paramChar, paramString, paramEnum.name());
  1679. return;
  1680. }
  1681. writeFieldValueStringWithDoubleQuote(paramChar, paramString, paramEnum.name(), false);
  1682. return;
  1683. }
  1684. writeFieldValue(paramChar, paramString, paramEnum.ordinal());
  1685. }
  1686. public void writeFieldValue(char paramChar, String paramString1, String paramString2)
  1687. {
  1688. if (isEnabled(SerializerFeature.QuoteFieldNames))
  1689. {
  1690. if (isEnabled(SerializerFeature.UseSingleQuotes))
  1691. {
  1692. write(paramChar);
  1693. writeFieldName(paramString1);
  1694. if (paramString2 == null)
  1695. {
  1696. writeNull();
  1697. return;
  1698. }
  1699. writeString(paramString2);
  1700. return;
  1701. }
  1702. if (isEnabled(SerializerFeature.BrowserCompatible))
  1703. {
  1704. write(paramChar);
  1705. writeStringWithDoubleQuote(paramString1, ':');
  1706. writeStringWithDoubleQuote(paramString2, '\000');
  1707. return;
  1708. }
  1709. writeFieldValueStringWithDoubleQuote(paramChar, paramString1, paramString2, true);
  1710. return;
  1711. }
  1712. write(paramChar);
  1713. writeFieldName(paramString1);
  1714. if (paramString2 == null)
  1715. {
  1716. writeNull();
  1717. return;
  1718. }
  1719. writeString(paramString2);
  1720. }
  1721. public void writeFieldValue(char paramChar, String paramString, BigDecimal paramBigDecimal)
  1722. {
  1723. write(paramChar);
  1724. writeFieldName(paramString);
  1725. if (paramBigDecimal == null)
  1726. {
  1727. writeNull();
  1728. return;
  1729. }
  1730. write(paramBigDecimal.toString());
  1731. }
  1732. public void writeFieldValue(char paramChar, String paramString, boolean paramBoolean)
  1733. {
  1734. int i;
  1735. if (isEnabled(SerializerFeature.UseSingleQuotes))
  1736. {
  1737. i = 39;
  1738. if (!paramBoolean)
  1739. break label87;
  1740. }
  1741. int k;
  1742. label87: for (int j = 4; ; j = 5)
  1743. {
  1744. k = paramString.length();
  1745. m = this.count + k + 4 + j;
  1746. if (m <= this.buf.length)
  1747. break label99;
  1748. if (this.writer == null)
  1749. break label93;
  1750. write(paramChar);
  1751. writeString(paramString);
  1752. write(':');
  1753. write(paramBoolean);
  1754. return;
  1755. i = 34;
  1756. break;
  1757. }
  1758. label93: expandCapacity(m);
  1759. label99: j = this.count;
  1760. this.count = m;
  1761. this.buf[j] = paramChar;
  1762. int m = j + k + 1;
  1763. this.buf[(j + 1)] = i;
  1764. paramString.getChars(0, k, this.buf, j + 2);
  1765. this.buf[(m + 1)] = i;
  1766. if (paramBoolean)
  1767. {
  1768. System.arraycopy(":true".toCharArray(), 0, this.buf, m + 2, 5);
  1769. return;
  1770. }
  1771. System.arraycopy(":false".toCharArray(), 0, this.buf, m + 2, 6);
  1772. }
  1773. public void writeFieldValue1(char paramChar, String paramString, int paramInt)
  1774. {
  1775. write(paramChar);
  1776. writeFieldName(paramString);
  1777. writeInt(paramInt);
  1778. }
  1779. public void writeFieldValue1(char paramChar, String paramString, long paramLong)
  1780. {
  1781. write(paramChar);
  1782. writeFieldName(paramString);
  1783. writeLong(paramLong);
  1784. }
  1785. public void writeFloatAndChar(float paramFloat, char paramChar)
  1786. {
  1787. String str2 = Float.toString(paramFloat);
  1788. String str1 = str2;
  1789. if (str2.endsWith(".0"))
  1790. str1 = str2.substring(0, str2.length() - 2);
  1791. write(str1);
  1792. write(paramChar);
  1793. }
  1794. public void writeInt(int paramInt)
  1795. {
  1796. if (paramInt == -2147483648)
  1797. {
  1798. write("-2147483648");
  1799. return;
  1800. }
  1801. if (paramInt < 0);
  1802. for (int i = IOUtils.stringSize(-paramInt) + 1; ; i = IOUtils.stringSize(paramInt))
  1803. {
  1804. int j = this.count + i;
  1805. if (j > this.buf.length)
  1806. {
  1807. if (this.writer != null)
  1808. break;
  1809. expandCapacity(j);
  1810. }
  1811. IOUtils.getChars(paramInt, j, this.buf);
  1812. this.count = j;
  1813. return;
  1814. }
  1815. char[] arrayOfChar = new char[i];
  1816. IOUtils.getChars(paramInt, i, arrayOfChar);
  1817. write(arrayOfChar, 0, arrayOfChar.length);
  1818. }
  1819. public void writeIntAndChar(int paramInt, char paramChar)
  1820. {
  1821. if (paramInt == -2147483648)
  1822. {
  1823. write("-2147483648");
  1824. write(paramChar);
  1825. return;
  1826. }
  1827. if (paramInt < 0);
  1828. int j;
  1829. for (int i = IOUtils.stringSize(-paramInt) + 1; ; i = IOUtils.stringSize(paramInt))
  1830. {
  1831. i = this.count + i;
  1832. j = i + 1;
  1833. if (j <= this.buf.length)
  1834. break label86;
  1835. if (this.writer == null)
  1836. break;
  1837. writeInt(paramInt);
  1838. write(paramChar);
  1839. return;
  1840. }
  1841. expandCapacity(j);
  1842. label86: IOUtils.getChars(paramInt, i, this.buf);
  1843. this.buf[i] = paramChar;
  1844. this.count = j;
  1845. }
  1846. public void writeLong(long paramLong)
  1847. {
  1848. if (paramLong == -9223372036854775808L)
  1849. {
  1850. write("-9223372036854775808");
  1851. return;
  1852. }
  1853. if (paramLong < 0L);
  1854. for (int i = IOUtils.stringSize(-paramLong) + 1; ; i = IOUtils.stringSize(paramLong))
  1855. {
  1856. int j = this.count + i;
  1857. if (j > this.buf.length)
  1858. {
  1859. if (this.writer != null)
  1860. break;
  1861. expandCapacity(j);
  1862. }
  1863. IOUtils.getChars(paramLong, j, this.buf);
  1864. this.count = j;
  1865. return;
  1866. }
  1867. char[] arrayOfChar = new char[i];
  1868. IOUtils.getChars(paramLong, i, arrayOfChar);
  1869. write(arrayOfChar, 0, arrayOfChar.length);
  1870. }
  1871. public void writeLongAndChar(long paramLong, char paramChar)
  1872. throws IOException
  1873. {
  1874. if (paramLong == -9223372036854775808L)
  1875. {
  1876. write("-9223372036854775808");
  1877. write(paramChar);
  1878. return;
  1879. }
  1880. if (paramLong < 0L);
  1881. int j;
  1882. for (int i = IOUtils.stringSize(-paramLong) + 1; ; i = IOUtils.stringSize(paramLong))
  1883. {
  1884. i = this.count + i;
  1885. j = i + 1;
  1886. if (j <= this.buf.length)
  1887. break label94;
  1888. if (this.writer == null)
  1889. break;
  1890. writeLong(paramLong);
  1891. write(paramChar);
  1892. return;
  1893. }
  1894. expandCapacity(j);
  1895. label94: IOUtils.getChars(paramLong, i, this.buf);
  1896. this.buf[i] = paramChar;
  1897. this.count = j;
  1898. }
  1899. public void writeNull()
  1900. {
  1901. write("null");
  1902. }
  1903. public void writeString(String paramString)
  1904. {
  1905. if (isEnabled(SerializerFeature.UseSingleQuotes))
  1906. {
  1907. writeStringWithSingleQuote(paramString);
  1908. return;
  1909. }
  1910. writeStringWithDoubleQuote(paramString, '\000');
  1911. }
  1912. public void writeString(String paramString, char paramChar)
  1913. {
  1914. if (isEnabled(SerializerFeature.UseSingleQuotes))
  1915. {
  1916. writeStringWithSingleQuote(paramString);
  1917. write(paramChar);
  1918. return;
  1919. }
  1920. writeStringWithDoubleQuote(paramString, paramChar);
  1921. }
  1922. public void writeTo(OutputStream paramOutputStream, String paramString)
  1923. throws IOException
  1924. {
  1925. writeTo(paramOutputStream, Charset.forName(paramString));
  1926. }
  1927. public void writeTo(OutputStream paramOutputStream, Charset paramCharset)
  1928. throws IOException
  1929. {
  1930. if (this.writer != null)
  1931. throw new UnsupportedOperationException("writer not null");
  1932. paramOutputStream.write(new String(this.buf, 0, this.count).getBytes(paramCharset));
  1933. }
  1934. public void writeTo(Writer paramWriter)
  1935. throws IOException
  1936. {
  1937. if (this.writer != null)
  1938. throw new UnsupportedOperationException("writer not null");
  1939. paramWriter.write(this.buf, 0, this.count);
  1940. }
  1941. }
  1942. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  1943. * Qualified Name: com.alibaba.fastjson.serializer.SerializeWriter
  1944. * JD-Core Version: 0.6.2
  1945. */