Big HTTP header parsing refactoring

This commit is contained in:
Ziver Koc 2016-02-19 20:28:26 +01:00
parent 946953699f
commit 862bc7763e
50 changed files with 3114 additions and 3072 deletions

View file

@ -29,6 +29,8 @@ import zutil.parser.Base64Decoder;
import java.io.*;
import java.util.BitSet;
import java.util.Iterator;
import java.util.Map;
public class Converter {
private Converter(){}
@ -265,6 +267,35 @@ public class Converter {
return ret.toString();
}
/**
* Generates a comma separated string with key and value pairs
*
* @return a comma separated String
*/
public static String toString(Map map){
StringBuilder tmp = new StringBuilder();
tmp.append("{");
Iterator<Object> it = map.keySet().iterator();
while(it.hasNext()){
Object key = it.next();
Object value = map.get(key);
tmp.append(key);
if (value != null) {
if (value instanceof String)
tmp.append(": \"").append(value).append("\"");
else
tmp.append(value);
}
else
tmp.append("null");
if(it.hasNext())
tmp.append(", ");
}
tmp.append('}');
return tmp.toString();
}
/**
* Converts a BitSet to a Integer
*