Пример #1
0
 /**
  * Get parameters
  *
  * @param hit String
  * @return HashMap
  */
 static LinkedHashMap<String, String> getParameters(String hit) {
   LinkedHashMap<String, String> map = new LinkedHashMap<>();
   try {
     URL url = new URL(hit);
     map.put("ssl", url.getProtocol().equals("http") ? "Off" : "On");
     map.put("log", url.getHost());
     String[] queryComponents = url.getQuery().split("&");
     for (String queryComponent : queryComponents) {
       String[] elem = queryComponent.split("=");
       if (elem.length > 1) {
         elem[1] = Tool.percentDecode(elem[1]);
         if (Tool.parseJSON(elem[1]) instanceof JSONObject) {
           JSONObject json = (JSONObject) Tool.parseJSON(elem[1]);
           if (json != null && elem[0].equals(Hit.HitParam.JSON.stringValue())) {
             map.put(elem[0], json.toString(3));
           } else {
             map.put(elem[0], elem[1]);
           }
         } else {
           map.put(elem[0], elem[1]);
         }
       } else {
         map.put(elem[0], "");
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return map;
 }