List of usage examples for java.util HashMap containsKey
public boolean containsKey(Object key)
From source file:MSUmpire.DIA.RTAlignedPepIonMapping.java
public void GenerateMappedPepIonToList(HashMap<String, PepIonID> ListA, HashMap<String, PepIonID> ListB) { Logger.getRootLogger().info(//from ww w .jav a 2 s . c o m "Mapping predicted peptide ions for " + FilenameUtils.getBaseName(LCMSB.mzXMLFileName) + "..."); if (!regression.valid()) { return; } for (PepIonID pepion : LCMSA.GetPepIonList().values()) { if (!LCMSB.GetPepIonList().containsKey(pepion.GetKey())) { PepIonID predictedPepIon = null; if (ListB.containsKey(pepion.GetKey())) { predictedPepIon = ListB.get(pepion.GetKey()); } else { predictedPepIon = pepion.ClonePepIonID(); ListB.put(pepion.GetKey(), predictedPepIon); } //System.out.println(pepion.GetIDRT()); XYZData predict = regression.GetPredictTimeSDYByTimelist(pepion.GetIDRT()); float PRT = predict.getY(); boolean added = true; for (float rt : predictedPepIon.PredictRT) { if (Math.abs(PRT - rt) < 0.1f) { added = false; } } if (added) { predictedPepIon.PredictRT.add(PRT); } predictedPepIon.SetRTSD(predict.getZ()); } } Logger.getRootLogger().info( "Mapping predicted peptide ions for " + FilenameUtils.getBaseName(LCMSA.mzXMLFileName) + "..."); for (PepIonID pepion : LCMSB.GetPepIonList().values()) { if (!LCMSA.GetPepIonList().containsKey(pepion.GetKey())) { PepIonID predictedPepIon = null; if (ListA.containsKey(pepion.GetKey())) { predictedPepIon = ListA.get(pepion.GetKey()); } else { predictedPepIon = pepion.ClonePepIonID(); ListA.put(pepion.GetKey(), predictedPepIon); } XYZData predict = regression.GetPredictTimeSDXByTimelist(pepion.GetIDRT()); float PRT = predict.getY(); boolean added = true; for (float rt : predictedPepIon.PredictRT) { if (Math.abs(PRT - rt) < 0.1f) { added = false; } } if (added) { predictedPepIon.PredictRT.add(PRT); } predictedPepIon.SetRTSD(predict.getZ()); } } }
From source file:com.predic8.membrane.core.interceptor.authentication.session.LDAPUserDataProvider.java
/** * @throws NoSuchElementException if no user could be found with the given login * @throws AuthenticationException if the password does not match * @throws CommunicationException e.g. on server timeout * @throws NamingException on any other LDAP error *//*from w w w.j a va 2 s .com*/ private HashMap<String, String> auth(String login, String password) throws NamingException { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); env.put("com.sun.jndi.ldap.read.timeout", timeout); env.put("com.sun.jndi.ldap.connect.timeout", connectTimeout); if (binddn != null) { env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, binddn); env.put(Context.SECURITY_CREDENTIALS, bindpw); } HashMap<String, String> userAttrs = new HashMap<String, String>(); String uid; DirContext ctx = new InitialDirContext(env); try { uid = searchUser(login, userAttrs, ctx); } finally { ctx.close(); } if (passwordAttribute != null) { if (!userAttrs.containsKey("_pass")) throw new NoSuchElementException(); String pass = userAttrs.get("_pass"); if (pass == null || !pass.startsWith("{x-plain}")) throw new NoSuchElementException(); log.debug("found password"); pass = pass.substring(9); if (!pass.equals(password)) throw new NoSuchElementException(); userAttrs.remove("_pass"); } else { env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, uid + "," + base); env.put(Context.SECURITY_CREDENTIALS, password); DirContext ctx2 = new InitialDirContext(env); try { if (readAttributesAsSelf) searchUser(login, userAttrs, ctx2); } finally { ctx2.close(); } } return userAttrs; }
From source file:net.geant.edugain.filter.EduGAINFilter.java
private void fromHome(HttpServletRequest request, HttpServletResponse response) { String target = request.getParameter("TARGET"); AuthenticationResponse eduGAINresponse = null; try {// w w w . j a v a 2 s .c o m eduGAINresponse = getSAMLResponse(request.getParameter("SAMLResponse").getBytes()); } catch (Exception e) { e.printStackTrace(); try { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Unable to parse eduGAIN response"); return; } catch (IOException e1) { this.log.error("Invalid eduGAIN response; unable to forward user to error page"); } } if ((eduGAINresponse != null) && eduGAINresponse.getResult().equals(AuthenticationResponse.EDUGAIN_NAMESPACE_RESULT_ACCEPTED)) { try { Cookie lcook = getCookie(request, response, "statecook"); HashMap attrs = validateCookie(lcook, "statecook"); if ((attrs != null) && (attrs.containsKey("KEY"))) { String key = (String) attrs.get("KEY"); HashMap<String, String> oldRequest = (HashMap<String, String>) this.loadRequest(key); String oldURL = reconstructRequest(oldRequest, response); attrs = parseAttrs(eduGAINresponse); request.getSession().setAttribute("SAMLResponse", eduGAINresponse.toSAML()); attachCookies("lcook", attrs, response, false); attachCookies("statecook", null, response, true); //addAttributes(attrs,request.getSession()); if (!(oldURL.equals("")) && (oldRequest != null) && !(response.isCommitted())) response.sendRedirect(oldURL); else response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unable to load old request"); } else response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Connection timed out"); } catch (IOException ioe) { try { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "State cookie not found"); } catch (IOException e) { this.log.error("State cookie not found"); ioe.printStackTrace(); } } catch (Exception e) { try { e.printStackTrace(); response.sendError(HttpServletResponse.SC_REQUEST_TIMEOUT, "Process timed out"); } catch (IOException e1) { this.log.error("Process timed out"); e1.printStackTrace(); } } } else try { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Invalid authentication at home domain"); } catch (IOException e) { this.log.error("Invalid authentication at home domain"); e.printStackTrace(); } catch (IllegalStateException ex) { this.log.error("Unable to forward user to error page"); ex.printStackTrace(); } }
From source file:in.sc.main.CategoryController.java
@RequestMapping(value = { "{category:[a-zA-Z0-9-]+}/{url:[a-zA-Z0-9-]+}" }) public String getParseUrl(Model model, @PathVariable String category, @PathVariable String url, HttpServletRequest request, @RequestParam(required = false) String filterQ) { String unique_id = null;//w w w . j av a2 s. co m String page = null; int found = 0; HashMap inputMap = new HashMap(); HashMap catPatternMap = daoutils.getCatPatternMap(); int pageNo = 1; if (request.getParameter("p") != null) { pageNo = Integer.parseInt(request.getParameter("p")); } int from = ((pageNo - 1) * 20); inputMap.put(ProductHelper.from, from); request.setAttribute("pageNo", (pageNo + 1)); try { if (catPatternMap.containsKey(category)) { LinkedList pList = (LinkedList) catPatternMap.get(category); inputMap.put(ProductHelper.category, pList.get(0)); for (int i = 1; i < 5; i++) { Pattern pa = Pattern.compile((String) pList.get(i)); Matcher matcher = pa.matcher(url); if (matcher.matches()) { found++; if (i == 2) { unique_id = matcher.group(1); inputMap.put(ProductHelper.unique_id, unique_id); page = singleMobile(inputMap, model); break; } if (i == 3) { String brandName = matcher.group(1); ArrayList bbList = new ArrayList(); bbList.add(brandName); inputMap.put(ProductHelper.brandname, bbList); model.addAttribute(ProductHelper.brandname, brandName); page = productList(unique_id, model, inputMap); break; } if (i == 1) { inputMap.put("filterQ", filterQ); page = productList(unique_id, model, inputMap); break; } if (i == 4) { inputMap.put("filterQ", filterQ); page = getHome(model, inputMap); break; } } } if (found == 0) { String cUrl = request.getRequestURL().toString(); cUrl = cUrl.substring(cUrl.lastIndexOf("/") + 1); ArrayList<ProductBean> list = (ArrayList) lHelper.getListsDetails(0, 0); for (ProductBean pb : list) { if (pb.getUrl().equals(cUrl)) { inputMap.put(ProductHelper.catListId, pb.getProductId()); inputMap.put("filterQ", filterQ); page = productList(unique_id, model, inputMap); model.addAttribute(ProductHelper.catListId, pb.getProductId()); break; } } } } if (request.getParameter("isAdmin") == null && page.equals("category_1")) { page = "category_2"; } return page; } catch (Exception e) { e.printStackTrace(); throw new CategoryController.ResourceNotFoundException(); } }
From source file:com.zd.vpn.fragments.AboutFragment.java
private void createPlayBuyOptions(ArrayList<String> ownedSkus, ArrayList<String> responseList) { try {//w w w . j av a2 s .c o m Vector<Pair<String, String>> gdonation = new Vector<Pair<String, String>>(); gdonation.add(new Pair<String, String>(getString(R.string.donatePlayStore), null)); HashMap<String, SkuResponse> responseMap = new HashMap<String, SkuResponse>(); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); responseMap.put(object.getString("productId"), new SkuResponse(object.getString("price"), object.getString("title"))); } for (String sku : donationSkus) if (responseMap.containsKey(sku)) gdonation.add( getSkuTitle(sku, responseMap.get(sku).title, responseMap.get(sku).price, ownedSkus)); String gmsTextString = ""; for (int i = 0; i < gdonation.size(); i++) { if (i == 1) gmsTextString += " "; else if (i > 1) gmsTextString += ", "; gmsTextString += gdonation.elementAt(i).first; } SpannableString gmsText = new SpannableString(gmsTextString); int lStart = 0; int lEnd = 0; for (Pair<String, String> item : gdonation) { lEnd = lStart + item.first.length(); if (item.second != null) { final String mSku = item.second; ClickableSpan cspan = new ClickableSpan() { @Override public void onClick(View widget) { triggerBuy(mSku); } }; gmsText.setSpan(cspan, lStart, lEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } lStart = lEnd + 2; // Account for ", " between items } if (gmsTextView != null) { gmsTextView.setText(gmsText); gmsTextView.setMovementMethod(LinkMovementMethod.getInstance()); gmsTextView.setVisibility(View.VISIBLE); } } catch (JSONException e) { VpnStatus.logException("Parsing Play Store IAP", e); } }
From source file:com.kloudtek.buildmagic.tools.createinstaller.deb.CreateDebTask.java
private byte[] generateControlFile() { final StringBuilder controlFile = new StringBuilder(); final HashMap<String, String> attrs = new HashMap<String, String>(); if (control != null) { for (final Control.Field field : control.getFields()) { final String name = field.getName(); if (attrs.containsKey(name)) { throw new BuildException("Duplicated control field: " + name); } else if (name.equals("Description")) { throw new BuildException( "package description musn't be defined using custom control field, use description element instead"); } else if (name.equals("Description")) { throw new BuildException( "package description musn't be defined using custom control field, use description element instead"); } else if (name.equals("Maintainer")) { throw new BuildException( "package Maintainer musn't be defined using custom control field, use maintName and maintEmail element instead"); } else if (name.equals("Package")) { throw new BuildException( "package name musn't be defined using custom control field, use 'name' attribute instead"); } else if (name.equals("Version")) { throw new BuildException( "package Version musn't be defined using custom control field, use 'version' attribute instead"); } else if (name.equals("Architecture")) { throw new BuildException( "package Architecture musn't be defined using custom control field, use 'arch' attribute instead"); } else { attrs.put(name, field.getValue()); }/* w w w. j a v a 2 s. c o m*/ } } attrs.put("Package", name); attrs.put("Version", version); attrs.put("Architecture", arch); attrs.put("Section", section); attrs.put("Priority", priority); attrs.put("Maintainer", maintName + " <" + maintEmail + ">"); if (!attrs.containsKey("Installed-Size")) { int totalSize = 0; for (final ResourceCollection rsCol : resources) { final Iterator rsIt = rsCol.iterator(); while (rsIt.hasNext()) { totalSize += ((Resource) rsIt.next()).getSize(); } } attrs.put("Installed-Size", Integer.toString(totalSize / 1024)); } for (final Map.Entry<String, String> entry : attrs.entrySet()) { controlFile.append(entry.getKey()); controlFile.append(": "); controlFile.append(entry.getValue()); controlFile.append('\n'); } if (desc != null) { controlFile.append("Description: "); controlFile.append(desc.getShortDesc()); controlFile.append('\n'); controlFile.append(' '); final String ldesc = desc.getLongDesc(); if (ldesc != null) { controlFile.append(generateExtendedControlField(ldesc)); } } return controlFile.toString().getBytes(); }
From source file:com.viettel.util.StringUtils.java
public static void buidQuery(String name, HashMap<String, Object> searchParams, StringBuilder strQuery, Map<String, Object> params, String... prefix) { ArrayList<String> arrQuery = new ArrayList<String>(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); HashMap<String, Object> searchParamsCopy = new HashMap<>(searchParams); for (Map.Entry<String, Object> entry : searchParams.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (value == null || value.toString().equals("")) { searchParamsCopy.remove(key); }// ww w . jav a2s .c om } String pref = prefix != null && prefix.length > 0 ? prefix[0] + "." : ""; for (Map.Entry<String, Object> entry : searchParamsCopy.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); /* * if (value == null || value.toString().equals("") || (value * instanceof Long && 0 >= (int) value)) { continue; } */ if (arrQuery.size() > 0) { arrQuery.add(" AND "); } if (value instanceof Date || DateUtil.isValidDateWithFormat(value.toString(), "yyyy-MM-dd")) { try { if (key.startsWith("from")) { String cl = key.replace("from", ""); if (searchParamsCopy.containsKey("to" + cl)) { arrQuery.add(String.format("%1$s BETWEEN :%2$s", pref + cl, key)); params.put(key, formatter.parse(value.toString())); Object objTo = searchParamsCopy.get("to" + cl); if (objTo != null) { arrQuery.add(String.format(" AND :%s", "to" + cl)); params.put("to" + cl, formatter.parse(objTo.toString())); } } else { arrQuery.add(String.format("%1$s >= :%2$s", pref + cl, key)); params.put(key, formatter.parse(value.toString())); } } else if (key.startsWith("to")) { String cl = key.replace("to", ""); if (!searchParamsCopy.containsKey("from" + cl)) { arrQuery.add(String.format("%1$s <= :%2$s", pref + cl, key)); params.put(key, formatter.parse(value.toString())); } else { if (arrQuery.size() > 0) { arrQuery.remove(arrQuery.size() - 1); } } } else { arrQuery.add(String.format("DATE(%1$s) = DATE(:%2$s)", pref + key, key)); params.put(key, value + "%"); } } catch (ParseException ex) { } } else if (value instanceof Number) { if (key.startsWith("and_")) { if (searchParamsCopy.containsKey(key.replace("and_", ""))) { if (!CollectionUtils.isEmpty(arrQuery)) { arrQuery.remove(arrQuery.size() - 1); } } } else if (searchParamsCopy.containsKey("and_" + key)) { arrQuery.add(String.format("(%1$s = :%2$s", pref + key, key)); if (value instanceof Integer) { params.put(key, Integer.parseInt(value.toString())); } else if (value instanceof Long) { params.put(key, Long.parseLong(value.toString())); } else if (value instanceof Float) { params.put(key, Float.parseFloat(value.toString())); } else if (value instanceof Double) { params.put(key, Double.parseDouble(value.toString())); } Object obj = searchParamsCopy.get("and_" + key); if (obj != null) { arrQuery.add(String.format(" OR %1$s = :%2$s)", pref + key, "and_" + key)); if (value instanceof Integer) { params.put("and_" + key, Integer.parseInt(obj.toString())); } else if (value instanceof Long) { params.put("and_" + key, Long.parseLong(obj.toString())); } else if (value instanceof Float) { params.put("and_" + key, Float.parseFloat(obj.toString())); } else if (value instanceof Double) { params.put("and_" + key, Double.parseDouble(obj.toString())); } } } else { arrQuery.add(String.format("%1$s = :%2$s", pref + key, key)); if (value instanceof Integer) { params.put(key, Integer.parseInt(value.toString())); } else if (value instanceof Long) { params.put(key, Long.parseLong(value.toString())); } else if (value instanceof Float) { params.put(key, Float.parseFloat(value.toString())); } else if (value instanceof Double) { params.put(key, Double.parseDouble(value.toString())); } } } else if (value instanceof String) { if (key.startsWith("and_")) { if (searchParamsCopy.containsKey(key.replace("and_", ""))) { if (arrQuery.size() > 0) { arrQuery.remove(arrQuery.size() - 1); } } } else if (searchParamsCopy.containsKey("and_" + key)) { arrQuery.add(String.format("(LOWER(%1$s) like LOWER(:%2$s)", pref + key, key)); params.put(key, "%" + value + "%"); Object obj = searchParamsCopy.get("and_" + key); if (obj != null) { arrQuery.add(String.format(" OR LOWER(%1$s) LIKE LOWER(:%2$s))", pref + key, "and_" + key)); params.put("and_" + key, "%" + obj + "%"); } } else if (key.startsWith("in_cond_")) { String cl = key.replace("in_cond_", ""); arrQuery.add(String.format("%1$s IN (%2$s)", pref + cl, value.toString())); params.remove(key); } else if (key.startsWith("not_in_cond_")) { String cl = key.replace("not_in_cond_", ""); arrQuery.add(String.format("%1$s NOT IN (%2$s)", pref + cl, value.toString())); params.remove(key); } else { arrQuery.add(String.format("LOWER(%1$s) LIKE LOWER(:%2$s)", pref + key, key)); params.put(key, "%" + value + "%"); } } } strQuery.append(String.join("", arrQuery)); }
From source file:com.vantiv.pws.apigee.objects.RestDriver.java
/** * Create a transaction response object from a Json string that was returned * via apigee. This is used when we send a request through apigee instead of * PWS direct.// w ww . ja v a2 s .c o m */ public TransactionResponseType createResponseFromApigee(TransactionResponseType response, String json_string) { HashMap<String, String> map = parseJsonResponse(stringToJsonObject(json_string)); if (map.containsKey("Error")) { System.out.println("ERROR: " + map.get("Error")); // System.out.println("Terminating program..."); logger.error("ERROR: " + map.get("Error")); // logger.error("Terminating program..."); // System.exit(1); } else { if (map.containsKey("AuthorizationCode")) response.setAuthorizationCode(map.get("AuthorizationCode")); if (map.containsKey("ReferenceNumber")) response.setReferenceNumber(map.get("ReferenceNumber")); if (map.containsKey("SystemTraceId")) response.setSystemTraceId(Long.parseLong(map.get("SystemTraceId"))); if (map.containsKey("TokenId") && map.containsKey("TokenValue")) { TokenType tokenType = new TokenType(); tokenType.setTokenId(map.get("TokenId")); tokenType.setTokenValue(map.get("TokenValue")); TokenizationResultType trt = new TokenizationResultType(); trt.setTokenType(tokenType); response.setTokenizationResult(trt); } if (map.containsKey("TransactionStatus")) { String t = map.get("TransactionStatus"); // apigee refunds are called "returns", so have to convert it to // "refunded" if (t.equalsIgnoreCase("returned")) t = "refunded"; else if (t.equalsIgnoreCase("partially_reversed")) t = "partially_canceled"; else if (t.equalsIgnoreCase("reversed")) t = "canceled"; response.setTransactionStatus(TransactionStatusType.fromValue(t)); } if (map.containsKey("DeclineCode")) response.setDeclineCode(map.get("DeclineCode")); if (map.containsKey("DeclineMessage")) response.setDeclineMessage(map.get("DeclineMessage")); } return response; }
From source file:com.dtolabs.rundeck.core.dispatcher.DataContextUtils.java
/** * Generate a dataset for a INodeEntry//from w w w . j a va 2 s .c o m * @param nodeentry node * @return dataset */ public static Map<String, String> nodeData(final INodeEntry nodeentry) { final HashMap<String, String> data = new HashMap<String, String>(); if (null != nodeentry) { HashSet<String> skipProps = new HashSet<String>(); skipProps.addAll(Arrays.asList("nodename", "osName", "osVersion", "osArch", "osFamily")); data.put("name", notNull(nodeentry.getNodename())); data.put("hostname", notNull(nodeentry.getHostname())); data.put("os-name", notNull(nodeentry.getOsName())); data.put("os-version", notNull(nodeentry.getOsVersion())); data.put("os-arch", notNull(nodeentry.getOsArch())); data.put("os-family", notNull(nodeentry.getOsFamily())); data.put("username", notNull(nodeentry.getUsername())); data.put("description", notNull(nodeentry.getDescription())); data.put("tags", null != nodeentry.getTags() ? join(nodeentry.getTags(), ",") : ""); //include attributes data if (null != nodeentry.getAttributes()) { for (final String name : nodeentry.getAttributes().keySet()) { if (null != nodeentry.getAttributes().get(name) && !data.containsKey(name) && !skipProps.contains(name)) { data.put(name, notNull(nodeentry.getAttributes().get(name))); } } } } return data; }
From source file:com.atinternet.tracker.Builder.java
/** * Prepare the hit queryString//from w w w . j a v a 2s .co m * * @return LinkedHashMap */ private LinkedHashMap<String, Object[]> prepareQuery() { LinkedHashMap<String, Object[]> formattedParameters = new LinkedHashMap<String, Object[]>(); ArrayList<Param> completeBuffer = new ArrayList<Param>() { { addAll(persistentParams); addAll(volatileParams); } }; ArrayList<Param> params = organizeParameters(completeBuffer); for (Param p : params) { String value = p.getValue().execute(); String key = p.getKey(); HashMap<String, String> plugins = PluginParam.get(tracker); if (plugins.containsKey(key)) { String pluginClass = plugins.get(key); Plugin plugin = null; try { plugin = (Plugin) Class.forName(pluginClass).newInstance(); plugin.execute(tracker); value = plugin.getResponse(); p.setType(Param.Type.JSON); key = Hit.HitParam.JSON.stringValue(); } catch (Exception e) { e.printStackTrace(); value = null; } } else if (key.equals(Hit.HitParam.UserId.stringValue())) { if (TechnicalContext.doNotTrackEnabled(Tracker.getAppContext())) { value = OPT_OUT; } else if (((Boolean) configuration.get(TrackerConfigurationKeys.HASH_USER_ID))) { value = Tool.SHA_256(value); } } if (p.getType() == Param.Type.Closure && Tool.parseJSON(value) != null) { p.setType(Param.Type.JSON); } if (value != null) { // Referrer processing if (key.equals(Hit.HitParam.Referrer.stringValue())) { value = value.replace("&", "$").replaceAll("[<>]", ""); } if (p.getOptions() != null && p.getOptions().isEncode()) { value = Tool.percentEncode(value); p.getOptions().setSeparator(Tool.percentEncode(p.getOptions().getSeparator())); } int duplicateParamIndex = -1; String duplicateParamKey = null; Set<String> keys = formattedParameters.keySet(); String[] keySet = keys.toArray(new String[keys.size()]); int length = keySet.length; for (int i = 0; i < length; i++) { if (keySet[i].equals(key)) { duplicateParamIndex = i; duplicateParamKey = key; break; } } if (duplicateParamIndex != -1) { List<Object[]> values = new ArrayList<Object[]>(formattedParameters.values()); Param duplicateParam = (Param) values.get(duplicateParamIndex)[0]; String str = ((String) formattedParameters.get(duplicateParamKey)[1]).split("=")[0] + "="; String val = ((String) formattedParameters.get(duplicateParamKey)[1]).split("=")[1]; if (p.getType() == Param.Type.JSON) { Object json = Tool.parseJSON(Tool.percentDecode(val)); Object newJson = Tool.parseJSON(Tool.percentDecode(value)); if (json != null && json instanceof JSONObject) { Map dictionary = Tool.toMap((JSONObject) json); if (newJson instanceof JSONObject) { Map newDictionary = Tool.toMap((JSONObject) newJson); dictionary.putAll(newDictionary); JSONObject jsonData = new JSONObject(dictionary); formattedParameters.put(key, new Object[] { duplicateParam, makeSubQuery(key, Tool.percentEncode(jsonData.toString())) }); } else { Tool.executeCallback(tracker.getListener(), CallbackType.warning, "Couldn't append value to a dictionary"); } } else if (json != null && json instanceof JSONArray) { try { ArrayList<Object> array = new ArrayList<Object>(); JSONArray jArray = (JSONArray) json; for (int i = 0; i < jArray.length(); i++) { array.add(jArray.get(i).toString()); } if (newJson instanceof JSONArray) { jArray = (JSONArray) newJson; for (int i = 0; i < jArray.length(); i++) { array.add(jArray.get(i).toString()); } JSONObject jsonData = new JSONObject(array.toString()); formattedParameters.put(key, new Object[] { duplicateParam, makeSubQuery(key, Tool.percentEncode(jsonData.toString())) }); } else { Tool.executeCallback(tracker.getListener(), CallbackType.warning, "Couldn't append value to an array"); } } catch (JSONException e) { Tool.executeCallback(tracker.getListener(), CallbackType.warning, "Couldn't append value to an array"); } } else { Tool.executeCallback(tracker.getListener(), CallbackType.warning, "Couldn't append value to a JSON Object"); } } else if (duplicateParam.getType() == Param.Type.JSON) { Tool.executeCallback(tracker.getListener(), CallbackType.warning, "Couldn't append value to a JSON Object"); } else { formattedParameters.put(key, new Object[] { duplicateParam, str + val + p.getOptions().getSeparator() + value }); } } else { formattedParameters.put(key, new Object[] { p, makeSubQuery(key, value) }); } } } return formattedParameters; }