001 // Copyright 2006 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 package org.apache.tapestry.portlet.multipart; 015 016 import java.util.Collections; 017 import java.util.Enumeration; 018 import java.util.Map; 019 020 import javax.portlet.ActionRequest; 021 022 import org.apache.hivemind.util.Defense; 023 024 /** 025 * @author Raphael Jean 026 */ 027 public class UploadFormPortletParametersWrapper extends ActionRequestWrapper 028 { 029 030 /** 031 * Map of {@link ValuePart} keyed on parameter name. 032 */ 033 private Map _parameterMap; 034 035 public UploadFormPortletParametersWrapper(ActionRequest request, 036 Map parameterMap) 037 { 038 super(request); 039 040 Defense.notNull(parameterMap, "parameterMap"); 041 042 _parameterMap = Collections.unmodifiableMap(parameterMap); 043 } 044 045 public String getParameter(String name) 046 { 047 String[] values = getParameterValues(name); 048 049 return (values == null || values.length == 0) ? null : values[0]; 050 } 051 052 public Map getParameterMap() 053 { 054 return _parameterMap; 055 } 056 057 public Enumeration getParameterNames() 058 { 059 return Collections.enumeration(_parameterMap.keySet()); 060 } 061 062 public String[] getParameterValues(String name) 063 { 064 return (String[]) _parameterMap.get(name); 065 } 066 067 public String toString() 068 { 069 return "<UploadFormPortletParametersWrapper for " + getRequest() + ">"; 070 } 071 072 }