PageRenderTime 73ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/QingTingFanBianYi/src/fm/qingting/framework/data/ServerConfig.java

https://gitlab.com/qt-prometheus/qt-prometheus
Java | 300 lines | 184 code | 16 blank | 100 comment | 30 complexity | d2b7a519d04df407141e84c50192e90d MD5 | raw file
  1. package fm.qingting.framework.data;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.alibaba.fastjson.JSONObject;
  5. import java.io.InputStream;
  6. import java.util.ArrayList;
  7. import java.util.Collection;
  8. import java.util.HashMap;
  9. import java.util.Iterator;
  10. import java.util.List;
  11. public class ServerConfig
  12. {
  13. private static ServerConfig instance = null;
  14. private HashMap<String, String> allDefaultProxies = new HashMap();
  15. private HashMap<String, List<String>> allDefaultRoots = new HashMap();
  16. private HashMap<String, MutableRequestTrait> requests = new HashMap();
  17. public static ServerConfig getInstance()
  18. {
  19. try
  20. {
  21. if (instance == null)
  22. instance = new ServerConfig();
  23. ServerConfig localServerConfig = instance;
  24. return localServerConfig;
  25. }
  26. finally
  27. {
  28. }
  29. }
  30. // ERROR //
  31. private void parse(InputStream paramInputStream)
  32. {
  33. // Byte code:
  34. // 0: aload_0
  35. // 1: getfield 26 fm/qingting/framework/data/ServerConfig:allDefaultRoots Ljava/util/HashMap;
  36. // 4: invokevirtual 42 java/util/HashMap:clear ()V
  37. // 7: aload_0
  38. // 8: getfield 28 fm/qingting/framework/data/ServerConfig:requests Ljava/util/HashMap;
  39. // 11: invokevirtual 42 java/util/HashMap:clear ()V
  40. // 14: new 44 java/io/ByteArrayOutputStream
  41. // 17: dup
  42. // 18: invokespecial 45 java/io/ByteArrayOutputStream:<init> ()V
  43. // 21: astore_2
  44. // 22: sipush 1024
  45. // 25: newarray byte
  46. // 27: astore_3
  47. // 28: aload_1
  48. // 29: aload_3
  49. // 30: iconst_0
  50. // 31: aload_3
  51. // 32: arraylength
  52. // 33: invokevirtual 51 java/io/InputStream:read ([BII)I
  53. // 36: istore 4
  54. // 38: iload 4
  55. // 40: iconst_m1
  56. // 41: if_icmpne +25 -> 66
  57. // 44: aload_0
  58. // 45: new 53 java/lang/String
  59. // 48: dup
  60. // 49: aload_2
  61. // 50: invokevirtual 57 java/io/ByteArrayOutputStream:toByteArray ()[B
  62. // 53: ldc 59
  63. // 55: invokespecial 62 java/lang/String:<init> ([BLjava/lang/String;)V
  64. // 58: invokespecial 66 fm/qingting/framework/data/ServerConfig:parseJson (Ljava/lang/String;)V
  65. // 61: aload_1
  66. // 62: invokevirtual 69 java/io/InputStream:close ()V
  67. // 65: return
  68. // 66: aload_2
  69. // 67: aload_3
  70. // 68: iconst_0
  71. // 69: iload 4
  72. // 71: invokevirtual 73 java/io/ByteArrayOutputStream:write ([BII)V
  73. // 74: goto -46 -> 28
  74. // 77: astore_2
  75. // 78: aload_2
  76. // 79: invokevirtual 76 java/io/UnsupportedEncodingException:printStackTrace ()V
  77. // 82: aload_1
  78. // 83: invokevirtual 69 java/io/InputStream:close ()V
  79. // 86: return
  80. // 87: astore_1
  81. // 88: aload_1
  82. // 89: invokevirtual 77 java/io/IOException:printStackTrace ()V
  83. // 92: return
  84. // 93: astore_2
  85. // 94: aload_2
  86. // 95: invokevirtual 77 java/io/IOException:printStackTrace ()V
  87. // 98: aload_1
  88. // 99: invokevirtual 69 java/io/InputStream:close ()V
  89. // 102: return
  90. // 103: astore_1
  91. // 104: aload_1
  92. // 105: invokevirtual 77 java/io/IOException:printStackTrace ()V
  93. // 108: return
  94. // 109: astore_2
  95. // 110: aload_1
  96. // 111: invokevirtual 69 java/io/InputStream:close ()V
  97. // 114: aload_2
  98. // 115: athrow
  99. // 116: astore_1
  100. // 117: aload_1
  101. // 118: invokevirtual 77 java/io/IOException:printStackTrace ()V
  102. // 121: goto -7 -> 114
  103. // 124: astore_1
  104. // 125: aload_1
  105. // 126: invokevirtual 77 java/io/IOException:printStackTrace ()V
  106. // 129: return
  107. //
  108. // Exception table:
  109. // from to target type
  110. // 14 28 77 java/io/UnsupportedEncodingException
  111. // 28 38 77 java/io/UnsupportedEncodingException
  112. // 44 61 77 java/io/UnsupportedEncodingException
  113. // 66 74 77 java/io/UnsupportedEncodingException
  114. // 82 86 87 java/io/IOException
  115. // 14 28 93 java/io/IOException
  116. // 28 38 93 java/io/IOException
  117. // 44 61 93 java/io/IOException
  118. // 66 74 93 java/io/IOException
  119. // 98 102 103 java/io/IOException
  120. // 14 28 109 finally
  121. // 28 38 109 finally
  122. // 44 61 109 finally
  123. // 66 74 109 finally
  124. // 78 82 109 finally
  125. // 94 98 109 finally
  126. // 110 114 116 java/io/IOException
  127. // 61 65 124 java/io/IOException
  128. }
  129. private void parseJson(String paramString)
  130. {
  131. try
  132. {
  133. paramString = (JSONObject)JSON.parse(paramString);
  134. Object localObject1 = paramString.getJSONArray("defaultroots");
  135. Object localObject2 = new ArrayList();
  136. int i = 0;
  137. while (true)
  138. {
  139. if (i >= ((JSONArray)localObject1).size())
  140. {
  141. setDefaultRoots((List)localObject2, "net");
  142. localObject2 = paramString.getJSONArray("requests");
  143. i = 0;
  144. if (i < ((JSONArray)localObject2).size())
  145. break;
  146. return;
  147. }
  148. ((List)localObject2).add(((JSONArray)localObject1).getJSONObject(i).getString("root").trim());
  149. i += 1;
  150. }
  151. Object localObject3 = ((JSONArray)localObject2).getJSONObject(i);
  152. String str1 = ((JSONObject)localObject3).getString("type");
  153. Object localObject4 = ((JSONObject)localObject3).getString("command");
  154. String str2 = ((JSONObject)localObject3).getString("datatype");
  155. String str3 = ((JSONObject)localObject3).getString("datasource");
  156. String str4 = ((JSONObject)localObject3).getString("method");
  157. localObject1 = ((JSONObject)localObject3).getString("encoding");
  158. paramString = (String)localObject1;
  159. if (localObject1 == null)
  160. paramString = "utf-8";
  161. localObject1 = ((JSONObject)localObject3).getString("commandparamencode");
  162. String str5 = ((JSONObject)localObject3).getString("proxy");
  163. ArrayList localArrayList = new ArrayList();
  164. if (localObject4 != null)
  165. localArrayList.add(localObject4);
  166. localObject4 = new ArrayList();
  167. localObject3 = ((JSONObject)localObject3).getJSONArray("roots");
  168. int j;
  169. if (localObject3 != null)
  170. j = 0;
  171. while (true)
  172. {
  173. if (j >= ((JSONArray)localObject3).size())
  174. {
  175. addRequest(str1, str3, localArrayList, str4, str2, (List)localObject4, paramString, str5, (String)localObject1);
  176. i += 1;
  177. break;
  178. }
  179. String str6 = ((JSONArray)localObject3).getJSONObject(j).getString("root");
  180. if (str6 != null)
  181. ((List)localObject4).add(str6);
  182. j += 1;
  183. }
  184. }
  185. catch (Exception paramString)
  186. {
  187. paramString.printStackTrace();
  188. }
  189. }
  190. public void addRequest(String paramString1, String paramString2, List<String> paramList1, String paramString3, String paramString4, List<String> paramList2, String paramString5, String paramString6, String paramString7)
  191. {
  192. paramString2 = new MutableRequestTrait(paramString1, paramString2, paramList1, paramString3, paramString4, paramList2, (List)this.allDefaultRoots.get(paramString2), paramString5, paramString6, paramString7);
  193. this.requests.put(paramString1, paramString2);
  194. }
  195. public String getDefaultProxy(String paramString)
  196. {
  197. if (paramString == null)
  198. return null;
  199. return (String)this.allDefaultProxies.get(paramString);
  200. }
  201. public RequestTrait getRequestTrait(String paramString)
  202. {
  203. return (RequestTrait)this.requests.get(paramString);
  204. }
  205. public void setDefaultProxy(String paramString1, String paramString2)
  206. {
  207. this.allDefaultProxies.put(paramString1, paramString2);
  208. }
  209. public void setDefaultRoot(String paramString1, String paramString2)
  210. {
  211. ArrayList localArrayList = new ArrayList();
  212. localArrayList.add(paramString1);
  213. setDefaultRoots(localArrayList, paramString2);
  214. }
  215. public void setDefaultRoots(List<String> paramList, String paramString)
  216. {
  217. Object localObject2 = (List)this.allDefaultRoots.get(paramString);
  218. Object localObject1 = localObject2;
  219. if (localObject2 == null)
  220. {
  221. localObject1 = new ArrayList();
  222. this.allDefaultRoots.put(paramString, localObject1);
  223. }
  224. ((List)localObject1).clear();
  225. paramList = paramList.iterator();
  226. if (!paramList.hasNext())
  227. paramList = this.requests.values().iterator();
  228. while (true)
  229. {
  230. if (!paramList.hasNext())
  231. {
  232. return;
  233. ((List)localObject1).add(new String((String)paramList.next()));
  234. break;
  235. }
  236. localObject2 = (MutableRequestTrait)paramList.next();
  237. if (((MutableRequestTrait)localObject2).dataSource.equalsIgnoreCase(paramString))
  238. ((MutableRequestTrait)localObject2).setDefaultRoots((List)localObject1);
  239. }
  240. }
  241. public void setEncoding(String paramString1, String paramString2)
  242. {
  243. Iterator localIterator = this.requests.values().iterator();
  244. while (true)
  245. {
  246. if (!localIterator.hasNext())
  247. return;
  248. MutableRequestTrait localMutableRequestTrait = (MutableRequestTrait)localIterator.next();
  249. if (localMutableRequestTrait.dataSource.equalsIgnoreCase(paramString2))
  250. localMutableRequestTrait.setEncoding(paramString1);
  251. }
  252. }
  253. public void setRequestCommands(List<String> paramList, String paramString)
  254. {
  255. paramString = (MutableRequestTrait)this.requests.get(paramString);
  256. if (paramString == null)
  257. return;
  258. paramString.setCommands(paramList);
  259. }
  260. public void setRequestRoots(List<String> paramList, String paramString)
  261. {
  262. paramString = (MutableRequestTrait)this.requests.get(paramString);
  263. if (paramString == null)
  264. return;
  265. paramString.setRoots(paramList);
  266. }
  267. public void setServerConfig(InputStream paramInputStream)
  268. {
  269. try
  270. {
  271. parse(paramInputStream);
  272. return;
  273. }
  274. finally
  275. {
  276. paramInputStream = finally;
  277. }
  278. throw paramInputStream;
  279. }
  280. }
  281. /* Location: C:\Users\User\dex2jar-2.0\dex\qting\classes-dex2jar.jar
  282. * Qualified Name: fm.qingting.framework.data.ServerConfig
  283. * JD-Core Version: 0.6.2
  284. */