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

https://gitlab.com/qt-prometheus/qt-prometheus · Java · 89 lines · 79 code · 6 blank · 4 comment · 13 complexity · 25d03bb63d2f9a2515102d0570c18d64 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.JSONLexer;
  5. import java.lang.reflect.ParameterizedType;
  6. import java.lang.reflect.Type;
  7. import java.util.AbstractCollection;
  8. import java.util.ArrayList;
  9. import java.util.Collection;
  10. import java.util.HashSet;
  11. import java.util.LinkedHashSet;
  12. import java.util.TreeSet;
  13. public class CollectionDeserializer
  14. implements ObjectDeserializer
  15. {
  16. public static final CollectionDeserializer instance = new CollectionDeserializer();
  17. public <T> T deserialze(DefaultJSONParser paramDefaultJSONParser, Type paramType, Object paramObject)
  18. {
  19. if (paramDefaultJSONParser.getLexer().token() == 8)
  20. {
  21. paramDefaultJSONParser.getLexer().nextToken(16);
  22. return null;
  23. }
  24. Class localClass = getRawClass(paramType);
  25. Object localObject;
  26. if (localClass == AbstractCollection.class)
  27. {
  28. localObject = new ArrayList();
  29. if (!(paramType instanceof ParameterizedType))
  30. break label213;
  31. }
  32. label213: for (paramType = ((ParameterizedType)paramType).getActualTypeArguments()[0]; ; paramType = Object.class)
  33. while (true)
  34. {
  35. paramDefaultJSONParser.parseArray(paramType, (Collection)localObject, paramObject);
  36. return localObject;
  37. if (localClass.isAssignableFrom(HashSet.class))
  38. {
  39. localObject = new HashSet();
  40. break;
  41. }
  42. if (localClass.isAssignableFrom(LinkedHashSet.class))
  43. {
  44. localObject = new LinkedHashSet();
  45. break;
  46. }
  47. if (localClass.isAssignableFrom(TreeSet.class))
  48. {
  49. localObject = new TreeSet();
  50. break;
  51. }
  52. if (localClass.isAssignableFrom(ArrayList.class))
  53. {
  54. localObject = new ArrayList();
  55. break;
  56. }
  57. try
  58. {
  59. localObject = (Collection)localClass.newInstance();
  60. }
  61. catch (Exception paramDefaultJSONParser)
  62. {
  63. throw new JSONException("create instane error, class " + localClass.getName());
  64. }
  65. }
  66. }
  67. public int getFastMatchToken()
  68. {
  69. return 14;
  70. }
  71. public Class<?> getRawClass(Type paramType)
  72. {
  73. if ((paramType instanceof Class))
  74. return (Class)paramType;
  75. if ((paramType instanceof ParameterizedType))
  76. return getRawClass(((ParameterizedType)paramType).getRawType());
  77. throw new JSONException("TODO");
  78. }
  79. }
  80. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  81. * Qualified Name: com.alibaba.fastjson.parser.deserializer.CollectionDeserializer
  82. * JD-Core Version: 0.6.2
  83. */