org.red5.server.util.UrlQueryStringMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ant-media-server Show documentation
Show all versions of ant-media-server Show documentation
Ant Media Server supports RTMP, RTSP, MP4, HLS, WebRTC, Adaptive Streaming, etc.
package org.red5.server.util;
import java.util.HashMap;
/**
* Simple query string to map converter.
*
* @param
* key
* @param
* value
*
* @author Paul Gregoire
*/
@SuppressWarnings("serial")
public final class UrlQueryStringMap extends HashMap {
public UrlQueryStringMap() {
super();
}
/**
* Parse a given query string and return an instance of this class.
*
* @param queryString
* query string
* @return query string items as map entries
*/
public static UrlQueryStringMap parse(String queryString) {
UrlQueryStringMap map = new UrlQueryStringMap();
//
String tmp = queryString;
//check if we start with '?' or not
if (queryString.charAt(0) != '?') {
tmp = queryString.split("\\?")[1];
} else if (queryString.charAt(0) == '?') {
tmp = queryString.substring(1);
}
//now break up into key/value blocks
String[] kvs = tmp.split("&");
//take each key/value block and break into its key value parts
for (String kv : kvs) {
String[] split = kv.split("=");
map.put(split[0], split[1]);
}
return map;
}
}