PageRenderTime 60ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/QingTingFanBianYi/src/com/alibaba/fastjson/JSONWriter.java

https://gitlab.com/qt-prometheus/qt-prometheus
Java | 219 lines | 192 code | 23 blank | 4 comment | 18 complexity | 9d5144d91804291589148e5fdf9d8647 MD5 | raw file
  1. package com.alibaba.fastjson;
  2. import com.alibaba.fastjson.serializer.JSONSerializer;
  3. import com.alibaba.fastjson.serializer.SerializeWriter;
  4. import com.alibaba.fastjson.serializer.SerializerFeature;
  5. import java.io.Closeable;
  6. import java.io.Flushable;
  7. import java.io.IOException;
  8. import java.io.Writer;
  9. public class JSONWriter
  10. implements Closeable, Flushable
  11. {
  12. private JSONStreamContext context;
  13. private JSONSerializer serializer;
  14. private SerializeWriter writer;
  15. public JSONWriter(Writer paramWriter)
  16. {
  17. this.writer = new SerializeWriter(paramWriter);
  18. this.serializer = new JSONSerializer(this.writer);
  19. }
  20. private void afterWriter()
  21. {
  22. if (this.context == null)
  23. return;
  24. int k = this.context.getState();
  25. int j = -1;
  26. int i = j;
  27. switch (k)
  28. {
  29. default:
  30. i = j;
  31. case 1005:
  32. case 1002:
  33. case 1001:
  34. case 1003:
  35. case 1004:
  36. }
  37. while (i != -1)
  38. {
  39. this.context.setState(i);
  40. return;
  41. i = 1003;
  42. continue;
  43. i = 1002;
  44. continue;
  45. i = 1005;
  46. }
  47. }
  48. private void beforeWrite()
  49. {
  50. if (this.context == null)
  51. return;
  52. switch (this.context.getState())
  53. {
  54. case 1001:
  55. case 1004:
  56. default:
  57. return;
  58. case 1002:
  59. this.writer.write(':');
  60. return;
  61. case 1003:
  62. this.writer.write(',');
  63. return;
  64. case 1005:
  65. }
  66. this.writer.write(',');
  67. }
  68. private void beginStructure()
  69. {
  70. int i = this.context.getState();
  71. switch (i)
  72. {
  73. case 1003:
  74. default:
  75. throw new JSONException("illegal state : " + i);
  76. case 1002:
  77. this.writer.write(':');
  78. case 1001:
  79. case 1004:
  80. return;
  81. case 1005:
  82. }
  83. this.writer.write(',');
  84. }
  85. private void endStructure()
  86. {
  87. this.context = this.context.getParent();
  88. if (this.context == null)
  89. return;
  90. int k = this.context.getState();
  91. int j = -1;
  92. int i = j;
  93. switch (k)
  94. {
  95. default:
  96. i = j;
  97. case 1003:
  98. case 1005:
  99. case 1002:
  100. case 1004:
  101. case 1001:
  102. }
  103. while (i != -1)
  104. {
  105. this.context.setState(i);
  106. return;
  107. i = 1003;
  108. continue;
  109. i = 1005;
  110. continue;
  111. i = 1002;
  112. }
  113. }
  114. public void close()
  115. throws IOException
  116. {
  117. this.writer.close();
  118. }
  119. public void config(SerializerFeature paramSerializerFeature, boolean paramBoolean)
  120. {
  121. this.writer.config(paramSerializerFeature, paramBoolean);
  122. }
  123. public void endArray()
  124. {
  125. this.writer.write(']');
  126. endStructure();
  127. }
  128. public void endObject()
  129. {
  130. this.writer.write('}');
  131. endStructure();
  132. }
  133. public void flush()
  134. throws IOException
  135. {
  136. this.writer.flush();
  137. }
  138. public void startArray()
  139. {
  140. if (this.context != null)
  141. beginStructure();
  142. this.context = new JSONStreamContext(this.context, 1004);
  143. this.writer.write('[');
  144. }
  145. public void startObject()
  146. {
  147. if (this.context != null)
  148. beginStructure();
  149. this.context = new JSONStreamContext(this.context, 1001);
  150. this.writer.write('{');
  151. }
  152. @Deprecated
  153. public void writeEndArray()
  154. {
  155. endArray();
  156. }
  157. @Deprecated
  158. public void writeEndObject()
  159. {
  160. endObject();
  161. }
  162. public void writeKey(String paramString)
  163. {
  164. writeObject(paramString);
  165. }
  166. public void writeObject(Object paramObject)
  167. {
  168. beforeWrite();
  169. this.serializer.write(paramObject);
  170. afterWriter();
  171. }
  172. public void writeObject(String paramString)
  173. {
  174. beforeWrite();
  175. this.serializer.write(paramString);
  176. afterWriter();
  177. }
  178. @Deprecated
  179. public void writeStartArray()
  180. {
  181. startArray();
  182. }
  183. @Deprecated
  184. public void writeStartObject()
  185. {
  186. startObject();
  187. }
  188. public void writeValue(Object paramObject)
  189. {
  190. writeObject(paramObject);
  191. }
  192. }
  193. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  194. * Qualified Name: com.alibaba.fastjson.JSONWriter
  195. * JD-Core Version: 0.6.2
  196. */