diff --git a/assembly/pom.xml b/assembly/pom.xml
index de4176997..56a801de1 100644
--- a/assembly/pom.xml
+++ b/assembly/pom.xml
@@ -216,11 +216,6 @@
struts2-json-plugin
-
- org.apache.struts
- struts2-embeddedjsp-plugin
-
-
org.apache.strutsstruts2-gxp-plugin
diff --git a/assembly/src/main/assembly/all.xml b/assembly/src/main/assembly/all.xml
index 8e83663f9..8dcb1856c 100644
--- a/assembly/src/main/assembly/all.xml
+++ b/assembly/src/main/assembly/all.xml
@@ -133,10 +133,6 @@
../plugins/convention/target/apidocsdocs/struts2-plugins/struts2-convention-plugin/apidocs
-
- ../plugins/embeddedjsp/target/apidocs
- docs/struts2-plugins/struts2-embeddedjsp-plugin/apidocs
- ../plugins/gxp/target/apidocsdocs/struts2-plugins/struts2-gxp-plugin/apidocs
diff --git a/assembly/src/main/assembly/docs.xml b/assembly/src/main/assembly/docs.xml
index 3cd720c94..641419eb9 100644
--- a/assembly/src/main/assembly/docs.xml
+++ b/assembly/src/main/assembly/docs.xml
@@ -68,10 +68,6 @@
../plugins/convention/target/apidocsdocs/struts2-plugins/struts2-convention-plugin/apidocs
-
- ../plugins/embeddedjsp/target/apidocs
- docs/struts2-plugins/struts2-embeddedjsp-plugin/apidocs
- ../plugins/gxp/target/apidocsdocs/struts2-plugins/struts2-gxp-plugin/apidocs
diff --git a/bom/pom.xml b/bom/pom.xml
index 5a967776b..0e184e248 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -81,11 +81,6 @@
struts2-config-browser-plugin${struts-version.version}
-
- org.apache.struts
- struts2-embeddedjsp-plugin
- ${struts-version.version}
- org.apache.strutsstruts2-gxp-plugin
diff --git a/plugins/embeddedjsp/README.md b/plugins/embeddedjsp/README.md
deleted file mode 100644
index 7064762e2..000000000
--- a/plugins/embeddedjsp/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-# Struts 2 EmbeddedJSP plugin
-This plugin is deprecated and it will be removed soon, **please do not use it**!
diff --git a/plugins/embeddedjsp/pom.xml b/plugins/embeddedjsp/pom.xml
deleted file mode 100644
index 6939e81fd..000000000
--- a/plugins/embeddedjsp/pom.xml
+++ /dev/null
@@ -1,102 +0,0 @@
-
-
-
- 4.0.0
-
- org.apache.struts
- struts2-plugins
- 6.4.0-SNAPSHOT
-
-
- struts2-embeddedjsp-plugin
- jar
- DEPRECATED: Struts 2 Embedded JSP Plugin, since 6.0.0
-
-
-
- org.apache.struts
- struts2-velocity-plugin
-
-
- org.springframework
- spring-test
- test
-
-
- org.springframework
- spring-core
- test
-
-
- org.springframework
- spring-web
- test
-
-
- org.easymock
- easymock
- test
-
-
- taglibs
- request
- test
-
-
- org.apache.tomcat
- tomcat-juli
-
-
- org.glassfish.web
- jakarta.servlet.jsp.jstl
- test
-
-
- jakarta.servlet.jsp.jstl
- jakarta.servlet.jsp.jstl-api
- test
-
-
- org.apache.tomcat
- tomcat-jasper
- provided
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- @{argLine}
-
- ${project.build.testOutputDirectory}/jsps.jar
-
-
-
-
-
-
- UTF-8
-
-
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/EmbeddedJSPResult.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/EmbeddedJSPResult.java
deleted file mode 100644
index a3afce46b..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/EmbeddedJSPResult.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.struts2;
-
-import com.opensymphony.xwork2.ActionInvocation;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.struts2.result.StrutsResultSupport;
-
-/**
- * Can render jsps from the classpath. "includes" in the jsps must not use relative paths
- */
-public class EmbeddedJSPResult extends StrutsResultSupport {
- protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
- JSPRuntime.handle(StringUtils.removeStart(finalLocation, "/"));
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPLoader.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPLoader.java
deleted file mode 100644
index cdc5d6aa0..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPLoader.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * 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.struts2;
-
-import com.opensymphony.xwork2.FileManager;
-import com.opensymphony.xwork2.FileManagerFactory;
-import com.opensymphony.xwork2.util.finder.ClassLoaderInterface;
-import com.opensymphony.xwork2.util.finder.ClassLoaderInterfaceDelegate;
-import com.opensymphony.xwork2.util.finder.UrlSet;
-import com.opensymphony.xwork2.util.fs.DefaultFileManager;
-import com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.LogManager;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.ObjectUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.struts2.compiler.MemoryClassLoader;
-import org.apache.struts2.compiler.MemoryJavaFileObject;
-import org.apache.struts2.jasper.JasperException;
-import org.apache.struts2.jasper.JspC;
-
-import jakarta.servlet.Servlet;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.ServletException;
-import jakarta.servlet.jsp.JspPage;
-import javax.tools.DiagnosticCollector;
-import javax.tools.FileObject;
-import javax.tools.ForwardingJavaFileManager;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.security.CodeSource;
-import java.security.ProtectionDomain;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Uses jasper to extract a JSP from the classpath to a file and compile it. The classpath used for
- * compilation is built by finding all the jar files using the current class loader (Thread), plus
- * directories.
- */
-public class JSPLoader {
- private static final Logger LOG = LogManager.getLogger(JSPLoader.class);
-
- private static MemoryClassLoader classLoader = new MemoryClassLoader();
- private static final String DEFAULT_PACKAGE = "org.apache.struts2.jsp";
-
- private static final Pattern PACKAGE_PATTERN = Pattern.compile("package (.*?);");
- private static final Pattern CLASS_PATTERN = Pattern.compile("public final class (.*?) ");
-
- public Servlet load(String location) throws Exception {
- location = StringUtils.substringBeforeLast(location, "?");
-
- LOG.debug("Compiling JSP [{}]", location);
-
- //use Jasper to compile the JSP into java code
- JspC jspC = compileJSP(location);
- String source = jspC.getSourceCode();
-
- //System.out.print(source);
-
- String className = extractClassName(source);
-
- //use Java Compiler API to compile the java code into a class
- //the tlds that were discovered are added (their jars) to the classpath
- compileJava(className, source, jspC.getTldAbsolutePaths());
-
- //load the class that was just built
- Class clazz = Class.forName(className, false, classLoader);
- return createServlet(clazz);
- }
-
- private String extractClassName(String source) {
- Matcher matcher = PACKAGE_PATTERN.matcher(source);
- matcher.find();
- String packageName = matcher.group(1);
-
- matcher = CLASS_PATTERN.matcher(source);
- matcher.find();
- String className = matcher.group(1);
-
- return packageName + "." + className;
- }
-
- /**
- * Creates and inits a servlet
- */
- private Servlet createServlet(Class clazz) throws IllegalAccessException, InstantiationException, ServletException {
- JSPServletConfig config = new JSPServletConfig(ServletActionContext.getServletContext());
-
- Servlet servlet = (Servlet) clazz.newInstance();
- servlet.init(config);
-
- /*
- there is no need to call JspPage.init explicitly because Jasper's
- JSP base classe HttpJspBase.init(ServletConfig) calls:
- jspInit();
- _jspInit();
- */
-
- return servlet;
- }
-
- /**
- * Compiles the given source code into java bytecode
- */
- private void compileJava(String className, final String source, Set extraClassPath) throws IOException {
- LOG.trace("Compiling [{}], source: [{}]", className, source);
-
- JavaCompiler compiler =ToolProvider.getSystemJavaCompiler();
- DiagnosticCollector diagnostics = new DiagnosticCollector();
-
- //the generated bytecode is fed to the class loader
- JavaFileManager jfm = new
- ForwardingJavaFileManager(
- compiler.getStandardFileManager(diagnostics, null, null)) {
-
- @Override
- public JavaFileObject getJavaFileForOutput(Location location,
- String name,
- JavaFileObject.Kind kind,
- FileObject sibling) throws IOException {
- MemoryJavaFileObject fileObject = new MemoryJavaFileObject(name, kind);
- classLoader.addMemoryJavaFileObject(name, fileObject);
- return fileObject;
- }
- };
-
- //read java source code from memory
- String fileName = className.replace('.', '/') + ".java";
- SimpleJavaFileObject sourceCodeObject = new SimpleJavaFileObject(toURI(fileName), JavaFileObject.Kind.SOURCE) {
- @Override
- public CharSequence getCharContent(boolean
- ignoreEncodingErrors)
- throws IOException, IllegalStateException,
- UnsupportedOperationException {
- return source;
- }
-
- };
-
- //build classpath
- //some entries will be added multiple times, hence the set
- List optionList = new ArrayList();
- Set classPath = new HashSet();
-
- //find available jars
- ClassLoaderInterface classLoaderInterface = getClassLoaderInterface();
- UrlSet urlSet = new UrlSet(classLoaderInterface);
-
- //find jars
- List urls = urlSet.getUrls();
-
- if (urls != null && urls.size() > 0) {
- final FileManagerFactory fileManagerFactoryGetInstance = ServletActionContext.getActionContext().getInstance(FileManagerFactory.class);
- final FileManagerFactory contextFileManagerFactory = (fileManagerFactoryGetInstance != null ? fileManagerFactoryGetInstance : (FileManagerFactory) ServletActionContext.getActionContext().get(StrutsConstants.STRUTS_FILE_MANAGER_FACTORY));
- final FileManagerFactory fileManagerFactory = (contextFileManagerFactory != null ? contextFileManagerFactory : new DefaultFileManagerFactory());
- final FileManager fileManagerGetInstance = fileManagerFactory.getFileManager();
- final FileManager contextFileManager = (fileManagerGetInstance != null ? fileManagerGetInstance : (FileManager) ServletActionContext.getActionContext().get(StrutsConstants.STRUTS_FILE_MANAGER));
- final FileManager fileManager = (contextFileManager != null ? contextFileManager : new DefaultFileManager());
- for (URL url : urls) {
- URL normalizedUrl = fileManager.normalizeToFileProtocol(url);
- File file = FileUtils.toFile(ObjectUtils.defaultIfNull(normalizedUrl, url));
- if (file.exists())
- classPath.add(file.getAbsolutePath());
- }
- }
-
- //these should be in the list already, but I am feeling paranoid
- //this jar
- classPath.add(getJarUrl(EmbeddedJSPResult.class));
- //servlet api
- classPath.add(getJarUrl(Servlet.class));
- //jsp api
- classPath.add(getJarUrl(JspPage.class));
-
- try {
- Class instanceManager = Class.forName("org.apache.tomcat.InstanceManager");
- classPath.add(getJarUrl(instanceManager));
- } catch (ClassNotFoundException e) {
- //ok ignore
- }
-
- //add extra classpath entries (jars where tlds were found will be here)
- for (Iterator iterator = extraClassPath.iterator(); iterator.hasNext();) {
- String entry = iterator.next();
- classPath.add(entry);
- }
-
- String classPathString = StringUtils.join(classPath, File.pathSeparator);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Compiling [#0] with classpath [#1]", className, classPathString);
- }
-
- optionList.addAll(Arrays.asList("-classpath", classPathString));
-
- //compile
- JavaCompiler.CompilationTask task = compiler.getTask(
- null, jfm, diagnostics, optionList, null,
- Arrays.asList(sourceCodeObject));
-
- if (!task.call()) {
- throw new StrutsException("Compilation failed:" + diagnostics.getDiagnostics().get(0).toString());
- }
- }
-
- protected String getJarUrl(Class clazz) {
- ProtectionDomain protectionDomain = clazz.getProtectionDomain();
- CodeSource codeSource = protectionDomain.getCodeSource();
- URL loc = codeSource.getLocation();
- File file = FileUtils.toFile(loc);
- return file.getAbsolutePath();
- }
-
- private JspC compileJSP(String location) throws JasperException {
- JspC jspC = new JspC();
- jspC.setClassLoaderInterface(getClassLoaderInterface());
- jspC.setCompile(false);
- jspC.setJspFiles(location);
- jspC.setPackage(DEFAULT_PACKAGE);
- jspC.execute();
- return jspC;
- }
-
- private ClassLoaderInterface getClassLoaderInterface() {
- ClassLoaderInterface classLoaderInterface = null;
- ServletContext ctx = ServletActionContext.getServletContext();
- if (ctx != null)
- classLoaderInterface = (ClassLoaderInterface) ctx.getAttribute(ClassLoaderInterface.CLASS_LOADER_INTERFACE);
-
- return (ClassLoaderInterface) ObjectUtils.defaultIfNull(classLoaderInterface, new ClassLoaderInterfaceDelegate(JSPLoader.class.getClassLoader()));
- }
-
- private static URI toURI(String name) {
- try {
- return new URI(name);
- } catch (URISyntaxException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPRuntime.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPRuntime.java
deleted file mode 100644
index d98e52559..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPRuntime.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.struts2;
-
-import com.opensymphony.xwork2.ActionContext;
-import org.apache.struts2.dispatcher.Parameter;
-import org.apache.struts2.url.QueryStringParser;
-
-import jakarta.servlet.Servlet;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import jakarta.servlet.jsp.HttpJspPage;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Maintains a cache of jsp locations -> servlet instances for those jsps. When a jsp is requested
- * from the cache, the cache will block if the jsp was not compiled already, and wait for the compilation
- */
-public abstract class JSPRuntime {
- //maps from jsp path -> pagelet
- protected static final ServletCache servletCache = new ServletCache();
-
- public static void clearCache() {
- servletCache.clear();
- }
-
- public static void handle(String location) throws Exception {
- handle(location, false);
- }
-
- public static void handle(String location, boolean flush) throws Exception {
- final HttpServletResponse response = ServletActionContext.getResponse();
- final HttpServletRequest request = ServletActionContext.getRequest();
-
- int i = location.indexOf("?");
- if (i > 0) {
- //extract params from the url and add them to the request
- ActionContext actionContext = ServletActionContext.getActionContext();
- if (actionContext == null) {
- throw new StrutsException("Running out of action context!");
- }
- final QueryStringParser parser = actionContext.getInstance(QueryStringParser.class);
- String query = location.substring(i + 1);
- Map queryParams = parser.parse(query, true);
- if (queryParams != null && !queryParams.isEmpty()) {
- Map newParams = new HashMap<>();
- for (Map.Entry entry : queryParams.entrySet()) {
- newParams.put(entry.getKey(), new Parameter.Request(entry.getKey(), entry.getValue()));
- }
- ActionContext.getContext().getParameters().appendAll(newParams);
- }
- location = location.substring(0, i);
- }
-
- Servlet servlet = servletCache.get(location);
- HttpJspPage page = (HttpJspPage) servlet;
-
- page._jspService(request, response);
- if (flush)
- response.flushBuffer();
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPServletConfig.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPServletConfig.java
deleted file mode 100644
index 1e9de4dbe..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPServletConfig.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.struts2;
-
-import jakarta.servlet.ServletConfig;
-import jakarta.servlet.ServletContext;
-import java.util.Collections;
-import java.util.Enumeration;
-
-/**
- * Used to init the servlets for the jsps
- */
-public class JSPServletConfig implements ServletConfig {
- private final Enumeration EMPTY_ENUMERATION = Collections.enumeration(Collections.EMPTY_LIST);
-
- private ServletContext servletContext;
-
- public JSPServletConfig(ServletContext servletContext) {
- this.servletContext = servletContext;
- }
-
- public String getInitParameter(String name) {
- return null;
- }
-
- public Enumeration getInitParameterNames() {
- return EMPTY_ENUMERATION;
- }
-
- public ServletContext getServletContext() {
- return servletContext;
- }
-
- public String getServletName() {
- return null;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/ServletCache.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/ServletCache.java
deleted file mode 100644
index 8afdb14a9..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/ServletCache.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.struts2;
-
-import jakarta.servlet.Servlet;
-import java.util.concurrent.*;
-
-/**
- * Caches servlet instances by jsp location. If a requested jsp is not in the cache, "get"
- * will block and wait for the jsp to be loaded
- */
-public class ServletCache {
- protected final ConcurrentMap> cache
- = new ConcurrentHashMap>();
-
- private final JSPLoader jspLoader = new JSPLoader();
-
- public void clear() {
- cache.clear();
- }
-
- public Servlet get(final String location) throws InterruptedException {
- while (true) {
- Future future = cache.get(location);
- if (future == null) {
- Callable loadJSPCallable = new Callable() {
- public Servlet call() throws Exception {
- return jspLoader.load(location);
- }
- };
- FutureTask futureTask = new FutureTask(loadJSPCallable);
- future = cache.putIfAbsent(location, futureTask);
- if (future == null) {
- future = futureTask;
- futureTask.run();
- }
- }
- try {
- return future.get();
- } catch (CancellationException e) {
- cache.remove(location, future);
- } catch (ExecutionException e) {
- throw launderThrowable(e.getCause());
- }
- }
- }
-
- public static RuntimeException launderThrowable(Throwable t) {
- if (t instanceof RuntimeException)
- return (RuntimeException) t;
- else if (t instanceof Error)
- throw (Error) t;
- else
- throw new IllegalStateException(t);
- }
-
-}
-
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/compiler/MemoryClassLoader.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/compiler/MemoryClassLoader.java
deleted file mode 100644
index 06c52300d..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/compiler/MemoryClassLoader.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.struts2.compiler;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Keeps a cache of class name -> MemoryJavaFileObject. If the requested class name is in the cache
- * a new class is defined for it, otherwise findClass delegates to the parent class loader
- */
-public class MemoryClassLoader extends ClassLoader {
- private Map cachedObjects = new ConcurrentHashMap<>();
-
- public MemoryClassLoader() {
- //without this, the tests will not run, because the tests are loaded by a custom classloader
- //so the classes referenced from the compiled code will not be found by the System Class Loader because
- //the target dir is not part of the classpath used when calling the jvm to execute the tests
- super(Thread.currentThread().getContextClassLoader());
- }
-
- @Override
- protected Class> findClass(String name) throws
- ClassNotFoundException {
- MemoryJavaFileObject fileObject = cachedObjects.get(name);
- if (fileObject != null) {
- byte[] bytes = fileObject.toByteArray();
- return defineClass(name, bytes, 0, bytes.length);
- }
- return super.findClass(name);
- }
-
- public void addMemoryJavaFileObject(String jsp, MemoryJavaFileObject memoryJavaFileObject) {
- cachedObjects.put(jsp, memoryJavaFileObject);
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/compiler/MemoryJavaFileObject.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/compiler/MemoryJavaFileObject.java
deleted file mode 100644
index b9923c8fb..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/compiler/MemoryJavaFileObject.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.struts2.compiler;
-
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-import java.io.*;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-/**
- * Captures the output of the java compiler in memory
- */
-public class MemoryJavaFileObject extends SimpleJavaFileObject {
-
- private ByteArrayOutputStream out;
-
- public MemoryJavaFileObject(String name, JavaFileObject.Kind kind) {
- super(toURI(name), kind);
- }
-
- public InputStream openInputStream() throws IOException,
- IllegalStateException, UnsupportedOperationException {
- return new ByteArrayInputStream(out.toByteArray());
- }
-
- public OutputStream openOutputStream() throws IOException,
- IllegalStateException, UnsupportedOperationException {
- return out = new ByteArrayOutputStream();
- }
-
- private static URI toURI(String name) {
- try {
- return new URI(name);
- } catch (URISyntaxException e) {
- throw new RuntimeException(e);
- }
- }
-
- public byte[] toByteArray() {
- return out.toByteArray();
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/ExpressionFactoryImpl.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/ExpressionFactoryImpl.java
deleted file mode 100644
index 022f437ac..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/ExpressionFactoryImpl.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.struts2.el;
-
-import jakarta.el.ELContext;
-import jakarta.el.ExpressionFactory;
-import jakarta.el.MethodExpression;
-import jakarta.el.ValueExpression;
-
-import org.apache.struts2.el.lang.ELSupport;
-import org.apache.struts2.el.lang.ExpressionBuilder;
-import org.apache.struts2.el.util.MessageFactory;
-
-/**
- * @see jakarta.el.ExpressionFactory
- *
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public class ExpressionFactoryImpl extends ExpressionFactory {
-
- /**
- *
- */
- public ExpressionFactoryImpl() {
- super();
- }
-
- public Object coerceToType(Object obj, Class type) {
- return ELSupport.coerceToType(obj, type);
- }
-
- public MethodExpression createMethodExpression(ELContext context,
- String expression, Class> expectedReturnType,
- Class>[] expectedParamTypes) {
- if (expectedParamTypes == null) {
- throw new NullPointerException(MessageFactory
- .get("error.method.nullParms"));
- }
- ExpressionBuilder builder = new ExpressionBuilder(expression, context);
- return builder.createMethodExpression(expectedReturnType,
- expectedParamTypes);
- }
-
- public ValueExpression createValueExpression(ELContext context,
- String expression, Class expectedType) {
- if (expectedType == null) {
- throw new NullPointerException(MessageFactory
- .get("error.value.expectedType"));
- }
- ExpressionBuilder builder = new ExpressionBuilder(expression, context);
- return builder.createValueExpression(expectedType);
- }
-
- public ValueExpression createValueExpression(Object instance,
- Class expectedType) {
- if (expectedType == null) {
- throw new NullPointerException(MessageFactory
- .get("error.value.expectedType"));
- }
- return new ValueExpressionLiteral(instance, expectedType);
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/MethodExpressionImpl.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/MethodExpressionImpl.java
deleted file mode 100644
index 8a62b39fe..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/MethodExpressionImpl.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * 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.struts2.el;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-import jakarta.el.ELContext;
-import jakarta.el.ELException;
-import jakarta.el.ELResolver;
-import jakarta.el.Expression;
-import jakarta.el.ExpressionFactory;
-import jakarta.el.FunctionMapper;
-import jakarta.el.MethodExpression;
-import jakarta.el.MethodInfo;
-import jakarta.el.MethodNotFoundException;
-import jakarta.el.PropertyNotFoundException;
-import jakarta.el.VariableMapper;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-import org.apache.struts2.el.lang.ExpressionBuilder;
-import org.apache.struts2.el.parser.Node;
-import org.apache.struts2.el.util.ReflectionUtil;
-
-/**
- * An Expression that refers to a method on an object.
- *
- *
- * The {@link ExpressionFactory#createMethodExpression} method
- * can be used to parse an expression string and return a concrete instance
- * of MethodExpression that encapsulates the parsed expression.
- * The {@link FunctionMapper} is used at parse time, not evaluation time,
- * so one is not needed to evaluate an expression using this class.
- * However, the {@link ELContext} is needed at evaluation time.
- *
- *
The {@link #getMethodInfo} and {@link #invoke} methods will evaluate the
- * expression each time they are called. The {@link ELResolver} in the
- * ELContext is used to resolve the top-level variables and to
- * determine the behavior of the . and []
- * operators. For any of the two methods, the {@link ELResolver#getValue}
- * method is used to resolve all properties up to but excluding the last
- * one. This provides the base object on which the method
- * appears. If the base object is null, a
- * NullPointerException must be thrown. At the last resolution,
- * the final property is then coerced to a String,
- * which provides the name of the method to be found. A method matching the
- * name and expected parameters provided at parse time is found and it is
- * either queried or invoked (depending on the method called on this
- * MethodExpression).
- * The result is true if and only if the argument is not
- * null, is an Expression object that is the
- * of the same type (ValueExpression or
- * MethodExpression), and has an identical parsed
- * representation.
- *
- *
- *
- * Note that two expressions can be equal if their expression Strings are
- * different. For example, ${fn1:foo()} and
- * ${fn2:foo()} are equal if their corresponding
- * FunctionMappers mapped fn1:foo and
- * fn2:foo to the same method.
- *
- *
- * @param obj
- * the Object to test for equality.
- * @return true if obj equals this
- * Expression; false otherwise.
- * @see java.util.Hashtable
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- return (obj instanceof MethodExpressionImpl && obj.hashCode() == this
- .hashCode());
- }
-
- /**
- * Returns the original String used to create this Expression,
- * unmodified.
- *
- *
- * This is used for debugging purposes but also for the purposes of
- * comparison (e.g. to ensure the expression in a configuration file has not
- * changed).
- *
- *
- *
- * This method does not provide sufficient information to re-create an
- * expression. Two different expressions can have exactly the same
- * expression string but different function mappings. Serialization should
- * be used to save and restore the state of an Expression.
- *
- *
- * @return The original expression String.
- *
- * @see jakarta.el.Expression#getExpressionString()
- */
- public String getExpressionString() {
- return this.expr;
- }
-
- /**
- * Evaluates the expression relative to the provided context, and returns
- * information about the actual referenced method.
- *
- * @param context
- * The context of this evaluation
- * @return an instance of MethodInfo containing information
- * about the method the expression evaluated to.
- * @throws NullPointerException
- * if context is null or the base object is
- * null on the last resolution.
- * @throws PropertyNotFoundException
- * if one of the property resolutions failed because a specified
- * variable or property does not exist or is not readable.
- * @throws MethodNotFoundException
- * if no suitable method can be found.
- * @throws ELException
- * if an exception was thrown while performing property or
- * variable resolution. The thrown exception must be included as
- * the cause property of this exception, if available.
- * @see jakarta.el.MethodExpression#getMethodInfo(jakarta.el.ELContext)
- */
- public MethodInfo getMethodInfo(ELContext context)
- throws PropertyNotFoundException, MethodNotFoundException,
- ELException {
- Node n = this.getNode();
- EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
- this.varMapper);
- return n.getMethodInfo(ctx, this.paramTypes);
- }
-
- /**
- * @return
- * @throws ELException
- */
- private Node getNode() throws ELException {
- if (this.node == null) {
- this.node = ExpressionBuilder.createNode(this.expr);
- }
- return this.node;
- }
-
- /**
- * Returns the hash code for this Expression.
- *
- *
- * See the note in the {@link #equals} method on how two expressions can be
- * equal if their expression Strings are different. Recall that if two
- * objects are equal according to the equals(Object) method,
- * then calling the hashCode method on each of the two
- * objects must produce the same integer result. Implementations must take
- * special note and implement hashCode correctly.
- *
- *
- * @return The hash code for this Expression.
- * @see #equals
- * @see java.util.Hashtable
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return this.expr.hashCode();
- }
-
- /**
- * Evaluates the expression relative to the provided context, invokes the
- * method that was found using the supplied parameters, and returns the
- * result of the method invocation.
- *
- * @param context
- * The context of this evaluation.
- * @param params
- * The parameters to pass to the method, or null
- * if no parameters.
- * @return the result of the method invocation (null if the
- * method has a void return type).
- * @throws NullPointerException
- * if context is null or the base object is
- * null on the last resolution.
- * @throws PropertyNotFoundException
- * if one of the property resolutions failed because a specified
- * variable or property does not exist or is not readable.
- * @throws MethodNotFoundException
- * if no suitable method can be found.
- * @throws ELException
- * if an exception was thrown while performing property or
- * variable resolution. The thrown exception must be included as
- * the cause property of this exception, if available. If the
- * exception thrown is an InvocationTargetException,
- * extract its cause and pass it to the
- * ELException constructor.
- * @see jakarta.el.MethodExpression#invoke(jakarta.el.ELContext,
- * java.lang.Object[])
- */
- public Object invoke(ELContext context, Object[] params)
- throws PropertyNotFoundException, MethodNotFoundException,
- ELException {
- EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
- this.varMapper);
- return this.getNode().invoke(ctx, this.paramTypes, params);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
- */
- public void readExternal(ObjectInput in) throws IOException,
- ClassNotFoundException {
- this.expr = in.readUTF();
- String type = in.readUTF();
- if (!"".equals(type)) {
- this.expectedType = ReflectionUtil.forName(type);
- }
- this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in
- .readObject()));
- this.fnMapper = (FunctionMapper) in.readObject();
- this.varMapper = (VariableMapper) in.readObject();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
- */
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeUTF(this.expr);
- out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
- : "");
- out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes));
- out.writeObject(this.fnMapper);
- out.writeObject(this.varMapper);
- }
-
- public boolean isLiteralText() {
- return false;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/MethodExpressionLiteral.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/MethodExpressionLiteral.java
deleted file mode 100644
index 4e52893cf..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/MethodExpressionLiteral.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.struts2.el;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-import jakarta.el.ELContext;
-import jakarta.el.ELException;
-import jakarta.el.MethodExpression;
-import jakarta.el.MethodInfo;
-
-import org.apache.struts2.el.lang.ELSupport;
-import org.apache.struts2.el.util.ReflectionUtil;
-
-public class MethodExpressionLiteral extends MethodExpression implements Externalizable {
-
- private Class expectedType;
-
- private String expr;
-
- private Class[] paramTypes;
-
- public MethodExpressionLiteral() {
- // do nothing
- }
-
- public MethodExpressionLiteral(String expr, Class expectedType, Class[] paramTypes) {
- this.expr = expr;
- this.expectedType = expectedType;
- this.paramTypes = paramTypes;
- }
-
- public MethodInfo getMethodInfo(ELContext context) throws ELException {
- return new MethodInfo(this.expr, this.expectedType, this.paramTypes);
- }
-
- public Object invoke(ELContext context, Object[] params) throws ELException {
- if (this.expectedType != null) {
- return ELSupport.coerceToType(this.expr, this.expectedType);
- } else {
- return this.expr;
- }
- }
-
- public String getExpressionString() {
- return this.expr;
- }
-
- public boolean equals(Object obj) {
- return (obj instanceof MethodExpressionLiteral && this.hashCode() == obj.hashCode());
- }
-
- public int hashCode() {
- return this.expr.hashCode();
- }
-
- public boolean isLiteralText() {
- return true;
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- this.expr = in.readUTF();
- String type = in.readUTF();
- if (!"".equals(type)) {
- this.expectedType = ReflectionUtil.forName(type);
- }
- this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in
- .readObject()));
- }
-
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeUTF(this.expr);
- out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
- : "");
- out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes));
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/ValueExpressionImpl.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/ValueExpressionImpl.java
deleted file mode 100644
index 07f6bb017..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/ValueExpressionImpl.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * 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.struts2.el;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-import jakarta.el.ELContext;
-import jakarta.el.ELException;
-import jakarta.el.ELResolver;
-import jakarta.el.Expression;
-import jakarta.el.ExpressionFactory;
-import jakarta.el.FunctionMapper;
-import jakarta.el.PropertyNotFoundException;
-import jakarta.el.PropertyNotWritableException;
-import jakarta.el.ValueExpression;
-import jakarta.el.VariableMapper;
-
-import org.apache.struts2.el.lang.ELSupport;
-import org.apache.struts2.el.lang.EvaluationContext;
-import org.apache.struts2.el.lang.ExpressionBuilder;
-import org.apache.struts2.el.parser.AstLiteralExpression;
-import org.apache.struts2.el.parser.Node;
-import org.apache.struts2.el.util.ReflectionUtil;
-
-/**
- * An Expression that can get or set a value.
- *
- *
- * In previous incarnations of this API, expressions could only be read.
- * ValueExpression objects can now be used both to retrieve a
- * value and to set a value. Expressions that can have a value set on them are
- * referred to as l-value expressions. Those that cannot are referred to as
- * r-value expressions. Not all r-value expressions can be used as l-value
- * expressions (e.g. "${1+1}" or
- * "${firstName} ${lastName}"). See the EL Specification for
- * details. Expressions that cannot be used as l-values must always return
- * true from isReadOnly().
- *
- *
- *
- * The {@link ExpressionFactory#createValueExpression} method
- * can be used to parse an expression string and return a concrete instance
- * of ValueExpression that encapsulates the parsed expression.
- * The {@link FunctionMapper} is used at parse time, not evaluation time,
- * so one is not needed to evaluate an expression using this class.
- * However, the {@link ELContext} is needed at evaluation time.
- *
- *
The {@link #getValue}, {@link #setValue}, {@link #isReadOnly} and
- * {@link #getType} methods will evaluate the expression each time they are
- * called. The {@link ELResolver} in the ELContext is used to
- * resolve the top-level variables and to determine the behavior of the
- * . and [] operators. For any of the four methods,
- * the {@link ELResolver#getValue} method is used to resolve all properties
- * up to but excluding the last one. This provides the base
- * object. At the last resolution, the ValueExpression will
- * call the corresponding {@link ELResolver#getValue},
- * {@link ELResolver#setValue}, {@link ELResolver#isReadOnly} or
- * {@link ELResolver#getType} method, depending on which was called on
- * the ValueExpression.
- *
- *
- *
See the notes about comparison, serialization and immutability in
- * the {@link Expression} javadocs.
- *
- * @see jakarta.el.ELResolver
- * @see jakarta.el.Expression
- * @see jakarta.el.ExpressionFactory
- * @see jakarta.el.ValueExpression
- *
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class ValueExpressionImpl extends ValueExpression implements
- Externalizable {
-
- private Class expectedType;
-
- private String expr;
-
- private FunctionMapper fnMapper;
-
- private VariableMapper varMapper;
-
- private transient Node node;
-
- public ValueExpressionImpl() {
-
- }
-
- /**
- * @param expr expression
- * @param node node
- * @param fnMapper function mapper
- * @param varMapper variable mapper
- * @param expectedType expected type
- */
- public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper,
- VariableMapper varMapper, Class expectedType) {
- this.expr = expr;
- this.node = node;
- this.fnMapper = fnMapper;
- this.varMapper = varMapper;
- this.expectedType = expectedType;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- return (obj instanceof ValueExpressionImpl && obj.hashCode() == this
- .hashCode());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see jakarta.el.ValueExpression#getExpectedType()
- */
- public Class getExpectedType() {
- return this.expectedType;
- }
-
- /**
- * Returns the type the result of the expression will be coerced to after
- * evaluation.
- *
- * @return the expectedType passed to the
- * ExpressionFactory.createValueExpression method
- * that created this ValueExpression.
- *
- * @see jakarta.el.Expression#getExpressionString()
- */
- public String getExpressionString() {
- return this.expr;
- }
-
- /**
- * @return
- * @throws ELException
- */
- private Node getNode() throws ELException {
- if (this.node == null) {
- this.node = ExpressionBuilder.createNode(this.expr);
- }
- return this.node;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see jakarta.el.ValueExpression#getType(jakarta.el.ELContext)
- */
- public Class getType(ELContext context) throws PropertyNotFoundException,
- ELException {
- EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
- this.varMapper);
- return this.getNode().getType(ctx);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see jakarta.el.ValueExpression#getValue(jakarta.el.ELContext)
- */
- public Object getValue(ELContext context) throws PropertyNotFoundException,
- ELException {
- EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
- this.varMapper);
- Object value = this.getNode().getValue(ctx);
- if (this.expectedType != null) {
- return ELSupport.coerceToType(value, this.expectedType);
- }
- return value;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return this.expr.hashCode();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see jakarta.el.ValueExpression#isLiteralText()
- */
- public boolean isLiteralText() {
- try {
- return this.getNode() instanceof AstLiteralExpression;
- } catch (ELException ele) {
- return false;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see jakarta.el.ValueExpression#isReadOnly(jakarta.el.ELContext)
- */
- public boolean isReadOnly(ELContext context)
- throws PropertyNotFoundException, ELException {
- EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
- this.varMapper);
- return this.getNode().isReadOnly(ctx);
- }
-
- public void readExternal(ObjectInput in) throws IOException,
- ClassNotFoundException {
- this.expr = in.readUTF();
- String type = in.readUTF();
- if (!"".equals(type)) {
- this.expectedType = ReflectionUtil.forName(type);
- }
- this.fnMapper = (FunctionMapper) in.readObject();
- this.varMapper = (VariableMapper) in.readObject();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see jakarta.el.ValueExpression#setValue(jakarta.el.ELContext,
- * java.lang.Object)
- */
- public void setValue(ELContext context, Object value)
- throws PropertyNotFoundException, PropertyNotWritableException,
- ELException {
- EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
- this.varMapper);
- this.getNode().setValue(ctx, value);
- }
-
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeUTF(this.expr);
- out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
- : "");
- out.writeObject(this.fnMapper);
- out.writeObject(this.varMapper);
- }
-
- public String toString() {
- return "ValueExpression["+this.expr+"]";
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/ValueExpressionLiteral.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/ValueExpressionLiteral.java
deleted file mode 100644
index 677d4da78..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/ValueExpressionLiteral.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.struts2.el;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import jakarta.el.ELContext;
-import jakarta.el.PropertyNotWritableException;
-
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-import jakarta.el.ValueExpression;
-
-import org.apache.struts2.el.lang.ELSupport;
-import org.apache.struts2.el.util.MessageFactory;
-import org.apache.struts2.el.util.ReflectionUtil;
-
-public final class ValueExpressionLiteral extends ValueExpression implements
- Externalizable {
-
- private static final long serialVersionUID = 1L;
-
- private Object value;
-
- private Class expectedType;
-
- public ValueExpressionLiteral() {
- super();
- }
-
- public ValueExpressionLiteral(Object value, Class expectedType) {
- this.value = value;
- this.expectedType = expectedType;
- }
-
- public Object getValue(ELContext context) {
- if (this.expectedType != null) {
- return ELSupport.coerceToType(this.value, this.expectedType);
- }
- return this.value;
- }
-
- public void setValue(ELContext context, Object value) {
- throw new PropertyNotWritableException(MessageFactory.get(
- "error.value.literal.write", this.value));
- }
-
- public boolean isReadOnly(ELContext context) {
- return true;
- }
-
- public Class getType(ELContext context) {
- return (this.value != null) ? this.value.getClass() : null;
- }
-
- public Class getExpectedType() {
- return this.expectedType;
- }
-
- public String getExpressionString() {
- return (this.value != null) ? this.value.toString() : null;
- }
-
- public boolean equals(Object obj) {
- return (obj instanceof ValueExpressionLiteral && this
- .equals((ValueExpressionLiteral) obj));
- }
-
- public boolean equals(ValueExpressionLiteral ve) {
- return (ve != null && (this.value != null && ve.value != null && (this.value == ve.value || this.value
- .equals(ve.value))));
- }
-
- public int hashCode() {
- return (this.value != null) ? this.value.hashCode() : 0;
- }
-
- public boolean isLiteralText() {
- return true;
- }
-
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(this.value);
- out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
- : "");
- }
-
- public void readExternal(ObjectInput in) throws IOException,
- ClassNotFoundException {
- this.value = in.readObject();
- String type = in.readUTF();
- if (!"".equals(type)) {
- this.expectedType = ReflectionUtil.forName(type);
- }
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/ELArithmetic.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/ELArithmetic.java
deleted file mode 100644
index 35d89f4b2..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/ELArithmetic.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/*
- * 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.struts2.el.lang;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.apache.struts2.el.util.MessageFactory;
-
-
-/**
- * A helper class of Arithmetic defined by the EL Specification
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: rjung $
- */
-public abstract class ELArithmetic {
-
- public final static class BigDecimalDelegate extends ELArithmetic {
-
- protected Number add(Number num0, Number num1) {
- return ((BigDecimal) num0).add((BigDecimal) num1);
- }
-
- protected Number coerce(Number num) {
- if (num instanceof BigDecimal)
- return num;
- if (num instanceof BigInteger)
- return new BigDecimal((BigInteger) num);
- return new BigDecimal(num.doubleValue());
- }
-
- protected Number coerce(String str) {
- return new BigDecimal(str);
- }
-
- protected Number divide(Number num0, Number num1) {
- return ((BigDecimal) num0).divide((BigDecimal) num1,
- BigDecimal.ROUND_HALF_UP);
- }
-
- protected Number subtract(Number num0, Number num1) {
- return ((BigDecimal) num0).subtract((BigDecimal) num1);
- }
-
- protected Number mod(Number num0, Number num1) {
- return new Double(num0.doubleValue() % num1.doubleValue());
- }
-
- protected Number multiply(Number num0, Number num1) {
- return ((BigDecimal) num0).multiply((BigDecimal) num1);
- }
-
- public boolean matches(Object obj0, Object obj1) {
- return (obj0 instanceof BigDecimal || obj1 instanceof BigDecimal);
- }
- }
-
- public final static class BigIntegerDelegate extends ELArithmetic {
-
- protected Number add(Number num0, Number num1) {
- return ((BigInteger) num0).add((BigInteger) num1);
- }
-
- protected Number coerce(Number num) {
- if (num instanceof BigInteger)
- return num;
- return new BigInteger(num.toString());
- }
-
- protected Number coerce(String str) {
- return new BigInteger(str);
- }
-
- protected Number divide(Number num0, Number num1) {
- return (new BigDecimal((BigInteger) num0)).divide(new BigDecimal((BigInteger) num1), BigDecimal.ROUND_HALF_UP);
- }
-
- protected Number multiply(Number num0, Number num1) {
- return ((BigInteger) num0).multiply((BigInteger) num1);
- }
-
- protected Number mod(Number num0, Number num1) {
- return ((BigInteger) num0).mod((BigInteger) num1);
- }
-
- protected Number subtract(Number num0, Number num1) {
- return ((BigInteger) num0).subtract((BigInteger) num1);
- }
-
- public boolean matches(Object obj0, Object obj1) {
- return (obj0 instanceof BigInteger || obj1 instanceof BigInteger);
- }
- }
-
- public final static class DoubleDelegate extends ELArithmetic {
-
- protected Number add(Number num0, Number num1) {
- // could only be one of these
- if (num0 instanceof BigDecimal) {
- return ((BigDecimal) num0).add(new BigDecimal(num1.doubleValue()));
- } else if (num1 instanceof BigDecimal) {
- return ((new BigDecimal(num0.doubleValue()).add((BigDecimal) num1)));
- }
- return new Double(num0.doubleValue() + num1.doubleValue());
- }
-
- protected Number coerce(Number num) {
- if (num instanceof Double)
- return num;
- if (num instanceof BigInteger)
- return new BigDecimal((BigInteger) num);
- return new Double(num.doubleValue());
- }
-
- protected Number coerce(String str) {
- return new Double(str);
- }
-
- protected Number divide(Number num0, Number num1) {
- return new Double(num0.doubleValue() / num1.doubleValue());
- }
-
- protected Number mod(Number num0, Number num1) {
- return new Double(num0.doubleValue() % num1.doubleValue());
- }
-
- protected Number subtract(Number num0, Number num1) {
- // could only be one of these
- if (num0 instanceof BigDecimal) {
- return ((BigDecimal) num0).subtract(new BigDecimal(num1.doubleValue()));
- } else if (num1 instanceof BigDecimal) {
- return ((new BigDecimal(num0.doubleValue()).subtract((BigDecimal) num1)));
- }
- return new Double(num0.doubleValue() - num1.doubleValue());
- }
-
- protected Number multiply(Number num0, Number num1) {
- // could only be one of these
- if (num0 instanceof BigDecimal) {
- return ((BigDecimal) num0).multiply(new BigDecimal(num1.doubleValue()));
- } else if (num1 instanceof BigDecimal) {
- return ((new BigDecimal(num0.doubleValue()).multiply((BigDecimal) num1)));
- }
- return new Double(num0.doubleValue() * num1.doubleValue());
- }
-
- public boolean matches(Object obj0, Object obj1) {
- return (obj0 instanceof Double
- || obj1 instanceof Double
- || obj0 instanceof Float
- || obj1 instanceof Float
- || (obj0 instanceof String && ELSupport
- .isStringFloat((String) obj0)) || (obj1 instanceof String && ELSupport
- .isStringFloat((String) obj1)));
- }
- }
-
- public final static class LongDelegate extends ELArithmetic {
-
- protected Number add(Number num0, Number num1) {
- return new Long(num0.longValue() + num1.longValue());
- }
-
- protected Number coerce(Number num) {
- if (num instanceof Long)
- return num;
- return new Long(num.longValue());
- }
-
- protected Number coerce(String str) {
- return new Long(str);
- }
-
- protected Number divide(Number num0, Number num1) {
- return new Long(num0.longValue() / num1.longValue());
- }
-
- protected Number mod(Number num0, Number num1) {
- return new Long(num0.longValue() % num1.longValue());
- }
-
- protected Number subtract(Number num0, Number num1) {
- return new Long(num0.longValue() - num1.longValue());
- }
-
- protected Number multiply(Number num0, Number num1) {
- return new Long(num0.longValue() * num1.longValue());
- }
-
- public boolean matches(Object obj0, Object obj1) {
- return (obj0 instanceof Long || obj1 instanceof Long);
- }
- }
-
- public final static BigDecimalDelegate BIGDECIMAL = new BigDecimalDelegate();
-
- public final static BigIntegerDelegate BIGINTEGER = new BigIntegerDelegate();
-
- public final static DoubleDelegate DOUBLE = new DoubleDelegate();
-
- public final static LongDelegate LONG = new LongDelegate();
-
- private final static Long ZERO = new Long(0);
-
- public final static Number add(final Object obj0, final Object obj1) {
- if (obj0 == null && obj1 == null) {
- return new Long(0);
- }
-
- final ELArithmetic delegate;
- if (BIGDECIMAL.matches(obj0, obj1))
- delegate = BIGDECIMAL;
- else if (DOUBLE.matches(obj0, obj1))
- delegate = DOUBLE;
- else if (BIGINTEGER.matches(obj0, obj1))
- delegate = BIGINTEGER;
- else
- delegate = LONG;
-
- Number num0 = delegate.coerce(obj0);
- Number num1 = delegate.coerce(obj1);
-
- return delegate.add(num0, num1);
- }
-
- public final static Number mod(final Object obj0, final Object obj1) {
- if (obj0 == null && obj1 == null) {
- return new Long(0);
- }
-
- final ELArithmetic delegate;
- if (BIGDECIMAL.matches(obj0, obj1))
- delegate = BIGDECIMAL;
- else if (DOUBLE.matches(obj0, obj1))
- delegate = DOUBLE;
- else if (BIGINTEGER.matches(obj0, obj1))
- delegate = BIGINTEGER;
- else
- delegate = LONG;
-
- Number num0 = delegate.coerce(obj0);
- Number num1 = delegate.coerce(obj1);
-
- return delegate.mod(num0, num1);
- }
-
- public final static Number subtract(final Object obj0, final Object obj1) {
- if (obj0 == null && obj1 == null) {
- return new Long(0);
- }
-
- final ELArithmetic delegate;
- if (BIGDECIMAL.matches(obj0, obj1))
- delegate = BIGDECIMAL;
- else if (DOUBLE.matches(obj0, obj1))
- delegate = DOUBLE;
- else if (BIGINTEGER.matches(obj0, obj1))
- delegate = BIGINTEGER;
- else
- delegate = LONG;
-
- Number num0 = delegate.coerce(obj0);
- Number num1 = delegate.coerce(obj1);
-
- return delegate.subtract(num0, num1);
- }
-
- public final static Number divide(final Object obj0, final Object obj1) {
- if (obj0 == null && obj1 == null) {
- return ZERO;
- }
-
- final ELArithmetic delegate;
- if (BIGDECIMAL.matches(obj0, obj1))
- delegate = BIGDECIMAL;
- else if (BIGINTEGER.matches(obj0, obj1))
- delegate = BIGDECIMAL;
- else
- delegate = DOUBLE;
-
- Number num0 = delegate.coerce(obj0);
- Number num1 = delegate.coerce(obj1);
-
- return delegate.divide(num0, num1);
- }
-
- public final static Number multiply(final Object obj0, final Object obj1) {
- if (obj0 == null && obj1 == null) {
- return new Long(0);
- }
-
- final ELArithmetic delegate;
- if (BIGDECIMAL.matches(obj0, obj1))
- delegate = BIGDECIMAL;
- else if (DOUBLE.matches(obj0, obj1))
- delegate = DOUBLE;
- else if (BIGINTEGER.matches(obj0, obj1))
- delegate = BIGINTEGER;
- else
- delegate = LONG;
-
- Number num0 = delegate.coerce(obj0);
- Number num1 = delegate.coerce(obj1);
-
- return delegate.multiply(num0, num1);
- }
-
- public final static boolean isNumber(final Object obj) {
- return (obj != null && isNumberType(obj.getClass()));
- }
-
- public final static boolean isNumberType(final Class> type) {
- return type == Long.TYPE || type == Double.TYPE ||
- type == Byte.TYPE || type == Short.TYPE ||
- type == Integer.TYPE || type == Float.TYPE ||
- Number.class.isAssignableFrom(type);
- }
-
- /**
- *
- */
- protected ELArithmetic() {
- super();
- }
-
- protected abstract Number add(final Number num0, final Number num1);
-
- protected abstract Number multiply(final Number num0, final Number num1);
-
- protected abstract Number subtract(final Number num0, final Number num1);
-
- protected abstract Number mod(final Number num0, final Number num1);
-
- protected abstract Number coerce(final Number num);
-
- protected final Number coerce(final Object obj) {
-
- if (isNumber(obj)) {
- return coerce((Number) obj);
- }
- if (obj instanceof String) {
- return coerce((String) obj);
- }
- if (obj == null || "".equals(obj)) {
- return coerce(ZERO);
- }
-
- if (obj instanceof Character) {
- return coerce(new Short((short) ((Character) obj).charValue()));
- }
-
- throw new IllegalArgumentException(MessageFactory.get("error.convert",
- obj, obj.getClass(), "Number"));
- }
-
- protected abstract Number coerce(final String str);
-
- protected abstract Number divide(final Number num0, final Number num1);
-
- protected abstract boolean matches(final Object obj0, final Object obj1);
-
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/ELSupport.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/ELSupport.java
deleted file mode 100644
index c6815ca1b..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/ELSupport.java
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
- * 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.struts2.el.lang;
-
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import jakarta.el.ELException;
-import jakarta.el.PropertyNotFoundException;
-
-import org.apache.struts2.el.util.MessageFactory;
-
-
-/**
- * A helper class that implements the EL Specification
- *
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public class ELSupport {
-
- private final static Long ZERO = new Long(0L);
-
- public final static void throwUnhandled(Object base, Object property)
- throws ELException {
- if (base == null) {
- throw new PropertyNotFoundException(MessageFactory.get(
- "error.resolver.unhandled.null", property));
- } else {
- throw new PropertyNotFoundException(MessageFactory.get(
- "error.resolver.unhandled", base.getClass(), property));
- }
- }
-
- /**
- * @param obj0 first object
- * @param obj1 second object
- * @return 0 if objects are equals
- * @throws ELException in case of errors
- */
- public final static int compare(final Object obj0, final Object obj1)
- throws ELException {
- if (obj0 == obj1 || equals(obj0, obj1)) {
- return 0;
- }
- if (isBigDecimalOp(obj0, obj1)) {
- BigDecimal bd0 = (BigDecimal) coerceToNumber(obj0, BigDecimal.class);
- BigDecimal bd1 = (BigDecimal) coerceToNumber(obj1, BigDecimal.class);
- return bd0.compareTo(bd1);
- }
- if (isDoubleOp(obj0, obj1)) {
- Double d0 = (Double) coerceToNumber(obj0, Double.class);
- Double d1 = (Double) coerceToNumber(obj1, Double.class);
- return d0.compareTo(d1);
- }
- if (isBigIntegerOp(obj0, obj1)) {
- BigInteger bi0 = (BigInteger) coerceToNumber(obj0, BigInteger.class);
- BigInteger bi1 = (BigInteger) coerceToNumber(obj1, BigInteger.class);
- return bi0.compareTo(bi1);
- }
- if (isLongOp(obj0, obj1)) {
- Long l0 = (Long) coerceToNumber(obj0, Long.class);
- Long l1 = (Long) coerceToNumber(obj1, Long.class);
- return l0.compareTo(l1);
- }
- if (obj0 instanceof String || obj1 instanceof String) {
- return coerceToString(obj0).compareTo(coerceToString(obj1));
- }
- if (obj0 instanceof Comparable) {
- return (obj1 != null) ? ((Comparable) obj0).compareTo(obj1) : 1;
- }
- if (obj1 instanceof Comparable) {
- return (obj0 != null) ? -((Comparable) obj1).compareTo(obj0) : -1;
- }
- throw new ELException(MessageFactory.get("error.compare", obj0, obj1));
- }
-
- /**
- * @param obj0 first object
- * @param obj1 second object
- * @return true if objects are equals
- * @throws ELException in case of errors
- */
- public final static boolean equals(final Object obj0, final Object obj1)
- throws ELException {
- if (obj0 == obj1) {
- return true;
- } else if (obj0 == null || obj1 == null) {
- return false;
- } else if (obj0 instanceof Boolean || obj1 instanceof Boolean) {
- return coerceToBoolean(obj0).equals(coerceToBoolean(obj1));
- } else if (obj0.getClass().isEnum()) {
- return obj0.equals(coerceToEnum(obj1, obj0.getClass()));
- } else if (obj1.getClass().isEnum()) {
- return obj1.equals(coerceToEnum(obj0, obj1.getClass()));
- } else if (obj0 instanceof String || obj1 instanceof String) {
- int lexCompare = coerceToString(obj0).compareTo(coerceToString(obj1));
- return (lexCompare == 0) ? true : false;
- }
- if (isBigDecimalOp(obj0, obj1)) {
- BigDecimal bd0 = (BigDecimal) coerceToNumber(obj0, BigDecimal.class);
- BigDecimal bd1 = (BigDecimal) coerceToNumber(obj1, BigDecimal.class);
- return bd0.equals(bd1);
- }
- if (isDoubleOp(obj0, obj1)) {
- Double d0 = (Double) coerceToNumber(obj0, Double.class);
- Double d1 = (Double) coerceToNumber(obj1, Double.class);
- return d0.equals(d1);
- }
- if (isBigIntegerOp(obj0, obj1)) {
- BigInteger bi0 = (BigInteger) coerceToNumber(obj0, BigInteger.class);
- BigInteger bi1 = (BigInteger) coerceToNumber(obj1, BigInteger.class);
- return bi0.equals(bi1);
- }
- if (isLongOp(obj0, obj1)) {
- Long l0 = (Long) coerceToNumber(obj0, Long.class);
- Long l1 = (Long) coerceToNumber(obj1, Long.class);
- return l0.equals(l1);
- } else {
- return obj0.equals(obj1);
- }
- }
-
- /**
- * @param obj object
- * @param type class ytpe
- * @return enum
- */
- public final static Enum coerceToEnum(final Object obj, Class type) {
- if (obj == null || "".equals(obj)) {
- return null;
- }
- if (obj.getClass().isEnum()) {
- return (Enum) obj;
- }
- return Enum.valueOf(type, obj.toString());
- }
-
- /**
- * @param obj object
- * @return boolean
- */
- public final static Boolean coerceToBoolean(final Object obj)
- throws IllegalArgumentException {
- if (obj == null || "".equals(obj)) {
- return Boolean.FALSE;
- }
- if (obj instanceof Boolean) {
- return (Boolean) obj;
- }
- if (obj instanceof String) {
- return Boolean.valueOf((String) obj);
- }
-
- throw new IllegalArgumentException(MessageFactory.get("error.convert",
- obj, obj.getClass(), Boolean.class));
- }
-
- public final static Character coerceToCharacter(final Object obj)
- throws IllegalArgumentException {
- if (obj == null || "".equals(obj)) {
- return new Character((char) 0);
- }
- if (obj instanceof String) {
- return new Character(((String) obj).charAt(0));
- }
- if (ELArithmetic.isNumber(obj)) {
- return new Character((char) ((Number) obj).shortValue());
- }
- Class objType = obj.getClass();
- if (obj instanceof Character) {
- return (Character) obj;
- }
-
- throw new IllegalArgumentException(MessageFactory.get("error.convert",
- obj, objType, Character.class));
- }
-
- public final static Number coerceToNumber(final Object obj) {
- if (obj == null) {
- return ZERO;
- } else if (obj instanceof Number) {
- return (Number) obj;
- } else {
- String str = coerceToString(obj);
- if (isStringFloat(str)) {
- return toFloat(str);
- } else {
- return toNumber(str);
- }
- }
- }
-
- protected final static Number coerceToNumber(final Number number,
- final Class type) throws IllegalArgumentException {
- if (Long.TYPE == type || Long.class.equals(type)) {
- return new Long(number.longValue());
- }
- if (Double.TYPE == type || Double.class.equals(type)) {
- return new Double(number.doubleValue());
- }
- if (Integer.TYPE == type || Integer.class.equals(type)) {
- return new Integer(number.intValue());
- }
- if (BigInteger.class.equals(type)) {
- if (number instanceof BigDecimal) {
- return ((BigDecimal) number).toBigInteger();
- }
- if (number instanceof BigInteger) {
- return number;
- }
- return BigInteger.valueOf(number.longValue());
- }
- if (BigDecimal.class.equals(type)) {
- if (number instanceof BigDecimal) {
- return number;
- }
- if (number instanceof BigInteger) {
- return new BigDecimal((BigInteger) number);
- }
- return new BigDecimal(number.doubleValue());
- }
- if (Byte.TYPE == type || Byte.class.equals(type)) {
- return new Byte(number.byteValue());
- }
- if (Short.TYPE == type || Short.class.equals(type)) {
- return new Short(number.shortValue());
- }
- if (Float.TYPE == type || Float.class.equals(type)) {
- return new Float(number.floatValue());
- }
-
- throw new IllegalArgumentException(MessageFactory.get("error.convert",
- number, number.getClass(), type));
- }
-
- public final static Number coerceToNumber(final Object obj, final Class type)
- throws IllegalArgumentException {
- if (obj == null || "".equals(obj)) {
- return coerceToNumber(ZERO, type);
- }
- if (obj instanceof String) {
- return coerceToNumber((String) obj, type);
- }
- if (ELArithmetic.isNumber(obj)) {
- return coerceToNumber((Number) obj, type);
- }
-
- if (obj instanceof Character) {
- return coerceToNumber(new Short((short) ((Character) obj)
- .charValue()), type);
- }
-
- throw new IllegalArgumentException(MessageFactory.get("error.convert",
- obj, obj.getClass(), type));
- }
-
- protected final static Number coerceToNumber(final String val,
- final Class type) throws IllegalArgumentException {
- if (Long.TYPE == type || Long.class.equals(type)) {
- return Long.valueOf(val);
- }
- if (Integer.TYPE == type || Integer.class.equals(type)) {
- return Integer.valueOf(val);
- }
- if (Double.TYPE == type || Double.class.equals(type)) {
- return Double.valueOf(val);
- }
- if (BigInteger.class.equals(type)) {
- return new BigInteger(val);
- }
- if (BigDecimal.class.equals(type)) {
- return new BigDecimal(val);
- }
- if (Byte.TYPE == type || Byte.class.equals(type)) {
- return Byte.valueOf(val);
- }
- if (Short.TYPE == type || Short.class.equals(type)) {
- return Short.valueOf(val);
- }
- if (Float.TYPE == type || Float.class.equals(type)) {
- return Float.valueOf(val);
- }
-
- throw new IllegalArgumentException(MessageFactory.get("error.convert",
- val, String.class, type));
- }
-
- /**
- * @param obj object
- * @return String
- */
- public final static String coerceToString(final Object obj) {
- if (obj == null) {
- return "";
- } else if (obj instanceof String) {
- return (String) obj;
- } else if (obj instanceof Enum) {
- return ((Enum) obj).name();
- } else {
- return obj.toString();
- }
- }
-
- public final static void checkType(final Object obj, final Class type)
- throws IllegalArgumentException {
- if (String.class.equals(type)) {
- coerceToString(obj);
- }
- if (ELArithmetic.isNumberType(type)) {
- coerceToNumber(obj, type);
- }
- if (Character.class.equals(type) || Character.TYPE == type) {
- coerceToCharacter(obj);
- }
- if (Boolean.class.equals(type) || Boolean.TYPE == type) {
- coerceToBoolean(obj);
- }
- if (type.isEnum()) {
- coerceToEnum(obj, type);
- }
- }
-
- public final static Object coerceToType(final Object obj, final Class type)
- throws IllegalArgumentException {
- if (type == null || Object.class.equals(type) ||
- (obj != null && type.isAssignableFrom(obj.getClass()))) {
- return obj;
- }
- if (String.class.equals(type)) {
- return coerceToString(obj);
- }
- if (ELArithmetic.isNumberType(type)) {
- return coerceToNumber(obj, type);
- }
- if (Character.class.equals(type) || Character.TYPE == type) {
- return coerceToCharacter(obj);
- }
- if (Boolean.class.equals(type) || Boolean.TYPE == type) {
- return coerceToBoolean(obj);
- }
- if (type.isEnum()) {
- return coerceToEnum(obj, type);
- }
-
- // new to spec
- if (obj == null)
- return null;
- if (obj instanceof String) {
- if ("".equals(obj))
- return null;
- PropertyEditor editor = PropertyEditorManager.findEditor(type);
- if (editor != null) {
- editor.setAsText((String) obj);
- return editor.getValue();
- }
- }
- throw new IllegalArgumentException(MessageFactory.get("error.convert",
- obj, obj.getClass(), type));
- }
-
- /**
- * @param obj object array
- * @return true if object array contains null values
- */
- public final static boolean containsNulls(final Object[] obj) {
- for (int i = 0; i < obj.length; i++) {
- if (obj[i] == null) {
- return true;
- }
- }
- return false;
- }
-
- public final static boolean isBigDecimalOp(final Object obj0,
- final Object obj1) {
- return (obj0 instanceof BigDecimal || obj1 instanceof BigDecimal);
- }
-
- public final static boolean isBigIntegerOp(final Object obj0,
- final Object obj1) {
- return (obj0 instanceof BigInteger || obj1 instanceof BigInteger);
- }
-
- public final static boolean isDoubleOp(final Object obj0, final Object obj1) {
- return (obj0 instanceof Double
- || obj1 instanceof Double
- || obj0 instanceof Float
- || obj1 instanceof Float);
- }
-
- public final static boolean isDoubleStringOp(final Object obj0,
- final Object obj1) {
- return (isDoubleOp(obj0, obj1)
- || (obj0 instanceof String && isStringFloat((String) obj0)) || (obj1 instanceof String && isStringFloat((String) obj1)));
- }
-
- public final static boolean isLongOp(final Object obj0, final Object obj1) {
- return (obj0 instanceof Long
- || obj1 instanceof Long
- || obj0 instanceof Integer
- || obj1 instanceof Integer
- || obj0 instanceof Character
- || obj1 instanceof Character
- || obj0 instanceof Short
- || obj1 instanceof Short
- || obj0 instanceof Byte
- || obj1 instanceof Byte);
- }
-
- public final static boolean isStringFloat(final String str) {
- int len = str.length();
- if (len > 1) {
- for (int i = 0; i < len; i++) {
- switch (str.charAt(i)) {
- case 'E':
- return true;
- case 'e':
- return true;
- case '.':
- return true;
- }
- }
- }
- return false;
- }
-
- public final static Number toFloat(final String value) {
- try {
- if (Double.parseDouble(value) > Double.MAX_VALUE) {
- return new BigDecimal(value);
- } else {
- return new Double(value);
- }
- } catch (NumberFormatException e0) {
- return new BigDecimal(value);
- }
- }
-
- public final static Number toNumber(final String value) {
- try {
- return new Integer(Integer.parseInt(value));
- } catch (NumberFormatException e0) {
- try {
- return new Long(Long.parseLong(value));
- } catch (NumberFormatException e1) {
- return new BigInteger(value);
- }
- }
- }
-
- public ELSupport() {
- super();
- }
-
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/EvaluationContext.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/EvaluationContext.java
deleted file mode 100644
index 54c81e222..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/EvaluationContext.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.struts2.el.lang;
-
-import java.util.Locale;
-
-import jakarta.el.ELContext;
-import jakarta.el.ELResolver;
-import jakarta.el.FunctionMapper;
-import jakarta.el.VariableMapper;
-
-public final class EvaluationContext extends ELContext {
-
- private final ELContext elContext;
-
- private final FunctionMapper fnMapper;
-
- private final VariableMapper varMapper;
-
- public EvaluationContext(ELContext elContext, FunctionMapper fnMapper,
- VariableMapper varMapper) {
- this.elContext = elContext;
- this.fnMapper = fnMapper;
- this.varMapper = varMapper;
- }
-
- public ELContext getELContext() {
- return this.elContext;
- }
-
- public FunctionMapper getFunctionMapper() {
- return this.fnMapper;
- }
-
- public VariableMapper getVariableMapper() {
- return this.varMapper;
- }
-
- public Object getContext(Class key) {
- return this.elContext.getContext(key);
- }
-
- public ELResolver getELResolver() {
- return this.elContext.getELResolver();
- }
-
- public boolean isPropertyResolved() {
- return this.elContext.isPropertyResolved();
- }
-
- public void putContext(Class key, Object contextObject) {
- this.elContext.putContext(key, contextObject);
- }
-
- public void setPropertyResolved(boolean resolved) {
- this.elContext.setPropertyResolved(resolved);
- }
-
- public Locale getLocale() {
- return this.elContext.getLocale();
- }
-
- public void setLocale(Locale locale) {
- this.elContext.setLocale(locale);
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/ExpressionBuilder.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/ExpressionBuilder.java
deleted file mode 100644
index 1835ee4be..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/ExpressionBuilder.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * 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.struts2.el.lang;
-
-import java.io.StringReader;
-import java.lang.reflect.Method;
-
-import jakarta.el.ELContext;
-import jakarta.el.ELException;
-import jakarta.el.FunctionMapper;
-import jakarta.el.MethodExpression;
-import jakarta.el.ValueExpression;
-import jakarta.el.VariableMapper;
-
-import org.apache.struts2.el.MethodExpressionImpl;
-import org.apache.struts2.el.MethodExpressionLiteral;
-import org.apache.struts2.el.ValueExpressionImpl;
-import org.apache.struts2.el.parser.AstCompositeExpression;
-import org.apache.struts2.el.parser.AstDeferredExpression;
-import org.apache.struts2.el.parser.AstDynamicExpression;
-import org.apache.struts2.el.parser.AstFunction;
-import org.apache.struts2.el.parser.AstIdentifier;
-import org.apache.struts2.el.parser.AstLiteralExpression;
-import org.apache.struts2.el.parser.AstValue;
-import org.apache.struts2.el.parser.ELParser;
-import org.apache.struts2.el.parser.Node;
-import org.apache.struts2.el.parser.NodeVisitor;
-import org.apache.struts2.el.parser.ParseException;
-import org.apache.struts2.el.util.ConcurrentCache;
-import org.apache.struts2.el.util.MessageFactory;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: rjung $
- */
-public final class ExpressionBuilder implements NodeVisitor {
-
- private static final ConcurrentCache cache = new ConcurrentCache(5000);
-
- private FunctionMapper fnMapper;
-
- private VariableMapper varMapper;
-
- private String expression;
-
- public ExpressionBuilder(String expression, ELContext ctx)
- throws ELException {
- this.expression = expression;
-
- FunctionMapper ctxFn = ctx.getFunctionMapper();
- VariableMapper ctxVar = ctx.getVariableMapper();
-
- if (ctxFn != null) {
- this.fnMapper = new FunctionMapperFactory(ctxFn);
- }
- if (ctxVar != null) {
- this.varMapper = new VariableMapperFactory(ctxVar);
- }
- }
-
- public final static Node createNode(String expr) throws ELException {
- Node n = createNodeInternal(expr);
- return n;
- }
-
- private final static Node createNodeInternal(String expr)
- throws ELException {
- if (expr == null) {
- throw new ELException(MessageFactory.get("error.null"));
- }
-
- Node n = cache.get(expr);
- if (n == null) {
- try {
- n = (new ELParser(new StringReader(expr)))
- .CompositeExpression();
-
- // validate composite expression
- if (n instanceof AstCompositeExpression) {
- int numChildren = n.jjtGetNumChildren();
- if (numChildren == 1) {
- n = n.jjtGetChild(0);
- } else {
- Class type = null;
- Node child = null;
- for (int i = 0; i < numChildren; i++) {
- child = n.jjtGetChild(i);
- if (child instanceof AstLiteralExpression)
- continue;
- if (type == null)
- type = child.getClass();
- else {
- if (!type.equals(child.getClass())) {
- throw new ELException(MessageFactory.get(
- "error.mixed", expr));
- }
- }
- }
- }
- }
- if (n instanceof AstDeferredExpression
- || n instanceof AstDynamicExpression) {
- n = n.jjtGetChild(0);
- }
- cache.put(expr, n);
- } catch (ParseException pe) {
- throw new ELException("Error Parsing: " + expr, pe);
- }
- }
- return n;
- }
-
- private void prepare(Node node) throws ELException {
- try {
- node.accept(this);
- } catch (Exception e) {
- if (e instanceof ELException) {
- throw (ELException) e;
- } else {
- throw (new ELException(e));
- }
- }
- if (this.fnMapper instanceof FunctionMapperFactory) {
- this.fnMapper = ((FunctionMapperFactory) this.fnMapper).create();
- }
- if (this.varMapper instanceof VariableMapperFactory) {
- this.varMapper = ((VariableMapperFactory) this.varMapper).create();
- }
- }
-
- private Node build() throws ELException {
- Node n = createNodeInternal(this.expression);
- this.prepare(n);
- if (n instanceof AstDeferredExpression
- || n instanceof AstDynamicExpression) {
- n = n.jjtGetChild(0);
- }
- return n;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.sun.el.parser.NodeVisitor#visit(com.sun.el.parser.Node)
- */
- public void visit(Node node) throws ELException {
- if (node instanceof AstFunction) {
-
- AstFunction funcNode = (AstFunction) node;
-
- if (this.fnMapper == null) {
- throw new ELException(MessageFactory.get("error.fnMapper.null"));
- }
- Method m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode
- .getLocalName());
- if (m == null) {
- throw new ELException(MessageFactory.get(
- "error.fnMapper.method", funcNode.getOutputName()));
- }
- int pcnt = m.getParameterTypes().length;
- if (node.jjtGetNumChildren() != pcnt) {
- throw new ELException(MessageFactory.get(
- "error.fnMapper.paramcount", funcNode.getOutputName(),
- "" + pcnt, "" + node.jjtGetNumChildren()));
- }
- } else if (node instanceof AstIdentifier && this.varMapper != null) {
- String variable = ((AstIdentifier) node).getImage();
-
- // simply capture it
- this.varMapper.resolveVariable(variable);
- }
- }
-
- public ValueExpression createValueExpression(Class expectedType)
- throws ELException {
- Node n = this.build();
- return new ValueExpressionImpl(this.expression, n, this.fnMapper,
- this.varMapper, expectedType);
- }
-
- public MethodExpression createMethodExpression(Class expectedReturnType,
- Class[] expectedParamTypes) throws ELException {
- Node n = this.build();
- if (n instanceof AstValue || n instanceof AstIdentifier) {
- return new MethodExpressionImpl(expression, n, this.fnMapper,
- this.varMapper, expectedReturnType, expectedParamTypes);
- } else if (n instanceof AstLiteralExpression) {
- return new MethodExpressionLiteral(expression, expectedReturnType,
- expectedParamTypes);
- } else {
- throw new ELException("Not a Valid Method Expression: "
- + expression);
- }
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/FunctionMapperFactory.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/FunctionMapperFactory.java
deleted file mode 100644
index 9e8f2746c..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/FunctionMapperFactory.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.struts2.el.lang;
-
-import java.lang.reflect.Method;
-
-import jakarta.el.FunctionMapper;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: rjung $
- */
-public class FunctionMapperFactory extends FunctionMapper {
-
- protected FunctionMapperImpl memento = null;
- protected FunctionMapper target;
-
- public FunctionMapperFactory(FunctionMapper mapper) {
- if (mapper == null) {
- throw new NullPointerException("FunctionMapper target cannot be null");
- }
- this.target = mapper;
- }
-
-
- /* (non-Javadoc)
- * @see jakarta.el.FunctionMapper#resolveFunction(java.lang.String, java.lang.String)
- */
- public Method resolveFunction(String prefix, String localName) {
- if (this.memento == null) {
- this.memento = new FunctionMapperImpl();
- }
- Method m = this.target.resolveFunction(prefix, localName);
- if (m != null) {
- this.memento.addFunction(prefix, localName, m);
- }
- return m;
- }
-
- public FunctionMapper create() {
- return this.memento;
- }
-
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/FunctionMapperImpl.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/FunctionMapperImpl.java
deleted file mode 100644
index bcb88be78..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/FunctionMapperImpl.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * 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.struts2.el.lang;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-import jakarta.el.FunctionMapper;
-
-import org.apache.struts2.el.util.ReflectionUtil;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: rjung $
- */
-public class FunctionMapperImpl extends FunctionMapper implements
- Externalizable {
-
- private static final long serialVersionUID = 1L;
-
- protected Map functions = null;
-
- /*
- * (non-Javadoc)
- *
- * @see jakarta.el.FunctionMapper#resolveFunction(java.lang.String,
- * java.lang.String)
- */
- public Method resolveFunction(String prefix, String localName) {
- if (this.functions != null) {
- Function f = this.functions.get(prefix + ":" + localName);
- return f.getMethod();
- }
- return null;
- }
-
- public void addFunction(String prefix, String localName, Method m) {
- if (this.functions == null) {
- this.functions = new HashMap();
- }
- Function f = new Function(prefix, localName, m);
- synchronized (this) {
- this.functions.put(prefix+":"+localName, f);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
- */
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(this.functions);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
- */
- public void readExternal(ObjectInput in) throws IOException,
- ClassNotFoundException {
- this.functions = (Map) in.readObject();
- }
-
- public static class Function implements Externalizable {
-
- protected transient Method m;
- protected String owner;
- protected String name;
- protected String[] types;
- protected String prefix;
- protected String localName;
-
- public Function(String prefix, String localName, Method m) {
- if (localName == null) {
- throw new NullPointerException("LocalName cannot be null");
- }
- if (m == null) {
- throw new NullPointerException("Method cannot be null");
- }
- this.prefix = prefix;
- this.localName = localName;
- this.m = m;
- }
-
- public Function() {
- // for serialization
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
- */
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeUTF((this.prefix != null) ? this.prefix : "");
- out.writeUTF(this.localName);
- // make sure m isn't null
- getMethod();
- out.writeUTF((this.owner != null) ?
- this.owner :
- this.m.getDeclaringClass().getName());
- out.writeUTF((this.name != null) ?
- this.name :
- this.m.getName());
- out.writeObject((this.types != null) ?
- this.types :
- ReflectionUtil.toTypeNameArray(this.m.getParameterTypes()));
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
- */
- public void readExternal(ObjectInput in) throws IOException,
- ClassNotFoundException {
-
- this.prefix = in.readUTF();
- if ("".equals(this.prefix)) this.prefix = null;
- this.localName = in.readUTF();
- this.owner = in.readUTF();
- this.name = in.readUTF();
- this.types = (String[]) in.readObject();
- }
-
- public Method getMethod() {
- if (this.m == null) {
- try {
- Class t = ReflectionUtil.forName(this.owner);
- Class[] p = ReflectionUtil.toTypeArray(this.types);
- this.m = t.getMethod(this.name, p);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return this.m;
- }
-
- public boolean matches(String prefix, String localName) {
- if (this.prefix != null) {
- if (prefix == null) return false;
- if (!this.prefix.equals(prefix)) return false;
- }
- return this.localName.equals(localName);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (obj instanceof Function) {
- return this.hashCode() == obj.hashCode();
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return (this.prefix + this.localName).hashCode();
- }
- }
-
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/VariableMapperFactory.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/VariableMapperFactory.java
deleted file mode 100644
index e77e44d19..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/VariableMapperFactory.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.struts2.el.lang;
-
-import jakarta.el.ValueExpression;
-import jakarta.el.VariableMapper;
-
-public class VariableMapperFactory extends VariableMapper {
-
- private final VariableMapper target;
- private VariableMapper momento;
-
- public VariableMapperFactory(VariableMapper target) {
- if (target == null) {
- throw new NullPointerException("Target VariableMapper cannot be null");
- }
- this.target = target;
- }
-
- public VariableMapper create() {
- return this.momento;
- }
-
- public ValueExpression resolveVariable(String variable) {
- ValueExpression expr = this.target.resolveVariable(variable);
- if (expr != null) {
- if (this.momento == null) {
- this.momento = new VariableMapperImpl();
- }
- this.momento.setVariable(variable, expr);
- }
- return expr;
- }
-
- public ValueExpression setVariable(String variable, ValueExpression expression) {
- throw new UnsupportedOperationException("Cannot Set Variables on Factory");
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/VariableMapperImpl.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/VariableMapperImpl.java
deleted file mode 100644
index fdee14e0a..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/lang/VariableMapperImpl.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.struts2.el.lang;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.HashMap;
-import java.util.Map;
-
-import jakarta.el.ValueExpression;
-import jakarta.el.VariableMapper;
-
-public class VariableMapperImpl extends VariableMapper implements Externalizable {
-
- private static final long serialVersionUID = 1L;
-
- private Map vars = new HashMap();
-
- public VariableMapperImpl() {
- super();
- }
-
- public ValueExpression resolveVariable(String variable) {
- return this.vars.get(variable);
- }
-
- public ValueExpression setVariable(String variable,
- ValueExpression expression) {
- return this.vars.put(variable, expression);
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- this.vars = (Map) in.readObject();
- }
-
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(this.vars);
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/ArithmeticNode.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/ArithmeticNode.java
deleted file mode 100644
index 6f443dfb3..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/ArithmeticNode.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public class ArithmeticNode extends SimpleNode {
-
- /**
- * @param i i
- */
- public ArithmeticNode(int i) {
- super(i);
- }
-
- public Class getType(EvaluationContext ctx)
- throws ELException {
- return Number.class;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstAnd.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstAnd.java
deleted file mode 100644
index 94c54904d..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstAnd.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstAnd extends BooleanNode {
- public AstAnd(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj = children[0].getValue(ctx);
- Boolean b = coerceToBoolean(obj);
- if (!b.booleanValue()) {
- return b;
- }
- obj = children[1].getValue(ctx);
- b = coerceToBoolean(obj);
- return b;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstBracketSuffix.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstBracketSuffix.java
deleted file mode 100644
index 865d08335..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstBracketSuffix.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstBracketSuffix extends SimpleNode {
- public AstBracketSuffix(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- return this.children[0].getValue(ctx);
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstChoice.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstChoice.java
deleted file mode 100644
index d77aa69a8..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstChoice.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstChoice extends SimpleNode {
- public AstChoice(int id) {
- super(id);
- }
-
- public Class getType(EvaluationContext ctx)
- throws ELException {
- Object val = this.getValue(ctx);
- return (val != null) ? val.getClass() : null;
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj0 = this.children[0].getValue(ctx);
- Boolean b0 = coerceToBoolean(obj0);
- return this.children[((b0.booleanValue() ? 1 : 2))].getValue(ctx);
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstCompositeExpression.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstCompositeExpression.java
deleted file mode 100644
index 86f32172b..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstCompositeExpression.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstCompositeExpression extends SimpleNode {
-
- public AstCompositeExpression(int id) {
- super(id);
- }
-
- public Class getType(EvaluationContext ctx)
- throws ELException {
- return String.class;
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- StringBuffer sb = new StringBuffer(16);
- Object obj = null;
- if (this.children != null) {
- for (int i = 0; i < this.children.length; i++) {
- obj = this.children[i].getValue(ctx);
- if (obj != null) {
- sb.append(obj);
- }
- }
- }
- return sb.toString();
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstDeferredExpression.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstDeferredExpression.java
deleted file mode 100644
index 322ed47b5..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstDeferredExpression.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstDeferredExpression extends SimpleNode {
- public AstDeferredExpression(int id) {
- super(id);
- }
-
- public Class getType(EvaluationContext ctx)
- throws ELException {
- return this.children[0].getType(ctx);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- return this.children[0].getValue(ctx);
- }
-
- public boolean isReadOnly(EvaluationContext ctx)
- throws ELException {
- return this.children[0].isReadOnly(ctx);
- }
-
- public void setValue(EvaluationContext ctx, Object value)
- throws ELException {
- this.children[0].setValue(ctx, value);
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstDiv.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstDiv.java
deleted file mode 100644
index 87fb7ccd6..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstDiv.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.ELArithmetic;
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstDiv extends ArithmeticNode {
- public AstDiv(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj0 = this.children[0].getValue(ctx);
- Object obj1 = this.children[1].getValue(ctx);
- return ELArithmetic.divide(obj0, obj1);
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstDotSuffix.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstDotSuffix.java
deleted file mode 100644
index 2b7ef6a64..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstDotSuffix.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstDotSuffix extends SimpleNode {
- public AstDotSuffix(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- return this.image;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstDynamicExpression.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstDynamicExpression.java
deleted file mode 100644
index 6443a9f75..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstDynamicExpression.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstDynamicExpression extends SimpleNode {
- public AstDynamicExpression(int id) {
- super(id);
- }
-
- public Class getType(EvaluationContext ctx)
- throws ELException {
- return this.children[0].getType(ctx);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- return this.children[0].getValue(ctx);
- }
-
- public boolean isReadOnly(EvaluationContext ctx)
- throws ELException {
- return this.children[0].isReadOnly(ctx);
- }
-
- public void setValue(EvaluationContext ctx, Object value)
- throws ELException {
- this.children[0].setValue(ctx, value);
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstEmpty.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstEmpty.java
deleted file mode 100644
index 81d531e4e..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstEmpty.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import java.util.Collection;
-import java.util.Map;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstEmpty extends SimpleNode {
- public AstEmpty(int id) {
- super(id);
- }
-
- public Class getType(EvaluationContext ctx)
- throws ELException {
- return Boolean.class;
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj = this.children[0].getValue(ctx);
- if (obj == null) {
- return Boolean.TRUE;
- } else if (obj instanceof String) {
- return Boolean.valueOf(((String) obj).length() == 0);
- } else if (obj instanceof Object[]) {
- return Boolean.valueOf(((Object[]) obj).length == 0);
- } else if (obj instanceof Collection) {
- return Boolean.valueOf(((Collection) obj).isEmpty());
- } else if (obj instanceof Map) {
- return Boolean.valueOf(((Map) obj).isEmpty());
- }
- return Boolean.FALSE;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstEqual.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstEqual.java
deleted file mode 100644
index 592d86a71..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstEqual.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstEqual extends BooleanNode {
- public AstEqual(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj0 = this.children[0].getValue(ctx);
- Object obj1 = this.children[1].getValue(ctx);
- return Boolean.valueOf(equals(obj0, obj1));
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstFalse.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstFalse.java
deleted file mode 100644
index 50d0bc519..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstFalse.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstFalse extends BooleanNode {
- public AstFalse(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- return Boolean.FALSE;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstFloatingPoint.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstFloatingPoint.java
deleted file mode 100644
index f5abb56d6..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstFloatingPoint.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import java.math.BigDecimal;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstFloatingPoint extends SimpleNode {
- public AstFloatingPoint(int id) {
- super(id);
- }
-
- private Number number;
-
- public Number getFloatingPoint() {
- if (this.number == null) {
- try {
- this.number = new Double(this.image);
- } catch (ArithmeticException e0) {
- this.number = new BigDecimal(this.image);
- }
- }
- return this.number;
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- return this.getFloatingPoint();
- }
-
- public Class getType(EvaluationContext ctx)
- throws ELException {
- return this.getFloatingPoint().getClass();
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstFunction.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstFunction.java
deleted file mode 100644
index 75e4c171c..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstFunction.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import jakarta.el.ELException;
-import jakarta.el.FunctionMapper;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-import org.apache.struts2.el.util.MessageFactory;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstFunction extends SimpleNode {
-
- protected String localName = "";
-
- protected String prefix = "";
-
- public AstFunction(int id) {
- super(id);
- }
-
- public String getLocalName() {
- return localName;
- }
-
- public String getOutputName() {
- if (this.prefix == null) {
- return this.localName;
- } else {
- return this.prefix + ":" + this.localName;
- }
- }
-
- public String getPrefix() {
- return prefix;
- }
-
- public Class getType(EvaluationContext ctx)
- throws ELException {
-
- FunctionMapper fnMapper = ctx.getFunctionMapper();
-
- // quickly validate again for this request
- if (fnMapper == null) {
- throw new ELException(MessageFactory.get("error.fnMapper.null"));
- }
- Method m = fnMapper.resolveFunction(this.prefix, this.localName);
- if (m == null) {
- throw new ELException(MessageFactory.get("error.fnMapper.method",
- this.getOutputName()));
- }
- return m.getReturnType();
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
-
- FunctionMapper fnMapper = ctx.getFunctionMapper();
-
- // quickly validate again for this request
- if (fnMapper == null) {
- throw new ELException(MessageFactory.get("error.fnMapper.null"));
- }
- Method m = fnMapper.resolveFunction(this.prefix, this.localName);
- if (m == null) {
- throw new ELException(MessageFactory.get("error.fnMapper.method",
- this.getOutputName()));
- }
-
- Class[] paramTypes = m.getParameterTypes();
- Object[] params = null;
- Object result = null;
- int numParams = this.jjtGetNumChildren();
- if (numParams > 0) {
- params = new Object[numParams];
- try {
- for (int i = 0; i < numParams; i++) {
- params[i] = this.children[i].getValue(ctx);
- params[i] = coerceToType(params[i], paramTypes[i]);
- }
- } catch (ELException ele) {
- throw new ELException(MessageFactory.get("error.function", this
- .getOutputName()), ele);
- }
- }
- try {
- result = m.invoke(null, params);
- } catch (IllegalAccessException iae) {
- throw new ELException(MessageFactory.get("error.function", this
- .getOutputName()), iae);
- } catch (InvocationTargetException ite) {
- throw new ELException(MessageFactory.get("error.function", this
- .getOutputName()), ite.getCause());
- }
- return result;
- }
-
- public void setLocalName(String localName) {
- this.localName = localName;
- }
-
- public void setPrefix(String prefix) {
- this.prefix = prefix;
- }
-
-
- public String toString()
- {
- return ELParserTreeConstants.jjtNodeName[id] + "[" + this.getOutputName() + "]";
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstGreaterThan.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstGreaterThan.java
deleted file mode 100644
index b65371c0a..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstGreaterThan.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstGreaterThan extends BooleanNode {
- public AstGreaterThan(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj0 = this.children[0].getValue(ctx);
- if (obj0 == null) {
- return Boolean.FALSE;
- }
- Object obj1 = this.children[1].getValue(ctx);
- if (obj1 == null) {
- return Boolean.FALSE;
- }
- return (compare(obj0, obj1) > 0) ? Boolean.TRUE : Boolean.FALSE;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstGreaterThanEqual.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstGreaterThanEqual.java
deleted file mode 100644
index 45cf09c21..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstGreaterThanEqual.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstGreaterThanEqual extends BooleanNode {
- public AstGreaterThanEqual(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj0 = this.children[0].getValue(ctx);
- Object obj1 = this.children[1].getValue(ctx);
- if (obj0 == obj1) {
- return Boolean.TRUE;
- }
- if (obj0 == null || obj1 == null) {
- return Boolean.FALSE;
- }
- return (compare(obj0, obj1) >= 0) ? Boolean.TRUE : Boolean.FALSE;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstIdentifier.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstIdentifier.java
deleted file mode 100644
index 7c003be96..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstIdentifier.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-import jakarta.el.MethodExpression;
-import jakarta.el.MethodInfo;
-import jakarta.el.MethodNotFoundException;
-import jakarta.el.ValueExpression;
-import jakarta.el.VariableMapper;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstIdentifier extends SimpleNode {
- public AstIdentifier(int id) {
- super(id);
- }
-
- public Class getType(EvaluationContext ctx) throws ELException {
- VariableMapper varMapper = ctx.getVariableMapper();
- if (varMapper != null) {
- ValueExpression expr = varMapper.resolveVariable(this.image);
- if (expr != null) {
- return expr.getType(ctx.getELContext());
- }
- }
- ctx.setPropertyResolved(false);
- return ctx.getELResolver().getType(ctx, null, this.image);
- }
-
- public Object getValue(EvaluationContext ctx) throws ELException {
- VariableMapper varMapper = ctx.getVariableMapper();
- if (varMapper != null) {
- ValueExpression expr = varMapper.resolveVariable(this.image);
- if (expr != null) {
- return expr.getValue(ctx.getELContext());
- }
- }
- ctx.setPropertyResolved(false);
- return ctx.getELResolver().getValue(ctx, null, this.image);
- }
-
- public boolean isReadOnly(EvaluationContext ctx) throws ELException {
- VariableMapper varMapper = ctx.getVariableMapper();
- if (varMapper != null) {
- ValueExpression expr = varMapper.resolveVariable(this.image);
- if (expr != null) {
- return expr.isReadOnly(ctx.getELContext());
- }
- }
- ctx.setPropertyResolved(false);
- return ctx.getELResolver().isReadOnly(ctx, null, this.image);
- }
-
- public void setValue(EvaluationContext ctx, Object value)
- throws ELException {
- VariableMapper varMapper = ctx.getVariableMapper();
- if (varMapper != null) {
- ValueExpression expr = varMapper.resolveVariable(this.image);
- if (expr != null) {
- expr.setValue(ctx.getELContext(), value);
- return;
- }
- }
- ctx.setPropertyResolved(false);
- ctx.getELResolver().setValue(ctx, null, this.image, value);
- }
-
- public Object invoke(EvaluationContext ctx, Class[] paramTypes,
- Object[] paramValues) throws ELException {
- return this.getMethodExpression(ctx).invoke(ctx.getELContext(), paramValues);
- }
-
-
- public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes)
- throws ELException {
- return this.getMethodExpression(ctx).getMethodInfo(ctx.getELContext());
- }
-
- private final MethodExpression getMethodExpression(EvaluationContext ctx)
- throws ELException {
- Object obj = null;
-
- // case A: ValueExpression exists, getValue which must
- // be a MethodExpression
- VariableMapper varMapper = ctx.getVariableMapper();
- ValueExpression ve = null;
- if (varMapper != null) {
- ve = varMapper.resolveVariable(this.image);
- if (ve != null) {
- obj = ve.getValue(ctx);
- }
- }
-
- // case B: evaluate the identity against the ELResolver, again, must be
- // a MethodExpression to be able to invoke
- if (ve == null) {
- ctx.setPropertyResolved(false);
- obj = ctx.getELResolver().getValue(ctx, null, this.image);
- }
-
- // finally provide helpful hints
- if (obj instanceof MethodExpression) {
- return (MethodExpression) obj;
- } else if (obj == null) {
- throw new MethodNotFoundException("Identity '" + this.image
- + "' was null and was unable to invoke");
- } else {
- throw new ELException(
- "Identity '"
- + this.image
- + "' does not reference a MethodExpression instance, returned type: "
- + obj.getClass().getName());
- }
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstInteger.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstInteger.java
deleted file mode 100644
index 05329b33f..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstInteger.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import java.math.BigInteger;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstInteger extends SimpleNode {
- public AstInteger(int id) {
- super(id);
- }
-
- private Number number;
-
- protected Number getInteger() {
- if (this.number == null) {
- try {
- this.number = new Long(this.image);
- } catch (ArithmeticException e1) {
- this.number = new BigInteger(this.image);
- }
- }
- return number;
- }
-
- public Class getType(EvaluationContext ctx)
- throws ELException {
- return this.getInteger().getClass();
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- return this.getInteger();
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstLessThan.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstLessThan.java
deleted file mode 100644
index 71bc6f545..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstLessThan.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstLessThan extends BooleanNode {
- public AstLessThan(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj0 = this.children[0].getValue(ctx);
- if (obj0 == null) {
- return Boolean.FALSE;
- }
- Object obj1 = this.children[1].getValue(ctx);
- if (obj1 == null) {
- return Boolean.FALSE;
- }
- return (compare(obj0, obj1) < 0) ? Boolean.TRUE : Boolean.FALSE;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstLessThanEqual.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstLessThanEqual.java
deleted file mode 100644
index 449ad6379..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstLessThanEqual.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstLessThanEqual extends BooleanNode {
- public AstLessThanEqual(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj0 = this.children[0].getValue(ctx);
- Object obj1 = this.children[1].getValue(ctx);
- if (obj0 == obj1) {
- return Boolean.TRUE;
- }
- if (obj0 == null || obj1 == null) {
- return Boolean.FALSE;
- }
- return (compare(obj0, obj1) <= 0) ? Boolean.TRUE : Boolean.FALSE;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstLiteralExpression.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstLiteralExpression.java
deleted file mode 100644
index 28459472b..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstLiteralExpression.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstLiteralExpression extends SimpleNode {
- public AstLiteralExpression(int id) {
- super(id);
- }
-
- public Class getType(EvaluationContext ctx) throws ELException {
- return String.class;
- }
-
- public Object getValue(EvaluationContext ctx) throws ELException {
- return this.image;
- }
-
- public void setImage(String image) {
- if (image.indexOf('\\') == -1) {
- this.image = image;
- return;
- }
- int size = image.length();
- StringBuffer buf = new StringBuffer(size);
- for (int i = 0; i < size; i++) {
- char c = image.charAt(i);
- if (c == '\\' && i + 1 < size) {
- char c1 = image.charAt(i + 1);
- if (c1 == '\\' || c1 == '"' || c1 == '\'' || c1 == '#'
- || c1 == '$') {
- c = c1;
- i++;
- }
- }
- buf.append(c);
- }
- this.image = buf.toString();
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstMinus.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstMinus.java
deleted file mode 100644
index 83007f665..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstMinus.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.ELArithmetic;
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstMinus extends ArithmeticNode {
- public AstMinus(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj0 = this.children[0].getValue(ctx);
- Object obj1 = this.children[1].getValue(ctx);
- return ELArithmetic.subtract(obj0, obj1);
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstMod.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstMod.java
deleted file mode 100644
index b5a6e4a53..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstMod.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.ELArithmetic;
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstMod extends ArithmeticNode {
- public AstMod(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj0 = this.children[0].getValue(ctx);
- Object obj1 = this.children[1].getValue(ctx);
- return ELArithmetic.mod(obj0, obj1);
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstMult.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstMult.java
deleted file mode 100644
index 6c523faa0..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstMult.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.ELArithmetic;
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstMult extends ArithmeticNode {
- public AstMult(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj0 = this.children[0].getValue(ctx);
- Object obj1 = this.children[1].getValue(ctx);
- return ELArithmetic.multiply(obj0, obj1);
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstNegative.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstNegative.java
deleted file mode 100644
index 8a8a2d443..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstNegative.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstNegative extends SimpleNode {
- public AstNegative(int id) {
- super(id);
- }
-
- public Class getType(EvaluationContext ctx)
- throws ELException {
- return Number.class;
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj = this.children[0].getValue(ctx);
-
- if (obj == null) {
- return new Long(0);
- }
- if (obj instanceof BigDecimal) {
- return ((BigDecimal) obj).negate();
- }
- if (obj instanceof BigInteger) {
- return ((BigInteger) obj).negate();
- }
- if (obj instanceof String) {
- if (isStringFloat((String) obj)) {
- return new Double(-Double.parseDouble((String) obj));
- }
- return new Long(-Long.parseLong((String) obj));
- }
- if (obj instanceof Long) {
- return new Long(-((Long) obj).longValue());
- }
- if (obj instanceof Double) {
- return new Double(-((Double) obj).doubleValue());
- }
- if (obj instanceof Integer) {
- return new Integer(-((Integer) obj).intValue());
- }
- if (obj instanceof Float) {
- return new Float(-((Float) obj).floatValue());
- }
- if (obj instanceof Short) {
- return new Short((short) -((Short) obj).shortValue());
- }
- if (obj instanceof Byte) {
- return new Byte((byte) -((Byte) obj).byteValue());
- }
- Long num = (Long) coerceToNumber(obj, Long.class);
- return new Long(-num.longValue());
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstNot.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstNot.java
deleted file mode 100644
index c4502145f..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstNot.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstNot extends SimpleNode {
- public AstNot(int id) {
- super(id);
- }
-
- public Class getType(EvaluationContext ctx)
- throws ELException {
- return Boolean.class;
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj = this.children[0].getValue(ctx);
- Boolean b = coerceToBoolean(obj);
- return Boolean.valueOf(!b.booleanValue());
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstNotEqual.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstNotEqual.java
deleted file mode 100644
index 69dda755f..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstNotEqual.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstNotEqual extends BooleanNode {
- public AstNotEqual(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj0 = this.children[0].getValue(ctx);
- Object obj1 = this.children[1].getValue(ctx);
- return Boolean.valueOf(!equals(obj0, obj1));
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstNull.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstNull.java
deleted file mode 100644
index 7957116ef..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstNull.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstNull extends SimpleNode {
- public AstNull(int id) {
- super(id);
- }
-
- public Class getType(EvaluationContext ctx)
- throws ELException {
- return null;
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- return null;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstOr.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstOr.java
deleted file mode 100644
index 94ee77be7..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstOr.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstOr extends BooleanNode {
- public AstOr(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj = this.children[0].getValue(ctx);
- Boolean b = coerceToBoolean(obj);
- if (b.booleanValue()) {
- return b;
- }
- obj = this.children[1].getValue(ctx);
- b = coerceToBoolean(obj);
- return b;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstPlus.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstPlus.java
deleted file mode 100644
index 7cff22bc5..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstPlus.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.ELArithmetic;
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstPlus extends ArithmeticNode {
- public AstPlus(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- Object obj0 = this.children[0].getValue(ctx);
- Object obj1 = this.children[1].getValue(ctx);
- return ELArithmetic.add(obj0, obj1);
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstString.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstString.java
deleted file mode 100644
index fc4c1aa88..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstString.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstString extends SimpleNode {
- public AstString(int id) {
- super(id);
- }
-
- private String string;
-
- public String getString() {
- if (this.string == null) {
- this.string = this.image.substring(1, this.image.length() - 1);
- }
- return this.string;
- }
-
- public Class getType(EvaluationContext ctx)
- throws ELException {
- return String.class;
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- return this.getString();
- }
-
- public void setImage(String image) {
- if (image.indexOf('\\') == -1) {
- this.image = image;
- return;
- }
- int size = image.length();
- StringBuffer buf = new StringBuffer(size);
- for (int i = 0; i < size; i++) {
- char c = image.charAt(i);
- if (c == '\\' && i + 1 < size) {
- char c1 = image.charAt(i + 1);
- if (c1 == '\\' || c1 == '"' || c1 == '\'' || c1 == '#'
- || c1 == '$') {
- c = c1;
- i++;
- }
- }
- buf.append(c);
- }
- this.image = buf.toString();
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstTrue.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstTrue.java
deleted file mode 100644
index 30a65c513..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstTrue.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstTrue extends BooleanNode {
- public AstTrue(int id) {
- super(id);
- }
-
- public Object getValue(EvaluationContext ctx)
- throws ELException {
- return Boolean.TRUE;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstValue.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstValue.java
deleted file mode 100644
index ea7df4887..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/AstValue.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import jakarta.el.ELException;
-import jakarta.el.ELResolver;
-import jakarta.el.MethodInfo;
-import jakarta.el.PropertyNotFoundException;
-
-import org.apache.struts2.el.lang.ELSupport;
-import org.apache.struts2.el.lang.EvaluationContext;
-import org.apache.struts2.el.util.MessageFactory;
-import org.apache.struts2.el.util.ReflectionUtil;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public final class AstValue extends SimpleNode {
-
- protected static final boolean COERCE_TO_ZERO =
- Boolean.valueOf(System.getProperty(
- "org.apache.el.parser.COERCE_TO_ZERO", "true")).booleanValue();
-
- protected static class Target {
- protected Object base;
-
- protected Object property;
- }
-
- public AstValue(int id) {
- super(id);
- }
-
- public Class getType(EvaluationContext ctx) throws ELException {
- Target t = getTarget(ctx);
- ctx.setPropertyResolved(false);
- return ctx.getELResolver().getType(ctx, t.base, t.property);
- }
-
- private final Target getTarget(EvaluationContext ctx) throws ELException {
- // evaluate expr-a to value-a
- Object base = this.children[0].getValue(ctx);
-
- // if our base is null (we know there are more properites to evaluate)
- if (base == null) {
- throw new PropertyNotFoundException(MessageFactory.get(
- "error.unreachable.base", this.children[0].getImage()));
- }
-
- // set up our start/end
- Object property = null;
- int propCount = this.jjtGetNumChildren() - 1;
- int i = 1;
-
- // evaluate any properties before our target
- ELResolver resolver = ctx.getELResolver();
- if (propCount > 1) {
- while (base != null && i < propCount) {
- property = this.children[i].getValue(ctx);
- ctx.setPropertyResolved(false);
- base = resolver.getValue(ctx, base, property);
- i++;
- }
- // if we are in this block, we have more properties to resolve,
- // but our base was null
- if (base == null || property == null) {
- throw new PropertyNotFoundException(MessageFactory.get(
- "error.unreachable.property", property));
- }
- }
-
- property = this.children[i].getValue(ctx);
-
- if (property == null) {
- throw new PropertyNotFoundException(MessageFactory.get(
- "error.unreachable.property", this.children[i]));
- }
-
- Target t = new Target();
- t.base = base;
- t.property = property;
- return t;
- }
-
- public Object getValue(EvaluationContext ctx) throws ELException {
- Object base = this.children[0].getValue(ctx);
- int propCount = this.jjtGetNumChildren();
- int i = 1;
- Object property = null;
- ELResolver resolver = ctx.getELResolver();
- while (base != null && i < propCount) {
- property = this.children[i].getValue(ctx);
- if (property == null) {
- return null;
- } else {
- ctx.setPropertyResolved(false);
- base = resolver.getValue(ctx, base, property);
- }
- i++;
- }
- return base;
- }
-
- public boolean isReadOnly(EvaluationContext ctx) throws ELException {
- Target t = getTarget(ctx);
- ctx.setPropertyResolved(false);
- return ctx.getELResolver().isReadOnly(ctx, t.base, t.property);
- }
-
- public void setValue(EvaluationContext ctx, Object value)
- throws ELException {
- Target t = getTarget(ctx);
- ctx.setPropertyResolved(false);
- ELResolver resolver = ctx.getELResolver();
-
- // coerce to the expected type
- Class> targetClass = resolver.getType(ctx, t.base, t.property);
- if (COERCE_TO_ZERO == true
- || !isAssignable(value, targetClass)) {
- value = ELSupport.coerceToType(value, targetClass);
- }
- resolver.setValue(ctx, t.base, t.property, value);
- }
-
- private boolean isAssignable(Object value, Class> targetClass) {
- if (targetClass == null) {
- return false;
- } else if (value != null && targetClass.isPrimitive()) {
- return false;
- } else if (value != null && !targetClass.isInstance(value)) {
- return false;
- }
- return true;
- }
-
-
- public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes)
- throws ELException {
- Target t = getTarget(ctx);
- Method m = ReflectionUtil.getMethod(t.base, t.property, paramTypes);
- return new MethodInfo(m.getName(), m.getReturnType(), m
- .getParameterTypes());
- }
-
- public Object invoke(EvaluationContext ctx, Class[] paramTypes,
- Object[] paramValues) throws ELException {
- Target t = getTarget(ctx);
- Method m = ReflectionUtil.getMethod(t.base, t.property, paramTypes);
- Object result = null;
- try {
- result = m.invoke(t.base, (Object[]) paramValues);
- } catch (IllegalAccessException iae) {
- throw new ELException(iae);
- } catch (InvocationTargetException ite) {
- throw new ELException(ite.getCause());
- }
- return result;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/BooleanNode.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/BooleanNode.java
deleted file mode 100644
index 574b24891..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/BooleanNode.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.struts2.el.parser;
-
-import jakarta.el.ELException;
-
-import org.apache.struts2.el.lang.EvaluationContext;
-
-/**
- * @author Jacob Hookom [jacob@hookom.net]
- * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
- */
-public class BooleanNode extends SimpleNode {
- /**
- * @param i i
- */
- public BooleanNode(int i) {
- super(i);
- }
- public Class getType(EvaluationContext ctx)
- throws ELException {
- return Boolean.class;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/ELParser.html b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/ELParser.html
deleted file mode 100644
index 24a312a6c..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/ELParser.html
+++ /dev/null
@@ -1,223 +0,0 @@
-
-
-
-
-BNF for ELParser.jj
-
-
-
- *
- * @author Danno Ferrin
- * @author Pierre Delisle
- * @author Costin Manolache
- * @author Yoav Shapira
- */
-public class JspC implements Options {
-
- public static final String DEFAULT_IE_CLASS_ID =
- "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
-
- // Logger
- protected static Log log = LogFactory.getLog(JspC.class);
-
- protected static final String SWITCH_VERBOSE = "-v";
- protected static final String SWITCH_HELP = "-help";
- protected static final String SWITCH_OUTPUT_DIR = "-d";
- protected static final String SWITCH_PACKAGE_NAME = "-p";
- protected static final String SWITCH_CACHE = "-cache";
- protected static final String SWITCH_CLASS_NAME = "-c";
- protected static final String SWITCH_FULL_STOP = "--";
- protected static final String SWITCH_COMPILE = "-compile";
- protected static final String SWITCH_SOURCE = "-source";
- protected static final String SWITCH_TARGET = "-target";
- protected static final String SWITCH_URI_BASE = "-uribase";
- protected static final String SWITCH_URI_ROOT = "-uriroot";
- protected static final String SWITCH_FILE_WEBAPP = "-webapp";
- protected static final String SWITCH_WEBAPP_INC = "-webinc";
- protected static final String SWITCH_WEBAPP_XML = "-webxml";
- protected static final String SWITCH_MAPPED = "-mapped";
- protected static final String SWITCH_XPOWERED_BY = "-xpoweredBy";
- protected static final String SWITCH_TRIM_SPACES = "-trimSpaces";
- protected static final String SWITCH_CLASSPATH = "-classpath";
- protected static final String SWITCH_DIE = "-die";
- protected static final String SWITCH_POOLING = "-poolingEnabled";
- protected static final String SWITCH_ENCODING = "-javaEncoding";
- protected static final String SWITCH_SMAP = "-smap";
- protected static final String SWITCH_DUMP_SMAP = "-dumpsmap";
-
- protected static final String SHOW_SUCCESS ="-s";
- protected static final String LIST_ERRORS = "-l";
- protected static final int INC_WEBXML = 10;
- protected static final int ALL_WEBXML = 20;
- protected static final int DEFAULT_DIE_LEVEL = 1;
- protected static final int NO_DIE_LEVEL = 0;
-
- protected static final String[] insertBefore =
- { "", "", "",
- "", "", "", "",
- "", "", "",
- "", "", "", "",
- "" };
-
- protected static int die;
- protected String classPath = null;
- protected URLClassLoader loader = null;
- protected boolean trimSpaces = false;
- protected boolean genStringAsCharArray = false;
- protected boolean xpoweredBy;
- protected boolean mappedFile = false;
- protected boolean poolingEnabled = true;
- protected File scratchDir;
- protected String ieClassId = DEFAULT_IE_CLASS_ID;
- protected String targetPackage;
- protected String targetClassName;
- protected String uriBase;
- protected String uriRoot;
- protected int dieLevel;
- protected boolean helpNeeded = false;
- protected boolean compile = false;
- protected boolean smapSuppressed = true;
- protected boolean smapDumped = false;
- protected boolean caching = true;
- protected Map cache = new HashMap();
-
- protected String compiler = null;
-
- protected String compilerTargetVM = "1.4";
- protected String compilerSourceVM = "1.4";
-
- protected boolean classDebugInfo = true;
-
- /**
- * Throw an exception if there's a compilation error, or swallow it.
- * Default is true to preserve old behavior.
- */
- protected boolean failOnError = true;
-
- /**
- * The file extensions to be handled as JSP files.
- * Default list is .jsp and .jspx.
- */
- protected List extensions;
-
- /**
- * The pages.
- */
- protected List pages = new Vector();
-
- /**
- * Needs better documentation, this data member does.
- * True by default.
- */
- protected boolean errorOnUseBeanInvalidClassAttribute = true;
-
- /**
- * The java file encoding. Default
- * is UTF-8. Added per bugzilla 19622.
- */
- protected String javaEncoding = "UTF-8";
-
- // Generation of web.xml fragments
- protected String webxmlFile;
- protected int webxmlLevel;
- protected boolean addWebXmlMappings = false;
-
- protected Writer mapout;
- protected CharArrayWriter servletout;
- protected CharArrayWriter mappingout;
-
- /**
- * The servlet context.
- */
- protected JspCServletContext context;
-
- /**
- * The runtime context.
- * Maintain a dummy JspRuntimeContext for compiling tag files.
- */
- protected JspRuntimeContext rctxt;
-
- /**
- * Cache for the TLD locations
- */
- protected TldLocationsCache tldLocationsCache = null;
-
- protected JspConfig jspConfig = null;
- protected TagPluginManager tagPluginManager = null;
-
- protected boolean verbose = false;
- protected boolean listErrors = false;
- protected boolean showSuccess = false;
- protected int argPos;
- protected boolean fullstop = false;
- protected String args[];
-
- private String sourceCode;
- private ClassLoaderInterface classLoaderInterface;
-
-
- public static void main(String arg[]) {
- if (arg.length == 0) {
- System.out.println(Localizer.getMessage("jspc.usage"));
- } else {
- try {
- JspC jspc = new JspC();
- jspc.setArgs(arg);
- if (jspc.helpNeeded) {
- System.out.println(Localizer.getMessage("jspc.usage"));
- } else {
- jspc.execute();
- }
- } catch (JasperException je) {
- System.err.println(je);
- if (die != NO_DIE_LEVEL) {
- System.exit(die);
- }
- }
- }
- }
-
- public void setArgs(String[] arg) throws JasperException {
- args = arg;
- String tok;
-
- dieLevel = NO_DIE_LEVEL;
- die = dieLevel;
-
- while ((tok = nextArg()) != null) {
- if (tok.equals(SWITCH_VERBOSE)) {
- verbose = true;
- showSuccess = true;
- listErrors = true;
- } else if (tok.equals(SWITCH_PACKAGE_NAME)) {
- targetPackage = nextArg();
- } else if (tok.equals(SWITCH_COMPILE)) {
- compile=true;
- } else if (tok.equals(SWITCH_CLASS_NAME)) {
- targetClassName = nextArg();
- } else if (tok.equals(SWITCH_URI_BASE)) {
- uriBase=nextArg();
- } else if ( tok.equals( SHOW_SUCCESS ) ) {
- showSuccess = true;
- } else if ( tok.equals( LIST_ERRORS ) ) {
- listErrors = true;
- } else if (tok.equals(SWITCH_WEBAPP_INC)) {
- webxmlFile = nextArg();
- if (webxmlFile != null) {
- webxmlLevel = INC_WEBXML;
- }
- } else if (tok.equals(SWITCH_WEBAPP_XML)) {
- webxmlFile = nextArg();
- if (webxmlFile != null) {
- webxmlLevel = ALL_WEBXML;
- }
- } else if (tok.equals(SWITCH_MAPPED)) {
- mappedFile = true;
- } else if (tok.equals(SWITCH_XPOWERED_BY)) {
- xpoweredBy = true;
- } else if (tok.equals(SWITCH_TRIM_SPACES)) {
- setTrimSpaces(true);
- } else if (tok.equals(SWITCH_CACHE)) {
- tok = nextArg();
- if ("false".equals(tok)) {
- caching = false;
- } else {
- caching = true;
- }
- } else if (tok.equals(SWITCH_CLASSPATH)) {
- setClassPath(nextArg());
- } else if (tok.startsWith(SWITCH_DIE)) {
- try {
- dieLevel = Integer.parseInt(
- tok.substring(SWITCH_DIE.length()));
- } catch (NumberFormatException nfe) {
- dieLevel = DEFAULT_DIE_LEVEL;
- }
- die = dieLevel;
- } else if (tok.equals(SWITCH_HELP)) {
- helpNeeded = true;
- } else if (tok.equals(SWITCH_POOLING)) {
- tok = nextArg();
- if ("false".equals(tok)) {
- poolingEnabled = false;
- } else {
- poolingEnabled = true;
- }
- } else if (tok.equals(SWITCH_ENCODING)) {
- setJavaEncoding(nextArg());
- } else if (tok.equals(SWITCH_SOURCE)) {
- setCompilerSourceVM(nextArg());
- } else if (tok.equals(SWITCH_TARGET)) {
- setCompilerTargetVM(nextArg());
- } else if (tok.equals(SWITCH_SMAP)) {
- smapSuppressed = false;
- } else if (tok.equals(SWITCH_DUMP_SMAP)) {
- smapDumped = true;
- } else {
- if (tok.startsWith("-")) {
- throw new JasperException("Unrecognized option: " + tok +
- ". Use -help for help.");
- }
- if (!fullstop) {
- argPos--;
- }
- // Start treating the rest as JSP Pages
- break;
- }
- }
-
- // Add all extra arguments to the list of files
- while( true ) {
- String file = nextFile();
- if( file==null ) {
- break;
- }
- pages.add( file );
- }
- }
-
- public String getSourceCode() {
- return sourceCode;
- }
-
- public void setClassLoaderInterface(ClassLoaderInterface classLoaderInterface) {
- this.classLoaderInterface = classLoaderInterface;
- }
-
- public Set getTldAbsolutePaths() {
- return tldLocationsCache.getAbsolutePathsOfLocations();
- }
-
-
-
- public boolean getKeepGenerated() {
- // isn't this why we are running jspc?
- return true;
- }
-
- public boolean getTrimSpaces() {
- return trimSpaces;
- }
-
- public void setTrimSpaces(boolean ts) {
- this.trimSpaces = ts;
- }
-
- public boolean isPoolingEnabled() {
- return poolingEnabled;
- }
-
- public void setPoolingEnabled(boolean poolingEnabled) {
- this.poolingEnabled = poolingEnabled;
- }
-
- public boolean isXpoweredBy() {
- return xpoweredBy;
- }
-
- public void setXpoweredBy(boolean xpoweredBy) {
- this.xpoweredBy = xpoweredBy;
- }
-
- public boolean getDisplaySourceFragment() {
- return true;
- }
-
- public boolean getErrorOnUseBeanInvalidClassAttribute() {
- return errorOnUseBeanInvalidClassAttribute;
- }
-
- public void setErrorOnUseBeanInvalidClassAttribute(boolean b) {
- errorOnUseBeanInvalidClassAttribute = b;
- }
-
- public int getTagPoolSize() {
- return Constants.MAX_POOL_SIZE;
- }
-
- /**
- * Are we supporting HTML mapped servlets?
- */
- public boolean getMappedFile() {
- return mappedFile;
- }
-
- // Off-line compiler, no need for security manager
- public Object getProtectionDomain() {
- return null;
- }
-
- public void setClassDebugInfo( boolean b ) {
- classDebugInfo=b;
- }
-
- public boolean getClassDebugInfo() {
- // compile with debug info
- return classDebugInfo;
- }
-
- /*
- * @see Options#isCaching()
- */
- public boolean isCaching() {
- return caching;
- }
-
- /*
- * @see Options#isCaching()
- */
- public void setCaching(boolean caching) {
- this.caching = caching;
- }
-
- /*
- * @see Options#getCache()
- */
- public Map getCache() {
- return cache;
- }
-
- /**
- * @return Background compilation check intervals in seconds
- */
- public int getCheckInterval() {
- return 0;
- }
-
- /**
- * @return Modification test interval.
- */
- public int getModificationTestInterval() {
- return 0;
- }
-
- /**
- * @return Is Jasper being used in development mode?
- */
- public boolean getDevelopment() {
- return false;
- }
-
- /**
- * @return Is the generation of SMAP info for JSR45 debuggin suppressed?
- */
- public boolean isSmapSuppressed() {
- return smapSuppressed;
- }
-
- /**
- * @param smapSuppressed Set smapSuppressed flag.
- */
- public void setSmapSuppressed(boolean smapSuppressed) {
- this.smapSuppressed = smapSuppressed;
- }
-
-
- /**
- * @return Should SMAP info for JSR45 debugging be dumped to a file?
- */
- public boolean isSmapDumped() {
- return smapDumped;
- }
-
- /**
- * @param smapDumped Set smapDumped flag.
- */
- public void setSmapDumped(boolean smapDumped) {
- this.smapDumped = smapDumped;
- }
-
-
- /**
- * Determines whether text strings are to be generated as char arrays,
- * which improves performance in some cases.
- *
- * @param genStringAsCharArray true if text strings are to be generated as
- * char arrays, false otherwise
- */
- public void setGenStringAsCharArray(boolean genStringAsCharArray) {
- this.genStringAsCharArray = genStringAsCharArray;
- }
-
- /**
- * Indicates whether text strings are to be generated as char arrays.
- *
- * @return true if text strings are to be generated as char arrays, false
- * otherwise
- */
- public boolean genStringAsCharArray() {
- return genStringAsCharArray;
- }
-
- /**
- * Sets the class-id value to be sent to Internet Explorer when using
- * <jsp:plugin> tags.
- *
- * @param ieClassId Class-id value
- */
- public void setIeClassId(String ieClassId) {
- this.ieClassId = ieClassId;
- }
-
- /**
- * Gets the class-id value that is sent to Internet Explorer when using
- * <jsp:plugin> tags.
- *
- * @return Class-id value
- */
- public String getIeClassId() {
- return ieClassId;
- }
-
- public File getScratchDir() {
- return scratchDir;
- }
-
- public Class getJspCompilerPlugin() {
- // we don't compile, so this is meanlingless
- return null;
- }
-
- public String getJspCompilerPath() {
- // we don't compile, so this is meanlingless
- return null;
- }
-
- /**
- * @return Compiler to use.
- */
- public String getCompiler() {
- return compiler;
- }
-
- public void setCompiler(String c) {
- compiler=c;
- }
-
- /**
- * @return Compiler class name to use.
- */
- public String getCompilerClassName() {
- return null;
- }
-
- /*
- * @see Options#getCompilerTargetVM
- */
- public String getCompilerTargetVM() {
- return compilerTargetVM;
- }
-
- public void setCompilerTargetVM(String vm) {
- compilerTargetVM = vm;
- }
-
- /*
- * @see Options#getCompilerSourceVM()
- */
- public String getCompilerSourceVM() {
- return compilerSourceVM;
- }
-
- /*
- * @see Options#getCompilerSourceVM()
- */
- public void setCompilerSourceVM(String vm) {
- compilerSourceVM = vm;
- }
-
- public TldLocationsCache getTldLocationsCache() {
- return tldLocationsCache;
- }
-
- /**
- * Returns the encoding to use for
- * java files. The default is UTF-8.
- *
- * @return String The encoding
- */
- public String getJavaEncoding() {
- return javaEncoding;
- }
-
- /**
- * Sets the encoding to use for
- * java files.
- *
- * @param encodingName The name, e.g. "UTF-8"
- */
- public void setJavaEncoding(String encodingName) {
- javaEncoding = encodingName;
- }
-
- public boolean getFork() {
- return false;
- }
-
- public String getClassPath() {
- if( classPath != null )
- return classPath;
- return System.getProperty("java.class.path");
- }
-
- public void setClassPath(String s) {
- classPath=s;
- }
-
- /**
- * Returns the list of file extensions
- * that are treated as JSP files.
- *
- * @return The list of extensions
- */
- public List getExtensions() {
- return extensions;
- }
-
- /**
- * Adds the given file extension to the
- * list of extensions handled as JSP files.
- *
- * @param extension The extension to add, e.g. "myjsp"
- */
- protected void addExtension(final String extension) {
- if(extension != null) {
- if(extensions == null) {
- extensions = new Vector();
- }
-
- extensions.add(extension);
- }
- }
-
-
- /**
- * Parses comma-separated list of JSP files to be processed. If the argument
- * is null, nothing is done.
- *
- *
Each file is interpreted relative to uriroot, unless it is absolute,
- * in which case it must start with uriroot.
- *
- * @param jspFiles Comma-separated list of JSP files to be processed
- */
- public void setJspFiles(final String jspFiles) {
- if(jspFiles == null) {
- return;
- }
-
- StringTokenizer tok = new StringTokenizer(jspFiles, ",");
- while (tok.hasMoreTokens()) {
- pages.add(tok.nextToken());
- }
- }
-
- /**
- * Sets the compile flag.
- *
- * @param b Flag value
- */
- public void setCompile( final boolean b ) {
- compile = b;
- }
-
- /**
- * Sets the verbosity level. The actual number doesn't
- * matter: if it's greater than zero, the verbose flag will
- * be true.
- *
- * @param level Positive means verbose
- */
- public void setVerbose( final int level ) {
- if (level > 0) {
- verbose = true;
- showSuccess = true;
- listErrors = true;
- }
- }
-
- public void setValidateXml( boolean b ) {
- ParserUtils.validating=b;
- }
-
- public void setListErrors( boolean b ) {
- listErrors = b;
- }
-
- public void setPackage( String p ) {
- targetPackage=p;
- }
-
- /**
- * @param p Class name of the generated file ( without package ).
- * Can only be used if a single file is converted.
- * XXX Do we need this feature ?
- */
- public void setClassName( String p ) {
- targetClassName=p;
- }
-
- public void setAddWebXmlMappings(boolean b) {
- addWebXmlMappings = b;
- }
-
- /**
- * @param b Set the option that throws an exception in case of a compilation error.
- */
- public void setFailOnError(final boolean b) {
- failOnError = b;
- }
-
- public boolean getFailOnError() {
- return failOnError;
- }
-
- /**
- * @return Obtain JSP configuration information specified in web.xml.
- */
- public JspConfig getJspConfig() {
- return jspConfig;
- }
-
- public TagPluginManager getTagPluginManager() {
- return tagPluginManager;
- }
-
- public void generateWebMapping( String file, JspCompilationContext clctxt )
- throws IOException
- {
- if (log.isDebugEnabled()) {
- log.debug("Generating web mapping for file " + file
- + " using compilation context " + clctxt);
- }
-
- String className = clctxt.getServletClassName();
- String packageName = clctxt.getServletPackageName();
-
- String thisServletName;
- if ("".equals(packageName)) {
- thisServletName = className;
- } else {
- thisServletName = packageName + '.' + className;
- }
-
- if (servletout != null) {
- servletout.write("\n \n ");
- servletout.write(thisServletName);
- servletout.write("\n ");
- servletout.write(thisServletName);
- servletout.write("\n \n");
- }
- if (mappingout != null) {
- mappingout.write("\n \n ");
- mappingout.write(thisServletName);
- mappingout.write("\n ");
- mappingout.write(file.replace('\\', '/'));
- mappingout.write("\n \n");
-
- }
- }
-
- /**
- * Include the generated web.xml inside the webapp's web.xml.
- *
- * @throws IOException in case of IO errors
- */
- protected void mergeIntoWebXml() throws IOException {
-
- File webappBase = new File(uriRoot);
- File webXml = new File(webappBase, "WEB-INF/web.xml");
- File webXml2 = new File(webappBase, "WEB-INF/web2.xml");
- String insertStartMarker =
- Localizer.getMessage("jspc.webinc.insertStart");
- String insertEndMarker =
- Localizer.getMessage("jspc.webinc.insertEnd");
-
- BufferedReader reader = new BufferedReader(new FileReader(webXml));
- BufferedReader fragmentReader =
- new BufferedReader(new FileReader(webxmlFile));
- PrintWriter writer = new PrintWriter(new FileWriter(webXml2));
-
- // Insert the and declarations
- int pos = -1;
- String line = null;
- while (true) {
- line = reader.readLine();
- if (line == null) {
- break;
- }
- // Skip anything previously generated by JSPC
- if (line.indexOf(insertStartMarker) >= 0) {
- while (true) {
- line = reader.readLine();
- if (line == null) {
- return;
- }
- if (line.indexOf(insertEndMarker) >= 0) {
- line = reader.readLine();
- line = reader.readLine();
- if (line == null) {
- return;
- }
- break;
- }
- }
- }
- for (int i = 0; i < insertBefore.length; i++) {
- pos = line.indexOf(insertBefore[i]);
- if (pos >= 0)
- break;
- }
- if (pos >= 0) {
- writer.print(line.substring(0, pos));
- break;
- } else {
- writer.println(line);
- }
- }
-
- writer.println(insertStartMarker);
- while (true) {
- String line2 = fragmentReader.readLine();
- if (line2 == null) {
- writer.println();
- break;
- }
- writer.println(line2);
- }
- writer.println(insertEndMarker);
- writer.println();
-
- for (int i = 0; i < pos; i++) {
- writer.print(" ");
- }
- writer.println(line.substring(pos));
-
- while (true) {
- line = reader.readLine();
- if (line == null) {
- break;
- }
- writer.println(line);
- }
- writer.close();
-
- reader.close();
- fragmentReader.close();
-
- FileInputStream fis = new FileInputStream(webXml2);
- FileOutputStream fos = new FileOutputStream(webXml);
-
- byte buf[] = new byte[512];
- while (true) {
- int n = fis.read(buf);
- if (n < 0) {
- break;
- }
- fos.write(buf, 0, n);
- }
-
- fis.close();
- fos.close();
-
- webXml2.delete();
- (new File(webxmlFile)).delete();
-
- }
-
- private void processFile(String file)
- throws JasperException {
- if (log.isDebugEnabled()) {
- log.debug("Processing file: " + file);
- }
-
- ClassLoader originalClassLoader = null;
-
- try {
- // set up a scratch/output dir if none is provided
- if (scratchDir == null) {
- String temp = System.getProperty("java.io.tmpdir");
- if (temp == null) {
- temp = "";
- }
- scratchDir = new File(new File(temp).getAbsolutePath());
- }
-
- String jspUri = file.replace('\\', '/');
- JspCompilationContext clctxt = new JspCompilationContext
- (jspUri, false, this, context, null, rctxt, classLoaderInterface);
-
- /* Override the defaults */
- if ((targetClassName != null) && (targetClassName.length() > 0)) {
- clctxt.setServletClassName(targetClassName);
- targetClassName = null;
- }
- if (targetPackage != null) {
- clctxt.setServletPackageName(targetPackage);
- }
-
- originalClassLoader = Thread.currentThread().getContextClassLoader();
- if (loader == null) {
- initClassLoader(clctxt);
- }
- Thread.currentThread().setContextClassLoader(loader);
-
- clctxt.setClassLoader(loader);
- clctxt.setClassPath(classPath);
-
- Compiler clc = clctxt.createCompiler();
-
- // If compile is set, generate both .java and .class, if
- // .jsp file is newer than .class file;
- // Otherwise only generate .java, if .jsp file is newer than
- // the .java file
- if (clc.isOutDated(compile)) {
- if (log.isDebugEnabled()) {
- log.debug(jspUri + " is out dated, compiling...");
- }
-
- clc.compile(compile, true);
- }
-
- // Generate mapping
- generateWebMapping(file, clctxt);
- if (showSuccess) {
- log.info("Built File: " + file);
- }
-
- this.sourceCode = clctxt.getSourceCode();
-
- } catch (JasperException je) {
- Throwable rootCause = je;
- while (rootCause instanceof JasperException
- && ((JasperException) rootCause).getRootCause() != null) {
- rootCause = ((JasperException) rootCause).getRootCause();
- }
- if (rootCause != je) {
- log.error(Localizer.getMessage("jspc.error.generalException",
- file),
- rootCause);
- }
-
- // Bugzilla 35114.
- if (getFailOnError()) {
- throw je;
- } else {
- log.error(je.getMessage(), je);
- ;
- }
-
- } catch (Exception e) {
- if ((e instanceof FileNotFoundException) && log.isWarnEnabled()) {
- log.warn(Localizer.getMessage("jspc.error.fileDoesNotExist",
- e.getMessage()));
- }
- throw new JasperException(e);
- } finally {
- if (originalClassLoader != null) {
- Thread.currentThread().setContextClassLoader(originalClassLoader);
- }
- }
- }
-
-
- /**
- * Locate all jsp files in the webapp. Used if no explicit
- * jsps are specified.
- *
- * @param base base
- * @throws JasperException in case of Jasper errors
- */
- public void scanFiles( File base ) throws JasperException {
- Stack dirs = new Stack<>();
- dirs.push(base.toString());
-
- // Make sure default extensions are always included
- if ((getExtensions() == null) || (getExtensions().size() < 2)) {
- addExtension("jsp");
- addExtension("jspx");
- }
-
- while (!dirs.isEmpty()) {
- String s = dirs.pop();
- File f = new File(s);
- if (f.exists() && f.isDirectory()) {
- String[] files = f.list();
- String ext;
- for (int i = 0; (files != null) && i < files.length; i++) {
- File f2 = new File(s, files[i]);
- if (f2.isDirectory()) {
- dirs.push(f2.getPath());
- } else {
- String path = f2.getPath();
- String uri = path.substring(uriRoot.length());
- ext = files[i].substring(files[i].lastIndexOf('.') +1);
- if (getExtensions().contains(ext) ||
- jspConfig.isJspPage(uri)) {
- pages.add(path);
- }
- }
- }
- }
- }
- }
-
- /**
- * Executes the compilation.
- *
- * @throws JasperException If an error occurs
- */
- public void execute() throws JasperException {
- if (log.isDebugEnabled()) {
- log.debug("execute() starting for " + pages.size() + " pages.");
- }
-
- try {
- if (context == null) {
- initServletContext();
- }
-
- initWebXml();
-
- Iterator iter = pages.iterator();
- while (iter.hasNext()) {
- String nextjsp = iter.next().toString();
-
- processFile(nextjsp);
- }
-
- completeWebXml();
- } catch (JasperException je) {
- Throwable rootCause = je;
- while (rootCause instanceof JasperException
- && ((JasperException) rootCause).getRootCause() != null) {
- rootCause = ((JasperException) rootCause).getRootCause();
- }
- if (rootCause != je) {
- rootCause.printStackTrace();
- }
- throw je;
- }
- }
- // ==================== protected utility methods ====================
-
- protected String nextArg() {
- if ((argPos >= args.length)
- || (fullstop = SWITCH_FULL_STOP.equals(args[argPos]))) {
- return null;
- } else {
- return args[argPos++];
- }
- }
-
- protected String nextFile() {
- if (fullstop) argPos++;
- if (argPos >= args.length) {
- return null;
- } else {
- return args[argPos++];
- }
- }
-
- protected void initWebXml() {
- try {
- if (webxmlLevel >= INC_WEBXML) {
- File fmapings = new File(webxmlFile);
- mapout = new FileWriter(fmapings);
- servletout = new CharArrayWriter();
- mappingout = new CharArrayWriter();
- } else {
- mapout = null;
- servletout = null;
- mappingout = null;
- }
- if (webxmlLevel >= ALL_WEBXML) {
- mapout.write(Localizer.getMessage("jspc.webxml.header"));
- mapout.flush();
- } else if ((webxmlLevel>= INC_WEBXML) && !addWebXmlMappings) {
- mapout.write(Localizer.getMessage("jspc.webinc.header"));
- mapout.flush();
- }
- } catch (IOException ioe) {
- mapout = null;
- servletout = null;
- mappingout = null;
- }
- }
-
- protected void completeWebXml() {
- if (mapout != null) {
- try {
- servletout.writeTo(mapout);
- mappingout.writeTo(mapout);
- if (webxmlLevel >= ALL_WEBXML) {
- mapout.write(Localizer.getMessage("jspc.webxml.footer"));
- } else if ((webxmlLevel >= INC_WEBXML) && !addWebXmlMappings) {
- mapout.write(Localizer.getMessage("jspc.webinc.footer"));
- }
- mapout.close();
- } catch (IOException ioe) {
- // noting to do if it fails since we are done with it
- }
- }
- }
-
- protected void initServletContext() {
-
- context = new JspCServletContext
- (new PrintWriter(System.out),
- classLoaderInterface);
- tldLocationsCache = new TldLocationsCache(context, true);
-
- rctxt = new JspRuntimeContext(context, this);
- jspConfig = new JspConfig(context);
- tagPluginManager = new TagPluginManager(context);
- }
-
- /**
- * Initializes the classloader as/if needed for the given
- * compilation context.
- *
- * @param clctxt The compilation context
- * @throws IOException If an error occurs
- */
- private void initClassLoader(JspCompilationContext clctxt)
- throws IOException {
-
- classPath = getClassPath();
-
- ClassLoader jspcLoader = getClass().getClassLoader();
- // Turn the classPath into URLs
- ArrayList urls = new ArrayList();
- StringTokenizer tokenizer = new StringTokenizer(classPath,
- File.pathSeparator);
- while (tokenizer.hasMoreTokens()) {
- String path = tokenizer.nextToken();
- try {
- File libFile = new File(path);
- urls.add(libFile.toURL());
- } catch (IOException ioe) {
- // Failing a toCanonicalPath on a file that
- // exists() should be a JVM regression test,
- // therefore we have permission to freak uot
- throw new RuntimeException(ioe.toString());
- }
- }
-
- //TODO: add .tld files to the URLCLassLoader
-
- URL urlsA[] = new URL[urls.size()];
- urls.toArray(urlsA);
- loader = new URLClassLoader(urlsA, this.getClass().getClassLoader());
-
- }
-
- /**
- * Find the WEB-INF dir by looking up in the directory tree.
- * This is used if no explicit docbase is set, but only files.
- * XXX Maybe we should require the docbase.
- *
- * @param f start file for lookup
- */
- protected void locateUriRoot( File f ) {
- String tUriBase = uriBase;
- if (tUriBase == null) {
- tUriBase = "/";
- }
- try {
- if (f.exists()) {
- f = new File(f.getAbsolutePath());
- while (f != null) {
- File g = new File(f, "WEB-INF");
- if (g.exists() && g.isDirectory()) {
- uriRoot = f.getCanonicalPath();
- uriBase = tUriBase;
- if (log.isInfoEnabled()) {
- log.info(Localizer.getMessage(
- "jspc.implicit.uriRoot",
- uriRoot));
- }
- break;
- }
- if (f.exists() && f.isDirectory()) {
- tUriBase = "/" + f.getName() + "/" + tUriBase;
- }
-
- String fParent = f.getParent();
- if (fParent == null) {
- break;
- } else {
- f = new File(fParent);
- }
-
- // If there is no acceptible candidate, uriRoot will
- // remain null to indicate to the CompilerContext to
- // use the current working/user dir.
- }
-
- if (uriRoot != null) {
- File froot = new File(uriRoot);
- uriRoot = froot.getCanonicalPath();
- }
- }
- } catch (IOException ioe) {
- // since this is an optional default and a null value
- // for uriRoot has a non-error meaning, we can just
- // pass straight through
- }
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JspCompilationContext.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JspCompilationContext.java
deleted file mode 100644
index 8bfecc6f3..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JspCompilationContext.java
+++ /dev/null
@@ -1,732 +0,0 @@
-/*
- * 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.struts2.jasper;
-
-import com.opensymphony.xwork2.util.finder.ClassLoaderInterface;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.struts2.jasper.compiler.Compiler;
-import org.apache.struts2.jasper.compiler.JspRuntimeContext;
-import org.apache.struts2.jasper.compiler.JspUtil;
-import org.apache.struts2.jasper.compiler.Localizer;
-import org.apache.struts2.jasper.compiler.ServletWriter;
-import org.apache.struts2.jasper.servlet.JasperLoader;
-import org.apache.struts2.jasper.servlet.JspServletWrapper;
-
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.jsp.tagext.TagInfo;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A place holder for various things that are used through out the JSP
- * engine. This is a per-request/per-context data structure. Some of
- * the instance variables are set at different points.
- *
- * Most of the path-related stuff is here - mangling names, versions, dirs,
- * loading resources and dealing with uris.
- *
- * @author Anil K. Vijendran
- * @author Harish Prabandham
- * @author Pierre Delisle
- * @author Costin Manolache
- * @author Kin-man Chung
- */
-public class JspCompilationContext {
-
- protected org.apache.juli.logging.Log log =
- org.apache.juli.logging.LogFactory.getLog(JspCompilationContext.class);
-
- protected Map tagFileJarUrls;
- protected boolean isPackagedTagFile;
-
- protected String className;
- protected String jspUri;
- protected boolean isErrPage;
- protected String basePackageName;
- protected String derivedPackageName;
- protected String servletJavaFileName;
- protected String javaPath;
- protected String classFileName;
- protected String contentType;
- protected ServletWriter writer;
- protected Options options;
- protected JspServletWrapper jsw;
- protected Compiler jspCompiler;
- protected String classPath;
-
- protected String baseURI;
- protected String outputDir;
- protected ServletContext context;
- protected ClassLoader loader;
-
- protected JspRuntimeContext rctxt;
-
- protected int removed = 0;
-
- protected URLClassLoader jspLoader;
- protected URL baseUrl;
- protected Class servletClass;
-
- protected boolean isTagFile;
- protected boolean protoTypeMode;
- protected TagInfo tagInfo;
- protected URL tagFileJarUrl;
- private ClassLoaderInterface classLoaderInterface;
- private String sourceCode;
-
- // jspURI _must_ be relative to the context
- public JspCompilationContext(String jspUri,
- boolean isErrPage,
- Options options,
- ServletContext context,
- JspServletWrapper jsw,
- JspRuntimeContext rctxt,
- ClassLoaderInterface classLoaderInterface) {
-
- this.jspUri = canonicalURI(jspUri);
- this.isErrPage = isErrPage;
- this.options = options;
- this.jsw = jsw;
- this.context = context;
-
- this.baseURI = jspUri.substring(0, jspUri.lastIndexOf('/') + 1);
- // hack fix for resolveRelativeURI
- if (baseURI == null) {
- baseURI = "/";
- } else if (baseURI.charAt(0) != '/') {
- // strip the basde slash since it will be combined with the
- // uriBase to generate a file
- baseURI = "/" + baseURI;
- }
- if (baseURI.charAt(baseURI.length() - 1) != '/') {
- baseURI += '/';
- }
-
- this.rctxt = rctxt;
- this.tagFileJarUrls = new HashMap<>();
- this.basePackageName = Constants.JSP_PACKAGE_NAME;
- this.classLoaderInterface = classLoaderInterface;
- }
-
- public JspCompilationContext(String tagfile,
- TagInfo tagInfo,
- Options options,
- ServletContext context,
- JspServletWrapper jsw,
- JspRuntimeContext rctxt,
- URL tagFileJarUrl) {
- this(tagfile, false, options, context, jsw, rctxt, null);
- this.isTagFile = true;
- this.tagInfo = tagInfo;
- this.tagFileJarUrl = tagFileJarUrl;
- if (tagFileJarUrl != null) {
- isPackagedTagFile = true;
- }
- }
-
- /* ==================== Methods to override ==================== */
-
- /** ---------- Class path and loader ---------- */
-
- /**
- * @return The classpath that is passed off to the Java compiler.
- */
- public String getClassPath() {
- if( classPath != null )
- return classPath;
- return rctxt.getClassPath();
- }
-
- /**
- * @param classPath The classpath that is passed off to the Java compiler.
- */
- public void setClassPath(String classPath) {
- this.classPath = classPath;
- }
-
- /**
- * @return What class loader to use for loading classes while compiling
- * this JSP?
- */
- public ClassLoader getClassLoader() {
- if( loader != null )
- return loader;
- return rctxt.getParentClassLoader();
- }
-
- public void setClassLoader(ClassLoader loader) {
- this.loader = loader;
- }
-
- public ClassLoader getJspLoader() {
- if( jspLoader == null ) {
- jspLoader = new JasperLoader
- (new URL[] {baseUrl},
- getClassLoader(),
- rctxt.getPermissionCollection(),
- rctxt.getCodeSource());
- }
- return jspLoader;
- }
-
- /** ---------- Input/Output ---------- */
-
- /**
- * @return The output directory to generate code into. The output directory
- * is make up of the scratch directory, which is provide in Options,
- * plus the directory derived from the package name.
- */
- public String getOutputDir() {
- if (outputDir == null) {
- createOutputDir();
- }
-
- return outputDir;
- }
-
- /**
- * @return Create a "Compiler" object based on some init param data. This
- * is not done yet. Right now we're just hardcoding the actual
- * compilers that are created.
- *
- * @throws JasperException in case of Jasper errors
- */
- public Compiler createCompiler() throws JasperException {
- jspCompiler = new CustomCompiler();
- jspCompiler.init(this, jsw);
- return jspCompiler;
- }
-
- protected Compiler createCompiler(String className) {
- Compiler compiler = null;
- try {
- compiler = (Compiler) Class.forName(className).newInstance();
- } catch (InstantiationException e) {
- log.warn(Localizer.getMessage("jsp.error.compiler"), e);
- } catch (IllegalAccessException e) {
- log.warn(Localizer.getMessage("jsp.error.compiler"), e);
- } catch (NoClassDefFoundError e) {
- if (log.isDebugEnabled()) {
- log.debug(Localizer.getMessage("jsp.error.compiler"), e);
- }
- } catch (ClassNotFoundException e) {
- if (log.isDebugEnabled()) {
- log.debug(Localizer.getMessage("jsp.error.compiler"), e);
- }
- }
- return compiler;
- }
-
- public Compiler getCompiler() {
- return jspCompiler;
- }
-
- /** ---------- Access resources in the webapp ---------- */
-
- /**
- * Get the full value of a URI relative to this compilations context
- * uses current file as the base.
- *
- * @param uri the URL
- * @return full URL
- */
- public String resolveRelativeUri(String uri) {
- // sometimes we get uri's massaged from File(String), so check for
- // a root directory deperator char
- if (uri.startsWith("/") || uri.startsWith(File.separator)) {
- return uri;
- } else {
- return baseURI + uri;
- }
- }
-
- /**
- * Gets a resource as a stream, relative to the meanings of this
- * context's implementation.
- *
- * @param res resource
- * @return a null if the resource cannot be found or represented
- * as an InputStream.
- */
- public java.io.InputStream getResourceAsStream(String res) {
- try {
- return classLoaderInterface.getResourceAsStream(canonicalURI(StringUtils.removeStart(res, "/")));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- }
-
-
- public URL getResource(String res) throws MalformedURLException {
- return classLoaderInterface.getResource(canonicalURI(StringUtils.removeStart(res, "/")));
- }
-
-
- public Set getResourcePaths(String path) {
- return context.getResourcePaths(canonicalURI(path));
- }
-
- /**
- * @param path the path
- *
- * @return the actual path of a URI relative to the context of
- * the compilation.
- */
- public String getRealPath(String path) {
- if (context != null) {
- return context.getRealPath(path);
- }
- return path;
- }
-
- /**
- * @return the tag-file-name-to-JAR-file map of this compilation unit,
- * which maps tag file names to the JAR files in which the tag files are
- * packaged.
- *
- * @param tagFile The map is populated when parsing the tag-file elements of the TLDs
- * of any imported taglibs.
- */
- public URL getTagFileJarUrl(String tagFile) {
- return this.tagFileJarUrls.get(tagFile);
- }
-
- public void setTagFileJarUrl(String tagFile, URL tagFileURL) {
- this.tagFileJarUrls.put(tagFile, tagFileURL);
- }
-
- /**
- * @return the JAR file in which the tag file for which this
- * JspCompilationContext was created is packaged, or null if this
- * JspCompilationContext does not correspond to a tag file, or if the
- * corresponding tag file is not packaged in a JAR.
- */
- public URL getTagFileJarUrl() {
- return this.tagFileJarUrl;
- }
-
- /* ==================== Common implementation ==================== */
-
- /**
- * @return Just the class name (does not include package name) of the
- * generated class.
- */
- public String getServletClassName() {
-
- if (className != null) {
- return className;
- }
-
- if (isTagFile) {
- className = tagInfo.getTagClassName();
- int lastIndex = className.lastIndexOf('.');
- if (lastIndex != -1) {
- className = className.substring(lastIndex + 1);
- }
- } else {
- int iSep = jspUri.lastIndexOf('/') + 1;
- className = JspUtil.makeJavaIdentifier(jspUri.substring(iSep));
- }
- return className;
- }
-
- public void setServletClassName(String className) {
- this.className = className;
- }
-
- /**
- * @return Path of the JSP URI. Note that this is not a file name. This is
- * the context rooted URI of the JSP file.
- */
- public String getJspFile() {
- return jspUri;
- }
-
- /**
- * @return Are we processing something that has been declared as an
- * errorpage?
- */
- public boolean isErrorPage() {
- return isErrPage;
- }
-
- public void setErrorPage(boolean isErrPage) {
- this.isErrPage = isErrPage;
- }
-
- public boolean isTagFile() {
- return isTagFile;
- }
-
- public TagInfo getTagInfo() {
- return tagInfo;
- }
-
- public void setTagInfo(TagInfo tagi) {
- tagInfo = tagi;
- }
-
- /**
- * @return True if we are compiling a tag file in prototype mode.
- * ie we only generate codes with class for the tag handler with empty
- * method bodies.
- */
- public boolean isPrototypeMode() {
- return protoTypeMode;
- }
-
- public void setPrototypeMode(boolean pm) {
- protoTypeMode = pm;
- }
-
- /**
- * @return Package name for the generated class is make up of the base package
- * name, which is user settable, and the derived package name. The
- * derived package name directly mirrors the file heirachy of the JSP page.
- */
- public String getServletPackageName() {
- if (isTagFile()) {
- String className = tagInfo.getTagClassName();
- int lastIndex = className.lastIndexOf('.');
- String pkgName = "";
- if (lastIndex != -1) {
- pkgName = className.substring(0, lastIndex);
- }
- return pkgName;
- } else {
- String dPackageName = getDerivedPackageName();
- if (dPackageName.length() == 0) {
- return basePackageName;
- }
- return basePackageName + '.' + getDerivedPackageName();
- }
- }
-
- protected String getDerivedPackageName() {
- if (derivedPackageName == null) {
- int iSep = jspUri.lastIndexOf('/');
- derivedPackageName = (iSep > 0) ?
- JspUtil.makeJavaPackage(jspUri.substring(1,iSep)) : "";
- }
- return derivedPackageName;
- }
-
- /**
- * @param servletPackageName The package name into which the servlet class is generated.
- */
- public void setServletPackageName(String servletPackageName) {
- this.basePackageName = servletPackageName;
- }
-
- /**
- * @return Full path name of the Java file into which the servlet is being
- * generated.
- */
- public String getServletJavaFileName() {
- if (servletJavaFileName == null) {
- servletJavaFileName = getOutputDir() + getServletClassName() + ".java";
- }
- return servletJavaFileName;
- }
-
- /**
- * @return Get hold of the Options object for this context.
- */
- public Options getOptions() {
- return options;
- }
-
- public ServletContext getServletContext() {
- return context;
- }
-
- public JspRuntimeContext getRuntimeContext() {
- return rctxt;
- }
-
- /**
- * @return Path of the Java file relative to the work directory.
- */
- public String getJavaPath() {
-
- if (javaPath != null) {
- return javaPath;
- }
-
- if (isTagFile()) {
- String tagName = tagInfo.getTagClassName();
- javaPath = tagName.replace('.', '/') + ".java";
- } else {
- javaPath = getServletPackageName().replace('.', '/') + '/' +
- getServletClassName() + ".java";
- }
- return javaPath;
- }
-
- public String getClassFileName() {
- if (classFileName == null) {
- classFileName = getOutputDir() + getServletClassName() + ".class";
- }
- return classFileName;
- }
-
- /**
- * @return Get the content type of this JSP.
- *
- * Content type includes content type and encoding.
- */
- public String getContentType() {
- return contentType;
- }
-
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
- /**
- * @return Where is the servlet being generated?
- */
- public ServletWriter getWriter() {
- return writer;
- }
-
- public void setWriter(ServletWriter writer) {
- this.writer = writer;
- }
-
- /**
- * Gets the 'location' of the TLD associated with the given taglib 'uri'.
- *
- * @param uri the URL
- *
- * @return An array of two Strings: The first element denotes the real
- * path to the TLD. If the path to the TLD points to a jar file, then the
- * second element denotes the name of the TLD entry in the jar file.
- * Returns null if the given uri is not associated with any tag library
- * 'exposed' in the web application.
- *
- * @throws JasperException in case of Jasper errors
- */
- public String[] getTldLocation(String uri) throws JasperException {
- String[] location =
- getOptions().getTldLocationsCache().getLocation(uri);
- return location;
- }
-
- /**
- * @return Are we keeping generated code around?
- */
- public boolean keepGenerated() {
- return getOptions().getKeepGenerated();
- }
-
- // ==================== Removal ====================
-
- public void incrementRemoved() {
- if (removed == 0 && rctxt != null) {
- rctxt.removeWrapper(jspUri);
- }
- removed++;
- }
-
- public boolean isRemoved() {
- if (removed > 1 ) {
- return true;
- }
- return false;
- }
-
- // ==================== Compile and reload ====================
-
- public void compile() throws JasperException, FileNotFoundException {
- createCompiler();
- if (jspCompiler.isOutDated()) {
- try {
- jspCompiler.removeGeneratedFiles();
- jspLoader = null;
- jspCompiler.compile();
- jsw.setReload(true);
- jsw.setCompilationException(null);
- } catch (JasperException ex) {
- // Cache compilation exception
- jsw.setCompilationException(ex);
- throw ex;
- } catch (Exception ex) {
- JasperException je = new JasperException(
- Localizer.getMessage("jsp.error.unable.compile"),
- ex);
- // Cache compilation exception
- jsw.setCompilationException(je);
- throw je;
- }
- }
- }
-
- // ==================== Manipulating the class ====================
-
- public Class load()
- throws JasperException, FileNotFoundException
- {
- try {
- getJspLoader();
-
- String name;
- if (isTagFile()) {
- name = tagInfo.getTagClassName();
- } else {
- name = getServletPackageName() + "." + getServletClassName();
- }
- servletClass = jspLoader.loadClass(name);
- } catch (ClassNotFoundException cex) {
- throw new JasperException(Localizer.getMessage("jsp.error.unable.load"),
- cex);
- } catch (Exception ex) {
- throw new JasperException(Localizer.getMessage("jsp.error.unable.compile"),
- ex);
- }
- removed = 0;
- return servletClass;
- }
-
- // ==================== protected methods ====================
-
- static Object outputDirLock = new Object();
-
- public void checkOutputDir() {
- if (outputDir != null) {
- if (!(new File(outputDir)).exists()) {
- makeOutputDir();
- }
- } else {
- createOutputDir();
- }
- }
-
- protected boolean makeOutputDir() {
- synchronized(outputDirLock) {
- File outDirFile = new File(outputDir);
- return (outDirFile.exists() || outDirFile.mkdirs());
- }
- }
-
- protected void createOutputDir() {
- String path = null;
- if (isTagFile()) {
- String tagName = tagInfo.getTagClassName();
- path = tagName.replace('.', File.separatorChar);
- path = path.substring(0, path.lastIndexOf(File.separatorChar));
- } else {
- path = getServletPackageName().replace('.',File.separatorChar);
- }
-
- // Append servlet or tag handler path to scratch dir
- try {
- File base = options.getScratchDir();
- baseUrl = base.toURI().toURL();
- outputDir = base.getAbsolutePath() + File.separator + path +
- File.separator;
- if (!makeOutputDir()) {
- throw new IllegalStateException(Localizer.getMessage("jsp.error.outputfolder"));
- }
- } catch (MalformedURLException e) {
- throw new IllegalStateException(Localizer.getMessage("jsp.error.outputfolder"), e);
- }
- }
-
- protected static final boolean isPathSeparator(char c) {
- return (c == '/' || c == '\\');
- }
-
- protected static final String canonicalURI(String s) {
- if (s == null) return null;
- StringBuffer result = new StringBuffer();
- 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();
- }
-
- public String getSourceCode() {
- return sourceCode;
- }
-
- public void setSourceCode(String sourceCode) {
- this.sourceCode = sourceCode;
- }
-
-}
-
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/Options.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/Options.java
deleted file mode 100644
index 892e29f02..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/Options.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * 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.struts2.jasper;
-
-import java.io.File;
-import java.util.Map;
-
-import org.apache.struts2.jasper.compiler.JspConfig;
-import org.apache.struts2.jasper.compiler.TagPluginManager;
-import org.apache.struts2.jasper.compiler.TldLocationsCache;
-
-/**
- * A class to hold all init parameters specific to the JSP engine.
- *
- * @author Anil K. Vijendran
- * @author Hans Bergsten
- * @author Pierre Delisle
- */
-public interface Options {
-
- /**
- * @return true if Jasper issues a compilation error instead of a runtime
- * Instantiation error if the class attribute specified in useBean action
- * is invalid.
- */
- public boolean getErrorOnUseBeanInvalidClassAttribute();
-
- /**
- * @return Are we keeping generated code around?
- */
- public boolean getKeepGenerated();
-
- /**
- * @return true if tag handler pooling is enabled, false otherwise.
- */
- public boolean isPoolingEnabled();
-
- /**
- * @return Are we supporting HTML mapped servlets?
- */
- public boolean getMappedFile();
-
- /**
- * @return Should we include debug information in compiled class?
- */
- public boolean getClassDebugInfo();
-
- /**
- * @return Background compile thread check interval in seconds
- */
- public int getCheckInterval();
-
- /**
- * @return Is Jasper being used in development mode?
- */
- public boolean getDevelopment();
-
- /**
- * @return Should we include a source fragment in exception messages, which could be displayed
- * to the developer ?
- */
- public boolean getDisplaySourceFragment();
-
- /**
- * @return Is the generation of SMAP info for JSR45 debugging suppressed?
- */
- public boolean isSmapSuppressed();
-
- /**
- * @return Indicates whether SMAP info for JSR45 debugging should be dumped to a
- * file.
- * Ignored is suppressSmap() is true
- */
- public boolean isSmapDumped();
-
- /**
- * @return Should white spaces between directives or actions be trimmed?
- */
- public boolean getTrimSpaces();
-
- /**
- * @return Class ID for use in the plugin tag when the browser is IE.
- */
- public String getIeClassId();
-
- /**
- * @return What is my scratch dir?
- */
- public File getScratchDir();
-
- /**
- * @return What classpath should I use while compiling the servlets
- * generated from JSP files?
- */
- public String getClassPath();
-
- /**
- * @return Compiler to use.
- */
- public String getCompiler();
-
- /**
- * @return The compiler target VM, e.g. 1.1, 1.2, 1.3, 1.4, or 1.5.
- */
- public String getCompilerTargetVM();
-
- /**
- * @return Compiler source VM, e.g. 1.3, 1.4, or 1.5.
- */
- public String getCompilerSourceVM();
-
- /**
- * @return Java compiler class to use.
- */
- public String getCompilerClassName();
-
- /**
- * The cache for the location of the TLD's
- * for the various tag libraries 'exposed'
- * by the web application.
- * A tag library is 'exposed' either explicitely in
- * web.xml or implicitely via the uri tag in the TLD
- * of a taglib deployed in a jar file (WEB-INF/lib).
- *
- * @return the instance of the TldLocationsCache
- * for the web-application.
- */
- public TldLocationsCache getTldLocationsCache();
-
- /**
- * @return Java platform encoding to generate the JSP
- * page servlet.
- */
- public String getJavaEncoding();
-
- /**
- * @return boolean flag to tell Ant whether to fork JSP page compilations.
- */
- public boolean getFork();
-
- /**
- * @return Obtain JSP configuration information specified in web.xml.
- */
- public JspConfig getJspConfig();
-
- /**
- * @return Is generation of X-Powered-By response header enabled/disabled?
- */
- public boolean isXpoweredBy();
-
- /**
- * @return Obtain a Tag Plugin Manager
- */
- public TagPluginManager getTagPluginManager();
-
- /**
- * @return Are Text strings to be generated as char arrays?
- */
- public boolean genStringAsCharArray();
-
- /**
- * @return Modification test interval.
- */
- public int getModificationTestInterval();
-
- /**
- * @return Is caching enabled (used for precompilation).
- */
- public boolean isCaching();
-
- /**
- * The web-application wide cache for the returned TreeNode
- * by parseXMLDocument in TagLibraryInfoImpl.parseTLD,
- * if isCaching returns true.
- *
- * @return the Map(String uri, TreeNode tld) instance.
- */
- public Map getCache();
-
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/BeanRepository.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/BeanRepository.java
deleted file mode 100644
index 85cf07bb0..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/BeanRepository.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.struts2.jasper.compiler;
-
-import java.util.HashMap;
-
-import org.apache.struts2.jasper.JasperException;
-
-/**
- * Repository of {page, request, session, application}-scoped beans
- *
- * @author Mandar Raje
- * @author Remy Maucherat
- */
-public class BeanRepository {
-
- protected HashMap beanTypes;
- protected ClassLoader loader;
- protected ErrorDispatcher errDispatcher;
-
- /**
- * Constructor.
- *
- * @param loader class loader
- * @param err the error dispatcher
- */
- public BeanRepository(ClassLoader loader, ErrorDispatcher err) {
- this.loader = loader;
- this.errDispatcher = err;
- beanTypes = new HashMap<>();
- }
-
- 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"))) {
- errDispatcher.jspError(n, "jsp.error.usebean.badScope");
- }
-
- beanTypes.put(s, type);
- }
-
- public Class getBeanType(String bean)
- throws JasperException {
- Class clazz = null;
- try {
- clazz = loader.loadClass(beanTypes.get(bean));
- } catch (ClassNotFoundException ex) {
- throw new JasperException (ex);
- }
- return clazz;
- }
-
- public boolean checkVariable(String bean) {
- return beanTypes.containsKey(bean);
- }
-
-}
-
-
-
-
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Collector.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Collector.java
deleted file mode 100644
index a038f0f15..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Collector.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * 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.struts2.jasper.compiler;
-
-import org.apache.struts2.jasper.JasperException;
-
-/**
- * Collect info about the page and nodes, and make them availabe through
- * the PageInfo object.
- *
- * @author Kin-man Chung
- * @author Mark Roth
- */
-
-class Collector {
-
- /**
- * A visitor for collecting information on the page and the body of
- * the custom tags.
- */
- static class CollectVisitor extends Node.Visitor {
-
- private boolean scriptingElementSeen = false;
- private boolean usebeanSeen = false;
- private boolean includeActionSeen = false;
- private boolean paramActionSeen = false;
- private boolean setPropertySeen = false;
- private boolean hasScriptingVars = false;
-
- public void visit(Node.ParamAction n) throws JasperException {
- if (n.getValue().isExpression()) {
- scriptingElementSeen = true;
- }
- paramActionSeen = true;
- }
-
- public void visit(Node.IncludeAction n) throws JasperException {
- if (n.getPage().isExpression()) {
- scriptingElementSeen = true;
- }
- includeActionSeen = true;
- visitBody(n);
- }
-
- public void visit(Node.ForwardAction n) throws JasperException {
- if (n.getPage().isExpression()) {
- scriptingElementSeen = true;
- }
- visitBody(n);
- }
-
- public void visit(Node.SetProperty n) throws JasperException {
- if (n.getValue() != null && n.getValue().isExpression()) {
- scriptingElementSeen = true;
- }
- setPropertySeen = true;
- }
-
- public void visit(Node.UseBean n) throws JasperException {
- if (n.getBeanName() != null && n.getBeanName().isExpression()) {
- scriptingElementSeen = true;
- }
- usebeanSeen = true;
- visitBody(n);
- }
-
- public void visit(Node.PlugIn n) throws JasperException {
- if (n.getHeight() != null && n.getHeight().isExpression()) {
- scriptingElementSeen = true;
- }
- if (n.getWidth() != null && n.getWidth().isExpression()) {
- scriptingElementSeen = true;
- }
- visitBody(n);
- }
-
- public void visit(Node.CustomTag n) throws JasperException {
- // Check to see what kinds of element we see as child elements
- 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
- {
- // save values collected so far
- boolean scriptingElementSeenSave = scriptingElementSeen;
- scriptingElementSeen = false;
- boolean usebeanSeenSave = usebeanSeen;
- usebeanSeen = false;
- boolean includeActionSeenSave = includeActionSeen;
- includeActionSeen = false;
- boolean paramActionSeenSave = paramActionSeen;
- paramActionSeen = false;
- boolean setPropertySeenSave = setPropertySeen;
- setPropertySeen = false;
- boolean hasScriptingVarsSave = hasScriptingVars;
- hasScriptingVars = false;
-
- // Scan attribute list for expressions
- 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()) {
- scriptingElementSeen = true;
- break;
- }
- }
- }
-
- visitBody(n);
-
- 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.setHasUseBean(usebeanSeen);
- ci.setHasIncludeAction(includeActionSeen);
- ci.setHasParamAction(paramActionSeen);
- ci.setHasSetProperty(setPropertySeen);
- ci.setHasScriptingVars(hasScriptingVars);
-
- // Propagate value of scriptingElementSeen up.
- scriptingElementSeen = scriptingElementSeen || scriptingElementSeenSave;
- usebeanSeen = usebeanSeen || usebeanSeenSave;
- setPropertySeen = setPropertySeen || setPropertySeenSave;
- includeActionSeen = includeActionSeen || includeActionSeenSave;
- paramActionSeen = paramActionSeen || paramActionSeenSave;
- hasScriptingVars = hasScriptingVars || hasScriptingVarsSave;
- }
-
- public void visit(Node.JspElement n) throws JasperException {
- if (n.getNameAttribute().isExpression())
- scriptingElementSeen = true;
-
- Node.JspAttribute[] attrs = n.getJspAttributes();
- for (int i = 0; i < attrs.length; i++) {
- if (attrs[i].isExpression()) {
- scriptingElementSeen = true;
- break;
- }
- }
- visitBody(n);
- }
-
- public void visit(Node.JspBody n) throws JasperException {
- checkSeen( n.getChildInfo(), n );
- }
-
- public void visit(Node.NamedAttribute n) throws JasperException {
- checkSeen( n.getChildInfo(), n );
- }
-
- public void visit(Node.Declaration n) throws JasperException {
- scriptingElementSeen = true;
- }
-
- public void visit(Node.Expression n) throws JasperException {
- scriptingElementSeen = true;
- }
-
- public void visit(Node.Scriptlet n) throws JasperException {
- scriptingElementSeen = true;
- }
-
- public void updatePageInfo(PageInfo pageInfo) {
- pageInfo.setScriptless(! scriptingElementSeen);
- }
- }
-
-
- public static void collect(Compiler compiler, Node.Nodes page)
- throws JasperException {
-
- CollectVisitor collectVisitor = new CollectVisitor();
- page.visit(collectVisitor);
- collectVisitor.updatePageInfo(compiler.getPageInfo());
-
- }
-}
-
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Compiler.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Compiler.java
deleted file mode 100644
index e5aac3e52..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Compiler.java
+++ /dev/null
@@ -1,569 +0,0 @@
-/*
- * 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.struts2.jasper.compiler;
-
-import java.io.*;
-import java.net.JarURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.struts2.jasper.JasperException;
-import org.apache.struts2.jasper.JspCompilationContext;
-import org.apache.struts2.jasper.Options;
-import org.apache.struts2.jasper.servlet.JspServletWrapper;
-
-/**
- * Main JSP compiler class. This class uses Ant for compiling.
- *
- * @author Anil K. Vijendran
- * @author Mandar Raje
- * @author Pierre Delisle
- * @author Kin-man Chung
- * @author Remy Maucherat
- * @author Mark Roth
- */
-public abstract class Compiler {
-
- protected org.apache.juli.logging.Log log = org.apache.juli.logging.LogFactory
- .getLog(Compiler.class);
-
- // ----------------------------------------------------- Instance Variables
-
- protected JspCompilationContext ctxt;
-
- protected ErrorDispatcher errDispatcher;
-
- protected PageInfo pageInfo;
-
- protected JspServletWrapper jsw;
-
- protected TagFileProcessor tfp;
-
- protected Options options;
-
- protected Node.Nodes pageNodes;
-
- // ------------------------------------------------------------ Constructor
-
- public void init(JspCompilationContext ctxt, JspServletWrapper jsw) {
- this.jsw = jsw;
- this.ctxt = ctxt;
- this.options = ctxt.getOptions();
- }
-
- // --------------------------------------------------------- Public Methods
-
- /**
- *
- * Retrieves the parsed nodes of the JSP page, if they are available. May
- * return null. Used in development mode for generating detailed error
- * messages. http://issues.apache.org/bugzilla/show_bug.cgi?id=37062.
- *
- *
- * @return page nodes
- */
- public Node.Nodes getPageNodes() {
- return this.pageNodes;
- }
-
- /**
- * Compile the jsp file into equivalent servlet in .java file
- *
- * @return a smap for the current JSP page, if one is generated, null
- * otherwise
- * @throws Exception in case of any errors
- */
- protected String[] generateJava() throws Exception {
-
- String[] smapStr = null;
-
- long t1, t2, t3, t4;
-
- t1 = t2 = t3 = t4 = 0;
-
- if (log.isDebugEnabled()) {
- t1 = System.currentTimeMillis();
- }
-
- // Setup page info area
- pageInfo = new PageInfo(new BeanRepository(ctxt.getClassLoader(),
- errDispatcher), ctxt.getJspFile());
-
- JspConfig jspConfig = options.getJspConfig();
- JspConfig.JspProperty jspProperty = jspConfig.findJspProperty(ctxt
- .getJspFile());
-
- /*
- * If the current uri is matched by a pattern specified in a
- * jsp-property-group in web.xml, initialize pageInfo with those
- * properties.
- */
- if (jspProperty.isELIgnored() != null) {
- pageInfo.setELIgnored(JspUtil.booleanValue(jspProperty
- .isELIgnored()));
- }
- if (jspProperty.isScriptingInvalid() != null) {
- pageInfo.setScriptingInvalid(JspUtil.booleanValue(jspProperty
- .isScriptingInvalid()));
- }
- if (jspProperty.getIncludePrelude() != null) {
- pageInfo.setIncludePrelude(jspProperty.getIncludePrelude());
- }
- if (jspProperty.getIncludeCoda() != null) {
- pageInfo.setIncludeCoda(jspProperty.getIncludeCoda());
- }
- if (jspProperty.isDeferedSyntaxAllowedAsLiteral() != null) {
- pageInfo.setDeferredSyntaxAllowedAsLiteral(JspUtil.booleanValue(jspProperty
- .isDeferedSyntaxAllowedAsLiteral()));
- }
- if (jspProperty.isTrimDirectiveWhitespaces() != null) {
- pageInfo.setTrimDirectiveWhitespaces(JspUtil.booleanValue(jspProperty
- .isTrimDirectiveWhitespaces()));
- }
-
- ctxt.checkOutputDir();
- String javaFileName = ctxt.getServletJavaFileName();
-
- ServletWriter writer = null;
- try {
- /*
- * The setting of isELIgnored changes the behaviour of the parser
- * in subtle ways. To add to the 'fun', isELIgnored can be set in
- * any file that forms part of the translation unit so setting it
- * in a file included towards the end of the translation unit can
- * change how the parser should have behaved when parsing content
- * up to the point where isELIgnored was set. Arghh!
- * Previous attempts to hack around this have only provided partial
- * solutions. We now use two passes to parse the translation unit.
- * The first just parses the directives and the second parses the
- * whole translation unit once we know how isELIgnored has been set.
- * TODO There are some possible optimisations of this process.
- */
- // Parse the file
- ParserController parserCtl = new ParserController(ctxt, this);
-
- // Pass 1 - the directives
- Node.Nodes directives =
- parserCtl.parseDirectives(ctxt.getJspFile());
- Validator.validateDirectives(this, directives);
-
- // Pass 2 - the whole translation unit
- pageNodes = parserCtl.parse(ctxt.getJspFile());
-
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(1024);
-
- if (ctxt.isPrototypeMode()) {
- // generate prototype .java file for the tag file
- writer = setupContextWriter(byteArrayOutputStream);
- Generator.generate(writer, this, pageNodes);
- writer.close();
- writer = null;
- return null;
- }
-
- // Validate and process attributes - don't re-validate the
- // directives we validated in pass 1
- Validator.validateExDirectives(this, pageNodes);
-
- if (log.isDebugEnabled()) {
- t2 = System.currentTimeMillis();
- }
-
- // Collect page info
- Collector.collect(this, pageNodes);
-
- // Compile (if necessary) and load the tag files referenced in
- // this compilation unit.
- tfp = new TagFileProcessor();
- tfp.loadTagFiles(this, pageNodes);
-
- if (log.isDebugEnabled()) {
- t3 = System.currentTimeMillis();
- }
-
- // Determine which custom tag needs to declare which scripting vars
- ScriptingVariabler.set(pageNodes, errDispatcher);
-
- // Optimizations by Tag Plugins
- TagPluginManager tagPluginManager = options.getTagPluginManager();
- tagPluginManager.apply(pageNodes, errDispatcher, pageInfo);
-
- // Optimization: concatenate contiguous template texts.
- TextOptimizer.concatenate(this, pageNodes);
-
- // Generate static function mapper codes.
- ELFunctionMapper.map(this, pageNodes);
-
- // generate servlet .java file
- writer = setupContextWriter(byteArrayOutputStream);
- Generator.generate(writer, this, pageNodes);
- writer.close();
- writer = null;
-
- // The writer is only used during the compile, dereference
- // it in the JspCompilationContext when done to allow it
- // to be GC'd and save memory.
- ctxt.setWriter(null);
- ctxt.setSourceCode(byteArrayOutputStream.toString());
-
- if (log.isDebugEnabled()) {
- t4 = System.currentTimeMillis();
- log.debug("Generated " + javaFileName + " total=" + (t4 - t1)
- + " generate=" + (t4 - t3) + " validate=" + (t2 - t1));
- }
-
- } catch (Exception e) {
- if (writer != null) {
- try {
- writer.close();
- writer = null;
- } catch (Exception e1) {
- // do nothing
- }
- }
- // Remove the generated .java file
- new File(javaFileName).delete();
- throw e;
- } finally {
- if (writer != null) {
- try {
- writer.close();
- } catch (Exception e2) {
- // do nothing
- }
- }
- }
-
- // JSR45 Support
- if (!options.isSmapSuppressed()) {
- smapStr = SmapUtil.generateSmap(ctxt, pageNodes);
- }
-
- // If any proto type .java and .class files was generated,
- // the prototype .java may have been replaced by the current
- // compilation (if the tag file is self referencing), but the
- // .class file need to be removed, to make sure that javac would
- // generate .class again from the new .java file just generated.
- tfp.removeProtoTypeFiles(ctxt.getClassFileName());
-
- return smapStr;
- }
-
- private ServletWriter setupContextWriter(OutputStream os)
- throws FileNotFoundException, JasperException {
- ServletWriter writer;
- // Setup the ServletWriter
- String javaEncoding = ctxt.getOptions().getJavaEncoding();
- OutputStreamWriter osw = null;
-
- try {
- osw = new OutputStreamWriter(os, javaEncoding);
- } catch (UnsupportedEncodingException ex) {
- errDispatcher.jspError("jsp.error.needAlternateJavaEncoding",
- javaEncoding);
- }
-
- writer = new ServletWriter(new PrintWriter(osw));
- ctxt.setWriter(writer);
- return writer;
- }
-
- /**
- * Compile the servlet from .java file to .class file
- *
- * @param smap string array
- * @throws FileNotFoundException is file was not found
- * @throws JasperException in case of jasper errors
- * @throws Exception in case of other errors
- */
- protected abstract void generateClass(String[] smap)
- throws FileNotFoundException, JasperException, Exception;
-
- /**
- * Compile the jsp file from the current engine context
- * @throws FileNotFoundException is file was not found
- * @throws JasperException in case of jasper errors
- * @throws Exception in case of other errors
- */
- public void compile() throws FileNotFoundException, JasperException,
- Exception {
- compile(true);
- }
-
- /**
- * Compile the jsp file from the current engine context. As an side- effect,
- * tag files that are referenced by this page are also compiled.
- *
- * @param compileClass
- * If true, generate both .java and .class file If false,
- * generate only .java file
- * @throws FileNotFoundException is file was not found
- * @throws JasperException in case of jasper errors
- * @throws Exception in case of other errors
- */
- public void compile(boolean compileClass) throws FileNotFoundException,
- JasperException, Exception {
- compile(compileClass, false);
- }
-
- /**
- * Compile the jsp file from the current engine context. As an side- effect,
- * tag files that are referenced by this page are also compiled.
- *
- * @param compileClass
- * If true, generate both .java and .class file If false,
- * generate only .java file
- * @param jspcMode
- * true if invoked from JspC, false otherwise
- * @throws FileNotFoundException is file was not found
- * @throws JasperException in case of jasper errors
- * @throws Exception in case of other errors
- */
- public void compile(boolean compileClass, boolean jspcMode)
- throws FileNotFoundException, JasperException, Exception {
- if (errDispatcher == null) {
- this.errDispatcher = new ErrorDispatcher(jspcMode);
- }
-
- try {
- String[] smap = generateJava();
- if (compileClass) {
- generateClass(smap);
- // Fix for bugzilla 41606
- // Set JspServletWrapper.servletClassLastModifiedTime after successful compile
- String targetFileName = ctxt.getClassFileName();
- if (targetFileName != null) {
- File targetFile = new File(targetFileName);
- if (targetFile.exists() && jsw != null) {
- jsw.setServletClassLastModifiedTime(targetFile.lastModified());
- }
- }
- }
- } finally {
- if (tfp != null && ctxt.isPrototypeMode()) {
- tfp.removeProtoTypeFiles(null);
- }
- // Make sure these object which are only used during the
- // generation and compilation of the JSP page get
- // dereferenced so that they can be GC'd and reduce the
- // memory footprint.
- tfp = null;
- errDispatcher = null;
- pageInfo = null;
-
- // Only get rid of the pageNodes if in production.
- // In development mode, they are used for detailed
- // error messages.
- // http://issues.apache.org/bugzilla/show_bug.cgi?id=37062
- if (!this.options.getDevelopment()) {
- pageNodes = null;
- }
-
- if (ctxt.getWriter() != null) {
- ctxt.getWriter().close();
- ctxt.setWriter(null);
- }
- }
- }
-
- /**
- * This is a protected method intended to be overridden by subclasses of
- * Compiler. This is used by the compile method to do all the compilation.
- *
- * @return true if out dated
- */
- public boolean isOutDated() {
- return isOutDated(true);
- }
-
- /**
- * Determine if a compilation is necessary by checking the time stamp of the
- * JSP page with that of the corresponding .class or .java file. If the page
- * has dependencies, the check is also extended to its dependants, and so
- * on. This method can by overridden by a subclasses of Compiler.
- *
- * @param checkClass
- * If true, check against .class file, if false, check against
- * .java file.
- *
- * @return true if out dated
- */
- public boolean isOutDated(boolean checkClass) {
-
- String jsp = ctxt.getJspFile();
-
- if (jsw != null
- && (ctxt.getOptions().getModificationTestInterval() > 0)) {
-
- if (jsw.getLastModificationTest()
- + (ctxt.getOptions().getModificationTestInterval() * 1000) > System
- .currentTimeMillis()) {
- return false;
- } else {
- jsw.setLastModificationTest(System.currentTimeMillis());
- }
- }
-
- long jspRealLastModified = 0;
- try {
- URL jspUrl = ctxt.getResource(jsp);
- if (jspUrl == null) {
- ctxt.incrementRemoved();
- return false;
- }
- URLConnection uc = jspUrl.openConnection();
- if (uc instanceof JarURLConnection) {
- jspRealLastModified =
- ((JarURLConnection) uc).getJarEntry().getTime();
- } else {
- jspRealLastModified = uc.getLastModified();
- }
- uc.getInputStream().close();
- } catch (Exception e) {
- return true;
- }
-
- long targetLastModified = 0;
- File targetFile;
-
- if (checkClass) {
- targetFile = new File(ctxt.getClassFileName());
- } else {
- targetFile = new File(ctxt.getServletJavaFileName());
- }
-
- if (!targetFile.exists()) {
- return true;
- }
-
- targetLastModified = targetFile.lastModified();
- if (checkClass && jsw != null) {
- jsw.setServletClassLastModifiedTime(targetLastModified);
- }
- if (targetLastModified < jspRealLastModified) {
- if (log.isDebugEnabled()) {
- log.debug("Compiler: outdated: " + targetFile + " "
- + targetLastModified);
- }
- return true;
- }
-
- // determine if source dependent files (e.g. includes using include
- // directives) have been changed.
- if (jsw == null) {
- return false;
- }
-
- List depends = jsw.getDependants();
- if (depends == null) {
- return false;
- }
-
- for (Object depend : depends) {
- String include = (String) depend;
- try {
- URL includeUrl = ctxt.getResource(include);
- if (includeUrl == null) {
- return true;
- }
-
- URLConnection iuc = includeUrl.openConnection();
- long includeLastModified = 0;
- if (iuc instanceof JarURLConnection) {
- includeLastModified =
- ((JarURLConnection) iuc).getJarEntry().getTime();
- } else {
- includeLastModified = iuc.getLastModified();
- }
- iuc.getInputStream().close();
-
- if (includeLastModified > targetLastModified) {
- return true;
- }
- } catch (Exception e) {
- return true;
- }
- }
-
- return false;
-
- }
-
- /**
- * @return the error dispatcher.
- */
- public ErrorDispatcher getErrorDispatcher() {
- return errDispatcher;
- }
-
- /**
- * @return the info about the page under compilation
- */
- public PageInfo getPageInfo() {
- return pageInfo;
- }
-
- public JspCompilationContext getCompilationContext() {
- return ctxt;
- }
-
- /**
- * Remove generated files
- */
- public void removeGeneratedFiles() {
- try {
- String classFileName = ctxt.getClassFileName();
- if (classFileName != null) {
- File classFile = new File(classFileName);
- if (log.isDebugEnabled())
- log.debug("Deleting " + classFile);
- classFile.delete();
- }
- } catch (Exception e) {
- // Remove as much as possible, ignore possible exceptions
- }
- try {
- String javaFileName = ctxt.getServletJavaFileName();
- if (javaFileName != null) {
- File javaFile = new File(javaFileName);
- if (log.isDebugEnabled())
- log.debug("Deleting " + javaFile);
- javaFile.delete();
- }
- } catch (Exception e) {
- // Remove as much as possible, ignore possible exceptions
- }
- }
-
- public void removeGeneratedClassFiles() {
- try {
- String classFileName = ctxt.getClassFileName();
- if (classFileName != null) {
- File classFile = new File(classFileName);
- if (log.isDebugEnabled())
- log.debug("Deleting " + classFile);
- classFile.delete();
- }
- } catch (Exception e) {
- // Remove as much as possible, ignore possible exceptions
- }
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/DefaultErrorHandler.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/DefaultErrorHandler.java
deleted file mode 100644
index 6807334f0..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/DefaultErrorHandler.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.struts2.jasper.compiler;
-
-import org.apache.struts2.jasper.JasperException;
-
-/**
- * Default implementation of ErrorHandler interface.
- *
- * @author Jan Luehe
- */
-class DefaultErrorHandler implements ErrorHandler {
-
- /*
- * Processes the given JSP parse error.
- *
- * @param fname Name of the JSP file in which the parse error occurred
- * @param line Parse error line number
- * @param column Parse error column number
- * @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);
- }
-
- /*
- * Processes the given JSP parse error.
- *
- * @param errMsg Parse error message
- * @param exception Parse exception
- */
- public void jspError(String errMsg, Exception ex) throws JasperException {
- throw new JasperException(errMsg, ex);
- }
-
- /*
- * Processes the given javac compilation errors.
- *
- * @param details Array of JavacErrorDetail instances corresponding to the
- * 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++) {
- if (details[i].getJspBeginLineNumber() >= 0) {
- 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("\n");
- buf.append(details[i].getErrorMessage());
- buf.append("\n");
- buf.append(details[i].getJspExtract());
- } else {
- args = new Object[] {
- new Integer(details[i].getJavaLineNumber()) };
- buf.append("\n\n");
- 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);
- }
-
- /**
- * 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);
- }
-
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Dumper.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Dumper.java
deleted file mode 100644
index 13dead792..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Dumper.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * 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.struts2.jasper.compiler;
-
-import org.xml.sax.Attributes;
-import org.apache.struts2.jasper.JasperException;
-
-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, 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(), "%>");
- }
-
- public void visit(Node.TaglibDirective n) throws JasperException {
- printAttributes("<%@ taglib", n.getAttributes(), "%>");
- }
-
- public void visit(Node.IncludeDirective n) throws JasperException {
- printAttributes("<%@ include", n.getAttributes(), "%>");
- dumpBody(n);
- }
-
- public void visit(Node.Comment n) throws JasperException {
- printString("<%--", n.getText(), "--%>");
- }
-
- public void visit(Node.Declaration n) throws JasperException {
- printString("<%!", n.getText(), "%>");
- }
-
- public void visit(Node.Expression n) throws JasperException {
- printString("<%=", n.getText(), "%>");
- }
-
- public void visit(Node.Scriptlet n) throws JasperException {
- printString("<%", n.getText(), "%>");
- }
-
- public void visit(Node.IncludeAction n) throws JasperException {
- printAttributes("");
- dumpBody(n);
- printString("");
- }
-
- public void visit(Node.ForwardAction n) throws JasperException {
- printAttributes("");
- dumpBody(n);
- printString("");
- }
-
- public void visit(Node.GetProperty n) throws JasperException {
- printAttributes("");
- }
-
- public void visit(Node.SetProperty n) throws JasperException {
- printAttributes("");
- dumpBody(n);
- printString("");
- }
-
- public void visit(Node.UseBean n) throws JasperException {
- printAttributes("");
- dumpBody(n);
- printString("");
- }
-
- public void visit(Node.PlugIn n) throws JasperException {
- printAttributes("");
- dumpBody(n);
- printString("");
- }
-
- public void visit(Node.ParamsAction n) throws JasperException {
- printAttributes("");
- dumpBody(n);
- printString("");
- }
-
- public void visit(Node.ParamAction n) throws JasperException {
- printAttributes("");
- dumpBody(n);
- printString("");
- }
-
- public void visit(Node.NamedAttribute n) throws JasperException {
- printAttributes("");
- dumpBody(n);
- printString("");
- }
-
- public void visit(Node.JspBody n) throws JasperException {
- printAttributes("");
- dumpBody(n);
- printString("");
- }
-
- public void visit(Node.ELExpression n) throws JasperException {
- printString( "${" + new String( n.getText() ) + "}" );
- }
-
- public void visit(Node.CustomTag n) throws JasperException {
- 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.TemplateText n) throws JasperException {
- printString(new String(n.getText()));
- }
-
- private void printIndent() {
- for (int i=0; i < indent; i++) {
- System.out.print(" ");
- }
- }
- }
-
- public static void dump(Node n) {
- try {
- n.accept(new DumpVisitor());
- } catch (JasperException e) {
- e.printStackTrace();
- }
- }
-
- public static void dump(Node.Nodes page) {
- try {
- page.visit(new DumpVisitor());
- } catch (JasperException e) {
- e.printStackTrace();
- }
- }
-}
-
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELFunctionMapper.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELFunctionMapper.java
deleted file mode 100644
index 85307d942..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELFunctionMapper.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * 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.struts2.jasper.compiler;
-
-import java.util.*;
-import jakarta.servlet.jsp.tagext.FunctionInfo;
-import org.apache.struts2.jasper.JasperException;
-
-/**
- * This class generates functions mappers for the EL expressions in the page.
- * Instead of a global mapper, a mapper is used for ecah call to EL
- * evaluator, thus avoiding the prefix overlapping and redefinition
- * issues.
- *
- * @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.
-
- /**
- * Creates the functions mappers for all EL expressions in the JSP page.
- *
- * @param compiler Current compiler, mainly for accessing error dispatcher.
- * @param page The current compilation unit.
- *
- * @throws JasperException in case of Jasper errors
- */
- public static void map(Compiler compiler, Node.Nodes page)
- throws JasperException {
-
- ELFunctionMapper map = new ELFunctionMapper();
- map.ds = new StringBuffer();
- map.ss = new StringBuffer();
-
- page.visit(map.new ELFunctionVisitor());
-
- // Append the declarations to the root node
- String ds = map.ds.toString();
- if (ds.length() > 0) {
- Node root = page.getRoot();
- new Node.Declaration(map.ss.toString(), null, root);
- new Node.Declaration("static {\n" + ds + "}\n", null, root);
- }
- }
-
- /**
- * A visitor for the page. The places where EL is allowed are scanned
- * 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.
- */
- private HashMap gMap = new HashMap();
-
- public void visit(Node.ParamAction n) throws JasperException {
- doMap(n.getValue());
- visitBody(n);
- }
-
- public void visit(Node.IncludeAction n) throws JasperException {
- doMap(n.getPage());
- visitBody(n);
- }
-
- public void visit(Node.ForwardAction n) throws JasperException {
- doMap(n.getPage());
- visitBody(n);
- }
-
- public void visit(Node.SetProperty n) throws JasperException {
- doMap(n.getValue());
- visitBody(n);
- }
-
- public void visit(Node.UseBean n) throws JasperException {
- doMap(n.getBeanName());
- visitBody(n);
- }
-
- public void visit(Node.PlugIn n) throws JasperException {
- doMap(n.getHeight());
- doMap(n.getWidth());
- visitBody(n);
- }
-
- public void visit(Node.JspElement n) throws JasperException {
-
- Node.JspAttribute[] attrs = n.getJspAttributes();
- for (int i = 0; attrs != null && i < attrs.length; i++) {
- doMap(attrs[i]);
- }
- doMap(n.getNameAttribute());
- visitBody(n);
- }
-
- public void visit(Node.UninterpretedTag n) throws JasperException {
-
- Node.JspAttribute[] attrs = n.getJspAttributes();
- for (int i = 0; attrs != null && i < attrs.length; i++) {
- doMap(attrs[i]);
- }
- visitBody(n);
- }
-
- public void visit(Node.CustomTag n) throws JasperException {
- Node.JspAttribute[] attrs = n.getJspAttributes();
- for (int i = 0; attrs != null && i < attrs.length; i++) {
- doMap(attrs[i]);
- }
- visitBody(n);
- }
-
- public void visit(Node.ELExpression n) throws JasperException {
- doMap(n.getEL());
- }
-
- private void doMap(Node.JspAttribute attr)
- throws JasperException {
- if (attr != null) {
- doMap(attr.getEL());
- }
- }
-
- /**
- * Creates function mappers, if needed, from ELNodes
- */
- private void doMap(ELNode.Nodes el)
- throws JasperException {
-
- // Only care about functions in ELNode's
- class Fvisitor extends ELNode.Visitor {
- ArrayList funcs =
- new ArrayList();
- HashMap keyMap = new HashMap();
- public void visit(ELNode.Function n) throws JasperException {
- String key = n.getPrefix() + ":" + n.getName();
- if (! keyMap.containsKey(key)) {
- keyMap.put(key,"");
- funcs.add(n);
- }
- }
- }
-
- if (el == null) {
- return;
- }
-
- // First locate all unique functions in this EL
- Fvisitor fv = new Fvisitor();
- el.visit(fv);
- ArrayList functions = fv.funcs;
-
- if (functions.size() == 0) {
- return;
- }
-
- // Reuse a previous map if possible
- String decName = matchMap(functions);
- if (decName != null) {
- el.setMapName(decName);
- return;
- }
-
- // Generate declaration for the map statically
- decName = getMapName();
- ss.append("static private org.apache.struts2.jasper.runtime.ProtectedFunctionMapper " + decName + ";\n");
-
- ds.append(" " + decName + "= ");
- ds.append("org.apache.struts2.jasper.runtime.ProtectedFunctionMapper");
-
- // Special case if there is only one function in the map
- String funcMethod = null;
- if (functions.size() == 1) {
- funcMethod = ".getMapForFunction";
- } else {
- ds.append(".getInstance();\n");
- funcMethod = " " + decName + ".mapFunction";
- }
-
- // Setup arguments for either getMapForFunction or mapFunction
- for (int i = 0; i < functions.size(); 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 params[] = f.getParameters();
- for (int k = 0; k < params.length; k++) {
- if (k != 0) {
- ds.append(", ");
- }
- int iArray = params[k].indexOf('[');
- if (iArray < 0) {
- ds.append(params[k] + ".class");
- }
- else {
- String baseType = params[k].substring(0, iArray);
- ds.append("java.lang.reflect.Array.newInstance(");
- ds.append(baseType);
- ds.append(".class,");
-
- // Count the number of array dimension
- int aCount = 0;
- for (int jj = iArray; jj < params[k].length(); jj++ ) {
- if (params[k].charAt(jj) == '[') {
- aCount++;
- }
- }
- if (aCount == 1) {
- ds.append("0).getClass()");
- } else {
- ds.append("new int[" + aCount + "]).getClass()");
- }
- }
- }
- ds.append("});\n");
- // Put the current name in the global function map
- gMap.put(f.getPrefix() + ':' + f.getName() + ':' + f.getUri(),
- decName);
- }
- el.setMapName(decName);
- }
-
- /**
- * Find the name of the function mapper for an EL. Reuse a
- * previously generated one if possible.
- * @param functions An ArrayList of ELNode.Function instances that
- * represents the functions in an EL
- * @return A previous generated function mapper name that can be used
- * by this EL; null if none found.
- */
- private String matchMap(ArrayList functions) {
-
- 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());
- if (temName == null) {
- return null;
- }
- if (mapName == null) {
- mapName = temName;
- } else if (!temName.equals(mapName)) {
- // If not all in the previous match, then no match.
- return null;
- }
- }
- return mapName;
- }
-
- /*
- * @return An unique name for a function mapper.
- */
- private String getMapName() {
- return "_jspx_fnmap_" + currFunc++;
- }
- }
-}
-
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELNode.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELNode.java
deleted file mode 100644
index eecf67f87..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELNode.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * 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.struts2.jasper.compiler;
-
-import java.util.*;
-import jakarta.servlet.jsp.tagext.FunctionInfo;
-import org.apache.struts2.jasper.JasperException;
-
-/**
- * This class defines internal representation for an EL Expression
- *
- * It currently only defines functions. It can be expanded to define
- * all the components of an EL expression, if need to.
- *
- * @author Kin-man Chung
- */
-
-abstract class ELNode {
-
- abstract public 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;
-
- Root(ELNode.Nodes expr, char type) {
- this.expr = expr;
- this.type = type;
- }
-
- public void accept(Visitor v) throws JasperException {
- v.visit(this);
- }
-
- public ELNode.Nodes getExpression() {
- return expr;
- }
-
- public char getType() {
- return type;
- }
- }
-
- /**
- * Represents text outside of EL expression.
- */
- public static class Text extends ELNode {
-
- private String text;
-
- Text(String text) {
- this.text = text;
- }
-
- public void accept(Visitor v) throws JasperException {
- v.visit(this);
- }
-
- public String getText() {
- return text;
- }
- }
-
- /**
- * Represents anything in EL expression, other than functions, including
- * function arguments etc
- */
- public static class ELText extends ELNode {
-
- private String text;
-
- ELText(String text) {
- this.text = text;
- }
-
- public void accept(Visitor v) throws JasperException {
- v.visit(this);
- }
-
- public String getText() {
- return text;
- }
- }
-
- /**
- * Represents a function
- * Currently only include the prefix and function name, but not its
- * arguments.
- */
- 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;
- }
- }
-
- /**
- * An ordered list of 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 list;
-
- public Nodes() {
- list = new ArrayList();
- }
-
- 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 iter = list.iterator();
- while (iter.hasNext()) {
- ELNode n = iter.next();
- n.accept(v);
- }
- }
-
- public Iterator iterator() {
- return list.iterator();
- }
-
- public boolean isEmpty() {
- return list.size() == 0;
- }
-
- /**
- * @return true if the expression contains a ${...}
- */
- public boolean containsEL() {
- Iterator 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;
- }
-
- }
-
- /*
- * A visitor class for traversing ELNodes
- */
- public static class Visitor {
-
- public void visit(Root n) throws JasperException {
- n.getExpression().visit(this);
- }
-
- public void visit(Function n) throws JasperException {
- }
-
- public void visit(Text n) throws JasperException {
- }
-
- public void visit(ELText n) throws JasperException {
- }
- }
-}
-
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELParser.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELParser.java
deleted file mode 100644
index 55ca75135..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELParser.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * 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.struts2.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
-
- private ELNode.Nodes expr;
-
- private ELNode.Nodes ELexpr;
-
- 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" };
-
- public ELParser(String expression) {
- index = 0;
- this.expression = expression;
- expr = new ELNode.Nodes();
- }
-
- /**
- * Parse an EL expression
- *
- * @param expression
- * The input expression string of the form Char* ('${' Char*
- * '}')* Char*
- * @return Parsed EL expression in ELNode.Nodes
- */
- public static ELNode.Nodes parse(String expression) {
- ELParser parser = new ELParser(expression);
- while (parser.hasNextChar()) {
- String text = parser.skipUntilEL();
- if (text.length() > 0) {
- parser.expr.add(new ELNode.Text(text));
- }
- ELNode.Nodes elexpr = parser.parseEL();
- if (!elexpr.isEmpty()) {
- parser.expr.add(new ELNode.Root(elexpr, parser.type));
- }
- }
- return parser.expr;
- }
-
- /**
- * 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.
- */
- private ELNode.Nodes parseEL() {
-
- StringBuffer buf = new StringBuffer();
- ELexpr = new ELNode.Nodes();
- while (hasNext()) {
- curToken = nextToken();
- if (curToken instanceof Char) {
- if (curToken.toChar() == '}') {
- break;
- }
- buf.append(curToken.toChar());
- } else {
- // Output whatever is in buffer
- if (buf.length() > 0) {
- ELexpr.add(new ELNode.ELText(buf.toString()));
- }
- if (!parseFunction()) {
- ELexpr.add(new ELNode.ELText(curToken.toString()));
- }
- }
- }
- if (buf.length() > 0) {
- ELexpr.add(new ELNode.ELText(buf.toString()));
- }
-
- return ELexpr;
- }
-
- /**
- * Parse for a function FunctionInvokation ::= (identifier ':')? identifier
- * '(' (Expression (,Expression)*)? ')' Note: currently we don't parse
- * arguments
- */
- private boolean parseFunction() {
- if (!(curToken instanceof Id) || isELReserved(curToken.toString())) {
- return false;
- }
- String s1 = null; // Function prefix
- String s2 = curToken.toString(); // Function name
- int mark = getIndex();
- if (hasNext()) {
- Token t = nextToken();
- if (t.toChar() == ':') {
- if (hasNext()) {
- Token t2 = nextToken();
- if (t2 instanceof Id) {
- s1 = s2;
- s2 = t2.toString();
- if (hasNext()) {
- t = nextToken();
- }
- }
- }
- }
- if (t.toChar() == '(') {
- ELexpr.add(new ELNode.Function(s1, s2));
- return true;
- }
- }
- setIndex(mark);
- return false;
- }
-
- /**
- * Test if an id is a reserved word in EL
- */
- private boolean isELReserved(String id) {
- int i = 0;
- int j = reservedWords.length;
- while (i < j) {
- int k = (i + j) / 2;
- int result = reservedWords[k].compareTo(id);
- if (result == 0) {
- return true;
- }
- if (result < 0) {
- i = k + 1;
- } else {
- j = k;
- }
- }
- return false;
- }
-
- /**
- * Skip until an EL expression ('${' || '#{') is reached, allowing escape
- * sequences '\\' and '\$' and '\#'.
- *
- * @return The text string up to the EL expression
- */
- private String skipUntilEL() {
- char prev = 0;
- StringBuffer buf = new StringBuffer();
- while (hasNextChar()) {
- char ch = nextChar();
- if (prev == '\\') {
- prev = 0;
- if (ch == '\\') {
- buf.append('\\');
- if (!escapeBS)
- prev = '\\';
- } else if (ch == '$' || ch == '#') {
- buf.append(ch);
- }
- // else error!
- } else if (prev == '$' || prev == '#') {
- if (ch == '{') {
- this.type = prev;
- prev = 0;
- break;
- }
- buf.append(prev);
- prev = 0;
- }
- if (ch == '\\' || ch == '$' || ch == '#') {
- prev = ch;
- } else {
- buf.append(ch);
- }
- }
- if (prev != 0) {
- buf.append(prev);
- }
- return buf.toString();
- }
-
- /*
- * @return true if there is something left in EL expression buffer other
- * than white spaces.
- */
- private boolean hasNext() {
- skipSpaces();
- return hasNextChar();
- }
-
- /*
- * @return The next token in the EL expression buffer.
- */
- private Token nextToken() {
- skipSpaces();
- if (hasNextChar()) {
- char ch = nextChar();
- if (Character.isJavaIdentifierStart(ch)) {
- StringBuffer buf = new StringBuffer();
- buf.append(ch);
- while ((ch = peekChar()) != -1
- && Character.isJavaIdentifierPart(ch)) {
- buf.append(ch);
- nextChar();
- }
- return new Id(buf.toString());
- }
-
- if (ch == '\'' || ch == '"') {
- return parseQuotedChars(ch);
- } else {
- // For now...
- return new Char(ch);
- }
- }
- return null;
- }
-
- /*
- * Parse a string in single or double quotes, allowing for escape sequences
- * '\\', and ('\"', or "\'")
- */
- private Token parseQuotedChars(char quote) {
- StringBuffer buf = new StringBuffer();
- buf.append(quote);
- while (hasNextChar()) {
- char ch = nextChar();
- if (ch == '\\') {
- ch = nextChar();
- if (ch == '\\' || ch == quote) {
- buf.append(ch);
- }
- // else error!
- } else if (ch == quote) {
- buf.append(ch);
- break;
- } else {
- buf.append(ch);
- }
- }
- return new QuotedString(buf.toString());
- }
-
- /*
- * A collection of low level parse methods dealing with character in the EL
- * expression buffer.
- */
-
- private void skipSpaces() {
- while (hasNextChar()) {
- if (expression.charAt(index) > ' ')
- break;
- index++;
- }
- }
-
- private boolean hasNextChar() {
- return index < expression.length();
- }
-
- private char nextChar() {
- if (index >= expression.length()) {
- return (char) -1;
- }
- return expression.charAt(index++);
- }
-
- private char peekChar() {
- if (index >= expression.length()) {
- return (char) -1;
- }
- return expression.charAt(index);
- }
-
- private int getIndex() {
- return index;
- }
-
- private void setIndex(int i) {
- index = i;
- }
-
- /*
- * Represents a token in EL expression string
- */
- private static class Token {
-
- char toChar() {
- return 0;
- }
-
- public String toString() {
- return "";
- }
- }
-
- /*
- * Represents an ID token in EL
- */
- private static class Id extends Token {
- String id;
-
- Id(String id) {
- this.id = id;
- }
-
- public String toString() {
- return id;
- }
- }
-
- /*
- * Represents a character token in EL
- */
- private static class Char extends Token {
-
- private char ch;
-
- Char(char ch) {
- this.ch = ch;
- }
-
- char toChar() {
- return ch;
- }
-
- public String toString() {
- return (new Character(ch)).toString();
- }
- }
-
- /*
- * Represents a quoted (single or double) string token in EL
- */
- private static class QuotedString extends Token {
-
- private String value;
-
- QuotedString(String v) {
- this.value = v;
- }
-
- public String toString() {
- return value;
- }
- }
-
- public char getType() {
- return type;
- }
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ErrorDispatcher.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ErrorDispatcher.java
deleted file mode 100644
index 85c821af0..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ErrorDispatcher.java
+++ /dev/null
@@ -1,699 +0,0 @@
-/*
- * 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.struts2.jasper.compiler;
-
-import org.apache.struts2.jasper.JasperException;
-import org.apache.struts2.jasper.JspCompilationContext;
-import org.xml.sax.SAXException;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-
-/**
- *
- * Class responsible for dispatching JSP parse and javac compilation errors
- * to the configured error handler.
- *
- *
- *
- * 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
- * the configured error handler.
- *
- *
- * @author Jan Luehe
- * @author Kin-man Chung
- */
-public class ErrorDispatcher {
-
- // Custom error handler
- private ErrorHandler errHandler;
-
- // Indicates whether the compilation was initiated by JspServlet or JspC
- private boolean jspcMode = false;
-
-
- /**
- * Constructor.
- *
- * @param jspcMode true if compilation has been initiated by JspC, false otherwise
- */
- public ErrorDispatcher(boolean jspcMode) {
- // XXX check web.xml for custom error handler
- errHandler = new DefaultErrorHandler();
- this.jspcMode = jspcMode;
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- *
- * @param errCode Error code
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(String errCode) throws JasperException {
- dispatch(null, errCode, null, null);
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- * @param where Error location
- * @param errCode Error code
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(Mark where, String errCode) throws JasperException {
- dispatch(where, errCode, null, null);
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- *
- * @param n Node that caused the error
- * @param errCode Error code
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(Node n, String errCode) throws JasperException {
- dispatch(n.getStart(), errCode, null, null);
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- *
- * @param errCode Error code
- * @param arg Argument for parametric replacement
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(String errCode, String arg) throws JasperException {
- dispatch(null, errCode, new Object[]{arg}, null);
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- *
- * @param where Error location
- * @param errCode Error code
- * @param arg Argument for parametric replacement
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(Mark where, String errCode, String arg)
- throws JasperException {
- dispatch(where, errCode, new Object[]{arg}, null);
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- *
- * @param n Node that caused the error
- * @param errCode Error code
- * @param arg Argument for parametric replacement
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(Node n, String errCode, String arg)
- throws JasperException {
- dispatch(n.getStart(), errCode, new Object[]{arg}, null);
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- *
- * @param errCode Error code
- * @param arg1 First argument for parametric replacement
- * @param arg2 Second argument for parametric replacement
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(String errCode, String arg1, String arg2)
- throws JasperException {
- dispatch(null, errCode, new Object[]{arg1, arg2}, null);
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- *
- * @param errCode Error code
- * @param arg1 First argument for parametric replacement
- * @param arg2 Second argument for parametric replacement
- * @param arg3 Third argument for parametric replacement
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(String errCode, String arg1, String arg2, String arg3)
- throws JasperException {
- dispatch(null, errCode, new Object[]{arg1, arg2, arg3}, null);
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- *
- * @param where Error location
- * @param errCode Error code
- * @param arg1 First argument for parametric replacement
- * @param arg2 Second argument for parametric replacement
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(Mark where, String errCode, String arg1, String arg2)
- throws JasperException {
- dispatch(where, errCode, new Object[]{arg1, arg2}, null);
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- *
- * @param where Error location
- * @param errCode Error code
- * @param arg1 First argument for parametric replacement
- * @param arg2 Second argument for parametric replacement
- * @param arg3 Third argument for parametric replacement
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(Mark where, String errCode, String arg1, String arg2,
- String arg3)
- throws JasperException {
- dispatch(where, errCode, new Object[]{arg1, arg2, arg3}, null);
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- *
- * @param n Node that caused the error
- * @param errCode Error code
- * @param arg1 First argument for parametric replacement
- * @param arg2 Second argument for parametric replacement
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(Node n, String errCode, String arg1, String arg2)
- throws JasperException {
- dispatch(n.getStart(), errCode, new Object[]{arg1, arg2}, null);
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- *
- * @param n Node that caused the error
- * @param errCode Error code
- * @param arg1 First argument for parametric replacement
- * @param arg2 Second argument for parametric replacement
- * @param arg3 Third argument for parametric replacement
- * @throws JasperException in case of Jasper errors
- */
- 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);
- }
-
- /**
- *
- * Dispatches the given parsing exception to the configured error handler.
- *
- *
- * @param e Parsing exception
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(Exception e) throws JasperException {
- dispatch(null, null, null, e);
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- *
- * @param errCode Error code
- * @param arg Argument for parametric replacement
- * @param e Parsing exception
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(String errCode, String arg, Exception e)
- throws JasperException {
- dispatch(null, errCode, new Object[]{arg}, e);
- }
-
- /**
- *
- * Dispatches the given JSP parse error to the configured error handler.
- *
- *
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- *
- * @param n Node that caused the error
- * @param errCode Error code
- * @param arg Argument for parametric replacement
- * @param e Parsing exception
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(Node n, String errCode, String arg, Exception e)
- throws JasperException {
- dispatch(n.getStart(), errCode, new Object[]{arg}, e);
- }
-
- /**
- *
- * Parses the given error message into an array of javac compilation error
- * messages (one per javac compilation error line number).
- *
- *
- * @param errMsg Error message
- * @param fname Name of Java source file whose compilation failed
- * @param page Node representation of JSP page from which the Java source
- * file was generated
- * @return Array of javac compilation errors, or null if the given error
- * message does not contain any compilation error line numbers
- * @throws JasperException in case of Jasper errors
- * @throws IOException in case of IO errors
- */
- public static JavacErrorDetail[] parseJavacErrors(String errMsg,
- String fname,
- Node.Nodes page)
- throws JasperException, IOException {
-
- return parseJavacMessage(errMsg, fname, page);
- }
-
- /**
- *
- * Dispatches the given javac compilation errors to the configured error
- * handler.
- *
- *
- * @param javacErrors Array of javac compilation errors
- * @throws JasperException in case of Jasper errors
- */
- public void javacError(JavacErrorDetail[] javacErrors)
- throws JasperException {
-
- errHandler.javacError(javacErrors);
- }
-
-
- /**
- *
- * Dispatches the given compilation error report and exception to the
- * configured error handler.
- *
- *
- * @param errorReport Compilation error report
- * @param e Compilation exception
- * @throws JasperException in case of Jasper errors
- */
- public void javacError(String errorReport, Exception e)
- throws JasperException {
-
- errHandler.javacError(errorReport, e);
- }
-
-
- //*********************************************************************
- // Private utility methods
-
- /*
- * Dispatches the given JSP parse error to the configured error handler.
- *
- * The given error code is localized. If it is not found in the
- * resource bundle for localized error messages, it is used as the error
- * message.
- *
- * @param where Error location
- * @param errCode Error code
- * @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) {
- if (jspcMode) {
- // Get the full URL of the resource that caused the error
- try {
- file = where.getURL().toString();
- } catch (MalformedURLException me) {
- // Fallback to using context-relative path
- file = where.getFile();
- }
- } else {
- // Get the context-relative resource path, so as to not
- // 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);
- }
- }
-
- /*
- * Parses the given Java compilation error message, which may contain one
- * or more compilation errors, into an array of JavacErrorDetail instances.
- *
- * Each JavacErrorDetail instance contains the information about a single
- * compilation error.
- *
- * @param errMsg Compilation error message that was generated by the
- * javac compiler
- * @param fname Name of Java source file whose compilation failed
- * @param page Node representation of JSP page from which the Java source
- * file was generated
- *
- * @return Array of JavacErrorDetail instances corresponding to the
- * compilation errors
- */
- private static JavacErrorDetail[] parseJavacMessage(
- String errMsg, String fname, Node.Nodes page)
- throws IOException, JasperException {
-
- ArrayList errors = new ArrayList();
- 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
- * the error.
- */
- 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 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 Name of the JSP file in which the parse error occurred
- * @param page page
- * @param errMsgBuf error message buffer
- * @param lineNum line number
- * @return JavacErrorDetail The error details
- * @throws JasperException in case of Jasper errors
- */
- public static JavacErrorDetail createJavacError(String fname,
- Node.Nodes page, StringBuffer errMsgBuf, int lineNum)
- throws JasperException {
- return createJavacError(fname, page, errMsgBuf, lineNum, null);
- }
-
-
- /**
- * @param fname Name of the JSP file in which the parse error occurred
- * @param page page
- * @param errMsgBuf error message buffer
- * @param lineNum line number
- * @param ctxt JSP compilation context
- * @return JavacErrorDetail The error details
- * @throws JasperException in case of Jasper errors
- */
- public static JavacErrorDetail createJavacError(String fname,
- Node.Nodes page, StringBuffer errMsgBuf, int lineNum,
- JspCompilationContext ctxt) throws JasperException {
- JavacErrorDetail javacError;
- // Attempt to map javac error line number to line in JSP page
- ErrorVisitor errVisitor = new ErrorVisitor(lineNum);
- page.visit(errVisitor);
- Node errNode = errVisitor.getJspSourceNode();
- if ((errNode != null) && (errNode.getStart() != null)) {
- // If this is a scriplet node then there is a one to one mapping
- // between JSP lines and Java lines
- if (errVisitor.getJspSourceNode() instanceof Node.Scriptlet) {
- javacError = new JavacErrorDetail(
- fname,
- lineNum,
- errNode.getStart().getFile(),
- errNode.getStart().getLineNumber() + lineNum -
- errVisitor.getJspSourceNode().getBeginJavaLine(),
- errMsgBuf,
- ctxt);
- } else {
- javacError = new JavacErrorDetail(
- fname,
- lineNum,
- errNode.getStart().getFile(),
- errNode.getStart().getLineNumber(),
- errMsgBuf,
- ctxt);
- }
- } else {
- /*
- * javac error line number cannot be mapped to JSP page
- * 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
- * of this, the javac error line numbers will be outside
- * the range of begin and end java line numbers that were
- * generated for the scriptlet, and therefore cannot be
- * mapped to the start line number of the scriptlet in the
- * JSP page.
- * Include just the javac error info in the error detail.
- */
- 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;
- }
- }
-
- /**
- * 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/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ErrorHandler.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ErrorHandler.java
deleted file mode 100644
index 846d152c5..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ErrorHandler.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.struts2.jasper.compiler;
-
-import org.apache.struts2.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
- * implementation's fully qualified class name.
- *
- *
- * @author Jan Luehe
- * @author Kin-man Chung
- */
-public interface ErrorHandler {
-
- /**
- * Processes the given JSP parse error.
- *
- * @param fname Name of the JSP file in which the parse error occurred
- * @param line Parse error line number
- * @param column Parse error column number
- * @param msg Parse error message
- * @param exception Parse exception
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(String fname, int line, int column, String msg, Exception exception) throws JasperException;
-
- /**
- * Processes the given JSP parse error.
- *
- * @param msg Parse error message
- * @param exception Parse exception
- * @throws JasperException in case of Jasper errors
- */
- public void jspError(String msg, Exception exception) throws JasperException;
-
- /**
- * Processes the given javac compilation errors.
- *
- * @param details Array of JavacErrorDetail instances corresponding to the
- * compilation errors
- * @throws JasperException in case of Jasper errors
- */
- public void javacError(JavacErrorDetail[] details)
- throws JasperException;
-
- /**
- * Processes the given javac error report and exception.
- *
- * @param errorReport Compilation error report
- * @param exception Compilation exception
- * @throws JasperException in case of Jasper errors
- */
- public void javacError(String errorReport, Exception exception) throws JasperException;
-}
diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Generator.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Generator.java
deleted file mode 100644
index 9fb8ee6b9..000000000
--- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Generator.java
+++ /dev/null
@@ -1,4190 +0,0 @@
-/*
- * 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.struts2.jasper.compiler;
-
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import jakarta.el.MethodExpression;
-import jakarta.el.ValueExpression;
-import jakarta.servlet.jsp.tagext.TagAttributeInfo;
-import jakarta.servlet.jsp.tagext.TagInfo;
-import jakarta.servlet.jsp.tagext.TagVariableInfo;
-import jakarta.servlet.jsp.tagext.VariableInfo;
-
-import org.apache.struts2.jasper.Constants;
-import org.apache.struts2.jasper.JasperException;
-import org.apache.struts2.jasper.JspCompilationContext;
-import org.apache.struts2.jasper.compiler.Node.NamedAttribute;
-import org.apache.struts2.jasper.runtime.JspRuntimeLibrary;
-import org.apache.struts2.JSPRuntime;
-import org.xml.sax.Attributes;
-
-/**
- * Generate Java source from Nodes
- *
- * @author Anil K. Vijendran
- * @author Danno Ferrin
- * @author Mandar Raje
- * @author Rajiv Mordani
- * @author Pierre Delisle
- *
- * Tomcat 4.1.x and Tomcat 5:
- * @author Kin-man Chung
- * @author Jan Luehe
- * @author Shawn Bayern
- * @author Mark Roth
- * @author Denis Benoit
- *
- * Tomcat 6.x
- * @author Jacob Hookom
- * @author Remy Maucherat
- */
-
-class Generator {
-
- private static final Class[] OBJECT_CLASS = { Object.class };
-
- private static final String VAR_EXPRESSIONFACTORY =
- System.getProperty("org.apache.struts2.jasper.compiler.Generator.VAR_EXPRESSIONFACTORY", "_el_expressionfactory");
- private static final String VAR_INSTANCEMANAGER =
- System.getProperty("org.apache.struts2.jasper.compiler.Generator.VAR_INSTANCEMANAGER", "_jsp_instancemanager");
-
- private ServletWriter out;
-
- private ArrayList methodsBuffered;
-
- private FragmentHelperClass fragmentHelperClass;
-
- private ErrorDispatcher err;
-
- private BeanRepository beanInfo;
-
- private JspCompilationContext ctxt;
-
- private boolean isPoolingEnabled;
-
- private boolean breakAtLF;
-
- private String jspIdPrefix;
-
- private int jspId;
-
- private PageInfo pageInfo;
-
- private Vector tagHandlerPoolNames;
-
- private GenBuffer charArrayBuffer;
-
- /**
- * @param s
- * the input string
- * @return quoted and escaped string, per Java rule
- */
- static String quote(String s) {
-
- if (s == null)
- return "null";
-
- return '"' + escape(s) + '"';
- }
-
- /**
- * @param s
- * the input string
- * @return escaped string, per Java rule
- */
- static String escape(String s) {
-
- if (s == null)
- return "";
-
- StringBuffer b = new StringBuffer();
- for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
- if (c == '"')
- b.append('\\').append('"');
- else if (c == '\\')
- b.append('\\').append('\\');
- else if (c == '\n')
- b.append('\\').append('n');
- else if (c == '\r')
- b.append('\\').append('r');
- else
- b.append(c);
- }
- return b.toString();
- }
-
- /**
- * Single quote and escape a character
- */
- static String quote(char c) {
-
- StringBuffer b = new StringBuffer();
- b.append('\'');
- if (c == '\'')
- b.append('\\').append('\'');
- else if (c == '\\')
- b.append('\\').append('\\');
- else if (c == '\n')
- b.append('\\').append('n');
- else if (c == '\r')
- b.append('\\').append('r');
- else
- b.append(c);
- b.append('\'');
- return b.toString();
- }
-
- private String createJspId() throws JasperException {
- if (this.jspIdPrefix == null) {
- StringBuffer sb = new StringBuffer(32);
- String name = ctxt.getServletJavaFileName();
- sb.append("jsp_").append(Math.abs(name.hashCode())).append('_');
- this.jspIdPrefix = sb.toString();
- }
- return this.jspIdPrefix + (this.jspId++);
- }
-
- /**
- * Generates declarations. This includes "info" of the page directive, and
- * scriptlet declarations.
- */
- private void generateDeclarations(Node.Nodes page) throws JasperException {
-
- class DeclarationVisitor extends Node.Visitor {
-
- private boolean getServletInfoGenerated = false;
-
- /*
- * Generates getServletInfo() method that returns the value of the
- * page directive's 'info' attribute, if present.
- *
- * The Validator has already ensured that if the translation unit
- * contains more than one page directive with an 'info' attribute,
- * their values match.
- */
- public void visit(Node.PageDirective n) throws JasperException {
-
- if (getServletInfoGenerated) {
- return;
- }
-
- String info = n.getAttributeValue("info");
- if (info == null)
- return;
-
- getServletInfoGenerated = true;
- out.printil("public String getServletInfo() {");
- out.pushIndent();
- out.printin("return ");
- out.print(quote(info));
- out.println(";");
- out.popIndent();
- out.printil("}");
- out.println();
- }
-
- public void visit(Node.Declaration n) throws JasperException {
- n.setBeginJavaLine(out.getJavaLine());
- out.printMultiLn(new String(n.getText()));
- out.println();
- n.setEndJavaLine(out.getJavaLine());
- }
-
- // Custom Tags may contain declarations from tag plugins.
- public void visit(Node.CustomTag n) throws JasperException {
- if (n.useTagPlugin()) {
- if (n.getAtSTag() != null) {
- n.getAtSTag().visit(this);
- }
- visitBody(n);
- if (n.getAtETag() != null) {
- n.getAtETag().visit(this);
- }
- } else {
- visitBody(n);
- }
- }
- }
-
- out.println();
- page.visit(new DeclarationVisitor());
- }
-
- /**
- * Compiles list of tag handler pool names.
- */
- private void compileTagHandlerPoolList(Node.Nodes page)
- throws JasperException {
-
- class TagHandlerPoolVisitor extends Node.Visitor {
-
- private Vector names;
-
- /*
- * Constructor
- *
- * @param v Vector of tag handler pool names to populate
- */
- TagHandlerPoolVisitor(Vector v) {
- names = v;
- }
-
- /*
- * Gets the name of the tag handler pool for the given custom tag
- * and adds it to the list of tag handler pool names unless it is
- * already contained in it.
- */
- public void visit(Node.CustomTag n) throws JasperException {
-
- if (!n.implementsSimpleTag()) {
- String name = createTagHandlerPoolName(n.getPrefix(), n
- .getLocalName(), n.getAttributes(),
- n.getNamedAttributeNodes(), n.hasEmptyBody());
- n.setTagHandlerPoolName(name);
- if (!names.contains(name)) {
- names.add(name);
- }
- }
- visitBody(n);
- }
-
- /*
- * Creates the name of the tag handler pool whose tag handlers may
- * be (re)used to service this action.
- *
- * @return The name of the tag handler pool
- */
- private String createTagHandlerPoolName(String prefix,
- String shortName, Attributes attrs, Node.Nodes namedAttrs,
- boolean hasEmptyBody) {
- String poolName = null;
-
- poolName = "_jspx_tagPool_" + prefix + "_" + shortName;
- if (attrs != null) {
- String[] attrNames =
- new String[attrs.getLength() + namedAttrs.size()];
- for (int i = 0; i < attrNames.length; i++) {
- attrNames[i] = attrs.getQName(i);
- }
- for (int i = 0; i < namedAttrs.size(); i++) {
- attrNames[attrs.getLength() + i] =
- ((NamedAttribute) namedAttrs.getNode(i)).getQName();
- }
- Arrays.sort(attrNames, Collections.reverseOrder());
- if (attrNames.length > 0) {
- poolName = poolName + "&";
- }
- for (int i = 0; i < attrNames.length; i++) {
- poolName = poolName + "_" + attrNames[i];
- }
- }
- if (hasEmptyBody) {
- poolName = poolName + "_nobody";
- }
- return JspUtil.makeJavaIdentifier(poolName);
- }
- }
-
- page.visit(new TagHandlerPoolVisitor(tagHandlerPoolNames));
- }
-
- private void declareTemporaryScriptingVars(Node.Nodes page)
- throws JasperException {
-
- class ScriptingVarVisitor extends Node.Visitor {
-
- private Vector vars;
-
- ScriptingVarVisitor() {
- vars = new Vector();
- }
-
- public void visit(Node.CustomTag n) throws JasperException {
-
- if (n.getCustomNestingLevel() > 0) {
- TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
- VariableInfo[] varInfos = n.getVariableInfos();
-
- if (varInfos.length > 0) {
- for (int i = 0; i < varInfos.length; i++) {
- String varName = varInfos[i].getVarName();
- String tmpVarName = "_jspx_" + varName + "_"
- + n.getCustomNestingLevel();
- if (!vars.contains(tmpVarName)) {
- vars.add(tmpVarName);
- out.printin(varInfos[i].getClassName());
- out.print(" ");
- out.print(tmpVarName);
- out.print(" = ");
- out.print(null);
- out.println(";");
- }
- }
- } else {
- for (int i = 0; i < tagVarInfos.length; i++) {
- String varName = tagVarInfos[i].getNameGiven();
- if (varName == null) {
- varName = n.getTagData().getAttributeString(
- tagVarInfos[i].getNameFromAttribute());
- } else if (tagVarInfos[i].getNameFromAttribute() != null) {
- // alias
- continue;
- }
- String tmpVarName = "_jspx_" + varName + "_"
- + n.getCustomNestingLevel();
- if (!vars.contains(tmpVarName)) {
- vars.add(tmpVarName);
- out.printin(tagVarInfos[i].getClassName());
- out.print(" ");
- out.print(tmpVarName);
- out.print(" = ");
- out.print(null);
- out.println(";");
- }
- }
- }
- }
-
- visitBody(n);
- }
- }
-
- page.visit(new ScriptingVarVisitor());
- }
-
- /**
- * Generates the _jspInit() method for instantiating the tag handler pools.
- * For tag file, _jspInit has to be invoked manually, and the ServletConfig
- * object explicitly passed.
- *
- * In JSP 2.1, we also instantiate an ExpressionFactory
- */
- private void generateInit() {
-
- if (ctxt.isTagFile()) {
- out.printil("private void _jspInit(ServletConfig config) {");
- } else {
- out.printil("public void _jspInit() {");
- }
-
- out.pushIndent();
- if (isPoolingEnabled) {
- for (int i = 0; i < tagHandlerPoolNames.size(); i++) {
- out.printin(tagHandlerPoolNames.elementAt(i));
- out.print(" = org.apache.struts2.jasper.runtime.TagHandlerPool.getTagHandlerPool(");
- if (ctxt.isTagFile()) {
- out.print("config");
- } else {
- out.print("getServletConfig()");
- }
- out.println(");");
- }
- }
-
- out.printin(VAR_EXPRESSIONFACTORY);
- out.print(" = _jspxFactory.getJspApplicationContext(");
- if (ctxt.isTagFile()) {
- out.print("config");
- } else {
- out.print("getServletConfig()");
- }
- out.println(".getServletContext()).getExpressionFactory();");
- out.printin(VAR_INSTANCEMANAGER);
- out.print(" = (org.apache.tomcat.InstanceManager) ");
- if (ctxt.isTagFile()) {
- out.print("config");
- } else {
- out.print("getServletConfig()");
- }
- out.println(".getServletContext().getAttribute(org.apache.tomcat.InstanceManager.class.getName());");
-
- out.popIndent();
- out.printil("}");
- out.println();
- }
-
- /**
- * Generates the _jspDestroy() method which is responsible for calling the
- * release() method on every tag handler in any of the tag handler pools.
- */
- private void generateDestroy() {
-
- out.printil("public void _jspDestroy() {");
- out.pushIndent();
-
- if (isPoolingEnabled) {
- for (int i = 0; i < tagHandlerPoolNames.size(); i++) {
- out.printin((String) tagHandlerPoolNames.elementAt(i));
- out.println(".release();");
- }
- }
-
- out.popIndent();
- out.printil("}");
- out.println();
- }
-
- /**
- * Generate preamble package name (shared by servlet and tag handler
- * preamble generation)
- */
- private void genPreamblePackage(String packageName) throws JasperException {
- if (!"".equals(packageName) && packageName != null) {
- out.printil("package " + packageName + ";");
- out.println();
- }
- }
-
- /**
- * Generate preamble imports (shared by servlet and tag handler preamble
- * generation)
- */
- private void genPreambleImports() throws JasperException {
- Iterator iter = pageInfo.getImports().iterator();
- while (iter.hasNext()) {
- out.printin("import ");
- out.print((String) iter.next());
- out.println(";");
- }
-
- out.println();
- }
-
- /**
- * Generation of static initializers in preamble. For example, dependant
- * list, el function map, prefix map. (shared by servlet and tag handler
- * preamble generation)
- */
- private void genPreambleStaticInitializers() throws JasperException {
- out.printil("private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();");
- out.println();
-
- // Static data for getDependants()
- out.printil("private static java.util.List _jspx_dependants;");
- out.println();
- List dependants = pageInfo.getDependants();
- Iterator iter = dependants.iterator();
- if (!dependants.isEmpty()) {
- out.printil("static {");
- out.pushIndent();
- out.printin("_jspx_dependants = new java.util.ArrayList(");
- out.print("" + dependants.size());
- out.println(");");
- while (iter.hasNext()) {
- out.printin("_jspx_dependants.add(\"");
- out.print((String) iter.next());
- out.println("\");");
- }
- out.popIndent();
- out.printil("}");
- out.println();
- }
- }
-
- /**
- * Declare tag handler pools (tags of the same type and with the same
- * attribute set share the same tag handler pool) (shared by servlet and tag
- * handler preamble generation)
- *
- * In JSP 2.1, we also scope an instance of ExpressionFactory
- */
- private void genPreambleClassVariableDeclarations(String className)
- throws JasperException {
- if (isPoolingEnabled && !tagHandlerPoolNames.isEmpty()) {
- for (int i = 0; i < tagHandlerPoolNames.size(); i++) {
- out.printil("private org.apache.struts2.jasper.runtime.TagHandlerPool "
- + tagHandlerPoolNames.elementAt(i) + ";");
- }
- out.println();
- }
- out.printin("private jakarta.el.ExpressionFactory ");
- out.print(VAR_EXPRESSIONFACTORY);
- out.println(";");
- out.printin("private org.apache.tomcat.InstanceManager ");
- out.print(VAR_INSTANCEMANAGER);
- out.println(";");
- out.println();
- }
-
- /**
- * Declare general-purpose methods (shared by servlet and tag handler
- * preamble generation)
- */
- private void genPreambleMethods() throws JasperException {
- // Method used to get compile time file dependencies
- out.printil("public Object getDependants() {");
- out.pushIndent();
- out.printil("return _jspx_dependants;");
- out.popIndent();
- out.printil("}");
- out.println();
-
- generateInit();
- generateDestroy();
- }
-
- /**
- * Generates the beginning of the static portion of the servlet.
- */
- private void generatePreamble(Node.Nodes page) throws JasperException {
-
- String servletPackageName = ctxt.getServletPackageName();
- String servletClassName = ctxt.getServletClassName();
- String serviceMethodName = Constants.SERVICE_METHOD_NAME;
-
- // First the package name:
- genPreamblePackage(servletPackageName);
-
- // Generate imports
- genPreambleImports();
-
- // Generate class declaration
- out.printin("public final class ");
- out.print(servletClassName);
- out.print(" extends ");
- out.println(pageInfo.getExtends());
- out.printin(" implements org.apache.struts2.jasper.runtime.JspSourceDependent");
- if (!pageInfo.isThreadSafe()) {
- out.println(",");
- out.printin(" SingleThreadModel");
- }
- out.println(" {");
- out.pushIndent();
-
- // Class body begins here
- generateDeclarations(page);
-
- // Static initializations here
- genPreambleStaticInitializers();
-
- // Class variable declarations
- genPreambleClassVariableDeclarations(servletClassName);
-
- // Constructor
- // generateConstructor(className);
-
- // Methods here
- genPreambleMethods();
-
- // Now the service method
- out.printin("public void ");
- out.print(serviceMethodName);
- out.println("(HttpServletRequest request, HttpServletResponse response)");
- out.println(" throws java.io.IOException, ServletException {");
-
- out.pushIndent();
- out.println();
-
- // Local variable declarations
- out.printil("PageContext pageContext = null;");
-
- if (pageInfo.isSession())
- out.printil("HttpSession session = null;");
-
- if (pageInfo.isErrorPage()) {
- out.printil("Throwable exception = org.apache.struts2.jasper.runtime.JspRuntimeLibrary.getThrowable(request);");
- out.printil("if (exception != null) {");
- out.pushIndent();
- out.printil("response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);");
- out.popIndent();
- out.printil("}");
- }
-
- out.printil("ServletContext application = null;");
- out.printil("ServletConfig config = null;");
- out.printil("JspWriter out = null;");
- out.printil("Object page = this;");
-
- out.printil("JspWriter _jspx_out = null;");
- out.printil("PageContext _jspx_page_context = null;");
- out.println();
-
- declareTemporaryScriptingVars(page);
- out.println();
-
- out.printil("try {");
- out.pushIndent();
-
- out.printin("response.setContentType(");
- out.print(quote(pageInfo.getContentType()));
- out.println(");");
-
- if (ctxt.getOptions().isXpoweredBy()) {
- out.printil("response.addHeader(\"X-Powered-By\", \"JSP/2.1\");");
- }
-
- out
- .printil("pageContext = _jspxFactory.getPageContext(this, request, response,");
- out.printin("\t\t\t");
- out.print(quote(pageInfo.getErrorPage()));
- out.print(", " + pageInfo.isSession());
- out.print(", " + pageInfo.getBuffer());
- out.print(", " + pageInfo.isAutoFlush());
- out.println(");");
- out.printil("_jspx_page_context = pageContext;");
-
- out.printil("application = pageContext.getServletContext();");
- out.printil("config = pageContext.getServletConfig();");
-
- if (pageInfo.isSession())
- out.printil("session = pageContext.getSession();");
- out.printil("out = pageContext.getOut();");
- out.printil("_jspx_out = out;");
- out.println();
- }
-
- /**
- * Generates an XML Prolog, which includes an XML declaration and an XML
- * doctype declaration.
- */
- private void generateXmlProlog(Node.Nodes page) {
-
- /*
- * An XML declaration is generated under the following conditions: -
- * 'omit-xml-declaration' attribute of action is set to
- * "no" or "false" - JSP document without a
- */
- String omitXmlDecl = pageInfo.getOmitXmlDecl();
- if ((omitXmlDecl != null && !JspUtil.booleanValue(omitXmlDecl))
- || (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(\"\\n\");");
- }
-
- /*
- * Output a DOCTYPE declaration if the doctype-root-element appears. If
- * doctype-public appears: else
- */
-
- String doctypeName = pageInfo.getDoctypeName();
- if (doctypeName != null) {
- String doctypePublic = pageInfo.getDoctypePublic();
- String doctypeSystem = pageInfo.getDoctypeSystem();
- out.printin("out.write(\"\\n\");");
- }
- }
-
- /**
- * A visitor that generates codes for the elements in the page.
- */
- class GenerateVisitor extends Node.Visitor {
-
- /*
- * Hashtable containing introspection information on tag handlers:
- * : tag prefix : hashtable containing introspection on tag
- * handlers: : tag short name : introspection info of tag
- * handler for tag
- */
- private Hashtable handlerInfos;
-
- private Hashtable tagVarNumbers;
-
- private String parent;
-
- private boolean isSimpleTagParent; // Is parent a SimpleTag?
-
- private String pushBodyCountVar;
-
- private String simpleTagHandlerVar;
-
- private boolean isSimpleTagHandler;
-
- private boolean isFragment;
-
- private boolean isTagFile;
-
- private ServletWriter out;
-
- private ArrayList methodsBuffered;
-
- private FragmentHelperClass fragmentHelperClass;
-
- private int methodNesting;
-
- private TagInfo tagInfo;
-
- private ClassLoader loader;
-
- private int charArrayCount;
-
- private HashMap textMap;
-
- /**
- * Constructor.
- */
- public GenerateVisitor(boolean isTagFile, ServletWriter out,
- ArrayList methodsBuffered,
- FragmentHelperClass fragmentHelperClass, ClassLoader loader,
- TagInfo tagInfo) {
-
- this.isTagFile = isTagFile;
- this.out = out;
- this.methodsBuffered = methodsBuffered;
- this.fragmentHelperClass = fragmentHelperClass;
- this.loader = loader;
- this.tagInfo = tagInfo;
- methodNesting = 0;
- handlerInfos = new Hashtable();
- tagVarNumbers = new Hashtable();
- textMap = new HashMap();
- }
-
- /**
- * Returns an attribute value, optionally URL encoded. If the value is a
- * runtime expression, the result is the expression itself, as a string.
- * If the result is an EL expression, we insert a call to the
- * interpreter. If the result is a Named Attribute we insert the
- * generated variable name. Otherwise the result is a string literal,
- * quoted and escaped.
- *
- * @param attr
- * An JspAttribute object
- * @param encode
- * true if to be URL encoded
- * @param expectedType
- * 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) {
- String v = attr.getValue();
- if (!attr.isNamedAttribute() && (v == null))
- return "";
-
- if (attr.isExpression()) {
- if (encode) {
- return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.URLEncode(String.valueOf("
- + v + "), request.getCharacterEncoding())";
- }
- return v;
- } else if (attr.isELInterpreterInput()) {
- v = attributeValueWithEL(this.isTagFile, v, expectedType,
- attr.getEL().getMapName());
- if (encode) {
- return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.URLEncode("
- + v + ", request.getCharacterEncoding())";
- }
- return v;
- } else if (attr.isNamedAttribute()) {
- return attr.getNamedAttributeNode().getTemporaryVariableName();
- } else {
- if (encode) {
- return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.URLEncode("
- + quote(v) + ", request.getCharacterEncoding())";
- }
- return quote(v);
- }
- }
-
-
- /*
- * When interpreting the EL attribute value, literals outside the EL
- * must not be unescaped but the EL processor will unescape them.
- * Therefore, make sure only the EL expressions are processed by the EL
- * processor.
- */
- private String attributeValueWithEL(boolean isTag, String tx,
- Class> expectedType, String mapName) {
- if (tx==null) return null;
- Class> type = expectedType;
- int size = tx.length();
- StringBuffer output = new StringBuffer(size);
- boolean el = false;
- int i = 0;
- int mark = 0;
- char ch;
-
- while(i < size){
- ch = tx.charAt(i);
-
- // Start of an EL expression
- if (!el && i+1 < size && ch == '$' && tx.charAt(i+1)=='{') {
- if (mark < i) {
- if (output.length() > 0) {
- output.append(" + ");
- // Composite expression - must coerce to String
- type = String.class;
- }
- output.append(quote(tx.substring(mark, i)));
- }
- mark = i;
- el = true;
- i += 2;
- } else if (ch=='\\' && i+1 < size &&
- (tx.charAt(i+1)=='$' || tx.charAt(i+1)=='}')) {
- // Skip an escaped $ or }
- i += 2;
- } else if (el && ch=='}') {
- // End of an EL expression
- if (output.length() > 0) {
- output.append(" + ");
- // Composite expression - must coerce to String
- type = String.class;
- }
- output.append(
- JspUtil.interpreterCall(isTag,
- tx.substring(mark, i+1), type,
- mapName, false));
- mark = i + 1;
- el = false;
- ++i;
- } else {
- // Nothing to see here - move to next character
- ++i;
- }
- }
- if (!el && mark < i) {
- if (output.length() > 0) {
- output.append(" + ");
- }
- output.append(quote(tx.substring(mark, i)));
- }
- return output.toString();
- }
-
-
- /**
- * Prints the attribute value specified in the param action, in the form
- * of name=value string.
- *
- * @param n
- * the parent node for the param action nodes.
- */
- private void printParams(Node n, String pageParam, boolean literal)
- throws JasperException {
-
- class ParamVisitor extends Node.Visitor {
- String separator;
-
- ParamVisitor(String separator) {
- this.separator = separator;
- }
-
- public void visit(Node.ParamAction n) throws JasperException {
-
- out.print(" + ");
- out.print(separator);
- out.print(" + ");
- out.print("org.apache.struts2.jasper.runtime.JspRuntimeLibrary."
- + "URLEncode(" + quote(n.getTextAttribute("name"))
- + ", request.getCharacterEncoding())");
- out.print("+ \"=\" + ");
- out.print(attributeValue(n.getValue(), true, String.class));
-
- // The separator is '&' after the second use
- separator = "\"&\"";
- }
- }
-
- String sep;
- if (literal) {
- sep = pageParam.indexOf('?') > 0 ? "\"&\"" : "\"?\"";
- } else {
- sep = "((" + pageParam + ").indexOf('?')>0? '&': '?')";
- }
- if (n.getBody() != null) {
- n.getBody().visit(new ParamVisitor(sep));
- }
- }
-
- public void visit(Node.Expression n) throws JasperException {
- n.setBeginJavaLine(out.getJavaLine());
- out.printin("out.print(");
- out.printMultiLn(n.getText());
- out.println(");");
- n.setEndJavaLine(out.getJavaLine());
- }
-
- public void visit(Node.Scriptlet n) throws JasperException {
- n.setBeginJavaLine(out.getJavaLine());
- out.printMultiLn(n.getText());
- out.println();
- n.setEndJavaLine(out.getJavaLine());
- }
-
- public void visit(Node.ELExpression n) throws JasperException {
- 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) + ");");
- } else {
- out.printil("out.write("
- + quote(n.getType() + "{" + new String(n.getText()) + "}") + ");");
- }
- n.setEndJavaLine(out.getJavaLine());
- }
-
- public void visit(Node.IncludeAction n) throws JasperException {
-
- String flush = n.getTextAttribute("flush");
- Node.JspAttribute page = n.getPage();
-
- boolean isFlush = false; // default to false;
- if ("true".equals(flush))
- isFlush = true;
-
- n.setBeginJavaLine(out.getJavaLine());
-
- String pageParam;
- if (page.isNamedAttribute()) {
- // If the page for jsp:include was specified via
- // jsp:attribute, first generate code to evaluate
- // that body.
- pageParam = generateNamedAttributeValue(page
- .getNamedAttributeNode());
- } else {
- pageParam = attributeValue(page, false, String.class);
- }
-
- // If any of the params have their values specified by
- // jsp:attribute, prepare those values first.
- Node jspBody = findJspBody(n);
- if (jspBody != null) {
- prepareParams(jspBody);
- } else {
- prepareParams(n);
- }
-
- out.printin(
- JSPRuntime.class.getName() + ".handle("
- + pageParam);
- printParams(n, pageParam, page.isLiteral());
- out.println(", " + isFlush + ");");
-
- n.setEndJavaLine(out.getJavaLine());
- }
-
- /**
- * Scans through all child nodes of the given parent for
- * subelements. For each element, if its value is specified via
- * a Named Attribute (), generate the code to evaluate
- * those bodies first.
- *
- * If parent is null, simply returns.
- */
- private void prepareParams(Node parent) throws JasperException {
- if (parent == null)
- return;
-
- Node.Nodes subelements = parent.getBody();
- if (subelements != null) {
- for (int i = 0; i < subelements.size(); i++) {
- 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++) {
- Node m = paramSubElements.getNode(j);
- if (m instanceof Node.NamedAttribute) {
- generateNamedAttributeValue((Node.NamedAttribute) m);
- }
- }
- }
- }
- }
- }
-
- /**
- * Finds the subelement of the given parent node. If not
- * found, null is returned.
- */
- private Node.JspBody findJspBody(Node parent) throws JasperException {
- Node.JspBody result = null;
-
- Node.Nodes subelements = parent.getBody();
- for (int i = 0; (subelements != null) && (i < subelements.size()); i++) {
- Node n = subelements.getNode(i);
- if (n instanceof Node.JspBody) {
- result = (Node.JspBody) n;
- break;
- }
- }
-
- return result;
- }
-
- public void visit(Node.ForwardAction n) throws JasperException {
- Node.JspAttribute page = n.getPage();
-
- n.setBeginJavaLine(out.getJavaLine());
-
- out.printil("if (true) {"); // So that javac won't complain about
- out.pushIndent(); // codes after "return"
-
- String pageParam;
- if (page.isNamedAttribute()) {
- // If the page for jsp:forward was specified via
- // jsp:attribute, first generate code to evaluate
- // that body.
- pageParam = generateNamedAttributeValue(page
- .getNamedAttributeNode());
- } else {
- pageParam = attributeValue(page, false, String.class);
- }
-
- // If any of the params have their values specified by
- // jsp:attribute, prepare those values first.
- Node jspBody = findJspBody(n);
- if (jspBody != null) {
- prepareParams(jspBody);
- } else {
- prepareParams(n);
- }
-
- out.printin("_jspx_page_context.forward(");
- out.print(pageParam);
- printParams(n, pageParam, page.isLiteral());
- out.println(");");
- if (isTagFile || isFragment) {
- out.printil("throw new SkipPageException();");
- } else {
- out.printil((methodNesting > 0) ? "return true;" : "return;");
- }
- out.popIndent();
- out.printil("}");
-
- n.setEndJavaLine(out.getJavaLine());
- // XXX Not sure if we can eliminate dead codes after this.
- }
-
- public void visit(Node.GetProperty n) throws JasperException {
- String name = n.getTextAttribute("name");
- String property = n.getTextAttribute("property");
-
- n.setBeginJavaLine(out.getJavaLine());
-
- if (beanInfo.checkVariable(name)) {
- // 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);
- String methodName = meth.getName();
- out
- .printil("out.write(org.apache.struts2.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.struts2.jasper.runtime.JspRuntimeLibrary.toString"
- + "(org.apache.struts2.jasper.runtime.JspRuntimeLibrary.handleGetProperty"
- + "(_jspx_page_context.getAttribute(\""
- + name
- + "\", PageContext.PAGE_SCOPE), \""
- + property
- + "\")));");
- }
-
- n.setEndJavaLine(out.getJavaLine());
- }
-
- public void visit(Node.SetProperty n) throws JasperException {
- String name = n.getTextAttribute("name");
- String property = n.getTextAttribute("property");
- String param = n.getTextAttribute("param");
- Node.JspAttribute value = n.getValue();
-
- n.setBeginJavaLine(out.getJavaLine());
-
- if ("*".equals(property)) {
- out
- .printil("org.apache.struts2.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.struts2.jasper.runtime.JspRuntimeLibrary.introspecthelper("
- + "_jspx_page_context.findAttribute(\""
- + name
- + "\"), \""
- + property
- + "\", request.getParameter(\""
- + param
- + "\"), "
- + "request, \""
- + param
- + "\", false);");
- } else if (value.isExpression()) {
- out
- .printil("org.apache.struts2.jasper.runtime.JspRuntimeLibrary.handleSetProperty("
- + "_jspx_page_context.findAttribute(\""
- + name
- + "\"), \"" + property + "\",");
- out.print(attributeValue(value, false, null));
- out.println(");");
- } else if (value.isELInterpreterInput()) {
- // We've got to resolve the very call to the interpreter
- // at runtime since we don't know what type to expect
- // in the general case; we thus can't hard-wire the call
- // into the generated code. (XXX We could, however,
- // optimize the case where the bean is exposed with
- // , much as the code here does for
- // getProperty.)
-
- // The following holds true for the arguments passed to
- // JspRuntimeLibrary.handleSetPropertyExpression():
- // - 'pageContext' is a VariableResolver.
- // - 'this' (either the generated Servlet or the generated tag
- // handler for Tag files) is a FunctionMapper.
- out
- .printil("org.apache.struts2.jasper.runtime.JspRuntimeLibrary.handleSetPropertyExpression("
- + "_jspx_page_context.findAttribute(\""
- + name
- + "\"), \""
- + property
- + "\", "
- + quote(value.getValue())
- + ", "
- + "_jspx_page_context, "
- + value.getEL().getMapName() + ");");
- } else if (value.isNamedAttribute()) {
- // 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.struts2.jasper.runtime.JspRuntimeLibrary.introspecthelper("
- + "_jspx_page_context.findAttribute(\""
- + name
- + "\"), \""
- + property
- + "\", "
- + valueVarName
- + ", null, null, false);");
- } else {
- out
- .printin("org.apache.struts2.jasper.runtime.JspRuntimeLibrary.introspecthelper("
- + "_jspx_page_context.findAttribute(\""
- + name
- + "\"), \"" + property + "\", ");
- out.print(attributeValue(value, false, null));
- out.println(", null, null, false);");
- }
-
- n.setEndJavaLine(out.getJavaLine());
- }
-
- public void visit(Node.UseBean n) throws JasperException {
-
- String name = n.getTextAttribute("id");
- String scope = n.getTextAttribute("scope");
- String klass = n.getTextAttribute("class");
- String type = n.getTextAttribute("type");
- Node.JspAttribute beanName = n.getBeanName();
-
- // If "class" is specified, try an instantiation at compile time
- boolean generateNew = false;
- String canonicalName = null; // Canonical name for klass
- if (klass != null) {
- try {
- Class bean = ctxt.getClassLoader().loadClass(klass);
- if (klass.indexOf('$') >= 0) {
- // Obtain the canonical type name
- canonicalName = JspUtil.getCanonicalName(bean);
- } else {
- canonicalName = klass;
- }
- int modifiers = bean.getModifiers();
- if (!Modifier.isPublic(modifiers)
- || Modifier.isInterface(modifiers)
- || Modifier.isAbstract(modifiers)) {
- throw new Exception("Invalid bean class modifier");
- }
- // Check that there is a 0 arg constructor
- bean.getConstructor(new Class[] {});
- // At compile time, we have determined that the bean class
- // exists, with a public zero constructor, new() can be
- // used for bean instantiation.
- generateNew = true;
- } catch (Exception e) {
- // 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()) {
- err.jspError(n, "jsp.error.invalid.bean", klass);
- }
- if (canonicalName == null) {
- // Doing our best here to get a canonical name
- // from the binary name, should work 99.99% of time.
- canonicalName = klass.replace('$', '.');
- }
- }
- if (type == null) {
- // if type is unspecified, use "class" as type of bean
- type = canonicalName;
- }
- }
-
- String scopename = "PageContext.PAGE_SCOPE"; // Default to page
- String lock = "_jspx_page_context";
-
- if ("request".equals(scope)) {
- scopename = "PageContext.REQUEST_SCOPE";
- lock = "request";
- } else if ("session".equals(scope)) {
- scopename = "PageContext.SESSION_SCOPE";
- lock = "session";
- } else if ("application".equals(scope)) {
- scopename = "PageContext.APPLICATION_SCOPE";
- lock = "application";
- }
-
- n.setBeginJavaLine(out.getJavaLine());
-
- // Declare bean
- out.printin(type);
- out.print(' ');
- out.print(name);
- out.println(" = null;");
-
- // Lock while getting or creating bean
- out.printin("synchronized (");
- out.print(lock);
- out.println(") {");
- out.pushIndent();
-
- // Locate bean from context
- out.printin(name);
- out.print(" = (");
- out.print(type);
- out.print(") _jspx_page_context.getAttribute(");
- out.print(quote(name));
- out.print(", ");
- out.print(scopename);
- out.println(");");
-
- // Create bean
- /*
- * Check if bean is alredy there
- */
- out.printin("if (");
- out.print(name);
- out.println(" == null){");
- out.pushIndent();
- if (klass == null && beanName == null) {
- /*
- * 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.print(name);
- out.println(" not found within scope\");");
- } else {
- /*
- * Instantiate the bean if it is not in the specified scope.
- */
- if (!generateNew) {
- String binaryName;
- if (beanName != null) {
- if (beanName.isNamedAttribute()) {
- // If the value for beanName was specified via
- // jsp:attribute, first generate code to evaluate
- // that body.
- binaryName = generateNamedAttributeValue(beanName
- .getNamedAttributeNode());
- } else {
- binaryName = attributeValue(beanName, false,
- String.class);
- }
- } else {
- // Implies klass is not null
- binaryName = quote(klass);
- }
- out.printil("try {");
- out.pushIndent();
- out.printin(name);
- out.print(" = (");
- out.print(type);
- out.print(") java.beans.Beans.instantiate(");
- out.print("this.getClass().getClassLoader(), ");
- out.print(binaryName);
- out.println(");");
- out.popIndent();
- /*
- * Note: Beans.instantiate throws ClassNotFoundException if
- * the bean class is abstract.
- */
- out.printil("} catch (ClassNotFoundException exc) {");
- out.pushIndent();
- out
- .printil("throw new InstantiationException(exc.getMessage());");
- out.popIndent();
- out.printil("} catch (Exception exc) {");
- out.pushIndent();
- out.printin("throw new ServletException(");
- out.print("\"Cannot create bean of class \" + ");
- out.print(binaryName);
- out.println(", exc);");
- out.popIndent();
- out.printil("}"); // close of try
- } else {
- // Implies klass is not null
- // Generate codes to instantiate the bean class
- out.printin(name);
- out.print(" = new ");
- out.print(canonicalName);
- out.println("();");
- }
- /*
- * Set attribute for bean in the specified scope
- */
- out.printin("_jspx_page_context.setAttribute(");
- out.print(quote(name));
- out.print(", ");
- out.print(name);
- out.print(", ");
- out.print(scopename);
- out.println(");");
-
- // Only visit the body when bean is instantiated
- visitBody(n);
- }
- out.popIndent();
- out.printil("}");
-
- // End of lock block
- out.popIndent();
- out.printil("}");
-
- n.setEndJavaLine(out.getJavaLine());
- }
-
- /**
- * @return a string for the form 'attr = "value"'
- */
- private String makeAttr(String attr, String value) {
- if (value == null)
- return "";
-
- return " " + attr + "=\"" + value + '\"';
- }
-
- public void visit(Node.PlugIn n) throws JasperException {
-
- /**
- * A visitor to handle in a plugin
- */
- class ParamVisitor extends Node.Visitor {
-
- private boolean ie;
-
- ParamVisitor(boolean ie) {
- this.ie = ie;
- }
-
- public void visit(Node.ParamAction n) throws JasperException {
-
- String name = n.getTextAttribute("name");
- if (name.equalsIgnoreCase("object"))
- name = "java_object";
- else if (name.equalsIgnoreCase("type"))
- name = "java_type";
-
- n.setBeginJavaLine(out.getJavaLine());
- // XXX - Fixed a bug here - value used to be output
- // inline, which is only okay if value is not an EL
- // expression. Also, key/value pairs for the
- // embed tag were not being generated correctly.
- // Double check that this is now the correct behavior.
- if (ie) {
- // We want something of the form
- // out.println( "" );
- out.printil("out.write( \"\" );");
- out.printil("out.write(\"\\n\");");
- } else {
- // We want something of the form
- // out.print( " blah=\"" + ... + "\"" );
- out.printil("out.write( \" "
- + escape(name)
- + "=\\\"\" + "
- + attributeValue(n.getValue(), false,
- String.class) + " + \"\\\"\" );");
- }
-
- n.setEndJavaLine(out.getJavaLine());
- }
- }
-
- String type = n.getTextAttribute("type");
- String code = n.getTextAttribute("code");
- String name = n.getTextAttribute("name");
- Node.JspAttribute height = n.getHeight();
- Node.JspAttribute width = n.getWidth();
- String hspace = n.getTextAttribute("hspace");
- String vspace = n.getTextAttribute("vspace");
- String align = n.getTextAttribute("align");
- String iepluginurl = n.getTextAttribute("iepluginurl");
- String nspluginurl = n.getTextAttribute("nspluginurl");
- String codebase = n.getTextAttribute("codebase");
- String archive = n.getTextAttribute("archive");
- String jreversion = n.getTextAttribute("jreversion");
-
- String widthStr = null;
- if (width != null) {
- if (width.isNamedAttribute()) {
- widthStr = generateNamedAttributeValue(width
- .getNamedAttributeNode());
- } else {
- widthStr = attributeValue(width, false, String.class);
- }
- }
-
- String heightStr = null;
- if (height != null) {
- if (height.isNamedAttribute()) {
- heightStr = generateNamedAttributeValue(height
- .getNamedAttributeNode());
- } else {
- heightStr = attributeValue(height, false, String.class);
- }
- }
-
- if (iepluginurl == null)
- iepluginurl = Constants.IE_PLUGIN_URL;
- if (nspluginurl == null)
- nspluginurl = Constants.NS_PLUGIN_URL;
-
- n.setBeginJavaLine(out.getJavaLine());
-
- // If any of the params have their values specified by
- // jsp:attribute, prepare those values first.
- // Look for a params node and prepare its param subelements:
- Node.JspBody jspBody = findJspBody(n);
- if (jspBody != null) {
- Node.Nodes subelements = jspBody.getBody();
- if (subelements != null) {
- for (int i = 0; i < subelements.size(); i++) {
- Node m = subelements.getNode(i);
- if (m instanceof Node.ParamsAction) {
- prepareParams(m);
- break;
- }
- }
- }
- }
-
- // XXX - Fixed a bug here - width and height can be set
- // dynamically. Double-check if this generation is correct.
-
- // IE style plugin
- //