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 protected final static FaceletHandler LEAF = new FaceletHandler()
41 {
42 public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
43 ELException
44 {
45 }
46
47 public String toString()
48 {
49 return "FaceletHandler Tail";
50 }
51 };
52
53 private List<CompilationUnit> children;
54
55 public CompilationUnit()
56 {
57 }
58
59 public void addChild(CompilationUnit unit)
60 {
61 if (this.children == null)
62 {
63 this.children = new ArrayList<CompilationUnit>();
64 }
65 this.children.add(unit);
66 }
67
68 public FaceletHandler createFaceletHandler()
69 {
70 return this.getNextFaceletHandler();
71 }
72
73 protected final FaceletHandler getNextFaceletHandler()
74 {
75 if (this.children == null || this.children.size() == 0)
76 {
77 return LEAF;
78 }
79 if (this.children.size() == 1)
80 {
81 CompilationUnit u = (CompilationUnit) this.children.get(0);
82 return u.createFaceletHandler();
83 }
84 FaceletHandler[] fh = new FaceletHandler[this.children.size()];
85 for (int i = 0; i < fh.length; i++)
86 {
87 fh[i] = ((CompilationUnit) this.children.get(i)).createFaceletHandler();
88 }
89 return new javax.faces.view.facelets.CompositeFaceletHandler(fh);
90 }
91
92 }