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

https://gitlab.com/qt-prometheus/qt-prometheus · Java · 75 lines · 66 code · 5 blank · 4 comment · 44 complexity · cc42074541752b2f3fc959fed29748a9 MD5 · raw file

  1. package com.alibaba.fastjson.parser.deserializer;
  2. import com.alibaba.fastjson.parser.DefaultJSONParser;
  3. import com.alibaba.fastjson.parser.JSONLexer;
  4. import com.alibaba.fastjson.util.TypeUtils;
  5. import java.lang.reflect.Type;
  6. import java.math.BigDecimal;
  7. public class NumberDeserializer
  8. implements ObjectDeserializer
  9. {
  10. public static final NumberDeserializer instance = new NumberDeserializer();
  11. public <T> T deserialze(DefaultJSONParser paramDefaultJSONParser, Type paramType, Object paramObject)
  12. {
  13. JSONLexer localJSONLexer = paramDefaultJSONParser.getLexer();
  14. if (localJSONLexer.token() == 2)
  15. if ((paramType == Double.TYPE) || (paramType == Double.class))
  16. {
  17. paramDefaultJSONParser = localJSONLexer.numberString();
  18. localJSONLexer.nextToken(16);
  19. paramDefaultJSONParser = Double.valueOf(Double.parseDouble(paramDefaultJSONParser));
  20. }
  21. do
  22. {
  23. return paramDefaultJSONParser;
  24. long l = localJSONLexer.longValue();
  25. localJSONLexer.nextToken(16);
  26. if ((paramType == Short.TYPE) || (paramType == Short.class))
  27. return Short.valueOf((short)(int)l);
  28. if ((paramType == Byte.TYPE) || (paramType == Byte.class))
  29. return Byte.valueOf((byte)(int)l);
  30. if ((l >= -2147483648L) && (l <= 2147483647L))
  31. return Integer.valueOf((int)l);
  32. return Long.valueOf(l);
  33. if (localJSONLexer.token() != 3)
  34. break label258;
  35. if ((paramType == Double.TYPE) || (paramType == Double.class))
  36. {
  37. paramDefaultJSONParser = localJSONLexer.numberString();
  38. localJSONLexer.nextToken(16);
  39. return Double.valueOf(Double.parseDouble(paramDefaultJSONParser));
  40. }
  41. paramObject = localJSONLexer.decimalValue();
  42. localJSONLexer.nextToken(16);
  43. if ((paramType == Short.TYPE) || (paramType == Short.class))
  44. return Short.valueOf(paramObject.shortValue());
  45. if (paramType == Byte.TYPE)
  46. break;
  47. paramDefaultJSONParser = paramObject;
  48. }
  49. while (paramType != Byte.class);
  50. return Byte.valueOf(paramObject.byteValue());
  51. label258: paramDefaultJSONParser = paramDefaultJSONParser.parse();
  52. if (paramDefaultJSONParser == null)
  53. return null;
  54. if ((paramType == Double.TYPE) || (paramType == Double.class))
  55. return TypeUtils.castToDouble(paramDefaultJSONParser);
  56. if ((paramType == Short.TYPE) || (paramType == Short.class))
  57. return TypeUtils.castToShort(paramDefaultJSONParser);
  58. if ((paramType == Byte.TYPE) || (paramType == Byte.class))
  59. return TypeUtils.castToByte(paramDefaultJSONParser);
  60. return TypeUtils.castToBigDecimal(paramDefaultJSONParser);
  61. }
  62. public int getFastMatchToken()
  63. {
  64. return 2;
  65. }
  66. }
  67. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  68. * Qualified Name: com.alibaba.fastjson.parser.deserializer.NumberDeserializer
  69. * JD-Core Version: 0.6.2
  70. */