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. 014package org.apache.tapestry.portlet.multipart; 015 016import java.util.Collections; 017import java.util.Enumeration; 018import java.util.Map; 019 020import javax.portlet.ActionRequest; 021 022import org.apache.hivemind.util.Defense; 023import org.apache.tapestry.multipart.ValuePart; 024 025/** 026 * @author Raphael Jean 027 * 028 */ 029public class UploadFormPortletParametersWrapper extends ActionRequestWrapper { 030 031 /** 032 * Map of {@link ValuePart} keyed on parameter name. 033 */ 034 private Map _parameterMap; 035 036 public UploadFormPortletParametersWrapper(ActionRequest request, 037 Map parameterMap) { 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}