001/* 002 * Copyright 2023 Web-Legacy 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.apache.tiles.request.jakarta.servlet.extractor; 017 018import java.util.Enumeration; 019 020import org.apache.tiles.request.attribute.HasKeys; 021 022import jakarta.servlet.http.HttpServletRequest; 023 024/** 025 * Extract parameters from the request. 026 * 027 * <p>Copied from Apache tiles-request-servlet 1.0.7 and adapted for 028 * Jakarta EE 9.</p> 029 */ 030public class ParameterExtractor implements HasKeys<String> { 031 032 /** 033 * The servlet request. 034 */ 035 private HttpServletRequest request; 036 037 /** 038 * Constructor. 039 * 040 * @param request The servlet request. 041 */ 042 public ParameterExtractor(HttpServletRequest request) { 043 this.request = request; 044 } 045 046 /** 047 * The enumeration of the keys in the stored attributes. 048 * 049 * @return The keys. 050 */ 051 @Override 052 public Enumeration<String> getKeys() { 053 return request.getParameterNames(); 054 } 055 056 /** 057 * Returns the value of the attribute with the given key. 058 * 059 * @param key The key of the attribute. 060 * 061 * @return The value. 062 */ 063 @Override 064 public String getValue(String key) { 065 return request.getParameter(key); 066 } 067}