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

https://gitlab.com/qt-prometheus/qt-prometheus · Java · 155 lines · 144 code · 7 blank · 4 comment · 30 complexity · 77d5f1b266ba7360c4a4357fc1c98e84 MD5 · raw file

  1. package com.alibaba.fastjson.parser.deserializer;
  2. import com.alibaba.fastjson.JSONException;
  3. import com.alibaba.fastjson.parser.DefaultJSONParser;
  4. import com.alibaba.fastjson.parser.Feature;
  5. import com.alibaba.fastjson.parser.JSONLexer;
  6. import com.alibaba.fastjson.parser.JSONToken;
  7. import com.alibaba.fastjson.parser.ParseContext;
  8. import com.alibaba.fastjson.parser.ParserConfig;
  9. import com.alibaba.fastjson.util.FieldInfo;
  10. import java.lang.reflect.ParameterizedType;
  11. import java.lang.reflect.Type;
  12. import java.lang.reflect.TypeVariable;
  13. import java.util.ArrayList;
  14. import java.util.Collection;
  15. import java.util.Map;
  16. public class ArrayListTypeFieldDeserializer extends FieldDeserializer
  17. {
  18. private ObjectDeserializer deserializer;
  19. private int itemFastMatchToken;
  20. private final Type itemType;
  21. public ArrayListTypeFieldDeserializer(ParserConfig paramParserConfig, Class<?> paramClass, FieldInfo paramFieldInfo)
  22. {
  23. super(paramClass, paramFieldInfo);
  24. if ((getFieldType() instanceof ParameterizedType))
  25. {
  26. this.itemType = ((ParameterizedType)getFieldType()).getActualTypeArguments()[0];
  27. return;
  28. }
  29. this.itemType = Object.class;
  30. }
  31. public int getFastMatchToken()
  32. {
  33. return 14;
  34. }
  35. public final void parseArray(DefaultJSONParser paramDefaultJSONParser, Type paramType, Collection paramCollection)
  36. {
  37. Type localType = this.itemType;
  38. Object localObject3 = this.deserializer;
  39. Object localObject2 = localType;
  40. Object localObject1 = localObject3;
  41. ParameterizedType localParameterizedType;
  42. int k;
  43. int j;
  44. int m;
  45. if ((localType instanceof TypeVariable))
  46. {
  47. localObject2 = localType;
  48. localObject1 = localObject3;
  49. if ((paramType instanceof ParameterizedType))
  50. {
  51. localObject2 = (TypeVariable)localType;
  52. localParameterizedType = (ParameterizedType)paramType;
  53. localObject1 = null;
  54. if ((localParameterizedType.getRawType() instanceof Class))
  55. localObject1 = (Class)localParameterizedType.getRawType();
  56. k = -1;
  57. j = k;
  58. if (localObject1 != null)
  59. {
  60. i = 0;
  61. m = ((Class)localObject1).getTypeParameters().length;
  62. }
  63. }
  64. }
  65. while (true)
  66. {
  67. j = k;
  68. if (i < m)
  69. {
  70. if (localObject1.getTypeParameters()[i].getName().equals(((TypeVariable)localObject2).getName()))
  71. j = i;
  72. }
  73. else
  74. {
  75. localObject2 = localType;
  76. localObject1 = localObject3;
  77. if (j != -1)
  78. {
  79. localType = localParameterizedType.getActualTypeArguments()[j];
  80. localObject2 = localType;
  81. localObject1 = localObject3;
  82. if (!localType.equals(this.itemType))
  83. {
  84. localObject1 = paramDefaultJSONParser.getConfig().getDeserializer(localType);
  85. localObject2 = localType;
  86. }
  87. }
  88. localObject3 = paramDefaultJSONParser.getLexer();
  89. if (((JSONLexer)localObject3).token() == 14)
  90. break;
  91. paramCollection = "exepct '[', but " + JSONToken.name(((JSONLexer)localObject3).token());
  92. paramDefaultJSONParser = paramCollection;
  93. if (paramType != null)
  94. paramDefaultJSONParser = paramCollection + ", type : " + paramType;
  95. throw new JSONException(paramDefaultJSONParser);
  96. }
  97. i += 1;
  98. }
  99. paramType = (Type)localObject1;
  100. if (localObject1 == null)
  101. {
  102. paramType = paramDefaultJSONParser.getConfig().getDeserializer((Type)localObject2);
  103. this.deserializer = paramType;
  104. this.itemFastMatchToken = this.deserializer.getFastMatchToken();
  105. }
  106. ((JSONLexer)localObject3).nextToken(this.itemFastMatchToken);
  107. int i = 0;
  108. while (true)
  109. {
  110. if (((JSONLexer)localObject3).isEnabled(Feature.AllowArbitraryCommas))
  111. while (((JSONLexer)localObject3).token() == 16)
  112. ((JSONLexer)localObject3).nextToken();
  113. if (((JSONLexer)localObject3).token() == 15)
  114. {
  115. ((JSONLexer)localObject3).nextToken(16);
  116. return;
  117. }
  118. paramCollection.add(paramType.deserialze(paramDefaultJSONParser, (Type)localObject2, Integer.valueOf(i)));
  119. paramDefaultJSONParser.checkListResolve(paramCollection);
  120. if (((JSONLexer)localObject3).token() == 16)
  121. ((JSONLexer)localObject3).nextToken(this.itemFastMatchToken);
  122. i += 1;
  123. }
  124. }
  125. public void parseField(DefaultJSONParser paramDefaultJSONParser, Object paramObject, Type paramType, Map<String, Object> paramMap)
  126. {
  127. if (paramDefaultJSONParser.getLexer().token() == 8)
  128. {
  129. setValue(paramObject, null);
  130. return;
  131. }
  132. ArrayList localArrayList = new ArrayList();
  133. ParseContext localParseContext = paramDefaultJSONParser.getContext();
  134. paramDefaultJSONParser.setContext(localParseContext, paramObject, this.fieldInfo.getName());
  135. parseArray(paramDefaultJSONParser, paramType, localArrayList);
  136. paramDefaultJSONParser.setContext(localParseContext);
  137. if (paramObject == null)
  138. {
  139. paramMap.put(this.fieldInfo.getName(), localArrayList);
  140. return;
  141. }
  142. setValue(paramObject, localArrayList);
  143. }
  144. }
  145. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  146. * Qualified Name: com.alibaba.fastjson.parser.deserializer.ArrayListTypeFieldDeserializer
  147. * JD-Core Version: 0.6.2
  148. */