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

https://gitlab.com/qt-prometheus/qt-prometheus · Java · 118 lines · 110 code · 4 blank · 4 comment · 21 complexity · 38798e57dce5b46dba89ef2d482c0ee3 MD5 · raw file

  1. package com.alibaba.fastjson.serializer;
  2. import java.io.IOException;
  3. import java.lang.reflect.Type;
  4. public class ObjectArraySerializer
  5. implements ObjectSerializer
  6. {
  7. public static final ObjectArraySerializer instance = new ObjectArraySerializer();
  8. public final void write(JSONSerializer paramJSONSerializer, Object paramObject1, Object paramObject2, Type paramType)
  9. throws IOException
  10. {
  11. SerializeWriter localSerializeWriter = paramJSONSerializer.getWriter();
  12. Object[] arrayOfObject = (Object[])paramObject1;
  13. if (paramObject1 == null)
  14. {
  15. if (localSerializeWriter.isEnabled(SerializerFeature.WriteNullListAsEmpty))
  16. {
  17. localSerializeWriter.write("[]");
  18. return;
  19. }
  20. localSerializeWriter.writeNull();
  21. return;
  22. }
  23. int j = arrayOfObject.length;
  24. int k = j - 1;
  25. if (k == -1)
  26. {
  27. localSerializeWriter.append("[]");
  28. return;
  29. }
  30. SerialContext localSerialContext = paramJSONSerializer.getContext();
  31. paramJSONSerializer.setContext(localSerialContext, paramObject1, paramObject2);
  32. paramObject2 = null;
  33. paramObject1 = null;
  34. while (true)
  35. {
  36. int i;
  37. Object localObject;
  38. try
  39. {
  40. localSerializeWriter.append('[');
  41. if (localSerializeWriter.isEnabled(SerializerFeature.PrettyFormat))
  42. {
  43. paramJSONSerializer.incrementIndent();
  44. paramJSONSerializer.println();
  45. i = 0;
  46. if (i < j)
  47. {
  48. if (i != 0)
  49. {
  50. localSerializeWriter.write(',');
  51. paramJSONSerializer.println();
  52. }
  53. paramJSONSerializer.write(arrayOfObject[i]);
  54. i += 1;
  55. continue;
  56. }
  57. paramJSONSerializer.decrementIdent();
  58. paramJSONSerializer.println();
  59. localSerializeWriter.write(']');
  60. return;
  61. }
  62. i = 0;
  63. if (i >= k)
  64. break label300;
  65. localObject = arrayOfObject[i];
  66. if (localObject == null)
  67. {
  68. localSerializeWriter.append("null,");
  69. }
  70. else if (paramJSONSerializer.containsReference(localObject))
  71. {
  72. paramJSONSerializer.writeReference(localObject);
  73. localSerializeWriter.append(',');
  74. }
  75. }
  76. finally
  77. {
  78. paramJSONSerializer.setContext(localSerialContext);
  79. }
  80. paramType = localObject.getClass();
  81. if (paramType == paramObject2)
  82. {
  83. paramObject1.write(paramJSONSerializer, localObject, null, null);
  84. }
  85. else
  86. {
  87. paramObject2 = paramType;
  88. paramObject1 = paramJSONSerializer.getObjectWriter(paramType);
  89. paramObject1.write(paramJSONSerializer, localObject, null, null);
  90. continue;
  91. label300: paramObject1 = arrayOfObject[k];
  92. if (paramObject1 == null)
  93. {
  94. localSerializeWriter.append("null]");
  95. paramJSONSerializer.setContext(localSerialContext);
  96. return;
  97. }
  98. if (paramJSONSerializer.containsReference(paramObject1))
  99. paramJSONSerializer.writeReference(paramObject1);
  100. while (true)
  101. {
  102. localSerializeWriter.append(']');
  103. break;
  104. paramJSONSerializer.writeWithFieldName(paramObject1, Integer.valueOf(k));
  105. }
  106. i += 1;
  107. }
  108. }
  109. }
  110. }
  111. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  112. * Qualified Name: com.alibaba.fastjson.serializer.ObjectArraySerializer
  113. * JD-Core Version: 0.6.2
  114. */