Decoded parameters to Map.

@param content the string containing the encoded parameters
@param map     the MultiMap to put parsed query parameters into
@param charset the charset to use for decoding
483051
public static void decodeTo(String content, MultiMap<String> map, Charset charset) {
        if (charset == null)
            charset = ENCODING;

        if (charset == StandardCharsets.UTF_8) {
            decodeUtf8To(content, 0, content.length(), map);
            return;
        }

        synchronized (map) {
            String key = null;
            String value = null;
            int mark = -1;
            boolean encoded = false;
            for (int i = 0; i < content.length(); i++) {
                char c = content.charAt(i);
                switch (c) {
                    case '&':
                        int l = i - mark - 1;
                        value = l == 0 ? "" :
                                (encoded ? decodeString(content, mark + 1, l, charset) : content.substring(mark + 1, i));
                        mark = i;
                        encoded = false;
                        if (key != null) {
                            map.add(key, value);
                        } else if (value != null && value.length() > 0) {
                            map.add(value, "");
                        }
                        key = null;
                        value = null;
                        break;
                    case '=':
                        if (key != null)
                            break;
                        key = encoded ? decodeString(content, mark + 1, i - mark - 1, charset) : content.substring(mark + 1, i);
                        mark = i;
                        encoded = false;
                        break;
                    case '+':
                        encoded = true;
                        break;
                    case '%':
                        encoded = true;
                        break;
                }
            }

            if (key != null) {
                int l = content.length() - mark - 1;
                value = l == 0 ? "" : (encoded ? decodeString(content, mark + 1, l, charset) : content.substring(mark + 1));
                map.add(key, value);
            } else if (mark < content.length()) {
                key = encoded
                        ? decodeString(content, mark + 1, content.length() - mark - 1, charset)
                        : content.substring(mark + 1);
                if (key != null && key.length() > 0) {
                    map.add(key, "");
                }
            }
        }
    }
196748
public void setContent(Object content, String contentType)
			throws UnsupportedEncodingException {
		// https://code.google.com/p/sipservlets/issues/detail?id=202
		if(getSipSession().getProxy() == null) {
			checkMessageState();
		}
		checkContentType(contentType);
		checkCommitted();

		if(contentType != null && contentType.length() > 0) {
			this.addHeader(ContentTypeHeader.NAME, contentType);
			ContentTypeHeader contentTypeHeader = (ContentTypeHeader)this.message.getHeader(ContentTypeHeader.NAME);
			String charset = this.getCharacterEncoding();
			try {
			    // https://code.google.com/p/sipservlets/issues/detail?id=169
				if(contentType.contains(CONTENT_TYPE_MULTIPART) && content instanceof Multipart) {
					// Fix for Issue 2667 : Correct Handling of MimeMultipart
					Multipart multipart = (Multipart) content;
					OutputStream os = new ByteArrayOutputStream();
					multipart.writeTo(os);
					this.message.setContent(os.toString(), contentTypeHeader);
				} else {
					Object tmpContent = content;
					if(tmpContent instanceof String  && charset != null) {
						//test for unsupportedencoding exception
						new String("testEncoding".getBytes(charset));
						tmpContent = new String(((String)tmpContent).getBytes());
					}
					this.message.setContent(content, contentTypeHeader);
				}
			} catch (UnsupportedEncodingException uee) {
				throw uee;
			} catch (Exception e) {
				throw new IllegalArgumentException("Parse error reading content " + content + " with content type " + contentType, e);
			}
		}
	}
715169
public static String getUrlParamsByMap(Map<String, String> data) throws UnsupportedEncodingException {
        if (data == null || data.isEmpty()) return null;

        StringBuilder sb = new StringBuilder();
        for (Map.Entry<String, String> i : data.entrySet()) {

            sb.append(i.getKey())
                    .append("=")
                    .append(URLEncoder.encode(i.getValue(), Charset.UTF_8))
                    .append("&");

        }
        String str = sb.toString();

        return str.substring(0, str.length() - 1);
    }
589940
public static String decodeBase64(String content, Charset charset, TestContext context) {
        return new DecodeBase64Function().execute(Arrays.asList(content, charset.displayName()), context);
    }
291028
private static Map<String, String> createParameterMap(String queryString) {
        if ((queryString == null) || queryString.isEmpty()) {
            return null;
        }

        final String[] pairs = queryString.split("&");
        final Map<String, String> params = new LinkedHashMap<>(pairs.length);

        for (final String pair : pairs) {
            if (pair.isEmpty()) {
                continue;
            }

            String[] tokens = pair.split("=", 2);
            switch (tokens.length) {
                case 1:
                    if (pair.charAt(0) == '=') {
                        params.put("", tokens[0]);
                    } else {
                        params.put(tokens[0], "");
                    }
                    break;
                case 2:
                    params.put(tokens[0], tokens[1]);
                    break;
            }
        }
        return new LinkedHashMap<>(params);
    }
772365
public static String decode(String content) {

		// return content;
		if (content == null || content.length() == 0) {
			return content;
		}
		else {
			byte[] decodeQueryString = org.apache.commons.codec.binary.Base64.decodeBase64(content);
			return new String(decodeQueryString);
		}

	}
1215998
@SuppressWarnings("unchecked")
    public static Map<String, String> deserializeMap(String map) {
        if (map == null || map.equals("")) {
            return new HashMap<String, String>();
        } else {
            XStream xstream = new XStream(new DomDriver());
            return (Map<String, String>) xstream.fromXML(map);
        }
    }
456518
private void _serializeMap(Map map, StringBuilder sb, Set<Object> done) throws ConverterException {
	if (map instanceof Serializable) {
	    _serializeSerializable((Serializable) map, sb);
	    return;
	}
	sb.append(goIn());
	sb.append("{");

	Iterator it = map.keySet().iterator();
	boolean doIt = false;
	deep++;
	while (it.hasNext()) {
	    Object key = it.next();
	    if (doIt) sb.append(',');
	    doIt = true;
	    sb.append(QUOTE_CHR);
	    sb.append(escape(key.toString()));
	    sb.append(QUOTE_CHR);
	    sb.append(':');
	    _serialize(map.get(key), sb, done);
	}
	deep--;

	sb.append('}');
    }
1328970
protected String getContentPartAsString(Map<String,ContentPart<?>> contentPartsMap,String parameter)
    {
        //get part
        String stringValue=null;
        ContentPart<?> contentPart=contentPartsMap.get(parameter);
        if(contentPart!=null)
        {
            ContentPartType contentPartType=contentPart.getType();
            Object content=contentPart.getContent();
            if(content!=null)
            {
                switch(contentPartType)
                {
                    case STRING:
                        stringValue=(String)content;
                        break;
                    case BINARY:
                        byte[] data=(byte[])content;
                        String encoding=IOHelper.getDefaultEncoding();
                        try
                        {
                            stringValue=new String(data,encoding);
                        }
                        catch(UnsupportedEncodingException exception)
                        {
                            throw new FaxException("Unable to convert binary data to string for parameter: "+parameter,exception);
                        }
                        break;
                    default:
                        throw new FaxException("Unsupported content part type: "+contentPartType);
                }
            }
        }
        
        return stringValue;
    }
1236685
public Map<String, String> getStringMap(final Map<String, String> map) {
		final int len = getVInt();
		for (int i = 0; i < len; i++) {
			map.put(getString(), getString());
		}
		return map;
	}
1013611
public final void setContent(String content)
    {
        //clear non relevant flags
        this.contentBinary=null;
        this.contentParts=null;
        this.contentType=ContentType.STRING;

        this.contentString=content;
    }
219420
@Override
	public void formatMap(Map<Object,Object> map) throws FormatException
	{
		if (map == null || map.isEmpty())
			return;// nothing to process

		// format properties
		Object key = null;
		Object value = null;
		String text = null;

		for (Map.Entry<Object, Object> entry :map.entrySet())
		{
			key = entry.getKey();
			value = entry.getValue();

			if (!(value instanceof String))
				continue; // skip

			text = (String) value;

			// overwrite value with formatted version
			if (text.indexOf(getTemplatePrefix()) > -1)
				map.put(key, format(text, map));
		}

	}
390873
public void setMap(Map<String, Object> map) {
        eventMap.clear();
        eventMap.putAll(map);
    }
525148
private static void setParams(Map<String, ?> map) {
        for (String name : map.keySet()) {
            setParam(name, map.get(name));
        }
    }
835655
public static String decode(String value, String charset) {
        String result = null;
        if (!StringUtils.isEmpty(value)) {
            try {
                result = URLDecoder.decode(value, charset);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return result;
    }
755800
public void setHeaders(Map<String, String> map) {
        headers = new MetadataMap<String, String>();
        for (Map.Entry<String, String> entry : map.entrySet()) {
            String[] values = entry.getValue().split(",");
            for (String v : values) {
                if (v.length() != 0) {
                    headers.add(entry.getKey(), v);
                }
            }
        }
    }
651536
@Override
    public void setCharacterEncoding(String charset) {
        if (null != this.outWriter || isCommitted()) {
            return;
        }
        if (null != charset) {
            this.encoding = connection.getEncodingUtils().stripQuotes(charset);
        }
        if (null != this.contentType) {
            int index = this.contentType.indexOf("charset=");
            StringBuilder sb = new StringBuilder();
            if (-1 != index) {
                sb.append(this.contentType.substring(0, index - 1).trim());
            } else {
                sb.append(this.contentType);
            }
            if (this.encoding != null) {
                sb.append(";charset=").append(this.encoding);
            }

            this.contentType = sb.toString();
            this.response.setHeader("Content-Type", this.contentType);
        }
    }