Snippet Preview
Snippet HTML Code
1
/* Licensed to the Apache Software Foundation (ASF) under one
2
* or more contributor license agreements. See the NOTICE file
3
* distributed with this work for additional information
4
* regarding copyright ownership. The ASF licenses this file
5
* to you under the Apache License, Version 2.0 (the
6
* "License"); you may not use this file except in compliance
7
* with the License. You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
11
* Unless required by applicable law or agreed to in writing,
12
* software distributed under the License is distributed on an
13
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
* KIND, either express or implied. See the License for the
15
* specific language governing permissions and limitations
16
* under the License.
17
*/
18
19
package org.apache.myfaces.portlet.faces.util.map;
20
21
import java.util.ArrayList;
22
import java.util.Collections;
23
import java.util.Enumeration;
24
import java.util.HashMap;
25
import java.util.List;
26
import java.util.Map;
27
28
import javax.portlet.PortletRequest;
32
33
public class PortletRequestParameterMap extends PortletAbstractMap<String>
34
{
35
private final PortletRequest mPortletRequest;
36
private final Map<String, String> mInternalAttributes;
37
private Map<String,String[]> mPrivateParameters;
38
39
public PortletRequestParameterMap(Object request, Map<String, String> internal)
40
41
if (request instanceof PortletRequest)
42
43
mPortletRequest = (PortletRequest) request;
44
if (internal == null)
45
46
mInternalAttributes = Collections.emptyMap();
47
}
48
else
49
50
mInternalAttributes = new HashMap(internal);;
51
52
53
54
55
throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
56
57
58
59
@Override
60
public String getAttribute(String key)
61
62
if (mPortletRequest != null)
63
64
if (mPrivateParameters == null)
65
66
mPrivateParameters = mPortletRequest.getPrivateParameterMap();
67
68
String[] params = mPrivateParameters.get(key);
69
if (params != null)
70
71
return params[0];
72
73
74
// Now try the internal/temp parameters (part of the views querystring)
75
76
return mInternalAttributes.get(key);
77
78
79
80
81
82
83
84
85
86
87
public void setAttribute(String key, String value)
88
89
throw new UnsupportedOperationException();
90
91
92
93
public void removeAttribute(String key)
94
95
96
97
98
@SuppressWarnings("unchecked")
99
100
public Enumeration<String> getAttributeNames()
101
102
103
104
// merged list of internal parameters & request parameters
105
List<String> attrNames = new ArrayList<String>(5);
106
107
108
109
110
111
attrNames.addAll(mPrivateParameters.keySet());
112
attrNames.addAll(mInternalAttributes.keySet());
113
114
return Collections.enumeration(attrNames);
115
116
117
118
119
120
121