|
|||||||||||||||||||
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 | |||||||||||||||
ComponentTreeWalker.java | 100% | 100% | 100% | 100% |
|
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.Collection;
|
|
18 |
import java.util.Iterator;
|
|
19 |
|
|
20 |
import org.apache.tapestry.IComponent;
|
|
21 |
import org.apache.tapestry.Tapestry;
|
|
22 |
|
|
23 |
/**
|
|
24 |
* Walks through the tree of components and invokes the visitors on each of
|
|
25 |
* of the components in the tree.
|
|
26 |
*
|
|
27 |
* @author mindbridge
|
|
28 |
* @since 3.0
|
|
29 |
*/
|
|
30 |
public class ComponentTreeWalker |
|
31 |
{ |
|
32 |
private IComponentVisitor[] _visitors;
|
|
33 |
|
|
34 | 220 |
public ComponentTreeWalker(IComponentVisitor[] visitors)
|
35 |
{ |
|
36 | 220 |
_visitors = visitors; |
37 |
} |
|
38 |
|
|
39 | 2266 |
public void walkComponentTree(IComponent component) |
40 |
{ |
|
41 |
// Invoke visitors
|
|
42 | 2266 |
for (int i = 0; i < _visitors.length; i++) |
43 |
{ |
|
44 | 2266 |
IComponentVisitor visitor = _visitors[i]; |
45 | 2266 |
visitor.visitComponent(component); |
46 |
} |
|
47 |
|
|
48 |
// Recurse into the embedded components
|
|
49 | 2266 |
Collection components = component.getComponents().values(); |
50 |
|
|
51 | 2266 |
if (Tapestry.size(components) == 0)
|
52 | 1850 |
return;
|
53 |
|
|
54 | 416 |
for (Iterator it = components.iterator(); it.hasNext();)
|
55 |
{ |
|
56 | 2004 |
IComponent embedded = (IComponent) it.next(); |
57 | 2004 |
walkComponentTree(embedded); |
58 |
} |
|
59 |
} |
|
60 |
} |
|
61 |
|
|