PageRenderTime 54ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://gitlab.com/qt-prometheus/qt-prometheus
Java | 184 lines | 176 code | 4 blank | 4 comment | 37 complexity | 8f4ed6f170a99f2f3e9d5064f1bc8dd2 MD5 | raw file
  1. package com.alibaba.fastjson.serializer;
  2. import java.io.IOException;
  3. import java.lang.reflect.ParameterizedType;
  4. import java.lang.reflect.Type;
  5. import java.util.List;
  6. public final class ListSerializer
  7. implements ObjectSerializer
  8. {
  9. public static final ListSerializer instance = new ListSerializer();
  10. public final void write(JSONSerializer paramJSONSerializer, Object paramObject1, Object paramObject2, Type paramType)
  11. throws IOException
  12. {
  13. boolean bool = paramJSONSerializer.isEnabled(SerializerFeature.WriteClassName);
  14. SerializeWriter localSerializeWriter = paramJSONSerializer.getWriter();
  15. Object localObject2 = null;
  16. Object localObject1 = localObject2;
  17. if (bool)
  18. {
  19. localObject1 = localObject2;
  20. if ((paramType instanceof ParameterizedType))
  21. localObject1 = ((ParameterizedType)paramType).getActualTypeArguments()[0];
  22. }
  23. if (paramObject1 == null)
  24. {
  25. if (localSerializeWriter.isEnabled(SerializerFeature.WriteNullListAsEmpty))
  26. {
  27. localSerializeWriter.write("[]");
  28. return;
  29. }
  30. localSerializeWriter.writeNull();
  31. return;
  32. }
  33. localObject2 = (List)paramObject1;
  34. int j = ((List)localObject2).size();
  35. int k = j - 1;
  36. if (k == -1)
  37. {
  38. localSerializeWriter.append("[]");
  39. return;
  40. }
  41. paramType = paramJSONSerializer.getContext();
  42. paramJSONSerializer.setContext(paramType, paramObject1, paramObject2);
  43. int i;
  44. Object localObject3;
  45. Object localObject4;
  46. if (j > 1)
  47. {
  48. try
  49. {
  50. if (!localSerializeWriter.isEnabled(SerializerFeature.PrettyFormat))
  51. break label310;
  52. localSerializeWriter.append('[');
  53. paramJSONSerializer.incrementIndent();
  54. i = 0;
  55. if (i >= j)
  56. break label287;
  57. if (i != 0)
  58. localSerializeWriter.append(',');
  59. paramJSONSerializer.println();
  60. localObject3 = ((List)localObject2).get(i);
  61. if (localObject3 != null)
  62. if (paramJSONSerializer.containsReference(localObject3))
  63. {
  64. paramJSONSerializer.writeReference(localObject3);
  65. }
  66. else
  67. {
  68. localObject4 = paramJSONSerializer.getObjectWriter(localObject3.getClass());
  69. paramJSONSerializer.setContext(new SerialContext(paramType, paramObject1, paramObject2));
  70. ((ObjectSerializer)localObject4).write(paramJSONSerializer, localObject3, Integer.valueOf(i), (Type)localObject1);
  71. }
  72. }
  73. finally
  74. {
  75. paramJSONSerializer.setContext(paramType);
  76. }
  77. paramJSONSerializer.getWriter().writeNull();
  78. break label694;
  79. label287: paramJSONSerializer.decrementIdent();
  80. paramJSONSerializer.println();
  81. localSerializeWriter.append(']');
  82. paramJSONSerializer.setContext(paramType);
  83. }
  84. else
  85. {
  86. label310: localSerializeWriter.append('[');
  87. i = 0;
  88. }
  89. while (true)
  90. {
  91. if (i < k)
  92. {
  93. localObject3 = ((List)localObject2).get(i);
  94. if (localObject3 == null)
  95. {
  96. localSerializeWriter.append("null,");
  97. }
  98. else
  99. {
  100. localObject4 = localObject3.getClass();
  101. if (localObject4 == Integer.class)
  102. {
  103. localSerializeWriter.writeIntAndChar(((Integer)localObject3).intValue(), ',');
  104. }
  105. else if (localObject4 == Long.class)
  106. {
  107. long l = ((Long)localObject3).longValue();
  108. if (bool)
  109. {
  110. localSerializeWriter.writeLongAndChar(l, 'L');
  111. localSerializeWriter.write(',');
  112. }
  113. else
  114. {
  115. localSerializeWriter.writeLongAndChar(l, ',');
  116. }
  117. }
  118. else
  119. {
  120. paramJSONSerializer.setContext(new SerialContext(paramType, paramObject1, paramObject2));
  121. if (paramJSONSerializer.containsReference(localObject3))
  122. paramJSONSerializer.writeReference(localObject3);
  123. while (true)
  124. {
  125. localSerializeWriter.append(',');
  126. break;
  127. paramJSONSerializer.getObjectWriter(localObject3.getClass()).write(paramJSONSerializer, localObject3, Integer.valueOf(i), (Type)localObject1);
  128. }
  129. }
  130. }
  131. }
  132. else
  133. {
  134. localObject2 = ((List)localObject2).get(k);
  135. if (localObject2 == null)
  136. localSerializeWriter.append("null]");
  137. while (true)
  138. {
  139. paramJSONSerializer.setContext(paramType);
  140. return;
  141. localObject3 = localObject2.getClass();
  142. if (localObject3 == Integer.class)
  143. {
  144. localSerializeWriter.writeIntAndChar(((Integer)localObject2).intValue(), ']');
  145. }
  146. else
  147. {
  148. if (localObject3 != Long.class)
  149. break;
  150. if (bool)
  151. {
  152. localSerializeWriter.writeLongAndChar(((Long)localObject2).longValue(), 'L');
  153. localSerializeWriter.write(']');
  154. }
  155. else
  156. {
  157. localSerializeWriter.writeLongAndChar(((Long)localObject2).longValue(), ']');
  158. }
  159. }
  160. }
  161. paramJSONSerializer.setContext(new SerialContext(paramType, paramObject1, paramObject2));
  162. if (paramJSONSerializer.containsReference(localObject2))
  163. paramJSONSerializer.writeReference(localObject2);
  164. while (true)
  165. {
  166. localSerializeWriter.append(']');
  167. break;
  168. paramJSONSerializer.getObjectWriter(localObject2.getClass()).write(paramJSONSerializer, localObject2, Integer.valueOf(k), (Type)localObject1);
  169. }
  170. label694: i += 1;
  171. break;
  172. }
  173. i += 1;
  174. }
  175. }
  176. }
  177. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  178. * Qualified Name: com.alibaba.fastjson.serializer.ListSerializer
  179. * JD-Core Version: 0.6.2
  180. */