1 /* 2 * Copyright 2023 Web-Legacy 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.apache.tiles.request.jakarta.servlet.extractor; 17 18 import java.util.Enumeration; 19 20 import org.apache.tiles.request.attribute.HasKeys; 21 22 import jakarta.servlet.http.HttpServletRequest; 23 24 /** 25 * Extract parameters from the request. 26 * 27 * <p>Copied from Apache tiles-request-servlet 1.0.7 and adapted for 28 * Jakarta EE 9.</p> 29 */ 30 public class ParameterExtractor implements HasKeys<String> { 31 32 /** 33 * The servlet request. 34 */ 35 private HttpServletRequest request; 36 37 /** 38 * Constructor. 39 * 40 * @param request The servlet request. 41 */ 42 public ParameterExtractor(HttpServletRequest request) { 43 this.request = request; 44 } 45 46 /** 47 * The enumeration of the keys in the stored attributes. 48 * 49 * @return The keys. 50 */ 51 @Override 52 public Enumeration<String> getKeys() { 53 return request.getParameterNames(); 54 } 55 56 /** 57 * Returns the value of the attribute with the given key. 58 * 59 * @param key The key of the attribute. 60 * 61 * @return The value. 62 */ 63 @Override 64 public String getValue(String key) { 65 return request.getParameter(key); 66 } 67 }