* @param ignoreSet The set of parameters to ignore.
* @return A map containing the parameters and their values.
*/
public static Lookup parseQuery(String sQuery, Set ignoreSet)
{
Lookup result = null;
int nQueryLength = (sQuery == null) ? 0 : sQuery.length();
for (int i = 0; i < nQueryLength;)
{
int j = sQuery.indexOf('&', i);
if (j < 0)
{
j = nQueryLength;
}
int k = sQuery.indexOf('=', i);
if (k < 0 || k > j)
{
k = j;
}
try
{
String sName = URLDecoder.decode(sQuery.substring(i, k), GenericHTTPServer.ENCODING);
if (ignoreSet == null || !ignoreSet.contains(sName))
{
String sValue;
if (k != j && k + 1 < nQueryLength)
{
sValue = URLDecoder.decode(sQuery.substring(k + 1, j), GenericHTTPServer.ENCODING);
}
else
{
sValue = "";
}
if (result == null)
{
result = new LookupHashMap();
}
String[] sValueArray = (String[])result.get(sName);
if (sValueArray != null)
{
int n = sValueArray.length;
String[] sNewValueArray = new String[n + 1];
System.arraycopy(sValueArray, 0, sNewValueArray, 0, n);
sNewValueArray[n] = sValue;
result.put(sName, sNewValueArray);
}
else
{
result.put(sName, new String[]{sValue});
}
}
}
// If there is a decoding issue then we do not add the key value pair to the result map
// and fall back on the value in the request parameter map.