MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / parseQuery

Method parseQuery

vm/JavaAPI/src/java/net/URIHelper.java:513–540  ·  view source on GitHub ↗

Parse the query string into an unordered map of name/value pairs. If keepDuplicates parameter is true, then the resulting map will contain values of String object when only one occurrence of a key is found in the query, and an ordered List object if more than one occurrence is found, where the list

(String query, boolean keepDuplicates)

Source from the content-addressed store, hash-verified

511 * @return the parsed parameters.
512 */
513 public static Hashtable<String, Object> parseQuery(String query, boolean keepDuplicates) throws URISyntaxException {
514 if (query == null) {
515 return null;
516 }
517 Hashtable<String, Object> parameters = new Hashtable<String, Object>();
518 List<NameValuePair> nvps = parseQueryOrdered(query);
519 Iterator<NameValuePair> i = nvps.iterator();
520 while(i.hasNext()) {
521 NameValuePair nvp = i.next();
522 if (parameters.containsKey(nvp.getName())) {
523 if (keepDuplicates == true) {
524 Object v = parameters.get(nvp.getName());
525 if (v instanceof String) {
526 parameters.put(nvp.getName(), new String[]{(String) v, nvp.getValue()});
527 } else {
528 int size = ((String[]) v).length;
529 String array[] = new String[size + 1];
530 System.arraycopy(v, 0, array, 0, size);
531 array[size] = nvp.getValue();
532 parameters.put(nvp.getName(), nvp.getValue());
533 }
534 }
535 } else {
536 parameters.put(nvp.getName(), (nvp.getValue() == null) ? String.valueOf(true) : nvp.getValue());
537 }
538 }
539 return parameters;
540 }
541
542 /**
543 * Get the default port that would be used for this connection if the port

Callers 1

getParametersMethod · 0.95

Calls 11

parseQueryOrderedMethod · 0.95
containsKeyMethod · 0.95
getNameMethod · 0.95
getMethod · 0.95
putMethod · 0.95
getValueMethod · 0.95
arraycopyMethod · 0.95
valueOfMethod · 0.95
iteratorMethod · 0.65
hasNextMethod · 0.65
nextMethod · 0.65

Tested by

no test coverage detected