1 28 29 package com.caucho.jsp.java; 30 31 import com.caucho.vfs.WriteStream; 32 import com.caucho.xml.QName; 33 import com.caucho.xml.XmlChar; 34 35 import java.io.IOException ; 36 37 40 public class JspTextNode extends JspNode { 41 private String _text; 42 43 public JspTextNode(JavaJspGenerator gen, String text, JspNode parent) 44 { 45 if (gen == null) 46 throw new NullPointerException (); 47 48 setGenerator(gen); 49 setQName(new QName("jsp", "text", JSP_NS)); 50 setParent(parent); 51 52 _text = text; 53 } 54 55 58 public String getText() 59 { 60 return _text; 61 } 62 63 66 public void setText(String text) 67 { 68 _text = text; 69 } 70 71 74 public boolean isStatic() 75 { 76 return true; 77 } 78 79 82 public boolean isWhitespace() 83 { 84 String text = _text; 85 86 for (int i = text.length() - 1; i >= 0; i--) { 87 if (! XmlChar.isWhitespace(text.charAt(i))) 88 return false ; 89 } 90 91 return true; 92 } 93 94 99 public void printXml(WriteStream os) 100 throws IOException 101 { 102 printXmlText(os, _text); 103 } 104 105 110 public void generate(JspJavaWriter out) 111 throws Exception 112 { 113 out.addText(_text); 114 } 115 116 121 public void generateStatic(JspJavaWriter out) 122 throws Exception 123 { 124 out.print(_text); 125 } 126 127 135 private void generateText(JspJavaWriter out, String text, 136 int offset, int length) 137 throws IOException 138 { 139 140 if (length > 32000) { 141 generateText(out, text, offset, 16 * 1024); 142 generateText(out, text, offset + 16 * 1024, length - 16 * 1024); 143 return; 144 } 145 146 text = text.substring(offset, offset + length); 147 int index = _gen.addString(text); 148 149 out.print("out.write(_jsp_string" + index + ", 0, "); 150 out.println("_jsp_string" + index + ".length);"); 151 } 152 } 153 | Popular Tags |