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.Iterator;
25
import java.util.List;
26
import java.util.Map;
27
28
import java.util.Set;
29
30
import javax.portlet.PortletRequest;
34
35
public class PortletRequestParameterMap extends PortletAbstractMap<String>
36
{
37
private final PortletRequest mPortletRequest;
38
private final Map<String, String> mInternalAttributes;
39
private Map<String,String[]> mPrivateParameters;
40
41
public PortletRequestParameterMap(Object request, Map<String, String> internal)
42
43
if (request instanceof PortletRequest)
44
45
mPortletRequest = (PortletRequest) request;
46
if (internal == null)
47
48
mInternalAttributes = Collections.emptyMap();
49
}
50
else
51
52
mInternalAttributes = internal;
53
54
55
56
57
throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
58
59
60
61
@Override
62
public String getAttribute(String key)
63
64
if (mPortletRequest != null)
65
66
String value = mInternalAttributes.get(key);
67
if (value != null)
68
69
return value;
70
71
72
if (mPrivateParameters == null)
73
74
mPrivateParameters = mPortletRequest.getPrivateParameterMap();
75
76
String[] params = mPrivateParameters.get(key);
77
if (params != null)
78
79
return params[0];
80
81
82
83
return null;
84
85
86
87
88
89
90
91
92
93
94
public void setAttribute(String key, String value)
95
96
throw new UnsupportedOperationException();
97
98
99
100
public void removeAttribute(String key)
101
102
103
104
105
@SuppressWarnings("unchecked")
106
107
public Enumeration<String> getAttributeNames()
108
109
110
111
// merged list of internal parameters & request parameters
112
List<String> attrNames = new ArrayList<String>(5);
113
114
115
116
117
118
attrNames.addAll(mPrivateParameters.keySet());
119
attrNames.addAll(mInternalAttributes.keySet());
120
121
return Collections.enumeration(attrNames);
122
123
124
125
126
127
128