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
23 import javax.el.ELContext;
24 import javax.el.ExpressionFactory;
25 import javax.faces.context.FacesContext;
26 import javax.faces.context.ResponseWriter;
27
28 import org.apache.myfaces.view.facelets.el.ELText;
29
30 final class TextInstruction implements Instruction
31 {
32 private final ELText txt;
33
34 private final String alias;
35
36 public TextInstruction(String alias, ELText txt)
37 {
38 this.alias = alias;
39 this.txt = txt;
40 }
41
42 public void write(FacesContext context) throws IOException
43 {
44 ResponseWriter out = context.getResponseWriter();
45 txt.writeText(out, context.getELContext());
46 }
47
48 public Instruction apply(ExpressionFactory factory, ELContext ctx)
49 {
50 ELText nt = this.txt.apply(factory, ctx);
51 if (nt == this.txt)
52 {
53 return this;
54 }
55
56 return new TextInstruction(alias, nt);
57 }
58
59 public boolean isLiteral()
60 {
61 return txt.isLiteral();
62 }
63 }