1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.view.facelets.compiler; |
20 | |
|
21 | |
import java.io.IOException; |
22 | |
import java.util.ArrayList; |
23 | |
import java.util.List; |
24 | |
|
25 | |
import javax.el.ELException; |
26 | |
import javax.faces.FacesException; |
27 | |
import javax.faces.component.UIComponent; |
28 | |
import javax.faces.view.facelets.FaceletContext; |
29 | |
import javax.faces.view.facelets.FaceletException; |
30 | |
import javax.faces.view.facelets.FaceletHandler; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
class CompilationUnit |
38 | |
{ |
39 | |
|
40 | 0 | protected final static FaceletHandler LEAF = new FaceletHandler() |
41 | 0 | { |
42 | |
public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException, |
43 | |
ELException |
44 | |
{ |
45 | 0 | } |
46 | |
|
47 | |
public String toString() |
48 | |
{ |
49 | 0 | return "FaceletHandler Tail"; |
50 | |
} |
51 | |
}; |
52 | |
|
53 | |
private List<CompilationUnit> children; |
54 | |
|
55 | |
public CompilationUnit() |
56 | 0 | { |
57 | 0 | } |
58 | |
|
59 | |
public void addChild(CompilationUnit unit) |
60 | |
{ |
61 | 0 | if (this.children == null) |
62 | |
{ |
63 | 0 | this.children = new ArrayList<CompilationUnit>(); |
64 | |
} |
65 | 0 | this.children.add(unit); |
66 | 0 | } |
67 | |
|
68 | |
public FaceletHandler createFaceletHandler() |
69 | |
{ |
70 | 0 | return this.getNextFaceletHandler(); |
71 | |
} |
72 | |
|
73 | |
protected final FaceletHandler getNextFaceletHandler() |
74 | |
{ |
75 | 0 | if (this.children == null || this.children.size() == 0) |
76 | |
{ |
77 | 0 | return LEAF; |
78 | |
} |
79 | 0 | if (this.children.size() == 1) |
80 | |
{ |
81 | 0 | CompilationUnit u = (CompilationUnit) this.children.get(0); |
82 | 0 | return u.createFaceletHandler(); |
83 | |
} |
84 | 0 | FaceletHandler[] fh = new FaceletHandler[this.children.size()]; |
85 | 0 | for (int i = 0; i < fh.length; i++) |
86 | |
{ |
87 | 0 | fh[i] = ((CompilationUnit) this.children.get(i)).createFaceletHandler(); |
88 | |
} |
89 | 0 | return new javax.faces.view.facelets.CompositeFaceletHandler(fh); |
90 | |
} |
91 | |
|
92 | |
} |