com.twelvemonkeys.servlet.ServletHeadersMapAdapter Maven / Gradle / Ivy
package com.twelvemonkeys.servlet;
import com.twelvemonkeys.util.CollectionUtil;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import static com.twelvemonkeys.lang.Validate.notNull;
/**
* ServletHeadersMapAdapter
*
* @author Harald Kuhr
* @author last modified by $Author: haku $
* @version $Id: ServletHeadersMapAdapter.java#1 $
*/
class ServletHeadersMapAdapter extends AbstractServletMapAdapter> {
protected final HttpServletRequest request;
public ServletHeadersMapAdapter(final HttpServletRequest pRequest) {
request = notNull(pRequest, "request");
}
protected List valueImpl(final String pName) {
@SuppressWarnings("unchecked")
Enumeration headers = request.getHeaders(pName);
return headers == null ? null : toList(CollectionUtil.iterator(headers));
}
private static List toList(final Iterator pValues) {
List list = new ArrayList();
CollectionUtil.addAll(list, pValues);
return Collections.unmodifiableList(list);
}
protected Iterator keysImpl() {
@SuppressWarnings("unchecked")
Enumeration headerNames = request.getHeaderNames();
return headerNames == null ? null : CollectionUtil.iterator(headerNames);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy