下面列出了org.springframework.util.MultiValueMap#size ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Decode the given matrix variables via {@link #decodeRequestString} unless
* {@link #setUrlDecode} is set to {@code true} in which case it is assumed
* the URL path from which the variables were extracted is already decoded
* through a call to {@link #getLookupPathForRequest(HttpServletRequest)}.
* @param request current HTTP request
* @param vars the URI variables extracted from the URL path
* @return the same Map or a new Map instance
*/
public MultiValueMap<String, String> decodeMatrixVariables(
HttpServletRequest request, MultiValueMap<String, String> vars) {
if (this.urlDecode) {
return vars;
}
else {
MultiValueMap<String, String> decodedVars = new LinkedMultiValueMap<>(vars.size());
vars.forEach((key, values) -> {
for (String value : values) {
decodedVars.add(key, decodeInternal(request, value));
}
});
return decodedVars;
}
}
/**
* Decode the given matrix variables via
* {@link #decodeRequestString(HttpServletRequest, String)} unless
* {@link #setUrlDecode(boolean)} is set to {@code true} in which case it is
* assumed the URL path from which the variables were extracted is already
* decoded through a call to
* {@link #getLookupPathForRequest(HttpServletRequest)}.
* @param request current HTTP request
* @param vars the URI variables extracted from the URL path
* @return the same Map or a new Map instance
*/
public MultiValueMap<String, String> decodeMatrixVariables(HttpServletRequest request,
MultiValueMap<String, String> vars) {
if (this.urlDecode) {
return vars;
}
else {
MultiValueMap<String, String> decodedVars = new LinkedMultiValueMap<>(vars.size());
vars.forEach((key, values) -> {
for (String value : values) {
decodedVars.add(key, decodeInternal(request, value));
}
});
return decodedVars;
}
}
@Test
public final void testToMultiValueMap() {
String rsql = "sites.trunks.id==2,id==2,company.id=='2',id==3,name==''";
MultiValueMap<String, String> map = toMultiValueMap(rsql);
log.info("MultiValueMap<String,String> map:{}", map);
long count = map.size();
log.info("rsql: {} -> count: {}", rsql, count);
assertThat("MultiValueMap", count, is(4l));
assertThat("MultiValueMap", map.get("id").size(), is(2));
}
/**
* Decode the given matrix variables via
* {@link #decodeRequestString(HttpServletRequest, String)} unless
* {@link #setUrlDecode(boolean)} is set to {@code true} in which case it is
* assumed the URL path from which the variables were extracted is already
* decoded through a call to
* {@link #getLookupPathForRequest(HttpServletRequest)}.
* @param request current HTTP request
* @param vars URI variables extracted from the URL path
* @return the same Map or a new Map instance
*/
public MultiValueMap<String, String> decodeMatrixVariables(HttpServletRequest request, MultiValueMap<String, String> vars) {
if (this.urlDecode) {
return vars;
}
else {
MultiValueMap<String, String> decodedVars = new LinkedMultiValueMap <String, String>(vars.size());
for (String key : vars.keySet()) {
for (String value : vars.get(key)) {
decodedVars.add(key, decodeInternal(request, value));
}
}
return decodedVars;
}
}
/**
* Decode the given matrix variables via
* {@link #decodeRequestString(HttpServletRequest, String)} unless
* {@link #setUrlDecode(boolean)} is set to {@code true} in which case it is
* assumed the URL path from which the variables were extracted is already
* decoded through a call to
* {@link #getLookupPathForRequest(HttpServletRequest)}.
* @param request current HTTP request
* @param vars URI variables extracted from the URL path
* @return the same Map or a new Map instance
*/
public MultiValueMap<String, String> decodeMatrixVariables(HttpServletRequest request, MultiValueMap<String, String> vars) {
if (this.urlDecode) {
return vars;
}
else {
MultiValueMap<String, String> decodedVars = new LinkedMultiValueMap <String, String>(vars.size());
for (String key : vars.keySet()) {
for (String value : vars.get(key)) {
decodedVars.add(key, decodeInternal(request, value));
}
}
return decodedVars;
}
}
private List<Connection<?>> getConnections(ConnectionRepository connectionRepository) {
MultiValueMap<String, Connection<?>> connections = connectionRepository.findAllConnections();
List<Connection<?>> allConnections = new ArrayList<Connection<?>>();
if (connections.size() > 0) {
for (List<Connection<?>> connectionList : connections.values()) {
for (Connection<?> connection : connectionList) {
allConnections.add(connection);
}
}
}
return allConnections;
}
private List<Connection<?>> getConnections(ConnectionRepository connectionRepository) {
MultiValueMap<String, Connection<?>> connections = connectionRepository.findAllConnections();
List<Connection<?>> allConnections = new ArrayList<Connection<?>>();
if (connections.size() > 0) {
for (List<Connection<?>> connectionList : connections.values()) {
for (Connection<?> connection : connectionList) {
allConnections.add(connection);
}
}
}
return allConnections;
}