示例#1
0
 public RootParamNode getRootParamNode() {
   checkAndParse();
   if (!rootParamsNodeIsGenerated) {
     rootParamNode = ParamNode.convert(data);
     rootParamsNodeIsGenerated = true;
   }
   return rootParamNode;
 }
示例#2
0
 public Map<String, String> allSimple() {
   checkAndParse();
   Map<String, String> result = new HashMap<String, String>();
   for (String key : data.keySet()) {
     result.put(key, data.get(key)[0]);
   }
   return result;
 }
示例#3
0
 public String get(String key) {
   if (!_contains(key)) {
     checkAndParse();
   }
   if (data.containsKey(key)) {
     return data.get(key)[0];
   }
   return null;
 }
示例#4
0
 public Map<String, String[]> sub(String prefix) {
   checkAndParse();
   Map<String, String[]> result = new HashMap<String, String[]>();
   for (String key : data.keySet()) {
     if (key.startsWith(prefix + ".")) {
       result.put(key.substring(prefix.length() + 1), data.get(key));
     }
   }
   return result;
 }
示例#5
0
 @SuppressWarnings("unchecked")
 public <T> T get(String key, Class<T> type) {
   try {
     checkAndParse();
     // TODO: This is used by the test, but this is not the most convenient.
     return (T) Binder.bind(getRootParamNode(), key, type, type, null);
   } catch (Exception e) {
     Validation.addError(key, "validation.invalid");
     return null;
   }
 }
示例#6
0
 public String urlEncode() {
   checkAndParse();
   String encoding = Http.Response.current().encoding;
   StringBuilder ue = new StringBuilder();
   for (String key : data.keySet()) {
     if (key.equals("body")) {
       continue;
     }
     String[] values = data.get(key);
     for (String value : values) {
       try {
         ue.append(URLEncoder.encode(key, encoding))
             .append("=")
             .append(URLEncoder.encode(value, encoding))
             .append("&");
       } catch (Exception e) {
         Logger.error(e, "Error (encoding ?)");
       }
     }
   }
   return ue.toString();
 }
示例#7
0
 public Map<String, String[]> all() {
   checkAndParse();
   return data;
 }
示例#8
0
 public String[] getAll(String key) {
   if (!_contains(key)) {
     checkAndParse();
   }
   return data.get(key);
 }
示例#9
0
 public void remove(String key) {
   checkAndParse();
   data.remove(key);
   // make sure rootsParamsNode is regenerated if needed
   rootParamsNodeIsGenerated = false;
 }
示例#10
0
 public void put(String key, String[] values) {
   checkAndParse();
   data.put(key, values);
   // make sure rootsParamsNode is regenerated if needed
   rootParamsNodeIsGenerated = false;
 }