|
|||||||||||||||||||
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
QueuedInheritInformalBindings.java | 75% | 86.7% | 100% | 84.6% |
|
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.pageload; | |
16 | ||
17 | import java.util.Iterator; | |
18 | ||
19 | import org.apache.tapestry.IBinding; | |
20 | import org.apache.tapestry.IComponent; | |
21 | import org.apache.tapestry.spec.IComponentSpecification; | |
22 | ||
23 | /** | |
24 | * Used to defer connection of inherited informal bindings. | |
25 | * | |
26 | * @author Howard Lewis Ship | |
27 | * @since 4.0 | |
28 | */ | |
29 | class QueuedInheritInformalBindings implements IQueuedInheritedBinding | |
30 | { | |
31 | private IComponent _component; | |
32 | ||
33 | 1 | QueuedInheritInformalBindings(IComponent component) |
34 | { | |
35 | 1 | _component = component; |
36 | } | |
37 | ||
38 | 1 | public void connect() |
39 | { | |
40 | ||
41 | 1 | IComponent container = _component.getContainer(); |
42 | ||
43 | 1 | for (Iterator it = container.getBindingNames().iterator(); it.hasNext();) |
44 | { | |
45 | 5 | String bindingName = (String) it.next(); |
46 | 5 | connectInformalBinding(container, _component, bindingName); |
47 | } | |
48 | } | |
49 | ||
50 | 5 | private void connectInformalBinding( |
51 | IComponent container, | |
52 | IComponent component, | |
53 | String bindingName) | |
54 | { | |
55 | 5 | IComponentSpecification componentSpec = component.getSpecification(); |
56 | 5 | IComponentSpecification containerSpec = container.getSpecification(); |
57 | ||
58 | // check if binding already exists in the component | |
59 | 5 | if (component.getBinding(bindingName) != null) |
60 | 0 | return; |
61 | ||
62 | // check if parameter is informal for the component | |
63 | 5 | if (componentSpec.getParameter(bindingName) != null |
64 | || componentSpec.isReservedParameterName(bindingName)) | |
65 | 3 | return; |
66 | ||
67 | // check if parameter is informal for the container | |
68 | 2 | if (containerSpec.getParameter(bindingName) != null |
69 | || containerSpec.isReservedParameterName(bindingName)) | |
70 | 0 | return; |
71 | ||
72 | // if everything passes, establish binding | |
73 | 2 | IBinding binding = container.getBinding(bindingName); |
74 | 2 | component.setBinding(bindingName, binding); |
75 | } | |
76 | } |
|