List of utility methods to do URL Parameter Builder
Map | getURLParameters(URI uri) get URL Parameters if (uri == null) { return null; String query = uri.getQuery(); if (query == null) { return null; Map parameters = new HashMap(); ... |
String | map2String(Map map String int count = 0; StringBuilder builder = new StringBuilder(); for (Entry<String, String> entry : params.entrySet()) { if (count > 0) { builder.append("&"); builder.append(entry.getKey()); builder.append("="); ... |
String | mapToFormEncodedString(Map map To Form Encoded String final List<String> acc = new ArrayList<String>(); for (Map.Entry<String, String> entry : data.entrySet()) { acc.add(encodeURIComponent(entry.getKey()) + "=" + encodeURIComponent(entry.getValue())); return "?" + join(acc, "&"); |
String | mapToFormString(Map map To Form String StringBuilder postDataStringBuilder = new StringBuilder(); String postDataString; try { for (Map.Entry<String, String> entry : map.entrySet()) { postDataStringBuilder.append(URLEncoder.encode(entry.getKey(), "UTF-8")).append("=") .append(URLEncoder.encode(entry.getValue(), "UTF-8")).append("&"); } catch (Exception e) { ... |
String | mapToStr(Map extends Object, ? extends Object> map) Creates an encoded String from a Map of name/value pairs (MUST BE STRINGS!) if (map == null) return null; StringBuilder buf = new StringBuilder(); boolean first = true; for (Map.Entry<? extends Object, ? extends Object> entry : map.entrySet()) { Object key = entry.getKey(); Object value = entry.getValue(); if (!(key instanceof String) || !(value instanceof String)) ... |
String | mapToStr(Map Creates an encoded String from a Map of name/value pairs (MUST BE STRINGS!) if (map == null) return null; StringBuffer buf = new StringBuffer(); Set<String> keySet = map.keySet(); Iterator<String> i = keySet.iterator(); boolean first = true; while (i.hasNext()) { Object key = i.next(); ... |
String | mapToString(Map map To String StringBuilder stringBuilder = new StringBuilder(); for (String key : map.keySet()) { if (stringBuilder.length() > 0) { stringBuilder.append("&"); String value = map.get(key); try { stringBuilder.append((key != null ? URLEncoder.encode(key, "UTF-8") : "")); ... |
void | parse(final Map Adds all parameters within the Scanner to the list of parameters , as encoded by encoding .
scanner.useDelimiter(PARAMETER_SEPARATOR); while (scanner.hasNext()) { final String[] nameValue = scanner.next().split(NAME_VALUE_SEPARATOR); if (nameValue.length == 0 || nameValue.length > 2) throw new IllegalArgumentException("bad parameter"); final String name = decode(nameValue[0], encoding); String value = null; if (nameValue.length == 2) ... |
Map | parse_parameters(String input) parsparameters final Map<String, List<String>> query_pairs = new LinkedHashMap<String, List<String>>(); final String[] pairs = input.split("&"); for (String pair : pairs) { final int idx = pair.indexOf("="); final String key = idx > 0 ? URLDecoder.decode(pair.substring(0, idx), "UTF-8") : pair; if (!query_pairs.containsKey(key)) { query_pairs.put(key, new LinkedList<String>()); final String value = idx > 0 && pair.length() > idx + 1 ? URLDecoder.decode(pair.substring(idx + 1), "UTF-8") : null; query_pairs.get(key).add(value); return query_pairs; |
void | parseGetParameters(HttpExchange exchange) parse Get Parameters Map<String, Object> parameters = new HashMap<String, Object>(); URI requestedUri = exchange.getRequestURI(); String query = requestedUri.getRawQuery(); parseQuery(query, parameters); exchange.setAttribute("parameters", parameters); |