public class PackData extends HashMap implements Map{
private static final long serialVersionUID = 1L;
Map map = null;
HttpServletRequest request;
public PackData(HttpServletRequest request){
this.request = request;
Map properties = request.getParameterMap();
Map returnMap = new HashMap();
Iterator entries = properties.entrySet().iterator();
Entry entry;
String name = "";
String value = "";
while (entries.hasNext()) {
entry = (Entry) entries.next();
name = (String) entry.getKey();
Object valueObj = entry.getValue();
if(null == valueObj){
value = "";
}else if(valueObj instanceof String[]){
String[] values = (String[])valueObj;
for(int i=0;i<values.length;i++){
value = values[i] + ",";
}
value = value.substring(0, value.length()-1);
}else{
value = valueObj.toString();
}
returnMap.put(name, value);
}
if(returnMap.containsKey("page")&&returnMap.containsKey("rows")){
Integer page = Integer.parseInt(returnMap.get("page").toString());
Integer rows = Integer.parseInt(returnMap.get("rows").toString());
Integer start = (page==0?0:page-1)*rows;
Integer end = rows;
returnMap.put("start", start);
returnMap.put("end", end);
}
map = returnMap;
}
public PackData() {
map = new HashMap();
}
public PackData(Map map) {
this.map = map;
}