1 14 15 package com.sun.facelets.compiler; 16 17 import java.io.IOException ; 18 import java.util.ArrayList ; 19 import java.util.List ; 20 21 import javax.el.ELException; 22 import javax.faces.FacesException; 23 import javax.faces.component.UIComponent; 24 25 import com.sun.facelets.FaceletContext; 26 import com.sun.facelets.FaceletException; 27 import com.sun.facelets.FaceletHandler; 28 import com.sun.facelets.tag.CompositeFaceletHandler; 29 30 35 class CompilationUnit { 36 37 protected final static FaceletHandler LEAF = new FaceletHandler() { 38 public void apply(FaceletContext ctx, UIComponent parent) 39 throws IOException , FacesException, FaceletException, 40 ELException { 41 } 42 public String toString() { 43 return "FaceletHandler Tail"; 44 } 45 }; 46 47 private List children; 48 49 public CompilationUnit() { 50 } 51 52 public void addChild(CompilationUnit unit) { 53 if (this.children == null) { 54 this.children = new ArrayList (); 55 } 56 this.children.add(unit); 57 } 58 59 public FaceletHandler createFaceletHandler() { 60 return this.getNextFaceletHandler(); 61 } 62 63 protected final FaceletHandler getNextFaceletHandler() { 64 if (this.children == null || this.children.size() == 0) { 65 return LEAF; 66 } 67 if (this.children.size() == 1) { 68 CompilationUnit u = (CompilationUnit) this.children.get(0); 69 return u.createFaceletHandler(); 70 } 71 FaceletHandler[] fh = new FaceletHandler[this.children.size()]; 72 for (int i = 0; i < fh.length; i++) { 73 fh[i] = ((CompilationUnit) this.children.get(i)) 74 .createFaceletHandler(); 75 } 76 return new CompositeFaceletHandler(fh); 77 } 78 79 } 80 | Popular Tags |