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

https://gitlab.com/qt-prometheus/qt-prometheus · Java · 70 lines · 61 code · 5 blank · 4 comment · 12 complexity · 7b65d7fc7ec44244188999615cc118d7 MD5 · raw file

  1. package com.alibaba.fastjson.serializer;
  2. import java.io.IOException;
  3. import java.lang.reflect.Type;
  4. public class ArraySerializer
  5. implements ObjectSerializer
  6. {
  7. private final ObjectSerializer compObjectSerializer;
  8. private final Class<?> componentType;
  9. public ArraySerializer(Class<?> paramClass, ObjectSerializer paramObjectSerializer)
  10. {
  11. this.componentType = paramClass;
  12. this.compObjectSerializer = paramObjectSerializer;
  13. }
  14. public final void write(JSONSerializer paramJSONSerializer, Object paramObject1, Object paramObject2, Type paramType)
  15. throws IOException
  16. {
  17. SerializeWriter localSerializeWriter = paramJSONSerializer.getWriter();
  18. if (paramObject1 == null)
  19. {
  20. if (localSerializeWriter.isEnabled(SerializerFeature.WriteNullListAsEmpty))
  21. {
  22. localSerializeWriter.write("[]");
  23. return;
  24. }
  25. localSerializeWriter.writeNull();
  26. return;
  27. }
  28. Object[] arrayOfObject = (Object[])paramObject1;
  29. int j = arrayOfObject.length;
  30. paramType = paramJSONSerializer.getContext();
  31. paramJSONSerializer.setContext(paramType, paramObject1, paramObject2);
  32. while (true)
  33. {
  34. int i;
  35. try
  36. {
  37. localSerializeWriter.append('[');
  38. i = 0;
  39. if (i >= j)
  40. break label179;
  41. if (i != 0)
  42. localSerializeWriter.append(',');
  43. paramObject1 = arrayOfObject[i];
  44. if (paramObject1 == null)
  45. localSerializeWriter.append("null");
  46. else if (paramObject1.getClass() == this.componentType)
  47. this.compObjectSerializer.write(paramJSONSerializer, paramObject1, Integer.valueOf(i), null);
  48. }
  49. finally
  50. {
  51. paramJSONSerializer.setContext(paramType);
  52. }
  53. paramJSONSerializer.getObjectWriter(paramObject1.getClass()).write(paramJSONSerializer, paramObject1, Integer.valueOf(i), null);
  54. break label194;
  55. label179: localSerializeWriter.append(']');
  56. paramJSONSerializer.setContext(paramType);
  57. return;
  58. label194: i += 1;
  59. }
  60. }
  61. }
  62. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  63. * Qualified Name: com.alibaba.fastjson.serializer.ArraySerializer
  64. * JD-Core Version: 0.6.2
  65. */