|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ServletUtil.java | - | 100% | 100% | 100% |
|
1 |
package com.diasparsoftware.javax.servlet;
|
|
2 |
|
|
3 |
import java.util.*;
|
|
4 |
|
|
5 |
import javax.servlet.http.HttpServletRequest;
|
|
6 |
|
|
7 |
import org.apache.commons.collections.*;
|
|
8 |
|
|
9 |
public class ServletUtil { |
|
10 |
|
|
11 |
/**
|
|
12 |
* Provides a nicer string representation of a
|
|
13 |
* servlet request parameter map.
|
|
14 |
*
|
|
15 |
* @param request The request whose parameters you
|
|
16 |
* want to display
|
|
17 |
* @return A nice string representation of the
|
|
18 |
* parameters to the specified request
|
|
19 |
*/
|
|
20 | 32 |
public static String parameterMapToString(HttpServletRequest request) { |
21 | 32 |
final Map parameters = new HashMap();
|
22 |
|
|
23 | 32 |
Closure convertArrayToListClosure = new Closure() {
|
24 | 32 |
public void execute(Object eachMapEntryAsObject) { |
25 | 32 |
Map.Entry eachMapEntry = |
26 |
(Map.Entry) eachMapEntryAsObject; |
|
27 |
|
|
28 | 32 |
String name = (String) eachMapEntry.getKey(); |
29 | 32 |
String[] values = (String[]) eachMapEntry.getValue(); |
30 |
|
|
31 | 32 |
parameters.put(name, Arrays.asList(values)); |
32 |
} |
|
33 |
}; |
|
34 |
|
|
35 | 32 |
CollectionUtils.forAllDo( |
36 |
request.getParameterMap().entrySet(), |
|
37 |
convertArrayToListClosure); |
|
38 |
|
|
39 | 32 |
return parameters.toString();
|
40 |
} |
|
41 |
|
|
42 |
} |
|
43 |
|
|