Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ContextAdapter |
|
| 1.0;1 |
1 | package org.apache.fulcrum.template.velocity; | |
2 | ||
3 | ||
4 | /* | |
5 | * Licensed to the Apache Software Foundation (ASF) under one | |
6 | * or more contributor license agreements. See the NOTICE file | |
7 | * distributed with this work for additional information | |
8 | * regarding copyright ownership. The ASF licenses this file | |
9 | * to you under the Apache License, Version 2.0 (the | |
10 | * "License"); you may not use this file except in compliance | |
11 | * with the License. You may obtain a copy of the License at | |
12 | * | |
13 | * http://www.apache.org/licenses/LICENSE-2.0 | |
14 | * | |
15 | * Unless required by applicable law or agreed to in writing, | |
16 | * software distributed under the License is distributed on an | |
17 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
18 | * KIND, either express or implied. See the License for the | |
19 | * specific language governing permissions and limitations | |
20 | * under the License. | |
21 | */ | |
22 | ||
23 | ||
24 | import org.apache.fulcrum.template.TemplateContext; | |
25 | ||
26 | import org.apache.velocity.context.AbstractContext; | |
27 | ||
28 | /** | |
29 | * An adapter for Fulcrum's {@link TemplateContext}. Allows for easy processing | |
30 | * of TemplateContext objects by Velocity. This class extends | |
31 | * {@link AbstractContext}, so it supports event cartridge handling. | |
32 | * | |
33 | * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a> | |
34 | * @author <a href="mailto:james@jamestaylor.org">James Taylor</a> | |
35 | * @see org.apache.fulcrum.template.TemplateContext | |
36 | * @see org.apache.velocity.context.Context | |
37 | */ | |
38 | 0 | public class ContextAdapter extends AbstractContext |
39 | { | |
40 | private TemplateContext context; | |
41 | ||
42 | public ContextAdapter(TemplateContext context) | |
43 | 0 | { |
44 | 0 | this.context = context; |
45 | 0 | } |
46 | ||
47 | /** | |
48 | * @see AbstractContext#internalGet | |
49 | */ | |
50 | public Object internalGet( String key ) | |
51 | { | |
52 | 0 | return context.get( key ); |
53 | } | |
54 | ||
55 | /** | |
56 | * @see AbstractContext#internalPut | |
57 | */ | |
58 | public Object internalPut( String key, Object value ) | |
59 | { | |
60 | 0 | context.put( key, value ); |
61 | ||
62 | 0 | return null; |
63 | } | |
64 | ||
65 | /** | |
66 | * @see AbstractContext#internalContainsKey | |
67 | */ | |
68 | public boolean internalContainsKey(Object key) | |
69 | { | |
70 | 0 | return context.containsKey( key ); |
71 | } | |
72 | ||
73 | /** | |
74 | * @see AbstractContext#internalGetKeys | |
75 | */ | |
76 | public Object[] internalGetKeys() | |
77 | { | |
78 | 0 | return context.getKeys(); |
79 | } | |
80 | ||
81 | /** | |
82 | * @see AbstractContext#internalRemove | |
83 | */ | |
84 | public Object internalRemove(Object key) | |
85 | { | |
86 | 0 | return context.remove( key ); |
87 | } | |
88 | } |