|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ListenerMapPropertyAccessor.java | 25% | 40% | 50% | 37.5% |
|
1 |
// Copyright 2004, 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.tapestry.listener;
|
|
16 |
|
|
17 |
import java.util.Map;
|
|
18 |
|
|
19 |
import ognl.ObjectPropertyAccessor;
|
|
20 |
import ognl.OgnlException;
|
|
21 |
|
|
22 |
/**
|
|
23 |
* Exposes {@link org.apache.tapestry.IActionListener} listeners
|
|
24 |
* provided by the {@link ListenerMap} as read-only properties
|
|
25 |
* of the ListenerMap.
|
|
26 |
*
|
|
27 |
* @author Howard Lewis Ship
|
|
28 |
* @since 2.2
|
|
29 |
*
|
|
30 |
**/
|
|
31 |
|
|
32 |
public class ListenerMapPropertyAccessor extends ObjectPropertyAccessor |
|
33 |
{ |
|
34 |
/**
|
|
35 |
* Checks to see if the ListenerMap provides the named
|
|
36 |
* listener, returning the listener if it does. Otherwise,
|
|
37 |
* invokes the super implementation.
|
|
38 |
*
|
|
39 |
**/
|
|
40 |
|
|
41 | 7 |
public Object getProperty(Map context, Object target, Object name) throws OgnlException |
42 |
{ |
|
43 | 7 |
ListenerMap map = (ListenerMap) target; |
44 | 7 |
String listenerName = (String) name; |
45 |
|
|
46 | 7 |
if (map.canProvideListener(listenerName))
|
47 | 7 |
return map.getListener(listenerName);
|
48 |
|
|
49 | 0 |
return super.getProperty(context, target, name); |
50 |
} |
|
51 |
|
|
52 |
/**
|
|
53 |
* Returns true if the ListenerMap contains the named listener,
|
|
54 |
* otherwise invokes super-implementation.
|
|
55 |
*
|
|
56 |
**/
|
|
57 |
|
|
58 | 0 |
public boolean hasGetProperty(Map context, Object target, Object oname) throws OgnlException |
59 |
{ |
|
60 | 0 |
ListenerMap map = (ListenerMap) target; |
61 | 0 |
String listenerName = (String) oname; |
62 |
|
|
63 | 0 |
if (map.canProvideListener(listenerName))
|
64 | 0 |
return true; |
65 |
|
|
66 | 0 |
return super.hasGetProperty(context, target, oname); |
67 |
} |
|
68 |
|
|
69 |
} |
|
70 |
|
|