You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by js...@apache.org on 2024/09/20 09:02:36 UTC
(sling-org-apache-sling-scripting-jsp) branch jsedding/SLING-12438-update-parent created (now dde3419)
This is an automated email from the ASF dual-hosted git repository.
jsedding pushed a change to branch jsedding/SLING-12438-update-parent
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-jsp.git
at dde3419 SLING-12438 - Update Sling Scripting JSP to parent version 60
This branch includes the following new commits:
new cc5bc3a SLING-12438 - Update Sling Scripting JSP to parent version 60
new 13325d0 SLING-12438 - Update Sling Scripting JSP to parent version 60
new dde3419 SLING-12438 - Update Sling Scripting JSP to parent version 60
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(sling-org-apache-sling-scripting-jsp) 01/03: SLING-12438 - Update Sling Scripting JSP to parent version 60
Posted by js...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jsedding pushed a commit to branch jsedding/SLING-12438-update-parent
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-jsp.git
commit cc5bc3a16d30a8607ab34a9023fe3908856876e5
Author: Julian Sedding <js...@apache.org>
AuthorDate: Fri Sep 20 11:00:23 2024 +0200
SLING-12438 - Update Sling Scripting JSP to parent version 60
- update to 60
- add .sling-module.json to build only on java 17+
---
.sling-module.json | 6 ++++++
bnd.bnd | 3 +++
pom.xml | 48 ++++++++++++++++++++++++++++--------------------
3 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/.sling-module.json b/.sling-module.json
new file mode 100644
index 0000000..d32d0be
--- /dev/null
+++ b/.sling-module.json
@@ -0,0 +1,6 @@
+{
+ "jenkins": {
+ "jdks": [17, 21],
+ "operatingSystems": [ "linux", "linux-arm", "windows" ]
+ }
+}
diff --git a/bnd.bnd b/bnd.bnd
index 9e1431b..56fd587 100644
--- a/bnd.bnd
+++ b/bnd.bnd
@@ -2,3 +2,6 @@ ScriptEngine-Name:${project.name}
ScriptEngine-Version:${project.version}
Import-Package: *
-conditionalpackage: org.apache.el.*
+# note: -fixupmessage also overwrites the directive inherited from the parent
+-fixupmessages: "Export org.apache.sling.scripting.jsp.jasper.runtime, has 2, private references"; \
+ is:=ignore
diff --git a/pom.xml b/pom.xml
index e973bfb..f0f296e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -7,9 +7,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling-bundle-parent</artifactId>
- <version>35</version>
+ <version>60</version>
<relativePath />
</parent>
@@ -36,45 +36,39 @@
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-jsp.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-jsp.git</developerConnection>
+ <tag>HEAD</tag>
<url>https://github.com/apache/sling-org-apache-sling-scripting-jsp.git</url>
- <tag>HEAD</tag>
- </scm>
+ </scm>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <!-- No javadocs -->
- <excludePackageNames>
- org.apache.sling.scripting,org.apache.juli.logging
- </excludePackageNames>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <properties>
+ <sling.java.version>11</sling.java.version>
+ </properties>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.framework</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.versioning</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.metatype.annotations</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.bundle</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
@@ -132,6 +126,7 @@
<groupId>org.apache.tomcat</groupId>
<artifactId>jasper-el</artifactId>
<version>6.0.30</version>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
@@ -151,4 +146,17 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <!-- No javadocs -->
+ <excludePackageNames>org.apache.sling.scripting,org.apache.juli.logging</excludePackageNames>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
(sling-org-apache-sling-scripting-jsp) 02/03: SLING-12438 - Update Sling Scripting JSP to parent version 60
Posted by js...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jsedding pushed a commit to branch jsedding/SLING-12438-update-parent
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-jsp.git
commit 13325d09ebd5822bc842f8cf3dd49b0499dc02b0
Author: Julian Sedding <js...@apache.org>
AuthorDate: Fri Sep 20 11:00:42 2024 +0200
SLING-12438 - Update Sling Scripting JSP to parent version 60
- apply spotless code formatting
---
src/main/java/org/apache/juli/logging/Log.java | 49 +-
.../juli/logging/LogConfigurationException.java | 4 +-
.../java/org/apache/juli/logging/LogFactory.java | 9 +-
.../java/org/apache/juli/logging/Slf4jLog.java | 2 -
.../scripting/jsp/JspScriptEngineFactory.java | 284 ++--
.../sling/scripting/jsp/JspServletConfig.java | 8 +-
.../sling/scripting/jsp/JspServletContext.java | 63 +-
.../sling/scripting/jsp/JspServletOptions.java | 48 +-
.../sling/scripting/jsp/PrecompiledJSPRunner.java | 86 +-
.../sling/scripting/jsp/SlingIOProvider.java | 46 +-
.../sling/scripting/jsp/SlingJspPageContext.java | 55 +-
.../sling/scripting/jsp/SlingPageException.java | 3 +-
.../scripting/jsp/SlingTldLocationsCache.java | 52 +-
.../sling/scripting/jsp/jasper/Constants.java | 159 +-
.../sling/scripting/jsp/jasper/IOProvider.java | 28 +-
.../scripting/jsp/jasper/JasperException.java | 45 +-
.../jsp/jasper/JspCompilationContext.java | 232 ++-
.../apache/sling/scripting/jsp/jasper/Options.java | 27 +-
.../jsp/jasper/compiler/BeanRepository.java | 59 +-
.../scripting/jsp/jasper/compiler/Collector.java | 66 +-
.../scripting/jsp/jasper/compiler/Compiler.java | 82 +-
.../jsp/jasper/compiler/DefaultErrorHandler.java | 80 +-
.../scripting/jsp/jasper/compiler/Dumper.java | 259 ++-
.../jsp/jasper/compiler/ELFunctionMapper.java | 88 +-
.../scripting/jsp/jasper/compiler/ELNode.java | 345 ++--
.../scripting/jsp/jasper/compiler/ELParser.java | 76 +-
.../jsp/jasper/compiler/ErrorDispatcher.java | 306 ++--
.../jsp/jasper/compiler/ErrorHandler.java | 45 +-
.../scripting/jsp/jasper/compiler/Generator.java | 724 ++++-----
.../jasper/compiler/ImplicitTagLibraryInfo.java | 77 +-
.../scripting/jsp/jasper/compiler/JDTCompiler.java | 71 +-
.../jsp/jasper/compiler/JasperTagInfo.java | 75 +-
.../jsp/jasper/compiler/JavacErrorDetail.java | 68 +-
.../scripting/jsp/jasper/compiler/JspConfig.java | 194 ++-
.../jsp/jasper/compiler/JspDocumentParser.java | 761 +++------
.../scripting/jsp/jasper/compiler/JspReader.java | 201 +--
.../jsp/jasper/compiler/JspRuntimeContext.java | 176 ++-
.../scripting/jsp/jasper/compiler/JspUtil.java | 1069 +++++++------
.../scripting/jsp/jasper/compiler/Localizer.java | 96 +-
.../sling/scripting/jsp/jasper/compiler/Mark.java | 96 +-
.../sling/scripting/jsp/jasper/compiler/Node.java | 535 ++++---
.../jsp/jasper/compiler/PageDataImpl.java | 1204 +++++++-------
.../scripting/jsp/jasper/compiler/PageInfo.java | 198 +--
.../scripting/jsp/jasper/compiler/Parser.java | 350 ++--
.../jsp/jasper/compiler/ParserController.java | 148 +-
.../jsp/jasper/compiler/ScriptingVariabler.java | 220 ++-
.../jsp/jasper/compiler/ServletWriter.java | 75 +-
.../jsp/jasper/compiler/SmapGenerator.java | 163 +-
.../scripting/jsp/jasper/compiler/SmapStratum.java | 170 +-
.../scripting/jsp/jasper/compiler/SmapUtil.java | 229 ++-
.../jsp/jasper/compiler/TagConstants.java | 31 +-
.../jsp/jasper/compiler/TagFileProcessor.java | 271 ++--
.../jsp/jasper/compiler/TagLibraryInfoImpl.java | 294 ++--
.../jsp/jasper/compiler/TagPluginManager.java | 353 ++---
.../jsp/jasper/compiler/TextOptimizer.java | 58 +-
.../jsp/jasper/compiler/TldLocationsCache.java | 30 +-
.../scripting/jsp/jasper/compiler/Validator.java | 801 +++++-----
.../jsp/jasper/compiler/tagplugin/TagPlugin.java | 33 +-
.../compiler/tagplugin/TagPluginContext.java | 34 +-
.../scripting/jsp/jasper/el/ELContextImpl.java | 52 +-
.../scripting/jsp/jasper/el/ELContextWrapper.java | 39 +-
.../scripting/jsp/jasper/el/ELResolverImpl.java | 247 ++-
.../jsp/jasper/el/ExpressionEvaluatorImpl.java | 72 +-
.../scripting/jsp/jasper/el/ExpressionImpl.java | 47 +-
.../jsp/jasper/el/FunctionMapperImpl.java | 49 +-
.../scripting/jsp/jasper/el/JspELException.java | 30 +-
.../jsp/jasper/el/JspMethodExpression.java | 53 +-
.../jsp/jasper/el/JspMethodNotFoundException.java | 30 +-
.../jasper/el/JspPropertyNotFoundException.java | 34 +-
.../jasper/el/JspPropertyNotWritableException.java | 33 +-
.../jsp/jasper/el/JspValueExpression.java | 60 +-
.../jsp/jasper/el/VariableResolverImpl.java | 45 +-
.../jsp/jasper/runtime/AnnotationHelper.java | 45 +-
.../jsp/jasper/runtime/AnnotationProcessor.java | 45 +-
.../jsp/jasper/runtime/BodyContentImpl.java | 177 +--
.../runtime/ExternalServletContextWrapper.java | 61 +-
.../scripting/jsp/jasper/runtime/HttpJspBase.java | 86 +-
.../runtime/InternalServletConfigWrapper.java | 51 +-
.../jasper/runtime/JspApplicationContextImpl.java | 213 ++-
.../jsp/jasper/runtime/JspContextWrapper.java | 833 +++++-----
.../jsp/jasper/runtime/JspFactoryImpl.java | 96 +-
.../jsp/jasper/runtime/JspFragmentHelper.java | 50 +-
.../jsp/jasper/runtime/JspRuntimeLibrary.java | 1251 +++++++--------
.../jsp/jasper/runtime/JspSourceDependent.java | 43 +-
.../jsp/jasper/runtime/JspWriterImpl.java | 255 ++-
.../jsp/jasper/runtime/PageContextImpl.java | 1671 ++++++++++----------
.../jasper/runtime/ProtectedFunctionMapper.java | 114 +-
.../runtime/ServletResponseWrapperInclude.java | 59 +-
.../jsp/jasper/runtime/TagHandlerPool.java | 94 +-
.../scripting/jsp/jasper/runtime/package-info.java | 34 +-
.../jsp/jasper/security/SecurityClassLoad.java | 129 +-
.../jsp/jasper/security/SecurityUtil.java | 44 +-
.../jsp/jasper/servlet/JspServletWrapper.java | 307 ++--
.../scripting/jsp/jasper/tagplugins/jstl/Util.java | 124 +-
.../jsp/jasper/tagplugins/jstl/core/Catch.java | 83 +-
.../jsp/jasper/tagplugins/jstl/core/Choose.java | 38 +-
.../jsp/jasper/tagplugins/jstl/core/ForEach.java | 351 ++--
.../jsp/jasper/tagplugins/jstl/core/ForTokens.java | 119 +-
.../jsp/jasper/tagplugins/jstl/core/If.java | 34 +-
.../jsp/jasper/tagplugins/jstl/core/Import.java | 466 +++---
.../jsp/jasper/tagplugins/jstl/core/Otherwise.java | 36 +-
.../jsp/jasper/tagplugins/jstl/core/Out.java | 83 +-
.../jsp/jasper/tagplugins/jstl/core/Param.java | 90 +-
.../jsp/jasper/tagplugins/jstl/core/Redirect.java | 100 +-
.../jsp/jasper/tagplugins/jstl/core/Remove.java | 53 +-
.../jsp/jasper/tagplugins/jstl/core/Set.java | 172 +-
.../jsp/jasper/tagplugins/jstl/core/Url.java | 115 +-
.../jsp/jasper/tagplugins/jstl/core/When.java | 41 +-
.../jsp/jasper/xmlparser/ASCIIReader.java | 61 +-
.../jsp/jasper/xmlparser/EncodingMap.java | 941 ++++++-----
.../jsp/jasper/xmlparser/ParserUtils.java | 114 +-
.../jsp/jasper/xmlparser/SymbolTable.java | 57 +-
.../scripting/jsp/jasper/xmlparser/TreeNode.java | 133 +-
.../scripting/jsp/jasper/xmlparser/UCSReader.java | 134 +-
.../scripting/jsp/jasper/xmlparser/UTF8Reader.java | 233 ++-
.../scripting/jsp/jasper/xmlparser/XMLChar.java | 904 ++++++-----
.../jsp/jasper/xmlparser/XMLEncodingDetector.java | 1370 ++++++++--------
.../scripting/jsp/jasper/xmlparser/XMLString.java | 65 +-
.../jsp/jasper/xmlparser/XMLStringBuffer.java | 93 +-
.../util/JspSlingHttpServletResponseWrapper.java | 35 +-
.../apache/sling/scripting/jsp/util/TagUtil.java | 33 +-
.../sling/scripting/jsp/util/package-info.java | 39 +-
.../scripting/jsp/SlingJspPageContextTest.java | 44 +-
123 files changed, 11316 insertions(+), 12705 deletions(-)
diff --git a/src/main/java/org/apache/juli/logging/Log.java b/src/main/java/org/apache/juli/logging/Log.java
index fc8a319..c3bf314 100644
--- a/src/main/java/org/apache/juli/logging/Log.java
+++ b/src/main/java/org/apache/juli/logging/Log.java
@@ -1,20 +1,21 @@
/*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
-
package org.apache.juli.logging;
/**
@@ -60,10 +61,8 @@ package org.apache.juli.logging;
*/
public interface Log {
-
// ----------------------------------------------------- Logging Properties
-
/**
* <p> Is debug logging currently enabled? </p>
*
@@ -75,7 +74,6 @@ public interface Log {
*/
public boolean isDebugEnabled();
-
/**
* <p> Is error logging currently enabled? </p>
*
@@ -87,7 +85,6 @@ public interface Log {
*/
public boolean isErrorEnabled();
-
/**
* <p> Is fatal logging currently enabled? </p>
*
@@ -99,7 +96,6 @@ public interface Log {
*/
public boolean isFatalEnabled();
-
/**
* <p> Is info logging currently enabled? </p>
*
@@ -111,7 +107,6 @@ public interface Log {
*/
public boolean isInfoEnabled();
-
/**
* <p> Is trace logging currently enabled? </p>
*
@@ -123,7 +118,6 @@ public interface Log {
*/
public boolean isTraceEnabled();
-
/**
* <p> Is warn logging currently enabled? </p>
*
@@ -135,10 +129,8 @@ public interface Log {
*/
public boolean isWarnEnabled();
-
// -------------------------------------------------------- Logging Methods
-
/**
* <p> Log a message with trace log level. </p>
*
@@ -146,7 +138,6 @@ public interface Log {
*/
public void trace(Object message);
-
/**
* <p> Log an error with trace log level. </p>
*
@@ -155,7 +146,6 @@ public interface Log {
*/
public void trace(Object message, Throwable t);
-
/**
* <p> Log a message with debug log level. </p>
*
@@ -163,7 +153,6 @@ public interface Log {
*/
public void debug(Object message);
-
/**
* <p> Log an error with debug log level. </p>
*
@@ -172,7 +161,6 @@ public interface Log {
*/
public void debug(Object message, Throwable t);
-
/**
* <p> Log a message with info log level. </p>
*
@@ -180,7 +168,6 @@ public interface Log {
*/
public void info(Object message);
-
/**
* <p> Log an error with info log level. </p>
*
@@ -189,7 +176,6 @@ public interface Log {
*/
public void info(Object message, Throwable t);
-
/**
* <p> Log a message with warn log level. </p>
*
@@ -197,7 +183,6 @@ public interface Log {
*/
public void warn(Object message);
-
/**
* <p> Log an error with warn log level. </p>
*
@@ -206,7 +191,6 @@ public interface Log {
*/
public void warn(Object message, Throwable t);
-
/**
* <p> Log a message with error log level. </p>
*
@@ -214,7 +198,6 @@ public interface Log {
*/
public void error(Object message);
-
/**
* <p> Log an error with error log level. </p>
*
@@ -223,7 +206,6 @@ public interface Log {
*/
public void error(Object message, Throwable t);
-
/**
* <p> Log a message with fatal log level. </p>
*
@@ -231,7 +213,6 @@ public interface Log {
*/
public void fatal(Object message);
-
/**
* <p> Log an error with fatal log level. </p>
*
@@ -239,6 +220,4 @@ public interface Log {
* @param t log this cause
*/
public void fatal(Object message, Throwable t);
-
-
}
diff --git a/src/main/java/org/apache/juli/logging/LogConfigurationException.java b/src/main/java/org/apache/juli/logging/LogConfigurationException.java
index 24f57b6..3da2c17 100644
--- a/src/main/java/org/apache/juli/logging/LogConfigurationException.java
+++ b/src/main/java/org/apache/juli/logging/LogConfigurationException.java
@@ -18,6 +18,4 @@
*/
package org.apache.juli.logging;
-public class LogConfigurationException extends RuntimeException {
-
-}
+public class LogConfigurationException extends RuntimeException {}
diff --git a/src/main/java/org/apache/juli/logging/LogFactory.java b/src/main/java/org/apache/juli/logging/LogFactory.java
index 5a2843f..15712c1 100644
--- a/src/main/java/org/apache/juli/logging/LogFactory.java
+++ b/src/main/java/org/apache/juli/logging/LogFactory.java
@@ -29,14 +29,11 @@ public class LogFactory {
* @exception LogConfigurationException if a suitable <code>Log</code>
* instance cannot be returned
*/
- public static Log getLog(Class<?> clazz)
- throws LogConfigurationException {
+ public static Log getLog(Class<?> clazz) throws LogConfigurationException {
return getLog(clazz.getName());
-
}
-
/**
* Convenience method to return a named logger, without the application
* having to care about factories.
@@ -48,10 +45,8 @@ public class LogFactory {
* @exception LogConfigurationException if a suitable <code>Log</code>
* instance cannot be returned
*/
- public static Log getLog(String name)
- throws LogConfigurationException {
+ public static Log getLog(String name) throws LogConfigurationException {
return new Slf4jLog(name);
-
}
}
diff --git a/src/main/java/org/apache/juli/logging/Slf4jLog.java b/src/main/java/org/apache/juli/logging/Slf4jLog.java
index b185ac4..07716e3 100644
--- a/src/main/java/org/apache/juli/logging/Slf4jLog.java
+++ b/src/main/java/org/apache/juli/logging/Slf4jLog.java
@@ -100,6 +100,4 @@ public class Slf4jLog implements Log {
public void warn(Object message) {
delegatee.warn(message.toString());
}
-
-
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java b/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
index 81de71f..66ccb21 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
@@ -1,21 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.scripting.jsp;
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import javax.servlet.ServletContext;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -25,12 +33,6 @@ import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
-import javax.script.Bindings;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import javax.servlet.ServletContext;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.observation.ExternalResourceChangeListener;
@@ -72,95 +74,107 @@ import static org.apache.sling.api.scripting.SlingBindings.SLING;
* The JSP engine (a.k.a Jasper).
*
*/
-@Component(service = {javax.script.ScriptEngineFactory.class,ResourceChangeListener.class,ClassLoaderWriterListener.class},
- property = {
- "extensions=jsp",
- "extensions=jspf",
- "extensions=jspx",
- "names=jsp",
- "names=JSP",
- Constants.SERVICE_VENDOR + "=The Apache Software Foundation",
- Constants.SERVICE_DESCRIPTION + "=JSP Script Handler",
- ResourceChangeListener.CHANGES + "=CHANGED",
- ResourceChangeListener.CHANGES + "=REMOVED",
- ResourceChangeListener.PATHS + "=glob:**/*.jsp",
- ResourceChangeListener.PATHS + "=glob:**/*.jspf",
- ResourceChangeListener.PATHS + "=glob:**/*.jspx",
- ResourceChangeListener.PATHS + "=glob:**/*.tld",
- ResourceChangeListener.PATHS + "=glob:**/*.tag"
- })
+@Component(
+ service = {javax.script.ScriptEngineFactory.class, ResourceChangeListener.class, ClassLoaderWriterListener.class
+ },
+ property = {
+ "extensions=jsp",
+ "extensions=jspf",
+ "extensions=jspx",
+ "names=jsp",
+ "names=JSP",
+ Constants.SERVICE_VENDOR + "=The Apache Software Foundation",
+ Constants.SERVICE_DESCRIPTION + "=JSP Script Handler",
+ ResourceChangeListener.CHANGES + "=CHANGED",
+ ResourceChangeListener.CHANGES + "=REMOVED",
+ ResourceChangeListener.PATHS + "=glob:**/*.jsp",
+ ResourceChangeListener.PATHS + "=glob:**/*.jspf",
+ ResourceChangeListener.PATHS + "=glob:**/*.jspx",
+ ResourceChangeListener.PATHS + "=glob:**/*.tld",
+ ResourceChangeListener.PATHS + "=glob:**/*.tag"
+ })
@Designate(ocd = JspScriptEngineFactory.Config.class)
-public class JspScriptEngineFactory
- extends AbstractScriptEngineFactory
- implements ResourceChangeListener,ExternalResourceChangeListener, ClassLoaderWriterListener {
-
- @ObjectClassDefinition(name = "Apache Sling JSP Script Handler",
- description = "The JSP Script Handler supports development of JSP " +
- "scripts to render response content on behalf of ScriptComponents. Internally " +
- "Jasper 6.0.14 JSP Engine is used together with the Eclipse Java Compiler to " +
- "compile generated Java code into Java class files. Some settings of Jasper " +
- "may be configured as shown below. Note that JSP scripts are expected in the " +
- "JCR repository and generated Java source and class files will be written to " +
- "the JCR repository below the configured Compilation Location.")
+public class JspScriptEngineFactory extends AbstractScriptEngineFactory
+ implements ResourceChangeListener, ExternalResourceChangeListener, ClassLoaderWriterListener {
+
+ @ObjectClassDefinition(
+ name = "Apache Sling JSP Script Handler",
+ description = "The JSP Script Handler supports development of JSP "
+ + "scripts to render response content on behalf of ScriptComponents. Internally "
+ + "Jasper 6.0.14 JSP Engine is used together with the Eclipse Java Compiler to "
+ + "compile generated Java code into Java class files. Some settings of Jasper "
+ + "may be configured as shown below. Note that JSP scripts are expected in the "
+ + "JCR repository and generated Java source and class files will be written to "
+ + "the JCR repository below the configured Compilation Location.")
public @interface Config {
- @AttributeDefinition(name = "Target Version",
- description = "The target JVM version for the compiled classes. If " +
- "left empty, the default version, 1.6., is used. If the value \"auto\" is used, the " +
- "current vm version will be used.")
+ @AttributeDefinition(
+ name = "Target Version",
+ description = "The target JVM version for the compiled classes. If "
+ + "left empty, the default version, 1.6., is used. If the value \"auto\" is used, the "
+ + "current vm version will be used.")
String jasper_compilerTargetVM() default JspServletOptions.AUTOMATIC_VERSION;
- @AttributeDefinition(name = "Source Version",
- description = "The JVM version for the java/JSP source. If " +
- "left empty, the default version, 1.6., is used. If the value \"auto\" is used, the " +
- "current vm version will be used.")
+ @AttributeDefinition(
+ name = "Source Version",
+ description = "The JVM version for the java/JSP source. If "
+ + "left empty, the default version, 1.6., is used. If the value \"auto\" is used, the "
+ + "current vm version will be used.")
String jasper_compilerSourceVM() default JspServletOptions.AUTOMATIC_VERSION;
- @AttributeDefinition(name = "Generate Debug Info",
- description = "Should the class file be compiled with " +
- "debugging information? true or false, default true.")
+ @AttributeDefinition(
+ name = "Generate Debug Info",
+ description = "Should the class file be compiled with "
+ + "debugging information? true or false, default true.")
boolean jasper_classdebuginfo() default true;
- @AttributeDefinition(name = "Tag Pooling",
- description = "Determines whether tag handler pooling is " +
- "enabled. true or false, default true.")
+ @AttributeDefinition(
+ name = "Tag Pooling",
+ description = "Determines whether tag handler pooling is " + "enabled. true or false, default true.")
boolean jasper_enablePooling() default true;
- @AttributeDefinition(name = "Plugin Class-ID",
- description = "The class-id value to be sent to Internet " +
- "Explorer when using <jsp:plugin> tags. Default " +
- "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93.")
+ @AttributeDefinition(
+ name = "Plugin Class-ID",
+ description =
+ "The class-id value to be sent to Internet " + "Explorer when using <jsp:plugin> tags. Default "
+ + "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93.")
String jasper_ieClassId() default "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
- @AttributeDefinition(name = "Char Array Strings",
- description = "Should text strings be generated as " +
- "char arrays, to improve performance in some cases? Default false.")
+ @AttributeDefinition(
+ name = "Char Array Strings",
+ description = "Should text strings be generated as "
+ + "char arrays, to improve performance in some cases? Default false.")
boolean jasper_genStringAsCharArray() default false;
- @AttributeDefinition(name = "Keep Generated Java",
- description = "Should we keep the generated Java source " +
- "code for each page instead of deleting it? true or false, default true.")
+ @AttributeDefinition(
+ name = "Keep Generated Java",
+ description = "Should we keep the generated Java source "
+ + "code for each page instead of deleting it? true or false, default true.")
boolean jasper_keepgenerated() default true;
- @AttributeDefinition(name = "Mapped Content",
- description = "Should we generate static content with one " +
- "print statement per input line, to ease debugging? true or false, default true.")
+ @AttributeDefinition(
+ name = "Mapped Content",
+ description = "Should we generate static content with one "
+ + "print statement per input line, to ease debugging? true or false, default true.")
boolean jasper_mappedfile() default true;
- @AttributeDefinition(name = "Trim Spaces",
- description = "Should white spaces in template text between " +
- "actions or directives be trimmed ?, default false.")
+ @AttributeDefinition(
+ name = "Trim Spaces",
+ description = "Should white spaces in template text between "
+ + "actions or directives be trimmed ?, default false.")
boolean jasper_trimSpaces() default false;
- @AttributeDefinition(name = "Display Source Fragments",
- description = "Should we include a source fragment " +
- "in exception messages, which could be displayed to the developer")
+ @AttributeDefinition(
+ name = "Display Source Fragments",
+ description = "Should we include a source fragment "
+ + "in exception messages, which could be displayed to the developer")
boolean jasper_displaySourceFragments() default false;
- @AttributeDefinition(name = "Default Session Value",
- description = "Should a session be created by default for every " +
- "JSP page? Warning - this behavior may produce unintended results and changing " +
- "it will not impact previously-compiled pages.")
+ @AttributeDefinition(
+ name = "Default Session Value",
+ description = "Should a session be created by default for every "
+ + "JSP page? Warning - this behavior may produce unintended results and changing "
+ + "it will not impact previously-compiled pages.")
boolean default_is_session() default true;
}
@@ -200,9 +214,9 @@ public class JspScriptEngineFactory
/** The handler for the jsp factories. */
private JspFactoryHandler jspFactoryHandler;
- public static final String[] SCRIPT_TYPE = { "jsp", "jspf", "jspx" };
+ public static final String[] SCRIPT_TYPE = {"jsp", "jspf", "jspx"};
- public static final String[] NAMES = { "jsp", "JSP" };
+ public static final String[] NAMES = {"jsp", "JSP"};
public JspScriptEngineFactory() {
setExtensions(SCRIPT_TYPE);
@@ -248,16 +262,16 @@ public class JspScriptEngineFactory
private JspServletWrapper getJspWrapper(final String scriptName) {
JspRuntimeContext rctxt = this.getJspRuntimeContext();
- JspServletWrapper wrapper = rctxt.getWrapper(scriptName);
+ JspServletWrapper wrapper = rctxt.getWrapper(scriptName);
if (wrapper != null) {
- if ( wrapper.isValid() ) {
+ if (wrapper.isValid()) {
return wrapper;
}
- synchronized ( this ) {
+ synchronized (this) {
rctxt = this.getJspRuntimeContext();
wrapper = rctxt.getWrapper(scriptName);
- if ( wrapper != null ) {
- if ( wrapper.isValid() ) {
+ if (wrapper != null) {
+ if (wrapper.isValid()) {
return wrapper;
}
this.renewJspRuntimeContext();
@@ -266,8 +280,7 @@ public class JspScriptEngineFactory
}
}
- wrapper = new JspServletWrapper(servletConfig, options,
- scriptName, false, rctxt);
+ wrapper = new JspServletWrapper(servletConfig, options, scriptName, false, rctxt);
wrapper = rctxt.addWrapper(scriptName, wrapper);
return wrapper;
@@ -279,9 +292,8 @@ public class JspScriptEngineFactory
* Activate this component
*/
@Activate
- protected void activate(final BundleContext bundleContext,
- final Config config,
- final Map<String, Object> properties) {
+ protected void activate(
+ final BundleContext bundleContext, final Config config, final Map<String, Object> properties) {
// set the current class loader as the thread context loader for
// the setup of the JspRuntimeContext
final ClassLoader old = Thread.currentThread().getContextClassLoader();
@@ -296,11 +308,11 @@ public class JspScriptEngineFactory
ioProvider = new SlingIOProvider(this.classLoaderWriter, this.javaCompiler);
// return options which use the jspClassLoader
- options = new JspServletOptions(slingServletContext, ioProvider,
- properties, tldLocationsCache, config.default_is_session());
+ options = new JspServletOptions(
+ slingServletContext, ioProvider, properties, tldLocationsCache, config.default_is_session());
- JspServletContext jspServletContext = new JspServletContext(ioProvider,
- slingServletContext, tldLocationsCache);
+ JspServletContext jspServletContext =
+ new JspServletContext(ioProvider, slingServletContext, tldLocationsCache);
servletConfig = new JspServletConfig(jspServletContext, options.getProperties());
@@ -325,11 +337,11 @@ public class JspScriptEngineFactory
@Deactivate
protected void deactivate(final BundleContext bundleContext) {
logger.info("Deactivating Apache Sling Script Engine for JSP");
- if ( this.precompiledJSPRunner != null ) {
+ if (this.precompiledJSPRunner != null) {
this.precompiledJSPRunner.cleanup();
this.precompiledJSPRunner = null;
}
- if ( this.tldLocationsCache != null ) {
+ if (this.tldLocationsCache != null) {
this.tldLocationsCache.deactivate(bundleContext);
this.tldLocationsCache = null;
}
@@ -355,26 +367,26 @@ public class JspScriptEngineFactory
is = this.classLoaderWriter.getInputStream(CONFIG_PATH);
byte[] buffer = new byte[1024];
int length = 0;
- while ( ( length = is.read(buffer)) != -1 ) {
+ while ((length = is.read(buffer)) != -1) {
baos.write(buffer, 0, length);
}
final String oldKey = new String(baos.toByteArray(), StandardCharsets.UTF_8);
changed = !oldKey.equals(this.servletConfig.getConfigKey());
- if ( changed ) {
+ if (changed) {
logger.info("Removing all class files due to jsp configuration change");
}
- } catch ( final IOException notFound ) {
+ } catch (final IOException notFound) {
changed = true;
} finally {
- if ( is != null ) {
+ if (is != null) {
try {
is.close();
- } catch ( final IOException ignore) {
+ } catch (final IOException ignore) {
// ignore
}
}
}
- if ( changed ) {
+ if (changed) {
try (OutputStream os = this.classLoaderWriter.getOutputStream(CONFIG_PATH)) {
os.write(this.servletConfig.getConfigKey().getBytes(StandardCharsets.UTF_8));
} catch (final IOException ignore) {
@@ -384,7 +396,7 @@ public class JspScriptEngineFactory
}
}
- @Reference(target="(name=org.apache.sling)")
+ @Reference(target = "(name=org.apache.sling)")
protected void bindSlingServletContext(final ServletContext context) {
this.slingServletContext = context;
}
@@ -395,8 +407,7 @@ public class JspScriptEngineFactory
*
* @param slingServletContext The <code>ServletContext</code> to be unbound
*/
- protected void unbindSlingServletContext(
- final ServletContext slingServletContext) {
+ protected void unbindSlingServletContext(final ServletContext slingServletContext) {
// remove JspApplicationContextImpl from the servlet context,
// otherwise a ClassCastException may be caused after this component
@@ -412,9 +423,7 @@ public class JspScriptEngineFactory
} catch (NullPointerException npe) {
// SLING-530, might be thrown on system shutdown in a servlet
// container when using the Equinox servlet container bridge
- logger.debug(
- "unbindSlingServletContext: ServletContext might already be unavailable",
- npe);
+ logger.debug("unbindSlingServletContext: ServletContext might already be unavailable", npe);
}
if (this.slingServletContext == slingServletContext) {
@@ -427,9 +436,9 @@ public class JspScriptEngineFactory
*
* @param rclp the new provider
*/
- @Reference(cardinality=ReferenceCardinality.MANDATORY, policy=ReferencePolicy.STATIC)
+ @Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
protected void bindDynamicClassLoaderManager(final DynamicClassLoaderManager rclp) {
- if ( this.dynamicClassLoader != null ) {
+ if (this.dynamicClassLoader != null) {
this.ungetClassLoader();
}
this.getClassLoader(rclp);
@@ -440,7 +449,7 @@ public class JspScriptEngineFactory
* @param rclp the old provider
*/
protected void unbindDynamicClassLoaderManager(final DynamicClassLoaderManager rclp) {
- if ( this.dynamicClassLoaderManager == rclp ) {
+ if (this.dynamicClassLoaderManager == rclp) {
this.ungetClassLoader();
}
}
@@ -479,25 +488,26 @@ public class JspScriptEngineFactory
throw new IllegalStateException(String.format("The %s variable is missing from the bindings.", SLING));
}
ResourceResolver resolver = scriptingResourceResolverProvider.getRequestScopedResourceResolver();
- if ( resolver == null ) {
+ if (resolver == null) {
resolver = scriptHelper.getScript().getScriptResource().getResourceResolver();
}
final SlingIOProvider io = ioProvider;
final JspFactoryHandler jspfh = jspFactoryHandler;
// abort if JSP Support is shut down concurrently (SLING-2704)
if (io == null || jspfh == null) {
- throw new RuntimeException("callJsp: JSP Script Engine seems to be shut down concurrently; not calling "+
- scriptHelper.getScript().getScriptResource().getPath());
+ throw new RuntimeException("callJsp: JSP Script Engine seems to be shut down concurrently; not calling "
+ + scriptHelper.getScript().getScriptResource().getPath());
}
final ResourceResolver oldResolver = io.setRequestResourceResolver(resolver);
jspfh.incUsage();
try {
- final boolean contextHasPrecompiledJsp = precompiledJSPRunner
- .callPrecompiledJSP(getJspRuntimeContext(), jspFactoryHandler, servletConfig, slingBindings);
+ final boolean contextHasPrecompiledJsp = precompiledJSPRunner.callPrecompiledJSP(
+ getJspRuntimeContext(), jspFactoryHandler, servletConfig, slingBindings);
if (!contextHasPrecompiledJsp) {
- final JspServletWrapper jsp = getJspWrapper(scriptHelper.getScript().getScriptResource().getPath());
+ final JspServletWrapper jsp = getJspWrapper(
+ scriptHelper.getScript().getScriptResource().getPath());
jsp.service(slingBindings);
}
} finally {
@@ -517,7 +527,7 @@ public class JspScriptEngineFactory
throw new IllegalStateException(String.format("The %s variable is missing from the bindings.", SLING));
}
ResourceResolver resolver = scriptingResourceResolverProvider.getRequestScopedResourceResolver();
- if ( resolver == null ) {
+ if (resolver == null) {
resolver = scriptHelper.getScript().getScriptResource().getResourceResolver();
}
final SlingIOProvider io = ioProvider;
@@ -525,8 +535,8 @@ public class JspScriptEngineFactory
// abort if JSP Support is shut down concurrently (SLING-2704)
if (io == null || jspfh == null) {
- throw new RuntimeException("callJsp: JSP Script Engine seems to be shut down concurrently; not calling "+
- scriptHelper.getScript().getScriptResource().getPath());
+ throw new RuntimeException("callJsp: JSP Script Engine seems to be shut down concurrently; not calling "
+ + scriptHelper.getScript().getScriptResource().getPath());
}
final ResourceResolver oldResolver = io.setRequestResourceResolver(resolver);
@@ -540,8 +550,7 @@ public class JspScriptEngineFactory
if (request != null) {
final Throwable t = (Throwable) request.getAttribute("javax.servlet.jsp.jspException");
- final Object newException = request
- .getAttribute("javax.servlet.error.exception");
+ final Object newException = request.getAttribute("javax.servlet.error.exception");
// t==null means the attribute was not set.
if ((newException != null) && (newException == t)) {
@@ -615,12 +624,11 @@ public class JspScriptEngineFactory
}
private JspRuntimeContext getJspRuntimeContext() {
- if ( this.jspRuntimeContext == null ) {
- synchronized ( this ) {
- if ( this.jspRuntimeContext == null ) {
+ if (this.jspRuntimeContext == null) {
+ synchronized (this) {
+ if (this.jspRuntimeContext == null) {
// Initialize the JSP Runtime Context
- this.jspRuntimeContext = new JspRuntimeContext(slingServletContext,
- options, ioProvider);
+ this.jspRuntimeContext = new JspRuntimeContext(slingServletContext, options, ioProvider);
}
}
}
@@ -628,13 +636,13 @@ public class JspScriptEngineFactory
}
@Override
- public void onChange(final List<ResourceChange> changes) {
- for(final ResourceChange change : changes){
+ public void onChange(final List<ResourceChange> changes) {
+ for (final ResourceChange change : changes) {
final JspRuntimeContext rctxt = this.jspRuntimeContext;
- if ( rctxt != null && rctxt.handleModification(change.getPath(), change.getType() == ChangeType.REMOVED) ) {
+ if (rctxt != null && rctxt.handleModification(change.getPath(), change.getType() == ChangeType.REMOVED)) {
renewJspRuntimeContext();
}
- }
+ }
}
/**
@@ -643,7 +651,7 @@ public class JspScriptEngineFactory
*/
private void renewJspRuntimeContext() {
final JspRuntimeContext jrc;
- synchronized ( this ) {
+ synchronized (this) {
jrc = this.jspRuntimeContext;
this.jspRuntimeContext = null;
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/JspServletConfig.java b/src/main/java/org/apache/sling/scripting/jsp/JspServletConfig.java
index ab616b7..b5c30d3 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/JspServletConfig.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/JspServletConfig.java
@@ -18,13 +18,13 @@
*/
package org.apache.sling.scripting.jsp;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+
import java.util.Collections;
import java.util.Enumeration;
import java.util.Map;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-
import org.osgi.framework.Constants;
class JspServletConfig implements ServletConfig {
@@ -68,7 +68,7 @@ class JspServletConfig implements ServletConfig {
*/
public String getConfigKey() {
final StringBuilder sb = new StringBuilder();
- for(final Map.Entry<String, String> entry : this.properties.entrySet() ) {
+ for (final Map.Entry<String, String> entry : this.properties.entrySet()) {
sb.append(entry.getKey());
sb.append('=');
sb.append(entry.getValue());
diff --git a/src/main/java/org/apache/sling/scripting/jsp/JspServletContext.java b/src/main/java/org/apache/sling/scripting/jsp/JspServletContext.java
index 7d08c83..90a5524 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/JspServletContext.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/JspServletContext.java
@@ -1,29 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.scripting.jsp;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.EventListener;
-import java.util.Map;
-import java.util.Set;
-
import javax.servlet.Filter;
import javax.servlet.FilterRegistration;
import javax.servlet.RequestDispatcher;
@@ -36,6 +30,14 @@ import javax.servlet.SessionCookieConfig;
import javax.servlet.SessionTrackingMode;
import javax.servlet.descriptor.JspConfigDescriptor;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.EventListener;
+import java.util.Map;
+import java.util.Set;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,14 +53,13 @@ public class JspServletContext implements ServletContext {
private final ServletContext delegatee;
private final SlingTldLocationsCache tcs;
- JspServletContext(SlingIOProvider ioProvider, ServletContext componentContext,
- SlingTldLocationsCache tcs) {
+ JspServletContext(SlingIOProvider ioProvider, ServletContext componentContext, SlingTldLocationsCache tcs) {
this.ioProvider = ioProvider;
this.delegatee = componentContext;
this.tcs = tcs;
}
- //---------- implemented methods ------------------------------------------
+ // ---------- implemented methods ------------------------------------------
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getResource(java.lang.String)
@@ -90,8 +91,7 @@ public class JspServletContext implements ServletContext {
return ioProvider.getInputStream(path);
} catch (Exception ex) {
// FileNotFoundException or IOException
- log.debug("getResourceAsStream: Cannot get resource {}: {}",
- path, ex.getMessage());
+ log.debug("getResourceAsStream: Cannot get resource {}: {}", path, ex.getMessage());
}
}
@@ -103,9 +103,7 @@ public class JspServletContext implements ServletContext {
return url.openStream();
}
} catch (Exception e) {
- log.debug(
- "getResourceAsStream: Cannot access resource {} through URL: {}",
- path, e.getMessage());
+ log.debug("getResourceAsStream: Cannot access resource {} through URL: {}", path, e.getMessage());
}
return null;
@@ -132,7 +130,7 @@ public class JspServletContext implements ServletContext {
log.error(message, throwable);
}
- //---------- delegated methods --------------------------------------------
+ // ---------- delegated methods --------------------------------------------
@Override
public Object getAttribute(String name) {
@@ -233,11 +231,11 @@ public class JspServletContext implements ServletContext {
return delegatee.getContextPath();
}
- //---------- internal -----------------------------------------------------
+ // ---------- internal -----------------------------------------------------
private URL getUrlForResource(String path) {
int cs = path.indexOf(":/");
- if (cs > 0 && cs < path.length()-2) {
+ if (cs > 0 && cs < path.length() - 2) {
// insert second slash after scheme (was canonicalized away)
cs += 2;
if (cs < path.length() && path.charAt(cs) != '/') {
@@ -254,8 +252,7 @@ public class JspServletContext implements ServletContext {
try {
return new URL(path);
} catch (MalformedURLException mue) {
- log.debug("getUrlForResource: Cannot create URL for {}: {}",
- path, mue.getMessage());
+ log.debug("getUrlForResource: Cannot create URL for {}: {}", path, mue.getMessage());
}
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java b/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java
index aca778f..4b96764 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java
@@ -1,26 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.scripting.jsp;
+import javax.servlet.ServletContext;
+
import java.util.Map;
import java.util.TreeMap;
-import javax.servlet.ServletContext;
-
import org.apache.sling.scripting.jsp.jasper.IOProvider;
import org.apache.sling.scripting.jsp.jasper.Options;
import org.apache.sling.scripting.jsp.jasper.compiler.JspConfig;
@@ -331,8 +333,10 @@ public class JspServletOptions implements Options {
* Create an JspServletOptions object using data available from
* ServletConfig and ServletContext.
*/
- public JspServletOptions(ServletContext servletContext,
- IOProvider ioProvider, Map<String, Object> config,
+ public JspServletOptions(
+ ServletContext servletContext,
+ IOProvider ioProvider,
+ Map<String, Object> config,
TldLocationsCache tldLocationsCache,
boolean defaultIsSession) {
@@ -341,18 +345,17 @@ public class JspServletOptions implements Options {
this.compilerSourceVM = System.getProperty("java.specification.version");
this.compilerTargetVM = this.compilerSourceVM;
- for(final Map.Entry<String, Object> entry : config.entrySet()) {
+ for (final Map.Entry<String, Object> entry : config.entrySet()) {
String key = entry.getKey();
if (key.startsWith("jasper.")) {
final Object value = entry.getValue();
if (value != null) {
final String strValue = String.valueOf(value).trim();
- if ( strValue.length() > 0 ) {
+ if (strValue.length() > 0) {
setProperty(key.substring("jasper.".length()), strValue);
}
}
}
-
}
// quick hack
@@ -400,8 +403,7 @@ public class JspServletOptions implements Options {
this.isPoolingEnabled = true;
String poolingEnabledParam = getProperty("enablePooling");
- if (poolingEnabledParam != null
- && !poolingEnabledParam.equalsIgnoreCase("true")) {
+ if (poolingEnabledParam != null && !poolingEnabledParam.equalsIgnoreCase("true")) {
if (poolingEnabledParam.equalsIgnoreCase("false")) {
this.isPoolingEnabled = false;
} else {
@@ -508,13 +510,13 @@ public class JspServletOptions implements Options {
}
final String targetVM = getProperty("compilerTargetVM");
- if (targetVM != null && !AUTOMATIC_VERSION.equalsIgnoreCase(targetVM) ) {
+ if (targetVM != null && !AUTOMATIC_VERSION.equalsIgnoreCase(targetVM)) {
this.compilerTargetVM = targetVM;
}
this.setProperty("compilerTargetVM", this.compilerTargetVM);
final String sourceVM = getProperty("compilerSourceVM");
- if (sourceVM != null && !AUTOMATIC_VERSION.equalsIgnoreCase(sourceVM) ) {
+ if (sourceVM != null && !AUTOMATIC_VERSION.equalsIgnoreCase(sourceVM)) {
this.compilerSourceVM = sourceVM;
}
this.setProperty("compilerSourceVM", this.compilerSourceVM);
diff --git a/src/main/java/org/apache/sling/scripting/jsp/PrecompiledJSPRunner.java b/src/main/java/org/apache/sling/scripting/jsp/PrecompiledJSPRunner.java
index eee7bcf..109f1fd 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/PrecompiledJSPRunner.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/PrecompiledJSPRunner.java
@@ -1,32 +1,32 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.sling.scripting.jsp;
+import javax.naming.NamingException;
+import javax.servlet.ServletException;
+
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import javax.naming.NamingException;
-import javax.servlet.ServletException;
-
import org.apache.sling.api.SlingException;
import org.apache.sling.api.SlingServletException;
import org.apache.sling.api.scripting.SlingBindings;
@@ -49,8 +49,11 @@ public class PrecompiledJSPRunner {
this.options = options;
}
- boolean callPrecompiledJSP(JspRuntimeContext runtimeContext, JspRuntimeContext.JspFactoryHandler jspFactoryHandler, JspServletConfig jspServletConfig,
- SlingBindings bindings) {
+ boolean callPrecompiledJSP(
+ JspRuntimeContext runtimeContext,
+ JspRuntimeContext.JspFactoryHandler jspFactoryHandler,
+ JspServletConfig jspServletConfig,
+ SlingBindings bindings) {
boolean found = false;
final BundledRenderUnit bundledRenderUnit = (BundledRenderUnit) bindings.get(BundledRenderUnit.VARIABLE);
if (bundledRenderUnit != null && bundledRenderUnit.getUnit() instanceof HttpJspBase) {
@@ -59,24 +62,35 @@ public class PrecompiledJSPRunner {
final JspHolder holder = holders.computeIfAbsent(jsp, key -> new JspHolder());
if (holder.wrapper == null) {
synchronized (holder) {
- if (holder.wrapper == null ) {
+ if (holder.wrapper == null) {
try {
- final PrecompiledServletConfig servletConfig = new PrecompiledServletConfig(jspServletConfig, bundledRenderUnit);
- final AnnotationProcessor annotationProcessor = (AnnotationProcessor) jspServletConfig.getServletContext()
- .getAttribute(AnnotationProcessor.class.getName());
+ final PrecompiledServletConfig servletConfig =
+ new PrecompiledServletConfig(jspServletConfig, bundledRenderUnit);
+ final AnnotationProcessor annotationProcessor = (AnnotationProcessor) jspServletConfig
+ .getServletContext()
+ .getAttribute(AnnotationProcessor.class.getName());
if (annotationProcessor != null) {
annotationProcessor.processAnnotations(jsp);
annotationProcessor.postConstruct(jsp);
}
- final JspServletWrapper wrapper = new JspServletWrapper(servletConfig, this.options, bundledRenderUnit.getPath(), false, runtimeContext, jsp);
+ final JspServletWrapper wrapper = new JspServletWrapper(
+ servletConfig,
+ this.options,
+ bundledRenderUnit.getPath(),
+ false,
+ runtimeContext,
+ jsp);
jsp.init(servletConfig);
holder.wrapper = wrapper;
- } catch ( final ServletException se ) {
+ } catch (final ServletException se) {
throw new SlingServletException(se);
} catch (IllegalAccessException | InvocationTargetException | NamingException e) {
- throw new SlingException("Unable to process annotations for servlet " + jsp.getClass().getName() + ".", e);
+ throw new SlingException(
+ "Unable to process annotations for servlet "
+ + jsp.getClass().getName() + ".",
+ e);
} catch (NoClassDefFoundError ignored) {
// wave your hands like we don't care - we're missing support for precompiled JSPs
}
@@ -93,12 +107,12 @@ public class PrecompiledJSPRunner {
final Set<JspHolder> holders = new HashSet<>(this.holders.values());
this.holders.clear();
try {
- for(final JspHolder h : holders) {
- if ( h.wrapper != null ) {
+ for (final JspHolder h : holders) {
+ if (h.wrapper != null) {
h.wrapper.destroy(true);
}
- }
- } catch ( final Throwable t) {
+ }
+ } catch (final Throwable t) {
// we ignore this exception as this might be called during shutdown
}
}
@@ -119,7 +133,8 @@ public class PrecompiledJSPRunner {
Bundle bundle = bundledRenderUnit.getBundle();
Object jsp = bundledRenderUnit.getUnit();
String originalName =
- JavaEscapeHelper.unescapeAll(jsp.getClass().getPackage().getName()) + "/" + JavaEscapeHelper.unescapeAll(jsp.getClass().getSimpleName());
+ JavaEscapeHelper.unescapeAll(jsp.getClass().getPackage().getName()) + "/"
+ + JavaEscapeHelper.unescapeAll(jsp.getClass().getSimpleName());
servletName = bundle.getSymbolicName() + ": " + originalName;
}
return servletName;
@@ -129,6 +144,5 @@ public class PrecompiledJSPRunner {
public static final class JspHolder {
public volatile JspServletWrapper wrapper;
-
}
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java b/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java
index 49deeee..0c62b3a 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/SlingIOProvider.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.scripting.jsp;
@@ -81,9 +83,8 @@ class SlingIOProvider implements IOProvider {
* ResourceProvider and retrieved from the Resource if the StreamProvider
* interface is implemented.
*/
- public InputStream getInputStream(final String path)
- throws FileNotFoundException, IOException {
- if ( path.startsWith(":") ) {
+ public InputStream getInputStream(final String path) throws FileNotFoundException, IOException {
+ if (path.startsWith(":")) {
return this.classLoaderWriter.getInputStream(path.substring(1));
}
ResourceResolver resolver = requestResourceResolver.get();
@@ -97,8 +98,7 @@ class SlingIOProvider implements IOProvider {
}
}
} catch (final SlingException se) {
- throw (IOException) new IOException(
- "Failed to get InputStream for " + path).initCause(se);
+ throw (IOException) new IOException("Failed to get InputStream for " + path).initCause(se);
}
}
throw new FileNotFoundException("Cannot find " + path);
@@ -111,7 +111,7 @@ class SlingIOProvider implements IOProvider {
* returned.
*/
public long lastModified(final String path) {
- if ( path.startsWith(":") ) {
+ if (path.startsWith(":")) {
return this.classLoaderWriter.getLastModified(path.substring(1));
}
ResourceResolver resolver = requestResourceResolver.get();
@@ -169,7 +169,6 @@ class SlingIOProvider implements IOProvider {
// ---------- Helper Methods for JspServletContext -------------------------
-
URL getURL(final String path) throws MalformedURLException {
ResourceResolver resolver = requestResourceResolver.get();
if (resolver != null) {
@@ -177,8 +176,7 @@ class SlingIOProvider implements IOProvider {
final Resource resource = resolver.getResource(cleanPath(path, true));
return (resource != null) ? resource.adaptTo(URL.class) : null;
} catch (final SlingException se) {
- throw (MalformedURLException) new MalformedURLException(
- "Cannot get URL for " + path).initCause(se);
+ throw (MalformedURLException) new MalformedURLException("Cannot get URL for " + path).initCause(se);
}
}
return null;
@@ -193,7 +191,8 @@ class SlingIOProvider implements IOProvider {
final String cleanedPath = cleanPath(path, false);
final boolean startsWithWebInfTags = cleanedPath.startsWith(WEB_INF_TAGS);
- Resource resource = resolver.getResource(startsWithWebInfTags ? cleanedPath.substring(WEB_INF_TAGS.length()) : cleanedPath);
+ Resource resource = resolver.getResource(
+ startsWithWebInfTags ? cleanedPath.substring(WEB_INF_TAGS.length()) : cleanedPath);
if (resource != null) {
Iterator<Resource> entries = resolver.listChildren(resource);
while (entries.hasNext()) {
@@ -206,8 +205,7 @@ class SlingIOProvider implements IOProvider {
}
}
} catch (final SlingException se) {
- log.warn("getResourcePaths: Cannot list children of " + path,
- se);
+ log.warn("getResourcePaths: Cannot list children of " + path, se);
}
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/SlingJspPageContext.java b/src/main/java/org/apache/sling/scripting/jsp/SlingJspPageContext.java
index 40f2fa9..99b7682 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/SlingJspPageContext.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/SlingJspPageContext.java
@@ -1,27 +1,23 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
package org.apache.sling.scripting.jsp;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Enumeration;
-
import javax.el.ELContext;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
@@ -38,6 +34,10 @@ import javax.servlet.jsp.el.ExpressionEvaluator;
import javax.servlet.jsp.el.VariableResolver;
import javax.servlet.jsp.tagext.BodyContent;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Enumeration;
+
import org.apache.sling.api.scripting.SlingBindings;
import org.apache.sling.scripting.jsp.jasper.compiler.JspRuntimeContext;
@@ -66,8 +66,15 @@ public class SlingJspPageContext extends PageContext {
}
@Override
- public void initialize(Servlet servlet, ServletRequest servletRequest, ServletResponse servletResponse, String s, boolean b, int i,
- boolean b1) throws IOException, IllegalStateException, IllegalArgumentException {
+ public void initialize(
+ Servlet servlet,
+ ServletRequest servletRequest,
+ ServletResponse servletResponse,
+ String s,
+ boolean b,
+ int i,
+ boolean b1)
+ throws IOException, IllegalStateException, IllegalArgumentException {
wrapped.initialize(servlet, servletRequest, servletResponse, s, b, i, b1);
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/SlingPageException.java b/src/main/java/org/apache/sling/scripting/jsp/SlingPageException.java
index 3ddf550..d1e1c98 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/SlingPageException.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/SlingPageException.java
@@ -1,5 +1,5 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one
+ * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@@ -37,5 +37,4 @@ public class SlingPageException extends SlingException {
public String getErrorPage() {
return this.errorPage;
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/SlingTldLocationsCache.java b/src/main/java/org/apache/sling/scripting/jsp/SlingTldLocationsCache.java
index b04cebc..96c1cad 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/SlingTldLocationsCache.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/SlingTldLocationsCache.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.scripting.jsp;
@@ -41,8 +43,7 @@ import org.osgi.framework.ServiceRegistration;
/**
* The <code>SlingTldLocationsCache</code> TODO
*/
-public class SlingTldLocationsCache
- extends TldLocationsCache implements BundleListener {
+public class SlingTldLocationsCache extends TldLocationsCache implements BundleListener {
private static final String TLD_SCHEME = "tld:";
@@ -57,7 +58,7 @@ public class SlingTldLocationsCache
context.addBundleListener(this);
final Bundle[] bundles = context.getBundles();
for (int i = 0; i < bundles.length; i++) {
- if (bundles[i].getState() == Bundle.RESOLVED || bundles[i].getState() == Bundle.ACTIVE ) {
+ if (bundles[i].getState() == Bundle.RESOLVED || bundles[i].getState() == Bundle.ACTIVE) {
addBundle(bundles[i]);
}
}
@@ -66,9 +67,7 @@ public class SlingTldLocationsCache
tldConfigPrinterProperties.put("felix.webconsole.label", "jsptaglibs");
tldConfigPrinterProperties.put("felix.webconsole.title", "JSP Taglibs");
tldConfigPrinterProperties.put("felix.webconsole.configprinter.modes", "always");
- this.serviceRegistration = context.registerService(Object.class.getName(),
- this, tldConfigPrinterProperties);
-
+ this.serviceRegistration = context.registerService(Object.class.getName(), this, tldConfigPrinterProperties);
}
public void deactivate(final BundleContext context) {
@@ -83,9 +82,9 @@ public class SlingTldLocationsCache
@Override
public void bundleChanged(final BundleEvent event) {
- if ( event.getType() == BundleEvent.RESOLVED ) {
+ if (event.getType() == BundleEvent.RESOLVED) {
this.addBundle(event.getBundle());
- } else if ( event.getType() == BundleEvent.UNRESOLVED ) {
+ } else if (event.getType() == BundleEvent.UNRESOLVED) {
this.removeBundle(event.getBundle());
}
}
@@ -113,8 +112,8 @@ public class SlingTldLocationsCache
public String[] getLocation(final String uri) throws JasperException {
synchronized (tldLocations) {
final TldLocationEntry entry = tldLocations.get(uri);
- if ( entry != null ) {
- return new String[] { TLD_SCHEME + uri, entry.getTldURL().toString() };
+ if (entry != null) {
+ return new String[] {TLD_SCHEME + uri, entry.getTldURL().toString()};
}
}
@@ -142,8 +141,9 @@ public class SlingTldLocationsCache
private void removeBundle(final Bundle bundle) {
synchronized (tldLocations) {
- final Iterator<Map.Entry<String, TldLocationEntry>> i = tldLocations.entrySet().iterator();
- while ( i.hasNext() ) {
+ final Iterator<Map.Entry<String, TldLocationEntry>> i =
+ tldLocations.entrySet().iterator();
+ while (i.hasNext()) {
final Map.Entry<String, TldLocationEntry> entry = i.next();
if (entry.getValue().getBundleId() == bundle.getBundleId()) {
i.remove();
@@ -162,8 +162,7 @@ public class SlingTldLocationsCache
stream = resource.openStream();
// Parse the tag library descriptor at the specified resource path
- TreeNode tld = new ParserUtils().parseXMLDocument(
- resource.toString(), stream);
+ TreeNode tld = new ParserUtils().parseXMLDocument(resource.toString(), stream);
TreeNode uri = tld.findChild("uri");
if (uri != null) {
String body = uri.getBody();
@@ -206,7 +205,6 @@ public class SlingTldLocationsCache
}
}
-
private static final class TldLocationEntry {
private final long bundleId;
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/Constants.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/Constants.java
index 89ade68..2983778 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/Constants.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/Constants.java
@@ -1,23 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper;
-
/**
* Some constants and other global data that are used by the compiler and the runtime.
*
@@ -27,20 +27,21 @@ package org.apache.sling.scripting.jsp.jasper;
* @author Mark Roth
*/
public class Constants {
-
+
/**
- * The base class of the generated servlets.
+ * The base class of the generated servlets.
*/
- public static final String JSP_SERVLET_BASE =
- System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.JSP_SERVLET_BASE", "org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase");
+ public static final String JSP_SERVLET_BASE = System.getProperty(
+ "org.apache.sling.scripting.jsp.jasper.Constants.JSP_SERVLET_BASE",
+ "org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase");
/**
- * _jspService is the name of the method that is called by
+ * _jspService is the name of the method that is called by
* HttpJspBase.service(). This is where most of the code generated
* from JSPs go.
*/
- public static final String SERVICE_METHOD_NAME =
- System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.SERVICE_METHOD_NAME", "_jspService");
+ public static final String SERVICE_METHOD_NAME =
+ System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.SERVICE_METHOD_NAME", "_jspService");
/**
* Default servlet content type.
@@ -49,21 +50,17 @@ public class Constants {
/**
* These classes/packages are automatically imported by the
- * generated code.
+ * generated code.
*/
- public static final String[] STANDARD_IMPORTS = {
- "javax.servlet.*",
- "javax.servlet.http.*",
- "javax.servlet.jsp.*"
- };
+ public static final String[] STANDARD_IMPORTS = {"javax.servlet.*", "javax.servlet.http.*", "javax.servlet.jsp.*"};
/**
- * ServletContext attribute for classpath. This is tomcat specific.
- * Other servlet engines may choose to support this attribute if they
- * want to have this JSP engine running on them.
+ * ServletContext attribute for classpath. This is tomcat specific.
+ * Other servlet engines may choose to support this attribute if they
+ * want to have this JSP engine running on them.
*/
- public static final String SERVLET_CLASSPATH =
- System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.SERVLET_CLASSPATH", "org.apache.catalina.jsp_classpath");
+ public static final String SERVLET_CLASSPATH = System.getProperty(
+ "org.apache.sling.scripting.jsp.jasper.Constants.SERVLET_CLASSPATH", "org.apache.catalina.jsp_classpath");
/**
* Request attribute for <code><jsp-file></code> element of a
@@ -71,9 +68,8 @@ public class Constants {
* value returned by <code>request.getServletPath()</code> to select
* the JSP page to be executed.
*/
- public static final String JSP_FILE =
- System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.JSP_FILE", "org.apache.catalina.jsp_file");
-
+ public static final String JSP_FILE = System.getProperty(
+ "org.apache.sling.scripting.jsp.jasper.Constants.JSP_FILE", "org.apache.catalina.jsp_file");
/**
* Default size of the JSP buffer.
@@ -92,116 +88,107 @@ public class Constants {
/**
* The query parameter that causes the JSP engine to just
- * pregenerated the servlet but not invoke it.
+ * pregenerated the servlet but not invoke it.
*/
- public static final String PRECOMPILE =
- System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.PRECOMPILE", "jsp_precompile");
+ public static final String PRECOMPILE =
+ System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.PRECOMPILE", "jsp_precompile");
/**
* The name of the system property that will be checked to set the value for {@link #JSP_PACKAGE_NAME}.
*/
- public static final String JSP_PACKAGE_NAME_PROPERTY_NAME = "org.apache.sling.scripting.jsp.jasper.Constants.JSP_PACKAGE_NAME";
+ public static final String JSP_PACKAGE_NAME_PROPERTY_NAME =
+ "org.apache.sling.scripting.jsp.jasper.Constants.JSP_PACKAGE_NAME";
/**
* The default package name for compiled jsp pages.
*/
- public static final String JSP_PACKAGE_NAME =
- System.getProperty(JSP_PACKAGE_NAME_PROPERTY_NAME, "org.apache.jsp");
+ public static final String JSP_PACKAGE_NAME = System.getProperty(JSP_PACKAGE_NAME_PROPERTY_NAME, "org.apache.jsp");
/**
* The default package name for tag handlers generated from tag files
*/
- public static final String TAG_FILE_PACKAGE_NAME =
- System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.TAG_FILE_PACKAGE_NAME", "org.apache.jsp.tag");
+ public static final String TAG_FILE_PACKAGE_NAME = System.getProperty(
+ "org.apache.sling.scripting.jsp.jasper.Constants.TAG_FILE_PACKAGE_NAME", "org.apache.jsp.tag");
/**
* Servlet context and request attributes that the JSP engine
- * uses.
+ * uses.
*/
public static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path";
+
public static final String TMP_DIR = "javax.servlet.context.tempdir";
// Must be kept in sync with org/apache/catalina/Globals.java
- public static final String ALT_DD_ATTR =
- System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.ALT_DD_ATTR", "org.apache.catalina.deploy.alt_dd");
+ public static final String ALT_DD_ATTR = System.getProperty(
+ "org.apache.sling.scripting.jsp.jasper.Constants.ALT_DD_ATTR", "org.apache.catalina.deploy.alt_dd");
/**
- * Public Id and the Resource path (of the cached copy)
- * of the DTDs for tag library descriptors.
+ * Public Id and the Resource path (of the cached copy)
+ * 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";
- public static final String TAGLIB_DTD_RESOURCE_PATH_11 =
- "/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";
- public static final String TAGLIB_DTD_RESOURCE_PATH_12 =
- "/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd";
+ public static final String TAGLIB_DTD_PUBLIC_ID_11 = "-//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";
+ public static final String TAGLIB_DTD_PUBLIC_ID_12 = "-//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";
/**
- * Public Id and the Resource path (of the cached copy)
+ * 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";
- public static final String WEBAPP_DTD_RESOURCE_PATH_22 =
- "/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";
- public static final String WEBAPP_DTD_RESOURCE_PATH_23 =
- "/javax/servlet/resources/web-app_2_3.dtd";
+ public static final String WEBAPP_DTD_PUBLIC_ID_22 = "-//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";
+ public static final String WEBAPP_DTD_PUBLIC_ID_23 = "-//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";
/**
* List of the Public IDs that we cache, and their
- * associated location. This is used by
+ * associated location. This is used by
* an EntityResolver to return the location of the
* cached copy of a DTD.
*/
public static final String[] 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 String[] 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,
};
-
+
/**
* Default URLs to download the pluging for Netscape and IE.
*/
- public static final String NS_PLUGIN_URL =
- "http://java.sun.com/products/plugin/";
+ public static final String NS_PLUGIN_URL = "http://java.sun.com/products/plugin/";
- public static final String IE_PLUGIN_URL =
- "http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0";
+ public static final String IE_PLUGIN_URL =
+ "http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0";
/**
* Prefix to use for generated temporary variable names
*/
- public static final String TEMP_VARIABLE_NAME_PREFIX =
- System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.TEMP_VARIABLE_NAME_PREFIX", "_jspx_temp");
+ public static final String TEMP_VARIABLE_NAME_PREFIX = System.getProperty(
+ "org.apache.sling.scripting.jsp.jasper.Constants.TEMP_VARIABLE_NAME_PREFIX", "_jspx_temp");
/**
* A replacement char for "\$".
* XXX This is a hack to avoid changing EL interpreter to recognize "\$"
*/
public static final char ESC = '\u001b';
+
public static final String ESCStr = "'\\u001b'";
/**
* Has security been turned on?
*/
- public static final boolean IS_SECURITY_ENABLED =
- (System.getSecurityManager() != null);
+ public static final boolean IS_SECURITY_ENABLED = (System.getSecurityManager() != null);
/**
* The name of the path parameter used to pass the session identifier
* back and forth with the client.
*/
public static final String SESSION_PARAMETER_NAME = "jsessionid";
-
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/IOProvider.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/IOProvider.java
index 9a94a6b..0662578 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/IOProvider.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/IOProvider.java
@@ -1,17 +1,20 @@
/*
- * Copyright 2007 The Apache Software Foundation.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.scripting.jsp.jasper;
@@ -55,8 +58,7 @@ public interface IOProvider {
* @throws FileNotFoundException If the file cannot be found
* @throws IOException If any other error occurs.
*/
- InputStream getInputStream(String fileName)
- throws FileNotFoundException, IOException;
+ InputStream getInputStream(String fileName) throws FileNotFoundException, IOException;
/**
* Remove a generated output.
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/JasperException.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/JasperException.java
index d6d7289..7b5feeb 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/JasperException.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/JasperException.java
@@ -1,46 +1,47 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper;
/**
* Base class for all exceptions generated by the JSP engine. Makes it
- * convienient to catch just this at the top-level.
+ * convienient to catch just this at the top-level.
*
* @author Anil K. Vijendran
*/
public class JasperException extends javax.servlet.ServletException {
-
+
public JasperException(String reason) {
- super(reason);
+ super(reason);
}
/**
* Creates a JasperException with the embedded exception and the reason for
* throwing a JasperException
*/
- public JasperException (String reason, Throwable exception) {
- super(reason, exception);
+ public JasperException(String reason, Throwable exception) {
+ super(reason, exception);
}
/**
* Creates a JasperException with the embedded exception
*/
- public JasperException (Throwable exception) {
- super(exception);
+ public JasperException(Throwable exception) {
+ super(exception);
}
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
index d414312..55efaf2 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
@@ -1,21 +1,26 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.scripting.jsp.jasper;
+import javax.servlet.ServletContext;
+import javax.servlet.jsp.tagext.TagInfo;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -27,9 +32,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import javax.servlet.ServletContext;
-import javax.servlet.jsp.tagext.TagInfo;
-
import org.apache.sling.commons.compiler.source.JavaEscapeHelper;
import org.apache.sling.scripting.jsp.jasper.compiler.Compiler;
import org.apache.sling.scripting.jsp.jasper.compiler.JDTCompiler;
@@ -79,21 +81,19 @@ public class JspCompilationContext {
private volatile TagInfo tagInfo;
private volatile URL tagFileJarUrl;
- public JspCompilationContext(String jspUri,
- boolean isErrPage,
- Options options,
- ServletContext context,
- JspRuntimeContext rctxt) {
+ public JspCompilationContext(
+ String jspUri, boolean isErrPage, Options options, ServletContext context, JspRuntimeContext rctxt) {
this(jspUri, isErrPage, options, context, rctxt, Constants.JSP_PACKAGE_NAME);
}
// jspURI _must_ be relative to the context
- public JspCompilationContext(String jspUri,
- boolean isErrPage,
- Options options,
- ServletContext context,
- JspRuntimeContext rctxt,
- String basePckName) {
+ public JspCompilationContext(
+ String jspUri,
+ boolean isErrPage,
+ Options options,
+ ServletContext context,
+ JspRuntimeContext rctxt,
+ String basePckName) {
this.jspUri = canonicalURI(jspUri);
this.isErrPage = isErrPage;
@@ -118,12 +118,13 @@ public class JspCompilationContext {
this.basePackageName = basePckName;
}
- public JspCompilationContext(String tagfile,
- TagInfo tagInfo,
- Options options,
- ServletContext context,
- JspRuntimeContext rctxt,
- URL tagFileJarUrl) {
+ public JspCompilationContext(
+ String tagfile,
+ TagInfo tagInfo,
+ Options options,
+ ServletContext context,
+ JspRuntimeContext rctxt,
+ URL tagFileJarUrl) {
this(tagfile, false, options, context, rctxt);
this.isTagFile = true;
this.tagInfo = tagInfo;
@@ -157,8 +158,7 @@ public class JspCompilationContext {
* @throws FileNotFoundException If the file cannot be found
* @throws IOException If an error occurrs creating the intput stream.
*/
- public InputStream getInputStream(String fileName)
- throws FileNotFoundException, IOException {
+ public InputStream getInputStream(String fileName) throws FileNotFoundException, IOException {
return getRuntimeContext().getIOProvider().getInputStream(fileName);
}
@@ -186,9 +186,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;
}
@@ -199,7 +199,7 @@ public class JspCompilationContext {
* compilers that are created.
*/
private Compiler createCompiler() {
- if (jspCompiler != null ) {
+ if (jspCompiler != null) {
return jspCompiler;
}
jspCompiler = new JDTCompiler(this);
@@ -211,9 +211,9 @@ public class JspCompilationContext {
}
public Compiler activateCompiler() {
- if ( jspCompiler == null ) {
- synchronized ( this ) {
- if ( jspCompiler == null ) {
+ if (jspCompiler == null) {
+ synchronized (this) {
+ if (jspCompiler == null) {
// create compile and compile
this.compile(); // we ignore the exception
}
@@ -247,7 +247,6 @@ public class JspCompilationContext {
return context.getResourceAsStream(canonicalURI(res));
}
-
public URL getResource(String res) throws MalformedURLException {
return context.getResource(canonicalURI(res));
}
@@ -402,8 +401,7 @@ public class JspCompilationContext {
protected String getDerivedPackageName() {
if (derivedPackageName == null) {
int iSep = jspUri.lastIndexOf('/');
- derivedPackageName = (iSep > 0) ?
- JavaEscapeHelper.makeJavaPackage(jspUri.substring(1,iSep)) : "";
+ derivedPackageName = (iSep > 0) ? JavaEscapeHelper.makeJavaPackage(jspUri.substring(1, iSep)) : "";
}
return derivedPackageName;
}
@@ -444,12 +442,11 @@ public class JspCompilationContext {
}
if (isTagFile()) {
- String tagName = tagInfo.getTagClassName();
+ String tagName = tagInfo.getTagClassName();
javaPath = tagName.replace('.', '/') + ".java";
} else {
- javaPath = getServletPackageName().replace('.', '/') + '/' +
- getServletClassName() + ".java";
- }
+ javaPath = getServletPackageName().replace('.', '/') + '/' + getServletClassName() + ".java";
+ }
return javaPath;
}
@@ -494,8 +491,7 @@ public class JspCompilationContext {
* 'exposed' in the web application.
*/
public String[] getTldLocation(String uri) throws JasperException {
- String[] location =
- getOptions().getTldLocationsCache().getLocation(uri);
+ String[] location = getOptions().getTldLocationsCache().getLocation(uri);
return location;
}
@@ -516,14 +512,10 @@ public class JspCompilationContext {
} catch (final JasperException ex) {
return ex;
} catch (final IOException ioe) {
- final JasperException je = new JasperException(
- Localizer.getMessage("jsp.error.unable.compile"),
- ioe);
+ final JasperException je = new JasperException(Localizer.getMessage("jsp.error.unable.compile"), ioe);
return je;
} catch (final Exception ex) {
- JasperException je = new JasperException(
- Localizer.getMessage("jsp.error.unable.compile"),
- ex);
+ JasperException je = new JasperException(Localizer.getMessage("jsp.error.unable.compile"), ex);
return je;
} finally {
c.clean();
@@ -544,18 +536,15 @@ public class JspCompilationContext {
return name;
}
- public Class<?> load()
- throws JasperException {
+ public Class<?> load() throws JasperException {
try {
final String name = this.getClassName();
final Class<?> servletClass = getClassLoader().loadClass(name);
return servletClass;
} catch (ClassNotFoundException cex) {
- throw new JasperException(Localizer.getMessage("jsp.error.unable.load"),
- cex);
+ throw new JasperException(Localizer.getMessage("jsp.error.unable.load"), cex);
} catch (Exception ex) {
- throw new JasperException(Localizer.getMessage("jsp.error.unable.compile"),
- ex);
+ throw new JasperException(Localizer.getMessage("jsp.error.unable.compile"), ex);
}
}
@@ -572,12 +561,12 @@ public class JspCompilationContext {
private void createOutputDir() {
String path = null;
if (isTagFile()) {
- String tagName = tagInfo.getTagClassName();
+ String tagName = tagInfo.getTagClassName();
path = tagName.replace('.', '/');
- path = path.substring(0, path.lastIndexOf('/'));
+ path = path.substring(0, path.lastIndexOf('/'));
} else {
path = getServletPackageName().replace('.', '/');
- }
+ }
// Append servlet or tag handler path to scratch dir
outputDir = options.getScratchDir() + File.separator + path + File.separator;
@@ -587,67 +576,62 @@ public class JspCompilationContext {
}
private static final boolean isPathSeparator(char c) {
- return (c == '/' || c == '\\');
+ return (c == '/' || c == '\\');
}
private static final String canonicalURI(String s) {
- if (s == null) return null;
- StringBuilder result = new StringBuilder();
- final int len = s.length();
- int pos = 0;
- while (pos < len) {
- char c = s.charAt(pos);
- if ( isPathSeparator(c) ) {
- /*
- * multiple path separators.
- * 'foo///bar' -> 'foo/bar'
- */
- while (pos+1 < len && isPathSeparator(s.charAt(pos+1))) {
- ++pos;
- }
-
- if (pos+1 < len && s.charAt(pos+1) == '.') {
- /*
- * a single dot at the end of the path - we are done.
- */
- if (pos+2 >= len) break;
-
- switch (s.charAt(pos+2)) {
- /*
- * self directory in path
- * foo/./bar -> foo/bar
- */
- case '/':
- case '\\':
- pos += 2;
- continue;
-
- /*
- * two dots in a path: go back one hierarchy.
- * foo/bar/../baz -> foo/baz
- */
- case '.':
- // only if we have exactly _two_ dots.
- if (pos+3 < len && isPathSeparator(s.charAt(pos+3))) {
- pos += 3;
- int separatorPos = result.length()-1;
- while (separatorPos >= 0 &&
- ! isPathSeparator(result
- .charAt(separatorPos))) {
- --separatorPos;
- }
- if (separatorPos >= 0)
- result.setLength(separatorPos);
- continue;
- }
- }
- }
- }
- result.append(c);
- ++pos;
- }
- return result.toString();
- }
+ if (s == null) return null;
+ StringBuilder result = new StringBuilder();
+ final int len = s.length();
+ int pos = 0;
+ while (pos < len) {
+ char c = s.charAt(pos);
+ if (isPathSeparator(c)) {
+ /*
+ * multiple path separators.
+ * 'foo///bar' -> 'foo/bar'
+ */
+ while (pos + 1 < len && isPathSeparator(s.charAt(pos + 1))) {
+ ++pos;
+ }
+ if (pos + 1 < len && s.charAt(pos + 1) == '.') {
+ /*
+ * a single dot at the end of the path - we are done.
+ */
+ if (pos + 2 >= len) break;
+
+ switch (s.charAt(pos + 2)) {
+ /*
+ * self directory in path
+ * foo/./bar -> foo/bar
+ */
+ case '/':
+ case '\\':
+ pos += 2;
+ continue;
+
+ /*
+ * two dots in a path: go back one hierarchy.
+ * foo/bar/../baz -> foo/baz
+ */
+ case '.':
+ // only if we have exactly _two_ dots.
+ if (pos + 3 < len && isPathSeparator(s.charAt(pos + 3))) {
+ pos += 3;
+ int separatorPos = result.length() - 1;
+ while (separatorPos >= 0 && !isPathSeparator(result.charAt(separatorPos))) {
+ --separatorPos;
+ }
+ if (separatorPos >= 0) result.setLength(separatorPos);
+ continue;
+ }
+ }
+ }
+ }
+ result.append(c);
+ ++pos;
+ }
+ return result.toString();
+ }
}
-
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/Options.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/Options.java
index e7f87df..2679dc3 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/Options.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/Options.java
@@ -1,20 +1,21 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper;
import org.apache.sling.scripting.jsp.jasper.compiler.JspConfig;
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/BeanRepository.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/BeanRepository.java
index 4b9f94a..22e37c8 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/BeanRepository.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/BeanRepository.java
@@ -1,28 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.scripting.jsp.jasper.compiler;
-
import java.util.HashMap;
import org.apache.sling.scripting.jsp.jasper.JasperException;
/**
- * Repository of {page, request, session, application}-scoped beans
+ * Repository of {page, request, session, application}-scoped beans
*
* @author Mandar Raje
* @author Remy Maucherat
@@ -35,41 +36,37 @@ public class BeanRepository {
/**
* Constructor.
- */
+ */
public BeanRepository(ClassLoader loader, ErrorDispatcher err) {
this.loader = loader;
this.errDispatcher = err;
beanTypes = new HashMap<String, String>();
}
- public void addBean(Node.UseBean n, String s, String type, String scope)
- throws JasperException {
+ public void addBean(Node.UseBean n, String s, String type, String scope) throws JasperException {
- if (!(scope == null || scope.equals("page") || scope.equals("request")
- || scope.equals("session") || scope.equals("application"))) {
+ if (!(scope == null
+ || scope.equals("page")
+ || scope.equals("request")
+ || scope.equals("session")
+ || scope.equals("application"))) {
errDispatcher.jspError(n, "jsp.error.usebean.badScope");
}
beanTypes.put(s, type);
}
-
- public Class getBeanType(String bean)
- throws JasperException {
+
+ public Class getBeanType(String bean) throws JasperException {
Class clazz = null;
try {
clazz = loader.loadClass(beanTypes.get(bean));
} catch (ClassNotFoundException ex) {
- throw new JasperException (ex);
+ throw new JasperException(ex);
}
return clazz;
}
-
+
public boolean checkVariable(String bean) {
return beanTypes.containsKey(bean);
}
-
}
-
-
-
-
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Collector.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Collector.java
index 7e2aec2..0edcd9b 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Collector.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Collector.java
@@ -1,20 +1,21 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
import org.apache.sling.scripting.jsp.jasper.JasperException;
@@ -26,7 +27,6 @@ import org.apache.sling.scripting.jsp.jasper.JasperException;
* @author Kin-man Chung
* @author Mark Roth
*/
-
class Collector {
/**
@@ -76,7 +76,7 @@ class Collector {
scriptingElementSeen = true;
}
usebeanSeen = true;
- visitBody(n);
+ visitBody(n);
}
public void visit(Node.PlugIn n) throws JasperException {
@@ -91,16 +91,14 @@ class Collector {
public void visit(Node.CustomTag n) throws JasperException {
// Check to see what kinds of element we see as child elements
- checkSeen( n.getChildInfo(), n );
+ checkSeen(n.getChildInfo(), n);
}
/**
* Check all child nodes for various elements and update the given
* ChildInfo object accordingly. Visits body in the process.
*/
- private void checkSeen( Node.ChildInfo ci, Node n )
- throws JasperException
- {
+ private void checkSeen(Node.ChildInfo ci, Node n) throws JasperException {
// save values collected so far
boolean scriptingElementSeenSave = scriptingElementSeen;
scriptingElementSeen = false;
@@ -116,8 +114,8 @@ class Collector {
hasScriptingVars = false;
// Scan attribute list for expressions
- if( n instanceof Node.CustomTag ) {
- Node.CustomTag ct = (Node.CustomTag)n;
+ if (n instanceof Node.CustomTag) {
+ Node.CustomTag ct = (Node.CustomTag) n;
Node.JspAttribute[] attrs = ct.getJspAttributes();
for (int i = 0; attrs != null && i < attrs.length; i++) {
if (attrs[i].isExpression()) {
@@ -129,14 +127,13 @@ class Collector {
visitBody(n);
- if( (n instanceof Node.CustomTag) && !hasScriptingVars) {
- Node.CustomTag ct = (Node.CustomTag)n;
- hasScriptingVars = ct.getVariableInfos().length > 0 ||
- ct.getTagVariableInfos().length > 0;
+ if ((n instanceof Node.CustomTag) && !hasScriptingVars) {
+ Node.CustomTag ct = (Node.CustomTag) n;
+ hasScriptingVars = ct.getVariableInfos().length > 0 || ct.getTagVariableInfos().length > 0;
}
// Record if the tag element and its body contains any scriptlet.
- ci.setScriptless(! scriptingElementSeen);
+ ci.setScriptless(!scriptingElementSeen);
ci.setHasUseBean(usebeanSeen);
ci.setHasIncludeAction(includeActionSeen);
ci.setHasParamAction(paramActionSeen);
@@ -153,8 +150,7 @@ class Collector {
}
public void visit(Node.JspElement n) throws JasperException {
- if (n.getNameAttribute().isExpression())
- scriptingElementSeen = true;
+ if (n.getNameAttribute().isExpression()) scriptingElementSeen = true;
Node.JspAttribute[] attrs = n.getJspAttributes();
for (int i = 0; i < attrs.length; i++) {
@@ -167,11 +163,11 @@ class Collector {
}
public void visit(Node.JspBody n) throws JasperException {
- checkSeen( n.getChildInfo(), n );
+ checkSeen(n.getChildInfo(), n);
}
public void visit(Node.NamedAttribute n) throws JasperException {
- checkSeen( n.getChildInfo(), n );
+ checkSeen(n.getChildInfo(), n);
}
public void visit(Node.Declaration n) throws JasperException {
@@ -187,18 +183,14 @@ class Collector {
}
public void updatePageInfo(PageInfo pageInfo) {
- pageInfo.setScriptless(! scriptingElementSeen);
+ pageInfo.setScriptless(!scriptingElementSeen);
}
}
+ public static void collect(Compiler compiler, Node.Nodes page) throws JasperException {
- public static void collect(Compiler compiler, Node.Nodes page)
- throws JasperException {
-
- CollectVisitor collectVisitor = new CollectVisitor();
+ CollectVisitor collectVisitor = new CollectVisitor();
page.visit(collectVisitor);
collectVisitor.updatePageInfo(compiler.getPageInfo());
-
}
}
-
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java
index ce23b30..8217ee8 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java
@@ -1,20 +1,21 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
import java.io.FileNotFoundException;
@@ -39,8 +40,7 @@ import org.apache.sling.scripting.jsp.jasper.compiler.Node.CustomTag;
*/
public abstract class Compiler {
- protected org.apache.juli.logging.Log log = org.apache.juli.logging.LogFactory
- .getLog(Compiler.class);
+ protected org.apache.juli.logging.Log log = org.apache.juli.logging.LogFactory.getLog(Compiler.class);
// ----------------------------------------------------- Instance Variables
@@ -92,12 +92,13 @@ public abstract class Compiler {
}
// Setup page info area
- pageInfo = new PageInfo(new BeanRepository(ctxt.getClassLoader(),
- errDispatcher), ctxt.getJspFile(), this.ctxt.getOptions().isDefaultSession());
+ pageInfo = new PageInfo(
+ new BeanRepository(ctxt.getClassLoader(), errDispatcher),
+ ctxt.getJspFile(),
+ this.ctxt.getOptions().isDefaultSession());
JspConfig jspConfig = this.ctxt.getOptions().getJspConfig();
- JspConfig.JspProperty jspProperty = jspConfig.findJspProperty(ctxt
- .getJspFile());
+ JspConfig.JspProperty jspProperty = jspConfig.findJspProperty(ctxt.getJspFile());
/*
* If the current uri is matched by a pattern specified in a
@@ -105,12 +106,10 @@ public abstract class Compiler {
* properties.
*/
if (jspProperty.isELIgnored() != null) {
- pageInfo.setELIgnored(JspUtil.booleanValue(jspProperty
- .isELIgnored()));
+ pageInfo.setELIgnored(JspUtil.booleanValue(jspProperty.isELIgnored()));
}
if (jspProperty.isScriptingInvalid() != null) {
- pageInfo.setScriptingInvalid(JspUtil.booleanValue(jspProperty
- .isScriptingInvalid()));
+ pageInfo.setScriptingInvalid(JspUtil.booleanValue(jspProperty.isScriptingInvalid()));
}
if (jspProperty.getIncludePrelude() != null) {
pageInfo.setIncludePrelude(jspProperty.getIncludePrelude());
@@ -119,12 +118,11 @@ public abstract class Compiler {
pageInfo.setIncludeCoda(jspProperty.getIncludeCoda());
}
if (jspProperty.isDeferedSyntaxAllowedAsLiteral() != null) {
- pageInfo.setDeferredSyntaxAllowedAsLiteral(JspUtil.booleanValue(jspProperty
- .isDeferedSyntaxAllowedAsLiteral()));
+ pageInfo.setDeferredSyntaxAllowedAsLiteral(
+ JspUtil.booleanValue(jspProperty.isDeferedSyntaxAllowedAsLiteral()));
}
if (jspProperty.isTrimDirectiveWhitespaces() != null) {
- pageInfo.setTrimDirectiveWhitespaces(JspUtil.booleanValue(jspProperty
- .isTrimDirectiveWhitespaces()));
+ pageInfo.setTrimDirectiveWhitespaces(JspUtil.booleanValue(jspProperty.isTrimDirectiveWhitespaces()));
}
ctxt.checkOutputDir();
@@ -137,13 +135,11 @@ public abstract class Compiler {
OutputStreamWriter osw = null;
try {
- osw = new OutputStreamWriter(
- ctxt.getOutputStream(javaFileName), javaEncoding);
+ osw = new OutputStreamWriter(ctxt.getOutputStream(javaFileName), javaEncoding);
} catch (UnsupportedEncodingException ex) {
- errDispatcher.jspError("jsp.error.needAlternateJavaEncoding",
- javaEncoding);
+ errDispatcher.jspError("jsp.error.needAlternateJavaEncoding", javaEncoding);
} catch (IOException ioe) {
- throw (IOException)new FileNotFoundException(ioe.getMessage()).initCause(ioe);
+ throw (IOException) new FileNotFoundException(ioe.getMessage()).initCause(ioe);
}
writer = new ServletWriter(new PrintWriter(osw));
@@ -209,8 +205,8 @@ public abstract class Compiler {
if (log.isDebugEnabled()) {
t4 = System.currentTimeMillis();
- log.debug("Generated " + javaFileName + " total=" + (t4 - t1)
- + " generate=" + (t4 - t3) + " validate=" + (t2 - t1));
+ log.debug("Generated " + javaFileName + " total=" + (t4 - t1) + " generate=" + (t4 - t3) + " validate="
+ + (t2 - t1));
}
} catch (Exception e) {
@@ -248,14 +244,12 @@ public abstract class Compiler {
/**
* Compile the servlet from .java file to .class file
*/
- protected abstract void generateClass(String[] smap)
- throws FileNotFoundException, JasperException, Exception;
+ protected abstract void generateClass(String[] smap) throws FileNotFoundException, JasperException, Exception;
/**
* Compile the jsp file from the current engine context
*/
- public void compile() throws FileNotFoundException, JasperException,
- Exception {
+ public void compile() throws FileNotFoundException, JasperException, Exception {
compile(true);
}
@@ -267,8 +261,7 @@ public abstract class Compiler {
* If true, generate both .java and .class file If false,
* generate only .java file
*/
- public void compile(boolean compileClass) throws FileNotFoundException,
- JasperException, Exception {
+ public void compile(boolean compileClass) throws FileNotFoundException, JasperException, Exception {
compile(compileClass, false);
}
@@ -311,9 +304,9 @@ public abstract class Compiler {
// In development mode, they are used for detailed
// error messages.
// http://issues.apache.org/bugzilla/show_bug.cgi?id=37062
- //if (!this.options.getDevelopment()) {
+ // if (!this.options.getDevelopment()) {
// pageNodes = null;
- //}
+ // }
if (ctxt.getWriter() != null) {
ctxt.getWriter().close();
@@ -373,14 +366,13 @@ public abstract class Compiler {
}
public void clean() {
- if ( this.pageNodes != null ) {
+ if (this.pageNodes != null) {
try {
pageNodes.visit(new CleanVisitor());
- } catch ( final JasperException ignore) {
+ } catch (final JasperException ignore) {
// ignore
}
}
-
}
private static final class CleanVisitor extends Node.Visitor {
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/DefaultErrorHandler.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/DefaultErrorHandler.java
index 38250b8..17849e8 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/DefaultErrorHandler.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/DefaultErrorHandler.java
@@ -1,20 +1,21 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
import org.apache.sling.scripting.jsp.jasper.JasperException;
@@ -25,7 +26,7 @@ import org.apache.sling.scripting.jsp.jasper.JasperException;
* @author Jan Luehe
*/
class DefaultErrorHandler implements ErrorHandler {
-
+
/*
* Processes the given JSP parse error.
*
@@ -35,12 +36,10 @@ class DefaultErrorHandler implements ErrorHandler {
* @param errMsg Parse error message
* @param exception Parse exception
*/
- public void jspError(String fname, int line, int column, String errMsg,
- Exception ex) throws JasperException {
- throw new JasperException(fname + "(" + line + "," + column + ")"
- + " " + errMsg, ex);
+ public void jspError(String fname, int line, int column, String errMsg, Exception ex) throws JasperException {
+ throw new JasperException(fname + "(" + line + "," + column + ")" + " " + errMsg, ex);
}
-
+
/*
* Processes the given JSP parse error.
*
@@ -50,7 +49,7 @@ class DefaultErrorHandler implements ErrorHandler {
public void jspError(String errMsg, Exception ex) throws JasperException {
throw new JasperException(errMsg, ex);
}
-
+
/*
* Processes the given javac compilation errors.
*
@@ -58,52 +57,43 @@ class DefaultErrorHandler implements ErrorHandler {
* compilation errors
*/
public void javacError(JavacErrorDetail[] details) throws JasperException {
-
+
if (details == null) {
return;
}
-
+
Object[] args = null;
StringBuffer buf = new StringBuffer();
-
- for (int i=0; i < details.length; i++) {
+
+ for (int i = 0; i < details.length; i++) {
if (details[i].getJspBeginLineNumber() >= 0) {
- args = new Object[] {
- new Integer(details[i].getJspBeginLineNumber()),
- details[i].getJspFileName() };
+ args = new Object[] {new Integer(details[i].getJspBeginLineNumber()), details[i].getJspFileName()};
buf.append("\n\n");
- buf.append(Localizer.getMessage("jsp.error.single.line.number",
- args));
+ buf.append(Localizer.getMessage("jsp.error.single.line.number", args));
buf.append("\n");
buf.append(details[i].getErrorMessage());
buf.append("\n");
buf.append(details[i].getJspExtract());
} else {
- args = new Object[] {
- new Integer(details[i].getJavaLineNumber()) };
+ args = new Object[] {new Integer(details[i].getJavaLineNumber())};
buf.append("\n\n");
- buf.append(Localizer.getMessage("jsp.error.java.line.number",
- args));
+ buf.append(Localizer.getMessage("jsp.error.java.line.number", args));
buf.append("\n");
buf.append(details[i].getErrorMessage());
}
}
- //buf.append("\n\nStacktrace:");
- throw new JasperException(
- Localizer.getMessage("jsp.error.unable.compile") + ": " + buf);
+ // buf.append("\n\nStacktrace:");
+ throw new JasperException(Localizer.getMessage("jsp.error.unable.compile") + ": " + buf);
}
-
+
/**
* Processes the given javac error report and exception.
*
* @param errorReport Compilation error report
* @param exception Compilation exception
*/
- public void javacError(String errorReport, Exception exception)
- throws JasperException {
-
- throw new JasperException(
- Localizer.getMessage("jsp.error.unable.compile"), exception);
+ public void javacError(String errorReport, Exception exception) throws JasperException {
+
+ throw new JasperException(Localizer.getMessage("jsp.error.unable.compile"), exception);
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Dumper.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Dumper.java
index b1961fb..67e8516 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Dumper.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Dumper.java
@@ -1,207 +1,204 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
-import org.xml.sax.Attributes;
import org.apache.sling.scripting.jsp.jasper.JasperException;
+import org.xml.sax.Attributes;
class Dumper {
static class DumpVisitor extends Node.Visitor {
- private int indent = 0;
-
- private String getAttributes(Attributes attrs) {
- if (attrs == null)
- return "";
-
- StringBuffer buf = new StringBuffer();
- 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, char[] chars, String suffix) {
- String str = null;
- if (chars != null) {
- str = new String(chars);
- }
- printString(prefix, str, suffix);
- }
-
- 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 int indent = 0;
+
+ private String getAttributes(Attributes attrs) {
+ if (attrs == null) return "";
+
+ StringBuffer buf = new StringBuffer();
+ 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, char[] chars, String suffix) {
+ String str = null;
+ if (chars != null) {
+ str = new String(chars);
+ }
+ printString(prefix, str, suffix);
+ }
+
+ 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--;
+ }
}
public void visit(Node.PageDirective n) throws JasperException {
- printAttributes("<%@ page", n.getAttributes(), "%>");
+ printAttributes("<%@ page", n.getAttributes(), "%>");
}
public void visit(Node.TaglibDirective n) throws JasperException {
- printAttributes("<%@ taglib", n.getAttributes(), "%>");
+ printAttributes("<%@ taglib", n.getAttributes(), "%>");
}
public void visit(Node.IncludeDirective n) throws JasperException {
- printAttributes("<%@ include", n.getAttributes(), "%>");
- dumpBody(n);
+ printAttributes("<%@ include", n.getAttributes(), "%>");
+ dumpBody(n);
}
public void visit(Node.Comment n) throws JasperException {
- printString("<%--", n.getText(), "--%>");
+ printString("<%--", n.getText(), "--%>");
}
public void visit(Node.Declaration n) throws JasperException {
- printString("<%!", n.getText(), "%>");
+ printString("<%!", n.getText(), "%>");
}
public void visit(Node.Expression n) throws JasperException {
- printString("<%=", n.getText(), "%>");
+ printString("<%=", n.getText(), "%>");
}
public void visit(Node.Scriptlet n) throws JasperException {
- printString("<%", n.getText(), "%>");
+ printString("<%", n.getText(), "%>");
}
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>");
}
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>");
}
public void visit(Node.GetProperty n) throws JasperException {
- printAttributes("<jsp:getProperty", n.getAttributes(), "/>");
+ printAttributes("<jsp:getProperty", n.getAttributes(), "/>");
}
public void visit(Node.SetProperty n) throws JasperException {
- printAttributes("<jsp:setProperty", n.getAttributes(), ">");
+ printAttributes("<jsp:setProperty", n.getAttributes(), ">");
dumpBody(n);
printString("</jsp:setProperty>");
}
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>");
}
-
+
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>");
+ }
+
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>");
}
-
+
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>");
}
-
+
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>");
}
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>");
}
-
+
public void visit(Node.ELExpression n) throws JasperException {
- printString( "${" + new String( n.getText() ) + "}" );
+ printString("${" + new String(n.getText()) + "}");
}
public void visit(Node.CustomTag n) throws JasperException {
- printAttributes("<" + n.getQName(), n.getAttributes(), ">");
- dumpBody(n);
- printString("</" + n.getQName() + ">");
+ printAttributes("<" + n.getQName(), n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</" + n.getQName() + ">");
}
- public void visit(Node.UninterpretedTag n) throws JasperException {
- String tag = n.getQName();
- printAttributes("<"+tag, n.getAttributes(), ">");
- dumpBody(n);
- printString("</" + tag + ">");
+ public void visit(Node.UninterpretedTag n) throws JasperException {
+ String tag = n.getQName();
+ printAttributes("<" + tag, n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</" + tag + ">");
}
- public void visit(Node.TemplateText n) throws JasperException {
- printString(new String(n.getText()));
- }
+ 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(" ");
- }
- }
+ 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();
+ }
}
}
-
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELFunctionMapper.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELFunctionMapper.java
index a340970..5e22aef 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELFunctionMapper.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELFunctionMapper.java
@@ -1,25 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
-import java.util.*;
import javax.servlet.jsp.tagext.FunctionInfo;
+import java.util.*;
+
import org.apache.sling.scripting.jsp.jasper.JasperException;
/**
@@ -30,11 +32,10 @@ import org.apache.sling.scripting.jsp.jasper.JasperException;
*
* @author Kin-man Chung
*/
-
public class ELFunctionMapper {
private int currFunc = 0;
- StringBuffer ds; // Contains codes to initialize the functions mappers.
- StringBuffer ss; // Contains declarations of the functions mappers.
+ StringBuffer ds; // Contains codes to initialize the functions mappers.
+ StringBuffer ss; // Contains declarations of the functions mappers.
/**
* Creates the functions mappers for all EL expressions in the JSP page.
@@ -42,8 +43,7 @@ public class ELFunctionMapper {
* @param compiler Current compiler, mainly for accessing error dispatcher.
* @param page The current compilation unit.
*/
- public static void map(Compiler compiler, Node.Nodes page)
- throws JasperException {
+ public static void map(Compiler compiler, Node.Nodes page) throws JasperException {
ELFunctionMapper map = new ELFunctionMapper();
map.ds = new StringBuffer();
@@ -65,7 +65,7 @@ public class ELFunctionMapper {
* for functions, and if found functions mappers are created.
*/
class ELFunctionVisitor extends Node.Visitor {
-
+
/**
* Use a global name map to facilitate reuse of function maps.
* The key used is prefix:function:uri.
@@ -134,8 +134,7 @@ public class ELFunctionMapper {
doMap(n.getEL());
}
- private void doMap(Node.JspAttribute attr)
- throws JasperException {
+ private void doMap(Node.JspAttribute attr) throws JasperException {
if (attr != null) {
doMap(attr.getEL());
}
@@ -144,18 +143,17 @@ public class ELFunctionMapper {
/**
* Creates function mappers, if needed, from ELNodes
*/
- private void doMap(ELNode.Nodes el)
- throws JasperException {
+ private void doMap(ELNode.Nodes el) throws JasperException {
// Only care about functions in ELNode's
class Fvisitor extends ELNode.Visitor {
- ArrayList<ELNode.Function> funcs =
- new ArrayList<ELNode.Function>();
+ ArrayList<ELNode.Function> funcs = new ArrayList<ELNode.Function>();
HashMap<String, String> keyMap = new HashMap<String, String>();
+
public void visit(ELNode.Function n) throws JasperException {
String key = n.getPrefix() + ":" + n.getName();
- if (! keyMap.containsKey(key)) {
- keyMap.put(key,"");
+ if (!keyMap.containsKey(key)) {
+ keyMap.put(key, "");
funcs.add(n);
}
}
@@ -180,10 +178,11 @@ public class ELFunctionMapper {
el.setMapName(decName);
return;
}
-
+
// Generate declaration for the map statically
decName = getMapName();
- ss.append("static private org.apache.sling.scripting.jsp.jasper.runtime.ProtectedFunctionMapper " + decName + ";\n");
+ ss.append("static private org.apache.sling.scripting.jsp.jasper.runtime.ProtectedFunctionMapper " + decName
+ + ";\n");
ds.append(" " + decName + "= ");
ds.append("org.apache.sling.scripting.jsp.jasper.runtime.ProtectedFunctionMapper");
@@ -199,13 +198,12 @@ public class ELFunctionMapper {
// Setup arguments for either getMapForFunction or mapFunction
for (int i = 0; i < functions.size(); i++) {
- ELNode.Function f = (ELNode.Function)functions.get(i);
+ ELNode.Function f = (ELNode.Function) functions.get(i);
FunctionInfo funcInfo = f.getFunctionInfo();
- String key = f.getPrefix()+ ":" + f.getName();
- ds.append(funcMethod + "(\"" + key + "\", " +
- funcInfo.getFunctionClass() + ".class, " +
- '\"' + f.getMethodName() + "\", " +
- "new Class[] {");
+ String key = f.getPrefix() + ":" + f.getName();
+ ds.append(funcMethod + "(\"" + key + "\", " + funcInfo.getFunctionClass()
+ + ".class, " + '\"'
+ + f.getMethodName() + "\", " + "new Class[] {");
String params[] = f.getParameters();
for (int k = 0; k < params.length; k++) {
if (k != 0) {
@@ -214,8 +212,7 @@ public class ELFunctionMapper {
int iArray = params[k].indexOf('[');
if (iArray < 0) {
ds.append(params[k] + ".class");
- }
- else {
+ } else {
String baseType = params[k].substring(0, iArray);
ds.append("java.lang.reflect.Array.newInstance(");
ds.append(baseType);
@@ -223,7 +220,7 @@ public class ELFunctionMapper {
// Count the number of array dimension
int aCount = 0;
- for (int jj = iArray; jj < params[k].length(); jj++ ) {
+ for (int jj = iArray; jj < params[k].length(); jj++) {
if (params[k].charAt(jj) == '[') {
aCount++;
}
@@ -237,8 +234,7 @@ public class ELFunctionMapper {
}
ds.append("});\n");
// Put the current name in the global function map
- gMap.put(f.getPrefix() + ':' + f.getName() + ':' + f.getUri(),
- decName);
+ gMap.put(f.getPrefix() + ':' + f.getName() + ':' + f.getUri(), decName);
}
el.setMapName(decName);
}
@@ -255,9 +251,8 @@ public class ELFunctionMapper {
String mapName = null;
for (int i = 0; i < functions.size(); i++) {
- ELNode.Function f = (ELNode.Function)functions.get(i);
- String temName = (String) gMap.get(f.getPrefix() + ':' +
- f.getName() + ':' + f.getUri());
+ ELNode.Function f = (ELNode.Function) functions.get(i);
+ String temName = (String) gMap.get(f.getPrefix() + ':' + f.getName() + ':' + f.getUri());
if (temName == null) {
return null;
}
@@ -279,4 +274,3 @@ public class ELFunctionMapper {
}
}
}
-
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELNode.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELNode.java
index a430090..48c49fa 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELNode.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELNode.java
@@ -1,25 +1,27 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
-import java.util.*;
import javax.servlet.jsp.tagext.FunctionInfo;
+import java.util.*;
+
import org.apache.sling.scripting.jsp.jasper.JasperException;
/**
@@ -30,40 +32,38 @@ import org.apache.sling.scripting.jsp.jasper.JasperException;
*
* @author Kin-man Chung
*/
-
abstract class ELNode {
- abstract public void accept(Visitor v) throws JasperException;
+ public abstract void accept(Visitor v) throws JasperException;
/**
* Child classes
*/
-
/**
* Represents an EL expression: anything in ${ and }.
*/
public static class Root extends ELNode {
- private ELNode.Nodes expr;
- private char type;
+ private ELNode.Nodes expr;
+ private char type;
- Root(ELNode.Nodes expr, char type) {
- this.expr = expr;
- this.type = type;
- }
+ Root(ELNode.Nodes expr, char type) {
+ this.expr = expr;
+ this.type = type;
+ }
- public void accept(Visitor v) throws JasperException {
- v.visit(this);
- }
+ public void accept(Visitor v) throws JasperException {
+ v.visit(this);
+ }
- public ELNode.Nodes getExpression() {
- return expr;
- }
+ public ELNode.Nodes getExpression() {
+ return expr;
+ }
- public char getType() {
- return type;
- }
+ public char getType() {
+ return type;
+ }
}
/**
@@ -71,19 +71,19 @@ abstract class ELNode {
*/
public static class Text extends ELNode {
- private String text;
+ private String text;
- Text(String text) {
- this.text = text;
- }
+ Text(String text) {
+ this.text = text;
+ }
- public void accept(Visitor v) throws JasperException {
- v.visit(this);
- }
+ public void accept(Visitor v) throws JasperException {
+ v.visit(this);
+ }
- public String getText() {
- return text;
- }
+ public String getText() {
+ return text;
+ }
}
/**
@@ -92,19 +92,19 @@ abstract class ELNode {
*/
public static class ELText extends ELNode {
- private String text;
+ private String text;
- ELText(String text) {
- this.text = text;
- }
+ ELText(String text) {
+ this.text = text;
+ }
- public void accept(Visitor v) throws JasperException {
- v.visit(this);
- }
+ public void accept(Visitor v) throws JasperException {
+ v.visit(this);
+ }
- public String getText() {
- return text;
- }
+ public String getText() {
+ return text;
+ }
}
/**
@@ -114,61 +114,61 @@ abstract class ELNode {
*/
public static class Function extends ELNode {
- private String prefix;
- private String name;
- private String uri;
- private FunctionInfo functionInfo;
- private String methodName;
- private String[] parameters;
-
- Function(String prefix, String name) {
- this.prefix = prefix;
- this.name = name;
- }
-
- public void accept(Visitor v) throws JasperException {
- v.visit(this);
- }
-
- public String getPrefix() {
- return prefix;
- }
-
- public String getName() {
- return name;
- }
-
- public void setUri(String uri) {
- this.uri = uri;
- }
-
- public String getUri() {
- return uri;
- }
-
- public void setFunctionInfo(FunctionInfo f) {
- this.functionInfo = f;
- }
-
- public FunctionInfo getFunctionInfo() {
- return functionInfo;
- }
-
- public void setMethodName(String methodName) {
- this.methodName = methodName;
- }
-
- public String getMethodName() {
- return methodName;
- }
-
- public void setParameters(String[] parameters) {
- this.parameters = parameters;
- }
-
- public String[] getParameters() {
- return parameters;
- }
+ private String prefix;
+ private String name;
+ private String uri;
+ private FunctionInfo functionInfo;
+ private String methodName;
+ private String[] parameters;
+
+ Function(String prefix, String name) {
+ this.prefix = prefix;
+ this.name = name;
+ }
+
+ public void accept(Visitor v) throws JasperException {
+ v.visit(this);
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public void setFunctionInfo(FunctionInfo f) {
+ this.functionInfo = f;
+ }
+
+ public FunctionInfo getFunctionInfo() {
+ return functionInfo;
+ }
+
+ public void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public void setParameters(String[] parameters) {
+ this.parameters = parameters;
+ }
+
+ public String[] getParameters() {
+ return parameters;
+ }
}
/**
@@ -176,62 +176,61 @@ abstract class ELNode {
*/
public static class Nodes {
- /* Name used for creating a map for the functions in this
- EL expression, for communication to Generator.
- */
- String mapName = null; // The function map associated this EL
- private List<ELNode> list;
-
- public Nodes() {
- list = new ArrayList<ELNode>();
- }
-
- public void add(ELNode en) {
- list.add(en);
- }
-
- /**
- * Visit the nodes in the list with the supplied visitor
- * @param v The visitor used
- */
- public void visit(Visitor v) throws JasperException {
- Iterator<ELNode> iter = list.iterator();
- while (iter.hasNext()) {
- ELNode n = iter.next();
- n.accept(v);
- }
- }
-
- public Iterator<ELNode> iterator() {
- return list.iterator();
- }
-
- public boolean isEmpty() {
- return list.size() == 0;
- }
-
- /**
- * @return true if the expression contains a ${...}
- */
- public boolean containsEL() {
- Iterator<ELNode> iter = list.iterator();
- while (iter.hasNext()) {
- ELNode n = iter.next();
- if (n instanceof Root) {
- return true;
- }
- }
- return false;
- }
-
- public void setMapName(String name) {
- this.mapName = name;
- }
-
- public String getMapName() {
- return mapName;
- }
-
+ /* Name used for creating a map for the functions in this
+ EL expression, for communication to Generator.
+ */
+ String mapName = null; // The function map associated this EL
+ private List<ELNode> list;
+
+ public Nodes() {
+ list = new ArrayList<ELNode>();
+ }
+
+ public void add(ELNode en) {
+ list.add(en);
+ }
+
+ /**
+ * Visit the nodes in the list with the supplied visitor
+ * @param v The visitor used
+ */
+ public void visit(Visitor v) throws JasperException {
+ Iterator<ELNode> iter = list.iterator();
+ while (iter.hasNext()) {
+ ELNode n = iter.next();
+ n.accept(v);
+ }
+ }
+
+ public Iterator<ELNode> iterator() {
+ return list.iterator();
+ }
+
+ public boolean isEmpty() {
+ return list.size() == 0;
+ }
+
+ /**
+ * @return true if the expression contains a ${...}
+ */
+ public boolean containsEL() {
+ Iterator<ELNode> iter = list.iterator();
+ while (iter.hasNext()) {
+ ELNode n = iter.next();
+ if (n instanceof Root) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void setMapName(String name) {
+ this.mapName = name;
+ }
+
+ public String getMapName() {
+ return mapName;
+ }
}
/*
@@ -239,18 +238,14 @@ abstract class ELNode {
*/
public static class Visitor {
- public void visit(Root n) throws JasperException {
- n.getExpression().visit(this);
- }
+ public void visit(Root n) throws JasperException {
+ n.getExpression().visit(this);
+ }
- public void visit(Function n) throws JasperException {
- }
+ public void visit(Function n) throws JasperException {}
- public void visit(Text n) throws JasperException {
- }
+ public void visit(Text n) throws JasperException {}
- public void visit(ELText n) throws JasperException {
- }
+ public void visit(ELText n) throws JasperException {}
}
}
-
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELParser.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELParser.java
index dc8ef61..f5d2007 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELParser.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELParser.java
@@ -1,33 +1,33 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
/**
* This class implements a parser for EL expressions.
- *
+ *
* It takes strings of the form xxx${..}yyy${..}zzz etc, and turn it into a
* ELNode.Nodes.
- *
+ *
* Currently, it only handles text outside ${..} and functions in ${ ..}.
- *
+ *
* @author Kin-man Chung
*/
-
public class ELParser {
private Token curToken; // current token
@@ -39,14 +39,29 @@ public class ELParser {
private int index; // Current index of the expression
private String expression; // The EL expression
-
+
private char type;
private boolean escapeBS; // is '\' an escape char in text outside EL?
- private static final String reservedWords[] = { "and", "div", "empty",
- "eq", "false", "ge", "gt", "instanceof", "le", "lt", "mod", "ne",
- "not", "null", "or", "true" };
+ private static final String reservedWords[] = {
+ "and",
+ "div",
+ "empty",
+ "eq",
+ "false",
+ "ge",
+ "gt",
+ "instanceof",
+ "le",
+ "lt",
+ "mod",
+ "ne",
+ "not",
+ "null",
+ "or",
+ "true"
+ };
public ELParser(String expression) {
index = 0;
@@ -56,7 +71,7 @@ public class ELParser {
/**
* Parse an EL expression
- *
+ *
* @param expression
* The input expression string of the form Char* ('${' Char*
* '}')* Char*
@@ -79,7 +94,7 @@ public class ELParser {
/**
* Parse an EL expression string '${...}'
- *
+ *
* @return An ELNode.Nodes representing the EL expression TODO: Currently
* only parsed into functions and text strings. This should be
* rewritten for a full parser.
@@ -171,7 +186,7 @@ public class ELParser {
/**
* Skip until an EL expression ('${' || '#{') is reached, allowing escape
* sequences '\\' and '\$' and '\#'.
- *
+ *
* @return The text string up to the EL expression
*/
private String skipUntilEL() {
@@ -183,8 +198,7 @@ public class ELParser {
prev = 0;
if (ch == '\\') {
buf.append('\\');
- if (!escapeBS)
- prev = '\\';
+ if (!escapeBS) prev = '\\';
} else if (ch == '$' || ch == '#') {
buf.append(ch);
}
@@ -229,8 +243,7 @@ public class ELParser {
if (Character.isJavaIdentifierStart(ch)) {
StringBuffer buf = new StringBuffer();
buf.append(ch);
- while ((ch = peekChar()) != -1
- && Character.isJavaIdentifierPart(ch)) {
+ while ((ch = peekChar()) != -1 && Character.isJavaIdentifierPart(ch)) {
buf.append(ch);
nextChar();
}
@@ -279,8 +292,7 @@ public class ELParser {
private void skipSpaces() {
while (hasNextChar()) {
- if (expression.charAt(index) > ' ')
- break;
+ if (expression.charAt(index) > ' ') break;
index++;
}
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorDispatcher.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorDispatcher.java
index 8da21d1..a70b03c 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorDispatcher.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorDispatcher.java
@@ -1,18 +1,20 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.scripting.jsp.jasper.compiler;
@@ -32,9 +34,9 @@ import org.xml.sax.SAXException;
*
* This class is also responsible for localizing any error codes before they
* are passed on to the configured error handler.
- *
+ *
* In the case of a Java compilation error, the compiler error message is
- * parsed into an array of JavacErrorDetail instances, which is passed on to
+ * parsed into an array of JavacErrorDetail instances, which is passed on to
* the configured error handler.
*
* @author Jan Luehe
@@ -48,7 +50,6 @@ public class ErrorDispatcher {
// Indicates whether the compilation was initiated by JspServlet or JspC
private boolean jspcMode = false;
-
/*
* Constructor.
*
@@ -56,8 +57,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 +72,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 +86,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 +100,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 +114,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);
}
/*
@@ -127,9 +128,8 @@ public class ErrorDispatcher {
* @param errCode Error code
* @param arg Argument for parametric replacement
*/
- public void jspError(Mark where, String errCode, String arg)
- throws JasperException {
- dispatch(where, errCode, new Object[] {arg}, null);
+ public void jspError(Mark where, String errCode, String arg) throws JasperException {
+ dispatch(where, errCode, new Object[] {arg}, null);
}
/*
@@ -143,9 +143,8 @@ public class ErrorDispatcher {
* @param errCode Error code
* @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);
+ public void jspError(Node n, String errCode, String arg) throws JasperException {
+ dispatch(n.getStart(), errCode, new Object[] {arg}, null);
}
/*
@@ -159,9 +158,8 @@ public class ErrorDispatcher {
* @param arg1 First argument for parametric replacement
* @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);
+ public void jspError(String errCode, String arg1, String arg2) throws JasperException {
+ dispatch(null, errCode, new Object[] {arg1, arg2}, null);
}
/*
@@ -176,9 +174,8 @@ public class ErrorDispatcher {
* @param arg2 Second argument for parametric replacement
* @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);
+ public void jspError(String errCode, String arg1, String arg2, String arg3) throws JasperException {
+ dispatch(null, errCode, new Object[] {arg1, arg2, arg3}, null);
}
/*
@@ -193,9 +190,8 @@ public class ErrorDispatcher {
* @param arg1 First argument for parametric replacement
* @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);
+ public void jspError(Mark where, String errCode, String arg1, String arg2) throws JasperException {
+ dispatch(where, errCode, new Object[] {arg1, arg2}, null);
}
/*
@@ -212,9 +208,7 @@ public class ErrorDispatcher {
* @param arg3 Third argument for parametric replacement
*/
- public void jspError(Mark where, String errCode, String arg1, String arg2,
- String arg3)
- throws JasperException {
+ public void jspError(Mark where, String errCode, String arg1, String arg2, String arg3) throws JasperException {
dispatch(where, errCode, new Object[] {arg1, arg2, arg3}, null);
}
@@ -231,9 +225,8 @@ public class ErrorDispatcher {
* @param arg2 Second argument for parametric replacement
*/
- public void jspError(Node n, String errCode, String arg1, String arg2)
- throws JasperException {
- dispatch(n.getStart(), errCode, new Object[] {arg1, arg2}, null);
+ public void jspError(Node n, String errCode, String arg1, String arg2) throws JasperException {
+ dispatch(n.getStart(), errCode, new Object[] {arg1, arg2}, null);
}
/*
@@ -250,10 +243,8 @@ public class ErrorDispatcher {
* @param arg3 Third argument for parametric replacement
*/
- 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);
+ 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);
}
/*
@@ -262,7 +253,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);
}
/*
@@ -276,9 +267,8 @@ public class ErrorDispatcher {
* @param arg Argument for parametric replacement
* @param e Parsing exception
*/
- public void jspError(String errCode, String arg, Exception e)
- throws JasperException {
- dispatch(null, errCode, new Object[] {arg}, e);
+ public void jspError(String errCode, String arg, Exception e) throws JasperException {
+ dispatch(null, errCode, new Object[] {arg}, e);
}
/*
@@ -293,9 +283,8 @@ public class ErrorDispatcher {
* @param arg Argument for parametric replacement
* @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);
+ public void jspError(Node n, String errCode, String arg, Exception e) throws JasperException {
+ dispatch(n.getStart(), errCode, new Object[] {arg}, e);
}
/**
@@ -310,12 +299,10 @@ public class ErrorDispatcher {
* @return Array of javac compilation errors, or null if the given error
* message does not contain any compilation error line numbers
*/
- public static JavacErrorDetail[] parseJavacErrors(String errMsg,
- String fname,
- Node.Nodes page)
+ public static JavacErrorDetail[] parseJavacErrors(String errMsg, String fname, Node.Nodes page)
throws JasperException, IOException {
- return parseJavacMessage(errMsg, fname, page);
+ return parseJavacMessage(errMsg, fname, page);
}
/*
@@ -324,13 +311,11 @@ public class ErrorDispatcher {
*
* @param javacErrors Array of javac compilation errors
*/
- public void javacError(JavacErrorDetail[] javacErrors)
- throws JasperException {
+ public void javacError(JavacErrorDetail[] javacErrors) throws JasperException {
errHandler.javacError(javacErrors);
}
-
/*
* Dispatches the given compilation error report and exception to the
* configured error handler.
@@ -338,14 +323,12 @@ public class ErrorDispatcher {
* @param errorReport Compilation error report
* @param e Compilation exception
*/
- public void javacError(String errorReport, Exception e)
- throws JasperException {
+ public void javacError(String errorReport, Exception e) throws JasperException {
errHandler.javacError(errorReport, e);
}
-
- //*********************************************************************
+ // *********************************************************************
// Private utility methods
/*
@@ -360,24 +343,23 @@ public class ErrorDispatcher {
* @param args Arguments for parametric replacement
* @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();
- }
-
- // Get error location
- if (where != null) {
+ 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();
+ }
+
+ // Get error location
+ if (where != null) {
if (jspcMode) {
// Get the full URL of the resource that caused the error
try {
@@ -391,23 +373,22 @@ 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);
+ }
}
/*
@@ -426,17 +407,16 @@ public class ErrorDispatcher {
* @return Array of JavacErrorDetail instances corresponding to the
* compilation errors
*/
- private static JavacErrorDetail[] parseJavacMessage(
- String errMsg, String fname, Node.Nodes page)
- throws IOException, JasperException {
+ private static JavacErrorDetail[] parseJavacMessage(String errMsg, String fname, Node.Nodes page)
+ throws IOException, JasperException {
ArrayList<JavacErrorDetail> errors = new ArrayList<JavacErrorDetail>();
StringBuffer errMsgBuf = null;
int lineNum = -1;
JavacErrorDetail javacError = null;
-
+
BufferedReader reader = new BufferedReader(new StringReader(errMsg));
-
+
/*
* Parse compilation errors. Each compilation error consists of a file
* path and error line number, followed by a number of lines describing
@@ -444,56 +424,55 @@ public class ErrorDispatcher {
*/
String line = null;
while ((line = reader.readLine()) != null) {
-
+
/*
* Error line number is delimited by set of colons.
* Ignore colon following drive letter on Windows (fromIndex = 2).
* XXX Handle deprecation warnings that don't have line info
*/
- int beginColon = line.indexOf(':', 2);
+ int beginColon = line.indexOf(':', 2);
int endColon = line.indexOf(':', beginColon + 1);
if ((beginColon >= 0) && (endColon >= 0)) {
if (javacError != null) {
// add previous error to error vector
errors.add(javacError);
}
-
+
String lineNumStr = line.substring(beginColon + 1, endColon);
try {
lineNum = Integer.parseInt(lineNumStr);
} catch (NumberFormatException e) {
lineNum = -1;
}
-
+
errMsgBuf = new StringBuffer();
-
+
javacError = createJavacError(fname, page, errMsgBuf, lineNum);
}
-
+
// Ignore messages preceding first error
if (errMsgBuf != null) {
errMsgBuf.append(line);
errMsgBuf.append("\n");
}
}
-
+
// Add last error to error vector
if (javacError != null) {
errors.add(javacError);
- }
-
+ }
+
reader.close();
-
+
JavacErrorDetail[] errDetails = null;
if (errors.size() > 0) {
errDetails = new JavacErrorDetail[errors.size()];
errors.toArray(errDetails);
}
-
+
return errDetails;
}
-
/**
* @param fname
* @param page
@@ -502,13 +481,11 @@ public class ErrorDispatcher {
* @return JavacErrorDetail The error details
* @throws JasperException
*/
- public static JavacErrorDetail createJavacError(String fname,
- Node.Nodes page, StringBuffer errMsgBuf, int lineNum)
- throws JasperException {
+ public static JavacErrorDetail createJavacError(String fname, Node.Nodes page, StringBuffer errMsgBuf, int lineNum)
+ throws JasperException {
return createJavacError(fname, page, errMsgBuf, lineNum, null);
}
-
-
+
/**
* @param fname
* @param page
@@ -518,11 +495,11 @@ public class ErrorDispatcher {
* @return JavacErrorDetail The error details
* @throws JasperException
*/
- public static JavacErrorDetail createJavacError(String fname,
- Node.Nodes page, StringBuffer errMsgBuf, int lineNum,
- JspCompilationContext ctxt) throws JasperException {
+ public static JavacErrorDetail createJavacError(
+ String fname, Node.Nodes page, StringBuffer errMsgBuf, int lineNum, JspCompilationContext ctxt)
+ throws JasperException {
JavacErrorDetail javacError = null;
-
+
if (page != null) {
// Attempt to map javac error line number to line in JSP page
ErrorVisitor errVisitor = new ErrorVisitor(lineNum);
@@ -538,11 +515,11 @@ public class ErrorDispatcher {
ctxt);
}
}
-
+
if (javacError == null) {
/*
* javac error line number cannot be mapped to JSP page
- * line number. For example, this is the case if a
+ * line number. For example, this is the case if a
* scriptlet is missing a closing brace, which causes
* havoc with the try-catch-finally block that the code
* generator places around all generated code: As a result
@@ -553,55 +530,50 @@ public class ErrorDispatcher {
* JSP page.
* Include just the javac error info in the error detail.
*/
- javacError = new JavacErrorDetail(
- fname,
- lineNum,
- errMsgBuf);
+ javacError = new JavacErrorDetail(fname, lineNum, errMsgBuf);
}
return javacError;
}
-
/*
* Visitor responsible for mapping a line number in the generated servlet
* source code to the corresponding JSP node.
*/
static class ErrorVisitor extends Node.Visitor {
- // 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;
- }
-
- public void doVisit(Node n) throws JasperException {
- if ((lineNum >= n.getBeginJavaLine())
- && (lineNum < n.getEndJavaLine())) {
- found = n;
- }
+ // 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;
}
- /*
- * 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;
- }
+ 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;
+ }
}
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorHandler.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorHandler.java
index def2467..e2ae090 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorHandler.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorHandler.java
@@ -1,27 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
import org.apache.sling.scripting.jsp.jasper.JasperException;
/**
* Interface for handling JSP parse and javac compilation errors.
- *
+ *
* An implementation of this interface may be registered with the
* ErrorDispatcher by setting the XXX initialization parameter in the JSP
* page compiler and execution servlet in Catalina's web.xml file to the
@@ -41,8 +42,7 @@ public interface ErrorHandler {
* @param msg Parse error message
* @param exception Parse exception
*/
- public void jspError(String fname, int line, int column, String msg,
- Exception exception) throws JasperException;
+ public void jspError(String fname, int line, int column, String msg, Exception exception) throws JasperException;
/**
* Processes the given JSP parse error.
@@ -50,8 +50,7 @@ public interface ErrorHandler {
* @param msg Parse error message
* @param exception Parse exception
*/
- public void jspError(String msg, Exception exception)
- throws JasperException;
+ public void jspError(String msg, Exception exception) throws JasperException;
/**
* Processes the given javac compilation errors.
@@ -59,8 +58,7 @@ public interface ErrorHandler {
* @param details Array of JavacErrorDetail instances corresponding to the
* compilation errors
*/
- public void javacError(JavacErrorDetail[] details)
- throws JasperException;
+ public void javacError(JavacErrorDetail[] details) throws JasperException;
/**
* Processes the given javac error report and exception.
@@ -68,6 +66,5 @@ public interface ErrorHandler {
* @param errorReport Compilation error report
* @param exception Compilation exception
*/
- public void javacError(String errorReport, Exception exception)
- throws JasperException;
+ public void javacError(String errorReport, Exception exception) throws JasperException;
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java
index 08ddf32..21ff736 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java
@@ -1,22 +1,30 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.servlet.jsp.tagext.TagAttributeInfo;
+import javax.servlet.jsp.tagext.TagInfo;
+import javax.servlet.jsp.tagext.TagVariableInfo;
+import javax.servlet.jsp.tagext.VariableInfo;
+
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
@@ -33,13 +41,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Vector;
-import javax.el.MethodExpression;
-import javax.el.ValueExpression;
-import javax.servlet.jsp.tagext.TagAttributeInfo;
-import javax.servlet.jsp.tagext.TagInfo;
-import javax.servlet.jsp.tagext.TagVariableInfo;
-import javax.servlet.jsp.tagext.VariableInfo;
-
import org.apache.sling.commons.compiler.source.JavaEscapeHelper;
import org.apache.sling.scripting.jsp.jasper.Constants;
import org.apache.sling.scripting.jsp.jasper.JasperException;
@@ -67,15 +68,15 @@ import org.xml.sax.Attributes;
* @author Jacob Hookom
* @author Remy Maucherat
*/
-
class Generator {
- private static final Class[] OBJECT_CLASS = { Object.class };
+ private static final Class[] OBJECT_CLASS = {Object.class};
- private static final String VAR_EXPRESSIONFACTORY =
- System.getProperty("org.apache.sling.scripting.jsp.jasper.compiler.Generator.VAR_EXPRESSIONFACTORY", "_el_expressionfactory");
- private static final String VAR_ANNOTATIONPROCESSOR =
- System.getProperty("org.apache.sling.scripting.jsp.jasper.compiler.Generator.VAR_ANNOTATIONPROCESSOR", "_jsp_annotationprocessor");
+ private static final String VAR_EXPRESSIONFACTORY = System.getProperty(
+ "org.apache.sling.scripting.jsp.jasper.compiler.Generator.VAR_EXPRESSIONFACTORY", "_el_expressionfactory");
+ private static final String VAR_ANNOTATIONPROCESSOR = System.getProperty(
+ "org.apache.sling.scripting.jsp.jasper.compiler.Generator.VAR_ANNOTATIONPROCESSOR",
+ "_jsp_annotationprocessor");
private ServletWriter out;
@@ -251,8 +252,7 @@ class Generator {
/**
* Compiles list of tag handler pool names.
*/
- private void compileTagHandlerPoolList(Node.Nodes page)
- throws JasperException {
+ private void compileTagHandlerPoolList(Node.Nodes page) throws JasperException {
class TagHandlerPoolVisitor extends Node.Visitor {
@@ -276,9 +276,8 @@ class Generator {
public void visit(Node.CustomTag n) throws JasperException {
if (!n.implementsSimpleTag()) {
- String name = createTagHandlerPoolName(n.getPrefix(), n
- .getLocalName(), n.getAttributes(), n
- .hasEmptyBody());
+ String name = createTagHandlerPoolName(
+ n.getPrefix(), n.getLocalName(), n.getAttributes(), n.hasEmptyBody());
n.setTagHandlerPoolName(name);
if (!names.contains(name)) {
names.add(name);
@@ -293,8 +292,8 @@ class Generator {
*
* @return The name of the tag handler pool
*/
- private String createTagHandlerPoolName(String prefix,
- String shortName, Attributes attrs, boolean hasEmptyBody) {
+ private String createTagHandlerPoolName(
+ String prefix, String shortName, Attributes attrs, boolean hasEmptyBody) {
String poolName = null;
poolName = "_jspx_tagPool_" + prefix + "_" + shortName;
@@ -318,8 +317,7 @@ class Generator {
page.visit(new TagHandlerPoolVisitor(tagHandlerPoolNames));
}
- private void declareTemporaryScriptingVars(Node.Nodes page)
- throws JasperException {
+ private void declareTemporaryScriptingVars(Node.Nodes page) throws JasperException {
class ScriptingVarVisitor extends Node.Visitor {
@@ -339,8 +337,7 @@ class Generator {
if (varInfos.length > 0) {
for (int i = 0; i < varInfos.length; i++) {
String varName = varInfos[i].getVarName();
- String tmpVarName = "_jspx_" + varName + "_"
- + n.getCustomNestingLevel();
+ String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel();
if (!vars.contains(tmpVarName)) {
vars.add(tmpVarName);
out.printin(varInfos[i].getClassName());
@@ -355,14 +352,12 @@ class Generator {
for (int i = 0; i < tagVarInfos.length; i++) {
String varName = tagVarInfos[i].getNameGiven();
if (varName == null) {
- varName = n.getTagData().getAttributeString(
- tagVarInfos[i].getNameFromAttribute());
+ varName = n.getTagData().getAttributeString(tagVarInfos[i].getNameFromAttribute());
} else if (tagVarInfos[i].getNameFromAttribute() != null) {
// alias
continue;
}
- String tmpVarName = "_jspx_" + varName + "_"
- + n.getCustomNestingLevel();
+ String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel();
if (!vars.contains(tmpVarName)) {
vars.add(tmpVarName);
out.printin(tagVarInfos[i].getClassName());
@@ -428,7 +423,8 @@ class Generator {
} else {
out.print("getServletConfig()");
}
- out.println(".getServletContext().getAttribute(org.apache.sling.scripting.jsp.jasper.runtime.AnnotationProcessor.class.getName());");
+ out.println(
+ ".getServletContext().getAttribute(org.apache.sling.scripting.jsp.jasper.runtime.AnnotationProcessor.class.getName());");
out.popIndent();
out.printil("}");
@@ -446,8 +442,8 @@ class Generator {
if (isPoolingEnabled) {
for (int i = 0; i < tagHandlerPoolNames.size(); i++) {
- out.printin(tagHandlerPoolNames.elementAt(i));
- out.println(".release();");
+ out.printin(tagHandlerPoolNames.elementAt(i));
+ out.println(".release();");
}
}
@@ -520,8 +516,7 @@ class Generator {
*
* In JSP 2.1, we also scope an instance of ExpressionFactory
*/
- private void genPreambleClassVariableDeclarations(String className)
- throws JasperException {
+ private void genPreambleClassVariableDeclarations(String className) throws JasperException {
if (isPoolingEnabled && !tagHandlerPoolNames.isEmpty()) {
for (int i = 0; i < tagHandlerPoolNames.size(); i++) {
out.printil("private org.apache.sling.scripting.jsp.jasper.runtime.TagHandlerPool "
@@ -615,10 +610,11 @@ class Generator {
}
if (pageInfo.isErrorPage()) {
- out.printil("Throwable exception = org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.getThrowable(request);");
+ out.printil(
+ "Throwable exception = org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.getThrowable(request);");
// Removed the following block because of SLING-2094
// If we leave it in, an error handler will always set the status code to 500!
- /* out.printil("if (exception != null) {");
+ /* out.printil("if (exception != null) {");
out.pushIndent();
out.printil("response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);");
out.popIndent();
@@ -648,8 +644,7 @@ class Generator {
out.printil("response.addHeader(\"X-Powered-By\", \"JSP/2.1\");");
}
- out
- .printil("pageContext = _jspxFactory.getPageContext(this, request, response,");
+ out.printil("pageContext = _jspxFactory.getPageContext(this, request, response,");
out.printin("\t\t\t");
out.print(quote(pageInfo.getErrorPage()));
out.print(", " + pageInfo.isSession());
@@ -682,12 +677,13 @@ class Generator {
*/
String omitXmlDecl = pageInfo.getOmitXmlDecl();
if ((omitXmlDecl != null && !JspUtil.booleanValue(omitXmlDecl))
- || (omitXmlDecl == null && page.getRoot().isXmlSyntax()
- && !pageInfo.hasJspRoot() && !ctxt.isTagFile())) {
+ || (omitXmlDecl == null
+ && page.getRoot().isXmlSyntax()
+ && !pageInfo.hasJspRoot()
+ && !ctxt.isTagFile())) {
String cType = pageInfo.getContentType();
String charSet = cType.substring(cType.indexOf("charset=") + 8);
- out.printil("out.write(\"<?xml version=\\\"1.0\\\" encoding=\\\""
- + charSet + "\\\"?>\\n\");");
+ out.printil("out.write(\"<?xml version=\\\"1.0\\\" encoding=\\\"" + charSet + "\\\"?>\\n\");");
}
/*
@@ -772,9 +768,12 @@ class Generator {
/**
* Constructor.
*/
- public GenerateVisitor(boolean isTagFile, ServletWriter out,
+ public GenerateVisitor(
+ boolean isTagFile,
+ ServletWriter out,
ArrayList methodsBuffered,
- FragmentHelperClass fragmentHelperClass, ClassLoader loader,
+ FragmentHelperClass fragmentHelperClass,
+ ClassLoader loader,
TagInfo tagInfo) {
this.isTagFile = isTagFile;
@@ -805,8 +804,7 @@ class Generator {
* the expected type for an EL evaluation (ignored for
* attributes that aren't EL expressions)
*/
- private String attributeValue(Node.JspAttribute attr, boolean encode,
- Class expectedType) {
+ private String attributeValue(Node.JspAttribute attr, boolean encode, Class expectedType) {
String v = attr.getValue();
if (!attr.isNamedAttribute() && (v == null)) {
return "";
@@ -820,23 +818,23 @@ class Generator {
return v;
} else if (attr.isELInterpreterInput()) {
boolean replaceESC = v.indexOf(Constants.ESC) > 0;
- v = JspUtil.interpreterCall(this.isTagFile, v, expectedType,
- attr.getEL().getMapName(), false);
+ v = JspUtil.interpreterCall(
+ this.isTagFile, v, expectedType, attr.getEL().getMapName(), false);
// XXX ESC replacement hack
if (replaceESC) {
v = "(" + v + ").replace(" + Constants.ESCStr + ", '$')";
}
if (encode) {
- return "org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.URLEncode("
- + v + ", request.getCharacterEncoding())";
+ return "org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.URLEncode(" + v
+ + ", request.getCharacterEncoding())";
}
return v;
} else if (attr.isNamedAttribute()) {
return attr.getNamedAttributeNode().getTemporaryVariableName();
} else {
if (encode) {
- return "org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.URLEncode("
- + quote(v) + ", request.getCharacterEncoding())";
+ return "org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.URLEncode(" + quote(v)
+ + ", request.getCharacterEncoding())";
}
return quote(v);
}
@@ -849,8 +847,7 @@ class Generator {
* @param n
* the parent node for the param action nodes.
*/
- private void printParams(Node n, String pageParam, boolean literal)
- throws JasperException {
+ private void printParams(Node n, String pageParam, boolean literal) throws JasperException {
class ParamVisitor extends Node.Visitor {
String separator;
@@ -909,12 +906,15 @@ class Generator {
n.setBeginJavaLine(out.getJavaLine());
if (!pageInfo.isELIgnored() && (n.getEL() != null)) {
out.printil("out.write("
- + JspUtil.interpreterCall(this.isTagFile, n.getType() + "{"
- + new String(n.getText()) + "}", String.class,
- n.getEL().getMapName(), false) + ");");
+ + JspUtil.interpreterCall(
+ this.isTagFile,
+ n.getType() + "{" + new String(n.getText()) + "}",
+ String.class,
+ n.getEL().getMapName(),
+ false)
+ + ");");
} else {
- out.printil("out.write("
- + quote(n.getType() + "{" + new String(n.getText()) + "}") + ");");
+ out.printil("out.write(" + quote(n.getType() + "{" + new String(n.getText()) + "}") + ");");
}
n.setEndJavaLine(out.getJavaLine());
}
@@ -937,8 +937,7 @@ class Generator {
// If the page for jsp:include was specified via
// jsp:attribute, first generate code to evaluate
// that body.
- pageParam = generateNamedAttributeValue(page
- .getNamedAttributeNode());
+ pageParam = generateNamedAttributeValue(page.getNamedAttributeNode());
} else {
pageParam = attributeValue(page, false, String.class);
}
@@ -952,9 +951,8 @@ class Generator {
prepareParams(n);
}
- out
- .printin("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.include(request, response, "
- + pageParam);
+ out.printin("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.include(request, response, "
+ + pageParam);
printParams(n, pageParam, page.isLiteral());
out.println(", out, " + isFlush + ");");
@@ -980,8 +978,7 @@ class Generator {
Node n = subelements.getNode(i);
if (n instanceof Node.ParamAction) {
Node.Nodes paramSubElements = n.getBody();
- for (int j = 0; (paramSubElements != null)
- && (j < paramSubElements.size()); j++) {
+ for (int j = 0; (paramSubElements != null) && (j < paramSubElements.size()); j++) {
Node m = paramSubElements.getNode(j);
if (m instanceof Node.NamedAttribute) {
generateNamedAttributeValue((Node.NamedAttribute) m);
@@ -1025,8 +1022,7 @@ class Generator {
// If the page for jsp:forward was specified via
// jsp:attribute, first generate code to evaluate
// that body.
- pageParam = generateNamedAttributeValue(page
- .getNamedAttributeNode());
+ pageParam = generateNamedAttributeValue(page.getNamedAttributeNode());
} else {
pageParam = attributeValue(page, false, String.class);
}
@@ -1067,28 +1063,25 @@ class Generator {
// Bean is defined using useBean, introspect at compile time
Class bean = beanInfo.getBeanType(name);
String beanName = JspUtil.getCanonicalName(bean);
- java.lang.reflect.Method meth = JspRuntimeLibrary
- .getReadMethod(bean, property);
+ java.lang.reflect.Method meth = JspRuntimeLibrary.getReadMethod(bean, property);
String methodName = meth.getName();
- out
- .printil("out.write(org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.toString("
- + "((("
- + beanName
- + ")_jspx_page_context.findAttribute("
- + "\""
- + name + "\"))." + methodName + "())));");
+ out.printil("out.write(org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.toString("
+ + "((("
+ + beanName
+ + ")_jspx_page_context.findAttribute("
+ + "\""
+ + name + "\"))." + methodName + "())));");
} else {
// The object could be a custom action with an associated
// VariableInfo entry for this name.
// Get the class name and then introspect at runtime.
- out
- .printil("out.write(org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.toString"
- + "(org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.handleGetProperty"
- + "(_jspx_page_context.getAttribute(\""
- + name
- + "\", PageContext.PAGE_SCOPE), \""
- + property
- + "\")));");
+ out.printil("out.write(org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.toString"
+ + "(org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.handleGetProperty"
+ + "(_jspx_page_context.getAttribute(\""
+ + name
+ + "\", PageContext.PAGE_SCOPE), \""
+ + property
+ + "\")));");
}
n.setEndJavaLine(out.getJavaLine());
@@ -1104,33 +1097,30 @@ class Generator {
n.setBeginJavaLine(out.getJavaLine());
if ("*".equals(property)) {
- out
- .printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.introspect("
- + "_jspx_page_context.findAttribute("
- + "\""
- + name + "\"), request);");
+ out.printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.introspect("
+ + "_jspx_page_context.findAttribute("
+ + "\""
+ + name + "\"), request);");
} else if (value == null) {
if (param == null) {
param = property; // default to same as property
}
- out
- .printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.introspecthelper("
- + "_jspx_page_context.findAttribute(\""
- + name
- + "\"), \""
- + property
- + "\", request.getParameter(\""
- + param
- + "\"), "
- + "request, \""
- + param
- + "\", false);");
+ out.printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.introspecthelper("
+ + "_jspx_page_context.findAttribute(\""
+ + name
+ + "\"), \""
+ + property
+ + "\", request.getParameter(\""
+ + param
+ + "\"), "
+ + "request, \""
+ + param
+ + "\", false);");
} else if (value.isExpression()) {
- out
- .printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.handleSetProperty("
- + "_jspx_page_context.findAttribute(\""
- + name
- + "\"), \"" + property + "\",");
+ out.printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.handleSetProperty("
+ + "_jspx_page_context.findAttribute(\""
+ + name
+ + "\"), \"" + property + "\",");
out.print(attributeValue(value, false, null));
out.println(");");
} else if (value.isELInterpreterInput()) {
@@ -1147,8 +1137,8 @@ class Generator {
// - 'pageContext' is a VariableResolver.
// - 'this' (either the generated Servlet or the generated tag
// handler for Tag files) is a FunctionMapper.
- out
- .printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.handleSetPropertyExpression("
+ out.printil(
+ "org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.handleSetPropertyExpression("
+ "_jspx_page_context.findAttribute(\""
+ name
+ "\"), \""
@@ -1162,23 +1152,20 @@ class Generator {
// If the value for setProperty was specified via
// jsp:attribute, first generate code to evaluate
// that body.
- String valueVarName = generateNamedAttributeValue(value
- .getNamedAttributeNode());
- out
- .printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.introspecthelper("
- + "_jspx_page_context.findAttribute(\""
- + name
- + "\"), \""
- + property
- + "\", "
- + valueVarName
- + ", null, null, false);");
+ String valueVarName = generateNamedAttributeValue(value.getNamedAttributeNode());
+ out.printil("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.introspecthelper("
+ + "_jspx_page_context.findAttribute(\""
+ + name
+ + "\"), \""
+ + property
+ + "\", "
+ + valueVarName
+ + ", null, null, false);");
} else {
- out
- .printin("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.introspecthelper("
- + "_jspx_page_context.findAttribute(\""
- + name
- + "\"), \"" + property + "\", ");
+ out.printin("org.apache.sling.scripting.jsp.jasper.runtime.JspRuntimeLibrary.introspecthelper("
+ + "_jspx_page_context.findAttribute(\""
+ + name
+ + "\"), \"" + property + "\", ");
out.print(attributeValue(value, false, null));
out.println(", null, null, false);");
}
@@ -1223,8 +1210,7 @@ class Generator {
// Cannot instantiate the specified class, either a
// compilation error or a runtime error will be raised,
// depending on a compiler flag.
- if (ctxt.getOptions()
- .getErrorOnUseBeanInvalidClassAttribute()) {
+ if (ctxt.getOptions().getErrorOnUseBeanInvalidClassAttribute()) {
err.jspError(n, "jsp.error.invalid.bean", klass);
}
if (canonicalName == null) {
@@ -1290,8 +1276,7 @@ class Generator {
* If both class name and beanName is not specified, the bean
* must be found locally, otherwise it's an error
*/
- out
- .printin("throw new java.lang.InstantiationException(\"bean ");
+ out.printin("throw new java.lang.InstantiationException(\"bean ");
out.print(name);
out.println(" not found within scope\");");
} else {
@@ -1305,11 +1290,9 @@ class Generator {
// If the value for beanName was specified via
// jsp:attribute, first generate code to evaluate
// that body.
- binaryName = generateNamedAttributeValue(beanName
- .getNamedAttributeNode());
+ binaryName = generateNamedAttributeValue(beanName.getNamedAttributeNode());
} else {
- binaryName = attributeValue(beanName, false,
- String.class);
+ binaryName = attributeValue(beanName, false, String.class);
}
} else {
// Implies klass is not null
@@ -1331,8 +1314,7 @@ class Generator {
*/
out.printil("} catch (ClassNotFoundException exc) {");
out.pushIndent();
- out
- .printil("throw new InstantiationException(exc.getMessage());");
+ out.printil("throw new InstantiationException(exc.getMessage());");
out.popIndent();
out.printil("} catch (Exception exc) {");
out.pushIndent();
@@ -1422,8 +1404,7 @@ class Generator {
out.printil("out.write( \"<param name=\\\""
+ escape(name)
+ "\\\" value=\\\"\" + "
- + attributeValue(n.getValue(), false,
- String.class) + " + \"\\\">\" );");
+ + attributeValue(n.getValue(), false, String.class) + " + \"\\\">\" );");
out.printil("out.write(\"\\n\");");
} else {
// We want something of the form
@@ -1431,8 +1412,7 @@ class Generator {
out.printil("out.write( \" "
+ escape(name)
+ "=\\\"\" + "
- + attributeValue(n.getValue(), false,
- String.class) + " + \"\\\"\" );");
+ + attributeValue(n.getValue(), false, String.class) + " + \"\\\"\" );");
}
n.setEndJavaLine(out.getJavaLine());
@@ -1456,8 +1436,7 @@ class Generator {
String widthStr = null;
if (width != null) {
if (width.isNamedAttribute()) {
- widthStr = generateNamedAttributeValue(width
- .getNamedAttributeNode());
+ widthStr = generateNamedAttributeValue(width.getNamedAttributeNode());
} else {
widthStr = attributeValue(width, false, String.class);
}
@@ -1466,8 +1445,7 @@ class Generator {
String heightStr = null;
if (height != null) {
if (height.isNamedAttribute()) {
- heightStr = generateNamedAttributeValue(height
- .getNamedAttributeNode());
+ heightStr = generateNamedAttributeValue(height.getNamedAttributeNode());
} else {
heightStr = attributeValue(height, false, String.class);
}
@@ -1505,9 +1483,7 @@ class Generator {
// IE style plugin
// <object ...>
// First compose the runtime output string
- String s0 = "<object"
- + makeAttr("classid", ctxt.getOptions().getIeClassId())
- + makeAttr("name", name);
+ String s0 = "<object" + makeAttr("classid", ctxt.getOptions().getIeClassId()) + makeAttr("name", name);
String s1 = "";
if (width != null) {
@@ -1519,13 +1495,14 @@ class Generator {
s2 = " + \" height=\\\"\" + " + heightStr + " + \"\\\"\"";
}
- String s3 = makeAttr("hspace", hspace) + makeAttr("vspace", vspace)
+ String s3 = makeAttr("hspace", hspace)
+ + makeAttr("vspace", vspace)
+ makeAttr("align", align)
- + makeAttr("codebase", iepluginurl) + '>';
+ + makeAttr("codebase", iepluginurl)
+ + '>';
// Then print the output string to the java file
- out.printil("out.write(" + quote(s0) + s1 + s2 + " + " + quote(s3)
- + ");");
+ out.printil("out.write(" + quote(s0) + s1 + s2 + " + " + quote(s3) + ");");
out.printil("out.write(\"\\n\");");
// <param > for java_code
@@ -1535,27 +1512,24 @@ class Generator {
// <param > for java_codebase
if (codebase != null) {
- s0 = "<param name=\"java_codebase\""
- + makeAttr("value", codebase) + '>';
+ s0 = "<param name=\"java_codebase\"" + makeAttr("value", codebase) + '>';
out.printil("out.write(" + quote(s0) + ");");
out.printil("out.write(\"\\n\");");
}
// <param > for java_archive
if (archive != null) {
- s0 = "<param name=\"java_archive\""
- + makeAttr("value", archive) + '>';
+ s0 = "<param name=\"java_archive\"" + makeAttr("value", archive) + '>';
out.printil("out.write(" + quote(s0) + ");");
out.printil("out.write(\"\\n\");");
}
// <param > for type
s0 = "<param name=\"type\""
- + makeAttr("value", "application/x-java-"
- + type
- + ";"
- + ((jreversion == null) ? "" : "version="
- + jreversion)) + '>';
+ + makeAttr(
+ "value",
+ "application/x-java-" + type + ";" + ((jreversion == null) ? "" : "version=" + jreversion))
+ + '>';
out.printil("out.write(" + quote(s0) + ");");
out.printil("out.write(\"\\n\");");
@@ -1572,22 +1546,21 @@ class Generator {
out.printil("out.write(" + quote("<comment>") + ");");
out.printil("out.write(\"\\n\");");
s0 = "<EMBED"
- + makeAttr("type", "application/x-java-"
- + type
- + ";"
- + ((jreversion == null) ? "" : "version="
- + jreversion)) + makeAttr("name", name);
+ + makeAttr(
+ "type",
+ "application/x-java-" + type + ";" + ((jreversion == null) ? "" : "version=" + jreversion))
+ + makeAttr("name", name);
// s1 and s2 are the same as before.
- s3 = makeAttr("hspace", hspace) + makeAttr("vspace", vspace)
+ s3 = makeAttr("hspace", hspace)
+ + makeAttr("vspace", vspace)
+ makeAttr("align", align)
+ makeAttr("pluginspage", nspluginurl)
+ makeAttr("java_code", code)
+ makeAttr("java_codebase", codebase)
+ makeAttr("java_archive", archive);
- out.printil("out.write(" + quote(s0) + s1 + s2 + " + " + quote(s3)
- + ");");
+ out.printil("out.write(" + quote(s0) + s1 + s2 + " + " + quote(s3) + ");");
/*
* Generate a 'attr = "value"' for each <jsp:param> in plugin body
@@ -1639,8 +1612,7 @@ class Generator {
TagHandlerInfo handlerInfo = getTagHandlerInfo(n);
// Create variable names
- String baseVar = createTagVarName(n.getQName(), n.getPrefix(), n
- .getLocalName());
+ String baseVar = createTagVarName(n.getQName(), n.getPrefix(), n.getLocalName());
String tagEvalVar = "_jspx_eval_" + baseVar;
String tagHandlerVar = "_jspx_th_" + baseVar;
String tagPushBodyCountVar = "_jspx_push_body_count_" + baseVar;
@@ -1682,8 +1654,7 @@ class Generator {
* there, hence they are set to null here to avoid double
* adjustments.
*/
- GenBuffer genBuffer = new GenBuffer(n,
- n.implementsSimpleTag() ? null : n.getBody());
+ GenBuffer genBuffer = new GenBuffer(n, n.implementsSimpleTag() ? null : n.getBody());
methodsBuffered.add(genBuffer);
out = genBuffer.getOut();
@@ -1710,8 +1681,7 @@ class Generator {
// Initilaize local variables used in this method.
if (!isTagFile) {
- out
- .printil("PageContext pageContext = _jspx_page_context;");
+ out.printil("PageContext pageContext = _jspx_page_context;");
}
out.printil("JspWriter out = _jspx_page_context.getOut();");
generateLocalVariables(out, n);
@@ -1724,8 +1694,7 @@ class Generator {
* Classic tag handler: Generate code for start element, body,
* and end element
*/
- generateCustomStart(n, handlerInfo, tagHandlerVar, tagEvalVar,
- tagPushBodyCountVar);
+ generateCustomStart(n, handlerInfo, tagHandlerVar, tagEvalVar, tagPushBodyCountVar);
// visit body
String tmpParent = parent;
@@ -1749,8 +1718,7 @@ class Generator {
}
isSimpleTagHandler = tmpIsSimpleTagHandler;
- generateCustomEnd(n, tagHandlerVar, tagEvalVar,
- tagPushBodyCountVar);
+ generateCustomEnd(n, tagHandlerVar, tagEvalVar, tagPushBodyCountVar);
}
if (ci.isScriptless() && !ci.hasScriptingVars()) {
@@ -1854,20 +1822,17 @@ class Generator {
for (int i = 0; attrs != null && i < attrs.length; i++) {
String attrStr = null;
if (attrs[i].isNamedAttribute()) {
- attrStr = generateNamedAttributeValue(attrs[i]
- .getNamedAttributeNode());
+ attrStr = generateNamedAttributeValue(attrs[i].getNamedAttributeNode());
} else {
attrStr = attributeValue(attrs[i], false, Object.class);
}
- String s = " + \" " + attrs[i].getName() + "=\\\"\" + "
- + attrStr + " + \"\\\"\"";
+ String s = " + \" " + attrs[i].getName() + "=\\\"\" + " + attrStr + " + \"\\\"\"";
map.put(attrs[i].getName(), s);
}
// Write begin tag, using XML-style 'name' attribute as the
// element name
- String elemName = attributeValue(n.getNameAttribute(), false,
- String.class);
+ String elemName = attributeValue(n.getNameAttribute(), false, String.class);
out.printin("out.write(\"<\"");
out.print(" + " + elemName);
@@ -1977,37 +1942,37 @@ class Generator {
char ch = text.charAt(i);
--count;
switch (ch) {
- case '"':
- sb.append('\\').append('\"');
- break;
- case '\\':
- sb.append('\\').append('\\');
- break;
- case '\r':
- sb.append('\\').append('r');
- break;
- case '\n':
- sb.append('\\').append('n');
- srcLine++;
-
- if (breakAtLF || count < 0) {
- // Generate an out.write() when see a '\n' in template
- sb.append("\");");
- out.println(sb.toString());
- if (i < text.length() - 1) {
- out.printin();
+ case '"':
+ sb.append('\\').append('\"');
+ break;
+ case '\\':
+ sb.append('\\').append('\\');
+ break;
+ case '\r':
+ sb.append('\\').append('r');
+ break;
+ case '\n':
+ sb.append('\\').append('n');
+ srcLine++;
+
+ if (breakAtLF || count < 0) {
+ // Generate an out.write() when see a '\n' in template
+ sb.append("\");");
+ out.println(sb.toString());
+ if (i < text.length() - 1) {
+ out.printin();
+ }
+ sb.setLength(initLength);
+ count = JspUtil.CHUNKSIZE;
}
- sb.setLength(initLength);
- count = JspUtil.CHUNKSIZE;
- }
- // add a Smap for this line
- n.addSmap(srcLine);
- break;
- case '\t': // Not sure we need this
- sb.append('\\').append('t');
- break;
- default:
- sb.append(ch);
+ // add a Smap for this line
+ n.addSmap(srcLine);
+ break;
+ case '\t': // Not sure we need this
+ sb.append('\\').append('t');
+ break;
+ default:
+ sb.append(ch);
}
}
@@ -2040,7 +2005,8 @@ class Generator {
// Copy virtual page scope of tag file to page scope of invoking
// page
- out.printil("((org.apache.sling.scripting.jsp.jasper.runtime.JspContextWrapper) this.jspContext).syncBeforeInvoke();");
+ out.printil(
+ "((org.apache.sling.scripting.jsp.jasper.runtime.JspContextWrapper) this.jspContext).syncBeforeInvoke();");
String varReaderAttr = n.getTextAttribute("varReader");
String varAttr = n.getTextAttribute("var");
if (varReaderAttr != null || varAttr != null) {
@@ -2090,7 +2056,8 @@ class Generator {
// Copy virtual page scope of tag file to page scope of invoking
// page
- out.printil("((org.apache.sling.scripting.jsp.jasper.runtime.JspContextWrapper) this.jspContext).syncBeforeInvoke();");
+ out.printil(
+ "((org.apache.sling.scripting.jsp.jasper.runtime.JspContextWrapper) this.jspContext).syncBeforeInvoke();");
// Invoke body
String varReaderAttr = n.getTextAttribute("varReader");
@@ -2111,8 +2078,7 @@ class Generator {
out.printin("_jspx_page_context.setAttribute(");
if (varReaderAttr != null) {
out.print(quote(varReaderAttr));
- out
- .print(", new java.io.StringReader(_jspx_sout.toString())");
+ out.print(", new java.io.StringReader(_jspx_sout.toString())");
} else {
out.print(quote(varAttr));
out.print(", _jspx_sout.toString()");
@@ -2136,23 +2102,19 @@ class Generator {
Node.JspAttribute[] attrs = tag.getJspAttributes();
for (int i = 0; attrs != null && i < attrs.length; i++) {
if (attrs[i].getName().equals(n.getName())) {
- out.print(evaluateAttribute(getTagHandlerInfo(tag),
- attrs[i], tag, null));
+ out.print(evaluateAttribute(getTagHandlerInfo(tag), attrs[i], tag, null));
break;
}
}
}
- private TagHandlerInfo getTagHandlerInfo(Node.CustomTag n)
- throws JasperException {
- Hashtable handlerInfosByShortName = (Hashtable) handlerInfos.get(n
- .getPrefix());
+ private TagHandlerInfo getTagHandlerInfo(Node.CustomTag n) throws JasperException {
+ Hashtable handlerInfosByShortName = (Hashtable) handlerInfos.get(n.getPrefix());
if (handlerInfosByShortName == null) {
handlerInfosByShortName = new Hashtable();
handlerInfos.put(n.getPrefix(), handlerInfosByShortName);
}
- TagHandlerInfo handlerInfo = (TagHandlerInfo) handlerInfosByShortName
- .get(n.getLocalName());
+ TagHandlerInfo handlerInfo = (TagHandlerInfo) handlerInfosByShortName.get(n.getLocalName());
if (handlerInfo == null) {
handlerInfo = new TagHandlerInfo(n, n.getTagHandlerClass(), err, n.getTagHandlerClassName());
handlerInfosByShortName.put(n.getLocalName(), handlerInfo);
@@ -2170,12 +2132,15 @@ class Generator {
}
}
- private void generateCustomStart(Node.CustomTag n,
- TagHandlerInfo handlerInfo, String tagHandlerVar,
- String tagEvalVar, String tagPushBodyCountVar)
+ private void generateCustomStart(
+ Node.CustomTag n,
+ TagHandlerInfo handlerInfo,
+ String tagHandlerVar,
+ String tagEvalVar,
+ String tagPushBodyCountVar)
throws JasperException {
-// Class tagHandlerClass = handlerInfo.getTagHandlerClass();
+ // Class tagHandlerClass = handlerInfo.getTagHandlerClass();
out.printin("// ");
out.println(n.getQName());
@@ -2251,8 +2216,7 @@ class Generator {
if (n.implementsBodyTag()) {
out.printin("if (");
out.print(tagEvalVar);
- out
- .println(" != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {");
+ out.println(" != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {");
// Assume EVAL_BODY_BUFFERED
out.pushIndent();
out.printil("out = _jspx_page_context.pushBody();");
@@ -2264,8 +2228,7 @@ class Generator {
out.println("[0]++;");
}
out.printin(tagHandlerVar);
- out
- .println(".setBodyContent((javax.servlet.jsp.tagext.BodyContent) out);");
+ out.println(".setBodyContent((javax.servlet.jsp.tagext.BodyContent) out);");
out.printin(tagHandlerVar);
out.println(".doInitBody();");
@@ -2291,8 +2254,8 @@ class Generator {
n.setEndJavaLine(out.getJavaLine());
}
- private void generateCustomEnd(Node.CustomTag n, String tagHandlerVar,
- String tagEvalVar, String tagPushBodyCountVar) {
+ private void generateCustomEnd(
+ Node.CustomTag n, String tagHandlerVar, String tagEvalVar, String tagPushBodyCountVar) {
if (!n.hasEmptyBody()) {
if (n.implementsIterationTag()) {
@@ -2304,8 +2267,7 @@ class Generator {
syncScriptingVars(n, VariableInfo.AT_BEGIN);
syncScriptingVars(n, VariableInfo.NESTED);
- out
- .printil("if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)");
+ out.printil("if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)");
out.pushIndent();
out.printil("break;");
out.popIndent();
@@ -2319,8 +2281,7 @@ class Generator {
if (n.implementsBodyTag()) {
out.printin("if (");
out.print(tagEvalVar);
- out
- .println(" != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {");
+ out.println(" != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {");
out.pushIndent();
out.printil("out = _jspx_page_context.popBody();");
if (n.implementsTryCatchFinally()) {
@@ -2340,8 +2301,7 @@ class Generator {
out.printin("if (");
out.print(tagHandlerVar);
- out
- .println(".doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {");
+ out.println(".doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {");
out.pushIndent();
if (!n.implementsTryCatchFinally()) {
if (isPoolingEnabled && !(n.implementsJspIdConsumer())) {
@@ -2419,11 +2379,10 @@ class Generator {
restoreScriptingVars(n, VariableInfo.AT_BEGIN);
}
- private void generateCustomDoTag(Node.CustomTag n,
- TagHandlerInfo handlerInfo, String tagHandlerVar)
+ private void generateCustomDoTag(Node.CustomTag n, TagHandlerInfo handlerInfo, String tagHandlerVar)
throws JasperException {
-// Class tagHandlerClass = handlerInfo.getTagHandlerClass();
+ // Class tagHandlerClass = handlerInfo.getTagHandlerClass();
n.setBeginJavaLine(out.getJavaLine());
out.printin("// ");
@@ -2529,8 +2488,7 @@ class Generator {
if (tagVarInfo.getDeclare()) {
String varName = tagVarInfo.getNameGiven();
if (varName == null) {
- varName = n.getTagData().getAttributeString(
- tagVarInfo.getNameFromAttribute());
+ varName = n.getTagData().getAttributeString(tagVarInfo.getNameFromAttribute());
} else if (tagVarInfo.getNameFromAttribute() != null) {
// alias
continue;
@@ -2576,8 +2534,7 @@ class Generator {
continue;
}
String varName = varInfos[i].getVarName();
- String tmpVarName = "_jspx_" + varName + "_"
- + n.getCustomNestingLevel();
+ String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel();
out.printin(tmpVarName);
out.print(" = ");
out.print(varName);
@@ -2595,14 +2552,12 @@ class Generator {
}
String varName = tagVarInfos[i].getNameGiven();
if (varName == null) {
- varName = n.getTagData().getAttributeString(
- tagVarInfos[i].getNameFromAttribute());
+ varName = n.getTagData().getAttributeString(tagVarInfos[i].getNameFromAttribute());
} else if (tagVarInfos[i].getNameFromAttribute() != null) {
// alias
continue;
}
- String tmpVarName = "_jspx_" + varName + "_"
- + n.getCustomNestingLevel();
+ String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel();
out.printin(tmpVarName);
out.print(" = ");
out.print(varName);
@@ -2640,8 +2595,7 @@ class Generator {
continue;
}
String varName = varInfos[i].getVarName();
- String tmpVarName = "_jspx_" + varName + "_"
- + n.getCustomNestingLevel();
+ String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel();
out.printin(varName);
out.print(" = ");
out.print(tmpVarName);
@@ -2659,14 +2613,12 @@ class Generator {
}
String varName = tagVarInfos[i].getNameGiven();
if (varName == null) {
- varName = n.getTagData().getAttributeString(
- tagVarInfos[i].getNameFromAttribute());
+ varName = n.getTagData().getAttributeString(tagVarInfos[i].getNameFromAttribute());
} else if (tagVarInfos[i].getNameFromAttribute() != null) {
// alias
continue;
}
- String tmpVarName = "_jspx_" + varName + "_"
- + n.getCustomNestingLevel();
+ String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel();
out.printin(varName);
out.print(" = ");
out.print(tmpVarName);
@@ -2703,8 +2655,7 @@ class Generator {
if (tagVarInfos[i].getScope() == scope) {
String name = tagVarInfos[i].getNameGiven();
if (name == null) {
- name = n.getTagData().getAttributeString(
- tagVarInfos[i].getNameFromAttribute());
+ name = n.getTagData().getAttributeString(tagVarInfos[i].getNameFromAttribute());
} else if (tagVarInfos[i].getNameFromAttribute() != null) {
// alias
continue;
@@ -2737,8 +2688,7 @@ class Generator {
* shortName and endcoded to make the resultant string a valid Java
* Identifier.
*/
- private String createTagVarName(String fullName, String prefix,
- String shortName) {
+ private String createTagVarName(String fullName, String prefix, String shortName) {
String varName;
synchronized (tagVarNumbers) {
@@ -2755,8 +2705,8 @@ class Generator {
return JavaEscapeHelper.getJavaIdentifier(varName);
}
- private String evaluateAttribute(TagHandlerInfo handlerInfo,
- Node.JspAttribute attr, Node.CustomTag n, String tagHandlerVar)
+ private String evaluateAttribute(
+ TagHandlerInfo handlerInfo, Node.JspAttribute attr, Node.CustomTag n, String tagHandlerVar)
throws JasperException {
String attrValue = attr.getValue();
@@ -2764,11 +2714,9 @@ class Generator {
if (attr.isNamedAttribute()) {
if (n.checkIfAttributeIsJspFragment(attr.getName())) {
// XXX - no need to generate temporary variable here
- attrValue = generateNamedAttributeJspFragment(attr
- .getNamedAttributeNode(), tagHandlerVar);
+ attrValue = generateNamedAttributeJspFragment(attr.getNamedAttributeNode(), tagHandlerVar);
} else {
- attrValue = generateNamedAttributeValue(attr
- .getNamedAttributeNode());
+ attrValue = generateNamedAttributeValue(attr.getNamedAttributeNode());
}
} else {
return null;
@@ -2784,8 +2732,7 @@ class Generator {
} else {
m = handlerInfo.getSetterMethod(localName);
if (m == null) {
- err.jspError(n, "jsp.error.unable.to_find_method", attr
- .getName());
+ err.jspError(n, "jsp.error.unable.to_find_method", attr.getName());
}
c = m.getParameterTypes();
// XXX assert(c.length > 0)
@@ -2794,10 +2741,9 @@ class Generator {
if (attr.isExpression()) {
// Do nothing
} else if (attr.isNamedAttribute()) {
- if (!n.checkIfAttributeIsJspFragment(attr.getName())
- && !attr.isDynamic()) {
- attrValue = convertString(c[0], attrValue, localName,
- handlerInfo.getPropertyEditorClass(localName), true);
+ if (!n.checkIfAttributeIsJspFragment(attr.getName()) && !attr.isDynamic()) {
+ attrValue = convertString(
+ c[0], attrValue, localName, handlerInfo.getPropertyEditorClass(localName), true);
}
} else if (attr.isELInterpreterInput()) {
@@ -2897,19 +2843,16 @@ class Generator {
} else {
// run attrValue through the expression interpreter
boolean replaceESC = attrValue.indexOf(Constants.ESC) > 0;
- String mapName = (attr.getEL() != null) ? attr.getEL()
- .getMapName() : null;
- attrValue = JspUtil.interpreterCall(this.isTagFile,
- attrValue, c[0], mapName, false);
+ String mapName = (attr.getEL() != null) ? attr.getEL().getMapName() : null;
+ attrValue = JspUtil.interpreterCall(this.isTagFile, attrValue, c[0], mapName, false);
// XXX hack: Replace ESC with '$'
if (replaceESC) {
- attrValue = "(" + attrValue + ").replace("
- + Constants.ESCStr + ", '$')";
+ attrValue = "(" + attrValue + ").replace(" + Constants.ESCStr + ", '$')";
}
}
} else {
- attrValue = convertString(c[0], attrValue, localName,
- handlerInfo.getPropertyEditorClass(localName), false);
+ attrValue =
+ convertString(c[0], attrValue, localName, handlerInfo.getPropertyEditorClass(localName), false);
}
return attrValue;
}
@@ -2919,8 +2862,7 @@ class Generator {
*
* @return the name of the map
*/
- private String generateAliasMap(Node.CustomTag n, String tagHandlerVar)
- throws JasperException {
+ private String generateAliasMap(Node.CustomTag n, String tagHandlerVar) throws JasperException {
TagVariableInfo[] tagVars = n.getTagVariableInfos();
String aliasMapVar = null;
@@ -2953,8 +2895,8 @@ class Generator {
return aliasMapVar;
}
- private void generateSetters(Node.CustomTag n, String tagHandlerVar,
- TagHandlerInfo handlerInfo, boolean simpleTag)
+ private void generateSetters(
+ Node.CustomTag n, String tagHandlerVar, TagHandlerInfo handlerInfo, boolean simpleTag)
throws JasperException {
// Set context
@@ -3014,11 +2956,11 @@ class Generator {
// need to handle deferred values and methods
Node.JspAttribute[] attrs = n.getJspAttributes();
for (int i = 0; attrs != null && i < attrs.length; i++) {
- String attrValue = evaluateAttribute(handlerInfo, attrs[i], n,
- tagHandlerVar);
+ String attrValue = evaluateAttribute(handlerInfo, attrs[i], n, tagHandlerVar);
Mark m = n.getStart();
- out.printil("// "+m.getFile()+"("+m.getLineNumber()+","+m.getColumnNumber()+") "+ attrs[i].getTagAttributeInfo());
+ out.printil("// " + m.getFile() + "(" + m.getLineNumber() + "," + m.getColumnNumber() + ") "
+ + attrs[i].getTagAttributeInfo());
if (attrs[i].isDynamic()) {
out.printin(tagHandlerVar);
out.print(".");
@@ -3037,8 +2979,8 @@ class Generator {
} else {
out.printin(tagHandlerVar);
out.print(".");
- out.print(handlerInfo.getSetterMethod(
- attrs[i].getLocalName()).getName());
+ out.print(
+ handlerInfo.getSetterMethod(attrs[i].getLocalName()).getName());
out.print("(");
out.print(attrValue);
out.println(");");
@@ -3054,8 +2996,8 @@ class Generator {
* attribute is a named attribute (that is, specified using the
* jsp:attribute standard action), and false otherwise
*/
- private String convertString(Class c, String s, String attrName,
- Class propEditorClass, boolean isNamedAttribute)
+ private String convertString(
+ Class c, String s, String attrName, Class propEditorClass, boolean isNamedAttribute)
throws JasperException {
String quoted = s;
@@ -3140,16 +3082,14 @@ class Generator {
* Generates anonymous JspFragment inner class which is passed as an
* argument to SimpleTag.setJspBody().
*/
- private void generateJspFragment(Node n, String tagHandlerVar)
- throws JasperException {
+ private void generateJspFragment(Node n, String tagHandlerVar) throws JasperException {
// XXX - A possible optimization here would be to check to see
// if the only child of the parent node is TemplateText. If so,
// we know there won't be any parameters, etc, so we can
// generate a low-overhead JspFragment that just echoes its
// body. The implementation of this fragment can come from
// the org.apache.sling.scripting.jsp.jasper.runtime package as a support class.
- FragmentHelperClass.Fragment fragment = fragmentHelperClass
- .openFragment(n, tagHandlerVar, methodNesting);
+ FragmentHelperClass.Fragment fragment = fragmentHelperClass.openFragment(n, tagHandlerVar, methodNesting);
ServletWriter outSave = out;
out = fragment.getGenBuffer().getOut();
String tmpParent = parent;
@@ -3184,8 +3124,7 @@ class Generator {
*
* @return The name of the temporary variable the result is stored in.
*/
- public String generateNamedAttributeValue(Node.NamedAttribute n)
- throws JasperException {
+ public String generateNamedAttributeValue(Node.NamedAttribute n) throws JasperException {
String varName = n.getTemporaryVariableName();
@@ -3204,9 +3143,7 @@ class Generator {
out.printil("String "
+ varName
+ " = "
- + quote(new String(
- ((Node.TemplateText) bodyElement)
- .getText())) + ";");
+ + quote(new String(((Node.TemplateText) bodyElement).getText())) + ";");
}
}
@@ -3240,12 +3177,11 @@ class Generator {
* knows its parent tag.
* @return The name of the temporary variable the fragment is stored in.
*/
- public String generateNamedAttributeJspFragment(Node.NamedAttribute n,
- String tagHandlerVar) throws JasperException {
+ public String generateNamedAttributeJspFragment(Node.NamedAttribute n, String tagHandlerVar)
+ throws JasperException {
String varName = n.getTemporaryVariableName();
- out.printin("javax.servlet.jsp.tagext.JspFragment " + varName
- + " = ");
+ out.printin("javax.servlet.jsp.tagext.JspFragment " + varName + " = ");
generateJspFragment(n, tagHandlerVar);
out.println(";");
@@ -3253,8 +3189,7 @@ class Generator {
}
}
- private static void generateLocalVariables(ServletWriter out, Node n)
- throws JasperException {
+ private static void generateLocalVariables(ServletWriter out, Node n) throws JasperException {
Node.ChildInfo ci;
if (n instanceof Node.CustomTag) {
ci = ((Node.CustomTag) n).getChildInfo();
@@ -3271,19 +3206,14 @@ class Generator {
}
if (ci.hasUseBean()) {
- out
- .printil("HttpSession session = _jspx_page_context.getSession();");
- out
- .printil("ServletContext application = _jspx_page_context.getServletContext();");
+ out.printil("HttpSession session = _jspx_page_context.getSession();");
+ out.printil("ServletContext application = _jspx_page_context.getServletContext();");
}
- if (ci.hasUseBean() || ci.hasIncludeAction() || ci.hasSetProperty()
- || ci.hasParamAction()) {
- out
- .printil("HttpServletRequest request = (HttpServletRequest)_jspx_page_context.getRequest();");
+ if (ci.hasUseBean() || ci.hasIncludeAction() || ci.hasSetProperty() || ci.hasParamAction()) {
+ out.printil("HttpServletRequest request = (HttpServletRequest)_jspx_page_context.getRequest();");
}
if (ci.hasIncludeAction()) {
- out
- .printil("HttpServletResponse response = (HttpServletResponse)_jspx_page_context.getResponse();");
+ out.printil("HttpServletResponse response = (HttpServletResponse)_jspx_page_context.getResponse();");
}
}
@@ -3338,8 +3268,7 @@ class Generator {
out.printil("} finally {");
out.pushIndent();
- out
- .printil("_jspxFactory.releasePageContext(_jspx_page_context);");
+ out.printil("_jspxFactory.releasePageContext(_jspx_page_context);");
out.popIndent();
out.printil("}");
@@ -3361,9 +3290,7 @@ class Generator {
charArrayBuffer = null;
err = compiler.getErrorDispatcher();
ctxt = compiler.getCompilationContext();
- fragmentHelperClass = new FragmentHelperClass(ctxt
- .getServletClassName()
- + "Helper");
+ fragmentHelperClass = new FragmentHelperClass(ctxt.getServletClassName() + "Helper");
pageInfo = compiler.getPageInfo();
/*
@@ -3397,8 +3324,7 @@ class Generator {
* @param page
* The input page
*/
- public static void generate(ServletWriter out, Compiler compiler,
- Node.Nodes page) throws JasperException {
+ public static void generate(ServletWriter out, Compiler compiler, Node.Nodes page) throws JasperException {
Generator gen = new Generator(out, compiler);
@@ -3415,17 +3341,27 @@ class Generator {
gen.generateXmlProlog(page);
gen.fragmentHelperClass.generatePreamble();
- page.visit(gen.new GenerateVisitor(gen.ctxt.isTagFile(), out,
- gen.methodsBuffered, gen.fragmentHelperClass, gen.ctxt
- .getClassLoader(), tagInfo));
+ page.visit(gen
+ .new GenerateVisitor(
+ gen.ctxt.isTagFile(),
+ out,
+ gen.methodsBuffered,
+ gen.fragmentHelperClass,
+ gen.ctxt.getClassLoader(),
+ tagInfo));
gen.generateTagHandlerPostamble(tagInfo);
} else {
gen.generatePreamble(page);
gen.generateXmlProlog(page);
gen.fragmentHelperClass.generatePreamble();
- page.visit(gen.new GenerateVisitor(gen.ctxt.isTagFile(), out,
- gen.methodsBuffered, gen.fragmentHelperClass, gen.ctxt
- .getClassLoader(), null));
+ page.visit(gen
+ .new GenerateVisitor(
+ gen.ctxt.isTagFile(),
+ out,
+ gen.methodsBuffered,
+ gen.fragmentHelperClass,
+ gen.ctxt.getClassLoader(),
+ null));
gen.generatePostamble(page);
}
}
@@ -3433,8 +3369,7 @@ class Generator {
/*
* Generates tag handler preamble.
*/
- private void generateTagHandlerPreamble(JasperTagInfo tagInfo,
- Node.Nodes tag) throws JasperException {
+ private void generateTagHandlerPreamble(JasperTagInfo tagInfo, Node.Nodes tag) throws JasperException {
// Generate package declaration
String className = tagInfo.getTagClassName();
@@ -3509,10 +3444,8 @@ class Generator {
out.printil("PageContext _jspx_page_context = (PageContext)jspContext;");
// Declare implicit objects.
- out.printil("HttpServletRequest request = "
- + "(HttpServletRequest) _jspx_page_context.getRequest();");
- out.printil("HttpServletResponse response = "
- + "(HttpServletResponse) _jspx_page_context.getResponse();");
+ out.printil("HttpServletRequest request = " + "(HttpServletRequest) _jspx_page_context.getRequest();");
+ out.printil("HttpServletResponse response = " + "(HttpServletResponse) _jspx_page_context.getResponse();");
out.printil("HttpSession session = _jspx_page_context.getSession();");
out.printil("ServletContext application = _jspx_page_context.getServletContext();");
out.printil("ServletConfig config = _jspx_page_context.getServletConfig();");
@@ -3585,8 +3518,7 @@ class Generator {
* Generates declarations for tag handler attributes, and defines the getter
* and setter methods for each.
*/
- private void generateTagHandlerAttributes(TagInfo tagInfo)
- throws JasperException {
+ private void generateTagHandlerAttributes(TagInfo tagInfo) throws JasperException {
if (tagInfo.hasDynamicAttributes()) {
out.printil("private java.util.HashMap _jspx_dynamic_attrs = new java.util.HashMap();");
@@ -3615,8 +3547,7 @@ class Generator {
if (attrInfos[i].isFragment()) {
out.print("javax.servlet.jsp.tagext.JspFragment ");
} else {
- out.print(JspUtil.toJavaSourceType(attrInfos[i]
- .getTypeName()));
+ out.print(JspUtil.toJavaSourceType(attrInfos[i].getTypeName()));
out.print(" ");
}
out.print(toGetterMethod(attrInfos[i].getName()));
@@ -3636,8 +3567,7 @@ class Generator {
out.print("(javax.servlet.jsp.tagext.JspFragment ");
} else {
out.print("(");
- out.print(JspUtil.toJavaSourceType(attrInfos[i]
- .getTypeName()));
+ out.print(JspUtil.toJavaSourceType(attrInfos[i].getTypeName()));
out.print(" ");
}
out.print(attrInfos[i].getName());
@@ -3679,16 +3609,14 @@ class Generator {
boolean aliasSeen = false;
TagVariableInfo[] tagVars = tagInfo.getTagVariableInfos();
for (int i = 0; i < tagVars.length; i++) {
- if (tagVars[i].getNameFromAttribute() != null
- && tagVars[i].getNameGiven() != null) {
+ if (tagVars[i].getNameFromAttribute() != null && tagVars[i].getNameGiven() != null) {
aliasSeen = true;
break;
}
}
if (aliasSeen) {
- out
- .printil("public void setJspContext(JspContext ctx, java.util.Map aliasMap) {");
+ out.printil("public void setJspContext(JspContext ctx, java.util.Map aliasMap) {");
} else {
out.printil("public void setJspContext(JspContext ctx) {");
}
@@ -3701,40 +3629,40 @@ class Generator {
for (int i = 0; i < tagVars.length; i++) {
switch (tagVars[i].getScope()) {
- case VariableInfo.NESTED:
- if (!nestedSeen) {
- out.printil("_jspx_nested = new java.util.ArrayList();");
- nestedSeen = true;
- }
- out.printin("_jspx_nested.add(");
- break;
+ case VariableInfo.NESTED:
+ if (!nestedSeen) {
+ out.printil("_jspx_nested = new java.util.ArrayList();");
+ nestedSeen = true;
+ }
+ out.printin("_jspx_nested.add(");
+ break;
- case VariableInfo.AT_BEGIN:
- if (!atBeginSeen) {
- out.printil("_jspx_at_begin = new java.util.ArrayList();");
- atBeginSeen = true;
- }
- out.printin("_jspx_at_begin.add(");
- break;
+ case VariableInfo.AT_BEGIN:
+ if (!atBeginSeen) {
+ out.printil("_jspx_at_begin = new java.util.ArrayList();");
+ atBeginSeen = true;
+ }
+ out.printin("_jspx_at_begin.add(");
+ break;
- case VariableInfo.AT_END:
- if (!atEndSeen) {
- out.printil("_jspx_at_end = new java.util.ArrayList();");
- atEndSeen = true;
- }
- out.printin("_jspx_at_end.add(");
- break;
+ case VariableInfo.AT_END:
+ if (!atEndSeen) {
+ out.printil("_jspx_at_end = new java.util.ArrayList();");
+ atEndSeen = true;
+ }
+ out.printin("_jspx_at_end.add(");
+ break;
} // switch
out.print(quote(tagVars[i].getNameGiven()));
out.println(");");
}
if (aliasSeen) {
- out
- .printil("this.jspContext = new org.apache.sling.scripting.jsp.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, aliasMap);");
+ out.printil(
+ "this.jspContext = new org.apache.sling.scripting.jsp.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, aliasMap);");
} else {
- out
- .printil("this.jspContext = new org.apache.sling.scripting.jsp.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, null);");
+ out.printil(
+ "this.jspContext = new org.apache.sling.scripting.jsp.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, null);");
}
out.popIndent();
out.printil("}");
@@ -3753,8 +3681,8 @@ class Generator {
* variable can later be created for it.
*/
public void generateSetDynamicAttribute() {
- out
- .printil("public void setDynamicAttribute(String uri, String localName, Object value) throws JspException {");
+ out.printil(
+ "public void setDynamicAttribute(String uri, String localName, Object value) throws JspException {");
out.pushIndent();
/*
* According to the spec, only dynamic attributes with no uri are to be
@@ -3787,7 +3715,8 @@ class Generator {
// we need to scope the modified VariableMapper for consistency and performance
if (!variableMapperVar) {
- out.printil("javax.el.VariableMapper _el_variablemapper = jspContext.getELContext().getVariableMapper();");
+ out.printil(
+ "javax.el.VariableMapper _el_variablemapper = jspContext.getELContext().getVariableMapper();");
variableMapperVar = true;
}
@@ -3872,8 +3801,7 @@ class Generator {
this.propertyEditorMaps = new Hashtable();
try {
- BeanInfo tagClassInfo = Introspector
- .getBeanInfo(tagHandlerClass);
+ BeanInfo tagClassInfo = Introspector.getBeanInfo(tagHandlerClass);
PropertyDescriptor[] pd = tagClassInfo.getPropertyDescriptors();
for (int i = 0; i < pd.length; i++) {
/*
@@ -3884,13 +3812,11 @@ class Generator {
methodMaps.put(pd[i].getName(), pd[i].getWriteMethod());
}
if (pd[i].getPropertyEditorClass() != null) {
- propertyEditorMaps.put(pd[i].getName(), pd[i]
- .getPropertyEditorClass());
+ propertyEditorMaps.put(pd[i].getName(), pd[i].getPropertyEditorClass());
}
}
} catch (IntrospectionException ie) {
- err.jspError(n, "jsp.error.introspect.taghandler",
- tagHandlerClass.getName(), ie);
+ err.jspError(n, "jsp.error.introspect.taghandler", tagHandlerClass.getName(), ie);
}
}
@@ -3980,8 +3906,7 @@ class Generator {
}
@Override
- public void visit(Node.CustomTag n)
- throws JasperException {
+ public void visit(Node.CustomTag n) throws JasperException {
Node.Nodes b = n.getBody();
if (b != null && !b.isGeneratedInBuffer()) {
// Don't adjust lines for the nested tags that
@@ -4057,12 +3982,10 @@ class Generator {
// Note: cannot be static, as we need to reference things like
// _jspx_meth_*
out.printil("private class " + className);
- out.printil(" extends "
- + "org.apache.sling.scripting.jsp.jasper.runtime.JspFragmentHelper");
+ out.printil(" extends " + "org.apache.sling.scripting.jsp.jasper.runtime.JspFragmentHelper");
out.printil("{");
out.pushIndent();
- out
- .printil("private javax.servlet.jsp.tagext.JspTag _jspx_parent;");
+ out.printil("private javax.servlet.jsp.tagext.JspTag _jspx_parent;");
out.printil("private int[] _jspx_push_body_count;");
out.println();
out.printil("public " + className
@@ -4077,8 +4000,7 @@ class Generator {
out.printil("}");
}
- public Fragment openFragment(Node parent, String tagHandlerVar,
- int methodNesting) throws JasperException {
+ public Fragment openFragment(Node parent, String tagHandlerVar, int methodNesting) throws JasperException {
Fragment result = new Fragment(fragments.size(), parent);
fragments.add(result);
this.used = true;
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ImplicitTagLibraryInfo.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ImplicitTagLibraryInfo.java
index 28edfb4..0da804d 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ImplicitTagLibraryInfo.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ImplicitTagLibraryInfo.java
@@ -1,22 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
+import javax.servlet.jsp.tagext.FunctionInfo;
+import javax.servlet.jsp.tagext.TagFileInfo;
+import javax.servlet.jsp.tagext.TagInfo;
+import javax.servlet.jsp.tagext.TagLibraryInfo;
+
import java.io.InputStream;
import java.util.Collection;
import java.util.Hashtable;
@@ -24,11 +30,6 @@ import java.util.Iterator;
import java.util.Set;
import java.util.Vector;
-import javax.servlet.jsp.tagext.FunctionInfo;
-import javax.servlet.jsp.tagext.TagFileInfo;
-import javax.servlet.jsp.tagext.TagInfo;
-import javax.servlet.jsp.tagext.TagLibraryInfo;
-
import org.apache.sling.scripting.jsp.jasper.JasperException;
import org.apache.sling.scripting.jsp.jasper.JspCompilationContext;
import org.apache.sling.scripting.jsp.jasper.xmlparser.ParserUtils;
@@ -36,7 +37,7 @@ import org.apache.sling.scripting.jsp.jasper.xmlparser.TreeNode;
/**
* Class responsible for generating an implicit tag library containing tag
- * handlers corresponding to the tag files in "/WEB-INF/tags/" or a
+ * handlers corresponding to the tag files in "/WEB-INF/tags/" or a
* subdirectory of it.
*
* @author Jan Luehe
@@ -61,12 +62,14 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo {
/**
* Constructor.
*/
- public ImplicitTagLibraryInfo(JspCompilationContext ctxt,
+ public ImplicitTagLibraryInfo(
+ JspCompilationContext ctxt,
ParserController pc,
PageInfo pi,
String prefix,
String tagdir,
- ErrorDispatcher err) throws JasperException {
+ ErrorDispatcher err)
+ throws JasperException {
super(prefix, null);
this.pc = pc;
this.pi = pi;
@@ -85,8 +88,7 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo {
// Determine the value of the <short-name> subelement of the
// "imaginary" <taglib> element
- if (tagdir.equals(WEB_INF_TAGS)
- || tagdir.equals( WEB_INF_TAGS + "/")) {
+ if (tagdir.equals(WEB_INF_TAGS) || tagdir.equals(WEB_INF_TAGS + "/")) {
shortname = TAGS_SHORTNAME;
} else {
shortname = tagdir.substring(WEB_INF_TAGS.length());
@@ -99,30 +101,27 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo {
Iterator it = dirList.iterator();
while (it.hasNext()) {
String path = (String) it.next();
- if (path.endsWith(TAG_FILE_SUFFIX)
- || path.endsWith(TAGX_FILE_SUFFIX)) {
+ if (path.endsWith(TAG_FILE_SUFFIX) || path.endsWith(TAGX_FILE_SUFFIX)) {
/*
* Use the filename of the tag file, without the .tag or
* .tagx extension, respectively, as the <name> subelement
* of the "imaginary" <tag-file> element
*/
- String suffix = path.endsWith(TAG_FILE_SUFFIX) ?
- TAG_FILE_SUFFIX : TAGX_FILE_SUFFIX;
+ String suffix = path.endsWith(TAG_FILE_SUFFIX) ? TAG_FILE_SUFFIX : TAGX_FILE_SUFFIX;
String tagName = path.substring(path.lastIndexOf("/") + 1);
- tagName = tagName.substring(0,
- tagName.lastIndexOf(suffix));
+ tagName = tagName.substring(0, tagName.lastIndexOf(suffix));
tagFileMap.put(tagName, path);
} else if (path.endsWith(IMPLICIT_TLD)) {
InputStream in = null;
try {
in = ctxt.getResourceAsStream(path);
if (in != null) {
-
+
// Add implicit TLD to dependency list
if (pi != null) {
pi.addDependant(path);
}
-
+
ParserUtils pu = new ParserUtils();
TreeNode tld = pu.parseXMLDocument(uri, in);
@@ -140,8 +139,7 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo {
if ("tlibversion".equals(tname) // JSP 1.1
|| "tlib-version".equals(tname)) { // JSP 1.2
this.tlibversion = element.getBody();
- } else if ("jspversion".equals(tname)
- || "jsp-version".equals(tname)) {
+ } else if ("jspversion".equals(tname) || "jsp-version".equals(tname)) {
this.jspversion = element.getBody();
} else if ("shortname".equals(tname) || "short-name".equals(tname)) {
// Ignore
@@ -169,8 +167,7 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo {
}
}
}
- }
-
+ }
}
/**
@@ -191,10 +188,7 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo {
TagInfo tagInfo = null;
try {
- tagInfo = TagFileProcessor.parseTagFileDirectives(pc,
- shortName,
- path,
- this);
+ tagInfo = TagFileProcessor.parseTagFileDirectives(pc, shortName, path, this);
} catch (JasperException je) {
throw new RuntimeException(je.toString(), je);
}
@@ -213,5 +207,4 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo {
Collection coll = pi.getTaglibs();
return (TagLibraryInfo[]) coll.toArray(new TagLibraryInfo[0]);
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JDTCompiler.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JDTCompiler.java
index 1681736..13fdda5 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JDTCompiler.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JDTCompiler.java
@@ -1,20 +1,21 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
import java.io.BufferedReader;
@@ -47,8 +48,7 @@ public class JDTCompiler extends org.apache.sling.scripting.jsp.jasper.compiler.
* Compile the servlet from .java file to .class file
*/
@Override
- protected void generateClass(String[] smap)
- throws FileNotFoundException, JasperException, Exception {
+ protected void generateClass(String[] smap) throws FileNotFoundException, JasperException, Exception {
long t1 = 0;
if (log.isDebugEnabled()) {
@@ -58,8 +58,7 @@ public class JDTCompiler extends org.apache.sling.scripting.jsp.jasper.compiler.
final String sourceFile = ctxt.getServletJavaFileName();
final String packageName = ctxt.getServletPackageName();
final String targetClassName =
- ((packageName.length() != 0) ? (packageName + ".") : "")
- + ctxt.getServletClassName();
+ ((packageName.length() != 0) ? (packageName + ".") : "") + ctxt.getServletClassName();
final CompilationUnit unit = new CompilationUnitWithSource() {
/**
@@ -80,8 +79,8 @@ public class JDTCompiler extends org.apache.sling.scripting.jsp.jasper.compiler.
* @see org.apache.sling.commons.compiler.CompilationUnit#getSource()
*/
public Reader getSource() throws IOException {
- return new BufferedReader(new InputStreamReader(ctxt.getInputStream(sourceFile),
- ctxt.getOptions().getJavaEncoding()));
+ return new BufferedReader(new InputStreamReader(
+ ctxt.getInputStream(sourceFile), ctxt.getOptions().getJavaEncoding()));
}
/**
@@ -93,7 +92,9 @@ public class JDTCompiler extends org.apache.sling.scripting.jsp.jasper.compiler.
};
final Options options = new Options();
- options.put(Options.KEY_CLASS_LOADER_WRITER, ctxt.getRuntimeContext().getIOProvider().getClassLoaderWriter());
+ options.put(
+ Options.KEY_CLASS_LOADER_WRITER,
+ ctxt.getRuntimeContext().getIOProvider().getClassLoaderWriter());
options.put(Options.KEY_GENERATE_DEBUG_INFO, ctxt.getOptions().getClassDebugInfo());
// Source JVM
@@ -113,14 +114,17 @@ public class JDTCompiler extends org.apache.sling.scripting.jsp.jasper.compiler.
}
final ArrayList<JavacErrorDetail> problemList = new ArrayList<JavacErrorDetail>();
- final CompilationResult result = this.ctxt.getRuntimeContext().getIOProvider().getJavaCompiler().compile(new CompilationUnit[] {unit}, options);
- if ( result.getErrors() != null ) {
- for(final CompilerMessage cm : result.getErrors() ) {
+ final CompilationResult result = this.ctxt
+ .getRuntimeContext()
+ .getIOProvider()
+ .getJavaCompiler()
+ .compile(new CompilationUnit[] {unit}, options);
+ if (result.getErrors() != null) {
+ for (final CompilerMessage cm : result.getErrors()) {
final String name = cm.getFile();
try {
- problemList.add(ErrorDispatcher.createJavacError
- (name, pageNodes, new StringBuffer(cm.getMessage()),
- cm.getLine(), ctxt));
+ problemList.add(ErrorDispatcher.createJavacError(
+ name, pageNodes, new StringBuffer(cm.getMessage()), cm.getLine(), ctxt));
} catch (JasperException e) {
log.error("Error visiting node", e);
}
@@ -132,15 +136,13 @@ public class JDTCompiler extends org.apache.sling.scripting.jsp.jasper.compiler.
}
if (!problemList.isEmpty()) {
- JavacErrorDetail[] jeds =
- problemList.toArray(new JavacErrorDetail[0]);
+ JavacErrorDetail[] jeds = problemList.toArray(new JavacErrorDetail[0]);
errDispatcher.javacError(jeds);
}
- if( log.isDebugEnabled() ) {
- long t2=System.currentTimeMillis();
- log.debug("Compiled " + ctxt.getServletJavaFileName() + " "
- + (t2-t1) + "ms");
+ if (log.isDebugEnabled()) {
+ long t2 = System.currentTimeMillis();
+ log.debug("Compiled " + ctxt.getServletJavaFileName() + " " + (t2 - t1) + "ms");
}
if (ctxt.isPrototypeMode()) {
@@ -148,11 +150,8 @@ public class JDTCompiler extends org.apache.sling.scripting.jsp.jasper.compiler.
}
// JSR45 Support
- if (! this.ctxt.getOptions().isSmapSuppressed()) {
+ if (!this.ctxt.getOptions().isSmapSuppressed()) {
SmapUtil.installSmap(getCompilationContext(), smap);
}
-
}
-
-
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JasperTagInfo.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JasperTagInfo.java
index a7d03c9..91db058 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JasperTagInfo.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JasperTagInfo.java
@@ -1,20 +1,21 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
import javax.servlet.jsp.tagext.*;
@@ -29,27 +30,37 @@ 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) {
+ 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) {
- 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;
}
public boolean hasDynamicAttributes() {
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JavacErrorDetail.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JavacErrorDetail.java
index 2635b6a..db4c856 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JavacErrorDetail.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JavacErrorDetail.java
@@ -1,20 +1,21 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
import java.io.BufferedReader;
@@ -49,9 +50,7 @@ public class JavacErrorDetail {
* @param javaLineNum The compilation error line number
* @param errMsg The compilation error message
*/
- public JavacErrorDetail(String javaFileName,
- int javaLineNum,
- StringBuffer errMsg) {
+ public JavacErrorDetail(String javaFileName, int javaLineNum, StringBuffer errMsg) {
this.javaFileName = javaFileName;
this.javaLineNum = javaLineNum;
@@ -71,17 +70,14 @@ public class JavacErrorDetail {
* responsible for the compilation error
* @param errMsg The compilation error message
*/
- public JavacErrorDetail(String javaFileName,
- int javaLineNum,
- String jspFileName,
- int jspBeginLineNum,
- StringBuffer errMsg) {
-
- this(javaFileName, javaLineNum, jspFileName, jspBeginLineNum, errMsg,
- null);
+ public JavacErrorDetail(
+ String javaFileName, int javaLineNum, String jspFileName, int jspBeginLineNum, StringBuffer errMsg) {
+
+ this(javaFileName, javaLineNum, jspFileName, jspBeginLineNum, errMsg, null);
}
- public JavacErrorDetail(String javaFileName,
+ public JavacErrorDetail(
+ String javaFileName,
int javaLineNum,
String jspFileName,
int jspBeginLineNum,
@@ -107,14 +103,13 @@ public class JavacErrorDetail {
// If the line contains the opening of a multi-line scriptlet
// block, then the JSP line number we got back is probably
// faulty. Scan forward to match the java line...
- if (jspLines[jspBeginLineNum-1].lastIndexOf("<%") >
- jspLines[jspBeginLineNum-1].lastIndexOf("%>")) {
- String javaLine = javaLines[javaLineNum-1].trim();
+ if (jspLines[jspBeginLineNum - 1].lastIndexOf("<%") > jspLines[jspBeginLineNum - 1].lastIndexOf("%>")) {
+ String javaLine = javaLines[javaLineNum - 1].trim();
- for (int i=jspBeginLineNum-1; i<jspLines.length; i++) {
+ for (int i = jspBeginLineNum - 1; i < jspLines.length; i++) {
if (jspLines[i].indexOf(javaLine) != -1) {
// Update jsp line number
- this.jspBeginLineNum = i+1;
+ this.jspBeginLineNum = i + 1;
break;
}
}
@@ -122,12 +117,11 @@ public class JavacErrorDetail {
// copy out a fragment of JSP to display to the user
StringBuffer fragment = new StringBuffer(1024);
- int startIndex = Math.max(0, this.jspBeginLineNum-1-3);
- int endIndex = Math.min(
- jspLines.length-1, this.jspBeginLineNum-1+3);
+ int startIndex = Math.max(0, this.jspBeginLineNum - 1 - 3);
+ int endIndex = Math.min(jspLines.length - 1, this.jspBeginLineNum - 1 + 3);
- for (int i=startIndex;i<=endIndex; ++i) {
- fragment.append(i+1);
+ for (int i = startIndex; i <= endIndex; ++i) {
+ fragment.append(i + 1);
fragment.append(": ");
fragment.append(jspLines[i]);
fragment.append("\n");
@@ -222,10 +216,10 @@ public class JavacErrorDetail {
List lines = new ArrayList();
String line;
- while ( (line = reader.readLine()) != null ) {
+ while ((line = reader.readLine()) != null) {
lines.add(line);
}
- return (String[]) lines.toArray( new String[lines.size()] );
+ return (String[]) lines.toArray(new String[lines.size()]);
}
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspConfig.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspConfig.java
index ffb84e8..49c0d16 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspConfig.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspConfig.java
@@ -1,28 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
+import javax.servlet.ServletContext;
+
import java.io.InputStream;
+import java.net.URL;
import java.util.Iterator;
import java.util.Vector;
-import java.net.URL;
-
-import javax.servlet.ServletContext;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
@@ -38,7 +39,6 @@ import org.xml.sax.InputSource;
* @author Kin-man Chung
* @author Remy Maucherat
*/
-
public class JspConfig {
private static final String WEB_XML = "/WEB-INF/web.xml";
@@ -50,8 +50,8 @@ public class JspConfig {
private ServletContext ctxt;
private boolean initialized = false;
- private String defaultIsXml = null; // unspecified
- private String defaultIsELIgnored = null; // unspecified
+ private String defaultIsXml = null; // unspecified
+ private String defaultIsELIgnored = null; // unspecified
private String defaultIsScriptingInvalid = null;
private String defaultDeferedSyntaxAllowedAsLiteral = null;
private String defaultTrimDirectiveWhitespaces = null;
@@ -85,13 +85,12 @@ public class JspConfig {
is = uri.openStream();
InputSource ip = new InputSource(is);
- ip.setSystemId(uri.toExternalForm());
+ ip.setSystemId(uri.toExternalForm());
ParserUtils pu = new ParserUtils();
TreeNode webApp = pu.parseXMLDocument(WEB_XML, ip);
- if (webApp == null
- || getVersion(webApp) < 2.4) {
+ if (webApp == null || getVersion(webApp) < 2.4) {
defaultIsELIgnored = "true";
return;
}
@@ -122,24 +121,16 @@ public class JspConfig {
element = (TreeNode) list.next();
String tname = element.getName();
- if ("url-pattern".equals(tname))
- urlPatterns.addElement( element.getBody() );
- else if ("page-encoding".equals(tname))
- pageEncoding = element.getBody();
- else if ("is-xml".equals(tname))
- isXml = element.getBody();
- else if ("el-ignored".equals(tname))
- elIgnored = element.getBody();
- else if ("scripting-invalid".equals(tname))
- scriptingInvalid = element.getBody();
- else if ("include-prelude".equals(tname))
- includePrelude.addElement(element.getBody());
- else if ("include-coda".equals(tname))
- includeCoda.addElement(element.getBody());
+ if ("url-pattern".equals(tname)) urlPatterns.addElement(element.getBody());
+ else if ("page-encoding".equals(tname)) pageEncoding = element.getBody();
+ else if ("is-xml".equals(tname)) isXml = element.getBody();
+ else if ("el-ignored".equals(tname)) elIgnored = element.getBody();
+ else if ("scripting-invalid".equals(tname)) scriptingInvalid = element.getBody();
+ else if ("include-prelude".equals(tname)) includePrelude.addElement(element.getBody());
+ else if ("include-coda".equals(tname)) includeCoda.addElement(element.getBody());
else if ("deferred-syntax-allowed-as-literal".equals(tname))
deferredSyntaxAllowedAsLiteral = element.getBody();
- else if ("trim-directive-whitespaces".equals(tname))
- trimDirectiveWhitespaces = element.getBody();
+ else if ("trim-directive-whitespaces".equals(tname)) trimDirectiveWhitespaces = element.getBody();
}
if (urlPatterns.size() == 0) {
@@ -148,8 +139,8 @@ public class JspConfig {
// Add one JspPropertyGroup for each URL Pattern. This makes
// the matching logic easier.
- for( int p = 0; p < urlPatterns.size(); p++ ) {
- String urlPattern = (String)urlPatterns.elementAt( p );
+ for (int p = 0; p < urlPatterns.size(); p++) {
+ String urlPattern = (String) urlPatterns.elementAt(p);
String path = null;
String extension = null;
@@ -160,8 +151,8 @@ public class JspConfig {
int i = urlPattern.lastIndexOf('/');
String file;
if (i >= 0) {
- path = urlPattern.substring(0,i+1);
- file = urlPattern.substring(i+1);
+ path = urlPattern.substring(0, i + 1);
+ file = urlPattern.substring(i + 1);
} else {
file = urlPattern;
}
@@ -170,7 +161,7 @@ public class JspConfig {
if (file.equals("*")) {
extension = "*";
} else if (file.startsWith("*.")) {
- extension = file.substring(file.indexOf('.')+1);
+ extension = file.substring(file.indexOf('.') + 1);
}
// The url patterns are reconstructed as the follwoing:
@@ -178,18 +169,16 @@ public class JspConfig {
// path == null, extension != null: *.ext
// path != null, extension == "*": /foo/*
boolean isStar = "*".equals(extension);
- if ((path == null && (extension == null || isStar))
- || (path != null && !isStar)) {
+ if ((path == null && (extension == null || isStar)) || (path != null && !isStar)) {
if (log.isWarnEnabled()) {
- log.warn(Localizer.getMessage(
- "jsp.warning.bad.urlpattern.propertygroup",
- urlPattern));
+ log.warn(Localizer.getMessage("jsp.warning.bad.urlpattern.propertygroup", urlPattern));
}
continue;
}
}
- JspProperty property = new JspProperty(isXml,
+ JspProperty property = new JspProperty(
+ isXml,
elIgnored,
scriptingInvalid,
pageEncoding,
@@ -197,8 +186,7 @@ public class JspConfig {
includeCoda,
deferredSyntaxAllowedAsLiteral,
trimDirectiveWhitespaces);
- JspPropertyGroup propertyGroup =
- new JspPropertyGroup(path, extension, property);
+ JspPropertyGroup propertyGroup = new JspPropertyGroup(path, extension, property);
jspProperties.addElement(propertyGroup);
}
@@ -209,7 +197,8 @@ public class JspConfig {
if (is != null) {
try {
is.close();
- } catch (Throwable t) {}
+ } catch (Throwable t) {
+ }
}
}
}
@@ -218,10 +207,14 @@ public class JspConfig {
if (!initialized) {
processWebDotXml(ctxt);
- defaultJspProperty = new JspProperty(defaultIsXml,
+ defaultJspProperty = new JspProperty(
+ defaultIsXml,
defaultIsELIgnored,
defaultIsScriptingInvalid,
- null, null, null, defaultDeferedSyntaxAllowedAsLiteral,
+ null,
+ null,
+ null,
+ defaultDeferedSyntaxAllowedAsLiteral,
defaultTrimDirectiveWhitespaces);
initialized = true;
}
@@ -231,8 +224,7 @@ public class JspConfig {
* Select the property group that has more restrictive url-pattern.
* In case of tie, select the first.
*/
- private JspPropertyGroup selectProperty(JspPropertyGroup prev,
- JspPropertyGroup curr) {
+ private JspPropertyGroup selectProperty(JspPropertyGroup prev, JspPropertyGroup curr) {
if (prev == null) {
return curr;
}
@@ -262,7 +254,6 @@ public class JspConfig {
return curr;
}
-
/**
* Find a property that best matches the supplied resource.
* @param uri the resource supplied.
@@ -272,21 +263,20 @@ public class JspConfig {
init();
- // JSP Configuration settings do not apply to tag files
- if (jspProperties == null || uri.endsWith(".tag")
- || uri.endsWith(".tagx")) {
+ // JSP Configuration settings do not apply to tag files
+ if (jspProperties == null || uri.endsWith(".tag") || uri.endsWith(".tagx")) {
return defaultJspProperty;
}
String uriPath = null;
int index = uri.lastIndexOf('/');
- if (index >=0 ) {
- uriPath = uri.substring(0, index+1);
+ if (index >= 0) {
+ uriPath = uri.substring(0, index + 1);
}
String uriExtension = null;
index = uri.lastIndexOf('.');
- if (index >=0) {
- uriExtension = uri.substring(index+1);
+ if (index >= 0) {
+ uriExtension = uri.substring(index + 1);
}
Vector includePreludes = new Vector();
@@ -317,13 +307,11 @@ public class JspConfig {
}
} else {
// Matching patterns *.ext or /p/*
- if (path != null && uriPath != null &&
- ! uriPath.startsWith(path)) {
+ if (path != null && uriPath != null && !uriPath.startsWith(path)) {
// not matched
continue;
}
- if (!extension.equals("*") &&
- !extension.equals(uriExtension)) {
+ if (!extension.equals("*") && !extension.equals(uriExtension)) {
// not matched
continue;
}
@@ -346,23 +334,19 @@ public class JspConfig {
elIgnoredMatch = selectProperty(elIgnoredMatch, jpg);
}
if (jp.isScriptingInvalid() != null) {
- scriptingInvalidMatch =
- selectProperty(scriptingInvalidMatch, jpg);
+ scriptingInvalidMatch = selectProperty(scriptingInvalidMatch, jpg);
}
if (jp.getPageEncoding() != null) {
pageEncodingMatch = selectProperty(pageEncodingMatch, jpg);
}
if (jp.isDeferedSyntaxAllowedAsLiteral() != null) {
- deferedSyntaxAllowedAsLiteralMatch =
- selectProperty(deferedSyntaxAllowedAsLiteralMatch, jpg);
+ deferedSyntaxAllowedAsLiteralMatch = selectProperty(deferedSyntaxAllowedAsLiteralMatch, jpg);
}
if (jp.isTrimDirectiveWhitespaces() != null) {
- trimDirectiveWhitespacesMatch =
- selectProperty(trimDirectiveWhitespacesMatch, jpg);
+ trimDirectiveWhitespacesMatch = selectProperty(trimDirectiveWhitespacesMatch, jpg);
}
}
-
String isXml = defaultIsXml;
String isELIgnored = defaultIsELIgnored;
String isScriptingInvalid = defaultIsScriptingInvalid;
@@ -377,24 +361,29 @@ public class JspConfig {
isELIgnored = elIgnoredMatch.getJspProperty().isELIgnored();
}
if (scriptingInvalidMatch != null) {
- isScriptingInvalid =
- scriptingInvalidMatch.getJspProperty().isScriptingInvalid();
+ isScriptingInvalid = scriptingInvalidMatch.getJspProperty().isScriptingInvalid();
}
if (pageEncodingMatch != null) {
pageEncoding = pageEncodingMatch.getJspProperty().getPageEncoding();
}
if (deferedSyntaxAllowedAsLiteralMatch != null) {
isDeferedSyntaxAllowedAsLiteral =
- deferedSyntaxAllowedAsLiteralMatch.getJspProperty().isDeferedSyntaxAllowedAsLiteral();
+ deferedSyntaxAllowedAsLiteralMatch.getJspProperty().isDeferedSyntaxAllowedAsLiteral();
}
if (trimDirectiveWhitespacesMatch != null) {
isTrimDirectiveWhitespaces =
- trimDirectiveWhitespacesMatch.getJspProperty().isTrimDirectiveWhitespaces();
- }
-
- return new JspProperty(isXml, isELIgnored, isScriptingInvalid,
- pageEncoding, includePreludes, includeCodas,
- isDeferedSyntaxAllowedAsLiteral, isTrimDirectiveWhitespaces);
+ trimDirectiveWhitespacesMatch.getJspProperty().isTrimDirectiveWhitespaces();
+ }
+
+ return new JspProperty(
+ isXml,
+ isELIgnored,
+ isScriptingInvalid,
+ pageEncoding,
+ includePreludes,
+ includeCodas,
+ isDeferedSyntaxAllowedAsLiteral,
+ isTrimDirectiveWhitespaces);
}
/**
@@ -410,13 +399,13 @@ public class JspConfig {
String uriPath = null;
int index = uri.lastIndexOf('/');
- if (index >=0 ) {
- uriPath = uri.substring(0, index+1);
+ if (index >= 0) {
+ uriPath = uri.substring(0, index + 1);
}
String uriExtension = null;
index = uri.lastIndexOf('.');
- if (index >=0) {
- uriExtension = uri.substring(index+1);
+ if (index >= 0) {
+ uriExtension = uri.substring(index + 1);
}
Iterator iter = jspProperties.iterator();
@@ -434,8 +423,8 @@ public class JspConfig {
return true;
}
} else {
- if ((path == null || path.equals(uriPath)) &&
- (extension.equals("*") || extension.equals(uriExtension))) {
+ if ((path == null || path.equals(uriPath))
+ && (extension.equals("*") || extension.equals(uriExtension))) {
// Matches *, *.ext, /p/*, or /p/*.ext
return true;
}
@@ -449,8 +438,7 @@ public class JspConfig {
private String extension;
private JspProperty jspProperty;
- JspPropertyGroup(String path, String extension,
- JspProperty jspProperty) {
+ JspPropertyGroup(String path, String extension, JspProperty jspProperty) {
this.path = path;
this.extension = extension;
this.jspProperty = jspProperty;
@@ -469,7 +457,7 @@ public class JspConfig {
}
}
- static public class JspProperty {
+ public static class JspProperty {
private String isXml;
private String elIgnored;
@@ -480,10 +468,14 @@ public class JspConfig {
private String deferedSyntaxAllowedAsLiteral;
private String trimDirectiveWhitespaces;
- public JspProperty(String isXml, String elIgnored,
- String scriptingInvalid, String pageEncoding,
- Vector includePrelude, Vector includeCoda,
- String deferedSyntaxAllowedAsLiteral,
+ public JspProperty(
+ String isXml,
+ String elIgnored,
+ String scriptingInvalid,
+ String pageEncoding,
+ Vector includePrelude,
+ Vector includeCoda,
+ String deferedSyntaxAllowedAsLiteral,
String trimDirectiveWhitespaces) {
this.isXml = isXml;
@@ -519,11 +511,11 @@ public class JspConfig {
public Vector getIncludeCoda() {
return includeCoda;
}
-
+
public String isDeferedSyntaxAllowedAsLiteral() {
return deferedSyntaxAllowedAsLiteral;
}
-
+
public String isTrimDirectiveWhitespaces() {
return trimDirectiveWhitespaces;
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspDocumentParser.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspDocumentParser.java
index e1e0d0b..7c09dea 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspDocumentParser.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspDocumentParser.java
@@ -1,21 +1,29 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.sling.scripting.jsp.jasper.compiler;
+import javax.servlet.jsp.tagext.TagFileInfo;
+import javax.servlet.jsp.tagext.TagInfo;
+import javax.servlet.jsp.tagext.TagLibraryInfo;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
import java.io.CharArrayWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -24,12 +32,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.jar.JarFile;
-import javax.servlet.jsp.tagext.TagFileInfo;
-import javax.servlet.jsp.tagext.TagInfo;
-import javax.servlet.jsp.tagext.TagLibraryInfo;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
import org.apache.sling.scripting.jsp.jasper.JasperException;
import org.apache.sling.scripting.jsp.jasper.JspCompilationContext;
import org.xml.sax.Attributes;
@@ -49,20 +51,14 @@ import org.xml.sax.helpers.DefaultHandler;
* @author Jan Luehe
* @author Kin-man Chung
*/
-
-class JspDocumentParser
- extends DefaultHandler
- implements LexicalHandler, TagConstants {
+class JspDocumentParser extends DefaultHandler implements LexicalHandler, TagConstants {
private static final String JSP_VERSION = "version";
- private static final String LEXICAL_HANDLER_PROPERTY =
- "http://xml.org/sax/properties/lexical-handler";
+ private static final String LEXICAL_HANDLER_PROPERTY = "http://xml.org/sax/properties/lexical-handler";
private static final String JSP_URI = "http://java.sun.com/JSP/Page";
private static final EnableDTDValidationException ENABLE_DTD_VALIDATION_EXCEPTION =
- new EnableDTDValidationException(
- "jsp.error.enable_dtd_validation",
- null);
+ new EnableDTDValidationException("jsp.error.enable_dtd_validation", null);
private ParserController parserController;
private JspCompilationContext ctxt;
@@ -82,16 +78,16 @@ class JspDocumentParser
private Locator locator;
- //Mark representing the start of the current element. Note
- //that locator.getLineNumber() and locator.getColumnNumber()
- //return the line and column numbers for the character
- //immediately _following_ the current element. The underlying
- //XMl parser eats white space that is not part of character
- //data, so for Nodes that are not created from character data,
- //this is the best we can do. But when we parse character data,
- //we get an accurate starting location by starting with startMark
- //as set by the previous element, and updating it as we advance
- //through the characters.
+ // Mark representing the start of the current element. Note
+ // that locator.getLineNumber() and locator.getColumnNumber()
+ // return the line and column numbers for the character
+ // immediately _following_ the current element. The underlying
+ // XMl parser eats white space that is not part of character
+ // data, so for Nodes that are not created from character data,
+ // this is the best we can do. But when we parse character data,
+ // we get an accurate starting location by starting with startMark
+ // as set by the previous element, and updating it as we advance
+ // through the characters.
private Mark startMark;
// Flag indicating whether we are inside DTD declarations
@@ -113,11 +109,7 @@ class JspDocumentParser
/*
* Constructor
*/
- public JspDocumentParser(
- ParserController pc,
- String path,
- boolean isTagFile,
- boolean directivesOnly) {
+ public JspDocumentParser(ParserController pc, String path, boolean isTagFile, boolean directivesOnly) {
this.parserController = pc;
this.ctxt = pc.getJspCompilationContext();
this.pageInfo = pc.getCompiler().getPageInfo();
@@ -134,20 +126,19 @@ class JspDocumentParser
* @throws JasperException
*/
public static Node.Nodes parse(
- ParserController pc,
- String path,
- JarFile jarFile,
- Node parent,
- boolean isTagFile,
- boolean directivesOnly,
- String pageEnc,
- String jspConfigPageEnc,
- boolean isEncodingSpecifiedInProlog,
- boolean isBomPresent)
- throws JasperException {
-
- JspDocumentParser jspDocParser =
- new JspDocumentParser(pc, path, isTagFile, directivesOnly);
+ ParserController pc,
+ String path,
+ JarFile jarFile,
+ Node parent,
+ boolean isTagFile,
+ boolean directivesOnly,
+ String pageEnc,
+ String jspConfigPageEnc,
+ boolean isEncodingSpecifiedInProlog,
+ boolean isBomPresent)
+ throws JasperException {
+
+ JspDocumentParser jspDocParser = new JspDocumentParser(pc, path, isTagFile, directivesOnly);
Node.Nodes pageNodes = null;
try {
@@ -156,14 +147,11 @@ class JspDocumentParser
Node.Root dummyRoot = new Node.Root(null, parent, true);
dummyRoot.setPageEncoding(pageEnc);
dummyRoot.setJspConfigPageEncoding(jspConfigPageEnc);
- dummyRoot.setIsEncodingSpecifiedInProlog(
- isEncodingSpecifiedInProlog);
+ dummyRoot.setIsEncodingSpecifiedInProlog(isEncodingSpecifiedInProlog);
dummyRoot.setIsBomPresent(isBomPresent);
jspDocParser.current = dummyRoot;
if (parent == null) {
- jspDocParser.addInclude(
- dummyRoot,
- jspDocParser.pageInfo.getIncludePrelude());
+ jspDocParser.addInclude(dummyRoot, jspDocParser.pageInfo.getIncludePrelude());
} else {
jspDocParser.isTop = false;
}
@@ -172,9 +160,7 @@ class JspDocumentParser
SAXParser saxParser = getSAXParser(false, jspDocParser);
InputStream inStream = null;
try {
- inStream = JspUtil.getInputStream(path, jarFile,
- jspDocParser.ctxt,
- jspDocParser.err);
+ inStream = JspUtil.getInputStream(path, jarFile, jspDocParser.ctxt, jspDocParser.err);
saxParser.parse(new InputSource(inStream), jspDocParser);
} catch (EnableDTDValidationException e) {
saxParser = getSAXParser(true, jspDocParser);
@@ -185,9 +171,7 @@ class JspDocumentParser
} catch (Exception any) {
}
}
- inStream = JspUtil.getInputStream(path, jarFile,
- jspDocParser.ctxt,
- jspDocParser.err);
+ inStream = JspUtil.getInputStream(path, jarFile, jspDocParser.ctxt, jspDocParser.err);
saxParser.parse(new InputSource(inStream), jspDocParser);
} finally {
if (inStream != null) {
@@ -199,9 +183,7 @@ class JspDocumentParser
}
if (parent == null) {
- jspDocParser.addInclude(
- dummyRoot,
- jspDocParser.pageInfo.getIncludeCoda());
+ jspDocParser.addInclude(dummyRoot, jspDocParser.pageInfo.getIncludeCoda());
}
// Create Node.Nodes from dummy root
@@ -210,10 +192,8 @@ class JspDocumentParser
} catch (IOException ioe) {
jspDocParser.err.jspError("jsp.error.data.file.read", path, ioe);
} catch (SAXParseException e) {
- jspDocParser.err.jspError
- (new Mark(jspDocParser.ctxt, path, e.getLineNumber(),
- e.getColumnNumber()),
- e.getMessage());
+ jspDocParser.err.jspError(
+ new Mark(jspDocParser.ctxt, path, e.getLineNumber(), e.getColumnNumber()), e.getMessage());
} catch (Exception e) {
jspDocParser.err.jspError(e);
}
@@ -231,14 +211,14 @@ class JspDocumentParser
if (files != null) {
Iterator iter = files.iterator();
while (iter.hasNext()) {
- String file = (String)iter.next();
+ String file = (String) iter.next();
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute("", "file", "file", "CDATA", file);
// Create a dummy Include directive node
- Node includeDir =
- new Node.IncludeDirective(attrs, null, // XXX
- parent);
+ Node includeDir = new Node.IncludeDirective(
+ attrs, null, // XXX
+ parent);
processIncludeDirective(file, includeDir);
}
}
@@ -257,12 +237,7 @@ class JspDocumentParser
* corresponding TagLibraryInfo object is added to the set of custom
* tag libraries.
*/
- public void startElement(
- String uri,
- String localName,
- String qName,
- Attributes attrs)
- throws SAXException {
+ public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
AttributesImpl taglibAttrs = null;
AttributesImpl nonTaglibAttrs = null;
@@ -272,20 +247,16 @@ class JspDocumentParser
checkPrefixes(uri, qName, attrs);
- if (directivesOnly &&
- !(JSP_URI.equals(uri) && localName.startsWith(DIRECTIVE_ACTION))) {
+ if (directivesOnly && !(JSP_URI.equals(uri) && localName.startsWith(DIRECTIVE_ACTION))) {
return;
}
// jsp:text must not have any subelements
if (JSP_URI.equals(uri) && TEXT_ACTION.equals(current.getLocalName())) {
- throw new SAXParseException(
- Localizer.getMessage("jsp.error.text.has_subelement"),
- locator);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.text.has_subelement"), locator);
}
- startMark = new Mark(ctxt, path, locator.getLineNumber(),
- locator.getColumnNumber());
+ startMark = new Mark(ctxt, path, locator.getLineNumber(), locator.getColumnNumber());
if (attrs != null) {
/*
@@ -301,11 +272,11 @@ class JspDocumentParser
nonTaglibAttrs = new AttributesImpl();
}
nonTaglibAttrs.addAttribute(
- attrs.getURI(i),
- attrs.getLocalName(i),
- attrs.getQName(i),
- attrs.getType(i),
- attrs.getValue(i));
+ attrs.getURI(i),
+ attrs.getLocalName(i),
+ attrs.getQName(i),
+ attrs.getType(i),
+ attrs.getValue(i));
} else {
if (attrQName.startsWith("xmlns:jsp")) {
isTaglib = true;
@@ -320,21 +291,21 @@ class JspDocumentParser
taglibAttrs = new AttributesImpl();
}
taglibAttrs.addAttribute(
- attrs.getURI(i),
- attrs.getLocalName(i),
- attrs.getQName(i),
- attrs.getType(i),
- attrs.getValue(i));
+ attrs.getURI(i),
+ attrs.getLocalName(i),
+ attrs.getQName(i),
+ attrs.getType(i),
+ attrs.getValue(i));
} else {
if (nonTaglibXmlnsAttrs == null) {
nonTaglibXmlnsAttrs = new AttributesImpl();
}
nonTaglibXmlnsAttrs.addAttribute(
- attrs.getURI(i),
- attrs.getLocalName(i),
- attrs.getQName(i),
- attrs.getType(i),
- attrs.getValue(i));
+ attrs.getURI(i),
+ attrs.getLocalName(i),
+ attrs.getQName(i),
+ attrs.getType(i),
+ attrs.getValue(i));
}
}
}
@@ -342,33 +313,17 @@ class JspDocumentParser
Node node = null;
- if (tagDependentPending && JSP_URI.equals(uri) &&
- localName.equals(BODY_ACTION)) {
+ if (tagDependentPending && JSP_URI.equals(uri) && localName.equals(BODY_ACTION)) {
tagDependentPending = false;
tagDependentNesting++;
- current =
- parseStandardAction(
- qName,
- localName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- startMark,
- current);
+ current = parseStandardAction(
+ qName, localName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, startMark, current);
return;
}
- if (tagDependentPending && JSP_URI.equals(uri) &&
- localName.equals(ATTRIBUTE_ACTION)) {
- current =
- parseStandardAction(
- qName,
- localName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- startMark,
- current);
+ if (tagDependentPending && JSP_URI.equals(uri) && localName.equals(ATTRIBUTE_ACTION)) {
+ current = parseStandardAction(
+ qName, localName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, startMark, current);
return;
}
@@ -378,55 +333,24 @@ class JspDocumentParser
}
if (tagDependentNesting > 0) {
- node =
- new Node.UninterpretedTag(
- qName,
- localName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- startMark,
- current);
+ node = new Node.UninterpretedTag(
+ qName, localName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, startMark, current);
} else if (JSP_URI.equals(uri)) {
- node =
- parseStandardAction(
- qName,
- localName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- startMark,
- current);
+ node = parseStandardAction(
+ qName, localName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, startMark, current);
} else {
- node =
- parseCustomAction(
- qName,
- localName,
- uri,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- startMark,
- current);
+ node = parseCustomAction(
+ qName, localName, uri, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, startMark, current);
if (node == null) {
- node =
- new Node.UninterpretedTag(
- qName,
- localName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- startMark,
- current);
+ node = new Node.UninterpretedTag(
+ qName, localName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, startMark, current);
} else {
// custom action
String bodyType = getBodyType((Node.CustomTag) node);
- if (scriptlessBodyNode == null
- && bodyType.equalsIgnoreCase(TagInfo.BODY_CONTENT_SCRIPTLESS)) {
+ if (scriptlessBodyNode == null && bodyType.equalsIgnoreCase(TagInfo.BODY_CONTENT_SCRIPTLESS)) {
scriptlessBodyNode = node;
- }
- else if (TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType)) {
+ } else if (TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType)) {
tagDependentPending = true;
}
}
@@ -474,13 +398,12 @@ class JspDocumentParser
* JSP.6.2.3 defines white space characters.
*/
boolean isAllSpace = true;
- if (!(current instanceof Node.JspText)
- && !(current instanceof Node.NamedAttribute)) {
+ if (!(current instanceof Node.JspText) && !(current instanceof Node.NamedAttribute)) {
for (int i = 0; i < charBuffer.length(); i++) {
if (!(charBuffer.charAt(i) == ' '
- || charBuffer.charAt(i) == '\n'
- || charBuffer.charAt(i) == '\r'
- || charBuffer.charAt(i) == '\t')) {
+ || charBuffer.charAt(i) == '\n'
+ || charBuffer.charAt(i) == '\r'
+ || charBuffer.charAt(i) == '\t')) {
isAllSpace = false;
break;
}
@@ -496,15 +419,12 @@ class JspDocumentParser
if (charBuffer.length() > 0) {
new Node.TemplateText(charBuffer.toString(), startMark, current);
}
- startMark = new Mark(ctxt, path, locator.getLineNumber(),
- locator.getColumnNumber());
+ startMark = new Mark(ctxt, path, locator.getLineNumber(), locator.getColumnNumber());
charBuffer = null;
return;
}
- if ((current instanceof Node.JspText)
- || (current instanceof Node.NamedAttribute)
- || !isAllSpace) {
+ if ((current instanceof Node.JspText) || (current instanceof Node.NamedAttribute) || !isAllSpace) {
int line = startMark.getLineNumber();
int column = startMark.getColumnNumber();
@@ -523,13 +443,10 @@ class JspDocumentParser
if ((lastCh == '$' || lastCh == '#') && ch == '{') {
elType = lastCh;
if (ttext.size() > 0) {
- new Node.TemplateText(
- ttext.toString(),
- startMark,
- current);
+ new Node.TemplateText(ttext.toString(), startMark, current);
ttext = new CharArrayWriter();
- //We subtract two from the column number to
- //account for the '[$,#]{' that we've already parsed
+ // We subtract two from the column number to
+ // account for the '[$,#]{' that we've already parsed
startMark = new Mark(ctxt, path, line, column - 2);
}
// following "${" || "#{" to first unquoted "}"
@@ -537,14 +454,10 @@ class JspDocumentParser
boolean singleQ = false;
boolean doubleQ = false;
lastCh = 0;
- for (;; i++) {
+ for (; ; i++) {
if (i >= charBuffer.length()) {
throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.unterminated",
- (char) elType + "{"),
- locator);
-
+ Localizer.getMessage("jsp.error.unterminated", (char) elType + "{"), locator);
}
ch = charBuffer.charAt(i);
if (ch == '\n') {
@@ -559,25 +472,20 @@ class JspDocumentParser
continue;
}
if (ch == '}') {
- new Node.ELExpression((char) elType,
- ttext.toString(),
- startMark,
- current);
+ new Node.ELExpression((char) elType, ttext.toString(), startMark, current);
ttext = new CharArrayWriter();
startMark = new Mark(ctxt, path, line, column);
break;
}
- if (ch == '"')
- doubleQ = !doubleQ;
- else if (ch == '\'')
- singleQ = !singleQ;
+ if (ch == '"') doubleQ = !doubleQ;
+ else if (ch == '\'') singleQ = !singleQ;
ttext.write(ch);
lastCh = ch;
}
} else if (lastCh == '\\' && (ch == '$' || ch == '#')) {
ttext.write(ch);
- ch = 0; // Not start of EL anymore
+ ch = 0; // Not start of EL anymore
} else {
if (lastCh == '$' || lastCh == '#' || lastCh == '\\') {
ttext.write(lastCh);
@@ -595,8 +503,7 @@ class JspDocumentParser
new Node.TemplateText(ttext.toString(), startMark, current);
}
}
- startMark = new Mark(ctxt, path, locator.getLineNumber(),
- locator.getColumnNumber());
+ startMark = new Mark(ctxt, path, locator.getLineNumber(), locator.getColumnNumber());
charBuffer = null;
}
@@ -604,19 +511,17 @@ class JspDocumentParser
/*
* Receives notification of the end of an element.
*/
- public void endElement(String uri, String localName, String qName)
- throws SAXException {
+ public void endElement(String uri, String localName, String qName) throws SAXException {
processChars();
- if (directivesOnly &&
- !(JSP_URI.equals(uri) && localName.startsWith(DIRECTIVE_ACTION))) {
+ if (directivesOnly && !(JSP_URI.equals(uri) && localName.startsWith(DIRECTIVE_ACTION))) {
return;
}
if (current instanceof Node.NamedAttribute) {
- boolean isTrim = ((Node.NamedAttribute)current).isTrim();
- Node.Nodes subElems = ((Node.NamedAttribute)current).getBody();
+ boolean isTrim = ((Node.NamedAttribute) current).isTrim();
+ Node.Nodes subElems = ((Node.NamedAttribute) current).getBody();
for (int i = 0; subElems != null && i < subElems.size(); i++) {
Node subElem = subElems.getNode(i);
if (!(subElem instanceof Node.TemplateText)) {
@@ -633,28 +538,27 @@ class JspDocumentParser
// is set to FALSE, which must be kept verbatim.
if (i == 0) {
if (isTrim) {
- ((Node.TemplateText)subElem).ltrim();
+ ((Node.TemplateText) subElem).ltrim();
}
} else if (i == subElems.size() - 1) {
if (isTrim) {
- ((Node.TemplateText)subElem).rtrim();
+ ((Node.TemplateText) subElem).rtrim();
}
} else {
- if (((Node.TemplateText)subElem).isAllSpace()) {
+ if (((Node.TemplateText) subElem).isAllSpace()) {
subElems.remove(subElem);
}
}
}
} else if (current instanceof Node.ScriptingElement) {
- checkScriptingBody((Node.ScriptingElement)current);
+ checkScriptingBody((Node.ScriptingElement) current);
}
- if ( isTagDependent(current)) {
+ if (isTagDependent(current)) {
tagDependentNesting--;
}
- if (scriptlessBodyNode != null
- && current.equals(scriptlessBodyNode)) {
+ if (scriptlessBodyNode != null && current.equals(scriptlessBodyNode)) {
scriptlessBodyNode = null;
}
@@ -677,16 +581,11 @@ class JspDocumentParser
*/
public void comment(char[] buf, int offset, int len) throws SAXException {
- processChars(); // Flush char buffer and remove white spaces
+ processChars(); // Flush char buffer and remove white spaces
// ignore comments in the DTD
if (!inDTD) {
- startMark =
- new Mark(
- ctxt,
- path,
- locator.getLineNumber(),
- locator.getColumnNumber());
+ startMark = new Mark(ctxt, path, locator.getLineNumber(), locator.getColumnNumber());
new Node.Comment(new String(buf, offset, len), startMark, current);
}
}
@@ -696,16 +595,15 @@ class JspDocumentParser
*/
public void startCDATA() throws SAXException {
- processChars(); // Flush char buffer and remove white spaces
- startMark = new Mark(ctxt, path, locator.getLineNumber(),
- locator.getColumnNumber());
+ processChars(); // Flush char buffer and remove white spaces
+ startMark = new Mark(ctxt, path, locator.getLineNumber(), locator.getColumnNumber());
}
/*
* See org.xml.sax.ext.LexicalHandler.
*/
public void endCDATA() throws SAXException {
- processChars(); // Flush char buffer and remove white spaces
+ processChars(); // Flush char buffer and remove white spaces
}
/*
@@ -725,8 +623,7 @@ class JspDocumentParser
/*
* See org.xml.sax.ext.LexicalHandler.
*/
- public void startDTD(String name, String publicId, String systemId)
- throws SAXException {
+ public void startDTD(String name, String publicId, String systemId) throws SAXException {
if (!isValidating) {
fatalError(ENABLE_DTD_VALIDATION_EXCEPTION);
}
@@ -758,8 +655,7 @@ class JspDocumentParser
/*
* Receives notification of the start of a Namespace mapping.
*/
- public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
TagLibraryInfo taglibInfo;
if (directivesOnly && !(JSP_URI.equals(uri))) {
@@ -769,10 +665,7 @@ class JspDocumentParser
try {
taglibInfo = getTaglibInfo(prefix, uri);
} catch (JasperException je) {
- throw new SAXParseException(
- Localizer.getMessage("jsp.error.could.not.add.taglibraries"),
- locator,
- je);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.could.not.add.taglibraries"), locator, je);
}
if (taglibInfo != null) {
@@ -800,333 +693,123 @@ class JspDocumentParser
pageInfo.popPrefixMapping(prefix);
}
- //*********************************************************************
+ // *********************************************************************
// Private utility methods
private Node parseStandardAction(
- String qName,
- String localName,
- Attributes nonTaglibAttrs,
- Attributes nonTaglibXmlnsAttrs,
- Attributes taglibAttrs,
- Mark start,
- Node parent)
- throws SAXException {
+ String qName,
+ String localName,
+ Attributes nonTaglibAttrs,
+ Attributes nonTaglibXmlnsAttrs,
+ Attributes taglibAttrs,
+ Mark start,
+ Node parent)
+ throws SAXException {
Node node = null;
if (localName.equals(ROOT_ACTION)) {
if (!(current instanceof Node.Root)) {
- throw new SAXParseException(
- Localizer.getMessage("jsp.error.nested_jsproot"),
- locator);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.nested_jsproot"), locator);
}
- node =
- new Node.JspRoot(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.JspRoot(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
if (isTop) {
pageInfo.setHasJspRoot(true);
}
} else if (localName.equals(PAGE_DIRECTIVE_ACTION)) {
if (isTagFile) {
- throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.action.istagfile",
- localName),
- locator);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.action.istagfile", localName), locator);
}
- node =
- new Node.PageDirective(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.PageDirective(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
String imports = nonTaglibAttrs.getValue("import");
// There can only be one 'import' attribute per page directive
if (imports != null) {
- ((Node.PageDirective)node).addImport(imports);
+ ((Node.PageDirective) node).addImport(imports);
}
} else if (localName.equals(INCLUDE_DIRECTIVE_ACTION)) {
- node =
- new Node.IncludeDirective(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.IncludeDirective(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
processIncludeDirective(nonTaglibAttrs.getValue("file"), node);
} else if (localName.equals(DECLARATION_ACTION)) {
if (scriptlessBodyNode != null) {
// We're nested inside a node whose body is
// declared to be scriptless
- throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.no.scriptlets",
- localName),
- locator);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.no.scriptlets", localName), locator);
}
- node =
- new Node.Declaration(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.Declaration(qName, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(SCRIPTLET_ACTION)) {
if (scriptlessBodyNode != null) {
// We're nested inside a node whose body is
// declared to be scriptless
- throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.no.scriptlets",
- localName),
- locator);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.no.scriptlets", localName), locator);
}
- node =
- new Node.Scriptlet(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.Scriptlet(qName, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(EXPRESSION_ACTION)) {
if (scriptlessBodyNode != null) {
// We're nested inside a node whose body is
// declared to be scriptless
- throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.no.scriptlets",
- localName),
- locator);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.no.scriptlets", localName), locator);
}
- node =
- new Node.Expression(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.Expression(qName, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(USE_BEAN_ACTION)) {
- node =
- new Node.UseBean(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.UseBean(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(SET_PROPERTY_ACTION)) {
- node =
- new Node.SetProperty(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.SetProperty(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(GET_PROPERTY_ACTION)) {
- node =
- new Node.GetProperty(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.GetProperty(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(INCLUDE_ACTION)) {
- node =
- new Node.IncludeAction(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.IncludeAction(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(FORWARD_ACTION)) {
- node =
- new Node.ForwardAction(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.ForwardAction(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(PARAM_ACTION)) {
- node =
- new Node.ParamAction(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.ParamAction(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(PARAMS_ACTION)) {
- node =
- new Node.ParamsAction(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.ParamsAction(qName, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(PLUGIN_ACTION)) {
- node =
- new Node.PlugIn(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.PlugIn(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(TEXT_ACTION)) {
- node =
- new Node.JspText(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.JspText(qName, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(BODY_ACTION)) {
- node =
- new Node.JspBody(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.JspBody(qName, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(ATTRIBUTE_ACTION)) {
- node =
- new Node.NamedAttribute(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.NamedAttribute(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(OUTPUT_ACTION)) {
- node =
- new Node.JspOutput(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.JspOutput(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(TAG_DIRECTIVE_ACTION)) {
if (!isTagFile) {
- throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.action.isnottagfile",
- localName),
- locator);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.action.isnottagfile", localName), locator);
}
- node =
- new Node.TagDirective(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.TagDirective(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
String imports = nonTaglibAttrs.getValue("import");
// There can only be one 'import' attribute per tag directive
if (imports != null) {
- ((Node.TagDirective)node).addImport(imports);
+ ((Node.TagDirective) node).addImport(imports);
}
} else if (localName.equals(ATTRIBUTE_DIRECTIVE_ACTION)) {
if (!isTagFile) {
- throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.action.isnottagfile",
- localName),
- locator);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.action.isnottagfile", localName), locator);
}
- node =
- new Node.AttributeDirective(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.AttributeDirective(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(VARIABLE_DIRECTIVE_ACTION)) {
if (!isTagFile) {
- throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.action.isnottagfile",
- localName),
- locator);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.action.isnottagfile", localName), locator);
}
- node =
- new Node.VariableDirective(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.VariableDirective(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(INVOKE_ACTION)) {
if (!isTagFile) {
- throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.action.isnottagfile",
- localName),
- locator);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.action.isnottagfile", localName), locator);
}
- node =
- new Node.InvokeAction(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.InvokeAction(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(DOBODY_ACTION)) {
if (!isTagFile) {
- throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.action.isnottagfile",
- localName),
- locator);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.action.isnottagfile", localName), locator);
}
- node =
- new Node.DoBodyAction(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.DoBodyAction(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(ELEMENT_ACTION)) {
- node =
- new Node.JspElement(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.JspElement(qName, nonTaglibAttrs, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else if (localName.equals(FALLBACK_ACTION)) {
- node =
- new Node.FallBackAction(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ node = new Node.FallBackAction(qName, nonTaglibXmlnsAttrs, taglibAttrs, start, current);
} else {
- throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.xml.badStandardAction",
- localName),
- locator);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.xml.badStandardAction", localName), locator);
}
return node;
@@ -1137,15 +820,15 @@ class JspDocumentParser
* and returns the corresponding Node object.
*/
private Node parseCustomAction(
- String qName,
- String localName,
- String uri,
- Attributes nonTaglibAttrs,
- Attributes nonTaglibXmlnsAttrs,
- Attributes taglibAttrs,
- Mark start,
- Node parent)
- throws SAXException {
+ String qName,
+ String localName,
+ String uri,
+ Attributes nonTaglibAttrs,
+ Attributes nonTaglibXmlnsAttrs,
+ Attributes taglibAttrs,
+ Mark start,
+ Node parent)
+ throws SAXException {
// Check if this is a user-defined (custom) tag
TagLibraryInfo tagLibInfo = pageInfo.getTaglib(uri);
@@ -1156,21 +839,16 @@ class JspDocumentParser
TagInfo tagInfo = tagLibInfo.getTag(localName);
TagFileInfo tagFileInfo = tagLibInfo.getTagFile(localName);
if (tagInfo == null && tagFileInfo == null) {
- throw new SAXException(
- Localizer.getMessage("jsp.error.xml.bad_tag", localName, uri));
+ throw new SAXException(Localizer.getMessage("jsp.error.xml.bad_tag", localName, uri));
}
Class tagHandlerClass = null;
if (tagInfo != null) {
String handlerClassName = tagInfo.getTagClassName();
try {
- tagHandlerClass =
- ctxt.getClassLoader().loadClass(handlerClassName);
+ tagHandlerClass = ctxt.getClassLoader().loadClass(handlerClassName);
} catch (Exception e) {
throw new SAXException(
- Localizer.getMessage("jsp.error.loadclass.taghandler",
- handlerClassName,
- qName),
- e);
+ Localizer.getMessage("jsp.error.loadclass.taghandler", handlerClassName, qName), e);
}
}
@@ -1182,8 +860,7 @@ class JspDocumentParser
Node.CustomTag ret = null;
if (tagInfo != null) {
- ret =
- new Node.CustomTag(
+ ret = new Node.CustomTag(
qName,
prefix,
localName,
@@ -1196,8 +873,7 @@ class JspDocumentParser
tagInfo,
tagHandlerClass);
} else {
- ret =
- new Node.CustomTag(
+ ret = new Node.CustomTag(
qName,
prefix,
localName,
@@ -1222,22 +898,14 @@ class JspDocumentParser
*
* @return The tag library associated with the given uri namespace
*/
- private TagLibraryInfo getTaglibInfo(String prefix, String uri)
- throws JasperException {
+ private TagLibraryInfo getTaglibInfo(String prefix, String uri) throws JasperException {
TagLibraryInfo result = null;
if (uri.startsWith(URN_JSPTAGDIR)) {
// uri (of the form "urn:jsptagdir:path") references tag file dir
String tagdir = uri.substring(URN_JSPTAGDIR.length());
- result =
- new ImplicitTagLibraryInfo(
- ctxt,
- parserController,
- pageInfo,
- prefix,
- tagdir,
- err);
+ result = new ImplicitTagLibraryInfo(ctxt, parserController, pageInfo, prefix, tagdir, err);
} else {
// uri references TLD file
boolean isPlainUri = false;
@@ -1256,15 +924,7 @@ class JspDocumentParser
* Instead, any actions in the namespace defined by the uri
* value must be treated as uninterpreted.
*/
- result =
- new TagLibraryInfoImpl(
- ctxt,
- parserController,
- pageInfo,
- prefix,
- uri,
- location,
- err);
+ result = new TagLibraryInfoImpl(ctxt, parserController, pageInfo, prefix, uri, location, err);
}
}
@@ -1279,8 +939,7 @@ class JspDocumentParser
* declaration, scriptlet, or expression) element, after the end tag of a
* scripting element has been reached.
*/
- private void checkScriptingBody(Node.ScriptingElement scriptingElem)
- throws SAXException {
+ private void checkScriptingBody(Node.ScriptingElement scriptingElem) throws SAXException {
Node.Nodes body = scriptingElem.getBody();
if (body != null) {
int size = body.size();
@@ -1288,14 +947,9 @@ class JspDocumentParser
Node n = body.getNode(i);
if (!(n instanceof Node.TemplateText)) {
String elemType = SCRIPTLET_ACTION;
- if (scriptingElem instanceof Node.Declaration)
- elemType = DECLARATION_ACTION;
- if (scriptingElem instanceof Node.Expression)
- elemType = EXPRESSION_ACTION;
- String msg =
- Localizer.getMessage(
- "jsp.error.parse.xml.scripting.invalid.body",
- elemType);
+ if (scriptingElem instanceof Node.Declaration) elemType = DECLARATION_ACTION;
+ if (scriptingElem instanceof Node.Expression) elemType = EXPRESSION_ACTION;
+ String msg = Localizer.getMessage("jsp.error.parse.xml.scripting.invalid.body", elemType);
throw new SAXException(msg);
}
}
@@ -1309,8 +963,7 @@ class JspDocumentParser
* 'file' attribute of the include directive
* @param parent The Node representing the include directive
*/
- private void processIncludeDirective(String fname, Node parent)
- throws SAXException {
+ private void processIncludeDirective(String fname, Node parent) throws SAXException {
if (fname == null) {
return;
@@ -1319,10 +972,7 @@ class JspDocumentParser
try {
parserController.parse(fname, parent, null);
} catch (FileNotFoundException fnfe) {
- throw new SAXParseException(
- Localizer.getMessage("jsp.error.file.not.found", fname),
- locator,
- fnfe);
+ throw new SAXParseException(Localizer.getMessage("jsp.error.file.not.found", fname), locator, fnfe);
} catch (Exception e) {
throw new SAXException(e);
}
@@ -1376,20 +1026,15 @@ class JspDocumentParser
*
* @return The SAXParser
*/
- private static SAXParser getSAXParser(
- boolean validating,
- JspDocumentParser jspDocParser)
- throws Exception {
+ private static SAXParser getSAXParser(boolean validating, JspDocumentParser jspDocParser) throws Exception {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
// Preserve xmlns attributes
- factory.setFeature(
- "http://xml.org/sax/features/namespace-prefixes",
- true);
+ factory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
factory.setValidating(validating);
- //factory.setFeature(
+ // factory.setFeature(
// "http://xml.org/sax/features/validation",
// validating);
@@ -1406,8 +1051,7 @@ class JspDocumentParser
* Exception indicating that a DOCTYPE declaration is present, but
* validation is turned off.
*/
- private static class EnableDTDValidationException
- extends SAXParseException {
+ private static class EnableDTDValidationException extends SAXParseException {
EnableDTDValidationException(String message, Locator loc) {
super(message, loc);
@@ -1427,8 +1071,7 @@ class JspDocumentParser
if (n instanceof Node.CustomTag) {
String bodyType = getBodyType((Node.CustomTag) n);
- return
- TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType);
+ return TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType);
}
return false;
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspReader.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspReader.java
index 47b0794..5244ae4 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspReader.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspReader.java
@@ -1,31 +1,32 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
import java.io.CharArrayWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.List;
import java.util.Vector;
import java.util.jar.JarFile;
-import java.net.URL;
-import java.net.MalformedURLException;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
@@ -47,7 +48,6 @@ import org.apache.sling.scripting.jsp.jasper.JspCompilationContext;
* @author Shawn Bayern
* @author Mark Roth
*/
-
class JspReader {
/**
@@ -109,27 +109,18 @@ class JspReader {
* @throws FileNotFoundException If the JSP file is not found (or is unreadable)
* @throws IOException If an IO-level error occurs, e.g. reading the file
*/
- public JspReader(JspCompilationContext ctxt,
- String fname,
- String encoding,
- JarFile jarFile,
- ErrorDispatcher err)
+ public JspReader(JspCompilationContext ctxt, String fname, String encoding, JarFile jarFile, ErrorDispatcher err)
throws JasperException, FileNotFoundException, IOException {
- this(ctxt, fname, encoding,
- JspUtil.getReader(fname, encoding, jarFile, ctxt, err),
- err);
+ this(ctxt, fname, encoding, JspUtil.getReader(fname, encoding, jarFile, ctxt, err), err);
}
/**
* Constructor: same as above constructor but with initialized reader
* to the file given.
*/
- public JspReader(JspCompilationContext ctxt,
- String fname,
- String encoding,
- InputStreamReader reader,
- ErrorDispatcher err)
+ public JspReader(
+ JspCompilationContext ctxt, String fname, String encoding, InputStreamReader reader, ErrorDispatcher err)
throws JasperException, FileNotFoundException {
this.context = ctxt;
@@ -142,13 +133,13 @@ class JspReader {
}
/**
- * @return JSP compilation context with which this JspReader is
+ * @return JSP compilation context with which this JspReader is
* associated
*/
JspCompilationContext getJspCompilationContext() {
return context;
}
-
+
/**
* Returns the file at the given position in the list.
*
@@ -158,16 +149,16 @@ class JspReader {
String getFile(final int fileid) {
return (String) sourceFiles.get(fileid);
}
-
+
/**
* Checks if the current file has more input.
*
* @return True if more reading is possible
* @throws JasperException if an error occurs
- */
+ */
boolean hasMoreInput() throws JasperException {
if (current.cursor >= current.stream.length) {
- if (singleFile) return false;
+ if (singleFile) return false;
while (popFile()) {
if (current.cursor < current.stream.length) return true;
}
@@ -175,15 +166,14 @@ class JspReader {
}
return true;
}
-
+
int nextChar() throws JasperException {
- if (!hasMoreInput())
- return -1;
-
+ if (!hasMoreInput()) return -1;
+
int ch = current.stream[current.cursor];
current.cursor++;
-
+
if (ch == '\n') {
current.line++;
current.col = 0;
@@ -206,16 +196,14 @@ class JspReader {
Mark oldstart = mark();
reset(start);
CharArrayWriter caw = new CharArrayWriter();
- while (!stop.equals(mark()))
- caw.write(nextChar());
+ while (!stop.equals(mark())) caw.write(nextChar());
caw.close();
reset(oldstart);
return caw.toString();
}
int peekChar() throws JasperException {
- if (!hasMoreInput())
- return -1;
+ if (!hasMoreInput()) return -1;
return current.stream[current.cursor];
}
@@ -266,47 +254,38 @@ class JspReader {
boolean matchesETag(String tagName) throws JasperException {
Mark mark = mark();
- if (!matches("</" + tagName))
- return false;
+ if (!matches("</" + tagName)) return false;
skipSpaces();
- if (nextChar() == '>')
- return true;
+ if (nextChar() == '>') return true;
reset(mark);
return false;
}
- boolean matchesETagWithoutLessThan(String tagName)
- throws JasperException
- {
- Mark mark = mark();
+ boolean matchesETagWithoutLessThan(String tagName) throws JasperException {
+ Mark mark = mark();
- if (!matches("/" + tagName))
- return false;
- skipSpaces();
- if (nextChar() == '>')
- return true;
+ if (!matches("/" + tagName)) return false;
+ skipSpaces();
+ if (nextChar() == '>') return true;
- reset(mark);
- return false;
+ reset(mark);
+ return false;
}
-
/**
* Looks ahead to see if there are optional spaces followed by
* the given String. If so, true is returned and those spaces and
* characters are skipped. If not, false is returned and the
* position is restored to where we were before.
*/
- boolean matchesOptionalSpacesFollowedBy( String s )
- throws JasperException
- {
+ boolean matchesOptionalSpacesFollowedBy(String s) throws JasperException {
Mark mark = mark();
skipSpaces();
- boolean result = matches( s );
- if( !result ) {
- reset( mark );
+ boolean result = matches(s);
+ if (!result) {
+ reset(mark);
}
return result;
@@ -335,14 +314,12 @@ class JspReader {
int limlen = limit.length();
int ch;
- skip:
- for (ret = mark(), ch = nextChar() ; ch != -1 ;
- ret = mark(), ch = nextChar()) {
+ skip:
+ for (ret = mark(), ch = nextChar(); ch != -1; ret = mark(), ch = nextChar()) {
if (ch == limit.charAt(0)) {
Mark restart = mark();
- for (int i = 1 ; i < limlen ; i++) {
- if (peekChar() == limit.charAt(i))
- nextChar();
+ for (int i = 1; i < limlen; i++) {
+ if (peekChar() == limit.charAt(i)) nextChar();
else {
reset(restart);
continue skip;
@@ -368,27 +345,23 @@ class JspReader {
Mark ret = null;
int limlen = limit.length();
int ch;
- int prev = 'x'; // Doesn't matter
-
- skip:
- for (ret = mark(), ch = nextChar() ; ch != -1 ;
- ret = mark(), prev = ch, ch = nextChar()) {
+ int prev = 'x'; // Doesn't matter
+
+ skip:
+ for (ret = mark(), ch = nextChar(); ch != -1; ret = mark(), prev = ch, ch = nextChar()) {
if (ch == '\\' && prev == '\\') {
- ch = 0; // Double \ is not an escape char anymore
- }
- else if (ch == limit.charAt(0) && prev != '\\') {
- for (int i = 1 ; i < limlen ; i++) {
- if (peekChar() == limit.charAt(i))
- nextChar();
- else
- continue skip;
+ ch = 0; // Double \ is not an escape char anymore
+ } else if (ch == limit.charAt(0) && prev != '\\') {
+ for (int i = 1; i < limlen; i++) {
+ if (peekChar() == limit.charAt(i)) nextChar();
+ else continue skip;
}
return ret;
}
}
return null;
}
-
+
/**
* Skip until the given end tag is matched in the stream.
* When returned, the context is positioned past the end of the tag.
@@ -401,8 +374,7 @@ class JspReader {
Mark ret = skipUntil("</" + tag);
if (ret != null) {
skipSpaces();
- if (nextChar() != '>')
- ret = null;
+ if (nextChar() != '>') ret = null;
}
return ret;
}
@@ -423,23 +395,21 @@ class JspReader {
StringBuffer stringBuffer = new StringBuffer();
skipSpaces();
stringBuffer.setLength(0);
-
+
if (!hasMoreInput()) {
return "";
}
int ch = peekChar();
-
+
if (quoted) {
if (ch == '"' || ch == '\'') {
char endQuote = ch == '"' ? '"' : '\'';
- // Consume the open quote:
+ // Consume the open quote:
ch = nextChar();
- for (ch = nextChar(); ch != -1 && ch != endQuote;
- ch = nextChar()) {
- if (ch == '\\')
- ch = nextChar();
+ for (ch = nextChar(); ch != -1 && ch != endQuote; ch = nextChar()) {
+ if (ch == '\\') ch = nextChar();
stringBuffer.append((char) ch);
}
// Check end of quote, skip closing quote:
@@ -456,8 +426,7 @@ class JspReader {
ch = nextChar();
// Take care of the quoting here.
if (ch == '\\') {
- if (peekChar() == '"' || peekChar() == '\'' ||
- peekChar() == '>' || peekChar() == '%')
+ if (peekChar() == '"' || peekChar() == '\'' || peekChar() == '>' || peekChar() == '%')
ch = nextChar();
}
stringBuffer.append((char) ch);
@@ -472,7 +441,6 @@ class JspReader {
singleFile = val;
}
-
/**
* Gets the URL for the given path name.
*
@@ -480,14 +448,13 @@ class JspReader {
*
* @return URL for the given path name.
*
- * @exception MalformedURLException if the path name is not given in
+ * @exception MalformedURLException if the path name is not given in
* the correct form
*/
URL getResource(String path) throws MalformedURLException {
return context.getResource(path);
}
-
/**
* Parse utils - Is current character a token delimiter ?
* Delimiters are currently defined to be =, >, <, ", and ' or any
@@ -496,18 +463,16 @@ class JspReader {
* @return A boolean.
*/
private boolean isDelimiter() throws JasperException {
- if (! isSpace()) {
+ if (!isSpace()) {
int ch = peekChar();
// Look for a single-char work delimiter:
- if (ch == '=' || ch == '>' || ch == '"' || ch == '\''
- || ch == '/') {
+ if (ch == '=' || ch == '>' || ch == '"' || ch == '\'' || ch == '/') {
return true;
}
- // Look for an end-of-comment or end-of-tag:
+ // Look for an end-of-comment or end-of-tag:
if (ch == '-') {
Mark mark = mark();
- if (((ch = nextChar()) == '>')
- || ((ch == '-') && (nextChar() == '>'))) {
+ if (((ch = nextChar()) == '>') || ((ch == '-') && (nextChar() == '>'))) {
reset(mark);
return true;
} else {
@@ -539,7 +504,6 @@ class JspReader {
return sourceFiles.size() - 1;
}
-
/**
* Unregister the source file.
@@ -563,9 +527,8 @@ class JspReader {
* Push a file (and its associated Stream) on the file stack. THe
* current position in the current file is remembered.
*/
- private void pushFile(String file, String encoding,
- InputStreamReader reader)
- throws JasperException, FileNotFoundException {
+ private void pushFile(String file, String encoding, InputStreamReader reader)
+ throws JasperException, FileNotFoundException {
// Register the file
String longName = file;
@@ -574,11 +537,11 @@ class JspReader {
if (fileid == -1) {
// Bugzilla 37407: http://issues.apache.org/bugzilla/show_bug.cgi?id=37407
- if(reader != null) {
+ if (reader != null) {
try {
reader.close();
} catch (Exception any) {
- if(log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
log.debug("Exception closing reader: ", any);
}
}
@@ -592,15 +555,12 @@ class JspReader {
try {
CharArrayWriter caw = new CharArrayWriter();
char buf[] = new char[1024];
- for (int i = 0 ; (i = reader.read(buf)) != -1 ;)
- caw.write(buf, 0, i);
+ for (int i = 0; (i = reader.read(buf)) != -1; ) caw.write(buf, 0, i);
caw.close();
if (current == null) {
- current = new Mark(this, caw.toCharArray(), fileid,
- getFile(fileid), master, encoding);
+ current = new Mark(this, caw.toCharArray(), fileid, getFile(fileid), master, encoding);
} else {
- current.pushStream(caw.toCharArray(), fileid, getFile(fileid),
- longName, encoding);
+ current.pushStream(caw.toCharArray(), fileid, getFile(fileid), longName, encoding);
}
} catch (Throwable ex) {
log.error("Exception parsing file ", ex);
@@ -612,7 +572,7 @@ class JspReader {
try {
reader.close();
} catch (Exception any) {
- if(log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
log.debug("Exception closing reader: ", any);
}
}
@@ -654,4 +614,3 @@ class JspReader {
return false;
}
}
-
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspRuntimeContext.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspRuntimeContext.java
index c544c53..e3e4831 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspRuntimeContext.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspRuntimeContext.java
@@ -1,22 +1,32 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.jsp.JspApplicationContext;
+import javax.servlet.jsp.JspEngineInfo;
+import javax.servlet.jsp.JspFactory;
+import javax.servlet.jsp.PageContext;
+
import java.io.File;
import java.io.FilePermission;
import java.net.URL;
@@ -34,15 +44,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import javax.servlet.Servlet;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.jsp.JspApplicationContext;
-import javax.servlet.jsp.JspEngineInfo;
-import javax.servlet.jsp.JspFactory;
-import javax.servlet.jsp.PageContext;
-
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.sling.api.SlingHttpServletRequest;
@@ -88,28 +89,39 @@ public final class JspRuntimeContext {
private final JspFactory own;
public JspFactoryHandler(final JspFactory orig, final JspFactory own) {
- this.original = (orig instanceof JspFactoryHandler ? ((JspFactoryHandler)orig).original : orig);
+ this.original = (orig instanceof JspFactoryHandler ? ((JspFactoryHandler) orig).original : orig);
this.own = own;
}
private JspFactory getFactory() {
final Integer useOwnFactory = USE_OWN_FACTORY.get();
- if ( useOwnFactory == null || useOwnFactory.intValue() == 0 ) {
+ if (useOwnFactory == null || useOwnFactory.intValue() == 0) {
return this.original;
}
return this.own;
}
@Override
- public PageContext getPageContext(Servlet paramServlet,
+ public PageContext getPageContext(
+ Servlet paramServlet,
ServletRequest paramServletRequest,
- ServletResponse paramServletResponse, String paramString,
- boolean paramBoolean1, int paramInt, boolean paramBoolean2) {
- PageContext context = this.getFactory().getPageContext(paramServlet, paramServletRequest,
- paramServletResponse, paramString, paramBoolean1,
- paramInt, paramBoolean2);
+ ServletResponse paramServletResponse,
+ String paramString,
+ boolean paramBoolean1,
+ int paramInt,
+ boolean paramBoolean2) {
+ PageContext context = this.getFactory()
+ .getPageContext(
+ paramServlet,
+ paramServletRequest,
+ paramServletResponse,
+ paramString,
+ paramBoolean1,
+ paramInt,
+ paramBoolean2);
if (paramServletRequest instanceof SlingHttpServletRequest) {
- SlingBindings slingBindings = (SlingBindings) paramServletRequest.getAttribute(SlingBindings.class.getName());
+ SlingBindings slingBindings =
+ (SlingBindings) paramServletRequest.getAttribute(SlingBindings.class.getName());
if (slingBindings != null) {
context = new SlingJspPageContext(context, slingBindings);
}
@@ -128,8 +140,7 @@ public final class JspRuntimeContext {
}
@Override
- public JspApplicationContext getJspApplicationContext(
- ServletContext paramServletContext) {
+ public JspApplicationContext getJspApplicationContext(ServletContext paramServletContext) {
return this.getFactory().getJspApplicationContext(paramServletContext);
}
@@ -138,7 +149,7 @@ public final class JspRuntimeContext {
*/
public void destroy() {
final JspFactory current = JspFactory.getDefaultFactory();
- if ( current == this ) {
+ if (current == this) {
JspFactory.setDefaultFactory(this.original);
}
}
@@ -146,7 +157,7 @@ public final class JspRuntimeContext {
public void incUsage() {
final Integer count = JspRuntimeContext.USE_OWN_FACTORY.get();
int newCount = 1;
- if ( count != null ) {
+ if (count != null) {
newCount = count + 1;
}
JspRuntimeContext.USE_OWN_FACTORY.set(newCount);
@@ -176,21 +187,21 @@ public final class JspRuntimeContext {
public static JspFactoryHandler initFactoryHandler() {
JspFactoryImpl factory = new JspFactoryImpl();
SecurityClassLoad.securityClassLoad(factory.getClass().getClassLoader());
- if( System.getSecurityManager() != null ) {
+ if (System.getSecurityManager() != null) {
String basePackage = "org.apache.sling.scripting.jsp.jasper.";
try {
- factory.getClass().getClassLoader().loadClass( basePackage +
- "runtime.JspFactoryImpl$PrivilegedGetPageContext");
- factory.getClass().getClassLoader().loadClass( basePackage +
- "runtime.JspFactoryImpl$PrivilegedReleasePageContext");
- factory.getClass().getClassLoader().loadClass( basePackage +
- "runtime.JspRuntimeLibrary");
- factory.getClass().getClassLoader().loadClass( basePackage +
- "runtime.JspRuntimeLibrary$PrivilegedIntrospectHelper");
- factory.getClass().getClassLoader().loadClass( basePackage +
- "runtime.ServletResponseWrapperInclude");
- factory.getClass().getClassLoader().loadClass( basePackage +
- "servlet.JspServletWrapper");
+ factory.getClass()
+ .getClassLoader()
+ .loadClass(basePackage + "runtime.JspFactoryImpl$PrivilegedGetPageContext");
+ factory.getClass()
+ .getClassLoader()
+ .loadClass(basePackage + "runtime.JspFactoryImpl$PrivilegedReleasePageContext");
+ factory.getClass().getClassLoader().loadClass(basePackage + "runtime.JspRuntimeLibrary");
+ factory.getClass()
+ .getClassLoader()
+ .loadClass(basePackage + "runtime.JspRuntimeLibrary$PrivilegedIntrospectHelper");
+ factory.getClass().getClassLoader().loadClass(basePackage + "runtime.ServletResponseWrapperInclude");
+ factory.getClass().getClassLoader().loadClass(basePackage + "servlet.JspServletWrapper");
} catch (ClassNotFoundException ex) {
throw new IllegalStateException(ex);
}
@@ -229,13 +240,15 @@ public final class JspRuntimeContext {
* This web applications ServletContext
*/
private ServletContext context;
+
private Options options;
private PermissionCollection permissionCollection;
/**
* Maps JSP pages to their JspServletWrapper's
*/
- private final ConcurrentHashMap<String, JspServletWrapper> jsps = new ConcurrentHashMap<String, JspServletWrapper>();
+ private final ConcurrentHashMap<String, JspServletWrapper> jsps =
+ new ConcurrentHashMap<String, JspServletWrapper>();
/**
* Maps dependencies to the using jsp.
@@ -250,12 +263,12 @@ public final class JspRuntimeContext {
// ------------------------------------------------------ Public Methods
public void addJspDependencies(final JspServletWrapper jsw, final List<String> deps) {
- if ( deps != null ) {
+ if (deps != null) {
final String jspUri = jsw.getJspUri();
- synchronized ( depToJsp ) {
- for(final String dep : deps) {
+ synchronized (depToJsp) {
+ for (final String dep : deps) {
Set<String> set = depToJsp.get(dep);
- if ( set == null ) {
+ if (set == null) {
set = new HashSet<String>();
depToJsp.put(dep, set);
}
@@ -269,18 +282,19 @@ public final class JspRuntimeContext {
* Handle jsp modifications
*/
public boolean handleModification(final String scriptName, final boolean isRemove) {
- if ( log.isDebugEnabled() ) {
+ if (log.isDebugEnabled()) {
log.debug("Handling modification " + scriptName);
}
final JspServletWrapper wrapper = jsps.remove(scriptName);
- if ( wrapper == null && isRemove ) {
+ if (wrapper == null && isRemove) {
boolean removed = false;
final Path path = new Path(scriptName);
- final Iterator<Map.Entry<String, JspServletWrapper>> iter = jsps.entrySet().iterator();
- while ( iter.hasNext() ) {
+ final Iterator<Map.Entry<String, JspServletWrapper>> iter =
+ jsps.entrySet().iterator();
+ while (iter.hasNext()) {
final Map.Entry<String, JspServletWrapper> entry = iter.next();
- if ( path.matches(entry.getKey()) ) {
+ if (path.matches(entry.getKey())) {
iter.remove();
removed |= handleModification(entry.getKey(), entry.getValue());
}
@@ -302,11 +316,11 @@ public final class JspRuntimeContext {
boolean removed = this.invalidate(wrapper);
final Set<String> deps;
- synchronized ( depToJsp ) {
+ synchronized (depToJsp) {
deps = depToJsp.remove(scriptName);
}
- if ( deps != null ) {
- for(final String dep : deps) {
+ if (deps != null) {
+ for (final String dep : deps) {
removed |= this.invalidate(jsps.remove(dep));
}
}
@@ -317,8 +331,8 @@ public final class JspRuntimeContext {
* Invalidate a wrapper and destroy it.
*/
private boolean invalidate(final JspServletWrapper wrapper) {
- if ( wrapper != null ) {
- if ( log.isDebugEnabled() ) {
+ if (wrapper != null) {
+ if (log.isDebugEnabled()) {
log.debug("Invalidating jsp " + wrapper.getJspUri());
}
wrapper.destroy(true);
@@ -335,7 +349,7 @@ public final class JspRuntimeContext {
*/
public JspServletWrapper addWrapper(final String jspUri, final JspServletWrapper jsw) {
final JspServletWrapper previous = jsps.putIfAbsent(jspUri, jsw);
- if ( previous == null ) {
+ if (previous == null) {
addJspDependencies(jsw, jsw.getDependants());
return jsw;
}
@@ -379,7 +393,7 @@ public final class JspRuntimeContext {
servlets.next().destroy(false);
}
jsps.clear();
- synchronized ( depToJsp ) {
+ synchronized (depToJsp) {
depToJsp.clear();
}
}
@@ -403,51 +417,46 @@ public final class JspRuntimeContext {
// web app context directory, then add a file read permission
// for that directory.
Policy policy = Policy.getPolicy();
- if( policy != null ) {
+ if (policy != null) {
try {
// Get the permissions for the web app context
String docBase = context.getRealPath("/");
- if( docBase == null ) {
+ if (docBase == null) {
docBase = options.getScratchDir().toString();
}
String codeBase = docBase;
- if (!codeBase.endsWith(File.separator)){
+ if (!codeBase.endsWith(File.separator)) {
codeBase = codeBase + File.separator;
}
File contextDir = new File(codeBase);
URL url = contextDir.getCanonicalFile().toURL();
- final CodeSource codeSource = new CodeSource(url,(Certificate[])null);
+ final CodeSource codeSource = new CodeSource(url, (Certificate[]) null);
permissionCollection = policy.getPermissions(codeSource);
// Create a file read permission for web app context directory
- if (!docBase.endsWith(File.separator)){
- permissionCollection.add
- (new FilePermission(docBase,"read"));
+ if (!docBase.endsWith(File.separator)) {
+ permissionCollection.add(new FilePermission(docBase, "read"));
docBase = docBase + File.separator;
} else {
- permissionCollection.add
- (new FilePermission
- (docBase.substring(0,docBase.length() - 1),"read"));
+ permissionCollection.add(new FilePermission(docBase.substring(0, docBase.length() - 1), "read"));
}
docBase = docBase + "-";
- permissionCollection.add(new FilePermission(docBase,"read"));
+ permissionCollection.add(new FilePermission(docBase, "read"));
// Create a file read permission for web app tempdir (work)
// directory
String workDir = options.getScratchDir().toString();
- if (!workDir.endsWith(File.separator)){
- permissionCollection.add
- (new FilePermission(workDir,"read"));
+ if (!workDir.endsWith(File.separator)) {
+ permissionCollection.add(new FilePermission(workDir, "read"));
workDir = workDir + File.separator;
}
workDir = workDir + "-";
- permissionCollection.add(new FilePermission(workDir,"read"));
+ permissionCollection.add(new FilePermission(workDir, "read"));
// Allow the JSP to access org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase
- permissionCollection.add( new RuntimePermission(
- "accessClassInPackage.org.apache.jasper.runtime") );
+ permissionCollection.add(new RuntimePermission("accessClassInPackage.org.apache.jasper.runtime"));
} catch (final Exception e) {
- context.log("Security Init for context failed",e);
+ context.log("Security Init for context failed", e);
}
}
}
@@ -467,5 +476,4 @@ public final class JspRuntimeContext {
return lock;
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspUtil.java b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspUtil.java
index 62feb77..8305d92 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspUtil.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspUtil.java
@@ -1,22 +1,26 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
-
package org.apache.sling.scripting.jsp.jasper.compiler;
+import javax.el.FunctionMapper;
+import javax.servlet.jsp.el.ExpressionEvaluator;
+
import java.io.CharArrayWriter;
import java.io.IOException;
import java.io.InputStream;
@@ -27,9 +31,6 @@ import java.util.Vector;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
-import javax.el.FunctionMapper;
-import javax.servlet.jsp.el.ExpressionEvaluator;
-
import org.apache.el.ExpressionFactoryImpl;
import org.apache.sling.commons.compiler.source.JavaEscapeHelper;
import org.apache.sling.scripting.jsp.jasper.Constants;
@@ -55,39 +56,78 @@ public class JspUtil {
private static final String META_INF_TAGS = "/META-INF/tags/";
// Delimiters for request-time expressions (JSP and XML syntax)
- private static final String OPEN_EXPR = "<%=";
+ private static final String OPEN_EXPR = "<%=";
private static final String CLOSE_EXPR = "%>";
- private static final String OPEN_EXPR_XML = "%=";
+ private static final String OPEN_EXPR_XML = "%=";
private static final String CLOSE_EXPR_XML = "%";
private static int tempSequenceNumber = 0;
- //private static ExpressionEvaluatorImpl expressionEvaluator
- //= new ExpressionEvaluatorImpl();
+ // private static ExpressionEvaluatorImpl expressionEvaluator
+ // = new ExpressionEvaluatorImpl();
- //tc6
- private final static ExpressionEvaluator expressionEvaluator =
- new ExpressionEvaluatorImpl(new ExpressionFactoryImpl());
+ // tc6
+ private static final ExpressionEvaluator expressionEvaluator =
+ new ExpressionEvaluatorImpl(new ExpressionFactoryImpl());
private static final String javaKeywords[] = {
- "abstract", "assert", "boolean", "break", "byte", "case",
- "catch", "char", "class", "const", "continue",
- "default", "do", "double", "else", "enum", "extends",
- "final", "finally", "float", "for", "goto",
- "if", "implements", "import", "instanceof", "int",
- "interface", "long", "native", "new", "package",
- "private", "protected", "public", "return", "short",
- "static", "strictfp", "super", "switch", "synchronized",
- "this", "throws", "transient", "try", "void",
- "volatile", "while" };
+ "abstract",
+ "assert",
+ "boolean",
+ "break",
+ "byte",
+ "case",
+ "catch",
+ "char",
+ "class",
+ "const",
+ "continue",
+ "default",
+ "do",
+ "double",
+ "else",
+ "enum",
+ "extends",
+ "final",
+ "finally",
+ "float",
+ "for",
+ "goto",
+ "if",
+ "implements",
+ "import",
+ "instanceof",
+ "int",
+ "interface",
+ "long",
+ "native",
+ "new",
+ "package",
+ "private",
+ "protected",
+ "public",
+ "return",
+ "short",
+ "static",
+ "strictfp",
+ "super",
+ "switch",
+ "synchronized",
+ "this",
+ "throws",
+ "transient",
+ "try",
+ "void",
+ "volatile",
+ "while"
+ };
public static final int CHUNKSIZE = 1024;
- public static char[] removeQuotes(char []chars) {
+ public static char[] removeQuotes(char[] chars) {
CharArrayWriter caw = new CharArrayWriter();
for (int i = 0; i < chars.length; i++) {
- if (chars[i] == '%' && chars[i+1] == '\\' &&
- chars[i+2] == '>') {
+ if (chars[i] == '%' && chars[i + 1] == '\\' && chars[i + 2] == '>') {
caw.write('%');
caw.write('>');
i = i + 2;
@@ -98,13 +138,12 @@ public class JspUtil {
return caw.toCharArray();
}
- public static char[] escapeQuotes (char []chars) {
+ public static char[] escapeQuotes(char[] chars) {
// Prescan to convert %\> to %>
String s = new String(chars);
while (true) {
int n = s.indexOf("%\\>");
- if (n < 0)
- break;
+ if (n < 0) break;
StringBuffer sb = new StringBuffer(s.substring(0, n));
sb.append("%>");
sb.append(s.substring(n + 3));
@@ -113,7 +152,6 @@ public class JspUtil {
chars = s.toCharArray();
return (chars);
-
// Escape all backslashes not inside a Java string literal
/*
CharArrayWriter caw = new CharArrayWriter();
@@ -138,46 +176,44 @@ public class JspUtil {
* return whether the token is a runtime expression or not.
*/
public static boolean isExpression(String token, boolean isXml) {
- String openExpr;
- String closeExpr;
- if (isXml) {
- openExpr = OPEN_EXPR_XML;
- closeExpr = CLOSE_EXPR_XML;
- } else {
- openExpr = OPEN_EXPR;
- closeExpr = CLOSE_EXPR;
- }
- if (token.startsWith(openExpr) && token.endsWith(closeExpr)) {
- return true;
- } else {
- return false;
- }
+ String openExpr;
+ String closeExpr;
+ if (isXml) {
+ openExpr = OPEN_EXPR_XML;
+ closeExpr = CLOSE_EXPR_XML;
+ } else {
+ openExpr = OPEN_EXPR;
+ closeExpr = CLOSE_EXPR;
+ }
+ if (token.startsWith(openExpr) && token.endsWith(closeExpr)) {
+ return true;
+ } else {
+ return false;
+ }
}
/**
* @return the "expression" part of a runtime expression,
* taking the delimiters out.
*/
- public static String getExpr (String expression, boolean isXml) {
- String returnString;
- String openExpr;
- String closeExpr;
- if (isXml) {
- openExpr = OPEN_EXPR_XML;
- closeExpr = CLOSE_EXPR_XML;
- } else {
- openExpr = OPEN_EXPR;
- closeExpr = CLOSE_EXPR;
- }
- int length = expression.length();
- if (expression.startsWith(openExpr) &&
- expression.endsWith(closeExpr)) {
- returnString = expression.substring(
- openExpr.length(), length - closeExpr.length());
- } else {
- returnString = "";
- }
- return returnString;
+ public static String getExpr(String expression, boolean isXml) {
+ String returnString;
+ String openExpr;
+ String closeExpr;
+ if (isXml) {
+ openExpr = OPEN_EXPR_XML;
+ closeExpr = CLOSE_EXPR_XML;
+ } else {
+ openExpr = OPEN_EXPR;
+ closeExpr = CLOSE_EXPR;
+ }
+ int length = expression.length();
+ if (expression.startsWith(openExpr) && expression.endsWith(closeExpr)) {
+ returnString = expression.substring(openExpr.length(), length - closeExpr.length());
+ } else {
+ returnString = "";
+ }
+ return returnString;
}
/**
@@ -187,9 +223,8 @@ public class JspUtil {
String returnString;
int length = expression.length();
- if (expression.startsWith(OPEN_EXPR)
- && expression.endsWith(CLOSE_EXPR)) {
- returnString = expression.substring (1, length - 1);
+ if (expression.startsWith(OPEN_EXPR) && expression.endsWith(CLOSE_EXPR)) {
+ returnString = expression.substring(1, length - 1);
} else {
returnString = expression;
}
@@ -209,12 +244,14 @@ public class JspUtil {
* "page", "request", "session", and
* "application"
*/
- public static void checkScope(String scope, Node n, ErrorDispatcher err)
- throws JasperException {
- if (scope != null && !scope.equals("page") && !scope.equals("request")
- && !scope.equals("session") && !scope.equals("application")) {
- err.jspError(n, "jsp.error.invalid.scope", scope);
- }
+ public static void checkScope(String scope, Node n, ErrorDispatcher err) throws JasperException {
+ if (scope != null
+ && !scope.equals("page")
+ && !scope.equals("request")
+ && !scope.equals("session")
+ && !scope.equals("application")) {
+ err.jspError(n, "jsp.error.invalid.scope", scope);
+ }
}
/**
@@ -223,40 +260,34 @@ public class JspUtil {
* attributes as well as attributes specified using the jsp:attribute
* standard action.
*/
- public static void checkAttributes(String typeOfTag,
- Node n,
- ValidAttribute[] validAttributes,
- ErrorDispatcher err)
- throws JasperException {
+ public static void checkAttributes(String typeOfTag, Node n, ValidAttribute[] validAttributes, ErrorDispatcher err)
+ throws JasperException {
Attributes attrs = n.getAttributes();
Mark start = n.getStart();
- boolean valid = true;
+ boolean valid = true;
// AttributesImpl.removeAttribute is broken, so we do this...
int tempLength = (attrs == null) ? 0 : attrs.getLength();
- Vector temp = new Vector(tempLength, 1);
+ Vector temp = new Vector(tempLength, 1);
for (int i = 0; i < tempLength; i++) {
String qName = attrs.getQName(i);
- if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:")))
- temp.addElement(qName);
+ if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:"))) temp.addElement(qName);
}
// Add names of attributes specified using jsp:attribute
Node.Nodes tagBody = n.getBody();
- if( tagBody != null ) {
+ if (tagBody != null) {
int numSubElements = tagBody.size();
- for( int i = 0; i < numSubElements; i++ ) {
- Node node = tagBody.getNode( i );
- if( node instanceof Node.NamedAttribute ) {
- String attrName = node.getAttributeValue( "name" );
- temp.addElement( attrName );
- // Check if this value appear in the attribute of the node
- if (n.getAttributeValue(attrName) != null) {
- err.jspError(n, "jsp.error.duplicate.name.jspattribute",
- attrName);
- }
- }
- else {
+ for (int i = 0; i < numSubElements; i++) {
+ Node node = tagBody.getNode(i);
+ if (node instanceof Node.NamedAttribute) {
+ String attrName = node.getAttributeValue("name");
+ temp.addElement(attrName);
+ // Check if this value appear in the attribute of the node
+ if (n.getAttributeValue(attrName) != null) {
+ err.jspError(n, "jsp.error.duplicate.name.jspattribute", attrName);
+ }
+ } else {
// Nothing can come before jsp:attribute, and only
// jsp:body can come after it.
break;
@@ -264,73 +295,66 @@ public class JspUtil {
}
}
- /*
- * First check to see if all the mandatory attributes are present.
- * If so only then proceed to see if the other attributes are valid
- * for the particular tag.
- */
- String missingAttribute = null;
+ /*
+ * First check to see if all the mandatory attributes are present.
+ * If so only then proceed to see if the other attributes are valid
+ * for the particular tag.
+ */
+ String missingAttribute = null;
- for (int i = 0; i < validAttributes.length; i++) {
- int attrPos;
- if (validAttributes[i].mandatory) {
+ for (int i = 0; i < validAttributes.length; i++) {
+ int attrPos;
+ if (validAttributes[i].mandatory) {
attrPos = temp.indexOf(validAttributes[i].name);
- if (attrPos != -1) {
- temp.remove(attrPos);
- valid = true;
- } else {
- valid = false;
- missingAttribute = validAttributes[i].name;
- break;
- }
+ if (attrPos != -1) {
+ temp.remove(attrPos);
+ valid = true;
+ } else {
+ valid = false;
+ missingAttribute = validAttributes[i].name;
+ break;
+ }
+ }
}
- }
- // If mandatory attribute is missing then the exception is thrown
- if (!valid)
- err.jspError(start, "jsp.error.mandatory.attribute", typeOfTag,
- missingAttribute);
+ // If mandatory attribute is missing then the exception is thrown
+ if (!valid) err.jspError(start, "jsp.error.mandatory.attribute", typeOfTag, missingAttribute);
- // Check to see if there are any more attributes for the specified tag.
+ // Check to see if there are any more attributes for the specified tag.
int attrLeftLength = temp.size();
- if (attrLeftLength == 0)
- return;
+ if (attrLeftLength == 0) return;
- // Now check to see if the rest of the attributes are valid too.
- String attribute = null;
+ // Now check to see if the rest of the attributes are valid too.
+ String attribute = null;
- for (int j = 0; j < attrLeftLength; j++) {
- valid = false;
- attribute = (String) temp.elementAt(j);
- for (int i = 0; i < validAttributes.length; i++) {
- if (attribute.equals(validAttributes[i].name)) {
- valid = true;
- break;
- }
+ for (int j = 0; j < attrLeftLength; j++) {
+ valid = false;
+ attribute = (String) temp.elementAt(j);
+ for (int i = 0; i < validAttributes.length; i++) {
+ if (attribute.equals(validAttributes[i].name)) {
+ valid = true;
+ break;
+ }
+ }
+ if (!valid) err.jspError(start, "jsp.error.invalid.attribute", typeOfTag, attribute);
}
- if (!valid)
- err.jspError(start, "jsp.error.invalid.attribute", typeOfTag,
- attribute);
- }
- // XXX *could* move EL-syntax validation here... (sb)
+ // XXX *could* move EL-syntax validation here... (sb)
}
public static String escapeQueryString(String unescString) {
- if ( unescString == null )
- return null;
+ if (unescString == null) return null;
- String escString = "";
- String shellSpChars = "\\\"";
+ String escString = "";
+ String shellSpChars = "\\\"";
- for(int index=0; index<unescString.length(); index++) {
- char nextChar = unescString.charAt(index);
+ for (int index = 0; index < unescString.length(); index++) {
+ char nextChar = unescString.charAt(index);
- if( shellSpChars.indexOf(nextChar) != -1 )
- escString += "\\";
+ if (shellSpChars.indexOf(nextChar) != -1) escString += "\\";
- escString += nextChar;
- }
- return escString;
+ escString += nextChar;
+ }
+ return escString;
}
/**
@@ -339,7 +363,7 @@ public class JspUtil {
public static String escapeXml(String s) {
if (s == null) return null;
StringBuffer sb = new StringBuffer();
- for(int i=0; i<s.length(); i++) {
+ for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '<') {
sb.append("<");
@@ -363,47 +387,45 @@ public class JspUtil {
* string <tt>with</tt>.
*/
public static String replace(String name, char replace, String with) {
- StringBuffer buf = new StringBuffer();
- int begin = 0;
- int end;
- int last = name.length();
-
- while (true) {
- end = name.indexOf(replace, begin);
- if (end < 0) {
- end = last;
- }
- buf.append(name.substring(begin, end));
- if (end == last) {
- break;
+ StringBuffer buf = new StringBuffer();
+ int begin = 0;
+ int end;
+ int last = name.length();
+
+ while (true) {
+ end = name.indexOf(replace, begin);
+ if (end < 0) {
+ end = last;
+ }
+ buf.append(name.substring(begin, end));
+ if (end == last) {
+ break;
+ }
+ buf.append(with);
+ begin = end + 1;
}
- buf.append(with);
- begin = end + 1;
- }
- return buf.toString();
+ return buf.toString();
}
public static class ValidAttribute {
- String name;
- boolean mandatory;
- boolean rtexprvalue; // not used now
-
- public ValidAttribute (String name, boolean mandatory,
- boolean rtexprvalue )
- {
- this.name = name;
- this.mandatory = mandatory;
+ String name;
+ boolean mandatory;
+ boolean rtexprvalue; // not used now
+
+ public ValidAttribute(String name, boolean mandatory, boolean rtexprvalue) {
+ this.name = name;
+ this.mandatory = mandatory;
this.rtexprvalue = rtexprvalue;
}
- public ValidAttribute (String name, boolean mandatory) {
- this( name, mandatory, false );
- }
+ public ValidAttribute(String name, boolean mandatory) {
+ this(name, mandatory, false);
+ }
- public ValidAttribute (String name) {
- this (name, false);
- }
+ public ValidAttribute(String name) {
+ this(name, false);
+ }
}
/**
@@ -417,15 +439,15 @@ public class JspUtil {
* @return the boolean value associated with the string s
*/
public static boolean booleanValue(String s) {
- boolean b = false;
- if (s != null) {
- if (s.equalsIgnoreCase("yes")) {
- b = true;
- } else {
- b = Boolean.valueOf(s).booleanValue();
+ boolean b = false;
+ if (s != null) {
+ if (s.equalsIgnoreCase("yes")) {
+ b = true;
+ } else {
+ b = Boolean.valueOf(s).booleanValue();
+ }
}
- }
- return b;
+ return b;
}
/**
@@ -437,48 +459,35 @@ public class JspUtil {
* name represents a primitive type, in which case it is converted to a
* <tt>Class</tt> object by appending ".class" to it (e.g., "int.class").
*/
- public static Class toClass(String type, ClassLoader loader)
- throws ClassNotFoundException {
-
- Class c = null;
- int i0 = type.indexOf('[');
- int dims = 0;
- if (i0 > 0) {
- // This is an array. Count the dimensions
- for (int i = 0; i < type.length(); i++) {
- if (type.charAt(i) == '[')
- dims++;
+ public static Class toClass(String type, ClassLoader loader) throws ClassNotFoundException {
+
+ Class c = null;
+ int i0 = type.indexOf('[');
+ int dims = 0;
+ if (i0 > 0) {
+ // This is an array. Count the dimensions
+ for (int i = 0; i < type.length(); i++) {
+ if (type.charAt(i) == '[') dims++;
+ }
+ type = type.substring(0, i0);
}
- type = type.substring(0, i0);
- }
- if ("boolean".equals(type))
- c = boolean.class;
- else if ("char".equals(type))
- c = char.class;
- else if ("byte".equals(type))
- c = byte.class;
- else if ("short".equals(type))
- c = short.class;
- else if ("int".equals(type))
- c = int.class;
- else if ("long".equals(type))
- c = long.class;
- else if ("float".equals(type))
- c = float.class;
- else if ("double".equals(type))
- c = double.class;
- else if (type.indexOf('[') < 0)
- c = loader.loadClass(type);
-
- if (dims == 0)
- return c;
-
- if (dims == 1)
- return java.lang.reflect.Array.newInstance(c, 1).getClass();
-
... 27652 lines suppressed ...
(sling-org-apache-sling-scripting-jsp) 03/03: SLING-12438 - Update Sling Scripting JSP to parent version 60
Posted by js...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jsedding pushed a commit to branch jsedding/SLING-12438-update-parent
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-jsp.git
commit dde34190291bc35d20329f43fbd45572c0158ee7
Author: Julian Sedding <js...@apache.org>
AuthorDate: Fri Sep 20 11:01:46 2024 +0200
SLING-12438 - Update Sling Scripting JSP to parent version 60
- ignore spotless code reformatting commit in git blame
---
.git-blame-ignore-revs | 1 +
1 file changed, 1 insertion(+)
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 0000000..fa58b2d
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1 @@
+13325d09ebd5822bc842f8cf3dd49b0499dc02b0