1/*2 * $Id: HeaderExtractor.java 1066499 2011-02-02 15:33:34Z apetrelli $3 *4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */21package org.apache.tiles.request.servlet.extractor;
2223import java.util.Enumeration;
2425import javax.servlet.http.HttpServletRequest;
26import javax.servlet.http.HttpServletResponse;
2728import org.apache.tiles.request.attribute.EnumeratedValuesExtractor;
2930/**31 * Extract header values from an HTTP request.32 *33 * @version $Rev: 1066499 $ $Date: 2011-02-03 02:33:34 +1100 (Thu, 03 Feb 2011) $34 */35publicclassHeaderExtractorimplementsEnumeratedValuesExtractor {
3637/**38 * The request.39 */40private HttpServletRequest request;
4142/**43 * The response.44 */45private HttpServletResponse response;
4647/**48 * Constructor.49 *50 * @param request The request.51 * @param response The response.52 */53publicHeaderExtractor(HttpServletRequest request,
54 HttpServletResponse response) {
55this.request = request;
56this.response = response;
57 }
5859 @SuppressWarnings("unchecked")
60 @Override
61public Enumeration<String> getKeys() {
62return request.getHeaderNames();
63 }
6465 @Override
66public String getValue(String key) {
67return request.getHeader(key);
68 }
6970 @SuppressWarnings("unchecked")
71 @Override
72public Enumeration<String> getValues(String key) {
73return request.getHeaders(key);
74 }
7576 @Override
77publicvoid setValue(String key, String value) {
78 response.setHeader(key, value);
79 }
80 }