1 19 20 package org.apache.jasper.compiler; 21 22 import java.io.FileNotFoundException ; 23 import java.io.IOException ; 24 import org.apache.jasper.JasperException; 25 import org.apache.jasper.JspCompilationContext; 26 import org.apache.jasper.Options; 27 import org.openide.ErrorManager; 28 29 33 public class ExtractPageData { 34 35 protected JspCompilationContext ctxt; 36 37 protected Options options; 38 private CompilerHacks compHacks; 39 40 private boolean isXml; 41 private String sourceEnc; 42 43 44 public ExtractPageData(JspCompilationContext ctxt) { 45 this.ctxt = ctxt; 46 this.options = ctxt.getOptions(); 47 this.compHacks = new CompilerHacks(ctxt); 48 } 49 50 51 public boolean isXMLSyntax() throws JasperException, FileNotFoundException , IOException { 52 if (sourceEnc == null) { 53 extractPageData(); 54 } 55 return isXml; 56 } 57 58 public String getEncoding() throws JasperException, FileNotFoundException , IOException { 59 if (sourceEnc == null) { 60 extractPageData(); 61 } 62 return sourceEnc; 63 } 64 65 66 private void extractPageData() throws JasperException, FileNotFoundException , IOException { 67 68 Compiler comp = compHacks.getCompiler(); 70 PageInfo pageInfo = comp.getPageInfo(); 71 72 JspConfig jspConfig = options.getJspConfig(); 73 JspConfig.JspProperty jspProperty = 74 jspConfig.findJspProperty(ctxt.getJspFile()); 75 76 81 pageInfo.setELIgnored(JspUtil.booleanValue(jspProperty.isELIgnored())); 82 pageInfo.setScriptingInvalid(JspUtil.booleanValue(jspProperty.isScriptingInvalid())); 83 if (jspProperty.getIncludePrelude() != null) { 84 pageInfo.setIncludePrelude(jspProperty.getIncludePrelude()); 85 } 86 if (jspProperty.getIncludeCoda() != null) { 87 pageInfo.setIncludeCoda(jspProperty.getIncludeCoda()); 88 } 89 103 104 JspUtil.resetTemporaryVariableName(); 106 107 ParserControllerProxy parserCtl = new ParserControllerProxy(ctxt, comp); 109 parserCtl.extractSyntaxAndEncoding(ctxt.getJspFile()); 110 111 isXml = parserCtl.isXml; 112 sourceEnc = parserCtl.sourceEnc; 113 } 114 115 } 116 | Popular Tags |