PageRenderTime 4458ms CodeModel.GetById 35ms RepoModel.GetById 2ms app.codeStats 0ms

/QingTingFanBianYi/src/com/alibaba/fastjson/parser/deserializer/ArrayDeserializer.java

https://gitlab.com/qt-prometheus/qt-prometheus
Java | 147 lines | 137 code | 6 blank | 4 comment | 30 complexity | 6ec309138e492a6c09beb03ae213429b MD5 | raw file
  1. package com.alibaba.fastjson.parser.deserializer;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.parser.DefaultJSONParser;
  4. import com.alibaba.fastjson.parser.JSONLexer;
  5. import com.alibaba.fastjson.parser.ParseContext;
  6. import com.alibaba.fastjson.util.TypeUtils;
  7. import java.lang.reflect.Array;
  8. import java.lang.reflect.GenericArrayType;
  9. import java.lang.reflect.ParameterizedType;
  10. import java.lang.reflect.Type;
  11. import java.lang.reflect.TypeVariable;
  12. import java.util.Collection;
  13. public class ArrayDeserializer
  14. implements ObjectDeserializer
  15. {
  16. public static final ArrayDeserializer instance = new ArrayDeserializer();
  17. private <T> T toObjectArray(DefaultJSONParser paramDefaultJSONParser, Class<?> paramClass, JSONArray paramJSONArray)
  18. {
  19. if (paramJSONArray == null)
  20. return null;
  21. int m = paramJSONArray.size();
  22. Object localObject4 = Array.newInstance(paramClass, m);
  23. int i = 0;
  24. if (i < m)
  25. {
  26. Object localObject3 = paramJSONArray.get(i);
  27. if (localObject3 == paramJSONArray)
  28. Array.set(localObject4, i, localObject4);
  29. while (true)
  30. {
  31. i += 1;
  32. break;
  33. if (paramClass.isArray())
  34. {
  35. if (paramClass.isInstance(localObject3));
  36. for (localObject1 = localObject3; ; localObject1 = toObjectArray(paramDefaultJSONParser, paramClass, (JSONArray)localObject3))
  37. {
  38. Array.set(localObject4, i, localObject1);
  39. break;
  40. }
  41. }
  42. Object localObject2 = null;
  43. Object localObject1 = localObject2;
  44. if ((localObject3 instanceof JSONArray))
  45. {
  46. int k = 0;
  47. JSONArray localJSONArray = (JSONArray)localObject3;
  48. int n = localJSONArray.size();
  49. int j = 0;
  50. while (j < n)
  51. {
  52. if (localJSONArray.get(j) == paramJSONArray)
  53. {
  54. localJSONArray.set(i, localObject4);
  55. k = 1;
  56. }
  57. j += 1;
  58. }
  59. localObject1 = localObject2;
  60. if (k != 0)
  61. localObject1 = localJSONArray.toArray();
  62. }
  63. localObject2 = localObject1;
  64. if (localObject1 == null)
  65. localObject2 = TypeUtils.cast(localObject3, paramClass, paramDefaultJSONParser.getConfig());
  66. Array.set(localObject4, i, localObject2);
  67. }
  68. }
  69. paramJSONArray.setRelatedArray(localObject4);
  70. paramJSONArray.setComponentType(paramClass);
  71. return localObject4;
  72. }
  73. public <T> T deserialze(DefaultJSONParser paramDefaultJSONParser, Type paramType, Object paramObject)
  74. {
  75. Object localObject1 = paramDefaultJSONParser.getLexer();
  76. if (((JSONLexer)localObject1).token() == 8)
  77. {
  78. ((JSONLexer)localObject1).nextToken(16);
  79. return null;
  80. }
  81. if (((JSONLexer)localObject1).token() == 4)
  82. {
  83. paramDefaultJSONParser = ((JSONLexer)localObject1).bytesValue();
  84. ((JSONLexer)localObject1).nextToken(16);
  85. return paramDefaultJSONParser;
  86. }
  87. if ((paramType instanceof GenericArrayType))
  88. {
  89. paramType = ((GenericArrayType)paramType).getGenericComponentType();
  90. if ((paramType instanceof TypeVariable))
  91. {
  92. TypeVariable localTypeVariable = (TypeVariable)paramType;
  93. paramType = paramDefaultJSONParser.getContext().getType();
  94. if ((paramType instanceof ParameterizedType))
  95. {
  96. ParameterizedType localParameterizedType = (ParameterizedType)paramType;
  97. Object localObject2 = localParameterizedType.getRawType();
  98. localObject1 = null;
  99. paramType = null;
  100. if ((localObject2 instanceof Class))
  101. {
  102. localObject2 = ((Class)localObject2).getTypeParameters();
  103. int i = 0;
  104. while (true)
  105. {
  106. localObject1 = paramType;
  107. if (i >= localObject2.length)
  108. break;
  109. if (localObject2[i].getName().equals(localTypeVariable.getName()))
  110. paramType = localParameterizedType.getActualTypeArguments()[i];
  111. i += 1;
  112. }
  113. }
  114. if ((localObject1 instanceof Class))
  115. paramType = (Class)localObject1;
  116. }
  117. }
  118. }
  119. while (true)
  120. {
  121. localObject1 = new JSONArray();
  122. paramDefaultJSONParser.parseArray(paramType, (Collection)localObject1, paramObject);
  123. return toObjectArray(paramDefaultJSONParser, paramType, (JSONArray)localObject1);
  124. paramType = Object.class;
  125. continue;
  126. paramType = Object.class;
  127. continue;
  128. paramType = (Class)paramType;
  129. continue;
  130. paramType = ((Class)paramType).getComponentType();
  131. }
  132. }
  133. public int getFastMatchToken()
  134. {
  135. return 14;
  136. }
  137. }
  138. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  139. * Qualified Name: com.alibaba.fastjson.parser.deserializer.ArrayDeserializer
  140. * JD-Core Version: 0.6.2
  141. */