You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2010/07/24 15:03:12 UTC
svn commit: r978865 [1/4] - in /tomcat/trunk: ./ java/org/apache/jasper/
java/org/apache/jasper/compiler/ java/org/apache/jasper/el/
java/org/apache/jasper/runtime/ java/org/apache/jasper/servlet/
java/org/apache/jasper/tagplugins/jstl/ java/org/apache...
Author: markt
Date: Sat Jul 24 13:03:11 2010
New Revision: 978865
URL: http://svn.apache.org/viewvc?rev=978865&view=rev
Log:
Remainder of tabs to spaces changes
Enable check in checkstyle config
Modified:
tomcat/trunk/checkstyle.xml
tomcat/trunk/java/org/apache/jasper/Constants.java
tomcat/trunk/java/org/apache/jasper/EmbeddedServletOptions.java
tomcat/trunk/java/org/apache/jasper/JasperException.java
tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java
tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java
tomcat/trunk/java/org/apache/jasper/compiler/Dumper.java
tomcat/trunk/java/org/apache/jasper/compiler/ErrorDispatcher.java
tomcat/trunk/java/org/apache/jasper/compiler/ErrorHandler.java
tomcat/trunk/java/org/apache/jasper/compiler/Generator.java
tomcat/trunk/java/org/apache/jasper/compiler/JarScannerFactory.java
tomcat/trunk/java/org/apache/jasper/compiler/JasperTagInfo.java
tomcat/trunk/java/org/apache/jasper/compiler/JspConfig.java
tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java
tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java
tomcat/trunk/java/org/apache/jasper/compiler/Localizer.java
tomcat/trunk/java/org/apache/jasper/compiler/Mark.java
tomcat/trunk/java/org/apache/jasper/compiler/PageDataImpl.java
tomcat/trunk/java/org/apache/jasper/compiler/ServletWriter.java
tomcat/trunk/java/org/apache/jasper/compiler/SmapGenerator.java
tomcat/trunk/java/org/apache/jasper/compiler/SmapUtil.java
tomcat/trunk/java/org/apache/jasper/compiler/TagPluginManager.java
tomcat/trunk/java/org/apache/jasper/compiler/TextOptimizer.java
tomcat/trunk/java/org/apache/jasper/el/ELResolverImpl.java
tomcat/trunk/java/org/apache/jasper/el/ExpressionEvaluatorImpl.java
tomcat/trunk/java/org/apache/jasper/el/ExpressionImpl.java
tomcat/trunk/java/org/apache/jasper/el/FunctionMapperImpl.java
tomcat/trunk/java/org/apache/jasper/el/VariableResolverImpl.java
tomcat/trunk/java/org/apache/jasper/runtime/HttpJspBase.java
tomcat/trunk/java/org/apache/jasper/runtime/InstanceManagerFactory.java
tomcat/trunk/java/org/apache/jasper/runtime/JspApplicationContextImpl.java
tomcat/trunk/java/org/apache/jasper/runtime/JspContextWrapper.java
tomcat/trunk/java/org/apache/jasper/runtime/JspWriterImpl.java
tomcat/trunk/java/org/apache/jasper/runtime/PageContextImpl.java
tomcat/trunk/java/org/apache/jasper/runtime/PerThreadTagHandlerPool.java
tomcat/trunk/java/org/apache/jasper/runtime/ServletResponseWrapperInclude.java
tomcat/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java
tomcat/trunk/java/org/apache/jasper/servlet/JspServlet.java
tomcat/trunk/java/org/apache/jasper/tagplugins/jstl/Util.java
tomcat/trunk/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java
tomcat/trunk/java/org/apache/jasper/tagplugins/jstl/core/Param.java
tomcat/trunk/java/org/apache/jasper/xmlparser/ASCIIReader.java
tomcat/trunk/java/org/apache/jasper/xmlparser/EncodingMap.java
tomcat/trunk/java/org/apache/jasper/xmlparser/ParserUtils.java
tomcat/trunk/java/org/apache/jasper/xmlparser/UCSReader.java
tomcat/trunk/java/org/apache/jasper/xmlparser/UTF8Reader.java
tomcat/trunk/java/org/apache/jasper/xmlparser/XMLEncodingDetector.java
Modified: tomcat/trunk/checkstyle.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/checkstyle.xml?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/checkstyle.xml (original)
+++ tomcat/trunk/checkstyle.xml Sat Jul 24 13:03:11 2010
@@ -19,7 +19,5 @@
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
-<!--
<module name="FileTabCharacter"/>
--->
</module>
\ No newline at end of file
Modified: tomcat/trunk/java/org/apache/jasper/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/Constants.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/Constants.java (original)
+++ tomcat/trunk/java/org/apache/jasper/Constants.java Sat Jul 24 13:03:11 2010
@@ -56,9 +56,9 @@ public class Constants {
* generated code.
*/
private static final String[] PRIVATE_STANDARD_IMPORTS = {
- "javax.servlet.*",
- "javax.servlet.http.*",
- "javax.servlet.jsp.*"
+ "javax.servlet.*",
+ "javax.servlet.http.*",
+ "javax.servlet.jsp.*"
};
public static final List<String> STANDARD_IMPORTS =
Collections.unmodifiableList(Arrays.asList(PRIVATE_STANDARD_IMPORTS));
@@ -135,26 +135,26 @@ public class Constants {
* of the DTDs for tag library descriptors.
*/
public static final String TAGLIB_DTD_PUBLIC_ID_11 =
- "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN";
+ "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN";
public static final String TAGLIB_DTD_RESOURCE_PATH_11 =
- "/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd";
+ "/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd";
public static final String TAGLIB_DTD_PUBLIC_ID_12 =
- "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN";
+ "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN";
public static final String TAGLIB_DTD_RESOURCE_PATH_12 =
- "/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd";
+ "/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd";
/**
* Public Id and the Resource path (of the cached copy)
* of the DTDs for web application deployment descriptors
*/
public static final String WEBAPP_DTD_PUBLIC_ID_22 =
- "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN";
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN";
public static final String WEBAPP_DTD_RESOURCE_PATH_22 =
- "/javax/servlet/resources/web-app_2_2.dtd";
+ "/javax/servlet/resources/web-app_2_2.dtd";
public static final String WEBAPP_DTD_PUBLIC_ID_23 =
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
public static final String WEBAPP_DTD_RESOURCE_PATH_23 =
- "/javax/servlet/resources/web-app_2_3.dtd";
+ "/javax/servlet/resources/web-app_2_3.dtd";
/**
* List of the Public IDs that we cache, and their
@@ -164,19 +164,19 @@ public class Constants {
*/
// TODO Add 2.4, 2.5, 3.0
private static final String[] PRIVATE_CACHED_DTD_PUBLIC_IDS = {
- TAGLIB_DTD_PUBLIC_ID_11,
- TAGLIB_DTD_PUBLIC_ID_12,
- WEBAPP_DTD_PUBLIC_ID_22,
- WEBAPP_DTD_PUBLIC_ID_23,
+ TAGLIB_DTD_PUBLIC_ID_11,
+ TAGLIB_DTD_PUBLIC_ID_12,
+ WEBAPP_DTD_PUBLIC_ID_22,
+ WEBAPP_DTD_PUBLIC_ID_23,
};
public static final List<String> CACHED_DTD_PUBLIC_IDS =
Collections.unmodifiableList(
Arrays.asList(PRIVATE_CACHED_DTD_PUBLIC_IDS));
private static final String[] PRIVATE_CACHED_DTD_RESOURCE_PATHS = {
- TAGLIB_DTD_RESOURCE_PATH_11,
- TAGLIB_DTD_RESOURCE_PATH_12,
- WEBAPP_DTD_RESOURCE_PATH_22,
- WEBAPP_DTD_RESOURCE_PATH_23,
+ TAGLIB_DTD_RESOURCE_PATH_11,
+ TAGLIB_DTD_RESOURCE_PATH_12,
+ WEBAPP_DTD_RESOURCE_PATH_22,
+ WEBAPP_DTD_RESOURCE_PATH_23,
};
public static final List<String> CACHED_DTD_RESOURCE_PATHS =
Collections.unmodifiableList(
Modified: tomcat/trunk/java/org/apache/jasper/EmbeddedServletOptions.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/EmbeddedServletOptions.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/EmbeddedServletOptions.java (original)
+++ tomcat/trunk/java/org/apache/jasper/EmbeddedServletOptions.java Sat Jul 24 13:03:11 2010
@@ -451,7 +451,7 @@ public final class EmbeddedServletOption
} else {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage("jsp.warning.enablePooling"));
- }
+ }
}
}
Modified: tomcat/trunk/java/org/apache/jasper/JasperException.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/JasperException.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/JasperException.java (original)
+++ tomcat/trunk/java/org/apache/jasper/JasperException.java Sat Jul 24 13:03:11 2010
@@ -26,7 +26,7 @@ package org.apache.jasper;
public class JasperException extends javax.servlet.ServletException {
public JasperException(String reason) {
- super(reason);
+ super(reason);
}
/**
@@ -34,13 +34,13 @@ public class JasperException extends jav
* throwing a JasperException
*/
public JasperException (String reason, Throwable exception) {
- super(reason, exception);
+ super(reason, exception);
}
/**
* Creates a JasperException with the embedded exception
*/
public JasperException (Throwable exception) {
- super(exception);
+ super(exception);
}
}
Modified: tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java (original)
+++ tomcat/trunk/java/org/apache/jasper/JspCompilationContext.java Sat Jul 24 13:03:11 2010
@@ -195,9 +195,9 @@ public class JspCompilationContext {
* plus the directory derived from the package name.
*/
public String getOutputDir() {
- if (outputDir == null) {
- createOutputDir();
- }
+ if (outputDir == null) {
+ createOutputDir();
+ }
return outputDir;
}
@@ -458,7 +458,7 @@ public class JspCompilationContext {
}
return derivedPackageName;
}
-
+
/**
* The package name into which the servlet class is generated.
*/
@@ -502,12 +502,12 @@ public class JspCompilationContext {
}
if (isTagFile()) {
- String tagName = tagInfo.getTagClassName();
+ String tagName = tagInfo.getTagClassName();
javaPath = tagName.replace('.', '/') + ".java";
} else {
javaPath = getServletPackageName().replace('.', '/') + '/' +
getServletClassName() + ".java";
- }
+ }
return javaPath;
}
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Compiler.java Sat Jul 24 13:03:11 2010
@@ -293,25 +293,25 @@ public abstract class Compiler {
return smapStr;
}
- private ServletWriter setupContextWriter(String javaFileName)
- throws FileNotFoundException, JasperException {
- ServletWriter writer;
- // Setup the ServletWriter
- String javaEncoding = ctxt.getOptions().getJavaEncoding();
- OutputStreamWriter osw = null;
-
- try {
- osw = new OutputStreamWriter(
- new FileOutputStream(javaFileName), javaEncoding);
- } catch (UnsupportedEncodingException ex) {
- errDispatcher.jspError("jsp.error.needAlternateJavaEncoding",
- javaEncoding);
- }
-
- writer = new ServletWriter(new PrintWriter(osw));
- ctxt.setWriter(writer);
- return writer;
- }
+ private ServletWriter setupContextWriter(String javaFileName)
+ throws FileNotFoundException, JasperException {
+ ServletWriter writer;
+ // Setup the ServletWriter
+ String javaEncoding = ctxt.getOptions().getJavaEncoding();
+ OutputStreamWriter osw = null;
+
+ try {
+ osw = new OutputStreamWriter(
+ new FileOutputStream(javaFileName), javaEncoding);
+ } catch (UnsupportedEncodingException ex) {
+ errDispatcher.jspError("jsp.error.needAlternateJavaEncoding",
+ javaEncoding);
+ }
+
+ writer = new ServletWriter(new PrintWriter(osw));
+ ctxt.setWriter(writer);
+ return writer;
+ }
/**
* Compile the servlet from .java file to .class file
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Dumper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Dumper.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Dumper.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Dumper.java Sat Jul 24 13:03:11 2010
@@ -23,198 +23,198 @@ import org.apache.jasper.JasperException
class Dumper {
static class DumpVisitor extends Node.Visitor {
- private int indent = 0;
+ private int indent = 0;
- private String getAttributes(Attributes attrs) {
- if (attrs == null)
- return "";
-
- StringBuilder buf = new StringBuilder();
- for (int i=0; i < attrs.getLength(); i++) {
- buf.append(" " + attrs.getQName(i) + "=\""
- + attrs.getValue(i) + "\"");
- }
- return buf.toString();
- }
-
- private void printString(String str) {
- printIndent();
- System.out.print(str);
- }
-
- private void printString(String prefix, String str, String suffix) {
- printIndent();
- if (str != null) {
- System.out.print(prefix + str + suffix);
- } else {
- System.out.print(prefix + suffix);
- }
- }
-
- private void printAttributes(String prefix, Attributes attrs,
- String suffix) {
- printString(prefix, getAttributes(attrs), suffix);
- }
-
- private void dumpBody(Node n) throws JasperException {
- Node.Nodes page = n.getBody();
- if (page != null) {
-// indent++;
- page.visit(this);
-// indent--;
- }
+ private String getAttributes(Attributes attrs) {
+ if (attrs == null)
+ return "";
+
+ StringBuilder buf = new StringBuilder();
+ for (int i=0; i < attrs.getLength(); i++) {
+ buf.append(" " + attrs.getQName(i) + "=\""
+ + attrs.getValue(i) + "\"");
+ }
+ return buf.toString();
+ }
+
+ private void printString(String str) {
+ printIndent();
+ System.out.print(str);
+ }
+
+ private void printString(String prefix, String str, String suffix) {
+ printIndent();
+ if (str != null) {
+ System.out.print(prefix + str + suffix);
+ } else {
+ System.out.print(prefix + suffix);
+ }
+ }
+
+ private void printAttributes(String prefix, Attributes attrs,
+ String suffix) {
+ printString(prefix, getAttributes(attrs), suffix);
+ }
+
+ private void dumpBody(Node n) throws JasperException {
+ Node.Nodes page = n.getBody();
+ if (page != null) {
+// indent++;
+ page.visit(this);
+// indent--;
+ }
}
@Override
public void visit(Node.PageDirective n) throws JasperException {
- printAttributes("<%@ page", n.getAttributes(), "%>");
+ printAttributes("<%@ page", n.getAttributes(), "%>");
}
@Override
public void visit(Node.TaglibDirective n) throws JasperException {
- printAttributes("<%@ taglib", n.getAttributes(), "%>");
+ printAttributes("<%@ taglib", n.getAttributes(), "%>");
}
@Override
public void visit(Node.IncludeDirective n) throws JasperException {
- printAttributes("<%@ include", n.getAttributes(), "%>");
- dumpBody(n);
+ printAttributes("<%@ include", n.getAttributes(), "%>");
+ dumpBody(n);
}
@Override
public void visit(Node.Comment n) throws JasperException {
- printString("<%--", n.getText(), "--%>");
+ printString("<%--", n.getText(), "--%>");
}
@Override
public void visit(Node.Declaration n) throws JasperException {
- printString("<%!", n.getText(), "%>");
+ printString("<%!", n.getText(), "%>");
}
@Override
public void visit(Node.Expression n) throws JasperException {
- printString("<%=", n.getText(), "%>");
+ printString("<%=", n.getText(), "%>");
}
@Override
public void visit(Node.Scriptlet n) throws JasperException {
- printString("<%", n.getText(), "%>");
+ printString("<%", n.getText(), "%>");
}
@Override
public void visit(Node.IncludeAction n) throws JasperException {
- printAttributes("<jsp:include", n.getAttributes(), ">");
- dumpBody(n);
+ printAttributes("<jsp:include", n.getAttributes(), ">");
+ dumpBody(n);
printString("</jsp:include>");
}
@Override
public void visit(Node.ForwardAction n) throws JasperException {
- printAttributes("<jsp:forward", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:forward>");
+ printAttributes("<jsp:forward", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:forward>");
}
@Override
public void visit(Node.GetProperty n) throws JasperException {
- printAttributes("<jsp:getProperty", n.getAttributes(), "/>");
+ printAttributes("<jsp:getProperty", n.getAttributes(), "/>");
}
@Override
public void visit(Node.SetProperty n) throws JasperException {
- printAttributes("<jsp:setProperty", n.getAttributes(), ">");
+ printAttributes("<jsp:setProperty", n.getAttributes(), ">");
dumpBody(n);
printString("</jsp:setProperty>");
}
@Override
public void visit(Node.UseBean n) throws JasperException {
- printAttributes("<jsp:useBean", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:useBean>");
+ printAttributes("<jsp:useBean", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:useBean>");
}
-
+
@Override
public void visit(Node.PlugIn n) throws JasperException {
- printAttributes("<jsp:plugin", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:plugin>");
- }
+ printAttributes("<jsp:plugin", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:plugin>");
+ }
@Override
public void visit(Node.ParamsAction n) throws JasperException {
- printAttributes("<jsp:params", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:params>");
+ printAttributes("<jsp:params", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:params>");
}
@Override
public void visit(Node.ParamAction n) throws JasperException {
- printAttributes("<jsp:param", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:param>");
+ printAttributes("<jsp:param", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:param>");
}
@Override
public void visit(Node.NamedAttribute n) throws JasperException {
- printAttributes("<jsp:attribute", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:attribute>");
+ printAttributes("<jsp:attribute", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:attribute>");
}
@Override
public void visit(Node.JspBody n) throws JasperException {
- printAttributes("<jsp:body", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:body>");
+ printAttributes("<jsp:body", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:body>");
}
@Override
public void visit(Node.ELExpression n) throws JasperException {
- printString( "${" + new String( n.getText() ) + "}" );
+ printString( "${" + new String( n.getText() ) + "}" );
}
@Override
public void visit(Node.CustomTag n) throws JasperException {
- printAttributes("<" + n.getQName(), n.getAttributes(), ">");
- dumpBody(n);
- printString("</" + n.getQName() + ">");
- }
-
- @Override
- public void visit(Node.UninterpretedTag n) throws JasperException {
- String tag = n.getQName();
- printAttributes("<"+tag, n.getAttributes(), ">");
- dumpBody(n);
- printString("</" + tag + ">");
- }
-
- @Override
- public void visit(Node.TemplateText n) throws JasperException {
- printString(new String(n.getText()));
- }
-
- private void printIndent() {
- for (int i=0; i < indent; i++) {
- System.out.print(" ");
- }
- }
+ printAttributes("<" + n.getQName(), n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</" + n.getQName() + ">");
+ }
+
+ @Override
+ public void visit(Node.UninterpretedTag n) throws JasperException {
+ String tag = n.getQName();
+ printAttributes("<"+tag, n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</" + tag + ">");
+ }
+
+ @Override
+ public void visit(Node.TemplateText n) throws JasperException {
+ printString(new String(n.getText()));
+ }
+
+ private void printIndent() {
+ for (int i=0; i < indent; i++) {
+ System.out.print(" ");
+ }
+ }
}
public static void dump(Node n) {
- try {
- n.accept(new DumpVisitor());
- } catch (JasperException e) {
- e.printStackTrace();
- }
+ try {
+ n.accept(new DumpVisitor());
+ } catch (JasperException e) {
+ e.printStackTrace();
+ }
}
public static void dump(Node.Nodes page) {
- try {
- page.visit(new DumpVisitor());
- } catch (JasperException e) {
- e.printStackTrace();
- }
+ try {
+ page.visit(new DumpVisitor());
+ } catch (JasperException e) {
+ e.printStackTrace();
+ }
}
}
Modified: tomcat/trunk/java/org/apache/jasper/compiler/ErrorDispatcher.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/ErrorDispatcher.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/ErrorDispatcher.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/ErrorDispatcher.java Sat Jul 24 13:03:11 2010
@@ -56,8 +56,8 @@ public class ErrorDispatcher {
* otherwise
*/
public ErrorDispatcher(boolean jspcMode) {
- // XXX check web.xml for custom error handler
- errHandler = new DefaultErrorHandler();
+ // XXX check web.xml for custom error handler
+ errHandler = new DefaultErrorHandler();
this.jspcMode = jspcMode;
}
@@ -71,7 +71,7 @@ public class ErrorDispatcher {
* @param errCode Error code
*/
public void jspError(String errCode) throws JasperException {
- dispatch(null, errCode, null, null);
+ dispatch(null, errCode, null, null);
}
/*
@@ -85,7 +85,7 @@ public class ErrorDispatcher {
* @param errCode Error code
*/
public void jspError(Mark where, String errCode) throws JasperException {
- dispatch(where, errCode, null, null);
+ dispatch(where, errCode, null, null);
}
/*
@@ -99,7 +99,7 @@ public class ErrorDispatcher {
* @param errCode Error code
*/
public void jspError(Node n, String errCode) throws JasperException {
- dispatch(n.getStart(), errCode, null, null);
+ dispatch(n.getStart(), errCode, null, null);
}
/*
@@ -113,7 +113,7 @@ public class ErrorDispatcher {
* @param arg Argument for parametric replacement
*/
public void jspError(String errCode, String arg) throws JasperException {
- dispatch(null, errCode, new Object[] {arg}, null);
+ dispatch(null, errCode, new Object[] {arg}, null);
}
/*
@@ -128,8 +128,8 @@ public class ErrorDispatcher {
* @param arg Argument for parametric replacement
*/
public void jspError(Mark where, String errCode, String arg)
- throws JasperException {
- dispatch(where, errCode, new Object[] {arg}, null);
+ throws JasperException {
+ dispatch(where, errCode, new Object[] {arg}, null);
}
/*
@@ -144,8 +144,8 @@ public class ErrorDispatcher {
* @param arg Argument for parametric replacement
*/
public void jspError(Node n, String errCode, String arg)
- throws JasperException {
- dispatch(n.getStart(), errCode, new Object[] {arg}, null);
+ throws JasperException {
+ dispatch(n.getStart(), errCode, new Object[] {arg}, null);
}
/*
@@ -160,8 +160,8 @@ public class ErrorDispatcher {
* @param arg2 Second argument for parametric replacement
*/
public void jspError(String errCode, String arg1, String arg2)
- throws JasperException {
- dispatch(null, errCode, new Object[] {arg1, arg2}, null);
+ throws JasperException {
+ dispatch(null, errCode, new Object[] {arg1, arg2}, null);
}
/*
@@ -177,8 +177,8 @@ public class ErrorDispatcher {
* @param arg3 Third argument for parametric replacement
*/
public void jspError(String errCode, String arg1, String arg2, String arg3)
- throws JasperException {
- dispatch(null, errCode, new Object[] {arg1, arg2, arg3}, null);
+ throws JasperException {
+ dispatch(null, errCode, new Object[] {arg1, arg2, arg3}, null);
}
/*
@@ -194,8 +194,8 @@ public class ErrorDispatcher {
* @param arg2 Second argument for parametric replacement
*/
public void jspError(Mark where, String errCode, String arg1, String arg2)
- throws JasperException {
- dispatch(where, errCode, new Object[] {arg1, arg2}, null);
+ throws JasperException {
+ dispatch(where, errCode, new Object[] {arg1, arg2}, null);
}
/*
@@ -232,8 +232,8 @@ public class ErrorDispatcher {
*/
public void jspError(Node n, String errCode, String arg1, String arg2)
- throws JasperException {
- dispatch(n.getStart(), errCode, new Object[] {arg1, arg2}, null);
+ throws JasperException {
+ dispatch(n.getStart(), errCode, new Object[] {arg1, arg2}, null);
}
/*
@@ -252,8 +252,8 @@ public class ErrorDispatcher {
public void jspError(Node n, String errCode, String arg1, String arg2,
String arg3)
- throws JasperException {
- dispatch(n.getStart(), errCode, new Object[] {arg1, arg2, arg3}, null);
+ throws JasperException {
+ dispatch(n.getStart(), errCode, new Object[] {arg1, arg2, arg3}, null);
}
/*
@@ -262,7 +262,7 @@ public class ErrorDispatcher {
* @param e Parsing exception
*/
public void jspError(Exception e) throws JasperException {
- dispatch(null, null, null, e);
+ dispatch(null, null, null, e);
}
/*
@@ -277,8 +277,8 @@ public class ErrorDispatcher {
* @param e Parsing exception
*/
public void jspError(String errCode, String arg, Exception e)
- throws JasperException {
- dispatch(null, errCode, new Object[] {arg}, e);
+ throws JasperException {
+ dispatch(null, errCode, new Object[] {arg}, e);
}
/*
@@ -294,8 +294,8 @@ public class ErrorDispatcher {
* @param e Parsing exception
*/
public void jspError(Node n, String errCode, String arg, Exception e)
- throws JasperException {
- dispatch(n.getStart(), errCode, new Object[] {arg}, e);
+ throws JasperException {
+ dispatch(n.getStart(), errCode, new Object[] {arg}, e);
}
/**
@@ -315,7 +315,7 @@ public class ErrorDispatcher {
Node.Nodes page)
throws JasperException, IOException {
- return parseJavacMessage(errMsg, fname, page);
+ return parseJavacMessage(errMsg, fname, page);
}
/*
@@ -361,23 +361,23 @@ public class ErrorDispatcher {
* @param e Parsing exception
*/
private void dispatch(Mark where, String errCode, Object[] args,
- Exception e) throws JasperException {
- String file = null;
- String errMsg = null;
- int line = -1;
- int column = -1;
- boolean hasLocation = false;
-
- // Localize
- if (errCode != null) {
- errMsg = Localizer.getMessage(errCode, args);
- } else if (e != null) {
- // give a hint about what's wrong
- errMsg = e.getMessage();
- }
+ Exception e) throws JasperException {
+ String file = null;
+ String errMsg = null;
+ int line = -1;
+ int column = -1;
+ boolean hasLocation = false;
+
+ // Localize
+ if (errCode != null) {
+ errMsg = Localizer.getMessage(errCode, args);
+ } else if (e != null) {
+ // give a hint about what's wrong
+ errMsg = e.getMessage();
+ }
- // Get error location
- if (where != null) {
+ // Get error location
+ if (where != null) {
if (jspcMode) {
// Get the full URL of the resource that caused the error
try {
@@ -391,23 +391,23 @@ public class ErrorDispatcher {
// disclose any local filesystem details
file = where.getFile();
}
- line = where.getLineNumber();
- column = where.getColumnNumber();
- hasLocation = true;
- }
-
- // Get nested exception
- Exception nestedEx = e;
- if ((e instanceof SAXException)
- && (((SAXException) e).getException() != null)) {
- nestedEx = ((SAXException) e).getException();
- }
-
- if (hasLocation) {
- errHandler.jspError(file, line, column, errMsg, nestedEx);
- } else {
- errHandler.jspError(errMsg, nestedEx);
- }
+ line = where.getLineNumber();
+ column = where.getColumnNumber();
+ hasLocation = true;
+ }
+
+ // Get nested exception
+ Exception nestedEx = e;
+ if ((e instanceof SAXException)
+ && (((SAXException) e).getException() != null)) {
+ nestedEx = ((SAXException) e).getException();
+ }
+
+ if (hasLocation) {
+ errHandler.jspError(file, line, column, errMsg, nestedEx);
+ } else {
+ errHandler.jspError(errMsg, nestedEx);
+ }
}
/*
@@ -428,7 +428,7 @@ public class ErrorDispatcher {
*/
private static JavacErrorDetail[] parseJavacMessage(
String errMsg, String fname, Node.Nodes page)
- throws IOException, JasperException {
+ throws IOException, JasperException {
ArrayList<JavacErrorDetail> errors = new ArrayList<JavacErrorDetail>();
StringBuilder errMsgBuf = null;
@@ -576,41 +576,41 @@ public class ErrorDispatcher {
*/
static class ErrorVisitor extends Node.Visitor {
- // Java source line number to be mapped
- private int lineNum;
+ // Java source line number to be mapped
+ private int lineNum;
- /*
- * JSP node whose Java source code range in the generated servlet
- * contains the Java source line number to be mapped
- */
- Node found;
-
- /*
- * Constructor.
- *
- * @param lineNum Source line number in the generated servlet code
- */
- public ErrorVisitor(int lineNum) {
- this.lineNum = lineNum;
- }
-
- @Override
- public void doVisit(Node n) throws JasperException {
- if ((lineNum >= n.getBeginJavaLine())
- && (lineNum < n.getEndJavaLine())) {
- found = n;
- }
+ /*
+ * JSP node whose Java source code range in the generated servlet
+ * contains the Java source line number to be mapped
+ */
+ Node found;
+
+ /*
+ * Constructor.
+ *
+ * @param lineNum Source line number in the generated servlet code
+ */
+ public ErrorVisitor(int lineNum) {
+ this.lineNum = lineNum;
}
- /*
- * Gets the JSP node to which the source line number in the generated
- * servlet code was mapped.
- *
- * @return JSP node to which the source line number in the generated
- * servlet code was mapped
- */
- public Node getJspSourceNode() {
- return found;
- }
+ @Override
+ public void doVisit(Node n) throws JasperException {
+ if ((lineNum >= n.getBeginJavaLine())
+ && (lineNum < n.getEndJavaLine())) {
+ found = n;
+ }
+ }
+
+ /*
+ * Gets the JSP node to which the source line number in the generated
+ * servlet code was mapped.
+ *
+ * @return JSP node to which the source line number in the generated
+ * servlet code was mapped
+ */
+ public Node getJspSourceNode() {
+ return found;
+ }
}
}
Modified: tomcat/trunk/java/org/apache/jasper/compiler/ErrorHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/ErrorHandler.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/ErrorHandler.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/ErrorHandler.java Sat Jul 24 13:03:11 2010
@@ -42,7 +42,7 @@ public interface ErrorHandler {
* @param exception Parse exception
*/
public void jspError(String fname, int line, int column, String msg,
- Exception exception) throws JasperException;
+ Exception exception) throws JasperException;
/**
* Processes the given JSP parse error.
@@ -51,7 +51,7 @@ public interface ErrorHandler {
* @param exception Parse exception
*/
public void jspError(String msg, Exception exception)
- throws JasperException;
+ throws JasperException;
/**
* Processes the given javac compilation errors.
@@ -60,7 +60,7 @@ public interface ErrorHandler {
* compilation errors
*/
public void javacError(JavacErrorDetail[] details)
- throws JasperException;
+ throws JasperException;
/**
* Processes the given javac error report and exception.
@@ -69,5 +69,5 @@ public interface ErrorHandler {
* @param exception Compilation exception
*/
public void javacError(String errorReport, Exception exception)
- throws JasperException;
+ throws JasperException;
}
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Generator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Generator.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Generator.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Generator.java Sat Jul 24 13:03:11 2010
@@ -2299,30 +2299,30 @@ class Generator {
}
private void writeNewInstance(String tagHandlerVar, String tagHandlerClassName) {
- if (Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
- out.printin(tagHandlerClassName);
- out.print(" ");
- out.print(tagHandlerVar);
- out.print(" = (");
- out.print(tagHandlerClassName);
- out.print(")");
- out.print(VAR_INSTANCEMANAGER);
- out.print(".newInstance(\"");
- out.print(tagHandlerClassName);
- out.println("\", this.getClass().getClassLoader());");
- } else {
- out.printin(tagHandlerClassName);
- out.print(" ");
- out.print(tagHandlerVar);
- out.print(" = (");
- out.print("new ");
- out.print(tagHandlerClassName);
- out.println("());");
- out.printin(VAR_INSTANCEMANAGER);
- out.print(".newInstance(");
- out.print(tagHandlerVar);
- out.println(");");
- }
+ if (Constants.USE_INSTANCE_MANAGER_FOR_TAGS) {
+ out.printin(tagHandlerClassName);
+ out.print(" ");
+ out.print(tagHandlerVar);
+ out.print(" = (");
+ out.print(tagHandlerClassName);
+ out.print(")");
+ out.print(VAR_INSTANCEMANAGER);
+ out.print(".newInstance(\"");
+ out.print(tagHandlerClassName);
+ out.println("\", this.getClass().getClassLoader());");
+ } else {
+ out.printin(tagHandlerClassName);
+ out.print(" ");
+ out.print(tagHandlerVar);
+ out.print(" = (");
+ out.print("new ");
+ out.print(tagHandlerClassName);
+ out.println("());");
+ out.printin(VAR_INSTANCEMANAGER);
+ out.print(".newInstance(");
+ out.print(tagHandlerVar);
+ out.println(");");
+ }
}
private void writeDestroyInstance(String tagHandlerVar) {
Modified: tomcat/trunk/java/org/apache/jasper/compiler/JarScannerFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JarScannerFactory.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JarScannerFactory.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JarScannerFactory.java Sat Jul 24 13:03:11 2010
@@ -41,7 +41,7 @@ public class JarScannerFactory {
*/
public static JarScanner getJarScanner(ServletContext ctxt) {
JarScanner jarScanner =
- (JarScanner) ctxt.getAttribute(JarScanner.class.getName());
+ (JarScanner) ctxt.getAttribute(JarScanner.class.getName());
if (jarScanner == null) {
ctxt.log(Localizer.getMessage("jsp.warning.noJarScanner"));
jarScanner = new StandardJarScanner();
Modified: tomcat/trunk/java/org/apache/jasper/compiler/JasperTagInfo.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JasperTagInfo.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JasperTagInfo.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JasperTagInfo.java Sat Jul 24 13:03:11 2010
@@ -30,26 +30,27 @@ class JasperTagInfo extends TagInfo {
private String dynamicAttrsMapName;
public JasperTagInfo(String tagName,
- String tagClassName,
- String bodyContent,
- String infoString,
- TagLibraryInfo taglib,
- TagExtraInfo tagExtraInfo,
- TagAttributeInfo[] attributeInfo,
- String displayName,
- String smallIcon,
- String largeIcon,
- TagVariableInfo[] tvi,
- String mapName) {
+ String tagClassName,
+ String bodyContent,
+ String infoString,
+ TagLibraryInfo taglib,
+ TagExtraInfo tagExtraInfo,
+ TagAttributeInfo[] attributeInfo,
+ String displayName,
+ String smallIcon,
+ String largeIcon,
+ TagVariableInfo[] tvi,
+ String mapName) {
- super(tagName, tagClassName, bodyContent, infoString, taglib,
- tagExtraInfo, attributeInfo, displayName, smallIcon, largeIcon,
- tvi);
- this.dynamicAttrsMapName = mapName;
+ super(tagName, tagClassName, bodyContent, infoString, taglib,
+ tagExtraInfo, attributeInfo, displayName, smallIcon, largeIcon,
+ tvi);
+
+ this.dynamicAttrsMapName = mapName;
}
public String getDynamicAttributesMapName() {
- return dynamicAttrsMapName;
+ return dynamicAttrsMapName;
}
@Override
Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspConfig.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JspConfig.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JspConfig.java Sat Jul 24 13:03:11 2010
@@ -45,8 +45,8 @@ public class JspConfig {
private ServletContext ctxt;
private volatile boolean initialized = false;
- private final static String defaultIsXml = null; // unspecified
- private String defaultIsELIgnored = null; // unspecified
+ private final static String defaultIsXml = null; // unspecified
+ private String defaultIsELIgnored = null; // unspecified
private final static String defaultIsScriptingInvalid = null;
private String defaultDeferedSyntaxAllowedAsLiteral = null;
private final static String defaultTrimDirectiveWhitespaces = null;
@@ -289,7 +289,7 @@ public class JspConfig {
init();
- // JSP Configuration settings do not apply to tag files
+ // JSP Configuration settings do not apply to tag files
if (jspProperties == null || uri.endsWith(".tag")
|| uri.endsWith(".tagx")) {
return defaultJspProperty;
Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java Sat Jul 24 13:03:11 2010
@@ -665,21 +665,21 @@ class JspDocumentParser
}
if (current instanceof Node.CustomTag) {
- String bodyType = getBodyType((Node.CustomTag) current);
- if (TagInfo.BODY_CONTENT_EMPTY.equalsIgnoreCase(bodyType)) {
- // Children - if any - must be JSP attributes
- Node.Nodes children = current.getBody();
- if (children != null && children.size() > 0) {
- for (int i = 0; i < children.size(); i++) {
- Node child = children.getNode(i);
- if (!(child instanceof Node.NamedAttribute)) {
- throw new SAXParseException(Localizer.getMessage(
- "jasper.error.emptybodycontent.nonempty",
- current.qName), locator);
- }
- }
- }
- }
+ String bodyType = getBodyType((Node.CustomTag) current);
+ if (TagInfo.BODY_CONTENT_EMPTY.equalsIgnoreCase(bodyType)) {
+ // Children - if any - must be JSP attributes
+ Node.Nodes children = current.getBody();
+ if (children != null && children.size() > 0) {
+ for (int i = 0; i < children.size(); i++) {
+ Node child = children.getNode(i);
+ if (!(child instanceof Node.NamedAttribute)) {
+ throw new SAXParseException(Localizer.getMessage(
+ "jasper.error.emptybodycontent.nonempty",
+ current.qName), locator);
+ }
+ }
+ }
+ }
}
if (current.getParent() != null) {
current = current.getParent();
Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java Sat Jul 24 13:03:11 2010
@@ -520,7 +520,7 @@ public final class JspRuntimeContext {
* If JSP's to be unloaded are found, they will be destroyed.
* Uses the lastCheck time from background compiler to determine if it is time to unload JSP's.
*/
- public void checkUnload() {
+ public void checkUnload() {
if (options.getMaxLoadedJsps() > 0) {
long now = System.currentTimeMillis();
if (now > (lastCheck + (options.getCheckInterval() * 1000L))) {
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Localizer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Localizer.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Localizer.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Localizer.java Sat Jul 24 13:03:11 2010
@@ -52,12 +52,12 @@ public class Localizer {
* @return Localized error message
*/
public static String getMessage(String errCode) {
- String errMsg = errCode;
- try {
- errMsg = bundle.getString(errCode);
- } catch (MissingResourceException e) {
- }
- return errMsg;
+ String errMsg = errCode;
+ try {
+ errMsg = bundle.getString(errCode);
+ } catch (MissingResourceException e) {
+ }
+ return errMsg;
}
/*
@@ -73,7 +73,7 @@ public class Localizer {
* @return Localized error message
*/
public static String getMessage(String errCode, String arg) {
- return getMessage(errCode, new Object[] {arg});
+ return getMessage(errCode, new Object[] {arg});
}
/*
@@ -90,7 +90,7 @@ public class Localizer {
* @return Localized error message
*/
public static String getMessage(String errCode, String arg1, String arg2) {
- return getMessage(errCode, new Object[] {arg1, arg2});
+ return getMessage(errCode, new Object[] {arg1, arg2});
}
/*
@@ -108,8 +108,8 @@ public class Localizer {
* @return Localized error message
*/
public static String getMessage(String errCode, String arg1, String arg2,
- String arg3) {
- return getMessage(errCode, new Object[] {arg1, arg2, arg3});
+ String arg3) {
+ return getMessage(errCode, new Object[] {arg1, arg2, arg3});
}
/*
@@ -128,8 +128,8 @@ public class Localizer {
* @return Localized error message
*/
public static String getMessage(String errCode, String arg1, String arg2,
- String arg3, String arg4) {
- return getMessage(errCode, new Object[] {arg1, arg2, arg3, arg4});
+ String arg3, String arg4) {
+ return getMessage(errCode, new Object[] {arg1, arg2, arg3, arg4});
}
/*
@@ -145,16 +145,16 @@ public class Localizer {
* @return Localized error message
*/
public static String getMessage(String errCode, Object[] args) {
- String errMsg = errCode;
- try {
- errMsg = bundle.getString(errCode);
- if (args != null) {
- MessageFormat formatter = new MessageFormat(errMsg);
- errMsg = formatter.format(args);
- }
- } catch (MissingResourceException e) {
- }
-
- return errMsg;
+ String errMsg = errCode;
+ try {
+ errMsg = bundle.getString(errCode);
+ if (args != null) {
+ MessageFormat formatter = new MessageFormat(errMsg);
+ errMsg = formatter.format(args);
+ }
+ } catch (MissingResourceException e) {
+ }
+
+ return errMsg;
}
}
Modified: tomcat/trunk/java/org/apache/jasper/compiler/Mark.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Mark.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Mark.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Mark.java Sat Jul 24 13:03:11 2010
@@ -142,7 +142,7 @@ final class Mark {
// store current state in stack
includeStack.push(new IncludeState(cursor, line, col, fileId,
fileName, baseDir,
- encoding, stream) );
+ encoding, stream) );
// set new variables
cursor = 0;
@@ -202,7 +202,7 @@ final class Mark {
@Override
public String toString() {
- return getFile()+"("+line+","+col+")";
+ return getFile()+"("+line+","+col+")";
}
public String getFile() {
@@ -222,13 +222,13 @@ final class Mark {
@Override
public boolean equals(Object other) {
- if (other instanceof Mark) {
- Mark m = (Mark) other;
- return this.reader == m.reader && this.fileId == m.fileId
- && this.cursor == m.cursor && this.line == m.line
- && this.col == m.col;
- }
- return false;
+ if (other instanceof Mark) {
+ Mark m = (Mark) other;
+ return this.reader == m.reader && this.fileId == m.fileId
+ && this.cursor == m.cursor && this.line == m.line
+ && this.col == m.col;
+ }
+ return false;
}
/**
Modified: tomcat/trunk/java/org/apache/jasper/compiler/PageDataImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/PageDataImpl.java?rev=978865&r1=978864&r2=978865&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/PageDataImpl.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/PageDataImpl.java Sat Jul 24 13:03:11 2010
@@ -61,19 +61,19 @@ class PageDataImpl extends PageData impl
* @param page the page nodes from which to generate the XML view
*/
public PageDataImpl(Node.Nodes page, Compiler compiler)
- throws JasperException {
+ throws JasperException {
- // First pass
- FirstPassVisitor firstPass = new FirstPassVisitor(page.getRoot(),
- compiler.getPageInfo());
- page.visit(firstPass);
-
- // Second pass
- buf = new StringBuilder();
- SecondPassVisitor secondPass
- = new SecondPassVisitor(page.getRoot(), buf, compiler,
- firstPass.getJspIdPrefix());
- page.visit(secondPass);
+ // First pass
+ FirstPassVisitor firstPass = new FirstPassVisitor(page.getRoot(),
+ compiler.getPageInfo());
+ page.visit(firstPass);
+
+ // Second pass
+ buf = new StringBuilder();
+ SecondPassVisitor secondPass
+ = new SecondPassVisitor(page.getRoot(), buf, compiler,
+ firstPass.getJspIdPrefix());
+ page.visit(secondPass);
}
/**
@@ -83,11 +83,11 @@ class PageDataImpl extends PageData impl
*/
@Override
public InputStream getInputStream() {
- // Turn StringBuilder into InputStream
+ // Turn StringBuilder into InputStream
try {
return new ByteArrayInputStream(buf.toString().getBytes("UTF-8"));
} catch (UnsupportedEncodingException uee) {
- // should never happen
+ // should never happen
throw new RuntimeException(uee.toString());
}
}
@@ -103,118 +103,118 @@ class PageDataImpl extends PageData impl
* attributes and adds them to the jsp:root element of the XML view.
*/
static class FirstPassVisitor
- extends Node.Visitor implements TagConstants {
+ extends Node.Visitor implements TagConstants {
- private Node.Root root;
- private AttributesImpl rootAttrs;
- private PageInfo pageInfo;
-
- // Prefix for the 'id' attribute
- private String jspIdPrefix;
-
- /*
- * Constructor
- */
- public FirstPassVisitor(Node.Root root, PageInfo pageInfo) {
- this.root = root;
- this.pageInfo = pageInfo;
- this.rootAttrs = new AttributesImpl();
- this.rootAttrs.addAttribute("", "", "version", "CDATA",
- JSP_VERSION);
- this.jspIdPrefix = "jsp";
- }
+ private Node.Root root;
+ private AttributesImpl rootAttrs;
+ private PageInfo pageInfo;
+
+ // Prefix for the 'id' attribute
+ private String jspIdPrefix;
+
+ /*
+ * Constructor
+ */
+ public FirstPassVisitor(Node.Root root, PageInfo pageInfo) {
+ this.root = root;
+ this.pageInfo = pageInfo;
+ this.rootAttrs = new AttributesImpl();
+ this.rootAttrs.addAttribute("", "", "version", "CDATA",
+ JSP_VERSION);
+ this.jspIdPrefix = "jsp";
+ }
- @Override
+ @Override
public void visit(Node.Root n) throws JasperException {
- visitBody(n);
- if (n == root) {
- /*
- * Top-level page.
- *
- * Add
- * xmlns:jsp="http://java.sun.com/JSP/Page"
- * attribute only if not already present.
- */
- if (!JSP_URI.equals(rootAttrs.getValue("xmlns:jsp"))) {
- rootAttrs.addAttribute("", "", "xmlns:jsp", "CDATA",
- JSP_URI);
- }
-
- if (pageInfo.isJspPrefixHijacked()) {
- /*
- * 'jsp' prefix has been hijacked, that is, bound to a
- * namespace other than the JSP namespace. This means that
- * when adding an 'id' attribute to each element, we can't
- * use the 'jsp' prefix. Therefore, create a new prefix
- * (one that is unique across the translation unit) for use
- * by the 'id' attribute, and bind it to the JSP namespace
- */
- jspIdPrefix += "jsp";
- while (pageInfo.containsPrefix(jspIdPrefix)) {
- jspIdPrefix += "jsp";
- }
- rootAttrs.addAttribute("", "", "xmlns:" + jspIdPrefix,
- "CDATA", JSP_URI);
- }
-
- root.setAttributes(rootAttrs);
- }
- }
+ visitBody(n);
+ if (n == root) {
+ /*
+ * Top-level page.
+ *
+ * Add
+ * xmlns:jsp="http://java.sun.com/JSP/Page"
+ * attribute only if not already present.
+ */
+ if (!JSP_URI.equals(rootAttrs.getValue("xmlns:jsp"))) {
+ rootAttrs.addAttribute("", "", "xmlns:jsp", "CDATA",
+ JSP_URI);
+ }
+
+ if (pageInfo.isJspPrefixHijacked()) {
+ /*
+ * 'jsp' prefix has been hijacked, that is, bound to a
+ * namespace other than the JSP namespace. This means that
+ * when adding an 'id' attribute to each element, we can't
+ * use the 'jsp' prefix. Therefore, create a new prefix
+ * (one that is unique across the translation unit) for use
+ * by the 'id' attribute, and bind it to the JSP namespace
+ */
+ jspIdPrefix += "jsp";
+ while (pageInfo.containsPrefix(jspIdPrefix)) {
+ jspIdPrefix += "jsp";
+ }
+ rootAttrs.addAttribute("", "", "xmlns:" + jspIdPrefix,
+ "CDATA", JSP_URI);
+ }
+
+ root.setAttributes(rootAttrs);
+ }
+ }
- @Override
+ @Override
public void visit(Node.JspRoot n) throws JasperException {
- addAttributes(n.getTaglibAttributes());
+ addAttributes(n.getTaglibAttributes());
addAttributes(n.getNonTaglibXmlnsAttributes());
- addAttributes(n.getAttributes());
+ addAttributes(n.getAttributes());
- visitBody(n);
- }
+ visitBody(n);
+ }
- /*
- * Converts taglib directive into "xmlns:..." attribute of jsp:root
- * element.
- */
- @Override
+ /*
+ * Converts taglib directive into "xmlns:..." attribute of jsp:root
+ * element.
+ */
+ @Override
public void visit(Node.TaglibDirective n) throws JasperException {
- Attributes attrs = n.getAttributes();
- if (attrs != null) {
- String qName = "xmlns:" + attrs.getValue("prefix");
- /*
- * According to javadocs of org.xml.sax.helpers.AttributesImpl,
- * the addAttribute method does not check to see if the
- * specified attribute is already contained in the list: This
- * is the application's responsibility!
- */
- if (rootAttrs.getIndex(qName) == -1) {
- String location = attrs.getValue("uri");
- if (location != null) {
+ Attributes attrs = n.getAttributes();
+ if (attrs != null) {
+ String qName = "xmlns:" + attrs.getValue("prefix");
+ /*
+ * According to javadocs of org.xml.sax.helpers.AttributesImpl,
+ * the addAttribute method does not check to see if the
+ * specified attribute is already contained in the list: This
+ * is the application's responsibility!
+ */
+ if (rootAttrs.getIndex(qName) == -1) {
+ String location = attrs.getValue("uri");
+ if (location != null) {
if (location.startsWith("/")) {
location = URN_JSPTLD + location;
}
- rootAttrs.addAttribute("", "", qName, "CDATA",
- location);
- } else {
- location = attrs.getValue("tagdir");
- rootAttrs.addAttribute("", "", qName, "CDATA",
- URN_JSPTAGDIR + location);
- }
- }
- }
- }
-
- public String getJspIdPrefix() {
- return jspIdPrefix;
- }
-
- private void addAttributes(Attributes attrs) {
- if (attrs != null) {
- int len = attrs.getLength();
+ rootAttrs.addAttribute("", "", qName, "CDATA",
+ location);
+ } else {
+ location = attrs.getValue("tagdir");
+ rootAttrs.addAttribute("", "", qName, "CDATA",
+ URN_JSPTAGDIR + location);
+ }
+ }
+ }
+ }
+
+ public String getJspIdPrefix() {
+ return jspIdPrefix;
+ }
- for (int i=0; i<len; i++) {
+ private void addAttributes(Attributes attrs) {
+ if (attrs != null) {
+ int len = attrs.getLength();
+
+ for (int i=0; i<len; i++) {
String qName = attrs.getQName(i);
- if ("version".equals(qName)) {
- continue;
- }
+ if ("version".equals(qName)) {
+ continue;
+ }
// Bugzilla 35252: http://issues.apache.org/bugzilla/show_bug.cgi?id=35252
if(rootAttrs.getIndex(qName) == -1) {
@@ -224,9 +224,9 @@ class PageDataImpl extends PageData impl
attrs.getType(i),
attrs.getValue(i));
}
- }
- }
- }
+ }
+ }
+ }
}
@@ -235,156 +235,156 @@ class PageDataImpl extends PageData impl
* each element a unique jsp:id attribute.
*/
static class SecondPassVisitor extends Node.Visitor
- implements TagConstants {
+ implements TagConstants {
- private Node.Root root;
- private StringBuilder buf;
- private Compiler compiler;
- private String jspIdPrefix;
- private boolean resetDefaultNS = false;
-
- // Current value of jsp:id attribute
- private int jspId;
-
- /*
- * Constructor
- */
- public SecondPassVisitor(Node.Root root, StringBuilder buf,
- Compiler compiler, String jspIdPrefix) {
- this.root = root;
- this.buf = buf;
- this.compiler = compiler;
- this.jspIdPrefix = jspIdPrefix;
- }
-
- /*
- * Visits root node.
- */
- @Override
+ private Node.Root root;
+ private StringBuilder buf;
+ private Compiler compiler;
+ private String jspIdPrefix;
+ private boolean resetDefaultNS = false;
+
+ // Current value of jsp:id attribute
+ private int jspId;
+
+ /*
+ * Constructor
+ */
+ public SecondPassVisitor(Node.Root root, StringBuilder buf,
+ Compiler compiler, String jspIdPrefix) {
+ this.root = root;
+ this.buf = buf;
+ this.compiler = compiler;
+ this.jspIdPrefix = jspIdPrefix;
+ }
+
+ /*
+ * Visits root node.
+ */
+ @Override
public void visit(Node.Root n) throws JasperException {
- if (n == this.root) {
- // top-level page
- appendXmlProlog();
- appendTag(n);
- } else {
- boolean resetDefaultNSSave = resetDefaultNS;
- if (n.isXmlSyntax()) {
- resetDefaultNS = true;
- }
- visitBody(n);
- resetDefaultNS = resetDefaultNSSave;
- }
- }
-
- /*
- * Visits jsp:root element of JSP page in XML syntax.
- *
- * Any nested jsp:root elements (from pages included via an
- * include directive) are ignored.
- */
- @Override
+ if (n == this.root) {
+ // top-level page
+ appendXmlProlog();
+ appendTag(n);
+ } else {
+ boolean resetDefaultNSSave = resetDefaultNS;
+ if (n.isXmlSyntax()) {
+ resetDefaultNS = true;
+ }
+ visitBody(n);
+ resetDefaultNS = resetDefaultNSSave;
+ }
+ }
+
+ /*
+ * Visits jsp:root element of JSP page in XML syntax.
+ *
+ * Any nested jsp:root elements (from pages included via an
+ * include directive) are ignored.
+ */
+ @Override
public void visit(Node.JspRoot n) throws JasperException {
- visitBody(n);
- }
+ visitBody(n);
+ }
- @Override
+ @Override
public void visit(Node.PageDirective n) throws JasperException {
- appendPageDirective(n);
- }
+ appendPageDirective(n);
+ }
- @Override
+ @Override
public void visit(Node.IncludeDirective n) throws JasperException {
- // expand in place
- visitBody(n);
- }
+ // expand in place
+ visitBody(n);
+ }
- @Override
+ @Override
public void visit(Node.Comment n) throws JasperException {
- // Comments are ignored in XML view
- }
+ // Comments are ignored in XML view
+ }
- @Override
+ @Override
public void visit(Node.Declaration n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.Expression n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.Scriptlet n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.JspElement n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.ELExpression n) throws JasperException {
- if (!n.getRoot().isXmlSyntax()) {
- buf.append("<").append(JSP_TEXT_ACTION);
- buf.append(" ");
- buf.append(jspIdPrefix);
- buf.append(":id=\"");
- buf.append(jspId++).append("\">");
- }
- buf.append("${");
+ if (!n.getRoot().isXmlSyntax()) {
+ buf.append("<").append(JSP_TEXT_ACTION);
+ buf.append(" ");
+ buf.append(jspIdPrefix);
+ buf.append(":id=\"");
+ buf.append(jspId++).append("\">");
+ }
+ buf.append("${");
buf.append(JspUtil.escapeXml(n.getText()));
- buf.append("}");
- if (!n.getRoot().isXmlSyntax()) {
- buf.append(JSP_TEXT_ACTION_END);
- }
- buf.append("\n");
- }
+ buf.append("}");
+ if (!n.getRoot().isXmlSyntax()) {
+ buf.append(JSP_TEXT_ACTION_END);
+ }
+ buf.append("\n");
+ }
- @Override
+ @Override
public void visit(Node.IncludeAction n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.ForwardAction n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.GetProperty n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.SetProperty n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.ParamAction n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.ParamsAction n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.FallBackAction n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.UseBean n) throws JasperException {
- appendTag(n);
- }
-
- @Override
+ appendTag(n);
+ }
+
+ @Override
public void visit(Node.PlugIn n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
@Override
public void visit(Node.NamedAttribute n) throws JasperException {
@@ -396,350 +396,350 @@ class PageDataImpl extends PageData impl
appendTag(n);
}
- @Override
+ @Override
public void visit(Node.CustomTag n) throws JasperException {
- boolean resetDefaultNSSave = resetDefaultNS;
- appendTag(n, resetDefaultNS);
- resetDefaultNS = resetDefaultNSSave;
- }
+ boolean resetDefaultNSSave = resetDefaultNS;
+ appendTag(n, resetDefaultNS);
+ resetDefaultNS = resetDefaultNSSave;
+ }
- @Override
+ @Override
public void visit(Node.UninterpretedTag n) throws JasperException {
- boolean resetDefaultNSSave = resetDefaultNS;
- appendTag(n, resetDefaultNS);
- resetDefaultNS = resetDefaultNSSave;
- }
+ boolean resetDefaultNSSave = resetDefaultNS;
+ appendTag(n, resetDefaultNS);
+ resetDefaultNS = resetDefaultNSSave;
+ }
- @Override
+ @Override
public void visit(Node.JspText n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.DoBodyAction n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
@Override
public void visit(Node.InvokeAction n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.TagDirective n) throws JasperException {
- appendTagDirective(n);
- }
+ appendTagDirective(n);
+ }
- @Override
+ @Override
public void visit(Node.AttributeDirective n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.VariableDirective n) throws JasperException {
- appendTag(n);
- }
+ appendTag(n);
+ }
- @Override
+ @Override
public void visit(Node.TemplateText n) throws JasperException {
- /*
- * If the template text came from a JSP page written in JSP syntax,
- * create a jsp:text element for it (JSP 5.3.2).
- */
- appendText(n.getText(), !n.getRoot().isXmlSyntax());
- }
-
- /*
- * Appends the given tag, including its body, to the XML view.
- */
- private void appendTag(Node n) throws JasperException {
- appendTag(n, false);
- }
-
- /*
- * Appends the given tag, including its body, to the XML view,
- * and optionally reset default namespace to "", if none specified.
- */
- private void appendTag(Node n, boolean addDefaultNS)
- throws JasperException {
-
- Node.Nodes body = n.getBody();
- String text = n.getText();
-
- buf.append("<").append(n.getQName());
- buf.append("\n");
-
- printAttributes(n, addDefaultNS);
- buf.append(" ").append(jspIdPrefix).append(":id").append("=\"");
- buf.append(jspId++).append("\"\n");
-
- if (ROOT_ACTION.equals(n.getLocalName()) || body != null
- || text != null) {
- buf.append(">\n");
- if (ROOT_ACTION.equals(n.getLocalName())) {
- if (compiler.getCompilationContext().isTagFile()) {
- appendTagDirective();
- } else {
- appendPageDirective();
- }
- }
- if (body != null) {
- body.visit(this);
- } else {
- appendText(text, false);
- }
- buf.append("</" + n.getQName() + ">\n");
- } else {
- buf.append("/>\n");
- }
- }
-
- /*
- * Appends the page directive with the given attributes to the XML
- * view.
- *
- * Since the import attribute of the page directive is the only page
- * attribute that is allowed to appear multiple times within the same
- * document, and since XML allows only single-value attributes,
- * the values of multiple import attributes must be combined into one,
- * separated by comma.
- *
- * If the given page directive contains just 'contentType' and/or
- * 'pageEncoding' attributes, we ignore it, as we've already appended
- * a page directive containing just these two attributes.
- */
- private void appendPageDirective(Node.PageDirective n) {
- boolean append = false;
- Attributes attrs = n.getAttributes();
- int len = (attrs == null) ? 0 : attrs.getLength();
- for (int i=0; i<len; i++) {
- String attrName = attrs.getQName(i);
- if (!"pageEncoding".equals(attrName)
- && !"contentType".equals(attrName)) {
- append = true;
- break;
- }
- }
- if (!append) {
- return;
- }
-
- buf.append("<").append(n.getQName());
- buf.append("\n");
-
- // append jsp:id
- buf.append(" ").append(jspIdPrefix).append(":id").append("=\"");
- buf.append(jspId++).append("\"\n");
-
- // append remaining attributes
- for (int i=0; i<len; i++) {
- String attrName = attrs.getQName(i);
- if ("import".equals(attrName) || "contentType".equals(attrName)
- || "pageEncoding".equals(attrName)) {
- /*
- * Page directive's 'import' attribute is considered
- * further down, and its 'pageEncoding' and 'contentType'
- * attributes are ignored, since we've already appended
- * a new page directive containing just these two
- * attributes
- */
- continue;
- }
- String value = attrs.getValue(i);
- buf.append(" ").append(attrName).append("=\"");
- buf.append(JspUtil.getExprInXml(value)).append("\"\n");
- }
- if (n.getImports().size() > 0) {
- // Concatenate names of imported classes/packages
- boolean first = true;
- ListIterator<String> iter = n.getImports().listIterator();
- while (iter.hasNext()) {
- if (first) {
- first = false;
- buf.append(" import=\"");
- } else {
- buf.append(",");
- }
- buf.append(JspUtil.getExprInXml(iter.next()));
- }
- buf.append("\"\n");
- }
- buf.append("/>\n");
- }
-
- /*
- * Appends a page directive with 'pageEncoding' and 'contentType'
- * attributes.
- *
- * The value of the 'pageEncoding' attribute is hard-coded
- * to UTF-8, whereas the value of the 'contentType' attribute, which
- * is identical to what the container will pass to
- * ServletResponse.setContentType(), is derived from the pageInfo.
- */
- private void appendPageDirective() {
- buf.append("<").append(JSP_PAGE_DIRECTIVE_ACTION);
- buf.append("\n");
-
- // append jsp:id
- buf.append(" ").append(jspIdPrefix).append(":id").append("=\"");
- buf.append(jspId++).append("\"\n");
- buf.append(" ").append("pageEncoding").append("=\"UTF-8\"\n");
- buf.append(" ").append("contentType").append("=\"");
- buf.append(compiler.getPageInfo().getContentType()).append("\"\n");
- buf.append("/>\n");
- }
-
- /*
- * Appends the tag directive with the given attributes to the XML
- * view.
- *
- * If the given tag directive contains just a 'pageEncoding'
- * attributes, we ignore it, as we've already appended
- * a tag directive containing just this attributes.
- */
- private void appendTagDirective(Node.TagDirective n)
- throws JasperException {
-
- boolean append = false;
- Attributes attrs = n.getAttributes();
- int len = (attrs == null) ? 0 : attrs.getLength();
- for (int i=0; i<len; i++) {
- String attrName = attrs.getQName(i);
- if (!"pageEncoding".equals(attrName)) {
- append = true;
- break;
- }
- }
- if (!append) {
- return;
- }
-
- appendTag(n);
- }
-
- /*
- * Appends a tag directive containing a single 'pageEncoding'
- * attribute whose value is hard-coded to UTF-8.
- */
- private void appendTagDirective() {
- buf.append("<").append(JSP_TAG_DIRECTIVE_ACTION);
- buf.append("\n");
-
- // append jsp:id
- buf.append(" ").append(jspIdPrefix).append(":id").append("=\"");
- buf.append(jspId++).append("\"\n");
- buf.append(" ").append("pageEncoding").append("=\"UTF-8\"\n");
- buf.append("/>\n");
- }
-
- private void appendText(String text, boolean createJspTextElement) {
- if (createJspTextElement) {
- buf.append("<").append(JSP_TEXT_ACTION);
- buf.append("\n");
-
- // append jsp:id
- buf.append(" ").append(jspIdPrefix).append(":id").append("=\"");
- buf.append(jspId++).append("\"\n");
- buf.append(">\n");
-
- appendCDATA(text);
- buf.append(JSP_TEXT_ACTION_END);
- buf.append("\n");
- } else {
- appendCDATA(text);
- }
- }
-
- /*
- * Appends the given text as a CDATA section to the XML view, unless
- * the text has already been marked as CDATA.
- */
- private void appendCDATA(String text) {
- buf.append(CDATA_START_SECTION);
- buf.append(escapeCDATA(text));
- buf.append(CDATA_END_SECTION);
- }
-
- /*
- * Escapes any occurrences of "]]>" (by replacing them with "]]>")
- * within the given text, so it can be included in a CDATA section.
- */
- private String escapeCDATA(String text) {
+ /*
+ * If the template text came from a JSP page written in JSP syntax,
+ * create a jsp:text element for it (JSP 5.3.2).
+ */
+ appendText(n.getText(), !n.getRoot().isXmlSyntax());
+ }
+
+ /*
+ * Appends the given tag, including its body, to the XML view.
+ */
+ private void appendTag(Node n) throws JasperException {
+ appendTag(n, false);
+ }
+
+ /*
+ * Appends the given tag, including its body, to the XML view,
+ * and optionally reset default namespace to "", if none specified.
+ */
+ private void appendTag(Node n, boolean addDefaultNS)
+ throws JasperException {
+
+ Node.Nodes body = n.getBody();
+ String text = n.getText();
+
+ buf.append("<").append(n.getQName());
+ buf.append("\n");
+
+ printAttributes(n, addDefaultNS);
+ buf.append(" ").append(jspIdPrefix).append(":id").append("=\"");
+ buf.append(jspId++).append("\"\n");
+
+ if (ROOT_ACTION.equals(n.getLocalName()) || body != null
+ || text != null) {
+ buf.append(">\n");
+ if (ROOT_ACTION.equals(n.getLocalName())) {
+ if (compiler.getCompilationContext().isTagFile()) {
+ appendTagDirective();
+ } else {
+ appendPageDirective();
+ }
+ }
+ if (body != null) {
+ body.visit(this);
+ } else {
+ appendText(text, false);
+ }
+ buf.append("</" + n.getQName() + ">\n");
+ } else {
+ buf.append("/>\n");
+ }
+ }
+
+ /*
+ * Appends the page directive with the given attributes to the XML
+ * view.
+ *
+ * Since the import attribute of the page directive is the only page
+ * attribute that is allowed to appear multiple times within the same
+ * document, and since XML allows only single-value attributes,
+ * the values of multiple import attributes must be combined into one,
+ * separated by comma.
+ *
+ * If the given page directive contains just 'contentType' and/or
+ * 'pageEncoding' attributes, we ignore it, as we've already appended
+ * a page directive containing just these two attributes.
+ */
+ private void appendPageDirective(Node.PageDirective n) {
+ boolean append = false;
+ Attributes attrs = n.getAttributes();
+ int len = (attrs == null) ? 0 : attrs.getLength();
+ for (int i=0; i<len; i++) {
+ String attrName = attrs.getQName(i);
+ if (!"pageEncoding".equals(attrName)
+ && !"contentType".equals(attrName)) {
+ append = true;
+ break;
+ }
+ }
+ if (!append) {
+ return;
+ }
+
+ buf.append("<").append(n.getQName());
+ buf.append("\n");
+
+ // append jsp:id
+ buf.append(" ").append(jspIdPrefix).append(":id").append("=\"");
+ buf.append(jspId++).append("\"\n");
+
+ // append remaining attributes
+ for (int i=0; i<len; i++) {
+ String attrName = attrs.getQName(i);
+ if ("import".equals(attrName) || "contentType".equals(attrName)
+ || "pageEncoding".equals(attrName)) {
+ /*
+ * Page directive's 'import' attribute is considered
+ * further down, and its 'pageEncoding' and 'contentType'
+ * attributes are ignored, since we've already appended
+ * a new page directive containing just these two
+ * attributes
+ */
+ continue;
+ }
+ String value = attrs.getValue(i);
+ buf.append(" ").append(attrName).append("=\"");
+ buf.append(JspUtil.getExprInXml(value)).append("\"\n");
+ }
+ if (n.getImports().size() > 0) {
+ // Concatenate names of imported classes/packages
+ boolean first = true;
+ ListIterator<String> iter = n.getImports().listIterator();
+ while (iter.hasNext()) {
+ if (first) {
+ first = false;
+ buf.append(" import=\"");
+ } else {
+ buf.append(",");
+ }
+ buf.append(JspUtil.getExprInXml(iter.next()));
+ }
+ buf.append("\"\n");
+ }
+ buf.append("/>\n");
+ }
+
+ /*
+ * Appends a page directive with 'pageEncoding' and 'contentType'
+ * attributes.
+ *
+ * The value of the 'pageEncoding' attribute is hard-coded
+ * to UTF-8, whereas the value of the 'contentType' attribute, which
+ * is identical to what the container will pass to
+ * ServletResponse.setContentType(), is derived from the pageInfo.
+ */
+ private void appendPageDirective() {
+ buf.append("<").append(JSP_PAGE_DIRECTIVE_ACTION);
+ buf.append("\n");
+
+ // append jsp:id
+ buf.append(" ").append(jspIdPrefix).append(":id").append("=\"");
+ buf.append(jspId++).append("\"\n");
+ buf.append(" ").append("pageEncoding").append("=\"UTF-8\"\n");
+ buf.append(" ").append("contentType").append("=\"");
+ buf.append(compiler.getPageInfo().getContentType()).append("\"\n");
+ buf.append("/>\n");
+ }
+
+ /*
+ * Appends the tag directive with the given attributes to the XML
+ * view.
+ *
+ * If the given tag directive contains just a 'pageEncoding'
+ * attributes, we ignore it, as we've already appended
+ * a tag directive containing just this attributes.
+ */
+ private void appendTagDirective(Node.TagDirective n)
+ throws JasperException {
+
+ boolean append = false;
+ Attributes attrs = n.getAttributes();
+ int len = (attrs == null) ? 0 : attrs.getLength();
+ for (int i=0; i<len; i++) {
+ String attrName = attrs.getQName(i);
+ if (!"pageEncoding".equals(attrName)) {
+ append = true;
+ break;
+ }
+ }
+ if (!append) {
+ return;
+ }
+
+ appendTag(n);
+ }
+
+ /*
+ * Appends a tag directive containing a single 'pageEncoding'
+ * attribute whose value is hard-coded to UTF-8.
+ */
+ private void appendTagDirective() {
+ buf.append("<").append(JSP_TAG_DIRECTIVE_ACTION);
+ buf.append("\n");
+
+ // append jsp:id
+ buf.append(" ").append(jspIdPrefix).append(":id").append("=\"");
+ buf.append(jspId++).append("\"\n");
+ buf.append(" ").append("pageEncoding").append("=\"UTF-8\"\n");
+ buf.append("/>\n");
+ }
+
+ private void appendText(String text, boolean createJspTextElement) {
+ if (createJspTextElement) {
+ buf.append("<").append(JSP_TEXT_ACTION);
+ buf.append("\n");
+
+ // append jsp:id
+ buf.append(" ").append(jspIdPrefix).append(":id").append("=\"");
+ buf.append(jspId++).append("\"\n");
+ buf.append(">\n");
+
+ appendCDATA(text);
+ buf.append(JSP_TEXT_ACTION_END);
+ buf.append("\n");
+ } else {
+ appendCDATA(text);
+ }
+ }
+
+ /*
+ * Appends the given text as a CDATA section to the XML view, unless
+ * the text has already been marked as CDATA.
+ */
+ private void appendCDATA(String text) {
+ buf.append(CDATA_START_SECTION);
+ buf.append(escapeCDATA(text));
+ buf.append(CDATA_END_SECTION);
+ }
+
+ /*
+ * Escapes any occurrences of "]]>" (by replacing them with "]]>")
+ * within the given text, so it can be included in a CDATA section.
+ */
+ private String escapeCDATA(String text) {
if( text==null ) return "";
- int len = text.length();
- CharArrayWriter result = new CharArrayWriter(len);
- for (int i=0; i<len; i++) {
- if (((i+2) < len)
- && (text.charAt(i) == ']')
- && (text.charAt(i+1) == ']')
- && (text.charAt(i+2) == '>')) {
- // match found
- result.write(']');
- result.write(']');
- result.write('&');
- result.write('g');
- result.write('t');
- result.write(';');
- i += 2;
- } else {
- result.write(text.charAt(i));
- }
- }
- return result.toString();
- }
-
- /*
- * Appends the attributes of the given Node to the XML view.
- */
- private void printAttributes(Node n, boolean addDefaultNS) {
-
- /*
- * Append "xmlns" attributes that represent tag libraries
- */
- Attributes attrs = n.getTaglibAttributes();
- int len = (attrs == null) ? 0 : attrs.getLength();
- for (int i=0; i<len; i++) {
- String name = attrs.getQName(i);
- String value = attrs.getValue(i);
- buf.append(" ").append(name).append("=\"").append(value).append("\"\n");
- }
-
- /*
- * Append "xmlns" attributes that do not represent tag libraries
- */
- attrs = n.getNonTaglibXmlnsAttributes();
- len = (attrs == null) ? 0 : attrs.getLength();
- boolean defaultNSSeen = false;
- for (int i=0; i<len; i++) {
- String name = attrs.getQName(i);
- String value = attrs.getValue(i);
- buf.append(" ").append(name).append("=\"").append(value).append("\"\n");
- defaultNSSeen |= "xmlns".equals(name);
- }
- if (addDefaultNS && !defaultNSSeen) {
- buf.append(" xmlns=\"\"\n");
- }
- resetDefaultNS = false;
-
- /*
- * Append all other attributes
- */
- attrs = n.getAttributes();
- len = (attrs == null) ? 0 : attrs.getLength();
- for (int i=0; i<len; i++) {
- String name = attrs.getQName(i);
- String value = attrs.getValue(i);
- buf.append(" ").append(name).append("=\"");
- buf.append(JspUtil.getExprInXml(value)).append("\"\n");
- }
- }
-
- /*
- * Appends XML prolog with encoding declaration.
- */
- private void appendXmlProlog() {
- buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
- }
+ int len = text.length();
+ CharArrayWriter result = new CharArrayWriter(len);
+ for (int i=0; i<len; i++) {
+ if (((i+2) < len)
+ && (text.charAt(i) == ']')
+ && (text.charAt(i+1) == ']')
+ && (text.charAt(i+2) == '>')) {
+ // match found
+ result.write(']');
+ result.write(']');
+ result.write('&');
+ result.write('g');
+ result.write('t');
+ result.write(';');
+ i += 2;
+ } else {
+ result.write(text.charAt(i));
+ }
+ }
+ return result.toString();
+ }
+
+ /*
+ * Appends the attributes of the given Node to the XML view.
+ */
+ private void printAttributes(Node n, boolean addDefaultNS) {
+
+ /*
+ * Append "xmlns" attributes that represent tag libraries
+ */
+ Attributes attrs = n.getTaglibAttributes();
+ int len = (attrs == null) ? 0 : attrs.getLength();
+ for (int i=0; i<len; i++) {
+ String name = attrs.getQName(i);
+ String value = attrs.getValue(i);
+ buf.append(" ").append(name).append("=\"").append(value).append("\"\n");
+ }
+
+ /*
+ * Append "xmlns" attributes that do not represent tag libraries
+ */
+ attrs = n.getNonTaglibXmlnsAttributes();
+ len = (attrs == null) ? 0 : attrs.getLength();
+ boolean defaultNSSeen = false;
+ for (int i=0; i<len; i++) {
+ String name = attrs.getQName(i);
+ String value = attrs.getValue(i);
+ buf.append(" ").append(name).append("=\"").append(value).append("\"\n");
+ defaultNSSeen |= "xmlns".equals(name);
+ }
+ if (addDefaultNS && !defaultNSSeen) {
+ buf.append(" xmlns=\"\"\n");
+ }
+ resetDefaultNS = false;
+
+ /*
+ * Append all other attributes
+ */
+ attrs = n.getAttributes();
+ len = (attrs == null) ? 0 : attrs.getLength();
+ for (int i=0; i<len; i++) {
+ String name = attrs.getQName(i);
+ String value = attrs.getValue(i);
+ buf.append(" ").append(name).append("=\"");
+ buf.append(JspUtil.getExprInXml(value)).append("\"\n");
+ }
+ }
+
+ /*
+ * Appends XML prolog with encoding declaration.
+ */
+ private void appendXmlProlog() {
+ buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org