1 29 30 package com.caucho.jsp.java; 31 32 import com.caucho.jsp.JspParseException; 33 import com.caucho.vfs.WriteStream; 34 35 import java.io.IOException ; 36 37 40 public class JspDeclaration extends JspNode { 41 private String _text; 42 43 46 public JspNode addText(String text) 47 { 48 if (_text == null) 49 _text = text; 50 else 51 _text += text; 52 53 return null; 54 } 55 56 59 public void endElement() 60 throws JspParseException 61 { 62 if (_parseState.isScriptingInvalid()) 63 throw error(L.l("Script declarations are forbidden here. Scripting has been disabled either:\n1) disabled by the web.xml scripting-invalid\n2) disabled in a tag's descriptor\n3) forbidden in <jsp:attribute> or <jsp:body> tags.")); 64 65 _gen.addDeclaration(this); 66 } 67 68 71 public boolean hasScripting() 72 { 73 return true; 74 } 75 76 81 public void printXml(WriteStream os) 82 throws IOException 83 { 84 os.print("<jsp:declaration"); 85 printJspId(os); 86 os.print(">"); 87 88 printXmlText(os, _text); 89 os.print("</jsp:declaration>"); 90 } 91 92 97 public void generateDeclaration(JspJavaWriter out) 98 throws IOException 99 { 100 int length = _text.length(); 101 102 out.setLocation(getFilename(), getStartLine()); 103 104 for (int i = 0; i < length; i++) { 105 char ch = _text.charAt(i); 106 107 if (ch == '\r' && i + 1 < length && _text.charAt(i + 1) != '\n') 108 ch = '\n'; 109 110 if (ch == '\n') 111 out.println(); 112 else 113 out.print(ch); 114 } 115 116 out.setLocation(_filename, _endLine); 117 118 out.println(); 119 } 120 121 126 public void generate(JspJavaWriter out) 127 throws Exception 128 { 129 } 130 } 131 | Popular Tags |