Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
VelocityScopeMap |
|
| 1.1428571428571428;1.143 |
1 | /* | |
2 | * $Id: VelocityScopeMap.java 942431 2010-05-08 18:05:19Z apetrelli $ | |
3 | * | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | package org.apache.tiles.request.velocity; | |
22 | ||
23 | import java.util.HashSet; | |
24 | import java.util.Set; | |
25 | ||
26 | import org.apache.tiles.request.collection.ScopeMap; | |
27 | import org.apache.tiles.request.velocity.extractor.VelocityScopeExtractor; | |
28 | import org.apache.velocity.context.Context; | |
29 | ||
30 | /** | |
31 | * <p>Private implementation of <code>Map</code> for servlet request | |
32 | * attributes.</p> | |
33 | * | |
34 | * @version $Rev: 942431 $ $Date: 2010-05-09 04:05:19 +1000 (Sun, 09 May 2010) $ | |
35 | */ | |
36 | ||
37 | 0 | final class VelocityScopeMap extends ScopeMap { |
38 | ||
39 | /** | |
40 | * The request object to use. | |
41 | */ | |
42 | 8 | private Context request = null; |
43 | ||
44 | /** | |
45 | * Constructor. | |
46 | * | |
47 | * @param request The request object to use. | |
48 | */ | |
49 | public VelocityScopeMap(Context request) { | |
50 | 8 | super(new VelocityScopeExtractor(request)); |
51 | 8 | this.request = request; |
52 | 8 | } |
53 | ||
54 | @Override | |
55 | public Object remove(Object key) { | |
56 | 1 | return request.remove(key); |
57 | } | |
58 | ||
59 | @Override | |
60 | public Object put(String key, Object value) { | |
61 | 1 | return request.put(key, value); |
62 | } | |
63 | ||
64 | /** {@inheritDoc} */ | |
65 | public boolean containsKey(Object key) { | |
66 | 1 | return request.containsKey(key); |
67 | } | |
68 | ||
69 | ||
70 | /** {@inheritDoc} */ | |
71 | public boolean isEmpty() { | |
72 | 2 | return size() < 1; |
73 | } | |
74 | ||
75 | ||
76 | /** {@inheritDoc} */ | |
77 | public Set<String> keySet() { | |
78 | 1 | Set<String> set = new HashSet<String>(); |
79 | 3 | for (Object key : request.getKeys()) { |
80 | 2 | set.add((String) key); |
81 | } | |
82 | 1 | return (set); |
83 | } | |
84 | ||
85 | /** {@inheritDoc} */ | |
86 | public int size() { | |
87 | 3 | return request.getKeys().length; |
88 | } | |
89 | } |