1 14 15 package com.sun.facelets.compiler; 16 17 18 import java.io.IOException ; 19 import java.util.List ; 20 21 import javax.el.ELContext; 22 import javax.el.ELException; 23 import javax.el.ExpressionFactory; 24 25 import javax.faces.context.FacesContext; 26 import javax.faces.context.ResponseWriter; 27 28 import com.sun.facelets.el.ELAdaptor; 29 import com.sun.facelets.el.ELText; 30 31 final class TextInstruction implements Instruction { 32 private final ELText txt; 33 34 private final String alias; 35 36 public TextInstruction(String alias, ELText txt) { 37 this.alias = alias; 38 this.txt = txt; 39 } 40 41 public void write(FacesContext context) throws IOException { 42 ResponseWriter out = context.getResponseWriter(); 43 try { 44 ELContext elContext = ELAdaptor.getELContext(context); 45 txt.writeText(out, elContext); 46 } catch (ELException e) { 48 throw new ELException(this.alias + ": " + e.getMessage(), e.getCause()); 49 } catch (Exception e) { 50 throw new ELException(this.alias + ": " + e.getMessage(), e); 51 } 52 } 53 54 55 public Instruction apply(ExpressionFactory factory, ELContext ctx) { 56 ELText nt = this.txt.apply(factory, ctx); 57 if (nt == this.txt) { 58 return this; 59 } 60 61 return new TextInstruction(alias, nt); 62 } 63 64 public boolean isLiteral() { 65 return txt.isLiteral(); 66 } 67 } 68 | Popular Tags |