add test to read jsp from jar. reformat code. replace commons logging with xwork logging in jasper.
git-svn-id: https://svn.apache.org/repos/asf/struts/sandbox/trunk@804373 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/struts2-jsp-plugin/pom.xml b/struts2-jsp-plugin/pom.xml
index 0562e3b..3fb2202 100644
--- a/struts2-jsp-plugin/pom.xml
+++ b/struts2-jsp-plugin/pom.xml
@@ -91,19 +91,22 @@
<version>1.1.2</version>
<scope>test</scope>
</dependency>
-
+
</dependencies>
- <!--<build>
+ <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.2</version>
<configuration>
+ <additionalClasspathElements>
+ <element>${project.build.testOutputDirectory}/jsps.jar</element>
+ </additionalClasspathElements>
<forkMode>never</forkMode>
</configuration>
</plugin>
</plugins>
- </build>-->
-
+ </build>
</project>
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/EmbeddedJSPResult.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/EmbeddedJSPResult.java
index 33ee880..114a2c3 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/EmbeddedJSPResult.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/EmbeddedJSPResult.java
@@ -1,6 +1,7 @@
package org.apache.struts2;
import com.opensymphony.xwork2.ActionInvocation;
+import org.apache.commons.lang.xwork.StringUtils;
import org.apache.struts2.dispatcher.StrutsResultSupport;
/**
@@ -8,6 +9,6 @@
*/
public class EmbeddedJSPResult extends StrutsResultSupport {
protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
- JSPRuntime.handle(finalLocation);
+ JSPRuntime.handle(StringUtils.removeStart(finalLocation, "/"));
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/JSPLoader.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/JSPLoader.java
index 401e773..91ff0f6 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/JSPLoader.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/JSPLoader.java
@@ -20,16 +20,15 @@
*/
package org.apache.struts2;
+import com.opensymphony.xwork2.util.URLUtil;
+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.finder.ClassLoaderInterface;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
-import com.opensymphony.xwork2.util.URLUtil;
-import com.opensymphony.xwork2.ActionContext;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.xwork.StringUtils;
import org.apache.commons.lang.xwork.ObjectUtils;
+import org.apache.commons.lang.xwork.StringUtils;
import org.apache.struts2.compiler.MemoryClassLoader;
import org.apache.struts2.compiler.MemoryJavaFileObject;
import org.apache.struts2.jasper.JasperException;
@@ -37,9 +36,8 @@
import org.apache.struts2.jasper.compiler.JspUtil;
import javax.servlet.Servlet;
-import javax.servlet.ServletException;
import javax.servlet.ServletContext;
-import javax.servlet.jsp.JspPage;
+import javax.servlet.ServletException;
import javax.tools.*;
import java.io.File;
import java.io.IOException;
@@ -219,7 +217,7 @@
private ClassLoaderInterface getClassLoaderInterface() {
ClassLoaderInterface classLoaderInterface = null;
- ServletContext ctx = ServletActionContext.getServletContext();
+ ServletContext ctx = ServletActionContext.getServletContext();
if (ctx != null)
classLoaderInterface = (ClassLoaderInterface) ctx.getAttribute(ClassLoaderInterface.CLASS_LOADER_INTERFACE);
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/JSPServletConfig.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/JSPServletConfig.java
index 9643911..69057df 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/JSPServletConfig.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/JSPServletConfig.java
@@ -38,7 +38,7 @@
}
public String getInitParameter(String name) {
- return null;
+ return null;
}
public Enumeration getInitParameterNames() {
@@ -50,6 +50,6 @@
}
public String getServletName() {
- return null;
+ return null;
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/Constants.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/Constants.java
index 7c5565b..ec8d5d1 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/Constants.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/Constants.java
@@ -28,12 +28,12 @@
*/
public class Constants {
/**
- * The base class of the generated servlets.
+ * The base class of the generated servlets.
*/
public static final String JSP_SERVLET_BASE = "org.apache.struts2.jasper.runtime.HttpJspBase";
/**
- * _jspService is the name of the method that is called by
+ * _jspService is the name of the method that is called by
* HttpJspBase.service(). This is where most of the code generated
* from JSPs go.
*/
@@ -46,19 +46,19 @@
/**
* These classes/packages are automatically imported by the
- * generated code.
+ * generated code.
*/
- public static final String[] STANDARD_IMPORTS = {
- "javax.servlet.*",
- "javax.servlet.http.*",
- "javax.servlet.jsp.*"
+ public static final String[] STANDARD_IMPORTS = {
+ "javax.servlet.*",
+ "javax.servlet.http.*",
+ "javax.servlet.jsp.*"
};
/**
* FIXME
- * ServletContext attribute for classpath. This is tomcat specific.
- * Other servlet engines may choose to support this attribute if they
- * want to have this JSP engine running on them.
+ * ServletContext attribute for classpath. This is tomcat specific.
+ * Other servlet engines may choose to support this attribute if they
+ * want to have this JSP engine running on them.
*/
public static final String SERVLET_CLASSPATH = "org.apache.catalina.jsp_classpath";
@@ -74,9 +74,9 @@
/**
* FIXME
- * ServletContext attribute for class loader. This is tomcat specific.
- * Other servlet engines can choose to have this attribute if they
- * want to have this JSP engine running on them.
+ * ServletContext attribute for class loader. This is tomcat specific.
+ * Other servlet engines can choose to have this attribute if they
+ * want to have this JSP engine running on them.
*/
//public static final String SERVLET_CLASS_LOADER = "org.apache.tomcat.classloader";
public static final String SERVLET_CLASS_LOADER = "org.apache.catalina.classloader";
@@ -85,7 +85,7 @@
* Default size of the JSP buffer.
*/
public static final int K = 1024;
- public static final int DEFAULT_BUFFER_SIZE = 8*K;
+ public static final int DEFAULT_BUFFER_SIZE = 8 * K;
/**
* Default size for the tag buffers.
@@ -99,7 +99,7 @@
/**
* The query parameter that causes the JSP engine to just
- * pregenerated the servlet but not invoke it.
+ * pregenerated the servlet but not invoke it.
*/
public static final String PRECOMPILE = "jsp_precompile";
@@ -115,7 +115,7 @@
/**
* Servlet context and request attributes that the JSP engine
- * uses.
+ * uses.
*/
public static final String INC_REQUEST_URI = "javax.servlet.include.request_uri";
public static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path";
@@ -126,90 +126,92 @@
public static final String ALT_DD_ATTR = "org.apache.catalina.deploy.alt_dd";
/**
- * Public Id and the Resource path (of the cached copy)
- * of the DTDs for tag library descriptors.
+ * Public Id and the Resource path (of the cached copy)
+ * of the DTDs for tag library descriptors.
*/
- public static final String TAGLIB_DTD_PUBLIC_ID_11 =
- "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN";
- public static final String TAGLIB_DTD_RESOURCE_PATH_11 =
- "/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd";
- public static final String TAGLIB_DTD_PUBLIC_ID_12 =
- "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN";
- public static final String TAGLIB_DTD_RESOURCE_PATH_12 =
- "/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd";
+ public static final String TAGLIB_DTD_PUBLIC_ID_11 =
+ "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN";
+ public static final String TAGLIB_DTD_RESOURCE_PATH_11 =
+ "/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd";
+ public static final String TAGLIB_DTD_PUBLIC_ID_12 =
+ "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN";
+ public static final String TAGLIB_DTD_RESOURCE_PATH_12 =
+ "/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd";
/**
- * Public Id and the Resource path (of the cached copy)
+ * Public Id and the Resource path (of the cached copy)
* of the DTDs for web application deployment descriptors
*/
- public static final String WEBAPP_DTD_PUBLIC_ID_22 =
- "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN";
- public static final String WEBAPP_DTD_RESOURCE_PATH_22 =
- "/javax/servlet/resources/web-app_2_2.dtd";
- public static final String WEBAPP_DTD_PUBLIC_ID_23 =
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
- public static final String WEBAPP_DTD_RESOURCE_PATH_23 =
- "/javax/servlet/resources/web-app_2_3.dtd";
+ public static final String WEBAPP_DTD_PUBLIC_ID_22 =
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN";
+ public static final String WEBAPP_DTD_RESOURCE_PATH_22 =
+ "/javax/servlet/resources/web-app_2_2.dtd";
+ public static final String WEBAPP_DTD_PUBLIC_ID_23 =
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
+ public static final String WEBAPP_DTD_RESOURCE_PATH_23 =
+ "/javax/servlet/resources/web-app_2_3.dtd";
/**
* List of the Public IDs that we cache, and their
- * associated location. This is used by
+ * associated location. This is used by
* an EntityResolver to return the location of the
* cached copy of a DTD.
*/
public static final String[] CACHED_DTD_PUBLIC_IDS = {
- TAGLIB_DTD_PUBLIC_ID_11,
- TAGLIB_DTD_PUBLIC_ID_12,
- WEBAPP_DTD_PUBLIC_ID_22,
- WEBAPP_DTD_PUBLIC_ID_23,
+ TAGLIB_DTD_PUBLIC_ID_11,
+ TAGLIB_DTD_PUBLIC_ID_12,
+ WEBAPP_DTD_PUBLIC_ID_22,
+ WEBAPP_DTD_PUBLIC_ID_23,
};
public static final String[] CACHED_DTD_RESOURCE_PATHS = {
- TAGLIB_DTD_RESOURCE_PATH_11,
- TAGLIB_DTD_RESOURCE_PATH_12,
- WEBAPP_DTD_RESOURCE_PATH_22,
- WEBAPP_DTD_RESOURCE_PATH_23,
+ TAGLIB_DTD_RESOURCE_PATH_11,
+ TAGLIB_DTD_RESOURCE_PATH_12,
+ WEBAPP_DTD_RESOURCE_PATH_22,
+ WEBAPP_DTD_RESOURCE_PATH_23,
};
-
+
/**
* Default URLs to download the pluging for Netscape and IE.
*/
- public static final String NS_PLUGIN_URL =
- "http://java.sun.com/products/plugin/";
+ public static final String NS_PLUGIN_URL =
+ "http://java.sun.com/products/plugin/";
- public static final String IE_PLUGIN_URL =
- "http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0";
+ public static final String IE_PLUGIN_URL =
+ "http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0";
/**
* Prefix to use for generated temporary variable names
*/
public static final String TEMP_VARIABLE_NAME_PREFIX =
- "_jspx_temp";
+ "_jspx_temp";
/**
* Previous replacement char for "\$".
+ *
* @deprecated
*/
- public static final char ESC='\u001b';
-
+ public static final char ESC = '\u001b';
+
/**
* Previous replacement char for "\$".
+ *
* @deprecated
*/
- public static final String ESCStr="'\\u001b'";
-
+ public static final String ESCStr = "'\\u001b'";
+
/**
* Replacement char for "\$". This is the first unicode character in the
* private use area.
* XXX This is a hack to avoid changing EL interpreter to recognize "\$"
*/
public static final char HACK_CHAR = '\ue000';
-
+
/**
* Replacement string for "\$". This is the first unicode character in the
* private use area.
* XXX This is a hack to avoid changing EL interpreter to recognize "\$"
*/
public static final String HACK_STR = "'\\ue000'";
-
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/CustomCompiler.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/CustomCompiler.java
index cf6b1a7..d993f66 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/CustomCompiler.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/CustomCompiler.java
@@ -22,7 +22,7 @@
import java.io.FileNotFoundException;
-public class CustomCompiler extends org.apache.struts2.jasper.compiler.Compiler{
+public class CustomCompiler extends org.apache.struts2.jasper.compiler.Compiler {
public boolean isOutDated() {
return true;
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/EmbeddedServletOptions.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/EmbeddedServletOptions.java
index 87c06f8..c6fb5ec 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/EmbeddedServletOptions.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/EmbeddedServletOptions.java
@@ -17,8 +17,8 @@
package org.apache.struts2.jasper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.compiler.JspConfig;
import org.apache.struts2.jasper.compiler.Localizer;
import org.apache.struts2.jasper.compiler.TagPluginManager;
@@ -33,254 +33,254 @@
import java.util.Properties;
/**
- * A class to hold all init parameters specific to the JSP engine.
+ * A class to hold all init parameters specific to the JSP engine.
*
* @author Anil K. Vijendran
* @author Hans Bergsten
* @author Pierre Delisle
*/
public final class EmbeddedServletOptions implements Options {
-
+
// Logger
- private Log log = LogFactory.getLog(EmbeddedServletOptions.class);
-
+ private Logger log = LoggerFactory.getLogger(EmbeddedServletOptions.class);
+
private Properties settings = new Properties();
-
+
/**
* Is Jasper being used in development mode?
*/
private boolean development = true;
-
+
/**
* Should Ant fork its java compiles of JSP pages.
*/
public boolean fork = true;
-
+
/**
* Do you want to keep the generated Java files around?
*/
private boolean keepGenerated = true;
-
+
/**
* Should white spaces between directives or actions be trimmed?
*/
private boolean trimSpaces = false;
-
+
/**
* Determines whether tag handler pooling is enabled.
*/
private boolean isPoolingEnabled = true;
-
+
/**
* Do you want support for "mapped" files? This will generate
* servlet that has a print statement per line of the JSP file.
* This seems like a really nice feature to have for debugging.
*/
private boolean mappedFile = true;
-
+
/**
* Do you want stack traces and such displayed in the client's
* browser? If this is false, such messages go to the standard
- * error or a log file if the standard error is redirected.
+ * error or a log file if the standard error is redirected.
*/
private boolean sendErrorToClient = false;
-
+
/**
* Do we want to include debugging information in the class file?
*/
private boolean classDebugInfo = true;
-
+
/**
* Background compile thread check interval in seconds.
*/
private int checkInterval = 0;
-
+
/**
* Is the generation of SMAP info for JSR45 debuggin suppressed?
*/
private boolean isSmapSuppressed = false;
-
+
/**
* Should SMAP info for JSR45 debugging be dumped to a file?
*/
private boolean isSmapDumped = false;
-
+
/**
* Are Text strings to be generated as char arrays?
*/
private boolean genStringAsCharArray = false;
-
+
private boolean errorOnUseBeanInvalidClassAttribute = true;
-
+
/**
* I want to see my generated servlets. Which directory are they
* in?
*/
private File scratchDir;
-
+
/**
* Need to have this as is for versions 4 and 5 of IE. Can be set from
* the initParams so if it changes in the future all that is needed is
* to have a jsp initParam of type ieClassId="<value>"
*/
private String ieClassId = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
-
+
/**
* What classpath should I use while compiling generated servlets?
*/
private String classpath = null;
-
+
/**
* Compiler to use.
*/
private String compiler = null;
-
+
/**
* Compiler target VM.
*/
private String compilerTargetVM = "1.5";
-
+
/**
* The compiler source VM.
*/
private String compilerSourceVM = "1.5";
-
+
/**
* Cache for the TLD locations
*/
private TldLocationsCache tldLocationsCache = null;
-
+
/**
* Jsp config information
*/
private JspConfig jspConfig = null;
-
+
/**
* TagPluginManager
*/
private TagPluginManager tagPluginManager = null;
-
+
/**
* Java platform encoding to generate the JSP
* page servlet.
*/
private String javaEncoding = "UTF8";
-
+
/**
* Modification test interval.
*/
private int modificationTestInterval = 4;
-
+
/**
* Is generation of X-Powered-By response header enabled/disabled?
*/
private boolean xpoweredBy;
-
- public String getProperty(String name ) {
- return settings.getProperty( name );
+
+ public String getProperty(String name) {
+ return settings.getProperty(name);
}
-
- public void setProperty(String name, String value ) {
- if (name != null && value != null){
- settings.setProperty( name, value );
+
+ public void setProperty(String name, String value) {
+ if (name != null && value != null) {
+ settings.setProperty(name, value);
}
}
-
+
/**
* Are we keeping generated code around?
*/
public boolean getKeepGenerated() {
return keepGenerated;
}
-
+
/**
* Should white spaces between directives or actions be trimmed?
*/
public boolean getTrimSpaces() {
return trimSpaces;
}
-
+
public boolean isPoolingEnabled() {
return isPoolingEnabled;
}
-
+
/**
* Are we supporting HTML mapped servlets?
*/
public boolean getMappedFile() {
return mappedFile;
}
-
+
/**
* Should errors be sent to client or thrown into stderr?
*/
public boolean getSendErrorToClient() {
return sendErrorToClient;
}
-
+
/**
* Should class files be compiled with debug information?
*/
public boolean getClassDebugInfo() {
return classDebugInfo;
}
-
+
/**
* Background JSP compile thread check intervall
*/
public int getCheckInterval() {
return checkInterval;
}
-
+
/**
* Modification test interval.
*/
public int getModificationTestInterval() {
return modificationTestInterval;
}
-
+
/**
* Is Jasper being used in development mode?
*/
public boolean getDevelopment() {
return development;
}
-
+
/**
* Is the generation of SMAP info for JSR45 debuggin suppressed?
*/
public boolean isSmapSuppressed() {
return isSmapSuppressed;
}
-
+
/**
* Should SMAP info for JSR45 debugging be dumped to a file?
*/
public boolean isSmapDumped() {
return isSmapDumped;
}
-
+
/**
* Are Text strings to be generated as char arrays?
*/
public boolean genStringAsCharArray() {
return this.genStringAsCharArray;
}
-
+
/**
- * Class ID for use in the plugin tag when the browser is IE.
+ * Class ID for use in the plugin tag when the browser is IE.
*/
public String getIeClassId() {
return ieClassId;
}
-
+
/**
* What is my scratch dir?
*/
public File getScratchDir() {
return scratchDir;
}
-
+
/**
* What classpath should I use while compiling the servlets
* generated from JSP files?
@@ -288,82 +288,82 @@
public String getClassPath() {
return classpath;
}
-
+
/**
* Is generation of X-Powered-By response header enabled/disabled?
*/
public boolean isXpoweredBy() {
return xpoweredBy;
}
-
+
/**
* Compiler to use.
*/
public String getCompiler() {
return compiler;
}
-
+
/**
* @see Options#getCompilerTargetVM
*/
public String getCompilerTargetVM() {
return compilerTargetVM;
}
-
+
/**
* @see Options#getCompilerSourceVM
*/
public String getCompilerSourceVM() {
return compilerSourceVM;
}
-
+
public boolean getErrorOnUseBeanInvalidClassAttribute() {
return errorOnUseBeanInvalidClassAttribute;
}
-
+
public void setErrorOnUseBeanInvalidClassAttribute(boolean b) {
errorOnUseBeanInvalidClassAttribute = b;
}
-
+
public TldLocationsCache getTldLocationsCache() {
return tldLocationsCache;
}
-
- public void setTldLocationsCache( TldLocationsCache tldC ) {
+
+ public void setTldLocationsCache(TldLocationsCache tldC) {
tldLocationsCache = tldC;
}
-
+
public String getJavaEncoding() {
return javaEncoding;
}
-
+
public boolean getFork() {
return fork;
}
-
+
public JspConfig getJspConfig() {
return jspConfig;
}
-
+
public TagPluginManager getTagPluginManager() {
return tagPluginManager;
}
-
+
public boolean isCaching() {
return false;
}
-
+
public Map getCache() {
return null;
}
/**
* Create an EmbeddedServletOptions object using data available from
- * ServletConfig and ServletContext.
+ * ServletConfig and ServletContext.
*/
public EmbeddedServletOptions(ServletConfig config,
- ServletContext context) {
-
+ ServletContext context) {
+
// JVM version numbers
try {
if (Float.parseFloat(System.getProperty("java.specification.version")) > 1.4) {
@@ -374,18 +374,18 @@
} catch (NumberFormatException e) {
// Ignore
}
-
- Enumeration enumeration=config.getInitParameterNames();
- while( enumeration.hasMoreElements() ) {
- String k=(String)enumeration.nextElement();
- String v=config.getInitParameter( k );
- setProperty( k, v);
+
+ Enumeration enumeration = config.getInitParameterNames();
+ while (enumeration.hasMoreElements()) {
+ String k = (String) enumeration.nextElement();
+ String v = config.getInitParameter(k);
+ setProperty(k, v);
}
-
+
// quick hack
- String validating=config.getInitParameter( "validating");
- if( "false".equals( validating )) ParserUtils.validating=false;
-
+ String validating = config.getInitParameter("validating");
+ if ("false".equals(validating)) ParserUtils.validating = false;
+
String keepgen = config.getInitParameter("keepgenerated");
if (keepgen != null) {
if (keepgen.equalsIgnoreCase("true")) {
@@ -398,9 +398,9 @@
}
}
}
-
-
- String trimsp = config.getInitParameter("trimSpaces");
+
+
+ String trimsp = config.getInitParameter("trimSpaces");
if (trimsp != null) {
if (trimsp.equalsIgnoreCase("true")) {
trimSpaces = true;
@@ -412,10 +412,10 @@
}
}
}
-
+
this.isPoolingEnabled = true;
String poolingEnabledParam
- = config.getInitParameter("enablePooling");
+ = config.getInitParameter("enablePooling");
if (poolingEnabledParam != null
&& !poolingEnabledParam.equalsIgnoreCase("true")) {
if (poolingEnabledParam.equalsIgnoreCase("false")) {
@@ -423,11 +423,11 @@
} else {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage("jsp.warning.enablePooling"));
- }
+ }
}
}
-
- String mapFile = config.getInitParameter("mappedfile");
+
+ String mapFile = config.getInitParameter("mappedfile");
if (mapFile != null) {
if (mapFile.equalsIgnoreCase("true")) {
this.mappedFile = true;
@@ -439,7 +439,7 @@
}
}
}
-
+
String senderr = config.getInitParameter("sendErrToClient");
if (senderr != null) {
if (senderr.equalsIgnoreCase("true")) {
@@ -452,42 +452,42 @@
}
}
}
-
+
String debugInfo = config.getInitParameter("classdebuginfo");
if (debugInfo != null) {
if (debugInfo.equalsIgnoreCase("true")) {
- this.classDebugInfo = true;
+ this.classDebugInfo = true;
} else if (debugInfo.equalsIgnoreCase("false")) {
- this.classDebugInfo = false;
+ this.classDebugInfo = false;
} else {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage("jsp.warning.classDebugInfo"));
}
}
}
-
+
String checkInterval = config.getInitParameter("checkInterval");
if (checkInterval != null) {
try {
this.checkInterval = Integer.parseInt(checkInterval);
- } catch(NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage("jsp.warning.checkInterval"));
}
}
}
-
+
String modificationTestInterval = config.getInitParameter("modificationTestInterval");
if (modificationTestInterval != null) {
try {
this.modificationTestInterval = Integer.parseInt(modificationTestInterval);
- } catch(NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage("jsp.warning.modificationTestInterval"));
}
}
}
-
+
String development = config.getInitParameter("development");
if (development != null) {
if (development.equalsIgnoreCase("true")) {
@@ -500,7 +500,7 @@
}
}
}
-
+
String suppressSmap = config.getInitParameter("suppressSmap");
if (suppressSmap != null) {
if (suppressSmap.equalsIgnoreCase("true")) {
@@ -513,7 +513,7 @@
}
}
}
-
+
String dumpSmap = config.getInitParameter("dumpSmap");
if (dumpSmap != null) {
if (dumpSmap.equalsIgnoreCase("true")) {
@@ -526,7 +526,7 @@
}
}
}
-
+
String genCharArray = config.getInitParameter("genStrAsCharArray");
if (genCharArray != null) {
if (genCharArray.equalsIgnoreCase("true")) {
@@ -539,9 +539,9 @@
}
}
}
-
+
String errBeanClass =
- config.getInitParameter("errorOnUseBeanInvalidClassAttribute");
+ config.getInitParameter("errorOnUseBeanInvalidClassAttribute");
if (errBeanClass != null) {
if (errBeanClass.equalsIgnoreCase("true")) {
errorOnUseBeanInvalidClassAttribute = true;
@@ -553,19 +553,19 @@
}
}
}
-
+
String ieClassId = config.getInitParameter("ieClassId");
if (ieClassId != null)
this.ieClassId = ieClassId;
-
+
String classpath = config.getInitParameter("classpath");
if (classpath != null)
this.classpath = classpath;
-
+
/*
- * scratchdir
- */
- String dir = config.getInitParameter("scratchdir");
+ * scratchdir
+ */
+ String dir = config.getInitParameter("scratchdir");
if (dir != null) {
scratchDir = new File(dir);
} else {
@@ -578,34 +578,34 @@
if (dir != null)
scratchDir = new File(dir);
}
- }
+ }
if (this.scratchDir == null) {
log.fatal(Localizer.getMessage("jsp.error.no.scratch.dir"));
return;
}
-
+
if (!(scratchDir.exists() && scratchDir.canRead() &&
scratchDir.canWrite() && scratchDir.isDirectory()))
log.fatal(Localizer.getMessage("jsp.error.bad.scratch.dir",
scratchDir.getAbsolutePath()));
-
+
this.compiler = config.getInitParameter("compiler");
-
+
String compilerTargetVM = config.getInitParameter("compilerTargetVM");
- if(compilerTargetVM != null) {
+ if (compilerTargetVM != null) {
this.compilerTargetVM = compilerTargetVM;
}
-
+
String compilerSourceVM = config.getInitParameter("compilerSourceVM");
- if(compilerSourceVM != null) {
+ if (compilerSourceVM != null) {
this.compilerSourceVM = compilerSourceVM;
}
-
+
String javaEncoding = config.getInitParameter("javaEncoding");
if (javaEncoding != null) {
this.javaEncoding = javaEncoding;
}
-
+
String fork = config.getInitParameter("fork");
if (fork != null) {
if (fork.equalsIgnoreCase("true")) {
@@ -618,8 +618,8 @@
}
}
}
-
- String xpoweredBy = config.getInitParameter("xpoweredBy");
+
+ String xpoweredBy = config.getInitParameter("xpoweredBy");
if (xpoweredBy != null) {
if (xpoweredBy.equalsIgnoreCase("true")) {
this.xpoweredBy = true;
@@ -631,17 +631,17 @@
}
}
}
-
+
// Setup the global Tag Libraries location cache for this
// web-application.
tldLocationsCache = new TldLocationsCache(context);
-
+
// Setup the jsp config info for this web app.
jspConfig = new JspConfig(context);
-
+
// Create a Tag plugin instance
tagPluginManager = new TagPluginManager(context);
}
-
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/JasperException.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/JasperException.java
index f7c0ae1..4eb16b9 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/JasperException.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/JasperException.java
@@ -19,28 +19,28 @@
/**
* Base class for all exceptions generated by the JSP engine. Makes it
- * convienient to catch just this at the top-level.
+ * convienient to catch just this at the top-level.
*
* @author Anil K. Vijendran
*/
public class JasperException extends javax.servlet.ServletException {
-
+
public JasperException(String reason) {
- super(reason);
+ super(reason);
}
/**
* Creates a JasperException with the embedded exception and the reason for
* throwing a JasperException
*/
- public JasperException (String reason, Throwable exception) {
- super(reason, exception);
+ public JasperException(String reason, Throwable exception) {
+ super(reason, exception);
}
/**
* Creates a JasperException with the embedded exception
*/
- public JasperException (Throwable exception) {
- super(exception);
+ public JasperException(Throwable exception) {
+ super(exception);
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/JspC.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/JspC.java
index 3f4862e..66c99a6 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/JspC.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/JspC.java
@@ -18,7 +18,8 @@
package org.apache.struts2.jasper;
import com.opensymphony.xwork2.util.finder.ClassLoaderInterface;
-import org.apache.commons.logging.Log;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.jasper.compiler.Compiler;
import org.apache.struts2.jasper.compiler.*;
@@ -33,10 +34,10 @@
* Shell for the jspc compiler. Handles all options associated with the
* command line and creates compilation contexts which it then compiles
* according to the specified options.
- *
+ * <p/>
* This version can process files from a _single_ webapp at once, i.e.
* a single docbase can be specified.
- *
+ * <p/>
* It can be used as an Ant task using:
* <pre>
* <taskdef classname="org.apache.struts.jasperJspC" name="jasper2" >
@@ -51,7 +52,7 @@
* <path refid="myjars"/>
* </classpath>
* </taskdef>
- *
+ * <p/>
* <jasper2 verbose="0"
* package="my.package"
* uriroot="${webapps.dir}/${webapp.name}"
@@ -65,12 +66,16 @@
* @author Yoav Shapira
*/
public class JspC implements Options {
- /** The default Microsoft Internet Explorer class ID. */
+ /**
+ * The default Microsoft Internet Explorer class ID.
+ */
public static final String DEFAULT_IE_CLASS_ID =
"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
- /** Logger (set by constructor.) */
- private Log log;
+ /**
+ * Logger (set by constructor.)
+ */
+ private Logger log;
private static final String SWITCH_VERBOSE = "-v";
private static final String SWITCH_HELP = "-help";
@@ -99,7 +104,7 @@
private static final String SWITCH_SMAP = "-smap";
private static final String SWITCH_DUMP_SMAP = "-dumpsmap";
- private static final String SHOW_SUCCESS ="-s";
+ private static final String SHOW_SUCCESS = "-s";
private static final String LIST_ERRORS = "-l";
private static final int NO_WEBXML = 0;
private static final int INC_WEBXML = 10;
@@ -108,11 +113,11 @@
private static final int NO_DIE_LEVEL = 0;
private static final String[] insertBefore =
- { "</web-app>", "<servlet-mapping>", "<session-config>",
- "<mime-mapping>", "<welcome-file-list>", "<error-page>", "<taglib>",
- "<resource-env-ref>", "<resource-ref>", "<security-constraint>",
- "<login-config>", "<security-role>", "<env-entry>", "<ejb-ref>",
- "<ejb-local-ref>" };
+ {"</web-app>", "<servlet-mapping>", "<session-config>",
+ "<mime-mapping>", "<welcome-file-list>", "<error-page>", "<taglib>",
+ "<resource-env-ref>", "<resource-ref>", "<security-constraint>",
+ "<login-config>", "<security-role>", "<env-entry>", "<ejb-ref>",
+ "<ejb-local-ref>"};
private static int die;
private String classPath = null;
@@ -231,9 +236,11 @@
}
}
- /** Constructor. */
+ /**
+ * Constructor.
+ */
public JspC() {
- log = LogFactory.getLog(getClass());
+ log = LoggerFactory.getLogger(getClass());
}
public String getSourceCode() {
@@ -258,18 +265,18 @@
listErrors = true;
} else if (tok.equals(SWITCH_OUTPUT_DIR)) {
tok = nextArg();
- setOutputDir( tok );
+ setOutputDir(tok);
} else if (tok.equals(SWITCH_PACKAGE_NAME)) {
targetPackage = nextArg();
} else if (tok.equals(SWITCH_COMPILE)) {
- compile=true;
+ 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 ) ) {
+ uriBase = nextArg();
+ } else if (tok.equals(SHOW_SUCCESS)) {
showSuccess = true;
- } else if ( tok.equals( LIST_ERRORS ) ) {
+ } else if (tok.equals(LIST_ERRORS)) {
listErrors = true;
} else if (tok.equals(SWITCH_WEBAPP_INC)) {
webxmlFile = nextArg();
@@ -293,13 +300,13 @@
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()));
+ tok.substring(SWITCH_DIE.length()));
} catch (NumberFormatException nfe) {
dieLevel = DEFAULT_DIE_LEVEL;
}
@@ -326,7 +333,7 @@
} else {
if (tok.startsWith("-")) {
throw new JasperException("Unrecognized option: " + tok +
- ". Use -help for help.");
+ ". Use -help for help.");
}
if (!fullstop) {
argPos--;
@@ -337,12 +344,12 @@
}
// Add all extra arguments to the list of files
- while( true ) {
+ while (true) {
String file = nextFile();
- if( file==null ) {
+ if (file == null) {
break;
}
- pages.add( file );
+ pages.add(file);
}
}
@@ -404,8 +411,8 @@
return true;
}
- public void setClassDebugInfo( boolean b ) {
- classDebugInfo=b;
+ public void setClassDebugInfo(boolean b) {
+ classDebugInfo = b;
}
public boolean getClassDebugInfo() {
@@ -413,8 +420,8 @@
return classDebugInfo;
}
- /**
- * @see Options#isCaching()
+ /**
+ * @see Options#isCaching()
*/
public boolean isCaching() {
return caching;
@@ -469,7 +476,7 @@
this.smapSuppressed = smapSuppressed;
}
-
+
/**
* Should SMAP info for JSR45 debugging be dumped to a file?
*/
@@ -484,13 +491,13 @@
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
+ * char arrays, false otherwise
*/
public void setGenStringAsCharArray(boolean genStringAsCharArray) {
this.genStringAsCharArray = genStringAsCharArray;
@@ -500,7 +507,7 @@
* 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
+ * otherwise
*/
public boolean genStringAsCharArray() {
return genStringAsCharArray;
@@ -531,12 +538,12 @@
}
public Class getJspCompilerPlugin() {
- // we don't compile, so this is meanlingless
+ // we don't compile, so this is meanlingless
return null;
}
public String getJspCompilerPath() {
- // we don't compile, so this is meanlingless
+ // we don't compile, so this is meanlingless
return null;
}
@@ -548,7 +555,7 @@
}
public void setCompiler(String c) {
- compiler=c;
+ compiler = c;
}
/**
@@ -565,10 +572,10 @@
/**
* @see Options#getCompilerSourceVM()
*/
- public String getCompilerSourceVM() {
- return compilerSourceVM;
- }
-
+ public String getCompilerSourceVM() {
+ return compilerSourceVM;
+ }
+
/**
* @see Options#getCompilerSourceVM()
*/
@@ -605,13 +612,13 @@
}
public String getClassPath() {
- if( classPath != null )
+ if (classPath != null)
return classPath;
return System.getProperty("java.class.path");
}
public void setClassPath(String s) {
- classPath=s;
+ classPath = s;
}
/**
@@ -631,8 +638,8 @@
* @param extension The extension to add, e.g. "myjsp"
*/
protected void addExtension(final String extension) {
- if(extension != null) {
- if(extensions == null) {
+ if (extension != null) {
+ if (extensions == null) {
extensions = new Vector();
}
@@ -643,14 +650,14 @@
/**
* Parses comma-separated list of JSP files to be processed. If the argument
* is null, nothing is done.
- *
+ * <p/>
* <p>Each file is interpreted relative to uriroot, unless it is absolute,
* in which case it must start with uriroot.</p>
*
* @param jspFiles Comma-separated list of JSP files to be processed
*/
public void setJspFiles(final String jspFiles) {
- if(jspFiles == null) {
+ if (jspFiles == null) {
return;
}
@@ -665,7 +672,7 @@
*
* @param b Flag value
*/
- public void setCompile( final boolean b ) {
+ public void setCompile(final boolean b) {
compile = b;
}
@@ -676,7 +683,7 @@
*
* @param level Positive means verbose
*/
- public void setVerbose( final int level ) {
+ public void setVerbose(final int level) {
if (level > 0) {
verbose = true;
showSuccess = true;
@@ -684,24 +691,24 @@
}
}
- public void setValidateXml( boolean b ) {
- org.apache.struts2.jasper.xmlparser.ParserUtils.validating=b;
+ public void setValidateXml(boolean b) {
+ org.apache.struts2.jasper.xmlparser.ParserUtils.validating = b;
}
- public void setListErrors( boolean b ) {
+ public void setListErrors(boolean b) {
listErrors = b;
}
- public void setOutputDir( String s ) {
- if( s!= null ) {
+ public void setOutputDir(String s) {
+ if (s != null) {
scratchDir = resolveFile(s).getAbsoluteFile();
} else {
- scratchDir=null;
+ scratchDir = null;
}
}
- public void setPackage( String p ) {
- targetPackage=p;
+ public void setPackage(String p) {
+ targetPackage = p;
}
/**
@@ -709,24 +716,24 @@
* 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 setClassName(String p) {
+ targetClassName = p;
}
/**
* File where we generate a web.xml fragment with the class definitions.
*/
- public void setWebXmlFragment( String s ) {
- webxmlFile=resolveFile(s).getAbsolutePath();
- webxmlLevel=INC_WEBXML;
+ public void setWebXmlFragment(String s) {
+ webxmlFile = resolveFile(s).getAbsolutePath();
+ webxmlLevel = INC_WEBXML;
}
/**
* File where we generate a complete web.xml with the class definitions.
*/
- public void setWebXml( String s ) {
- webxmlFile=resolveFile(s).getAbsolutePath();
- webxmlLevel=ALL_WEBXML;
+ public void setWebXml(String s) {
+ webxmlFile = resolveFile(s).getAbsolutePath();
+ webxmlLevel = ALL_WEBXML;
}
/**
@@ -751,19 +758,18 @@
return tagPluginManager;
}
- public void generateWebMapping( String file, JspCompilationContext clctxt )
- throws IOException
- {
+ public void generateWebMapping(String file, JspCompilationContext clctxt)
+ throws IOException {
if (log.isDebugEnabled()) {
log.debug("Generating web mapping for file " + file
- + " using compilation context " + clctxt);
+ + " using compilation context " + clctxt);
}
String className = clctxt.getServletClassName();
String packageName = clctxt.getServletPackageName();
String thisServletName;
- if ("".equals(packageName)) {
+ if ("".equals(packageName)) {
thisServletName = className;
} else {
thisServletName = packageName + '.' + className;
@@ -787,8 +793,7 @@
}
private void processFile(String file)
- throws JasperException
- {
+ throws JasperException {
if (log.isDebugEnabled()) {
log.debug("Processing file: " + file);
}
@@ -805,9 +810,9 @@
scratchDir = new File(new File(temp).getAbsolutePath());
}
- String jspUri=file.replace('\\','/');
+ String jspUri = file.replace('\\', '/');
JspCompilationContext clctxt = new JspCompilationContext
- ( jspUri, false, this, context, null, rctxt, classLoaderInterface );
+ (jspUri, false, this, context, null, rctxt, classLoaderInterface);
/* Override the defaults */
if ((targetClassName != null) && (targetClassName.length() > 0)) {
@@ -819,8 +824,8 @@
}
originalClassLoader = Thread.currentThread().getContextClassLoader();
- if( loader==null ) {
- initClassLoader( clctxt );
+ if (loader == null) {
+ initClassLoader(clctxt);
}
Thread.currentThread().setContextClassLoader(loader);
@@ -833,7 +838,7 @@
// .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 (clc.isOutDated(compile)) {
if (log.isDebugEnabled()) {
log.debug(jspUri + " is out dated, compiling...");
}
@@ -842,9 +847,9 @@
}
// Generate mapping
- generateWebMapping( file, clctxt );
- if ( showSuccess ) {
- log.info( "Built File: " + file );
+ generateWebMapping(file, clctxt);
+ if (showSuccess) {
+ log.info("Built File: " + file);
}
this.sourceCode = clctxt.getSourceCode();
@@ -857,25 +862,26 @@
}
if (rootCause != je) {
log.error(Localizer.getMessage("jspc.error.generalException",
- file),
- rootCause);
+ file),
+ rootCause);
}
// Bugzilla 35114.
- if(getFailOnError()) {
+ if (getFailOnError()) {
throw je;
} else {
- log.error(je.getMessage(), je);;
+ log.error(je.getMessage(), je);
+ ;
}
} catch (Exception e) {
if ((e instanceof FileNotFoundException) && log.isWarnEnabled()) {
log.warn(Localizer.getMessage("jspc.error.fileDoesNotExist",
- e.getMessage()));
+ e.getMessage()));
}
throw new JasperException(e);
} finally {
- if(originalClassLoader != null) {
+ if (originalClassLoader != null) {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
}
@@ -892,12 +898,12 @@
* @throws JasperException If an error occurs
*/
public void execute() throws JasperException {
- if(log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
log.debug("execute() starting for " + pages.size() + " pages.");
}
try {
- if( context==null ) {
+ if (context == null) {
initServletContext();
}
@@ -906,12 +912,12 @@
Iterator iter = pages.iterator();
while (iter.hasNext()) {
String nextjsp = iter.next().toString();
-
+
processFile(nextjsp);
}
completeWebXml();
- }catch (JasperException je) {
+ } catch (JasperException je) {
Throwable rootCause = je;
while (rootCause instanceof JasperException
&& ((JasperException) rootCause).getRootCause() != null) {
@@ -932,7 +938,7 @@
private String nextArg() {
if ((argPos >= args.length)
- || (fullstop = SWITCH_FULL_STOP.equals(args[argPos]))) {
+ || (fullstop = SWITCH_FULL_STOP.equals(args[argPos]))) {
return null;
} else {
return args[argPos++];
@@ -963,7 +969,7 @@
if (webxmlLevel >= ALL_WEBXML) {
mapout.write(Localizer.getMessage("jspc.webxml.header"));
mapout.flush();
- } else if ((webxmlLevel>= INC_WEBXML)) {
+ } else if ((webxmlLevel >= INC_WEBXML)) {
mapout.write(Localizer.getMessage("jspc.webinc.header"));
mapout.flush();
}
@@ -993,10 +999,10 @@
private void initServletContext() {
- context =new JspCServletContext
+ context = new JspCServletContext
(new PrintWriter(System.out),
- classLoaderInterface);
- tldLocationsCache = new TldLocationsCache(context, true);
+ classLoaderInterface);
+ tldLocationsCache = new TldLocationsCache(context, true);
rctxt = new JspRuntimeContext(context, this);
jspConfig = new JspConfig(context);
@@ -1011,7 +1017,7 @@
* @throws IOException If an error occurs
*/
private void initClassLoader(JspCompilationContext clctxt)
- throws IOException {
+ throws IOException {
classPath = getClassPath();
@@ -1019,7 +1025,7 @@
// Turn the classPath into URLs
ArrayList urls = new ArrayList();
StringTokenizer tokenizer = new StringTokenizer(classPath,
- File.pathSeparator);
+ File.pathSeparator);
while (tokenizer.hasMoreTokens()) {
String path = tokenizer.nextToken();
try {
@@ -1035,7 +1041,7 @@
//TODO: add .tld files to the URLCLassLoader
- URL urlsA[]=new URL[urls.size()];
+ URL urlsA[] = new URL[urls.size()];
urls.toArray(urlsA);
loader = new URLClassLoader(urlsA, this.getClass().getClassLoader());
@@ -1046,13 +1052,13 @@
* in both Ant and command-line situations. If Ant launched
* us, we should use the basedir of the current project
* to resolve relative paths.
- *
+ * <p/>
* See Bugzilla 35571.
*
* @param s The file
* @return The file resolved
*/
- protected File resolveFile(final String s) {
+ protected File resolveFile(final String s) {
//TODO: what to do with this
return new File(s);
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/JspCompilationContext.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/JspCompilationContext.java
index 67a50b5..87aa5a8 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/JspCompilationContext.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/JspCompilationContext.java
@@ -18,6 +18,8 @@
package org.apache.struts2.jasper;
import com.opensymphony.xwork2.util.finder.ClassLoaderInterface;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.compiler.Compiler;
import org.apache.struts2.jasper.compiler.*;
import org.apache.struts2.jasper.servlet.JasperLoader;
@@ -37,9 +39,9 @@
* 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.
- *
+ * <p/>
* Most of the path-related stuff is here - mangling names, versions, dirs,
- * loading resources and dealing with uris.
+ * loading resources and dealing with uris.
*
* @author Anil K. Vijendran
* @author Harish Prabandham
@@ -49,8 +51,7 @@
*/
public class JspCompilationContext {
- protected org.apache.commons.logging.Log log =
- org.apache.commons.logging.LogFactory.getLog(JspCompilationContext.class);
+ private Logger log = LoggerFactory.getLogger(JspCompilationContext.class);
private Hashtable tagFileJarUrls;
private boolean isPackagedTagFile;
@@ -119,7 +120,7 @@
}
public JspCompilationContext(String tagfile,
- TagInfo tagInfo,
+ TagInfo tagInfo,
Options options,
ServletContext context,
JspServletWrapper jsw,
@@ -135,20 +136,20 @@
}
/* ==================== Methods to override ==================== */
-
+
/** ---------- Class path and loader ---------- */
/**
- * The classpath that is passed off to the Java compiler.
+ * The classpath that is passed off to the Java compiler.
*/
public String getClassPath() {
- if( classPath != null )
+ if (classPath != null)
return classPath;
return rctxt.getClassPath();
}
/**
- * The classpath that is passed off to the Java compiler.
+ * The classpath that is passed off to the Java compiler.
*/
public void setClassPath(String classPath) {
this.classPath = classPath;
@@ -159,7 +160,7 @@
* this JSP?
*/
public ClassLoader getClassLoader() {
- if( loader != null )
+ if (loader != null)
return loader;
return rctxt.getParentClassLoader();
}
@@ -169,22 +170,22 @@
}
public ClassLoader getJspLoader() {
- if( jspLoader == null ) {
+ if (jspLoader == null) {
jspLoader = new JasperLoader
- (new URL[] {baseUrl},
- getClassLoader(),
- rctxt.getPermissionCollection(),
- rctxt.getCodeSource());
+ (new URL[]{baseUrl},
+ getClassLoader(),
+ rctxt.getPermissionCollection(),
+ rctxt.getCodeSource());
}
return jspLoader;
}
/** ---------- Input/Output ---------- */
-
+
/**
* 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.
+ * compilers that are created.
*/
public Compiler createCompiler() throws JasperException {
jspCompiler = new CustomCompiler();
@@ -193,7 +194,7 @@
}
private Compiler createCompiler(String className) {
- Compiler compiler = null;
+ Compiler compiler = null;
try {
compiler = (Compiler) Class.forName(className).newInstance();
} catch (Throwable t) {
@@ -203,7 +204,7 @@
}
return compiler;
}
-
+
public Compiler getCompiler() {
return jspCompiler;
}
@@ -213,7 +214,8 @@
/**
* Gets a resource as a stream, relative to the meanings of this
* context's implementation.
- * @return a null if the resource cannot be found or represented
+ *
+ * @return a null if the resource cannot be found or represented
* as an InputStream.
*/
public java.io.InputStream getResourceAsStream(String res) {
@@ -233,7 +235,7 @@
return context.getResourcePaths(canonicalURI(path));
}
- /**
+ /**
* Gets the actual path of a URI relative to the context of
* the compilation.
*/
@@ -248,9 +250,9 @@
* Returns 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.
- *
+ * <p/>
* The map is populated when parsing the tag-file elements of the TLDs
- * of any imported taglibs.
+ * of any imported taglibs.
*/
public Hashtable getTagFileJarUrls() {
return this.tagFileJarUrls;
@@ -270,7 +272,7 @@
/**
* Just the class name (does not include package name) of the
- * generated class.
+ * generated class.
*/
public String getServletClassName() {
@@ -294,10 +296,10 @@
public void setServletClassName(String className) {
this.className = className;
}
-
+
/**
* Path of the JSP URI. Note that this is not a file name. This is
- * the context rooted URI of the JSP file.
+ * the context rooted URI of the JSP file.
*/
public String getJspFile() {
return jspUri;
@@ -305,7 +307,7 @@
/**
* Are we processing something that has been declared as an
- * errorpage?
+ * errorpage?
*/
public boolean isErrorPage() {
return isErrPage;
@@ -368,11 +370,11 @@
if (derivedPackageName == null) {
int iSep = jspUri.lastIndexOf('/');
derivedPackageName = (iSep > 0) ?
- JspUtil.makeJavaPackage(jspUri.substring(0,iSep)) : "";
+ JspUtil.makeJavaPackage(jspUri.substring(0, iSep)) : "";
}
return derivedPackageName;
}
-
+
/**
* The package name into which the servlet class is generated.
*/
@@ -382,13 +384,13 @@
/**
* Full path name of the Java file into which the servlet is being
- * generated.
+ * generated.
*/
public String getServletJavaFileName() {
if (servletJavaFileName == null) {
servletJavaFileName =
- getServletClassName() + ".java";
+ getServletClassName() + ".java";
}
return servletJavaFileName;
}
@@ -398,7 +400,7 @@
}
/**
- * Get hold of the Options object for this context.
+ * Get hold of the Options object for this context.
*/
public Options getOptions() {
return options;
@@ -422,12 +424,12 @@
}
if (isTagFile()) {
- String tagName = tagInfo.getTagClassName();
+ String tagName = tagInfo.getTagClassName();
javaPath = tagName.replace('.', '/') + ".java";
} else {
javaPath = getServletPackageName().replace('.', '/') + '/' +
- getServletClassName() + ".java";
- }
+ getServletClassName() + ".java";
+ }
return javaPath;
}
@@ -435,13 +437,13 @@
if (classFileName == null) {
classFileName = getServletClassName() + ".class";
- }
+ }
return classFileName;
}
/**
* Get the content type of this JSP.
- *
+ * <p/>
* Content type includes content type and encoding.
*/
public String getContentType() {
@@ -465,16 +467,16 @@
/**
* Gets the 'location' of the TLD associated with the given taglib 'uri'.
- *
+ *
* @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.
+ * 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.
*/
public String[] getTldLocation(String uri) throws JasperException {
- String[] location =
- getOptions().getTldLocationsCache().getLocation(uri);
+ String[] location =
+ getOptions().getTldLocationsCache().getLocation(uri);
return location;
}
@@ -490,21 +492,21 @@
public void incrementRemoved() {
if (removed > 1) {
jspCompiler.removeGeneratedFiles();
- if( rctxt != null )
+ if (rctxt != null)
rctxt.removeWrapper(jspUri);
}
removed++;
}
public boolean isRemoved() {
- if (removed > 1 ) {
+ if (removed > 1) {
return true;
}
return false;
}
// ==================== Compile and reload ====================
-
+
public void compile() throws JasperException, FileNotFoundException {
createCompiler();
if (isPackagedTagFile || jspCompiler.isOutDated()) {
@@ -520,8 +522,8 @@
} catch (Exception ex) {
ex.printStackTrace();
JasperException je = new JasperException(
- Localizer.getMessage("jsp.error.unable.compile"),
- ex);
+ Localizer.getMessage("jsp.error.unable.compile"),
+ ex);
// Cache compilation exception
jsw.setCompilationException(je);
throw je;
@@ -535,12 +537,11 @@
// ==================== Manipulating the class ====================
- public Class load()
- throws JasperException, FileNotFoundException
- {
+ public Class load()
+ throws JasperException, FileNotFoundException {
try {
getJspLoader();
-
+
String name;
if (isTagFile()) {
name = tagInfo.getTagClassName();
@@ -550,10 +551,10 @@
servletClass = jspLoader.loadClass(name);
} catch (ClassNotFoundException cex) {
throw new JasperException(Localizer.getMessage("jsp.error.unable.load"),
- cex);
+ cex);
} catch (Exception ex) {
throw new JasperException(Localizer.getMessage("jsp.error.unable.compile"),
- ex);
+ ex);
}
removed = 0;
return servletClass;
@@ -564,66 +565,66 @@
static Object outputDirLock = new Object();
private static final boolean isPathSeparator(char c) {
- return (c == '/' || c == '\\');
+ return (c == '/' || c == '\\');
}
public 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) ) {
- /*
+ 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;
- }
+ while (pos + 1 < len && isPathSeparator(s.charAt(pos + 1))) {
+ ++pos;
+ }
- if (pos+1 < len && s.charAt(pos+1) == '.') {
- /*
+ 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;
+ if (pos + 2 >= len) break;
- switch (s.charAt(pos+2)) {
- /*
+ switch (s.charAt(pos + 2)) {
+ /*
* self directory in path
* foo/./bar -> foo/bar
*/
- case '/':
- case '\\':
- pos += 2;
- continue;
+ 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();
+ /*
+ * two dots in a path: go back one hierarchy.
+ * foo/bar/../baz -> foo/baz
+ */
+ case '.':
+ // only if we have exactly _two_ dots.
+ if (pos + 3 < len && isPathSeparator(s.charAt(pos + 3))) {
+ pos += 3;
+ int separatorPos = result.length() - 1;
+ while (separatorPos >= 0 &&
+ !isPathSeparator(result
+ .charAt(separatorPos))) {
+ --separatorPos;
+ }
+ if (separatorPos >= 0)
+ result.setLength(separatorPos);
+ continue;
+ }
+ }
+ }
+ }
+ result.append(c);
+ ++pos;
+ }
+ return result.toString();
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/Options.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/Options.java
index c008f6d..0c08270 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/Options.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/Options.java
@@ -25,7 +25,7 @@
import java.util.Map;
/**
- * A class to hold all init parameters specific to the JSP engine.
+ * A class to hold all init parameters specific to the JSP engine.
*
* @author Anil K. Vijendran
* @author Hans Bergsten
@@ -59,7 +59,7 @@
* Should errors be sent to client or thrown into stderr?
*/
public boolean getSendErrorToClient();
-
+
/**
* Should we include debug information in compiled class?
*/
@@ -93,7 +93,7 @@
public boolean getTrimSpaces();
/**
- * Class ID for use in the plugin tag when the browser is IE.
+ * Class ID for use in the plugin tag when the browser is IE.
*/
public String getIeClassId();
@@ -121,18 +121,18 @@
/**
* Compiler source VM, e.g. 1.3, 1.4, or 1.5.
*/
- public String getCompilerSourceVM();
+ public String getCompilerSourceVM();
/**
* 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
+ * 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.
+ * for the web-application.
*/
public TldLocationsCache getTldLocationsCache();
@@ -148,7 +148,7 @@
public boolean getFork();
/**
- * Obtain JSP configuration informantion specified in web.xml.
+ * Obtain JSP configuration informantion specified in web.xml.
*/
public JspConfig getJspConfig();
@@ -166,24 +166,24 @@
* Are Text strings to be generated as char arrays?
*/
public boolean genStringAsCharArray();
-
+
/**
* Modification test interval.
*/
public int getModificationTestInterval();
-
+
/**
* 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/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/BeanRepository.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/BeanRepository.java
index 6021e04..a508ee3 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/BeanRepository.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/BeanRepository.java
@@ -23,7 +23,7 @@
import java.util.Vector;
/**
- * Repository of {page, request, session, application}-scoped beans
+ * Repository of {page, request, session, application}-scoped beans
*
* @author Mandar Raje
*/
@@ -39,73 +39,73 @@
/*
* Constructor.
- */
+ */
public BeanRepository(ClassLoader loader, ErrorDispatcher err) {
this.loader = loader;
- this.errDispatcher = err;
+ this.errDispatcher = err;
- sessionBeans = new Vector(11);
- pageBeans = new Vector(11);
- appBeans = new Vector(11);
- requestBeans = new Vector(11);
- beanTypes = new Hashtable();
+ sessionBeans = new Vector(11);
+ pageBeans = new Vector(11);
+ appBeans = new Vector(11);
+ requestBeans = new Vector(11);
+ beanTypes = new Hashtable();
}
-
+
public void addBean(Node.UseBean n, String s, String type, String scope)
- throws JasperException {
+ throws JasperException {
- if (scope == null || scope.equals("page")) {
- pageBeans.addElement(s);
- } else if (scope.equals("request")) {
- requestBeans.addElement(s);
- } else if (scope.equals("session")) {
- sessionBeans.addElement(s);
- } else if (scope.equals("application")) {
- appBeans.addElement(s);
- } else {
- errDispatcher.jspError(n, "jsp.error.usebean.badScope");
- }
-
- putBeanType(s, type);
+ if (scope == null || scope.equals("page")) {
+ pageBeans.addElement(s);
+ } else if (scope.equals("request")) {
+ requestBeans.addElement(s);
+ } else if (scope.equals("session")) {
+ sessionBeans.addElement(s);
+ } else if (scope.equals("application")) {
+ appBeans.addElement(s);
+ } else {
+ errDispatcher.jspError(n, "jsp.error.usebean.badScope");
+ }
+
+ putBeanType(s, type);
}
-
+
public Class getBeanType(String bean) throws JasperException {
- Class clazz = null;
- try {
- clazz = loader.loadClass ((String)beanTypes.get(bean));
- } catch (ClassNotFoundException ex) {
- throw new JasperException (ex);
- }
- return clazz;
+ Class clazz = null;
+ try {
+ clazz = loader.loadClass((String) beanTypes.get(bean));
+ } catch (ClassNotFoundException ex) {
+ throw new JasperException(ex);
+ }
+ return clazz;
}
-
- public boolean checkVariable (String bean) {
- // XXX Not sure if this is the correct way.
- // After pageContext is finalised this will change.
- return (checkPageBean(bean) || checkSessionBean(bean) ||
- checkRequestBean(bean) || checkApplicationBean(bean));
+
+ public boolean checkVariable(String bean) {
+ // XXX Not sure if this is the correct way.
+ // After pageContext is finalised this will change.
+ return (checkPageBean(bean) || checkSessionBean(bean) ||
+ checkRequestBean(bean) || checkApplicationBean(bean));
}
private void putBeanType(String bean, String type) {
- beanTypes.put (bean, type);
+ beanTypes.put(bean, type);
}
- private boolean checkPageBean (String s) {
- return pageBeans.contains (s);
+ private boolean checkPageBean(String s) {
+ return pageBeans.contains(s);
}
- private boolean checkRequestBean (String s) {
- return requestBeans.contains (s);
+ private boolean checkRequestBean(String s) {
+ return requestBeans.contains(s);
}
- private boolean checkSessionBean (String s) {
- return sessionBeans.contains (s);
+ private boolean checkSessionBean(String s) {
+ return sessionBeans.contains(s);
}
- private boolean checkApplicationBean (String s) {
- return appBeans.contains (s);
+ private boolean checkApplicationBean(String s) {
+ return appBeans.contains(s);
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Collector.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Collector.java
index 959a71d..88cec9b 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Collector.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Collector.java
@@ -76,7 +76,7 @@
scriptingElementSeen = true;
}
usebeanSeen = true;
- visitBody(n);
+ visitBody(n);
}
public void visit(Node.PlugIn n) throws JasperException {
@@ -91,16 +91,15 @@
public void visit(Node.CustomTag n) throws JasperException {
// Check to see what kinds of element we see as child elements
- checkSeen( n.getChildInfo(), n );
+ checkSeen(n.getChildInfo(), n);
}
/**
* Check all child nodes for various elements and update the given
* ChildInfo object accordingly. Visits body in the process.
*/
- private void checkSeen( Node.ChildInfo ci, Node n )
- throws JasperException
- {
+ private void checkSeen(Node.ChildInfo ci, Node n)
+ throws JasperException {
// save values collected so far
boolean scriptingElementSeenSave = scriptingElementSeen;
scriptingElementSeen = false;
@@ -116,8 +115,8 @@
hasScriptingVars = false;
// Scan attribute list for expressions
- if( n instanceof Node.CustomTag ) {
- Node.CustomTag ct = (Node.CustomTag)n;
+ if (n instanceof Node.CustomTag) {
+ Node.CustomTag ct = (Node.CustomTag) n;
Node.JspAttribute[] attrs = ct.getJspAttributes();
for (int i = 0; attrs != null && i < attrs.length; i++) {
if (attrs[i].isExpression()) {
@@ -129,14 +128,14 @@
visitBody(n);
- if( (n instanceof Node.CustomTag) && !hasScriptingVars) {
- Node.CustomTag ct = (Node.CustomTag)n;
+ if ((n instanceof Node.CustomTag) && !hasScriptingVars) {
+ Node.CustomTag ct = (Node.CustomTag) n;
hasScriptingVars = ct.getVariableInfos().length > 0 ||
- ct.getTagVariableInfos().length > 0;
+ ct.getTagVariableInfos().length > 0;
}
// Record if the tag element and its body contains any scriptlet.
- ci.setScriptless(! scriptingElementSeen);
+ ci.setScriptless(!scriptingElementSeen);
ci.setHasUseBean(usebeanSeen);
ci.setHasIncludeAction(includeActionSeen);
ci.setHasParamAction(paramActionSeen);
@@ -167,11 +166,11 @@
}
public void visit(Node.JspBody n) throws JasperException {
- checkSeen( n.getChildInfo(), n );
+ checkSeen(n.getChildInfo(), n);
}
public void visit(Node.NamedAttribute n) throws JasperException {
- checkSeen( n.getChildInfo(), n );
+ checkSeen(n.getChildInfo(), n);
}
public void visit(Node.Declaration n) throws JasperException {
@@ -187,15 +186,15 @@
}
public void updatePageInfo(PageInfo pageInfo) {
- pageInfo.setScriptless(! scriptingElementSeen);
+ pageInfo.setScriptless(!scriptingElementSeen);
}
}
public static void collect(Compiler compiler, Node.Nodes page)
- throws JasperException {
+ throws JasperException {
- CollectVisitor collectVisitor = new CollectVisitor();
+ CollectVisitor collectVisitor = new CollectVisitor();
page.visit(collectVisitor);
collectVisitor.updatePageInfo(compiler.getPageInfo());
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Compiler.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Compiler.java
index c7780c0..b70cc1b 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Compiler.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Compiler.java
@@ -17,6 +17,8 @@
package org.apache.struts2.jasper.compiler;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.JasperException;
import org.apache.struts2.jasper.JspCompilationContext;
import org.apache.struts2.jasper.Options;
@@ -39,8 +41,7 @@
* @author Mark Roth
*/
public abstract class Compiler {
- protected org.apache.commons.logging.Log log=
- org.apache.commons.logging.LogFactory.getLog( Compiler.class );
+ private Logger log = LoggerFactory.getLogger(Compiler.class);
// ----------------------------------------------------------------- Static
@@ -82,8 +83,9 @@
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
*/
@@ -94,19 +96,19 @@
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());
+ errDispatcher),
+ ctxt.getJspFile());
JspConfig jspConfig = options.getJspConfig();
JspConfig.JspProperty jspProperty =
- jspConfig.findJspProperty(ctxt.getJspFile());
+ jspConfig.findJspProperty(ctxt.getJspFile());
/*
* If the current uri is matched by a pattern specified in
@@ -114,9 +116,9 @@
* those properties.
*/
pageInfo.setELIgnored(JspUtil.booleanValue(
- jspProperty.isELIgnored()));
+ jspProperty.isELIgnored()));
pageInfo.setScriptingInvalid(JspUtil.booleanValue(
- jspProperty.isScriptingInvalid()));
+ jspProperty.isScriptingInvalid()));
if (jspProperty.getIncludePrelude() != null) {
pageInfo.setIncludePrelude(jspProperty.getIncludePrelude());
}
@@ -131,14 +133,14 @@
// Setup the ServletWriter
String javaEncoding = ctxt.getOptions().getJavaEncoding();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(1024);
- OutputStreamWriter osw = null;
+ OutputStreamWriter osw = null;
try {
osw = new OutputStreamWriter(
- byteArrayOutputStream, javaEncoding);
+ byteArrayOutputStream, javaEncoding);
} catch (UnsupportedEncodingException ex) {
errDispatcher.jspError("jsp.error.needAlternateJavaEncoding",
- javaEncoding);
+ javaEncoding);
}
writer = new ServletWriter(new PrintWriter(osw));
@@ -177,7 +179,7 @@
if (log.isDebugEnabled()) {
t3 = System.currentTimeMillis();
}
-
+
// Determine which custom tag needs to declare which scripting vars
ScriptingVariabler.set(pageNodes, errDispatcher);
@@ -203,9 +205,9 @@
ctxt.setSourceCode(byteArrayOutputStream.toString());
if (log.isDebugEnabled()) {
t4 = System.currentTimeMillis();
- log.debug("Generated "+ javaFileName + " total="
- + (t4-t1) + " generate=" + (t4-t3)
- + " validate=" + (t2-t1));
+ log.debug("Generated " + javaFileName + " total="
+ + (t4 - t1) + " generate=" + (t4 - t3)
+ + " validate=" + (t2 - t1));
}
} catch (Exception e) {
@@ -229,9 +231,9 @@
}
}
}
-
+
// JSR45 Support
- if (! options.isSmapSuppressed()) {
+ if (!options.isSmapSuppressed()) {
smapStr = SmapUtil.generateSmap(ctxt, pageNodes);
}
@@ -245,31 +247,30 @@
return smapStr;
}
- /**
+ /**
* Compile the servlet from .java file to .class file
*/
protected abstract void generateClass(String[] smap)
- throws FileNotFoundException, JasperException, Exception;
-
-
- /**
+ throws FileNotFoundException, JasperException, Exception;
+
+
+ /**
* Compile the jsp file from the current engine context
*/
public void compile()
- throws FileNotFoundException, JasperException, Exception
- {
+ 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
*/
public void compile(boolean compileClass)
- throws FileNotFoundException, JasperException, Exception
- {
+ throws FileNotFoundException, JasperException, Exception {
compile(compileClass, false);
}
@@ -279,11 +280,10 @@
*
* @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
+ * @param jspcMode true if invoked from JspC, false otherwise
*/
public void compile(boolean compileClass, boolean jspcMode)
- throws FileNotFoundException, JasperException, Exception
- {
+ throws FileNotFoundException, JasperException, Exception {
if (errDispatcher == null) {
this.errDispatcher = new ErrorDispatcher(jspcMode);
}
@@ -309,7 +309,7 @@
// In development mode, they are used for detailed
// error messages.
// http://issues.apache.org/bugzilla/show_bug.cgi?id=37062
- if(!this.options.getDevelopment()) {
+ if (!this.options.getDevelopment()) {
pageNodes = null;
}
@@ -321,12 +321,12 @@
}
/**
- * This is a protected method intended to be overridden by
+ * 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.
+ * to do all the compilation.
*/
public boolean isOutDated() {
- return isOutDated( true );
+ return isOutDated(true);
}
/**
@@ -335,6 +335,7 @@
* If the page has dependencies, the check is also extended to its
* dependeants, and so on.
* This method can by overidden by a subclasses of Compiler.
+ *
* @param checkClass If true, check against .class file,
* if false, check against .java file.
*/
@@ -344,16 +345,16 @@
if (jsw != null
&& (ctxt.getOptions().getModificationTestInterval() > 0)) {
-
+
if (jsw.getLastModificationTest()
- + (ctxt.getOptions().getModificationTestInterval() * 1000)
+ + (ctxt.getOptions().getModificationTestInterval() * 1000)
> System.currentTimeMillis()) {
return false;
} else {
jsw.setLastModificationTest(System.currentTimeMillis());
}
}
-
+
long jspRealLastModified = 0;
try {
URL jspUrl = ctxt.getResource(jsp);
@@ -371,13 +372,13 @@
long targetLastModified = 0;
File targetFile;
-
- if( checkClass ) {
+
+ if (checkClass) {
targetFile = new File(ctxt.getClassFileName());
} else {
targetFile = new File(ctxt.getServletJavaFileName());
}
-
+
if (!targetFile.exists()) {
return true;
}
@@ -385,21 +386,21 @@
targetLastModified = targetFile.lastModified();
if (checkClass && jsw != null) {
jsw.setServletClassLastModifiedTime(targetLastModified);
- }
+ }
if (targetLastModified < jspRealLastModified) {
- if( log.isDebugEnabled() ) {
+ if (log.isDebugEnabled()) {
log.debug("Compiler: outdated: " + targetFile + " " +
- targetLastModified );
+ targetLastModified);
}
return true;
}
// determine if source dependent files (e.g. includes using include
// directives) have been changed.
- if( jsw==null ) {
+ if (jsw == null) {
return false;
}
-
+
List depends = jsw.getDependants();
if (depends == null) {
return false;
@@ -407,7 +408,7 @@
Iterator it = depends.iterator();
while (it.hasNext()) {
- String include = (String)it.next();
+ String include = (String) it.next();
try {
URL includeUrl = ctxt.getResource(include);
if (includeUrl == null) {
@@ -431,7 +432,7 @@
}
-
+
/**
* Gets the error dispatcher.
*/
@@ -461,8 +462,8 @@
String classFileName = ctxt.getClassFileName();
if (classFileName != null) {
File classFile = new File(classFileName);
- if( log.isDebugEnabled() )
- log.debug( "Deleting " + classFile );
+ if (log.isDebugEnabled())
+ log.debug("Deleting " + classFile);
classFile.delete();
}
} catch (Exception e) {
@@ -472,8 +473,8 @@
String javaFileName = ctxt.getServletJavaFileName();
if (javaFileName != null) {
File javaFile = new File(javaFileName);
- if( log.isDebugEnabled() )
- log.debug( "Deleting " + javaFile );
+ if (log.isDebugEnabled())
+ log.debug("Deleting " + javaFile);
javaFile.delete();
}
} catch (Exception e) {
@@ -486,8 +487,8 @@
String classFileName = ctxt.getClassFileName();
if (classFileName != null) {
File classFile = new File(classFileName);
- if( log.isDebugEnabled() )
- log.debug( "Deleting " + classFile );
+ if (log.isDebugEnabled())
+ log.debug("Deleting " + classFile);
classFile.delete();
}
} catch (Exception e) {
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/DefaultErrorHandler.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/DefaultErrorHandler.java
index ec4b2c5..37e279b 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/DefaultErrorHandler.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/DefaultErrorHandler.java
@@ -25,63 +25,63 @@
* @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
- */
+ * 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 {
+ 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
- */
+ * 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
- */
+ * 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++) {
+
+ for (int i = 0; i < details.length; i++) {
buf.append("\n");
if (details[i].getJspBeginLineNumber() >= 0) {
- args = new Object[] {
- new Integer(details[i].getJspBeginLineNumber()),
- details[i].getJspFileName() };
+ args = new Object[]{
+ new Integer(details[i].getJspBeginLineNumber()),
+ details[i].getJspFileName()};
buf.append("\n");
buf.append(Localizer.getMessage("jsp.error.single.line.number",
args));
- buf.append("\n");
+ buf.append("\n");
buf.append(details[i].getErrorMessage());
- buf.append("\n");
+ buf.append("\n");
buf.append(details[i].getJspExtract());
} else {
- args = new Object[] {
- new Integer(details[i].getJavaLineNumber()) };
+ args = new Object[]{
+ new Integer(details[i].getJavaLineNumber())};
buf.append("\n\n");
buf.append(Localizer.getMessage("jsp.error.java.line.number",
args));
@@ -92,18 +92,18 @@
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
+ * @param exception Compilation exception
*/
public void javacError(String errorReport, Exception exception)
- throws JasperException {
-
+ throws JasperException {
+
throw new JasperException(
Localizer.getMessage("jsp.error.unable.compile"), exception);
}
-
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Dumper.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Dumper.java
index 2c6f947..5be9977 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Dumper.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Dumper.java
@@ -23,185 +23,185 @@
class Dumper {
static class DumpVisitor extends Node.Visitor {
- private int indent = 0;
+ private int indent = 0;
- private String getAttributes(Attributes attrs) {
- if (attrs == null)
- return "";
+ 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();
- }
+ 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 str) {
+ printIndent();
+ System.out.print(str);
+ }
- private void printString(String prefix, char[] chars, String suffix) {
- String str = null;
- if (chars != null) {
- str = new String(chars);
- }
- printString(prefix, str, suffix);
- }
-
- private void printString(String prefix, String str, String suffix) {
- printIndent();
- if (str != null) {
- System.out.print(prefix + str + suffix);
- } else {
- System.out.print(prefix + suffix);
- }
- }
+ private void printString(String prefix, char[] chars, String suffix) {
+ String str = null;
+ if (chars != null) {
+ str = new String(chars);
+ }
+ printString(prefix, str, suffix);
+ }
- private void printAttributes(String prefix, Attributes attrs,
- String suffix) {
- printString(prefix, getAttributes(attrs), suffix);
- }
+ private void printString(String prefix, String str, String suffix) {
+ printIndent();
+ if (str != null) {
+ System.out.print(prefix + str + suffix);
+ } else {
+ System.out.print(prefix + suffix);
+ }
+ }
- private void dumpBody(Node n) throws JasperException {
- Node.Nodes page = n.getBody();
- if (page != null) {
+ 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);
+ page.visit(this);
// indent--;
- }
+ }
}
public void visit(Node.PageDirective n) throws JasperException {
- printAttributes("<%@ page", n.getAttributes(), "%>");
+ printAttributes("<%@ page", n.getAttributes(), "%>");
}
public void visit(Node.TaglibDirective n) throws JasperException {
- printAttributes("<%@ taglib", n.getAttributes(), "%>");
+ printAttributes("<%@ taglib", n.getAttributes(), "%>");
}
public void visit(Node.IncludeDirective n) throws JasperException {
- printAttributes("<%@ include", n.getAttributes(), "%>");
- dumpBody(n);
+ printAttributes("<%@ include", n.getAttributes(), "%>");
+ dumpBody(n);
}
public void visit(Node.Comment n) throws JasperException {
- printString("<%--", n.getText(), "--%>");
+ printString("<%--", n.getText(), "--%>");
}
public void visit(Node.Declaration n) throws JasperException {
- printString("<%!", n.getText(), "%>");
+ printString("<%!", n.getText(), "%>");
}
public void visit(Node.Expression n) throws JasperException {
- printString("<%=", n.getText(), "%>");
+ printString("<%=", n.getText(), "%>");
}
public void visit(Node.Scriptlet n) throws JasperException {
- printString("<%", n.getText(), "%>");
+ printString("<%", n.getText(), "%>");
}
public void visit(Node.IncludeAction n) throws JasperException {
- printAttributes("<jsp:include", n.getAttributes(), ">");
- dumpBody(n);
+ printAttributes("<jsp:include", n.getAttributes(), ">");
+ dumpBody(n);
printString("</jsp:include>");
}
public void visit(Node.ForwardAction n) throws JasperException {
- printAttributes("<jsp:forward", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:forward>");
+ printAttributes("<jsp:forward", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:forward>");
}
public void visit(Node.GetProperty n) throws JasperException {
- printAttributes("<jsp:getProperty", n.getAttributes(), "/>");
+ printAttributes("<jsp:getProperty", n.getAttributes(), "/>");
}
public void visit(Node.SetProperty n) throws JasperException {
- printAttributes("<jsp:setProperty", n.getAttributes(), ">");
+ printAttributes("<jsp:setProperty", n.getAttributes(), ">");
dumpBody(n);
printString("</jsp:setProperty>");
}
public void visit(Node.UseBean n) throws JasperException {
- printAttributes("<jsp:useBean", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:useBean>");
+ printAttributes("<jsp:useBean", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:useBean>");
}
-
+
public void visit(Node.PlugIn n) throws JasperException {
- printAttributes("<jsp:plugin", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:plugin>");
- }
-
+ printAttributes("<jsp:plugin", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:plugin>");
+ }
+
public void visit(Node.ParamsAction n) throws JasperException {
- printAttributes("<jsp:params", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:params>");
+ printAttributes("<jsp:params", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:params>");
}
-
+
public void visit(Node.ParamAction n) throws JasperException {
- printAttributes("<jsp:param", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:param>");
+ printAttributes("<jsp:param", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:param>");
}
-
+
public void visit(Node.NamedAttribute n) throws JasperException {
- printAttributes("<jsp:attribute", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:attribute>");
+ printAttributes("<jsp:attribute", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:attribute>");
}
public void visit(Node.JspBody n) throws JasperException {
- printAttributes("<jsp:body", n.getAttributes(), ">");
- dumpBody(n);
- printString("</jsp:body>");
+ printAttributes("<jsp:body", n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</jsp:body>");
}
-
+
public void visit(Node.ELExpression n) throws JasperException {
- printString( "${" + new String( n.getText() ) + "}" );
+ printString("${" + new String(n.getText()) + "}");
}
public void visit(Node.CustomTag n) throws JasperException {
- printAttributes("<" + n.getQName(), n.getAttributes(), ">");
- dumpBody(n);
- printString("</" + n.getQName() + ">");
+ printAttributes("<" + n.getQName(), n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</" + n.getQName() + ">");
}
- public void visit(Node.UninterpretedTag n) throws JasperException {
- String tag = n.getQName();
- printAttributes("<"+tag, n.getAttributes(), ">");
- dumpBody(n);
- printString("</" + tag + ">");
+ public void visit(Node.UninterpretedTag n) throws JasperException {
+ String tag = n.getQName();
+ printAttributes("<" + tag, n.getAttributes(), ">");
+ dumpBody(n);
+ printString("</" + tag + ">");
}
- public void visit(Node.TemplateText n) throws JasperException {
- printString(new String(n.getText()));
- }
+ public void visit(Node.TemplateText n) throws JasperException {
+ printString(new String(n.getText()));
+ }
- private void printIndent() {
- for (int i=0; i < indent; i++) {
- System.out.print(" ");
- }
- }
+ private void printIndent() {
+ for (int i = 0; i < indent; i++) {
+ System.out.print(" ");
+ }
+ }
}
public static void dump(Node n) {
- try {
- n.accept(new DumpVisitor());
- } catch (JasperException e) {
- e.printStackTrace();
- }
+ try {
+ n.accept(new DumpVisitor());
+ } catch (JasperException e) {
+ e.printStackTrace();
+ }
}
public static void dump(Node.Nodes page) {
- try {
- page.visit(new DumpVisitor());
- } catch (JasperException e) {
- e.printStackTrace();
- }
+ try {
+ page.visit(new DumpVisitor());
+ } catch (JasperException e) {
+ e.printStackTrace();
+ }
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ELFunctionMapper.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ELFunctionMapper.java
index f0289f9..17b5139 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ELFunctionMapper.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ELFunctionMapper.java
@@ -41,10 +41,10 @@
* 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.
+ * @param page The current compilation unit.
*/
- public static void map(Compiler compiler, Node.Nodes page)
- throws JasperException {
+ public static void map(Compiler compiler, Node.Nodes page)
+ throws JasperException {
ELFunctionMapper map = new ELFunctionMapper();
map.ds = new StringBuffer();
@@ -66,7 +66,7 @@
* 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.
@@ -135,7 +135,7 @@
doMap(n.getEL());
}
- private void doMap(Node.JspAttribute attr)
+ private void doMap(Node.JspAttribute attr)
throws JasperException {
if (attr != null) {
doMap(attr.getEL());
@@ -145,17 +145,18 @@
/**
* Creates function mappers, if needed, from ELNodes
*/
- private void doMap(ELNode.Nodes el)
+ 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,"");
+ if (!keyMap.containsKey(key)) {
+ keyMap.put(key, "");
funcs.add(n);
}
}
@@ -180,7 +181,7 @@
el.setMapName(decName);
return;
}
-
+
// Generate declaration for the map statically
decName = getMapName();
ss.append("static private org.apache.struts2.jasper.runtime.ProtectedFunctionMapper " + decName + ";\n");
@@ -199,9 +200,9 @@
// Setup arguments for either getMapForFunction or mapFunction
for (int i = 0; i < functions.size(); i++) {
- ELNode.Function f = (ELNode.Function)functions.get(i);
+ ELNode.Function f = (ELNode.Function) functions.get(i);
FunctionInfo funcInfo = f.getFunctionInfo();
- String key = f.getPrefix()+ ":" + f.getName();
+ String key = f.getPrefix() + ":" + f.getName();
ds.append(funcMethod + "(\"" + key + "\", " +
funcInfo.getFunctionClass() + ".class, " +
'\"' + f.getMethodName() + "\", " +
@@ -214,8 +215,7 @@
int iArray = params[k].indexOf('[');
if (iArray < 0) {
ds.append(params[k] + ".class");
- }
- else {
+ } else {
String baseType = params[k].substring(0, iArray);
ds.append("java.lang.reflect.Array.newInstance(");
ds.append(baseType);
@@ -223,7 +223,7 @@
// Count the number of array dimension
int aCount = 0;
- for (int jj = iArray; jj < params[k].length(); jj++ ) {
+ for (int jj = iArray; jj < params[k].length(); jj++) {
if (params[k].charAt(jj) == '[') {
aCount++;
}
@@ -238,7 +238,7 @@
ds.append("});\n");
// Put the current name in the global function map
gMap.put(f.getPrefix() + ':' + f.getName() + ':' + f.getUri(),
- decName);
+ decName);
}
el.setMapName(decName);
}
@@ -246,6 +246,7 @@
/**
* 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
@@ -255,9 +256,9 @@
String mapName = null;
for (int i = 0; i < functions.size(); i++) {
- ELNode.Function f = (ELNode.Function)functions.get(i);
+ ELNode.Function f = (ELNode.Function) functions.get(i);
String temName = (String) gMap.get(f.getPrefix() + ':' +
- f.getName() + ':' + f.getUri());
+ f.getName() + ':' + f.getUri());
if (temName == null) {
return null;
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ELNode.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ELNode.java
index 62587ac..85724b3 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ELNode.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ELNode.java
@@ -26,7 +26,7 @@
/**
* This class defines internal representation for an EL Expression
- *
+ * <p/>
* It currently only defines functions. It can be expanded to define
* all the components of an EL expression, if need to.
*
@@ -47,19 +47,19 @@
*/
public static class Root extends ELNode {
- private ELNode.Nodes expr;
+ private ELNode.Nodes expr;
- Root(ELNode.Nodes expr) {
- this.expr = expr;
- }
+ Root(ELNode.Nodes expr) {
+ this.expr = expr;
+ }
- public void accept(Visitor v) throws JasperException {
- v.visit(this);
- }
+ public void accept(Visitor v) throws JasperException {
+ v.visit(this);
+ }
- public ELNode.Nodes getExpression() {
- return expr;
- }
+ public ELNode.Nodes getExpression() {
+ return expr;
+ }
}
/**
@@ -67,19 +67,19 @@
*/
public static class Text extends ELNode {
- private String text;
+ private String text;
- Text(String text) {
- this.text = text;
- }
+ Text(String text) {
+ this.text = text;
+ }
- public void accept(Visitor v) throws JasperException {
- v.visit(this);
- }
+ public void accept(Visitor v) throws JasperException {
+ v.visit(this);
+ }
- public String getText() {
- return text;
- }
+ public String getText() {
+ return text;
+ }
}
/**
@@ -88,19 +88,19 @@
*/
public static class ELText extends ELNode {
- private String text;
+ private String text;
- ELText(String text) {
- this.text = text;
- }
+ ELText(String text) {
+ this.text = text;
+ }
- public void accept(Visitor v) throws JasperException {
- v.visit(this);
- }
+ public void accept(Visitor v) throws JasperException {
+ v.visit(this);
+ }
- public String getText() {
- return text;
- }
+ public String getText() {
+ return text;
+ }
}
/**
@@ -110,61 +110,61 @@
*/
public static class Function extends ELNode {
- private String prefix;
- private String name;
- private String uri;
- private FunctionInfo functionInfo;
- private String methodName;
- private String[] parameters;
+ private String prefix;
+ private String name;
+ private String uri;
+ private FunctionInfo functionInfo;
+ private String methodName;
+ private String[] parameters;
- Function(String prefix, String name) {
- this.prefix = prefix;
- this.name = name;
- }
+ Function(String prefix, String name) {
+ this.prefix = prefix;
+ this.name = name;
+ }
- public void accept(Visitor v) throws JasperException {
- v.visit(this);
- }
+ public void accept(Visitor v) throws JasperException {
+ v.visit(this);
+ }
- public String getPrefix() {
- return prefix;
- }
+ public String getPrefix() {
+ return prefix;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- public void setUri(String uri) {
- this.uri = uri;
- }
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
- public String getUri() {
- return uri;
- }
+ public String getUri() {
+ return uri;
+ }
- public void setFunctionInfo(FunctionInfo f) {
- this.functionInfo = f;
- }
+ public void setFunctionInfo(FunctionInfo f) {
+ this.functionInfo = f;
+ }
- public FunctionInfo getFunctionInfo() {
- return functionInfo;
- }
+ public FunctionInfo getFunctionInfo() {
+ return functionInfo;
+ }
- public void setMethodName(String methodName) {
- this.methodName = methodName;
- }
+ public void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
- public String getMethodName() {
- return methodName;
- }
+ public String getMethodName() {
+ return methodName;
+ }
- public void setParameters(String[] parameters) {
- this.parameters = parameters;
- }
+ public void setParameters(String[] parameters) {
+ this.parameters = parameters;
+ }
- public String[] getParameters() {
- return parameters;
- }
+ public String[] getParameters() {
+ return parameters;
+ }
}
/**
@@ -172,61 +172,62 @@
*/
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;
+ /* 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 Nodes() {
+ list = new ArrayList();
+ }
- public void add(ELNode en) {
- list.add(en);
- }
+ 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 = (ELNode) iter.next();
- n.accept(v);
- }
- }
+ /**
+ * 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 = (ELNode) iter.next();
+ n.accept(v);
+ }
+ }
- public Iterator iterator() {
- return list.iterator();
- }
+ public Iterator iterator() {
+ return list.iterator();
+ }
- public boolean isEmpty() {
- return list.size() == 0;
- }
+ 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 = (ELNode) iter.next();
- if (n instanceof Root) {
- return true;
- }
- }
- return false;
- }
+ /**
+ * @return true if the expression contains a ${...}
+ */
+ public boolean containsEL() {
+ Iterator iter = list.iterator();
+ while (iter.hasNext()) {
+ ELNode n = (ELNode) iter.next();
+ if (n instanceof Root) {
+ return true;
+ }
+ }
+ return false;
+ }
- public void setMapName(String name) {
- this.mapName = name;
- }
+ public void setMapName(String name) {
+ this.mapName = name;
+ }
- public String getMapName() {
- return mapName;
- }
+ public String getMapName() {
+ return mapName;
+ }
}
/*
@@ -234,18 +235,18 @@
*/
public static class Visitor {
- public void visit(Root n) throws JasperException {
- n.getExpression().visit(this);
- }
+ public void visit(Root n) throws JasperException {
+ n.getExpression().visit(this);
+ }
- public void visit(Function n) throws JasperException {
- }
+ public void visit(Function n) throws JasperException {
+ }
- public void visit(Text n) throws JasperException {
- }
+ public void visit(Text n) throws JasperException {
+ }
- public void visit(ELText n) throws JasperException {
- }
+ public void visit(ELText n) throws JasperException {
+ }
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ELParser.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ELParser.java
index fac1ae7..f904e5f 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ELParser.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ELParser.java
@@ -19,10 +19,10 @@
/**
* This class implements a parser for EL expressions.
- *
+ * <p/>
* It takes strings of the form xxx${..}yyy${..}zzz etc, and turn it into
* a ELNode.Nodes.
- *
+ * <p/>
* Currently, it only handles text outside ${..} and functions in ${ ..}.
*
* @author Kin-man Chung
@@ -38,9 +38,9 @@
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"};
+ "and", "div", "empty", "eq", "false",
+ "ge", "gt", "instanceof", "le", "lt", "mod",
+ "ne", "not", "null", "or", "true"};
public ELParser(String expression) {
index = 0;
@@ -50,6 +50,7 @@
/**
* Parse an EL expression
+ *
* @param expression The input expression string of the form
* Char* ('${' Char* '}')* Char*
* @return Parsed EL expression in ELNode.Nodes
@@ -62,7 +63,7 @@
parser.expr.add(new ELNode.Text(text));
}
ELNode.Nodes elexpr = parser.parseEL();
- if (! elexpr.isEmpty()) {
+ if (!elexpr.isEmpty()) {
parser.expr.add(new ELNode.Root(elexpr));
}
}
@@ -71,9 +72,10 @@
/**
* 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.
+ *
+ * @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() {
@@ -106,11 +108,11 @@
/**
* Parse for a function
* FunctionInvokation ::= (identifier ':')? identifier '('
- * (Expression (,Expression)*)? ')'
+ * (Expression (,Expression)*)? ')'
* Note: currently we don't parse arguments
*/
private boolean parseFunction() {
- if (! (curToken instanceof Id) || isELReserved(curToken.toString())) {
+ if (!(curToken instanceof Id) || isELReserved(curToken.toString())) {
return false;
}
String s1 = null; // Function prefix
@@ -146,13 +148,13 @@
int i = 0;
int j = reservedWords.length;
while (i < j) {
- int k = (i+j)/2;
+ int k = (i + j) / 2;
int result = reservedWords[k].compareTo(id);
if (result == 0) {
return true;
}
if (result < 0) {
- i = k+1;
+ i = k + 1;
} else {
j = k;
}
@@ -163,6 +165,7 @@
/**
* Skip until an EL expression ('${') is reached, allowing escape sequences
* '\\' and '\$'.
+ *
* @return The text string up to the EL expression
*/
private String skipUntilEL() {
@@ -184,7 +187,7 @@
if (ch == '{') {
prev = 0;
break;
- }
+ }
buf.append('$');
buf.append(ch);
prev = 0;
@@ -220,7 +223,7 @@
StringBuffer buf = new StringBuffer();
buf.append(ch);
while ((ch = peekChar()) != -1 &&
- Character.isJavaIdentifierPart(ch)) {
+ Character.isJavaIdentifierPart(ch)) {
buf.append(ch);
nextChar();
}
@@ -281,14 +284,14 @@
private char nextChar() {
if (index >= expression.length()) {
- return (char)-1;
+ return (char) -1;
}
return expression.charAt(index++);
}
private char peekChar() {
if (index >= expression.length()) {
- return (char)-1;
+ return (char) -1;
}
return expression.charAt(index);
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ErrorDispatcher.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ErrorDispatcher.java
index 4488db4..091efdd 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ErrorDispatcher.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ErrorDispatcher.java
@@ -29,12 +29,12 @@
/**
* Class responsible for dispatching JSP parse and javac compilation errors
* to the configured error handler.
- *
+ * <p/>
* This class is also responsible for localizing any error codes before they
* are passed on to the configured error handler.
- *
+ * <p/>
* In the case of a Java compilation error, the compiler error message is
- * parsed into an array of JavacErrorDetail instances, which is passed on to
+ * parsed into an array of JavacErrorDetail instances, which is passed on to
* the configured error handler.
*
* @author Jan Luehe
@@ -56,8 +56,8 @@
* otherwise
*/
public ErrorDispatcher(boolean jspcMode) {
- // XXX check web.xml for custom error handler
- errHandler = new DefaultErrorHandler();
+ // XXX check web.xml for custom error handler
+ errHandler = new DefaultErrorHandler();
this.jspcMode = jspcMode;
}
@@ -71,7 +71,7 @@
* @param errCode Error code
*/
public void jspError(String errCode) throws JasperException {
- dispatch(null, errCode, null, null);
+ dispatch(null, errCode, null, null);
}
/*
@@ -85,7 +85,7 @@
* @param errCode Error code
*/
public void jspError(Mark where, String errCode) throws JasperException {
- dispatch(where, errCode, null, null);
+ dispatch(where, errCode, null, null);
}
/*
@@ -99,7 +99,7 @@
* @param errCode Error code
*/
public void jspError(Node n, String errCode) throws JasperException {
- dispatch(n.getStart(), errCode, null, null);
+ dispatch(n.getStart(), errCode, null, null);
}
/*
@@ -113,7 +113,7 @@
* @param arg Argument for parametric replacement
*/
public void jspError(String errCode, String arg) throws JasperException {
- dispatch(null, errCode, new Object[] {arg}, null);
+ dispatch(null, errCode, new Object[]{arg}, null);
}
/*
@@ -128,8 +128,8 @@
* @param arg Argument for parametric replacement
*/
public void jspError(Mark where, String errCode, String arg)
- throws JasperException {
- dispatch(where, errCode, new Object[] {arg}, null);
+ throws JasperException {
+ dispatch(where, errCode, new Object[]{arg}, null);
}
/*
@@ -144,8 +144,8 @@
* @param arg Argument for parametric replacement
*/
public void jspError(Node n, String errCode, String arg)
- throws JasperException {
- dispatch(n.getStart(), errCode, new Object[] {arg}, null);
+ throws JasperException {
+ dispatch(n.getStart(), errCode, new Object[]{arg}, null);
}
/*
@@ -160,8 +160,8 @@
* @param arg2 Second argument for parametric replacement
*/
public void jspError(String errCode, String arg1, String arg2)
- throws JasperException {
- dispatch(null, errCode, new Object[] {arg1, arg2}, null);
+ throws JasperException {
+ dispatch(null, errCode, new Object[]{arg1, arg2}, null);
}
/*
@@ -177,8 +177,8 @@
* @param arg3 Third argument for parametric replacement
*/
public void jspError(String errCode, String arg1, String arg2, String arg3)
- throws JasperException {
- dispatch(null, errCode, new Object[] {arg1, arg2, arg3}, null);
+ throws JasperException {
+ dispatch(null, errCode, new Object[]{arg1, arg2, arg3}, null);
}
/*
@@ -194,8 +194,8 @@
* @param arg2 Second argument for parametric replacement
*/
public void jspError(Mark where, String errCode, String arg1, String arg2)
- throws JasperException {
- dispatch(where, errCode, new Object[] {arg1, arg2}, null);
+ throws JasperException {
+ dispatch(where, errCode, new Object[]{arg1, arg2}, null);
}
/*
@@ -214,8 +214,8 @@
public void jspError(Mark where, String errCode, String arg1, String arg2,
String arg3)
- throws JasperException {
- dispatch(where, errCode, new Object[] {arg1, arg2, arg3}, null);
+ throws JasperException {
+ dispatch(where, errCode, new Object[]{arg1, arg2, arg3}, null);
}
/*
@@ -232,8 +232,8 @@
*/
public void jspError(Node n, String errCode, String arg1, String arg2)
- throws JasperException {
- dispatch(n.getStart(), errCode, new Object[] {arg1, arg2}, null);
+ throws JasperException {
+ dispatch(n.getStart(), errCode, new Object[]{arg1, arg2}, null);
}
/*
@@ -252,8 +252,8 @@
public void jspError(Node n, String errCode, String arg1, String arg2,
String arg3)
- throws JasperException {
- dispatch(n.getStart(), errCode, new Object[] {arg1, arg2, arg3}, null);
+ throws JasperException {
+ dispatch(n.getStart(), errCode, new Object[]{arg1, arg2, arg3}, null);
}
/*
@@ -262,7 +262,7 @@
* @param e Parsing exception
*/
public void jspError(Exception e) throws JasperException {
- dispatch(null, null, null, e);
+ dispatch(null, null, null, e);
}
/*
@@ -277,8 +277,8 @@
* @param e Parsing exception
*/
public void jspError(String errCode, String arg, Exception e)
- throws JasperException {
- dispatch(null, errCode, new Object[] {arg}, e);
+ throws JasperException {
+ dispatch(null, errCode, new Object[]{arg}, e);
}
/*
@@ -294,8 +294,8 @@
* @param e Parsing exception
*/
public void jspError(Node n, String errCode, String arg, Exception e)
- throws JasperException {
- dispatch(n.getStart(), errCode, new Object[] {arg}, e);
+ throws JasperException {
+ dispatch(n.getStart(), errCode, new Object[]{arg}, e);
}
/**
@@ -303,19 +303,18 @@
* 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
- *
+ * @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
+ * message does not contain any compilation error line numbers
*/
public static JavacErrorDetail[] parseJavacErrors(String errMsg,
String fname,
Node.Nodes page)
throws JasperException, IOException {
- return parseJavacMessage(errMsg, fname, page);
+ return parseJavacMessage(errMsg, fname, page);
}
/*
@@ -339,7 +338,7 @@
* @param e Compilation exception
*/
public void javacError(String errorReport, Exception e)
- throws JasperException {
+ throws JasperException {
errHandler.javacError(errorReport, e);
}
@@ -360,24 +359,25 @@
* @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;
+ 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();
- }
+ // Localize
+ if (errCode != null) {
+ errMsg = Localizer.getMessage(errCode, args);
+ } else if (e != null) {
+ // give a hint about what's wrong
+ errMsg = e.getMessage();
+ }
- // Get error location
- if (where != null) {
+ // Get error location
+ if (where != null) {
if (jspcMode) {
// Get the full URL of the resource that caused the error
try {
@@ -391,23 +391,23 @@
// disclose any local filesystem details
file = where.getFile();
}
- line = where.getLineNumber();
- column = where.getColumnNumber();
- hasLocation = true;
- }
+ 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();
- }
+ // 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);
- }
+ if (hasLocation) {
+ errHandler.jspError(file, line, column, errMsg, nestedEx);
+ } else {
+ errHandler.jspError(errMsg, nestedEx);
+ }
}
/*
@@ -427,69 +427,69 @@
* compilation errors
*/
private static JavacErrorDetail[] parseJavacMessage(
- String errMsg, String fname, Node.Nodes page)
- throws IOException, JasperException {
+ String errMsg, String fname, Node.Nodes page)
+ throws IOException, JasperException {
Vector errVec = new Vector();
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.
- */
+ * 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);
+ * 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
errVec.add(javacError);
}
-
+
String lineNumStr = line.substring(beginColon + 1, endColon);
try {
lineNum = Integer.parseInt(lineNumStr);
} catch (NumberFormatException e) {
// XXX
}
-
+
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) {
errVec.add(javacError);
- }
-
+ }
+
reader.close();
-
+
JavacErrorDetail[] errDetails = null;
if (errVec.size() > 0) {
errDetails = new JavacErrorDetail[errVec.size()];
errVec.copyInto(errDetails);
}
-
+
return errDetails;
}
@@ -503,10 +503,11 @@
* @throws JasperException
*/
public static JavacErrorDetail createJavacError(String fname,
- Node.Nodes page,
- StringBuffer errMsgBuf, int lineNum) throws JasperException {
+ Node.Nodes page,
+ StringBuffer errMsgBuf, int lineNum) throws JasperException {
return createJavacError(fname, page, errMsgBuf, lineNum, null);
}
+
/**
* @param fname
* @param page
@@ -517,9 +518,9 @@
* @throws JasperException
*/
public static JavacErrorDetail createJavacError(String fname,
- Node.Nodes page,
- StringBuffer errMsgBuf, int lineNum, JspCompilationContext ctxt)
- throws JasperException {
+ 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);
@@ -534,7 +535,7 @@
lineNum,
errNode.getStart().getFile(),
errNode.getStart().getLineNumber() + lineNum -
- errVisitor.getJspSourceNode().getBeginJavaLine(),
+ errVisitor.getJspSourceNode().getBeginJavaLine(),
errMsgBuf,
ctxt);
} else {
@@ -575,40 +576,40 @@
*/
static class ErrorVisitor extends Node.Visitor {
- // Java source line number to be mapped
- private int lineNum;
+ // Java source line number to be mapped
+ private int lineNum;
- /*
- * JSP node whose Java source code range in the generated servlet
- * contains the Java source line number to be mapped
- */
- Node found;
+ /*
+ * 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;
- }
+ /*
+ * Constructor.
+ *
+ * @param lineNum Source line number in the generated servlet code
+ */
+ public ErrorVisitor(int lineNum) {
+ this.lineNum = lineNum;
}
- /*
- * Gets the JSP node to which the source line number in the generated
- * servlet code was mapped.
- *
- * @return JSP node to which the source line number in the generated
- * servlet code was mapped
- */
- public Node getJspSourceNode() {
- return found;
- }
+ public void doVisit(Node n) throws JasperException {
+ if ((lineNum >= n.getBeginJavaLine())
+ && (lineNum < n.getEndJavaLine())) {
+ found = n;
+ }
+ }
+
+ /*
+ * Gets the JSP node to which the source line number in the generated
+ * servlet code was mapped.
+ *
+ * @return JSP node to which the source line number in the generated
+ * servlet code was mapped
+ */
+ public Node getJspSourceNode() {
+ return found;
+ }
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ErrorHandler.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ErrorHandler.java
index 7db0982..63f2153 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ErrorHandler.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ErrorHandler.java
@@ -21,7 +21,7 @@
/**
* Interface for handling JSP parse and javac compilation errors.
- *
+ * <p/>
* 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
@@ -35,39 +35,39 @@
/**
* 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 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
*/
public void jspError(String fname, int line, int column, String msg,
- Exception exception) throws JasperException;
+ Exception exception) throws JasperException;
/**
* Processes the given JSP parse error.
*
- * @param msg Parse error message
+ * @param msg Parse error message
* @param exception Parse exception
*/
public void jspError(String msg, Exception exception)
- throws JasperException;
+ throws JasperException;
/**
* Processes the given javac compilation errors.
*
* @param details Array of JavacErrorDetail instances corresponding to the
- * compilation errors
+ * compilation errors
*/
public void javacError(JavacErrorDetail[] details)
- throws JasperException;
+ throws JasperException;
/**
* Processes the given javac error report and exception.
*
* @param errorReport Compilation error report
- * @param exception Compilation exception
+ * @param exception Compilation exception
*/
public void javacError(String errorReport, Exception exception)
- throws JasperException;
+ throws JasperException;
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Generator.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Generator.java
index 4967fb0..0b3eef9 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Generator.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Generator.java
@@ -44,8 +44,8 @@
* @author Mandar Raje
* @author Rajiv Mordani
* @author Pierre Delisle
- *
- * Tomcat 4.1.x and Tomcat 5:
+ * <p/>
+ * Tomcat 4.1.x and Tomcat 5:
* @author Kin-man Chung
* @author Jan Luehe
* @author Shawn Bayern
@@ -55,7 +55,7 @@
class Generator {
- private static final Class[] OBJECT_CLASS = { Object.class };
+ private static final Class[] OBJECT_CLASS = {Object.class};
private ServletWriter out;
private ArrayList methodsBuffered;
private FragmentHelperClass fragmentHelperClass;
@@ -197,7 +197,7 @@
* Compiles list of tag handler pool names.
*/
private void compileTagHandlerPoolList(Node.Nodes page)
- throws JasperException {
+ throws JasperException {
class TagHandlerPoolVisitor extends Node.Visitor {
@@ -221,11 +221,11 @@
if (!n.implementsSimpleTag()) {
String name =
- createTagHandlerPoolName(
- n.getPrefix(),
- n.getLocalName(),
- n.getAttributes(),
- n.hasEmptyBody());
+ createTagHandlerPoolName(
+ n.getPrefix(),
+ n.getLocalName(),
+ n.getAttributes(),
+ n.hasEmptyBody());
n.setTagHandlerPoolName(name);
if (!names.contains(name)) {
names.add(name);
@@ -241,10 +241,10 @@
* @return The name of the tag handler pool
*/
private String createTagHandlerPoolName(
- String prefix,
- String shortName,
- Attributes attrs,
- boolean hasEmptyBody) {
+ String prefix,
+ String shortName,
+ Attributes attrs,
+ boolean hasEmptyBody) {
String poolName = null;
poolName = "_jspx_tagPool_" + prefix + "_" + shortName;
@@ -272,7 +272,7 @@
}
private void declareTemporaryScriptingVars(Node.Nodes page)
- throws JasperException {
+ throws JasperException {
class ScriptingVarVisitor extends Node.Visitor {
@@ -292,10 +292,10 @@
for (int i = 0; i < varInfos.length; i++) {
String varName = varInfos[i].getVarName();
String tmpVarName =
- "_jspx_"
- + varName
- + "_"
- + n.getCustomNestingLevel();
+ "_jspx_"
+ + varName
+ + "_"
+ + n.getCustomNestingLevel();
if (!vars.contains(tmpVarName)) {
vars.add(tmpVarName);
out.printin(varInfos[i].getClassName());
@@ -311,19 +311,19 @@
String varName = tagVarInfos[i].getNameGiven();
if (varName == null) {
varName =
- n.getTagData().getAttributeString(
- tagVarInfos[i].getNameFromAttribute());
+ n.getTagData().getAttributeString(
+ tagVarInfos[i].getNameFromAttribute());
} else if (
- tagVarInfos[i].getNameFromAttribute()
- != null) {
+ tagVarInfos[i].getNameFromAttribute()
+ != null) {
// alias
continue;
}
String tmpVarName =
- "_jspx_"
- + varName
- + "_"
- + n.getCustomNestingLevel();
+ "_jspx_"
+ + varName
+ + "_"
+ + n.getCustomNestingLevel();
if (!vars.contains(tmpVarName)) {
vars.add(tmpVarName);
out.printin(tagVarInfos[i].getClassName());
@@ -359,9 +359,9 @@
out.pushIndent();
for (int i = 0; i < tagHandlerPoolNames.size(); i++) {
- out.printin((String)tagHandlerPoolNames.elementAt(i));
+ out.printin((String) tagHandlerPoolNames.elementAt(i));
out.print(
- " = org.apache.struts2.jasper.runtime.TagHandlerPool.getTagHandlerPool(");
+ " = org.apache.struts2.jasper.runtime.TagHandlerPool.getTagHandlerPool(");
if (ctxt.isTagFile()) {
out.print("config");
} else {
@@ -383,7 +383,7 @@
out.printil("public void _jspDestroy() {");
out.pushIndent();
for (int i = 0; i < tagHandlerPoolNames.size(); i++) {
- out.printin((String)tagHandlerPoolNames.elementAt(i));
+ out.printin((String) tagHandlerPoolNames.elementAt(i));
out.println(".release();");
}
out.popIndent();
@@ -396,7 +396,7 @@
* (shared by servlet and tag handler preamble generation)
*/
private void genPreamblePackage(String packageName)
- throws JasperException {
+ throws JasperException {
if (!"".equals(packageName) && packageName != null) {
out.printil("package " + packageName + ";");
out.println();
@@ -411,7 +411,7 @@
Iterator iter = pageInfo.getImports().iterator();
while (iter.hasNext()) {
out.printin("import ");
- out.print((String)iter.next());
+ out.print((String) iter.next());
out.println(";");
}
out.println();
@@ -436,7 +436,7 @@
out.println(");");
while (iter.hasNext()) {
out.printin("_jspx_dependants.add(\"");
- out.print((String)iter.next());
+ out.print((String) iter.next());
out.println("\");");
}
out.popIndent();
@@ -451,13 +451,13 @@
* (shared by servlet and tag handler preamble generation)
*/
private void genPreambleClassVariableDeclarations(String className)
- throws JasperException {
+ 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)
- + ";");
+ "private org.apache.struts2.jasper.runtime.TagHandlerPool "
+ + tagHandlerPoolNames.elementAt(i)
+ + ";");
}
out.println();
}
@@ -503,7 +503,7 @@
out.print(" extends ");
out.println(pageInfo.getExtends());
out.printin(
- " implements org.apache.struts2.jasper.runtime.JspSourceDependent");
+ " implements org.apache.struts2.jasper.runtime.JspSourceDependent");
if (!pageInfo.isThreadSafe()) {
out.println(",");
out.printin(" SingleThreadModel");
@@ -530,7 +530,7 @@
out.printin("public void ");
out.print(serviceMethodName);
out.println(
- "(HttpServletRequest request, HttpServletResponse response)");
+ "(HttpServletRequest request, HttpServletResponse response)");
out.println(" throws java.io.IOException, ServletException {");
out.pushIndent();
@@ -544,11 +544,11 @@
if (pageInfo.isErrorPage()) {
out.printil(
- "Throwable exception = org.apache.struts2.jasper.runtime.JspRuntimeLibrary.getThrowable(request);");
+ "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);");
+ "response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);");
out.popIndent();
out.printil("}");
}
@@ -579,7 +579,7 @@
}
out.printil(
- "pageContext = _jspxFactory.getPageContext(this, request, response,");
+ "pageContext = _jspxFactory.getPageContext(this, request, response,");
out.printin("\t\t\t");
out.print(quote(pageInfo.getErrorPage()));
out.print(", " + pageInfo.isSession());
@@ -613,16 +613,16 @@
*/
String omitXmlDecl = pageInfo.getOmitXmlDecl();
if ((omitXmlDecl != null && !JspUtil.booleanValue(omitXmlDecl))
- || (omitXmlDecl == null
+ || (omitXmlDecl == null
&& page.getRoot().isXmlSyntax()
&& !pageInfo.hasJspRoot()
&& !ctxt.isTagFile())) {
String cType = pageInfo.getContentType();
String charSet = cType.substring(cType.indexOf("charset=") + 8);
out.printil(
- "out.write(\"<?xml version=\\\"1.0\\\" encoding=\\\""
- + charSet
- + "\\\"?>\\n\");");
+ "out.write(\"<?xml version=\\\"1.0\\\" encoding=\\\""
+ + charSet
+ + "\\\"?>\\n\");");
}
/*
@@ -697,12 +697,12 @@
* Constructor.
*/
public GenerateVisitor(
- boolean isTagFile,
- ServletWriter out,
- ArrayList methodsBuffered,
- FragmentHelperClass fragmentHelperClass,
- ClassLoader loader,
- TagInfo tagInfo) {
+ boolean isTagFile,
+ ServletWriter out,
+ ArrayList methodsBuffered,
+ FragmentHelperClass fragmentHelperClass,
+ ClassLoader loader,
+ TagInfo tagInfo) {
this.isTagFile = isTagFile;
this.out = out;
@@ -724,15 +724,15 @@
* 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 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)
+ * (ignored for attributes that aren't EL expressions)
*/
private String attributeValue(
- Node.JspAttribute attr,
- boolean encode,
- Class expectedType) {
+ Node.JspAttribute attr,
+ boolean encode,
+ Class expectedType) {
String v = attr.getValue();
if (!attr.isNamedAttribute() && (v == null))
return "";
@@ -740,27 +740,27 @@
if (attr.isExpression()) {
if (encode) {
return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.URLEncode(String.valueOf("
- + v
- + "), request.getCharacterEncoding())";
+ + v
+ + "), request.getCharacterEncoding())";
}
return v;
} else if (attr.isELInterpreterInput()) {
boolean replaceESC = v.indexOf(Constants.HACK_CHAR) > 0;
v =
- JspUtil.interpreterCall(
- this.isTagFile,
- v,
- expectedType,
- attr.getEL().getMapName(),
- false);
+ JspUtil.interpreterCall(
+ this.isTagFile,
+ v,
+ expectedType,
+ attr.getEL().getMapName(),
+ false);
// XXX hack replacement
if (replaceESC) {
v = "(" + v + ").replace(" + Constants.HACK_STR + ", '$')";
}
if (encode) {
return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.URLEncode("
- + v
- + ", request.getCharacterEncoding())";
+ + v
+ + ", request.getCharacterEncoding())";
}
return v;
} else if (attr.isNamedAttribute()) {
@@ -768,8 +768,8 @@
} else {
if (encode) {
return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.URLEncode("
- + quote(v)
- + ", request.getCharacterEncoding())";
+ + quote(v)
+ + ", request.getCharacterEncoding())";
}
return quote(v);
}
@@ -782,7 +782,7 @@
* @param n the parent node for the param action nodes.
*/
private void printParams(Node n, String pageParam, boolean literal)
- throws JasperException {
+ throws JasperException {
class ParamVisitor extends Node.Visitor {
String separator;
@@ -797,10 +797,10 @@
out.print(separator);
out.print(" + ");
out.print(
- "org.apache.struts2.jasper.runtime.JspRuntimeLibrary."
- + "URLEncode("
- + quote(n.getTextAttribute("name"))
- + ", request.getCharacterEncoding())");
+ "org.apache.struts2.jasper.runtime.JspRuntimeLibrary."
+ + "URLEncode("
+ + quote(n.getTextAttribute("name"))
+ + ", request.getCharacterEncoding())");
out.print("+ \"=\" + ");
out.print(attributeValue(n.getValue(), true, String.class));
@@ -839,19 +839,19 @@
n.setBeginJavaLine(out.getJavaLine());
if (!pageInfo.isELIgnored()) {
out.printil(
- "out.write("
- + JspUtil.interpreterCall(
- this.isTagFile,
- "${" + new String(n.getText()) + "}",
- String.class,
- n.getEL().getMapName(),
- false)
- + ");");
+ "out.write("
+ + JspUtil.interpreterCall(
+ this.isTagFile,
+ "${" + new String(n.getText()) + "}",
+ String.class,
+ n.getEL().getMapName(),
+ false)
+ + ");");
} else {
out.printil(
- "out.write("
- + quote("${" + new String(n.getText()) + "}")
- + ");");
+ "out.write("
+ + quote("${" + new String(n.getText()) + "}")
+ + ");");
}
n.setEndJavaLine(out.getJavaLine());
}
@@ -873,7 +873,7 @@
// jsp:attribute, first generate code to evaluate
// that body.
pageParam =
- generateNamedAttributeValue(page.getNamedAttributeNode());
+ generateNamedAttributeValue(page.getNamedAttributeNode());
} else {
pageParam = attributeValue(page, false, String.class);
}
@@ -889,7 +889,7 @@
out.printin(
JSPRuntime.class.getName() + ".handle("
- + pageParam);
+ + pageParam);
printParams(n, pageParam, page.isLiteral());
out.println(", " + isFlush + ");");
@@ -901,7 +901,7 @@
* <param> subelements. For each <param> element, if its value
* is specified via a Named Attribute (<jsp:attribute>),
* generate the code to evaluate those bodies first.
- * <p>
+ * <p/>
* If parent is null, simply returns.
*/
private void prepareParams(Node parent) throws JasperException {
@@ -915,13 +915,13 @@
if (n instanceof Node.ParamAction) {
Node.Nodes paramSubElements = n.getBody();
for (int j = 0;
- (paramSubElements != null)
- && (j < paramSubElements.size());
- j++) {
+ (paramSubElements != null)
+ && (j < paramSubElements.size());
+ j++) {
Node m = paramSubElements.getNode(j);
if (m instanceof Node.NamedAttribute) {
generateNamedAttributeValue(
- (Node.NamedAttribute)m);
+ (Node.NamedAttribute) m);
}
}
}
@@ -938,11 +938,11 @@
Node.Nodes subelements = parent.getBody();
for (int i = 0;
- (subelements != null) && (i < subelements.size());
- i++) {
+ (subelements != null) && (i < subelements.size());
+ i++) {
Node n = subelements.getNode(i);
if (n instanceof Node.JspBody) {
- result = (Node.JspBody)n;
+ result = (Node.JspBody) n;
break;
}
}
@@ -964,7 +964,7 @@
// jsp:attribute, first generate code to evaluate
// that body.
pageParam =
- generateNamedAttributeValue(page.getNamedAttributeNode());
+ generateNamedAttributeValue(page.getNamedAttributeNode());
} else {
pageParam = attributeValue(page, false, String.class);
}
@@ -1005,30 +1005,30 @@
Class bean = beanInfo.getBeanType(name);
String beanName = JspUtil.getCanonicalName(bean);
java.lang.reflect.Method meth =
- JspRuntimeLibrary.getReadMethod(bean, property);
+ 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
- + "())));");
+ "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
- + "\")));");
+ "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());
@@ -1044,34 +1044,34 @@
if ("*".equals(property)) {
out.printil(
- "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.introspect("
- + "_jspx_page_context.findAttribute("
- + "\""
- + name
- + "\"), request);");
+ "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);");
+ "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
- + "\",");
+ "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()) {
@@ -1089,40 +1089,40 @@
// - '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()
- + ");");
+ "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());
+ generateNamedAttributeValue(value.getNamedAttributeNode());
out.printil(
- "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.introspecthelper("
- + "_jspx_page_context.findAttribute(\""
- + name
- + "\"), \""
- + property
- + "\", "
- + valueVarName
- + ", null, null, false);");
+ "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
- + "\", ");
+ "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.introspecthelper("
+ + "_jspx_page_context.findAttribute(\""
+ + name
+ + "\"), \""
+ + property
+ + "\", ");
out.print(attributeValue(value, false, null));
out.println(", null, null, false);");
}
@@ -1144,7 +1144,7 @@
if (klass != null) {
try {
Class bean = ctxt.getClassLoader().loadClass(klass);
- if (klass.indexOf('$') >= 0) {
+ if (klass.indexOf('$') >= 0) {
// Obtain the canonical type name
canonicalName = JspUtil.getCanonicalName(bean);
} else {
@@ -1152,12 +1152,12 @@
}
int modifiers = bean.getModifiers();
if (!Modifier.isPublic(modifiers) ||
- Modifier.isInterface(modifiers) ||
- Modifier.isAbstract(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[] {});
+ 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.
@@ -1166,13 +1166,13 @@
// Cannot instantiate the specified class, either a
// compilation error or a runtime error will be raised,
// depending on a compiler flag.
- if(ctxt.getOptions().getErrorOnUseBeanInvalidClassAttribute()) {
+ if (ctxt.getOptions().getErrorOnUseBeanInvalidClassAttribute()) {
err.jspError(n, "jsp.error.invalid.bean", klass);
}
if (canonicalName == null) {
// Doing our best here to get a canonical name
// from the binary name, should work 99.99% of time.
- canonicalName = klass.replace('$','.');
+ canonicalName = klass.replace('$', '.');
}
}
if (type == null) {
@@ -1233,7 +1233,7 @@
* must be found locally, otherwise it's an error
*/
out.printin(
- "throw new java.lang.InstantiationException(\"bean ");
+ "throw new java.lang.InstantiationException(\"bean ");
out.print(name);
out.println(" not found within scope\");");
} else {
@@ -1248,11 +1248,11 @@
// jsp:attribute, first generate code to evaluate
// that body.
binaryName =
- generateNamedAttributeValue(
- beanName.getNamedAttributeNode());
+ generateNamedAttributeValue(
+ beanName.getNamedAttributeNode());
} else {
binaryName =
- attributeValue(beanName, false, String.class);
+ attributeValue(beanName, false, String.class);
}
} else {
// Implies klass is not null
@@ -1275,7 +1275,7 @@
out.printil("} catch (ClassNotFoundException exc) {");
out.pushIndent();
out.printil(
- "throw new InstantiationException(exc.getMessage());");
+ "throw new InstantiationException(exc.getMessage());");
out.popIndent();
out.printil("} catch (Exception exc) {");
out.pushIndent();
@@ -1359,27 +1359,27 @@
// out.println( "<param name=\"blah\"
// value=\"" + ... + "\">" );
out.printil(
- "out.write( \"<param name=\\\""
- + escape(name)
- + "\\\" value=\\\"\" + "
- + attributeValue(
- n.getValue(),
- false,
- String.class)
- + " + \"\\\">\" );");
+ "out.write( \"<param name=\\\""
+ + escape(name)
+ + "\\\" value=\\\"\" + "
+ + attributeValue(
+ n.getValue(),
+ false,
+ String.class)
+ + " + \"\\\">\" );");
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)
- + " + \"\\\"\" );");
+ "out.write( \" "
+ + escape(name)
+ + "=\\\"\" + "
+ + attributeValue(
+ n.getValue(),
+ false,
+ String.class)
+ + " + \"\\\"\" );");
}
n.setEndJavaLine(out.getJavaLine());
@@ -1404,8 +1404,8 @@
if (width != null) {
if (width.isNamedAttribute()) {
widthStr =
- generateNamedAttributeValue(
- width.getNamedAttributeNode());
+ generateNamedAttributeValue(
+ width.getNamedAttributeNode());
} else {
widthStr = attributeValue(width, false, String.class);
}
@@ -1415,8 +1415,8 @@
if (height != null) {
if (height.isNamedAttribute()) {
heightStr =
- generateNamedAttributeValue(
- height.getNamedAttributeNode());
+ generateNamedAttributeValue(
+ height.getNamedAttributeNode());
} else {
heightStr = attributeValue(height, false, String.class);
}
@@ -1474,7 +1474,7 @@
// Then print the output string to the java file
out.printil(
- "out.write(" + quote(s0) + s1 + s2 + " + " + quote(s3) + ");");
+ "out.write(" + quote(s0) + s1 + s2 + " + " + quote(s3) + ");");
out.printil("out.write(\"\\n\");");
// <param > for java_code
@@ -1503,13 +1503,13 @@
// <param > for type
s0 = "<param name=\"type\""
+ makeAttr(
- "value",
- "application/x-java-"
+ "value",
+ "application/x-java-"
+ type
+ ";"
+ ((jreversion == null)
- ? ""
- : "version=" + jreversion))
+ ? ""
+ : "version=" + jreversion))
+ '>';
out.printil("out.write(" + quote(s0) + ");");
out.printil("out.write(\"\\n\");");
@@ -1527,13 +1527,13 @@
out.printil("out.write(\"\\n\");");
s0 = "<embed"
+ makeAttr(
- "type",
- "application/x-java-"
+ "type",
+ "application/x-java-"
+ type
+ ";"
+ ((jreversion == null)
- ? ""
- : "version=" + jreversion))
+ ? ""
+ : "version=" + jreversion))
+ makeAttr("name", name);
// s1 and s2 are the same as before.
@@ -1546,7 +1546,7 @@
+ makeAttr("java_codebase", codebase)
+ makeAttr("java_archive", archive);
out.printil(
- "out.write(" + quote(s0) + s1 + s2 + " + " + quote(s3) + ");");
+ "out.write(" + quote(s0) + s1 + s2 + " + " + quote(s3) + ");");
/*
* Generate a 'attr = "value"' for each <jsp:param> in plugin body
@@ -1596,7 +1596,7 @@
// Create variable names
String baseVar =
- createTagVarName(n.getQName(), n.getPrefix(), n.getLocalName());
+ createTagVarName(n.getQName(), n.getPrefix(), n.getLocalName());
String tagEvalVar = "_jspx_eval_" + baseVar;
String tagHandlerVar = "_jspx_th_" + baseVar;
String tagPushBodyCountVar = "_jspx_push_body_count_" + baseVar;
@@ -1638,7 +1638,7 @@
adjustments.
*/
GenBuffer genBuffer =
- new GenBuffer(n, n.implementsSimpleTag()? null: n.getBody());
+ new GenBuffer(n, n.implementsSimpleTag() ? null : n.getBody());
methodsBuffered.add(genBuffer);
out = genBuffer.getOut();
@@ -1664,7 +1664,7 @@
out.pushIndent();
// Initilaize local variables used in this method.
- if (! isTagFile) {
+ if (!isTagFile) {
out.printil("PageContext pageContext = _jspx_page_context;");
}
out.printil("JspWriter out = _jspx_page_context.getOut();");
@@ -1679,11 +1679,11 @@
* and end element
*/
generateCustomStart(
- n,
- handlerInfo,
- tagHandlerVar,
- tagEvalVar,
- tagPushBodyCountVar);
+ n,
+ handlerInfo,
+ tagHandlerVar,
+ tagEvalVar,
+ tagPushBodyCountVar);
// visit body
String tmpParent = parent;
@@ -1708,10 +1708,10 @@
isSimpleTagHandler = tmpIsSimpleTagHandler;
generateCustomEnd(
- n,
- tagHandlerVar,
- tagEvalVar,
- tagPushBodyCountVar);
+ n,
+ tagHandlerVar,
+ tagEvalVar,
+ tagPushBodyCountVar);
}
if (ci.isScriptless() && !ci.hasScriptingVars()) {
@@ -1813,32 +1813,32 @@
String attrStr = null;
if (attrs[i].isNamedAttribute()) {
attrStr =
- generateNamedAttributeValue(
- attrs[i].getNamedAttributeNode());
+ generateNamedAttributeValue(
+ attrs[i].getNamedAttributeNode());
} else {
attrStr = attributeValue(attrs[i], false, Object.class);
}
String s =
- " + \" "
- + attrs[i].getName()
- + "=\\\"\" + "
- + attrStr
- + " + \"\\\"\"";
+ " + \" "
+ + attrs[i].getName()
+ + "=\\\"\" + "
+ + attrStr
+ + " + \"\\\"\"";
map.put(attrs[i].getName(), s);
}
// Write begin tag, using XML-style 'name' attribute as the
// element name
String elemName =
- attributeValue(n.getNameAttribute(), false, String.class);
+ attributeValue(n.getNameAttribute(), false, String.class);
out.printin("out.write(\"<\"");
out.print(" + " + elemName);
// Write remaining attributes
Enumeration enumeration = map.keys();
while (enumeration.hasMoreElements()) {
- String attrName = (String)enumeration.nextElement();
- out.print((String)map.get(attrName));
+ String attrName = (String) enumeration.nextElement();
+ out.print((String) map.get(attrName));
}
// Does the <jsp:element> have nested tags other than
@@ -1894,25 +1894,25 @@
}
if (textSize <= 3) {
- // Special case small text strings
- n.setBeginJavaLine(out.getJavaLine());
- int lineInc = 0;
- for (int i = 0; i < textSize; i++) {
- char ch = text.charAt(i);
- out.printil("out.write(" + quote(ch) + ");");
- if (i > 0) {
- n.addSmap(lineInc);
- }
- if (ch == '\n') {
- lineInc++;
- }
- }
- n.setEndJavaLine(out.getJavaLine());
- return;
- }
+ // Special case small text strings
+ n.setBeginJavaLine(out.getJavaLine());
+ int lineInc = 0;
+ for (int i = 0; i < textSize; i++) {
+ char ch = text.charAt(i);
+ out.printil("out.write(" + quote(ch) + ");");
+ if (i > 0) {
+ n.addSmap(lineInc);
+ }
+ if (ch == '\n') {
+ lineInc++;
+ }
+ }
+ n.setEndJavaLine(out.getJavaLine());
+ return;
+ }
if (ctxt.getOptions().genStringAsCharArray()) {
- // Generate Strings as char arrays, for performance
+ // Generate Strings as char arrays, for performance
ServletWriter caOut;
if (charArrayBuffer == null) {
charArrayBuffer = new GenBuffer();
@@ -1950,16 +1950,16 @@
char ch = text.charAt(i);
--count;
switch (ch) {
- case '"' :
+ case '"':
sb.append('\\').append('\"');
break;
- case '\\' :
+ case '\\':
sb.append('\\').append('\\');
break;
- case '\r' :
+ case '\r':
sb.append('\\').append('r');
break;
- case '\n' :
+ case '\n':
sb.append('\\').append('n');
srcLine++;
@@ -1976,10 +1976,10 @@
// add a Smap for this line
n.addSmap(srcLine);
break;
- case '\t' : // Not sure we need this
+ case '\t': // Not sure we need this
sb.append('\\').append('t');
break;
- default :
+ default:
sb.append(ch);
}
}
@@ -2012,7 +2012,7 @@
// Copy virtual page scope of tag file to page scope of invoking
// page
out.printil(
- "((org.apache.struts2.jasper.runtime.JspContextWrapper) this.jspContext).syncBeforeInvoke();");
+ "((org.apache.struts2.jasper.runtime.JspContextWrapper) this.jspContext).syncBeforeInvoke();");
String varReaderAttr = n.getTextAttribute("varReader");
String varAttr = n.getTextAttribute("var");
if (varReaderAttr != null || varAttr != null) {
@@ -2038,7 +2038,7 @@
if (varReaderAttr != null) {
out.print(quote(varReaderAttr));
out.print(
- ", new java.io.StringReader(_jspx_sout.toString())");
+ ", new java.io.StringReader(_jspx_sout.toString())");
} else {
out.print(quote(varAttr));
out.print(", _jspx_sout.toString()");
@@ -2060,7 +2060,7 @@
// Copy virtual page scope of tag file to page scope of invoking
// page
out.printil(
- "((org.apache.struts2.jasper.runtime.JspContextWrapper) this.jspContext).syncBeforeInvoke();");
+ "((org.apache.struts2.jasper.runtime.JspContextWrapper) this.jspContext).syncBeforeInvoke();");
// Invoke body
String varReaderAttr = n.getTextAttribute("varReader");
@@ -2082,7 +2082,7 @@
if (varReaderAttr != null) {
out.print(quote(varReaderAttr));
out.print(
- ", new java.io.StringReader(_jspx_sout.toString())");
+ ", new java.io.StringReader(_jspx_sout.toString())");
} else {
out.print(quote(varAttr));
out.print(", _jspx_sout.toString()");
@@ -2103,36 +2103,36 @@
for (int i = 0; attrs != null && i < attrs.length; i++) {
if (attrs[i].getName().equals(n.getName())) {
out.print(
- evaluateAttribute(
- getTagHandlerInfo(tag),
- attrs[i],
- tag,
- null));
+ evaluateAttribute(
+ getTagHandlerInfo(tag),
+ attrs[i],
+ tag,
+ null));
break;
}
}
}
private TagHandlerInfo getTagHandlerInfo(Node.CustomTag n)
- throws JasperException {
+ throws JasperException {
Hashtable handlerInfosByShortName =
- (Hashtable)handlerInfos.get(n.getPrefix());
+ (Hashtable) handlerInfos.get(n.getPrefix());
if (handlerInfosByShortName == null) {
handlerInfosByShortName = new Hashtable();
handlerInfos.put(n.getPrefix(), handlerInfosByShortName);
}
TagHandlerInfo handlerInfo =
- (TagHandlerInfo)handlerInfosByShortName.get(n.getLocalName());
+ (TagHandlerInfo) handlerInfosByShortName.get(n.getLocalName());
if (handlerInfo == null) {
handlerInfo =
- new TagHandlerInfo(n, n.getTagHandlerClass(), err);
+ new TagHandlerInfo(n, n.getTagHandlerClass(), err);
handlerInfosByShortName.put(n.getLocalName(), handlerInfo);
}
return handlerInfo;
}
private void generateTagPlugin(Node.CustomTag n)
- throws JasperException {
+ throws JasperException {
if (n.getAtSTag() != null) {
n.getAtSTag().visit(this);
}
@@ -2143,12 +2143,12 @@
}
private void generateCustomStart(
- Node.CustomTag n,
- TagHandlerInfo handlerInfo,
- String tagHandlerVar,
- String tagEvalVar,
- String tagPushBodyCountVar)
- throws JasperException {
+ Node.CustomTag n,
+ TagHandlerInfo handlerInfo,
+ String tagHandlerVar,
+ String tagEvalVar,
+ String tagPushBodyCountVar)
+ throws JasperException {
Class tagHandlerClass = handlerInfo.getTagHandlerClass();
@@ -2161,7 +2161,7 @@
saveScriptingVars(n, VariableInfo.AT_BEGIN);
String tagHandlerClassName =
- JspUtil.getCanonicalName(tagHandlerClass);
+ JspUtil.getCanonicalName(tagHandlerClass);
out.printin(tagHandlerClassName);
out.print(" ");
out.print(tagHandlerVar);
@@ -2214,7 +2214,7 @@
out.printin("if (");
out.print(tagEvalVar);
out.println(
- " != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {");
+ " != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {");
// Assume EVAL_BODY_BUFFERED
out.pushIndent();
out.printil("out = _jspx_page_context.pushBody();");
@@ -2227,7 +2227,7 @@
}
out.printin(tagHandlerVar);
out.println(
- ".setBodyContent((javax.servlet.jsp.tagext.BodyContent) out);");
+ ".setBodyContent((javax.servlet.jsp.tagext.BodyContent) out);");
out.printin(tagHandlerVar);
out.println(".doInitBody();");
@@ -2254,10 +2254,10 @@
}
private void generateCustomEnd(
- Node.CustomTag n,
- String tagHandlerVar,
- String tagEvalVar,
- String tagPushBodyCountVar) {
+ Node.CustomTag n,
+ String tagHandlerVar,
+ String tagEvalVar,
+ String tagPushBodyCountVar) {
if (!n.hasEmptyBody()) {
if (n.implementsIterationTag()) {
@@ -2270,7 +2270,7 @@
syncScriptingVars(n, VariableInfo.NESTED);
out.printil(
- "if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)");
+ "if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)");
out.pushIndent();
out.printil("break;");
out.popIndent();
@@ -2285,7 +2285,7 @@
out.printin("if (");
out.print(tagEvalVar);
out.println(
- " != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {");
+ " != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {");
out.pushIndent();
out.printil("out = _jspx_page_context.popBody();");
if (n.implementsTryCatchFinally()) {
@@ -2306,10 +2306,10 @@
out.printin("if (");
out.print(tagHandlerVar);
out.println(
- ".doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {");
+ ".doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {");
out.pushIndent();
- if(!n.implementsTryCatchFinally()) {
- if(isPoolingEnabled) {
+ if (!n.implementsTryCatchFinally()) {
+ if (isPoolingEnabled) {
out.printin(n.getTagHandlerPoolName());
out.print(".reuse(");
out.print(tagHandlerVar);
@@ -2375,10 +2375,10 @@
}
private void generateCustomDoTag(
- Node.CustomTag n,
- TagHandlerInfo handlerInfo,
- String tagHandlerVar)
- throws JasperException {
+ Node.CustomTag n,
+ TagHandlerInfo handlerInfo,
+ String tagHandlerVar)
+ throws JasperException {
Class tagHandlerClass = handlerInfo.getTagHandlerClass();
@@ -2391,7 +2391,7 @@
saveScriptingVars(n, VariableInfo.AT_BEGIN);
String tagHandlerClassName =
- JspUtil.getCanonicalName(tagHandlerClass);
+ JspUtil.getCanonicalName(tagHandlerClass);
out.printin(tagHandlerClassName);
out.print(" ");
out.print(tagHandlerVar);
@@ -2453,7 +2453,7 @@
for (int i = 0; i < vec.size(); i++) {
Object elem = vec.elementAt(i);
if (elem instanceof VariableInfo) {
- VariableInfo varInfo = (VariableInfo)elem;
+ VariableInfo varInfo = (VariableInfo) elem;
if (varInfo.getDeclare()) {
out.printin(varInfo.getClassName());
out.print(" ");
@@ -2461,15 +2461,15 @@
out.println(" = null;");
}
} else {
- TagVariableInfo tagVarInfo = (TagVariableInfo)elem;
+ TagVariableInfo tagVarInfo = (TagVariableInfo) elem;
if (tagVarInfo.getDeclare()) {
String varName = tagVarInfo.getNameGiven();
if (varName == null) {
varName =
- n.getTagData().getAttributeString(
- tagVarInfo.getNameFromAttribute());
+ n.getTagData().getAttributeString(
+ tagVarInfo.getNameFromAttribute());
} else if (
- tagVarInfo.getNameFromAttribute() != null) {
+ tagVarInfo.getNameFromAttribute() != null) {
// alias
continue;
}
@@ -2513,7 +2513,7 @@
continue;
String varName = varInfos[i].getVarName();
String tmpVarName =
- "_jspx_" + varName + "_" + n.getCustomNestingLevel();
+ "_jspx_" + varName + "_" + n.getCustomNestingLevel();
out.printin(tmpVarName);
out.print(" = ");
out.print(varName);
@@ -2530,14 +2530,14 @@
String varName = tagVarInfos[i].getNameGiven();
if (varName == null) {
varName =
- n.getTagData().getAttributeString(
- tagVarInfos[i].getNameFromAttribute());
+ n.getTagData().getAttributeString(
+ tagVarInfos[i].getNameFromAttribute());
} else if (tagVarInfos[i].getNameFromAttribute() != null) {
// alias
continue;
}
String tmpVarName =
- "_jspx_" + varName + "_" + n.getCustomNestingLevel();
+ "_jspx_" + varName + "_" + n.getCustomNestingLevel();
out.printin(tmpVarName);
out.print(" = ");
out.print(varName);
@@ -2574,7 +2574,7 @@
continue;
String varName = varInfos[i].getVarName();
String tmpVarName =
- "_jspx_" + varName + "_" + n.getCustomNestingLevel();
+ "_jspx_" + varName + "_" + n.getCustomNestingLevel();
out.printin(varName);
out.print(" = ");
out.print(tmpVarName);
@@ -2591,14 +2591,14 @@
String varName = tagVarInfos[i].getNameGiven();
if (varName == null) {
varName =
- n.getTagData().getAttributeString(
- tagVarInfos[i].getNameFromAttribute());
+ n.getTagData().getAttributeString(
+ tagVarInfos[i].getNameFromAttribute());
} else if (tagVarInfos[i].getNameFromAttribute() != null) {
// alias
continue;
}
String tmpVarName =
- "_jspx_" + varName + "_" + n.getCustomNestingLevel();
+ "_jspx_" + varName + "_" + n.getCustomNestingLevel();
out.printin(varName);
out.print(" = ");
out.print(tmpVarName);
@@ -2636,10 +2636,10 @@
String name = tagVarInfos[i].getNameGiven();
if (name == null) {
name =
- n.getTagData().getAttributeString(
- tagVarInfos[i].getNameFromAttribute());
+ n.getTagData().getAttributeString(
+ tagVarInfos[i].getNameFromAttribute());
} else if (
- tagVarInfos[i].getNameFromAttribute() != null) {
+ tagVarInfos[i].getNameFromAttribute() != null) {
// alias
continue;
}
@@ -2660,15 +2660,15 @@
* Identifier.
*/
private String createTagVarName(
- String fullName,
- String prefix,
- String shortName) {
+ String fullName,
+ String prefix,
+ String shortName) {
String varName;
synchronized (tagVarNumbers) {
varName = prefix + "_" + shortName + "_";
if (tagVarNumbers.get(fullName) != null) {
- Integer i = (Integer)tagVarNumbers.get(fullName);
+ Integer i = (Integer) tagVarNumbers.get(fullName);
varName = varName + i.intValue();
tagVarNumbers.put(fullName, new Integer(i.intValue() + 1));
} else {
@@ -2680,11 +2680,11 @@
}
private String evaluateAttribute(
- TagHandlerInfo handlerInfo,
- Node.JspAttribute attr,
- Node.CustomTag n,
- String tagHandlerVar)
- throws JasperException {
+ TagHandlerInfo handlerInfo,
+ Node.JspAttribute attr,
+ Node.CustomTag n,
+ String tagHandlerVar)
+ throws JasperException {
String attrValue = attr.getValue();
if (attrValue == null) {
@@ -2692,13 +2692,13 @@
if (n.checkIfAttributeIsJspFragment(attr.getName())) {
// XXX - no need to generate temporary variable here
attrValue =
- generateNamedAttributeJspFragment(
- attr.getNamedAttributeNode(),
- tagHandlerVar);
+ generateNamedAttributeJspFragment(
+ attr.getNamedAttributeNode(),
+ tagHandlerVar);
} else {
attrValue =
- generateNamedAttributeValue(
- attr.getNamedAttributeNode());
+ generateNamedAttributeValue(
+ attr.getNamedAttributeNode());
}
} else {
return null;
@@ -2715,9 +2715,9 @@
m = handlerInfo.getSetterMethod(localName);
if (m == null) {
err.jspError(
- n,
- "jsp.error.unable.to_find_method",
- attr.getName());
+ n,
+ "jsp.error.unable.to_find_method",
+ attr.getName());
}
c = m.getParameterTypes();
// XXX assert(c.length > 0)
@@ -2727,52 +2727,53 @@
// Do nothing
} else if (attr.isNamedAttribute()) {
if (!n.checkIfAttributeIsJspFragment(attr.getName())
- && !attr.isDynamic()) {
+ && !attr.isDynamic()) {
attrValue =
- convertString(
- c[0],
- attrValue,
- localName,
- handlerInfo.getPropertyEditorClass(localName),
- true);
+ convertString(
+ c[0],
+ attrValue,
+ localName,
+ handlerInfo.getPropertyEditorClass(localName),
+ true);
}
} else if (attr.isELInterpreterInput()) {
// run attrValue through the expression interpreter
boolean replaceESC = attrValue.indexOf(Constants.HACK_CHAR) > 0;
attrValue =
- JspUtil.interpreterCall(
- this.isTagFile,
- attrValue,
- c[0],
- attr.getEL().getMapName(),
- false);
+ JspUtil.interpreterCall(
+ this.isTagFile,
+ attrValue,
+ c[0],
+ attr.getEL().getMapName(),
+ false);
// XXX hack: Replace ESC with '$'
if (replaceESC) {
attrValue =
- "("
- + attrValue
- + ").replace("
- + Constants.HACK_STR
- + ", '$')";
+ "("
+ + attrValue
+ + ").replace("
+ + Constants.HACK_STR
+ + ", '$')";
}
} else {
attrValue =
- convertString(
- c[0],
- attrValue,
- localName,
- handlerInfo.getPropertyEditorClass(localName),
- false);
+ convertString(
+ c[0],
+ attrValue,
+ localName,
+ handlerInfo.getPropertyEditorClass(localName),
+ false);
}
return attrValue;
}
/**
* Generate code to create a map for the alias variables
+ *
* @return the name of the map
*/
private String generateAliasMap(Node.CustomTag n, String tagHandlerVar)
- throws JasperException {
+ throws JasperException {
TagVariableInfo[] tagVars = n.getTagVariableInfos();
String aliasMapVar = null;
@@ -2805,11 +2806,11 @@
}
private void generateSetters(
- Node.CustomTag n,
- String tagHandlerVar,
- TagHandlerInfo handlerInfo,
- boolean simpleTag)
- throws JasperException {
+ Node.CustomTag n,
+ String tagHandlerVar,
+ TagHandlerInfo handlerInfo,
+ boolean simpleTag)
+ throws JasperException {
// Set context
if (simpleTag) {
@@ -2868,7 +2869,7 @@
Node.JspAttribute[] attrs = n.getJspAttributes();
for (int i = 0; attrs != null && i < attrs.length; i++) {
String attrValue =
- evaluateAttribute(handlerInfo, attrs[i], n, tagHandlerVar);
+ evaluateAttribute(handlerInfo, attrs[i], n, tagHandlerVar);
if (attrs[i].isDynamic()) {
out.printin(tagHandlerVar);
@@ -2889,9 +2890,9 @@
out.printin(tagHandlerVar);
out.print(".");
out.print(
- handlerInfo
- .getSetterMethod(attrs[i].getLocalName())
- .getName());
+ handlerInfo
+ .getSetterMethod(attrs[i].getLocalName())
+ .getName());
out.print("(");
out.print(attrValue);
out.println(");");
@@ -2910,12 +2911,12 @@
* action), and false otherwise
*/
private String convertString(
- Class c,
- String s,
- String attrName,
- Class propEditorClass,
- boolean isNamedAttribute)
- throws JasperException {
+ Class c,
+ String s,
+ String attrName,
+ Class propEditorClass,
+ boolean isNamedAttribute)
+ throws JasperException {
String quoted = s;
if (!isNamedAttribute) {
@@ -2925,16 +2926,16 @@
if (propEditorClass != null) {
String className = JspUtil.getCanonicalName(c);
return "("
- + className
- + ")org.apache.struts2.jasper.runtime.JspRuntimeLibrary.getValueFromBeanInfoPropertyEditor("
- + className
- + ".class, \""
- + attrName
- + "\", "
- + quoted
- + ", "
- + JspUtil.getCanonicalName(propEditorClass)
- + ".class)";
+ + className
+ + ")org.apache.struts2.jasper.runtime.JspRuntimeLibrary.getValueFromBeanInfoPropertyEditor("
+ + className
+ + ".class, \""
+ + attrName
+ + "\", "
+ + quoted
+ + ", "
+ + JspUtil.getCanonicalName(propEditorClass)
+ + ".class)";
} else if (c == String.class) {
return quoted;
} else if (c == boolean.class) {
@@ -2974,14 +2975,14 @@
} else {
String className = JspUtil.getCanonicalName(c);
return "("
- + className
- + ")org.apache.struts2.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager("
- + className
- + ".class, \""
- + attrName
- + "\", "
- + quoted
- + ")";
+ + className
+ + ")org.apache.struts2.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager("
+ + className
+ + ".class, \""
+ + attrName
+ + "\", "
+ + quoted
+ + ")";
}
}
@@ -3009,7 +3010,7 @@
* argument to SimpleTag.setJspBody().
*/
private void generateJspFragment(Node n, String tagHandlerVar)
- throws JasperException {
+ throws JasperException {
// XXX - A possible optimization here would be to check to see
// if the only child of the parent node is TemplateText. If so,
// we know there won't be any parameters, etc, so we can
@@ -3017,10 +3018,10 @@
// body. The implementation of this fragment can come from
// the org.apache.struts2.jasper.runtime package as a support class.
FragmentHelperClass.Fragment fragment =
- fragmentHelperClass.openFragment(
- n,
- tagHandlerVar,
- methodNesting);
+ fragmentHelperClass.openFragment(
+ n,
+ tagHandlerVar,
+ methodNesting);
ServletWriter outSave = out;
out = fragment.getGenBuffer().getOut();
String tmpParent = parent;
@@ -3045,15 +3046,15 @@
// we're not in a place where pageContext is defined (e.g.
// in a fragment or in a tag file.
out.print(
- "new "
- + fragmentHelperClass.getClassName()
- + "( "
- + fragment.getId()
- + ", _jspx_page_context, "
- + tagHandlerVar
- + ", "
- + pushBodyCountVar
- + ")");
+ "new "
+ + fragmentHelperClass.getClassName()
+ + "( "
+ + fragment.getId()
+ + ", _jspx_page_context, "
+ + tagHandlerVar
+ + ", "
+ + pushBodyCountVar
+ + ")");
}
/**
@@ -3063,7 +3064,7 @@
* @return The name of the temporary variable the result is stored in.
*/
public String generateNamedAttributeValue(Node.NamedAttribute n)
- throws JasperException {
+ throws JasperException {
String varName = n.getTemporaryVariableName();
@@ -3080,14 +3081,14 @@
if (bodyElement instanceof Node.TemplateText) {
templateTextOptimization = true;
out.printil(
- "String "
- + varName
- + " = "
- + quote(
- new String(
- ((Node.TemplateText)bodyElement)
- .getText()))
- + ";");
+ "String "
+ + varName
+ + " = "
+ + quote(
+ new String(
+ ((Node.TemplateText) bodyElement)
+ .getText()))
+ + ";");
}
}
@@ -3098,11 +3099,11 @@
out.printil("out = _jspx_page_context.pushBody();");
visitBody(n);
out.printil(
- "String "
- + varName
- + " = "
- + "((javax.servlet.jsp.tagext.BodyContent)"
- + "out).getString();");
+ "String "
+ + varName
+ + " = "
+ + "((javax.servlet.jsp.tagext.BodyContent)"
+ + "out).getString();");
out.printil("out = _jspx_page_context.popBody();");
}
} else {
@@ -3117,20 +3118,20 @@
* Similar to generateNamedAttributeValue, but create a JspFragment
* instead.
*
- * @param n The parent node of the named attribute
+ * @param n The parent node of the named attribute
* @param tagHandlerVar The variable the tag handler is stored in,
- * so the fragment knows its parent tag.
+ * so the fragment knows its parent tag.
* @return The name of the temporary variable the fragment
- * is stored in.
+ * is stored in.
*/
public String generateNamedAttributeJspFragment(
- Node.NamedAttribute n,
- String tagHandlerVar)
- throws JasperException {
+ Node.NamedAttribute n,
+ String tagHandlerVar)
+ throws JasperException {
String varName = n.getTemporaryVariableName();
out.printin(
- "javax.servlet.jsp.tagext.JspFragment " + varName + " = ");
+ "javax.servlet.jsp.tagext.JspFragment " + varName + " = ");
generateJspFragment(n, tagHandlerVar);
out.println(";");
@@ -3139,14 +3140,14 @@
}
private static void generateLocalVariables(ServletWriter out, Node n)
- throws JasperException {
+ throws JasperException {
Node.ChildInfo ci;
if (n instanceof Node.CustomTag) {
- ci = ((Node.CustomTag)n).getChildInfo();
+ ci = ((Node.CustomTag) n).getChildInfo();
} else if (n instanceof Node.JspBody) {
- ci = ((Node.JspBody)n).getChildInfo();
+ ci = ((Node.JspBody) n).getChildInfo();
} else if (n instanceof Node.NamedAttribute) {
- ci = ((Node.NamedAttribute)n).getChildInfo();
+ ci = ((Node.NamedAttribute) n).getChildInfo();
} else {
// Cannot access err since this method is static, but at
// least flag an error.
@@ -3158,18 +3159,18 @@
if (ci.hasUseBean()) {
out.printil("HttpSession session = _jspx_page_context.getSession();");
out.printil(
- "ServletContext application = _jspx_page_context.getServletContext();");
+ "ServletContext application = _jspx_page_context.getServletContext();");
}
if (ci.hasUseBean()
- || ci.hasIncludeAction()
- || ci.hasSetProperty()
- || ci.hasParamAction()) {
+ || ci.hasIncludeAction()
+ || ci.hasSetProperty()
+ || ci.hasParamAction()) {
out.printil(
- "HttpServletRequest request = (HttpServletRequest)_jspx_page_context.getRequest();");
+ "HttpServletRequest request = (HttpServletRequest)_jspx_page_context.getRequest();");
}
if (ci.hasIncludeAction()) {
out.printil(
- "HttpServletResponse response = (HttpServletResponse)_jspx_page_context.getResponse();");
+ "HttpServletResponse response = (HttpServletResponse)_jspx_page_context.getResponse();");
}
}
@@ -3179,7 +3180,7 @@
private void genCommonPostamble() {
// Append any methods that were generated in the buffer.
for (int i = 0; i < methodsBuffered.size(); i++) {
- GenBuffer methodBuffer = (GenBuffer)methodsBuffered.get(i);
+ GenBuffer methodBuffer = (GenBuffer) methodsBuffered.get(i);
methodBuffer.adjustJavaLines(out.getJavaLine() - 1);
out.printMultiLn(methodBuffer.toString());
}
@@ -3209,7 +3210,7 @@
out.printil("} catch (Throwable t) {");
out.pushIndent();
out.printil(
- "if (!(t instanceof SkipPageException)){");
+ "if (!(t instanceof SkipPageException)){");
out.pushIndent();
out.printil("out = _jspx_out;");
out.printil("if (out != null && out.getBufferSize() != 0)");
@@ -3218,7 +3219,7 @@
out.popIndent();
out.printil(
- "if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);");
+ "if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);");
out.popIndent();
out.printil("}");
out.popIndent();
@@ -3226,7 +3227,7 @@
out.pushIndent();
out.printil(
- "if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);");
+ "if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);");
out.popIndent();
out.printil("}");
@@ -3275,15 +3276,16 @@
/**
* The main entry for Generator.
- * @param out The servlet output writer
+ *
+ * @param out The servlet output writer
* @param compiler The compiler
- * @param page The input page
+ * @param page The input page
*/
public static void generate(
- ServletWriter out,
- Compiler compiler,
- Node.Nodes page)
- throws JasperException {
+ ServletWriter out,
+ Compiler compiler,
+ Node.Nodes page)
+ throws JasperException {
Generator gen = new Generator(out, compiler);
@@ -3291,7 +3293,7 @@
gen.compileTagHandlerPoolList(page);
}
if (gen.ctxt.isTagFile()) {
- JasperTagInfo tagInfo = (JasperTagInfo)gen.ctxt.getTagInfo();
+ JasperTagInfo tagInfo = (JasperTagInfo) gen.ctxt.getTagInfo();
gen.generateTagHandlerPreamble(tagInfo, page);
if (gen.ctxt.isPrototypeMode()) {
@@ -3301,26 +3303,26 @@
gen.generateXmlProlog(page);
gen.fragmentHelperClass.generatePreamble();
page.visit(
- gen.new GenerateVisitor(
- gen.ctxt.isTagFile(),
- out,
- gen.methodsBuffered,
- gen.fragmentHelperClass,
- gen.ctxt.getClassLoader(),
- tagInfo));
+ gen.new GenerateVisitor(
+ gen.ctxt.isTagFile(),
+ out,
+ gen.methodsBuffered,
+ gen.fragmentHelperClass,
+ gen.ctxt.getClassLoader(),
+ tagInfo));
gen.generateTagHandlerPostamble(tagInfo);
} else {
gen.generatePreamble(page);
gen.generateXmlProlog(page);
gen.fragmentHelperClass.generatePreamble();
page.visit(
- gen.new GenerateVisitor(
- gen.ctxt.isTagFile(),
- out,
- gen.methodsBuffered,
- gen.fragmentHelperClass,
- gen.ctxt.getClassLoader(),
- null));
+ gen.new GenerateVisitor(
+ gen.ctxt.isTagFile(),
+ out,
+ gen.methodsBuffered,
+ gen.fragmentHelperClass,
+ gen.ctxt.getClassLoader(),
+ null));
gen.generatePostamble(page);
}
}
@@ -3329,9 +3331,9 @@
* Generates tag handler preamble.
*/
private void generateTagHandlerPreamble(
- JasperTagInfo tagInfo,
- Node.Nodes tag)
- throws JasperException {
+ JasperTagInfo tagInfo,
+ Node.Nodes tag)
+ throws JasperException {
// Generate package declaration
String className = tagInfo.getTagClassName();
@@ -3350,11 +3352,11 @@
out.println(className);
out.printil(" extends javax.servlet.jsp.tagext.SimpleTagSupport");
out.printin(
- " implements org.apache.struts2.jasper.runtime.JspSourceDependent");
+ " implements org.apache.struts2.jasper.runtime.JspSourceDependent");
if (tagInfo.hasDynamicAttributes()) {
out.println(",");
out.printin(
- " javax.servlet.jsp.tagext.DynamicAttributes");
+ " javax.servlet.jsp.tagext.DynamicAttributes");
}
out.println(" {");
out.println();
@@ -3390,7 +3392,7 @@
// Now the doTag() method
out.printil(
- "public void doTag() throws JspException, java.io.IOException {");
+ "public void doTag() throws JspException, java.io.IOException {");
if (ctxt.isPrototypeMode()) {
out.printil("}");
@@ -3411,14 +3413,14 @@
// Declare implicit objects.
out.printil(
- "HttpServletRequest request = "
- + "(HttpServletRequest) _jspx_page_context.getRequest();");
+ "HttpServletRequest request = "
+ + "(HttpServletRequest) _jspx_page_context.getRequest();");
out.printil(
- "HttpServletResponse response = "
- + "(HttpServletResponse) _jspx_page_context.getResponse();");
+ "HttpServletResponse response = "
+ + "(HttpServletResponse) _jspx_page_context.getResponse();");
out.printil("HttpSession session = _jspx_page_context.getSession();");
out.printil(
- "ServletContext application = _jspx_page_context.getServletContext();");
+ "ServletContext application = _jspx_page_context.getServletContext();");
out.printil("ServletConfig config = _jspx_page_context.getServletConfig();");
out.printil("JspWriter out = jspContext.getOut();");
if (isPoolingEnabled && !tagHandlerPoolNames.isEmpty()) {
@@ -3453,7 +3455,7 @@
out.printil("} finally {");
out.pushIndent();
out.printil(
- "((org.apache.struts2.jasper.runtime.JspContextWrapper) jspContext).syncEndTagFile();");
+ "((org.apache.struts2.jasper.runtime.JspContextWrapper) jspContext).syncEndTagFile();");
if (isPoolingEnabled && !tagHandlerPoolNames.isEmpty()) {
out.printil("_jspDestroy();");
}
@@ -3473,11 +3475,11 @@
* getter and setter methods for each.
*/
private void generateTagHandlerAttributes(TagInfo tagInfo)
- throws JasperException {
+ throws JasperException {
if (tagInfo.hasDynamicAttributes()) {
out.printil(
- "private java.util.HashMap _jspx_dynamic_attrs = new java.util.HashMap();");
+ "private java.util.HashMap _jspx_dynamic_attrs = new java.util.HashMap();");
}
// Declare attributes
@@ -3559,7 +3561,7 @@
TagVariableInfo[] tagVars = tagInfo.getTagVariableInfos();
for (int i = 0; i < tagVars.length; i++) {
if (tagVars[i].getNameFromAttribute() != null
- && tagVars[i].getNameGiven() != null) {
+ && tagVars[i].getNameGiven() != null) {
aliasSeen = true;
break;
}
@@ -3567,7 +3569,7 @@
if (aliasSeen) {
out.printil(
- "public void setJspContext(JspContext ctx, java.util.Map aliasMap) {");
+ "public void setJspContext(JspContext ctx, java.util.Map aliasMap) {");
} else {
out.printil("public void setJspContext(JspContext ctx) {");
}
@@ -3580,28 +3582,28 @@
for (int i = 0; i < tagVars.length; i++) {
switch (tagVars[i].getScope()) {
- case VariableInfo.NESTED :
+ case VariableInfo.NESTED:
if (!nestedSeen) {
out.printil(
- "_jspx_nested = new java.util.ArrayList();");
+ "_jspx_nested = new java.util.ArrayList();");
nestedSeen = true;
}
out.printin("_jspx_nested.add(");
break;
- case VariableInfo.AT_BEGIN :
+ case VariableInfo.AT_BEGIN:
if (!atBeginSeen) {
out.printil(
- "_jspx_at_begin = new java.util.ArrayList();");
+ "_jspx_at_begin = new java.util.ArrayList();");
atBeginSeen = true;
}
out.printin("_jspx_at_begin.add(");
break;
- case VariableInfo.AT_END :
+ case VariableInfo.AT_END:
if (!atEndSeen) {
out.printil(
- "_jspx_at_end = new java.util.ArrayList();");
+ "_jspx_at_end = new java.util.ArrayList();");
atEndSeen = true;
}
out.printin("_jspx_at_end.add(");
@@ -3613,10 +3615,10 @@
}
if (aliasSeen) {
out.printil(
- "this.jspContext = new org.apache.struts2.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, aliasMap);");
+ "this.jspContext = new org.apache.struts2.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, aliasMap);");
} else {
out.printil(
- "this.jspContext = new org.apache.struts2.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, null);");
+ "this.jspContext = new org.apache.struts2.jasper.runtime.JspContextWrapper(ctx, _jspx_nested, _jspx_at_begin, _jspx_at_end, null);");
}
out.popIndent();
out.printil("}");
@@ -3636,7 +3638,7 @@
*/
public void generateSetDynamicAttribute() {
out.printil(
- "public void setDynamicAttribute(String uri, String localName, Object value) throws JspException {");
+ "public void setDynamicAttribute(String uri, String localName, Object value) throws JspException {");
out.pushIndent();
/*
* According to the spec, only dynamic attributes with no uri are to
@@ -3709,20 +3711,20 @@
/**
* Constructor.
*
- * @param n The custom tag whose tag handler class is to be
- * introspected
+ * @param n The custom tag whose tag handler class is to be
+ * introspected
* @param tagHandlerClass Tag handler class
- * @param err Error dispatcher
+ * @param err Error dispatcher
*/
TagHandlerInfo(Node n, Class tagHandlerClass, ErrorDispatcher err)
- throws JasperException {
+ throws JasperException {
this.tagHandlerClass = tagHandlerClass;
this.methodMaps = new Hashtable();
this.propertyEditorMaps = new Hashtable();
try {
BeanInfo tagClassInfo =
- Introspector.getBeanInfo(tagHandlerClass);
+ Introspector.getBeanInfo(tagHandlerClass);
PropertyDescriptor[] pd = tagClassInfo.getPropertyDescriptors();
for (int i = 0; i < pd.length; i++) {
/*
@@ -3734,15 +3736,15 @@
}
if (pd[i].getPropertyEditorClass() != null)
propertyEditorMaps.put(
- pd[i].getName(),
- pd[i].getPropertyEditorClass());
+ pd[i].getName(),
+ pd[i].getPropertyEditorClass());
}
} catch (IntrospectionException ie) {
err.jspError(
- n,
- "jsp.error.introspect.taghandler",
- tagHandlerClass.getName(),
- ie);
+ n,
+ "jsp.error.introspect.taghandler",
+ tagHandlerClass.getName(),
+ ie);
}
}
@@ -3750,14 +3752,14 @@
* XXX
*/
public Method getSetterMethod(String attrName) {
- return (Method)methodMaps.get(attrName);
+ return (Method) methodMaps.get(attrName);
}
/**
* XXX
*/
public Class getPropertyEditorClass(String attrName) {
- return (Class)propertyEditorMaps.get(attrName);
+ return (Class) propertyEditorMaps.get(attrName);
}
/**
@@ -3828,7 +3830,7 @@
}
public void visit(Node.CustomTag n)
- throws JasperException {
+ throws JasperException {
Node.Nodes b = n.getBody();
if (b != null && !b.isGeneratedInBuffer()) {
// Don't adjust lines for the nested tags that
@@ -3904,19 +3906,19 @@
// _jspx_meth_*
out.printil("private class " + className);
out.printil(
- " extends " + "org.apache.struts2.jasper.runtime.JspFragmentHelper");
+ " extends " + "org.apache.struts2.jasper.runtime.JspFragmentHelper");
out.printil("{");
out.pushIndent();
out.printil(
- "private javax.servlet.jsp.tagext.JspTag _jspx_parent;");
+ "private javax.servlet.jsp.tagext.JspTag _jspx_parent;");
out.printil("private int[] _jspx_push_body_count;");
out.println();
out.printil(
- "public "
- + className
- + "( int discriminator, JspContext jspContext, "
- + "javax.servlet.jsp.tagext.JspTag _jspx_parent, "
- + "int[] _jspx_push_body_count ) {");
+ "public "
+ + className
+ + "( int discriminator, JspContext jspContext, "
+ + "javax.servlet.jsp.tagext.JspTag _jspx_parent, "
+ + "int[] _jspx_push_body_count ) {");
out.pushIndent();
out.printil("super( discriminator, jspContext, _jspx_parent );");
out.printil("this._jspx_parent = _jspx_parent;");
@@ -3926,10 +3928,10 @@
}
public Fragment openFragment(
- Node parent,
- String tagHandlerVar,
- int methodNesting)
- throws JasperException {
+ Node parent,
+ String tagHandlerVar,
+ int methodNesting)
+ throws JasperException {
Fragment result = new Fragment(fragments.size(), parent);
fragments.add(result);
this.used = true;
@@ -3978,7 +3980,7 @@
ServletWriter out = this.classBuffer.getOut();
// Generate all fragment methods:
for (int i = 0; i < fragments.size(); i++) {
- Fragment fragment = (Fragment)fragments.get(i);
+ Fragment fragment = (Fragment) fragments.get(i);
fragment.getGenBuffer().adjustJavaLines(out.getJavaLine() - 1);
out.printMultiLn(fragment.getGenBuffer().toString());
}
@@ -4018,7 +4020,7 @@
out.printil("catch( Throwable e ) {");
out.pushIndent();
out.printil(
- "if (e instanceof SkipPageException)");
+ "if (e instanceof SkipPageException)");
out.printil(" throw (SkipPageException) e;");
out.printil("throw new JspException( e );");
out.popIndent();
@@ -4047,7 +4049,7 @@
public void adjustJavaLines(int offset) {
for (int i = 0; i < fragments.size(); i++) {
- Fragment fragment = (Fragment)fragments.get(i);
+ Fragment fragment = (Fragment) fragments.get(i);
fragment.getGenBuffer().adjustJavaLines(offset);
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ImplicitTagLibraryInfo.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ImplicitTagLibraryInfo.java
index 7c4763c..4e72ac4 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ImplicitTagLibraryInfo.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ImplicitTagLibraryInfo.java
@@ -31,7 +31,7 @@
/**
* Class responsible for generating an implicit tag library containing tag
- * handlers corresponding to the tag files in "/WEB-INF/tags/" or a
+ * handlers corresponding to the tag files in "/WEB-INF/tags/" or a
* subdirectory of it.
*
* @author Jan Luehe
@@ -55,57 +55,57 @@
* Constructor.
*/
public ImplicitTagLibraryInfo(JspCompilationContext ctxt,
- ParserController pc,
- String prefix,
- String tagdir,
- ErrorDispatcher err) throws JasperException {
+ ParserController pc,
+ String prefix,
+ String tagdir,
+ ErrorDispatcher err) throws JasperException {
super(prefix, null);
- this.pc = pc;
- this.tagFileMap = new Hashtable();
- this.vec = new Vector();
+ this.pc = pc;
+ this.tagFileMap = new Hashtable();
+ this.vec = new Vector();
// Implicit tag libraries have no functions:
this.functions = new FunctionInfo[0];
- tlibversion = TLIB_VERSION;
- jspversion = JSP_VERSION;
+ tlibversion = TLIB_VERSION;
+ jspversion = JSP_VERSION;
- if (!tagdir.startsWith(WEB_INF_TAGS)) {
- err.jspError("jsp.error.invalid.tagdir", tagdir);
- }
-
- // Determine the value of the <short-name> subelement of the
- // "imaginary" <taglib> element
- if (tagdir.equals(WEB_INF_TAGS)
- || tagdir.equals( WEB_INF_TAGS + "/")) {
- shortname = TAGS_SHORTNAME;
- } else {
- shortname = tagdir.substring(WEB_INF_TAGS.length());
- shortname = shortname.replace('/', '-');
- }
+ if (!tagdir.startsWith(WEB_INF_TAGS)) {
+ err.jspError("jsp.error.invalid.tagdir", tagdir);
+ }
- // Populate mapping of tag names to tag file paths
- Set dirList = ctxt.getResourcePaths(tagdir);
- if (dirList != null) {
- Iterator it = dirList.iterator();
- while (it.hasNext()) {
- String path = (String) it.next();
- if (path.endsWith(TAG_FILE_SUFFIX)
- || path.endsWith(TAGX_FILE_SUFFIX)) {
- /*
- * Use the filename of the tag file, without the .tag or
- * .tagx extension, respectively, as the <name> subelement
- * of the "imaginary" <tag-file> element
- */
- String suffix = path.endsWith(TAG_FILE_SUFFIX) ?
- TAG_FILE_SUFFIX : TAGX_FILE_SUFFIX;
- String tagName = path.substring(path.lastIndexOf("/") + 1);
- tagName = tagName.substring(0,
- tagName.lastIndexOf(suffix));
- tagFileMap.put(tagName, path);
- }
- }
- }
+ // Determine the value of the <short-name> subelement of the
+ // "imaginary" <taglib> element
+ if (tagdir.equals(WEB_INF_TAGS)
+ || tagdir.equals(WEB_INF_TAGS + "/")) {
+ shortname = TAGS_SHORTNAME;
+ } else {
+ shortname = tagdir.substring(WEB_INF_TAGS.length());
+ shortname = shortname.replace('/', '-');
+ }
+
+ // Populate mapping of tag names to tag file paths
+ Set dirList = ctxt.getResourcePaths(tagdir);
+ if (dirList != null) {
+ Iterator it = dirList.iterator();
+ while (it.hasNext()) {
+ String path = (String) it.next();
+ if (path.endsWith(TAG_FILE_SUFFIX)
+ || path.endsWith(TAGX_FILE_SUFFIX)) {
+ /*
+ * Use the filename of the tag file, without the .tag or
+ * .tagx extension, respectively, as the <name> subelement
+ * of the "imaginary" <tag-file> element
+ */
+ String suffix = path.endsWith(TAG_FILE_SUFFIX) ?
+ TAG_FILE_SUFFIX : TAGX_FILE_SUFFIX;
+ String tagName = path.substring(path.lastIndexOf("/") + 1);
+ tagName = tagName.substring(0,
+ tagName.lastIndexOf(suffix));
+ tagFileMap.put(tagName, path);
+ }
+ }
+ }
}
/**
@@ -113,34 +113,34 @@
* and if so, parses the corresponding tag file.
*
* @return The TagFileInfo corresponding to the given tag name, or null if
- * the given tag name is not implemented as a tag file
+ * the given tag name is not implemented as a tag file
*/
public TagFileInfo getTagFile(String shortName) {
- TagFileInfo tagFile = super.getTagFile(shortName);
- if (tagFile == null) {
- String path = (String) tagFileMap.get(shortName);
- if (path == null) {
- return null;
- }
+ TagFileInfo tagFile = super.getTagFile(shortName);
+ if (tagFile == null) {
+ String path = (String) tagFileMap.get(shortName);
+ if (path == null) {
+ return null;
+ }
- TagInfo tagInfo = null;
- try {
- tagInfo = TagFileProcessor.parseTagFileDirectives(pc,
- shortName,
- path,
- this);
- } catch (JasperException je) {
- throw new RuntimeException(je.toString());
- }
+ TagInfo tagInfo = null;
+ try {
+ tagInfo = TagFileProcessor.parseTagFileDirectives(pc,
+ shortName,
+ path,
+ this);
+ } catch (JasperException je) {
+ throw new RuntimeException(je.toString());
+ }
- tagFile = new TagFileInfo(shortName, path, tagInfo);
- vec.addElement(tagFile);
+ tagFile = new TagFileInfo(shortName, path, tagInfo);
+ vec.addElement(tagFile);
- this.tagFiles = new TagFileInfo[vec.size()];
- vec.copyInto(this.tagFiles);
- }
+ this.tagFiles = new TagFileInfo[vec.size()];
+ vec.copyInto(this.tagFiles);
+ }
- return tagFile;
+ return tagFile;
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JasperTagInfo.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JasperTagInfo.java
index ce47150..8f02f51 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JasperTagInfo.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JasperTagInfo.java
@@ -30,26 +30,26 @@
private String dynamicAttrsMapName;
public JasperTagInfo(String tagName,
- String tagClassName,
- String bodyContent,
- String infoString,
- TagLibraryInfo taglib,
- TagExtraInfo tagExtraInfo,
- TagAttributeInfo[] attributeInfo,
- String displayName,
- String smallIcon,
- String largeIcon,
- TagVariableInfo[] tvi,
- String mapName) {
+ String tagClassName,
+ String bodyContent,
+ String infoString,
+ TagLibraryInfo taglib,
+ TagExtraInfo tagExtraInfo,
+ TagAttributeInfo[] attributeInfo,
+ String displayName,
+ String smallIcon,
+ String largeIcon,
+ TagVariableInfo[] tvi,
+ String mapName) {
- super(tagName, tagClassName, bodyContent, infoString, taglib,
- tagExtraInfo, attributeInfo, displayName, smallIcon, largeIcon,
- tvi);
- this.dynamicAttrsMapName = mapName;
+ super(tagName, tagClassName, bodyContent, infoString, taglib,
+ tagExtraInfo, attributeInfo, displayName, smallIcon, largeIcon,
+ tvi);
+ this.dynamicAttrsMapName = mapName;
}
public String getDynamicAttributesMapName() {
- return dynamicAttrsMapName;
+ return dynamicAttrsMapName;
}
public boolean hasDynamicAttributes() {
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JavacErrorDetail.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JavacErrorDetail.java
index 52158ce..301962d 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JavacErrorDetail.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JavacErrorDetail.java
@@ -41,10 +41,10 @@
/**
* Constructor.
*
- * @param javaFileName The name of the Java file in which the
- * compilation error occurred
- * @param javaLineNum The compilation error line number
- * @param errMsg The compilation error message
+ * @param javaFileName The name of the Java file in which the
+ * compilation error occurred
+ * @param javaLineNum The compilation error line number
+ * @param errMsg The compilation error message
*/
public JavacErrorDetail(String javaFileName,
int javaLineNum,
@@ -59,14 +59,14 @@
/**
* Constructor.
*
- * @param javaFileName The name of the Java file in which the
- * compilation error occurred
- * @param javaLineNum The compilation error line number
- * @param jspFileName The name of the JSP file from which the Java source
- * file was generated
+ * @param javaFileName The name of the Java file in which the
+ * compilation error occurred
+ * @param javaLineNum The compilation error line number
+ * @param jspFileName The name of the JSP file from which the Java source
+ * file was generated
* @param jspBeginLineNum The start line number of the JSP element
- * responsible for the compilation error
- * @param errMsg The compilation error message
+ * responsible for the compilation error
+ * @param errMsg The compilation error message
*/
public JavacErrorDetail(String javaFileName,
int javaLineNum,
@@ -79,15 +79,15 @@
}
public JavacErrorDetail(String javaFileName,
- int javaLineNum,
- String jspFileName,
- int jspBeginLineNum,
- StringBuffer errMsg,
- JspCompilationContext ctxt) {
+ int javaLineNum,
+ String jspFileName,
+ int jspBeginLineNum,
+ StringBuffer errMsg,
+ JspCompilationContext ctxt) {
this(javaFileName, javaLineNum, errMsg);
this.jspFileName = jspFileName;
this.jspBeginLineNum = jspBeginLineNum;
-
+
if (jspBeginLineNum > 0 && ctxt != null) {
InputStream is = null;
FileInputStream fis = null;
@@ -95,40 +95,40 @@
// Read both files in, so we can inspect them
is = ctxt.getResourceAsStream(jspFileName);
String[] jspLines = readFile(is);
-
+
fis = new FileInputStream(ctxt.getServletJavaFileName());
String[] javaLines = readFile(fis);
-
+
// If the line contains the opening of a multi-line scriptlet
// block, then the JSP line number we got back is probably
// faulty. Scan forward to match the java line...
- if (jspLines[jspBeginLineNum-1].lastIndexOf("<%") >
- jspLines[jspBeginLineNum-1].lastIndexOf("%>")) {
- String javaLine = javaLines[javaLineNum-1].trim();
-
- for (int i=jspBeginLineNum-1; i<jspLines.length; i++) {
+ if (jspLines[jspBeginLineNum - 1].lastIndexOf("<%") >
+ jspLines[jspBeginLineNum - 1].lastIndexOf("%>")) {
+ String javaLine = javaLines[javaLineNum - 1].trim();
+
+ for (int i = jspBeginLineNum - 1; i < jspLines.length; i++) {
if (jspLines[i].indexOf(javaLine) != -1) {
// Update jsp line number
- this.jspBeginLineNum = i+1;
+ this.jspBeginLineNum = i + 1;
break;
}
}
}
-
+
// copy out a fragment of JSP to display to the user
StringBuffer fragment = new StringBuffer(1024);
- int startIndex = Math.max(0, this.jspBeginLineNum-1-3);
+ int startIndex = Math.max(0, this.jspBeginLineNum - 1 - 3);
int endIndex = Math.min(
- jspLines.length-1, this.jspBeginLineNum-1+3);
-
- for (int i=startIndex;i<=endIndex; ++i) {
- fragment.append(i+1);
+ jspLines.length - 1, this.jspBeginLineNum - 1 + 3);
+
+ for (int i = startIndex; i <= endIndex; ++i) {
+ fragment.append(i + 1);
fragment.append(": ");
fragment.append(jspLines[i]);
fragment.append("\n");
}
jspExtract = fragment.toString();
-
+
} catch (IOException ioe) {
// Can't read files - ignore
} finally {
@@ -150,6 +150,7 @@
}
}
+
/**
* Gets the name of the Java source file in which the compilation error
* occurred.
@@ -162,7 +163,7 @@
/**
* Gets the compilation error line number.
- *
+ *
* @return Compilation error line number
*/
public int getJavaLineNumber() {
@@ -184,7 +185,7 @@
* responsible for the compilation error.
*
* @return Start line number of the JSP element responsible for the
- * compilation error
+ * compilation error
*/
public int getJspBeginLineNumber() {
return this.jspBeginLineNum;
@@ -198,7 +199,7 @@
public String getErrorMessage() {
return this.errMsg.toString();
}
-
+
/**
* Gets the extract of the JSP that corresponds to this message.
*
@@ -207,7 +208,7 @@
public String getJspExtract() {
return this.jspExtract;
}
-
+
/**
* Reads a text file from an input stream into a String[]. Used to read in
* the JSP and generated Java file when generating error messages.
@@ -217,10 +218,10 @@
List lines = new ArrayList();
String line;
- while ( (line = reader.readLine()) != null ) {
+ while ((line = reader.readLine()) != null) {
lines.add(line);
}
- return (String[]) lines.toArray( new String[lines.size()] );
+ return (String[]) lines.toArray(new String[lines.size()]);
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspConfig.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspConfig.java
index 605a4b8..b43ec54 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspConfig.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspConfig.java
@@ -17,8 +17,8 @@
package org.apache.struts2.jasper.compiler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.JasperException;
import org.apache.struts2.jasper.xmlparser.ParserUtils;
import org.apache.struts2.jasper.xmlparser.TreeNode;
@@ -42,7 +42,7 @@
private static final String WEB_XML = "/WEB-INF/web.xml";
// Logger
- private Log log = LogFactory.getLog(JspConfig.class);
+ private Logger log = LoggerFactory.getLogger(JspConfig.class);
private Vector jspProperties = null;
private ServletContext ctxt;
@@ -70,7 +70,7 @@
is = uri.openStream();
InputSource ip = new InputSource(is);
- ip.setSystemId(uri.toExternalForm());
+ ip.setSystemId(uri.toExternalForm());
ParserUtils pu = new ParserUtils();
TreeNode webApp = pu.parseXMLDocument(WEB_XML, ip);
@@ -106,7 +106,7 @@
String tname = element.getName();
if ("url-pattern".equals(tname))
- urlPatterns.addElement( element.getBody() );
+ urlPatterns.addElement(element.getBody());
else if ("page-encoding".equals(tname))
pageEncoding = element.getBody();
else if ("is-xml".equals(tname))
@@ -124,14 +124,14 @@
if (urlPatterns.size() == 0) {
continue;
}
-
+
// Add one JspPropertyGroup for each URL Pattern. This makes
// the matching logic easier.
- for( int p = 0; p < urlPatterns.size(); p++ ) {
- String urlPattern = (String)urlPatterns.elementAt( p );
+ for (int p = 0; p < urlPatterns.size(); p++) {
+ String urlPattern = (String) urlPatterns.elementAt(p);
String path = null;
String extension = null;
-
+
if (urlPattern.indexOf('*') < 0) {
// Exact match
path = urlPattern;
@@ -139,17 +139,17 @@
int i = urlPattern.lastIndexOf('/');
String file;
if (i >= 0) {
- path = urlPattern.substring(0,i+1);
- file = urlPattern.substring(i+1);
+ path = urlPattern.substring(0, i + 1);
+ file = urlPattern.substring(i + 1);
} else {
file = urlPattern;
}
-
+
// pattern must be "*", or of the form "*.jsp"
if (file.equals("*")) {
extension = "*";
} else if (file.startsWith("*.")) {
- extension = file.substring(file.indexOf('.')+1);
+ extension = file.substring(file.indexOf('.') + 1);
}
// The url patterns are reconstructed as the follwoing:
@@ -161,21 +161,21 @@
|| (path != null && !isStar)) {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage(
- "jsp.warning.bad.urlpattern.propertygroup",
- urlPattern));
+ "jsp.warning.bad.urlpattern.propertygroup",
+ urlPattern));
}
continue;
}
}
JspProperty property = new JspProperty(isXml,
- elIgnored,
- scriptingInvalid,
- pageEncoding,
- includePrelude,
- includeCoda);
+ elIgnored,
+ scriptingInvalid,
+ pageEncoding,
+ includePrelude,
+ includeCoda);
JspPropertyGroup propertyGroup =
- new JspPropertyGroup(path, extension, property);
+ new JspPropertyGroup(path, extension, property);
jspProperties.addElement(propertyGroup);
}
@@ -186,7 +186,8 @@
if (is != null) {
try {
is.close();
- } catch (Throwable t) {}
+ } catch (Throwable t) {
+ }
}
}
}
@@ -196,9 +197,9 @@
if (!initialized) {
processWebDotXml(ctxt);
defaultJspProperty = new JspProperty(defaultIsXml,
- defaultIsELIgnored,
- defaultIsScriptingInvalid,
- null, null, null);
+ defaultIsELIgnored,
+ defaultIsScriptingInvalid,
+ null, null, null);
initialized = true;
}
}
@@ -237,10 +238,11 @@
}
return curr;
}
-
+
/**
* Find a property that best matches the supplied resource.
+ *
* @param uri the resource supplied.
* @return a JspProperty indicating the best match, or some default.
*/
@@ -256,13 +258,13 @@
String uriPath = null;
int index = uri.lastIndexOf('/');
- if (index >=0 ) {
- uriPath = uri.substring(0, index+1);
+ if (index >= 0) {
+ uriPath = uri.substring(0, index + 1);
}
String uriExtension = null;
index = uri.lastIndexOf('.');
- if (index >=0) {
- uriExtension = uri.substring(index+1);
+ if (index >= 0) {
+ uriExtension = uri.substring(index + 1);
}
Vector includePreludes = new Vector();
@@ -279,53 +281,53 @@
JspPropertyGroup jpg = (JspPropertyGroup) iter.next();
JspProperty jp = jpg.getJspProperty();
- // (arrays will be the same length)
- String extension = jpg.getExtension();
- String path = jpg.getPath();
-
- if (extension == null) {
- // exact match pattern: /a/foo.jsp
- if (!uri.equals(path)) {
- // not matched;
- continue;
- }
- } else {
- // Matching patterns *.ext or /p/*
- if (path != null && uriPath != null &&
- ! uriPath.startsWith(path)) {
- // not matched
- continue;
- }
- if (!extension.equals("*") &&
- !extension.equals(uriExtension)) {
- // not matched
- continue;
- }
- }
- // We have a match
- // Add include-preludes and include-codas
- if (jp.getIncludePrelude() != null) {
- includePreludes.addAll(jp.getIncludePrelude());
- }
- if (jp.getIncludeCoda() != null) {
- includeCodas.addAll(jp.getIncludeCoda());
- }
+ // (arrays will be the same length)
+ String extension = jpg.getExtension();
+ String path = jpg.getPath();
- // If there is a previous match for the same property, remember
- // the one that is more restrictive.
- if (jp.isXml() != null) {
- isXmlMatch = selectProperty(isXmlMatch, jpg);
- }
- if (jp.isELIgnored() != null) {
- elIgnoredMatch = selectProperty(elIgnoredMatch, jpg);
- }
- if (jp.isScriptingInvalid() != null) {
- scriptingInvalidMatch =
- selectProperty(scriptingInvalidMatch, jpg);
- }
- if (jp.getPageEncoding() != null) {
- pageEncodingMatch = selectProperty(pageEncodingMatch, jpg);
- }
+ if (extension == null) {
+ // exact match pattern: /a/foo.jsp
+ if (!uri.equals(path)) {
+ // not matched;
+ continue;
+ }
+ } else {
+ // Matching patterns *.ext or /p/*
+ if (path != null && uriPath != null &&
+ !uriPath.startsWith(path)) {
+ // not matched
+ continue;
+ }
+ if (!extension.equals("*") &&
+ !extension.equals(uriExtension)) {
+ // not matched
+ continue;
+ }
+ }
+ // We have a match
+ // Add include-preludes and include-codas
+ if (jp.getIncludePrelude() != null) {
+ includePreludes.addAll(jp.getIncludePrelude());
+ }
+ if (jp.getIncludeCoda() != null) {
+ includeCodas.addAll(jp.getIncludeCoda());
+ }
+
+ // If there is a previous match for the same property, remember
+ // the one that is more restrictive.
+ if (jp.isXml() != null) {
+ isXmlMatch = selectProperty(isXmlMatch, jpg);
+ }
+ if (jp.isELIgnored() != null) {
+ elIgnoredMatch = selectProperty(elIgnoredMatch, jpg);
+ }
+ if (jp.isScriptingInvalid() != null) {
+ scriptingInvalidMatch =
+ selectProperty(scriptingInvalidMatch, jpg);
+ }
+ if (jp.getPageEncoding() != null) {
+ pageEncodingMatch = selectProperty(pageEncodingMatch, jpg);
+ }
}
@@ -342,14 +344,14 @@
}
if (scriptingInvalidMatch != null) {
isScriptingInvalid =
- scriptingInvalidMatch.getJspProperty().isScriptingInvalid();
+ scriptingInvalidMatch.getJspProperty().isScriptingInvalid();
}
if (pageEncodingMatch != null) {
pageEncoding = pageEncodingMatch.getJspProperty().getPageEncoding();
}
return new JspProperty(isXml, isELIgnored, isScriptingInvalid,
- pageEncoding, includePreludes, includeCodas);
+ pageEncoding, includePreludes, includeCodas);
}
/**
@@ -365,13 +367,13 @@
String uriPath = null;
int index = uri.lastIndexOf('/');
- if (index >=0 ) {
- uriPath = uri.substring(0, index+1);
+ if (index >= 0) {
+ uriPath = uri.substring(0, index + 1);
}
String uriExtension = null;
index = uri.lastIndexOf('.');
- if (index >=0) {
- uriExtension = uri.substring(index+1);
+ if (index >= 0) {
+ uriExtension = uri.substring(index + 1);
}
Iterator iter = jspProperties.iterator();
@@ -389,7 +391,7 @@
}
} else {
if ((path == null || path.equals(uriPath)) &&
- (extension.equals("*") || extension.equals(uriExtension))) {
+ (extension.equals("*") || extension.equals(uriExtension))) {
// Matches *, *.ext, /p/*, or /p/*.ext
return true;
}
@@ -433,8 +435,8 @@
private Vector includeCoda;
public JspProperty(String isXml, String elIgnored,
- String scriptingInvalid, String pageEncoding,
- Vector includePrelude, Vector includeCoda) {
+ String scriptingInvalid, String pageEncoding,
+ Vector includePrelude, Vector includeCoda) {
this.isXml = isXml;
this.elIgnored = elIgnored;
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspDocumentParser.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspDocumentParser.java
index 432e7b2..607f525 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspDocumentParser.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspDocumentParser.java
@@ -45,18 +45,18 @@
*/
class JspDocumentParser
- extends DefaultHandler
- implements LexicalHandler, TagConstants {
+ extends DefaultHandler
+ implements LexicalHandler, TagConstants {
private static final String JSP_VERSION = "version";
private static final String LEXICAL_HANDLER_PROPERTY =
- "http://xml.org/sax/properties/lexical-handler";
+ "http://xml.org/sax/properties/lexical-handler";
private static final String JSP_URI = "http://java.sun.com/JSP/Page";
private static final EnableDTDValidationException ENABLE_DTD_VALIDATION_EXCEPTION =
- new EnableDTDValidationException(
- "jsp.error.enable_dtd_validation",
- null);
+ new EnableDTDValidationException(
+ "jsp.error.enable_dtd_validation",
+ null);
private ParserController parserController;
private JspCompilationContext ctxt;
@@ -71,7 +71,7 @@
* Outermost (in the nesting hierarchy) node whose body is declared to be
* scriptless. If a node's body is declared to be scriptless, all its
* nested nodes must be scriptless, too.
- */
+ */
private Node scriptlessBodyNode;
private Locator locator;
@@ -108,10 +108,10 @@
* Constructor
*/
public JspDocumentParser(
- ParserController pc,
- String path,
- boolean isTagFile,
- boolean directivesOnly) {
+ ParserController pc,
+ String path,
+ boolean isTagFile,
+ boolean directivesOnly) {
this.parserController = pc;
this.ctxt = pc.getJspCompilationContext();
this.pageInfo = pc.getCompiler().getPageInfo();
@@ -128,19 +128,19 @@
* @throws JasperException
*/
public static Node.Nodes parse(
- ParserController pc,
- String path,
- JarFile jarFile,
- Node parent,
- boolean isTagFile,
- boolean directivesOnly,
- String pageEnc,
- String jspConfigPageEnc,
- boolean isEncodingSpecifiedInProlog)
- throws JasperException {
+ ParserController pc,
+ String path,
+ JarFile jarFile,
+ Node parent,
+ boolean isTagFile,
+ boolean directivesOnly,
+ String pageEnc,
+ String jspConfigPageEnc,
+ boolean isEncodingSpecifiedInProlog)
+ throws JasperException {
JspDocumentParser jspDocParser =
- new JspDocumentParser(pc, path, isTagFile, directivesOnly);
+ new JspDocumentParser(pc, path, isTagFile, directivesOnly);
Node.Nodes pageNodes = null;
try {
@@ -150,12 +150,12 @@
dummyRoot.setPageEncoding(pageEnc);
dummyRoot.setJspConfigPageEncoding(jspConfigPageEnc);
dummyRoot.setIsEncodingSpecifiedInProlog(
- isEncodingSpecifiedInProlog);
+ isEncodingSpecifiedInProlog);
jspDocParser.current = dummyRoot;
if (parent == null) {
jspDocParser.addInclude(
- dummyRoot,
- jspDocParser.pageInfo.getIncludePrelude());
+ dummyRoot,
+ jspDocParser.pageInfo.getIncludePrelude());
} else {
jspDocParser.isTop = false;
}
@@ -165,8 +165,8 @@
InputStream inStream = null;
try {
inStream = JspUtil.getInputStream(path, jarFile,
- jspDocParser.ctxt,
- jspDocParser.err);
+ jspDocParser.ctxt,
+ jspDocParser.err);
saxParser.parse(new InputSource(inStream), jspDocParser);
} catch (EnableDTDValidationException e) {
saxParser = getSAXParser(true, jspDocParser);
@@ -178,8 +178,8 @@
}
}
inStream = JspUtil.getInputStream(path, jarFile,
- jspDocParser.ctxt,
- jspDocParser.err);
+ jspDocParser.ctxt,
+ jspDocParser.err);
saxParser.parse(new InputSource(inStream), jspDocParser);
} finally {
if (inStream != null) {
@@ -192,8 +192,8 @@
if (parent == null) {
jspDocParser.addInclude(
- dummyRoot,
- jspDocParser.pageInfo.getIncludeCoda());
+ dummyRoot,
+ jspDocParser.pageInfo.getIncludeCoda());
}
// Create Node.Nodes from dummy root
@@ -203,9 +203,9 @@
jspDocParser.err.jspError("jsp.error.data.file.read", path, ioe);
} catch (SAXParseException e) {
jspDocParser.err.jspError
- (new Mark(jspDocParser.ctxt, path, e.getLineNumber(),
- e.getColumnNumber()),
- e.getMessage());
+ (new Mark(jspDocParser.ctxt, path, e.getLineNumber(),
+ e.getColumnNumber()),
+ e.getMessage());
} catch (Exception e) {
jspDocParser.err.jspError(e);
}
@@ -223,14 +223,14 @@
if (files != null) {
Iterator iter = files.iterator();
while (iter.hasNext()) {
- String file = (String)iter.next();
+ String file = (String) iter.next();
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute("", "file", "file", "CDATA", file);
// Create a dummy Include directive node
- Node includeDir =
+ Node includeDir =
new Node.IncludeDirective(attrs, null, // XXX
- parent);
+ parent);
processIncludeDirective(file, includeDir);
}
}
@@ -250,11 +250,11 @@
* tag libraries.
*/
public void startElement(
- String uri,
- String localName,
- String qName,
- Attributes attrs)
- throws SAXException {
+ String uri,
+ String localName,
+ String qName,
+ Attributes attrs)
+ throws SAXException {
AttributesImpl taglibAttrs = null;
AttributesImpl nonTaglibAttrs = null;
@@ -265,22 +265,22 @@
checkPrefixes(uri, qName, attrs);
if (directivesOnly &&
- !(JSP_URI.equals(uri) && localName.startsWith(DIRECTIVE_ACTION))) {
+ !(JSP_URI.equals(uri) && localName.startsWith(DIRECTIVE_ACTION))) {
return;
}
String currentPrefix = getPrefix(current.getQName());
-
+
// jsp:text must not have any subelements
if (JSP_URI.equals(uri) && TEXT_ACTION.equals(current.getLocalName())
&& "jsp".equals(currentPrefix)) {
throw new SAXParseException(
- Localizer.getMessage("jsp.error.text.has_subelement"),
- locator);
+ Localizer.getMessage("jsp.error.text.has_subelement"),
+ locator);
}
startMark = new Mark(ctxt, path, locator.getLineNumber(),
- locator.getColumnNumber());
+ locator.getColumnNumber());
if (attrs != null) {
/*
@@ -296,11 +296,11 @@
nonTaglibAttrs = new AttributesImpl();
}
nonTaglibAttrs.addAttribute(
- attrs.getURI(i),
- attrs.getLocalName(i),
- attrs.getQName(i),
- attrs.getType(i),
- attrs.getValue(i));
+ attrs.getURI(i),
+ attrs.getLocalName(i),
+ attrs.getQName(i),
+ attrs.getType(i),
+ attrs.getValue(i));
} else {
if (attrQName.startsWith("xmlns:jsp")) {
isTaglib = true;
@@ -315,21 +315,21 @@
taglibAttrs = new AttributesImpl();
}
taglibAttrs.addAttribute(
- attrs.getURI(i),
- attrs.getLocalName(i),
- attrs.getQName(i),
- attrs.getType(i),
- attrs.getValue(i));
+ attrs.getURI(i),
+ attrs.getLocalName(i),
+ attrs.getQName(i),
+ attrs.getType(i),
+ attrs.getValue(i));
} else {
if (nonTaglibXmlnsAttrs == null) {
nonTaglibXmlnsAttrs = new AttributesImpl();
}
nonTaglibXmlnsAttrs.addAttribute(
- attrs.getURI(i),
- attrs.getLocalName(i),
- attrs.getQName(i),
- attrs.getType(i),
- attrs.getValue(i));
+ attrs.getURI(i),
+ attrs.getLocalName(i),
+ attrs.getQName(i),
+ attrs.getType(i),
+ attrs.getValue(i));
}
}
}
@@ -338,32 +338,32 @@
Node node = null;
if (tagDependentPending && JSP_URI.equals(uri) &&
- localName.equals(BODY_ACTION)) {
+ localName.equals(BODY_ACTION)) {
tagDependentPending = false;
tagDependentNesting++;
current =
- parseStandardAction(
- qName,
- localName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- startMark,
- current);
+ parseStandardAction(
+ qName,
+ localName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ startMark,
+ current);
return;
}
if (tagDependentPending && JSP_URI.equals(uri) &&
- localName.equals(ATTRIBUTE_ACTION)) {
+ localName.equals(ATTRIBUTE_ACTION)) {
current =
- parseStandardAction(
- qName,
- localName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- startMark,
- current);
+ parseStandardAction(
+ qName,
+ localName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ startMark,
+ current);
return;
}
@@ -374,45 +374,45 @@
if (tagDependentNesting > 0) {
node =
- new Node.UninterpretedTag(
- qName,
- localName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- startMark,
- current);
+ new Node.UninterpretedTag(
+ qName,
+ localName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ startMark,
+ current);
} else if (JSP_URI.equals(uri)) {
node =
- parseStandardAction(
- qName,
- localName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- startMark,
- current);
+ parseStandardAction(
+ qName,
+ localName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ startMark,
+ current);
} else {
node =
- parseCustomAction(
- qName,
- localName,
- uri,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- startMark,
- current);
+ parseCustomAction(
+ qName,
+ localName,
+ uri,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ startMark,
+ current);
if (node == null) {
node =
- new Node.UninterpretedTag(
- qName,
- localName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- startMark,
- current);
+ new Node.UninterpretedTag(
+ qName,
+ localName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ startMark,
+ current);
} else {
// custom action
String bodyType = getBodyType((Node.CustomTag) node);
@@ -420,8 +420,7 @@
if (scriptlessBodyNode == null
&& bodyType.equalsIgnoreCase(TagInfo.BODY_CONTENT_SCRIPTLESS)) {
scriptlessBodyNode = node;
- }
- else if (TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType)) {
+ } else if (TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType)) {
tagDependentPending = true;
}
}
@@ -470,12 +469,12 @@
*/
boolean isAllSpace = true;
if (!(current instanceof Node.JspText)
- && !(current instanceof Node.NamedAttribute)) {
+ && !(current instanceof Node.NamedAttribute)) {
for (int i = 0; i < charBuffer.length(); i++) {
if (!(charBuffer.charAt(i) == ' '
- || charBuffer.charAt(i) == '\n'
- || charBuffer.charAt(i) == '\r'
- || charBuffer.charAt(i) == '\t')) {
+ || charBuffer.charAt(i) == '\n'
+ || charBuffer.charAt(i) == '\r'
+ || charBuffer.charAt(i) == '\t')) {
isAllSpace = false;
break;
}
@@ -492,14 +491,14 @@
new Node.TemplateText(charBuffer.toString(), startMark, current);
}
startMark = new Mark(ctxt, path, locator.getLineNumber(),
- locator.getColumnNumber());
+ locator.getColumnNumber());
charBuffer = null;
return;
}
if ((current instanceof Node.JspText)
- || (current instanceof Node.NamedAttribute)
- || !isAllSpace) {
+ || (current instanceof Node.NamedAttribute)
+ || !isAllSpace) {
int line = startMark.getLineNumber();
int column = startMark.getColumnNumber();
@@ -518,9 +517,9 @@
if (lastCh == '$' && ch == '{') {
if (ttext.size() > 0) {
new Node.TemplateText(
- ttext.toString(),
- startMark,
- current);
+ ttext.toString(),
+ startMark,
+ current);
ttext = new CharArrayWriter();
//We subtract two from the column number to
//account for the '${' that we've already parsed
@@ -531,13 +530,13 @@
boolean singleQ = false;
boolean doubleQ = false;
lastCh = 0;
- for (;; i++) {
+ for (; ; i++) {
if (i >= charBuffer.length()) {
throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.unterminated",
- "${"),
- locator);
+ Localizer.getMessage(
+ "jsp.error.unterminated",
+ "${"),
+ locator);
}
ch = charBuffer.charAt(i);
@@ -554,9 +553,9 @@
}
if (ch == '}') {
new Node.ELExpression(
- ttext.toString(),
- startMark,
- current);
+ ttext.toString(),
+ startMark,
+ current);
ttext = new CharArrayWriter();
startMark = new Mark(ctxt, path, line, column);
break;
@@ -590,7 +589,7 @@
}
}
startMark = new Mark(ctxt, path, locator.getLineNumber(),
- locator.getColumnNumber());
+ locator.getColumnNumber());
charBuffer = null;
}
@@ -599,18 +598,18 @@
* Receives notification of the end of an element.
*/
public void endElement(String uri, String localName, String qName)
- throws SAXException {
+ throws SAXException {
processChars();
if (directivesOnly &&
- !(JSP_URI.equals(uri) && localName.startsWith(DIRECTIVE_ACTION))) {
+ !(JSP_URI.equals(uri) && localName.startsWith(DIRECTIVE_ACTION))) {
return;
}
if (current instanceof Node.NamedAttribute) {
- boolean isTrim = ((Node.NamedAttribute)current).isTrim();
- Node.Nodes subElems = ((Node.NamedAttribute)current).getBody();
+ boolean isTrim = ((Node.NamedAttribute) current).isTrim();
+ Node.Nodes subElems = ((Node.NamedAttribute) current).getBody();
for (int i = 0; subElems != null && i < subElems.size(); i++) {
Node subElem = subElems.getNode(i);
if (!(subElem instanceof Node.TemplateText)) {
@@ -627,23 +626,23 @@
// is set to FALSE, which must be kept verbatim.
if (i == 0) {
if (isTrim) {
- ((Node.TemplateText)subElem).ltrim();
+ ((Node.TemplateText) subElem).ltrim();
}
} else if (i == subElems.size() - 1) {
if (isTrim) {
- ((Node.TemplateText)subElem).rtrim();
+ ((Node.TemplateText) subElem).rtrim();
}
} else {
- if (((Node.TemplateText)subElem).isAllSpace()) {
+ if (((Node.TemplateText) subElem).isAllSpace()) {
subElems.remove(subElem);
}
}
}
} else if (current instanceof Node.ScriptingElement) {
- checkScriptingBody((Node.ScriptingElement)current);
+ checkScriptingBody((Node.ScriptingElement) current);
}
- if ( isTagDependent(current)) {
+ if (isTagDependent(current)) {
tagDependentNesting--;
}
@@ -676,11 +675,11 @@
// ignore comments in the DTD
if (!inDTD) {
startMark =
- new Mark(
- ctxt,
- path,
- locator.getLineNumber(),
- locator.getColumnNumber());
+ new Mark(
+ ctxt,
+ path,
+ locator.getLineNumber(),
+ locator.getColumnNumber());
new Node.Comment(new String(buf, offset, len), startMark, current);
}
}
@@ -692,7 +691,7 @@
processChars(); // Flush char buffer and remove white spaces
startMark = new Mark(ctxt, path, locator.getLineNumber(),
- locator.getColumnNumber());
+ locator.getColumnNumber());
}
/*
@@ -720,7 +719,7 @@
* See org.xml.sax.ext.LexicalHandler.
*/
public void startDTD(String name, String publicId, String systemId)
- throws SAXException {
+ throws SAXException {
if (!isValidating) {
fatalError(ENABLE_DTD_VALIDATION_EXCEPTION);
}
@@ -753,20 +752,20 @@
* Receives notification of the start of a Namespace mapping.
*/
public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
+ throws SAXException {
TagLibraryInfo taglibInfo;
if (directivesOnly && !(JSP_URI.equals(uri))) {
return;
}
-
+
try {
taglibInfo = getTaglibInfo(prefix, uri);
} catch (JasperException je) {
throw new SAXParseException(
- Localizer.getMessage("jsp.error.could.not.add.taglibraries"),
- locator,
- je);
+ Localizer.getMessage("jsp.error.could.not.add.taglibraries"),
+ locator,
+ je);
}
if (taglibInfo != null) {
@@ -798,329 +797,329 @@
// Private utility methods
private Node parseStandardAction(
- String qName,
- String localName,
- Attributes nonTaglibAttrs,
- Attributes nonTaglibXmlnsAttrs,
- Attributes taglibAttrs,
- Mark start,
- Node parent)
- throws SAXException {
+ String qName,
+ String localName,
+ Attributes nonTaglibAttrs,
+ Attributes nonTaglibXmlnsAttrs,
+ Attributes taglibAttrs,
+ Mark start,
+ Node parent)
+ throws SAXException {
Node node = null;
if (localName.equals(ROOT_ACTION)) {
if (!(current instanceof Node.Root)) {
throw new SAXParseException(
- Localizer.getMessage("jsp.error.nested_jsproot"),
- locator);
+ Localizer.getMessage("jsp.error.nested_jsproot"),
+ locator);
}
node =
- new Node.JspRoot(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.JspRoot(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
if (isTop) {
pageInfo.setHasJspRoot(true);
}
} else if (localName.equals(PAGE_DIRECTIVE_ACTION)) {
if (isTagFile) {
throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.action.istagfile",
- localName),
- locator);
+ Localizer.getMessage(
+ "jsp.error.action.istagfile",
+ localName),
+ locator);
}
node =
- new Node.PageDirective(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.PageDirective(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
String imports = nonTaglibAttrs.getValue("import");
// There can only be one 'import' attribute per page directive
if (imports != null) {
- ((Node.PageDirective)node).addImport(imports);
+ ((Node.PageDirective) node).addImport(imports);
}
} else if (localName.equals(INCLUDE_DIRECTIVE_ACTION)) {
node =
- new Node.IncludeDirective(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.IncludeDirective(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
processIncludeDirective(nonTaglibAttrs.getValue("file"), node);
} else if (localName.equals(DECLARATION_ACTION)) {
if (scriptlessBodyNode != null) {
// We're nested inside a node whose body is
// declared to be scriptless
throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.no.scriptlets",
- localName),
- locator);
+ Localizer.getMessage(
+ "jsp.error.no.scriptlets",
+ localName),
+ locator);
}
node =
- new Node.Declaration(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.Declaration(
+ qName,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(SCRIPTLET_ACTION)) {
if (scriptlessBodyNode != null) {
// We're nested inside a node whose body is
// declared to be scriptless
throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.no.scriptlets",
- localName),
- locator);
+ Localizer.getMessage(
+ "jsp.error.no.scriptlets",
+ localName),
+ locator);
}
node =
- new Node.Scriptlet(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.Scriptlet(
+ qName,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(EXPRESSION_ACTION)) {
if (scriptlessBodyNode != null) {
// We're nested inside a node whose body is
// declared to be scriptless
throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.no.scriptlets",
- localName),
- locator);
+ Localizer.getMessage(
+ "jsp.error.no.scriptlets",
+ localName),
+ locator);
}
node =
- new Node.Expression(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.Expression(
+ qName,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(USE_BEAN_ACTION)) {
node =
- new Node.UseBean(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.UseBean(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(SET_PROPERTY_ACTION)) {
node =
- new Node.SetProperty(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.SetProperty(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(GET_PROPERTY_ACTION)) {
node =
- new Node.GetProperty(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.GetProperty(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(INCLUDE_ACTION)) {
node =
- new Node.IncludeAction(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.IncludeAction(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(FORWARD_ACTION)) {
node =
- new Node.ForwardAction(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.ForwardAction(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(PARAM_ACTION)) {
node =
- new Node.ParamAction(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.ParamAction(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(PARAMS_ACTION)) {
node =
- new Node.ParamsAction(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.ParamsAction(
+ qName,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(PLUGIN_ACTION)) {
node =
- new Node.PlugIn(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.PlugIn(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(TEXT_ACTION)) {
node =
- new Node.JspText(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.JspText(
+ qName,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(BODY_ACTION)) {
node =
- new Node.JspBody(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.JspBody(
+ qName,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(ATTRIBUTE_ACTION)) {
node =
- new Node.NamedAttribute(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.NamedAttribute(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(OUTPUT_ACTION)) {
node =
- new Node.JspOutput(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.JspOutput(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(TAG_DIRECTIVE_ACTION)) {
if (!isTagFile) {
throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.action.isnottagfile",
- localName),
- locator);
+ Localizer.getMessage(
+ "jsp.error.action.isnottagfile",
+ localName),
+ locator);
}
node =
- new Node.TagDirective(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.TagDirective(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
String imports = nonTaglibAttrs.getValue("import");
// There can only be one 'import' attribute per tag directive
if (imports != null) {
- ((Node.TagDirective)node).addImport(imports);
+ ((Node.TagDirective) node).addImport(imports);
}
} else if (localName.equals(ATTRIBUTE_DIRECTIVE_ACTION)) {
if (!isTagFile) {
throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.action.isnottagfile",
- localName),
- locator);
+ Localizer.getMessage(
+ "jsp.error.action.isnottagfile",
+ localName),
+ locator);
}
node =
- new Node.AttributeDirective(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.AttributeDirective(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(VARIABLE_DIRECTIVE_ACTION)) {
if (!isTagFile) {
throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.action.isnottagfile",
- localName),
- locator);
+ Localizer.getMessage(
+ "jsp.error.action.isnottagfile",
+ localName),
+ locator);
}
node =
- new Node.VariableDirective(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.VariableDirective(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(INVOKE_ACTION)) {
if (!isTagFile) {
throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.action.isnottagfile",
- localName),
- locator);
+ Localizer.getMessage(
+ "jsp.error.action.isnottagfile",
+ localName),
+ locator);
}
node =
- new Node.InvokeAction(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.InvokeAction(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(DOBODY_ACTION)) {
if (!isTagFile) {
throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.action.isnottagfile",
- localName),
- locator);
+ Localizer.getMessage(
+ "jsp.error.action.isnottagfile",
+ localName),
+ locator);
}
node =
- new Node.DoBodyAction(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.DoBodyAction(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(ELEMENT_ACTION)) {
node =
- new Node.JspElement(
- qName,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.JspElement(
+ qName,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else if (localName.equals(FALLBACK_ACTION)) {
node =
- new Node.FallBackAction(
- qName,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- current);
+ new Node.FallBackAction(
+ qName,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ current);
} else {
throw new SAXParseException(
- Localizer.getMessage(
- "jsp.error.xml.badStandardAction",
- localName),
- locator);
+ Localizer.getMessage(
+ "jsp.error.xml.badStandardAction",
+ localName),
+ locator);
}
return node;
@@ -1131,15 +1130,15 @@
* and returns the corresponding Node object.
*/
private Node parseCustomAction(
- String qName,
- String localName,
- String uri,
- Attributes nonTaglibAttrs,
- Attributes nonTaglibXmlnsAttrs,
- Attributes taglibAttrs,
- Mark start,
- Node parent)
- throws SAXException {
+ String qName,
+ String localName,
+ String uri,
+ Attributes nonTaglibAttrs,
+ Attributes nonTaglibXmlnsAttrs,
+ Attributes taglibAttrs,
+ Mark start,
+ Node parent)
+ throws SAXException {
// Check if this is a user-defined (custom) tag
TagLibraryInfo tagLibInfo = pageInfo.getTaglib(uri);
@@ -1151,20 +1150,20 @@
TagFileInfo tagFileInfo = tagLibInfo.getTagFile(localName);
if (tagInfo == null && tagFileInfo == null) {
throw new SAXException(
- Localizer.getMessage("jsp.error.xml.bad_tag", localName, uri));
+ Localizer.getMessage("jsp.error.xml.bad_tag", localName, uri));
}
Class tagHandlerClass = null;
if (tagInfo != null) {
String handlerClassName = tagInfo.getTagClassName();
try {
tagHandlerClass =
- ctxt.getClassLoader().loadClass(handlerClassName);
+ ctxt.getClassLoader().loadClass(handlerClassName);
} catch (Exception e) {
throw new SAXException(
- Localizer.getMessage("jsp.error.loadclass.taghandler",
- handlerClassName,
- qName),
- e);
+ Localizer.getMessage("jsp.error.loadclass.taghandler",
+ handlerClassName,
+ qName),
+ e);
}
}
@@ -1173,31 +1172,31 @@
Node.CustomTag ret = null;
if (tagInfo != null) {
ret =
- new Node.CustomTag(
- qName,
- prefix,
- localName,
- uri,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- parent,
- tagInfo,
- tagHandlerClass);
+ new Node.CustomTag(
+ qName,
+ prefix,
+ localName,
+ uri,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ parent,
+ tagInfo,
+ tagHandlerClass);
} else {
ret =
- new Node.CustomTag(
- qName,
- prefix,
- localName,
- uri,
- nonTaglibAttrs,
- nonTaglibXmlnsAttrs,
- taglibAttrs,
- start,
- parent,
- tagFileInfo);
+ new Node.CustomTag(
+ qName,
+ prefix,
+ localName,
+ uri,
+ nonTaglibAttrs,
+ nonTaglibXmlnsAttrs,
+ taglibAttrs,
+ start,
+ parent,
+ tagFileInfo);
}
return ret;
@@ -1213,7 +1212,7 @@
* @return The tag library associated with the given uri namespace
*/
private TagLibraryInfo getTaglibInfo(String prefix, String uri)
- throws JasperException {
+ throws JasperException {
TagLibraryInfo result = null;
@@ -1221,12 +1220,12 @@
// uri (of the form "urn:jsptagdir:path") references tag file dir
String tagdir = uri.substring(URN_JSPTAGDIR.length());
result =
- new ImplicitTagLibraryInfo(
- ctxt,
- parserController,
- prefix,
- tagdir,
- err);
+ new ImplicitTagLibraryInfo(
+ ctxt,
+ parserController,
+ prefix,
+ tagdir,
+ err);
} else {
// uri references TLD file
boolean isPlainUri = false;
@@ -1250,13 +1249,13 @@
* value must be treated as uninterpreted.
*/
result =
- new TagLibraryInfoImpl(
- ctxt,
- parserController,
- prefix,
- uri,
- location,
- err);
+ new TagLibraryInfoImpl(
+ ctxt,
+ parserController,
+ prefix,
+ uri,
+ location,
+ err);
if (ctxt.getOptions().isCaching()) {
ctxt.getOptions().getCache().put(uri, result);
}
@@ -1276,7 +1275,7 @@
* scripting element has been reached.
*/
private void checkScriptingBody(Node.ScriptingElement scriptingElem)
- throws SAXException {
+ throws SAXException {
Node.Nodes body = scriptingElem.getBody();
if (body != null) {
int size = body.size();
@@ -1289,9 +1288,9 @@
if (scriptingElem instanceof Node.Expression)
elemType = EXPRESSION_ACTION;
String msg =
- Localizer.getMessage(
- "jsp.error.parse.xml.scripting.invalid.body",
- elemType);
+ Localizer.getMessage(
+ "jsp.error.parse.xml.scripting.invalid.body",
+ elemType);
throw new SAXException(msg);
}
}
@@ -1306,7 +1305,7 @@
* @param parent The Node representing the include directive
*/
private void processIncludeDirective(String fname, Node parent)
- throws SAXException {
+ throws SAXException {
if (fname == null) {
return;
@@ -1316,9 +1315,9 @@
parserController.parse(fname, parent, null);
} catch (FileNotFoundException fnfe) {
throw new SAXParseException(
- Localizer.getMessage("jsp.error.file.not.found", fname),
- locator,
- fnfe);
+ Localizer.getMessage("jsp.error.file.not.found", fname),
+ locator,
+ fnfe);
} catch (Exception e) {
throw new SAXException(e);
}
@@ -1380,22 +1379,22 @@
* @return The SAXParser
*/
private static SAXParser getSAXParser(
- boolean validating,
- JspDocumentParser jspDocParser)
- throws Exception {
+ boolean validating,
+ JspDocumentParser jspDocParser)
+ throws Exception {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
// Preserve xmlns attributes
factory.setFeature(
- "http://xml.org/sax/features/namespace-prefixes",
- true);
+ "http://xml.org/sax/features/namespace-prefixes",
+ true);
factory.setValidating(validating);
//factory.setFeature(
// "http://xml.org/sax/features/validation",
// validating);
-
+
// Configure the parser
SAXParser saxParser = factory.newSAXParser();
XMLReader xmlReader = saxParser.getXMLReader();
@@ -1410,7 +1409,7 @@
* validation is turned off.
*/
private static class EnableDTDValidationException
- extends SAXParseException {
+ extends SAXParseException {
EnableDTDValidationException(String message, Locator loc) {
super(message, loc);
@@ -1431,7 +1430,7 @@
if (n instanceof Node.CustomTag) {
String bodyType = getBodyType((Node.CustomTag) n);
return
- TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType);
+ TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType);
}
return false;
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspReader.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspReader.java
index 457f44a..ccb4a9f 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspReader.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspReader.java
@@ -17,8 +17,8 @@
package org.apache.struts2.jasper.compiler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.JasperException;
import org.apache.struts2.jasper.JspCompilationContext;
@@ -53,7 +53,7 @@
/**
* Logger.
*/
- private Log log = LogFactory.getLog(JspReader.class);
+ private Logger log = LoggerFactory.getLogger(JspReader.class);
/**
* The current spot in the file.
@@ -100,14 +100,14 @@
/**
* Constructor.
*
- * @param ctxt The compilation context
- * @param fname The file name
+ * @param ctxt The compilation context
+ * @param fname The file name
* @param encoding The file encoding
- * @param jarFile ?
- * @param err The error dispatcher
- * @throws JasperException If a Jasper-internal error occurs
+ * @param jarFile ?
+ * @param err The error dispatcher
+ * @throws JasperException If a Jasper-internal error occurs
* @throws FileNotFoundException If the JSP file is not found (or is unreadable)
- * @throws IOException If an IO-level error occurs, e.g. reading the file
+ * @throws IOException If an IO-level error occurs, e.g. reading the file
*/
public JspReader(JspCompilationContext ctxt,
String fname,
@@ -117,8 +117,8 @@
throws JasperException, FileNotFoundException, IOException {
this(ctxt, fname, encoding,
- JspUtil.getReader(fname, encoding, jarFile, ctxt, err),
- err);
+ JspUtil.getReader(fname, encoding, jarFile, ctxt, err),
+ err);
}
/**
@@ -142,13 +142,13 @@
}
/**
- * @return JSP compilation context with which this JspReader is
- * associated
+ * @return JSP compilation context with which this JspReader is
+ * associated
*/
JspCompilationContext getJspCompilationContext() {
return context;
}
-
+
/**
* Returns the file at the given position in the list.
*
@@ -158,16 +158,16 @@
String getFile(final int fileid) {
return (String) sourceFiles.get(fileid);
}
-
+
/**
* Checks if the current file has more input.
*
* @return True if more reading is possible
* @throws JasperException if an error occurs
- */
+ */
boolean hasMoreInput() throws JasperException {
if (current.cursor >= current.stream.length) {
- if (singleFile) return false;
+ if (singleFile) return false;
while (popFile()) {
if (current.cursor < current.stream.length) return true;
}
@@ -175,15 +175,15 @@
}
return true;
}
-
+
int nextChar() throws JasperException {
if (!hasMoreInput())
return -1;
-
+
int ch = current.stream[current.cursor];
current.cursor++;
-
+
if (ch == '\n') {
current.line++;
current.col = 0;
@@ -244,10 +244,11 @@
/**
* search the stream for a match to a string
+ *
* @param string The string to match
* @return <strong>true</strong> is one is found, the current position
* in stream is positioned after the search string, <strong>
- * false</strong> otherwise, position in stream unchanged.
+ * false</strong> otherwise, position in stream unchanged.
*/
boolean matches(String string) throws JasperException {
Mark mark = mark();
@@ -277,18 +278,17 @@
}
boolean matchesETagWithoutLessThan(String tagName)
- throws JasperException
- {
- Mark mark = mark();
+ throws JasperException {
+ Mark mark = mark();
- if (!matches("/" + tagName))
- return false;
- skipSpaces();
- if (nextChar() == '>')
- return true;
+ if (!matches("/" + tagName))
+ return false;
+ skipSpaces();
+ if (nextChar() == '>')
+ return true;
- reset(mark);
- return false;
+ reset(mark);
+ return false;
}
@@ -298,15 +298,14 @@
* characters are skipped. If not, false is returned and the
* position is restored to where we were before.
*/
- boolean matchesOptionalSpacesFollowedBy( String s )
- throws JasperException
- {
+ boolean matchesOptionalSpacesFollowedBy(String s)
+ throws JasperException {
Mark mark = mark();
skipSpaces();
- boolean result = matches( s );
- if( !result ) {
- reset( mark );
+ boolean result = matches(s);
+ if (!result) {
+ reset(mark);
}
return result;
@@ -335,12 +334,12 @@
int limlen = limit.length();
int ch;
- skip:
- for (ret = mark(), ch = nextChar() ; ch != -1 ;
- ret = mark(), ch = nextChar()) {
+ skip:
+ for (ret = mark(), ch = nextChar(); ch != -1;
+ ret = mark(), ch = nextChar()) {
if (ch == limit.charAt(0)) {
Mark restart = mark();
- for (int i = 1 ; i < limlen ; i++) {
+ for (int i = 1; i < limlen; i++) {
if (peekChar() == limit.charAt(i))
nextChar();
else {
@@ -369,15 +368,14 @@
int limlen = limit.length();
int ch;
int prev = 'x'; // Doesn't matter
-
- skip:
- for (ret = mark(), ch = nextChar() ; ch != -1 ;
- ret = mark(), prev = ch, ch = nextChar()) {
+
+ skip:
+ for (ret = mark(), ch = nextChar(); ch != -1;
+ ret = mark(), prev = ch, ch = nextChar()) {
if (ch == '\\' && prev == '\\') {
ch = 0; // Double \ is not an escape char anymore
- }
- else if (ch == limit.charAt(0) && prev != '\\') {
- for (int i = 1 ; i < limlen ; i++) {
+ } else if (ch == limit.charAt(0) && prev != '\\') {
+ for (int i = 1; i < limlen; i++) {
if (peekChar() == limit.charAt(i))
nextChar();
else
@@ -388,14 +386,14 @@
}
return null;
}
-
+
/**
* Skip until the given end tag is matched in the stream.
* When returned, the context is positioned past the end of the tag.
*
* @param tag The name of the tag whose ETag (</tag>) to match.
* @return A non-null <code>Mark</code> instance (positioned immediately
- * before the ETag) if found, <strong>null</strong> otherwise.
+ * before the ETag) if found, <strong>null</strong> otherwise.
*/
Mark skipUntilETag(String tag) throws JasperException {
Mark ret = skipUntil("</" + tag);
@@ -423,13 +421,13 @@
StringBuffer stringBuffer = new StringBuffer();
skipSpaces();
stringBuffer.setLength(0);
-
+
if (!hasMoreInput()) {
return "";
}
int ch = peekChar();
-
+
if (quoted) {
if (ch == '"' || ch == '\'') {
@@ -437,8 +435,8 @@
// Consume the open quote:
ch = nextChar();
for (ch = nextChar(); ch != -1 && ch != endQuote;
- ch = nextChar()) {
- if (ch == '\\')
+ ch = nextChar()) {
+ if (ch == '\\')
ch = nextChar();
stringBuffer.append((char) ch);
}
@@ -457,7 +455,7 @@
// Take care of the quoting here.
if (ch == '\\') {
if (peekChar() == '"' || peekChar() == '\'' ||
- peekChar() == '>' || peekChar() == '%')
+ peekChar() == '>' || peekChar() == '%')
ch = nextChar();
}
stringBuffer.append((char) ch);
@@ -477,11 +475,9 @@
* Gets the URL for the given path name.
*
* @param path Path name
- *
* @return URL for the given path name.
- *
- * @exception MalformedURLException if the path name is not given in
- * the correct form
+ * @throws MalformedURLException if the path name is not given in
+ * the correct form
*/
URL getResource(String path) throws MalformedURLException {
return context.getResource(path);
@@ -496,7 +492,7 @@
* @return A boolean.
*/
private boolean isDelimiter() throws JasperException {
- if (! isSpace()) {
+ if (!isSpace()) {
int ch = peekChar();
// Look for a single-char work delimiter:
if (ch == '=' || ch == '>' || ch == '"' || ch == '\''
@@ -539,7 +535,7 @@
return sourceFiles.size() - 1;
}
-
+
/**
* Unregister the source file.
@@ -563,9 +559,9 @@
* Push a file (and its associated Stream) on the file stack. THe
* current position in the current file is remembered.
*/
- private void pushFile(String file, String encoding,
- InputStreamReader reader)
- throws JasperException, FileNotFoundException {
+ private void pushFile(String file, String encoding,
+ InputStreamReader reader)
+ throws JasperException, FileNotFoundException {
// Register the file
String longName = file;
@@ -574,11 +570,11 @@
if (fileid == -1) {
// Bugzilla 37407: http://issues.apache.org/bugzilla/show_bug.cgi?id=37407
- if(reader != null) {
+ if (reader != null) {
try {
reader.close();
} catch (Exception any) {
- if(log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
log.debug("Exception closing reader: ", any);
}
}
@@ -592,15 +588,15 @@
try {
CharArrayWriter caw = new CharArrayWriter();
char buf[] = new char[1024];
- for (int i = 0 ; (i = reader.read(buf)) != -1 ;)
+ for (int i = 0; (i = reader.read(buf)) != -1;)
caw.write(buf, 0, i);
caw.close();
if (current == null) {
- current = new Mark(this, caw.toCharArray(), fileid,
- getFile(fileid), master, encoding);
+ current = new Mark(this, caw.toCharArray(), fileid,
+ getFile(fileid), master, encoding);
} else {
current.pushStream(caw.toCharArray(), fileid, getFile(fileid),
- longName, encoding);
+ longName, encoding);
}
} catch (Throwable ex) {
log.error("Exception parsing file ", ex);
@@ -612,7 +608,7 @@
try {
reader.close();
} catch (Exception any) {
- if(log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
log.debug("Exception closing reader: ", any);
}
}
@@ -624,6 +620,7 @@
* Pop a file from the file stack. The field "current" is retored
* to the value to point to the previous files, if any, and is set
* to null otherwise.
+ *
* @return true is there is a previous file on the stack.
* false otherwise.
*/
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspRuntimeContext.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspRuntimeContext.java
index 75143e7..cc64f6c 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspRuntimeContext.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspRuntimeContext.java
@@ -17,8 +17,8 @@
package org.apache.struts2.jasper.compiler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.Constants;
import org.apache.struts2.jasper.JspCompilationContext;
import org.apache.struts2.jasper.Options;
@@ -45,11 +45,11 @@
/**
* Class for tracking JSP compile time file dependencies when the
* &060;%@include file="..."%&062; directive is used.
- *
+ * <p/>
* A background thread periodically checks the files a JSP page
* is dependent upon. If a dpendent file changes the JSP page
* which included it is recompiled.
- *
+ * <p/>
* Only used if a web application context is a directory.
*
* @author Glenn L. Nielsen
@@ -58,7 +58,7 @@
public final class JspRuntimeContext implements Runnable {
// Logger
- private Log log = LogFactory.getLog(JspRuntimeContext.class);
+ private Logger log = LoggerFactory.getLogger(JspRuntimeContext.class);
/*
* Counts how many times the webapp's JSPs have been reloaded.
@@ -79,7 +79,7 @@
/**
* Create a JspRuntimeContext for a web application context.
- *
+ * <p/>
* Loads in any previously generated dependencies from file.
*
* @param context ServletContext for web application
@@ -91,27 +91,27 @@
// Get the parent class loader
parentClassLoader =
- (URLClassLoader) Thread.currentThread().getContextClassLoader();
+ (URLClassLoader) Thread.currentThread().getContextClassLoader();
if (parentClassLoader == null) {
parentClassLoader =
- (URLClassLoader)this.getClass().getClassLoader();
+ (URLClassLoader) this.getClass().getClassLoader();
}
- if (log.isDebugEnabled()) {
- if (parentClassLoader != null) {
- log.debug(Localizer.getMessage("jsp.message.parent_class_loader_is",
- parentClassLoader.toString()));
- } else {
- log.debug(Localizer.getMessage("jsp.message.parent_class_loader_is",
- "<none>"));
- }
+ if (log.isDebugEnabled()) {
+ if (parentClassLoader != null) {
+ log.debug(Localizer.getMessage("jsp.message.parent_class_loader_is",
+ parentClassLoader.toString()));
+ } else {
+ log.debug(Localizer.getMessage("jsp.message.parent_class_loader_is",
+ "<none>"));
+ }
}
initClassPath();
- if (context instanceof org.apache.struts2.jasper.servlet.JspCServletContext) {
- return;
- }
+ if (context instanceof org.apache.struts2.jasper.servlet.JspCServletContext) {
+ return;
+ }
if (System.getSecurityManager() != null) {
initSecurity();
@@ -119,18 +119,18 @@
// If this web application context is running from a
// directory, start the background compilation thread
- String appBase = context.getRealPath("/");
+ String appBase = context.getRealPath("/");
if (!options.getDevelopment()
&& appBase != null
&& options.getCheckInterval() > 0) {
- if (appBase.endsWith(File.separator) ) {
- appBase = appBase.substring(0,appBase.length()-1);
+ if (appBase.endsWith(File.separator)) {
+ appBase = appBase.substring(0, appBase.length() - 1);
}
String directory =
- appBase.substring(appBase.lastIndexOf(File.separator));
+ appBase.substring(appBase.lastIndexOf(File.separator));
threadName = threadName + "[" + directory + "]";
threadStart();
- }
+ }
}
// ----------------------------------------------------- Instance Variables
@@ -142,14 +142,14 @@
private Options options;
private URLClassLoader parentClassLoader;
private PermissionCollection permissionCollection;
- private CodeSource codeSource;
+ private CodeSource codeSource;
private String classpath;
/**
* Maps JSP pages to their JspServletWrapper's
*/
- private Map jsps = Collections.synchronizedMap( new HashMap());
-
+ private Map jsps = Collections.synchronizedMap(new HashMap());
+
/**
* The background thread.
@@ -174,11 +174,11 @@
* Add a new JspServletWrapper.
*
* @param jspUri JSP URI
- * @param jsw Servlet wrapper for JSP
+ * @param jsw Servlet wrapper for JSP
*/
public void addWrapper(String jspUri, JspServletWrapper jsw) {
jsps.remove(jspUri);
- jsps.put(jspUri,jsw);
+ jsps.put(jspUri, jsw);
}
/**
@@ -241,7 +241,7 @@
/**
* Process a "destory" event for this web application context.
- */
+ */
public void destroy() {
threadStop();
@@ -284,20 +284,20 @@
* registered with this class for JSP's.
*/
private void checkCompile() {
- Object [] wrappers = jsps.values().toArray();
- for (int i = 0; i < wrappers.length; i++ ) {
- JspServletWrapper jsw = (JspServletWrapper)wrappers[i];
+ Object[] wrappers = jsps.values().toArray();
+ for (int i = 0; i < wrappers.length; i++) {
+ JspServletWrapper jsw = (JspServletWrapper) wrappers[i];
JspCompilationContext ctxt = jsw.getJspEngineContext();
// JspServletWrapper also synchronizes on this when
// it detects it has to do a reload
- synchronized(jsw) {
+ synchronized (jsw) {
try {
ctxt.compile();
} catch (FileNotFoundException ex) {
ctxt.incrementRemoved();
} catch (Throwable t) {
jsw.getServletContext().log("Background compile failed",
- t);
+ t);
}
}
}
@@ -315,22 +315,22 @@
*/
private void initClassPath() {
- URL [] urls = parentClassLoader.getURLs();
+ URL[] urls = parentClassLoader.getURLs();
StringBuffer cpath = new StringBuffer();
String sep = System.getProperty("path.separator");
- for(int i = 0; i < urls.length; i++) {
+ for (int i = 0; i < urls.length; i++) {
// Tomcat 4 can use URL's other than file URL's,
// a protocol other than file: will generate a
// bad file system path, so only add file:
// protocol URL's to the classpath.
-
- if( urls[i].getProtocol().equals("file") ) {
- cpath.append((String)urls[i].getFile()+sep);
- }
- }
- cpath.append(options.getScratchDir() + sep);
+ if (urls[i].getProtocol().equals("file")) {
+ cpath.append((String) urls[i].getFile() + sep);
+ }
+ }
+
+ cpath.append(options.getScratchDir() + sep);
String cp = (String) context.getAttribute(Constants.SERVLET_CLASSPATH);
if (cp == null || cp.equals("")) {
@@ -339,7 +339,7 @@
classpath = cpath.toString() + cp;
- if(log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
log.debug("Compilation classpath initialized: " + getClassPath());
}
}
@@ -354,80 +354,80 @@
// web app context directory, then add a file read permission
// for that directory.
Policy policy = Policy.getPolicy();
- if( policy != null ) {
- try {
+ if (policy != null) {
+ try {
// Get the permissions for the web app context
String docBase = context.getRealPath("/");
- if( docBase == null ) {
+ if (docBase == null) {
docBase = options.getScratchDir().toString();
}
String codeBase = docBase;
- if (!codeBase.endsWith(File.separator)){
+ if (!codeBase.endsWith(File.separator)) {
codeBase = codeBase + File.separator;
}
File contextDir = new File(codeBase);
URL url = contextDir.getCanonicalFile().toURL();
- codeSource = new CodeSource(url,(Certificate[])null);
+ codeSource = new CodeSource(url, (Certificate[]) null);
permissionCollection = policy.getPermissions(codeSource);
// Create a file read permission for web app context directory
- if (!docBase.endsWith(File.separator)){
+ if (!docBase.endsWith(File.separator)) {
permissionCollection.add
- (new FilePermission(docBase,"read"));
+ (new FilePermission(docBase, "read"));
docBase = docBase + File.separator;
} else {
permissionCollection.add
- (new FilePermission
- (docBase.substring(0,docBase.length() - 1),"read"));
+ (new FilePermission
+ (docBase.substring(0, docBase.length() - 1), "read"));
}
docBase = docBase + "-";
- permissionCollection.add(new FilePermission(docBase,"read"));
+ permissionCollection.add(new FilePermission(docBase, "read"));
// Create a file read permission for web app tempdir (work)
// directory
String workDir = options.getScratchDir().toString();
- if (!workDir.endsWith(File.separator)){
+ if (!workDir.endsWith(File.separator)) {
permissionCollection.add
- (new FilePermission(workDir,"read"));
+ (new FilePermission(workDir, "read"));
workDir = workDir + File.separator;
}
workDir = workDir + "-";
- permissionCollection.add(new FilePermission(workDir,"read"));
+ permissionCollection.add(new FilePermission(workDir, "read"));
// Allow the JSP to access org.apache.struts2.jasper.runtime.HttpJspBase
- permissionCollection.add( new RuntimePermission(
- "accessClassInPackage.org.apache.struts2.jasper.runtime") );
+ permissionCollection.add(new RuntimePermission(
+ "accessClassInPackage.org.apache.struts2.jasper.runtime"));
if (parentClassLoader instanceof URLClassLoader) {
- URL [] urls = parentClassLoader.getURLs();
+ URL[] urls = parentClassLoader.getURLs();
String jarUrl = null;
String jndiUrl = null;
- for (int i=0; i<urls.length; i++) {
+ for (int i = 0; i < urls.length; i++) {
if (jndiUrl == null
- && urls[i].toString().startsWith("jndi:") ) {
+ && urls[i].toString().startsWith("jndi:")) {
jndiUrl = urls[i].toString() + "-";
}
if (jarUrl == null
&& urls[i].toString().startsWith("jar:jndi:")
) {
jarUrl = urls[i].toString();
- jarUrl = jarUrl.substring(0,jarUrl.length() - 2);
+ jarUrl = jarUrl.substring(0, jarUrl.length() - 2);
jarUrl = jarUrl.substring(0,
- jarUrl.lastIndexOf('/')) + "/-";
+ jarUrl.lastIndexOf('/')) + "/-";
}
}
if (jarUrl != null) {
permissionCollection.add(
- new FilePermission(jarUrl,"read"));
+ new FilePermission(jarUrl, "read"));
permissionCollection.add(
- new FilePermission(jarUrl.substring(4),"read"));
+ new FilePermission(jarUrl.substring(4), "read"));
}
if (jndiUrl != null)
permissionCollection.add(
- new FilePermission(jndiUrl,"read") );
+ new FilePermission(jndiUrl, "read"));
}
- } catch(Exception e) {
- context.log("Security Init for context failed",e);
+ } catch (Exception e) {
+ context.log("Security Init for context failed", e);
}
}
}
@@ -439,8 +439,8 @@
* Start the background thread that will periodically check for
* changes to compile time included files in a JSP.
*
- * @exception IllegalStateException if we should not be starting
- * a background thread now
+ * @throws IllegalStateException if we should not be starting
+ * a background thread now
*/
protected void threadStart() {
@@ -461,7 +461,7 @@
/**
* Stop the background thread that is periodically checking for
* changes to compile time included files in a JSP.
- */
+ */
protected void threadStop() {
if (thread == null) {
@@ -475,35 +475,35 @@
} catch (InterruptedException e) {
;
}
-
+
thread = null;
-
+
}
/**
* Sleep for the duration specified by the <code>checkInterval</code>
* property.
- */
+ */
protected void threadSleep() {
-
+
try {
Thread.sleep(options.getCheckInterval() * 1000L);
} catch (InterruptedException e) {
;
}
-
- }
-
-
+
+ }
+
+
// ------------------------------------------------------ Background Thread
-
-
+
+
/**
* The background thread that checks for changes to files
* included by a JSP and flags that a recompile is required.
- */
+ */
public void run() {
-
+
// Loop until the termination semaphore is set
while (!threadDone) {
@@ -518,7 +518,7 @@
log.error("Exception checking if recompile needed: ", t);
}
}
-
+
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspUtil.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspUtil.java
index 13cb75c..aa6ea6b 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspUtil.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/JspUtil.java
@@ -31,7 +31,7 @@
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
-/**
+/**
* This class has all the utility method(s).
* Ideally should move all the bean containers here.
*
@@ -48,34 +48,34 @@
private static final String META_INF_TAGS = "/META-INF/tags/";
// Delimiters for request-time expressions (JSP and XML syntax)
- private static final String OPEN_EXPR = "<%=";
+ private static final String OPEN_EXPR = "<%=";
private static final String CLOSE_EXPR = "%>";
- private static final String OPEN_EXPR_XML = "%=";
+ private static final String OPEN_EXPR_XML = "%=";
private static final String CLOSE_EXPR_XML = "%";
private static int tempSequenceNumber = 0;
private static ExpressionEvaluatorImpl expressionEvaluator
- = new ExpressionEvaluatorImpl();
+ = new ExpressionEvaluatorImpl();
private static final String javaKeywords[] = {
- "abstract", "assert", "boolean", "break", "byte", "case",
- "catch", "char", "class", "const", "continue",
- "default", "do", "double", "else", "enum", "extends",
- "final", "finally", "float", "for", "goto",
- "if", "implements", "import", "instanceof", "int",
- "interface", "long", "native", "new", "package",
- "private", "protected", "public", "return", "short",
- "static", "strictfp", "super", "switch", "synchronized",
- "this", "throws", "transient", "try", "void",
- "volatile", "while" };
+ "abstract", "assert", "boolean", "break", "byte", "case",
+ "catch", "char", "class", "const", "continue",
+ "default", "do", "double", "else", "enum", "extends",
+ "final", "finally", "float", "for", "goto",
+ "if", "implements", "import", "instanceof", "int",
+ "interface", "long", "native", "new", "package",
+ "private", "protected", "public", "return", "short",
+ "static", "strictfp", "super", "switch", "synchronized",
+ "this", "throws", "transient", "try", "void",
+ "volatile", "while"};
public static final int CHUNKSIZE = 1024;
-
- public static char[] removeQuotes(char []chars) {
+
+ public static char[] removeQuotes(char[] chars) {
CharArrayWriter caw = new CharArrayWriter();
for (int i = 0; i < chars.length; i++) {
- if (chars[i] == '%' && chars[i+1] == '\\' &&
- chars[i+2] == '>') {
+ if (chars[i] == '%' && chars[i + 1] == '\\' &&
+ chars[i + 2] == '>') {
caw.write('%');
caw.write('>');
i = i + 2;
@@ -86,7 +86,7 @@
return caw.toCharArray();
}
- public static char[] escapeQuotes (char []chars) {
+ public static char[] escapeQuotes(char[] chars) {
// Prescan to convert %\> to %>
String s = new String(chars);
while (true) {
@@ -123,49 +123,49 @@
* expression starts with '%=' and ends with '%'.
*
* @param token The token to be checked
- * return whether the token is a runtime expression or not.
+ * return whether the token is a runtime expression or not.
*/
public static boolean isExpression(String token, boolean isXml) {
- String openExpr;
- String closeExpr;
- if (isXml) {
- openExpr = OPEN_EXPR_XML;
- closeExpr = CLOSE_EXPR_XML;
- } else {
- openExpr = OPEN_EXPR;
- closeExpr = CLOSE_EXPR;
- }
- if (token.startsWith(openExpr) && token.endsWith(closeExpr)) {
- return true;
- } else {
- return false;
- }
+ String openExpr;
+ String closeExpr;
+ if (isXml) {
+ openExpr = OPEN_EXPR_XML;
+ closeExpr = CLOSE_EXPR_XML;
+ } else {
+ openExpr = OPEN_EXPR;
+ closeExpr = CLOSE_EXPR;
+ }
+ if (token.startsWith(openExpr) && token.endsWith(closeExpr)) {
+ return true;
+ } else {
+ return false;
+ }
}
/**
- * @return the "expression" part of a runtime expression,
- * taking the delimiters out.
+ * @return the "expression" part of a runtime expression,
+ * taking the delimiters out.
*/
- public static String getExpr (String expression, boolean isXml) {
- String returnString;
- String openExpr;
- String closeExpr;
- if (isXml) {
- openExpr = OPEN_EXPR_XML;
- closeExpr = CLOSE_EXPR_XML;
- } else {
- openExpr = OPEN_EXPR;
- closeExpr = CLOSE_EXPR;
- }
- int length = expression.length();
- if (expression.startsWith(openExpr) &&
+ public static String getExpr(String expression, boolean isXml) {
+ String returnString;
+ String openExpr;
+ String closeExpr;
+ if (isXml) {
+ openExpr = OPEN_EXPR_XML;
+ closeExpr = CLOSE_EXPR_XML;
+ } else {
+ openExpr = OPEN_EXPR;
+ closeExpr = CLOSE_EXPR;
+ }
+ int length = expression.length();
+ if (expression.startsWith(openExpr) &&
expression.endsWith(closeExpr)) {
- returnString = expression.substring(
- openExpr.length(), length - closeExpr.length());
- } else {
- returnString = "";
- }
- return returnString;
+ returnString = expression.substring(
+ openExpr.length(), length - closeExpr.length());
+ } else {
+ returnString = "";
+ }
+ return returnString;
}
/**
@@ -175,9 +175,9 @@
String returnString;
int length = expression.length();
- if (expression.startsWith(OPEN_EXPR)
+ if (expression.startsWith(OPEN_EXPR)
&& expression.endsWith(CLOSE_EXPR)) {
- returnString = expression.substring (1, length - 1);
+ returnString = expression.substring(1, length - 1);
} else {
returnString = expression;
}
@@ -189,40 +189,39 @@
* Checks to see if the given scope is valid.
*
* @param scope The scope to be checked
- * @param n The Node containing the 'scope' attribute whose value is to be
- * checked
- * @param err error dispatcher
- *
+ * @param n The Node containing the 'scope' attribute whose value is to be
+ * checked
+ * @param err error dispatcher
* @throws JasperException if scope is not null and different from
- * "page", "request", "session", and
- * "application"
+ * "page", "request", "session", and
+ * "application"
*/
public static void checkScope(String scope, Node n, ErrorDispatcher err)
throws JasperException {
- if (scope != null && !scope.equals("page") && !scope.equals("request")
- && !scope.equals("session") && !scope.equals("application")) {
- err.jspError(n, "jsp.error.invalid.scope", scope);
- }
+ if (scope != null && !scope.equals("page") && !scope.equals("request")
+ && !scope.equals("session") && !scope.equals("application")) {
+ err.jspError(n, "jsp.error.invalid.scope", scope);
+ }
}
/**
* Checks if all mandatory attributes are present and if all attributes
* present have valid names. Checks attributes specified as XML-style
* attributes as well as attributes specified using the jsp:attribute
- * standard action.
+ * standard action.
*/
public static void checkAttributes(String typeOfTag,
- Node n,
- ValidAttribute[] validAttributes,
- ErrorDispatcher err)
- throws JasperException {
+ Node n,
+ ValidAttribute[] validAttributes,
+ ErrorDispatcher err)
+ throws JasperException {
Attributes attrs = n.getAttributes();
Mark start = n.getStart();
- boolean valid = true;
+ boolean valid = true;
// AttributesImpl.removeAttribute is broken, so we do this...
int tempLength = (attrs == null) ? 0 : attrs.getLength();
- Vector temp = new Vector(tempLength, 1);
+ Vector temp = new Vector(tempLength, 1);
for (int i = 0; i < tempLength; i++) {
String qName = attrs.getQName(i);
if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:")))
@@ -231,20 +230,19 @@
// Add names of attributes specified using jsp:attribute
Node.Nodes tagBody = n.getBody();
- if( tagBody != null ) {
+ if (tagBody != null) {
int numSubElements = tagBody.size();
- for( int i = 0; i < numSubElements; i++ ) {
- Node node = tagBody.getNode( i );
- if( node instanceof Node.NamedAttribute ) {
- String attrName = node.getAttributeValue( "name" );
- temp.addElement( attrName );
- // Check if this value appear in the attribute of the node
- if (n.getAttributeValue(attrName) != null) {
- err.jspError(n, "jsp.error.duplicate.name.jspattribute",
- attrName);
- }
- }
- else {
+ for (int i = 0; i < numSubElements; i++) {
+ Node node = tagBody.getNode(i);
+ if (node instanceof Node.NamedAttribute) {
+ String attrName = node.getAttributeValue("name");
+ temp.addElement(attrName);
+ // Check if this value appear in the attribute of the node
+ if (n.getAttributeValue(attrName) != null) {
+ err.jspError(n, "jsp.error.duplicate.name.jspattribute",
+ attrName);
+ }
+ } else {
// Nothing can come before jsp:attribute, and only
// jsp:body can come after it.
break;
@@ -252,82 +250,82 @@
}
}
- /*
- * First check to see if all the mandatory attributes are present.
- * If so only then proceed to see if the other attributes are valid
- * for the particular tag.
- */
- String missingAttribute = null;
+ /*
+ * First check to see if all the mandatory attributes are present.
+ * If so only then proceed to see if the other attributes are valid
+ * for the particular tag.
+ */
+ String missingAttribute = null;
- for (int i = 0; i < validAttributes.length; i++) {
- int attrPos;
- if (validAttributes[i].mandatory) {
+ for (int i = 0; i < validAttributes.length; i++) {
+ int attrPos;
+ if (validAttributes[i].mandatory) {
attrPos = temp.indexOf(validAttributes[i].name);
- if (attrPos != -1) {
- temp.remove(attrPos);
- valid = true;
- } else {
- valid = false;
- missingAttribute = validAttributes[i].name;
- break;
- }
- }
- }
+ if (attrPos != -1) {
+ temp.remove(attrPos);
+ valid = true;
+ } else {
+ valid = false;
+ missingAttribute = validAttributes[i].name;
+ break;
+ }
+ }
+ }
- // If mandatory attribute is missing then the exception is thrown
- if (!valid)
- err.jspError(start, "jsp.error.mandatory.attribute", typeOfTag,
- missingAttribute);
+ // If mandatory attribute is missing then the exception is thrown
+ if (!valid)
+ err.jspError(start, "jsp.error.mandatory.attribute", typeOfTag,
+ missingAttribute);
- // Check to see if there are any more attributes for the specified tag.
+ // Check to see if there are any more attributes for the specified tag.
int attrLeftLength = temp.size();
- if (attrLeftLength == 0)
- return;
+ if (attrLeftLength == 0)
+ return;
- // Now check to see if the rest of the attributes are valid too.
- String attribute = null;
+ // Now check to see if the rest of the attributes are valid too.
+ String attribute = null;
- for (int j = 0; j < attrLeftLength; j++) {
- valid = false;
- attribute = (String) temp.elementAt(j);
- for (int i = 0; i < validAttributes.length; i++) {
- if (attribute.equals(validAttributes[i].name)) {
- valid = true;
- break;
- }
- }
- if (!valid)
- err.jspError(start, "jsp.error.invalid.attribute", typeOfTag,
- attribute);
- }
- // XXX *could* move EL-syntax validation here... (sb)
+ for (int j = 0; j < attrLeftLength; j++) {
+ valid = false;
+ attribute = (String) temp.elementAt(j);
+ for (int i = 0; i < validAttributes.length; i++) {
+ if (attribute.equals(validAttributes[i].name)) {
+ valid = true;
+ break;
+ }
+ }
+ if (!valid)
+ err.jspError(start, "jsp.error.invalid.attribute", typeOfTag,
+ attribute);
+ }
+ // XXX *could* move EL-syntax validation here... (sb)
}
-
+
public static String escapeQueryString(String unescString) {
- if ( unescString == null )
- return null;
-
- String escString = "";
- String shellSpChars = "\\\"";
-
- for(int index=0; index<unescString.length(); index++) {
- char nextChar = unescString.charAt(index);
-
- if( shellSpChars.indexOf(nextChar) != -1 )
- escString += "\\";
-
- escString += nextChar;
- }
- return escString;
+ if (unescString == null)
+ return null;
+
+ String escString = "";
+ String shellSpChars = "\\\"";
+
+ for (int index = 0; index < unescString.length(); index++) {
+ char nextChar = unescString.charAt(index);
+
+ if (shellSpChars.indexOf(nextChar) != -1)
+ escString += "\\";
+
+ escString += nextChar;
+ }
+ return escString;
}
-
+
/**
- * Escape the 5 entities defined by XML.
+ * Escape the 5 entities defined by XML.
*/
public static String escapeXml(String s) {
if (s == null) return null;
StringBuffer sb = new StringBuffer();
- for(int i=0; i<s.length(); i++) {
+ for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '<') {
sb.append("<");
@@ -351,189 +349,188 @@
* string <tt>with</tt>.
*/
public static String replace(String name, char replace, String with) {
- StringBuffer buf = new StringBuffer();
- int begin = 0;
- int end;
- int last = name.length();
+ StringBuffer buf = new StringBuffer();
+ int begin = 0;
+ int end;
+ int last = name.length();
- while (true) {
- end = name.indexOf(replace, begin);
- if (end < 0) {
- end = last;
- }
- buf.append(name.substring(begin, end));
- if (end == last) {
- break;
- }
- buf.append(with);
- begin = end + 1;
- }
-
- return buf.toString();
+ while (true) {
+ end = name.indexOf(replace, begin);
+ if (end < 0) {
+ end = last;
+ }
+ buf.append(name.substring(begin, end));
+ if (end == last) {
+ break;
+ }
+ buf.append(with);
+ begin = end + 1;
+ }
+
+ return buf.toString();
}
public static class ValidAttribute {
- String name;
- boolean mandatory;
- boolean rtexprvalue; // not used now
+ String name;
+ boolean mandatory;
+ boolean rtexprvalue; // not used now
- public ValidAttribute (String name, boolean mandatory,
- boolean rtexprvalue )
- {
- this.name = name;
- this.mandatory = mandatory;
+ public ValidAttribute(String name, boolean mandatory,
+ boolean rtexprvalue) {
+ this.name = name;
+ this.mandatory = mandatory;
this.rtexprvalue = rtexprvalue;
}
- public ValidAttribute (String name, boolean mandatory) {
- this( name, mandatory, false );
- }
+ public ValidAttribute(String name, boolean mandatory) {
+ this(name, mandatory, false);
+ }
- public ValidAttribute (String name) {
- this (name, false);
- }
+ public ValidAttribute(String name) {
+ this(name, false);
+ }
}
-
+
/**
* Convert a String value to 'boolean'.
* Besides the standard conversions done by
* Boolean.valueOf(s).booleanValue(), the value "yes"
- * (ignore case) is also converted to 'true'.
+ * (ignore case) is also converted to 'true'.
* If 's' is null, then 'false' is returned.
*
* @param s the string to be converted
* @return the boolean value associated with the string s
*/
public static boolean booleanValue(String s) {
- boolean b = false;
- if (s != null) {
- if (s.equalsIgnoreCase("yes")) {
- b = true;
- } else {
- b = Boolean.valueOf(s).booleanValue();
- }
- }
- return b;
+ boolean b = false;
+ if (s != null) {
+ if (s.equalsIgnoreCase("yes")) {
+ b = true;
+ } else {
+ b = Boolean.valueOf(s).booleanValue();
+ }
+ }
+ return b;
}
/**
* Returns the <tt>Class</tt> object associated with the class or
* interface with the given string name.
- *
+ * <p/>
* <p> The <tt>Class</tt> object is determined by passing the given string
* name to the <tt>Class.forName()</tt> method, unless the given string
* name represents a primitive type, in which case it is converted to a
* <tt>Class</tt> object by appending ".class" to it (e.g., "int.class").
*/
public static Class toClass(String type, ClassLoader loader)
- throws ClassNotFoundException {
+ throws ClassNotFoundException {
- Class c = null;
- int i0 = type.indexOf('[');
- int dims = 0;
- if (i0 > 0) {
- // This is an array. Count the dimensions
- for (int i = 0; i < type.length(); i++) {
- if (type.charAt(i) == '[')
- dims++;
- }
- type = type.substring(0, i0);
- }
+ Class c = null;
+ int i0 = type.indexOf('[');
+ int dims = 0;
+ if (i0 > 0) {
+ // This is an array. Count the dimensions
+ for (int i = 0; i < type.length(); i++) {
+ if (type.charAt(i) == '[')
+ dims++;
+ }
+ type = type.substring(0, i0);
+ }
- if ("boolean".equals(type))
- c = boolean.class;
- else if ("char".equals(type))
- c = char.class;
- else if ("byte".equals(type))
- c = byte.class;
- else if ("short".equals(type))
- c = short.class;
- else if ("int".equals(type))
- c = int.class;
- else if ("long".equals(type))
- c = long.class;
- else if ("float".equals(type))
- c = float.class;
- else if ("double".equals(type))
- c = double.class;
- else if (type.indexOf('[') < 0)
- c = loader.loadClass(type);
+ if ("boolean".equals(type))
+ c = boolean.class;
+ else if ("char".equals(type))
+ c = char.class;
+ else if ("byte".equals(type))
+ c = byte.class;
+ else if ("short".equals(type))
+ c = short.class;
+ else if ("int".equals(type))
+ c = int.class;
+ else if ("long".equals(type))
+ c = long.class;
+ else if ("float".equals(type))
+ c = float.class;
+ else if ("double".equals(type))
+ c = double.class;
+ else if (type.indexOf('[') < 0)
+ c = loader.loadClass(type);
- if (dims == 0)
- return c;
+ if (dims == 0)
+ return c;
- if (dims == 1)
- return java.lang.reflect.Array.newInstance(c, 1).getClass();
+ if (dims == 1)
+ return java.lang.reflect.Array.newInstance(c, 1).getClass();
- // Array of more than i dimension
- return java.lang.reflect.Array.newInstance(c, new int[dims]).getClass();
+ // Array of more than i dimension
+ return java.lang.reflect.Array.newInstance(c, new int[dims]).getClass();
}
/**
* Produces a String representing a call to the EL interpreter.
- * @param expression a String containing zero or more "${}" expressions
+ *
+ * @param expression a String containing zero or more "${}" expressions
* @param expectedType the expected type of the interpreted result
- * @param fnmapvar Variable pointing to a function map.
- * @param XmlEscape True if the result should do XML escaping
+ * @param fnmapvar Variable pointing to a function map.
+ * @param XmlEscape True if the result should do XML escaping
* @return a String representing a call to the EL interpreter.
*/
public static String interpreterCall(boolean isTagFile,
- String expression,
+ String expression,
Class expectedType,
String fnmapvar,
- boolean XmlEscape )
- {
+ boolean XmlEscape) {
/*
* Determine which context object to use.
*/
- String jspCtxt = null;
- if (isTagFile)
- jspCtxt = "this.getJspContext()";
- else
- jspCtxt = "_jspx_page_context";
+ String jspCtxt = null;
+ if (isTagFile)
+ jspCtxt = "this.getJspContext()";
+ else
+ jspCtxt = "_jspx_page_context";
- /*
- * Determine whether to use the expected type's textual name
- * or, if it's a primitive, the name of its correspondent boxed
- * type.
- */
- String targetType = expectedType.getName();
- String primitiveConverterMethod = null;
- if (expectedType.isPrimitive()) {
- if (expectedType.equals(Boolean.TYPE)) {
- targetType = Boolean.class.getName();
- primitiveConverterMethod = "booleanValue";
- } else if (expectedType.equals(Byte.TYPE)) {
- targetType = Byte.class.getName();
- primitiveConverterMethod = "byteValue";
- } else if (expectedType.equals(Character.TYPE)) {
- targetType = Character.class.getName();
- primitiveConverterMethod = "charValue";
- } else if (expectedType.equals(Short.TYPE)) {
- targetType = Short.class.getName();
- primitiveConverterMethod = "shortValue";
- } else if (expectedType.equals(Integer.TYPE)) {
- targetType = Integer.class.getName();
- primitiveConverterMethod = "intValue";
- } else if (expectedType.equals(Long.TYPE)) {
- targetType = Long.class.getName();
- primitiveConverterMethod = "longValue";
- } else if (expectedType.equals(Float.TYPE)) {
- targetType = Float.class.getName();
- primitiveConverterMethod = "floatValue";
- } else if (expectedType.equals(Double.TYPE)) {
- targetType = Double.class.getName();
- primitiveConverterMethod = "doubleValue";
- }
- }
-
- if (primitiveConverterMethod != null) {
- XmlEscape = false;
- }
+ /*
+ * Determine whether to use the expected type's textual name
+ * or, if it's a primitive, the name of its correspondent boxed
+ * type.
+ */
+ String targetType = expectedType.getName();
+ String primitiveConverterMethod = null;
+ if (expectedType.isPrimitive()) {
+ if (expectedType.equals(Boolean.TYPE)) {
+ targetType = Boolean.class.getName();
+ primitiveConverterMethod = "booleanValue";
+ } else if (expectedType.equals(Byte.TYPE)) {
+ targetType = Byte.class.getName();
+ primitiveConverterMethod = "byteValue";
+ } else if (expectedType.equals(Character.TYPE)) {
+ targetType = Character.class.getName();
+ primitiveConverterMethod = "charValue";
+ } else if (expectedType.equals(Short.TYPE)) {
+ targetType = Short.class.getName();
+ primitiveConverterMethod = "shortValue";
+ } else if (expectedType.equals(Integer.TYPE)) {
+ targetType = Integer.class.getName();
+ primitiveConverterMethod = "intValue";
+ } else if (expectedType.equals(Long.TYPE)) {
+ targetType = Long.class.getName();
+ primitiveConverterMethod = "longValue";
+ } else if (expectedType.equals(Float.TYPE)) {
+ targetType = Float.class.getName();
+ primitiveConverterMethod = "floatValue";
+ } else if (expectedType.equals(Double.TYPE)) {
+ targetType = Double.class.getName();
+ primitiveConverterMethod = "doubleValue";
+ }
+ }
- /*
- * Build up the base call to the interpreter.
- */
+ if (primitiveConverterMethod != null) {
+ XmlEscape = false;
+ }
+
+ /*
+ * Build up the base call to the interpreter.
+ */
// XXX - We use a proprietary call to the interpreter for now
// as the current standard machinery is inefficient and requires
// lots of wrappers and adapters. This should all clear up once
@@ -545,33 +542,34 @@
// Note that PageContextImpl implements VariableResolver and
// the generated Servlet/SimpleTag implements FunctionMapper, so
// that machinery is already in place (mroth).
- targetType = toJavaSourceType(targetType);
- StringBuffer call = new StringBuffer(
- "(" + targetType + ") "
- + "org.apache.struts2.jasper.runtime.PageContextImpl.proprietaryEvaluate"
- + "(" + Generator.quote(expression) + ", "
- + targetType + ".class, "
- + "(PageContext)" + jspCtxt
- + ", " + fnmapvar
- + ", " + XmlEscape
- + ")");
-
- /*
- * Add the primitive converter method if we need to.
- */
- if (primitiveConverterMethod != null) {
- call.insert(0, "(");
- call.append(")." + primitiveConverterMethod + "()");
- }
-
- return call.toString();
+ targetType = toJavaSourceType(targetType);
+ StringBuffer call = new StringBuffer(
+ "(" + targetType + ") "
+ + "org.apache.struts2.jasper.runtime.PageContextImpl.proprietaryEvaluate"
+ + "(" + Generator.quote(expression) + ", "
+ + targetType + ".class, "
+ + "(PageContext)" + jspCtxt
+ + ", " + fnmapvar
+ + ", " + XmlEscape
+ + ")");
+
+ /*
+ * Add the primitive converter method if we need to.
+ */
+ if (primitiveConverterMethod != null) {
+ call.insert(0, "(");
+ call.append(")." + primitiveConverterMethod + "()");
+ }
+
+ return call.toString();
}
/**
* Validates the syntax of all ${} expressions within the given string.
- * @param where the approximate location of the expressions in the JSP page
+ *
+ * @param where the approximate location of the expressions in the JSP page
* @param expressions a string containing zero or more "${}" expressions
- * @param err an error dispatcher to use
+ * @param err an error dispatcher to use
*/
public static void validateExpressions(Mark where,
String expressions,
@@ -581,16 +579,16 @@
throws JasperException {
try {
- JspUtil.expressionEvaluator.parseExpression( expressions,
- expectedType, null );
+ JspUtil.expressionEvaluator.parseExpression(expressions,
+ expectedType, null);
}
- catch( ELParseException e ) {
+ catch (ELParseException e) {
err.jspError(where, "jsp.error.invalid.expression", expressions,
- e.toString() );
+ e.toString());
}
- catch( ELException e ) {
+ catch (ELException e) {
err.jspError(where, "jsp.error.invalid.expression", expressions,
- e.toString() );
+ e.toString());
}
}
@@ -611,230 +609,230 @@
}
public static String coerceToPrimitiveBoolean(String s,
- boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToBoolean(" + s + ")";
- } else {
- if (s == null || s.length() == 0)
- return "false";
- else
- return Boolean.valueOf(s).toString();
- }
+ boolean isNamedAttribute) {
+ if (isNamedAttribute) {
+ return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToBoolean(" + s + ")";
+ } else {
+ if (s == null || s.length() == 0)
+ return "false";
+ else
+ return Boolean.valueOf(s).toString();
+ }
}
public static String coerceToBoolean(String s, boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "(Boolean) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Boolean.class)";
- } else {
- if (s == null || s.length() == 0) {
- return "new Boolean(false)";
- } else {
- // Detect format error at translation time
- return "new Boolean(" + Boolean.valueOf(s).toString() + ")";
- }
- }
+ if (isNamedAttribute) {
+ return "(Boolean) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Boolean.class)";
+ } else {
+ if (s == null || s.length() == 0) {
+ return "new Boolean(false)";
+ } else {
+ // Detect format error at translation time
+ return "new Boolean(" + Boolean.valueOf(s).toString() + ")";
+ }
+ }
}
public static String coerceToPrimitiveByte(String s,
- boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToByte(" + s + ")";
- } else {
- if (s == null || s.length() == 0)
- return "(byte) 0";
- else
- return "((byte)" + Byte.valueOf(s).toString() + ")";
- }
+ boolean isNamedAttribute) {
+ if (isNamedAttribute) {
+ return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToByte(" + s + ")";
+ } else {
+ if (s == null || s.length() == 0)
+ return "(byte) 0";
+ else
+ return "((byte)" + Byte.valueOf(s).toString() + ")";
+ }
}
public static String coerceToByte(String s, boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "(Byte) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Byte.class)";
- } else {
- if (s == null || s.length() == 0) {
- return "new Byte((byte) 0)";
- } else {
- // Detect format error at translation time
- return "new Byte((byte)" + Byte.valueOf(s).toString() + ")";
- }
- }
+ if (isNamedAttribute) {
+ return "(Byte) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Byte.class)";
+ } else {
+ if (s == null || s.length() == 0) {
+ return "new Byte((byte) 0)";
+ } else {
+ // Detect format error at translation time
+ return "new Byte((byte)" + Byte.valueOf(s).toString() + ")";
+ }
+ }
}
public static String coerceToChar(String s, boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToChar(" + s + ")";
- } else {
- if (s == null || s.length() == 0) {
- return "(char) 0";
- } else {
- char ch = s.charAt(0);
- // this trick avoids escaping issues
- return "((char) " + (int) ch + ")";
- }
- }
+ if (isNamedAttribute) {
+ return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToChar(" + s + ")";
+ } else {
+ if (s == null || s.length() == 0) {
+ return "(char) 0";
+ } else {
+ char ch = s.charAt(0);
+ // this trick avoids escaping issues
+ return "((char) " + (int) ch + ")";
+ }
+ }
}
public static String coerceToCharacter(String s, boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "(Character) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Character.class)";
- } else {
- if (s == null || s.length() == 0) {
- return "new Character((char) 0)";
- } else {
- char ch = s.charAt(0);
- // this trick avoids escaping issues
- return "new Character((char) " + (int) ch + ")";
- }
- }
+ if (isNamedAttribute) {
+ return "(Character) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Character.class)";
+ } else {
+ if (s == null || s.length() == 0) {
+ return "new Character((char) 0)";
+ } else {
+ char ch = s.charAt(0);
+ // this trick avoids escaping issues
+ return "new Character((char) " + (int) ch + ")";
+ }
+ }
}
public static String coerceToPrimitiveDouble(String s,
- boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToDouble(" + s + ")";
- } else {
- if (s == null || s.length() == 0)
- return "(double) 0";
- else
- return Double.valueOf(s).toString();
- }
+ boolean isNamedAttribute) {
+ if (isNamedAttribute) {
+ return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToDouble(" + s + ")";
+ } else {
+ if (s == null || s.length() == 0)
+ return "(double) 0";
+ else
+ return Double.valueOf(s).toString();
+ }
}
public static String coerceToDouble(String s, boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "(Double) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Double.class)";
- } else {
- if (s == null || s.length() == 0) {
- return "new Double(0)";
- } else {
- // Detect format error at translation time
- return "new Double(" + Double.valueOf(s).toString() + ")";
- }
- }
+ if (isNamedAttribute) {
+ return "(Double) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Double.class)";
+ } else {
+ if (s == null || s.length() == 0) {
+ return "new Double(0)";
+ } else {
+ // Detect format error at translation time
+ return "new Double(" + Double.valueOf(s).toString() + ")";
+ }
+ }
}
public static String coerceToPrimitiveFloat(String s,
- boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToFloat(" + s + ")";
- } else {
- if (s == null || s.length() == 0)
- return "(float) 0";
- else
- return Float.valueOf(s).toString() + "f";
- }
+ boolean isNamedAttribute) {
+ if (isNamedAttribute) {
+ return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToFloat(" + s + ")";
+ } else {
+ if (s == null || s.length() == 0)
+ return "(float) 0";
+ else
+ return Float.valueOf(s).toString() + "f";
+ }
}
public static String coerceToFloat(String s, boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "(Float) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Float.class)";
- } else {
- if (s == null || s.length() == 0) {
- return "new Float(0)";
- } else {
- // Detect format error at translation time
- return "new Float(" + Float.valueOf(s).toString() + "f)";
- }
- }
+ if (isNamedAttribute) {
+ return "(Float) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Float.class)";
+ } else {
+ if (s == null || s.length() == 0) {
+ return "new Float(0)";
+ } else {
+ // Detect format error at translation time
+ return "new Float(" + Float.valueOf(s).toString() + "f)";
+ }
+ }
}
public static String coerceToInt(String s, boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToInt(" + s + ")";
- } else {
- if (s == null || s.length() == 0)
- return "0";
- else
- return Integer.valueOf(s).toString();
- }
+ if (isNamedAttribute) {
+ return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToInt(" + s + ")";
+ } else {
+ if (s == null || s.length() == 0)
+ return "0";
+ else
+ return Integer.valueOf(s).toString();
+ }
}
public static String coerceToInteger(String s, boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "(Integer) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Integer.class)";
- } else {
- if (s == null || s.length() == 0) {
- return "new Integer(0)";
- } else {
- // Detect format error at translation time
- return "new Integer(" + Integer.valueOf(s).toString() + ")";
- }
- }
+ if (isNamedAttribute) {
+ return "(Integer) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Integer.class)";
+ } else {
+ if (s == null || s.length() == 0) {
+ return "new Integer(0)";
+ } else {
+ // Detect format error at translation time
+ return "new Integer(" + Integer.valueOf(s).toString() + ")";
+ }
+ }
}
public static String coerceToPrimitiveShort(String s,
- boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToShort(" + s + ")";
- } else {
- if (s == null || s.length() == 0)
- return "(short) 0";
- else
- return "((short) " + Short.valueOf(s).toString() + ")";
- }
+ boolean isNamedAttribute) {
+ if (isNamedAttribute) {
+ return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToShort(" + s + ")";
+ } else {
+ if (s == null || s.length() == 0)
+ return "(short) 0";
+ else
+ return "((short) " + Short.valueOf(s).toString() + ")";
+ }
}
-
+
public static String coerceToShort(String s, boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "(Short) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Short.class)";
- } else {
- if (s == null || s.length() == 0) {
- return "new Short((short) 0)";
- } else {
- // Detect format error at translation time
- return "new Short(\"" + Short.valueOf(s).toString() + "\")";
- }
- }
+ if (isNamedAttribute) {
+ return "(Short) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Short.class)";
+ } else {
+ if (s == null || s.length() == 0) {
+ return "new Short((short) 0)";
+ } else {
+ // Detect format error at translation time
+ return "new Short(\"" + Short.valueOf(s).toString() + "\")";
+ }
+ }
}
-
+
public static String coerceToPrimitiveLong(String s,
- boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToLong(" + s + ")";
- } else {
- if (s == null || s.length() == 0)
- return "(long) 0";
- else
- return Long.valueOf(s).toString() + "l";
- }
+ boolean isNamedAttribute) {
+ if (isNamedAttribute) {
+ return "org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerceToLong(" + s + ")";
+ } else {
+ if (s == null || s.length() == 0)
+ return "(long) 0";
+ else
+ return Long.valueOf(s).toString() + "l";
+ }
}
public static String coerceToLong(String s, boolean isNamedAttribute) {
- if (isNamedAttribute) {
- return "(Long) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Long.class)";
- } else {
- if (s == null || s.length() == 0) {
- return "new Long(0)";
- } else {
- // Detect format error at translation time
- return "new Long(" + Long.valueOf(s).toString() + "l)";
- }
- }
+ if (isNamedAttribute) {
+ return "(Long) org.apache.struts2.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Long.class)";
+ } else {
+ if (s == null || s.length() == 0) {
+ return "new Long(0)";
+ } else {
+ // Detect format error at translation time
+ return "new Long(" + Long.valueOf(s).toString() + "l)";
+ }
+ }
}
public static InputStream getInputStream(String fname, JarFile jarFile,
- JspCompilationContext ctxt,
- ErrorDispatcher err)
- throws JasperException, IOException {
+ JspCompilationContext ctxt,
+ ErrorDispatcher err)
+ throws JasperException, IOException {
InputStream in = null;
- if (jarFile != null) {
- String jarEntryName = fname.substring(1, fname.length());
- ZipEntry jarEntry = jarFile.getEntry(jarEntryName);
- if (jarEntry == null) {
- err.jspError("jsp.error.file.not.found", fname);
- }
- in = jarFile.getInputStream(jarEntry);
- } else {
- in = ctxt.getResourceAsStream(fname);
- }
+ if (jarFile != null) {
+ String jarEntryName = fname.substring(1, fname.length());
+ ZipEntry jarEntry = jarFile.getEntry(jarEntryName);
+ if (jarEntry == null) {
+ err.jspError("jsp.error.file.not.found", fname);
+ }
+ in = jarFile.getInputStream(jarEntry);
+ } else {
+ in = ctxt.getResourceAsStream(fname);
+ }
- if (in == null) {
- err.jspError("jsp.error.file.not.found", fname);
- }
+ if (in == null) {
+ err.jspError("jsp.error.file.not.found", fname);
+ }
- return in;
+ return in;
}
/**
@@ -842,19 +840,18 @@
* the given tag file path.
*
* @param path Tag file path
- * @param err Error dispatcher
- *
- * @return Fully-qualified class name of the tag handler corresponding to
- * the given tag file path
+ * @param err Error dispatcher
+ * @return Fully-qualified class name of the tag handler corresponding to
+ * the given tag file path
*/
public static String getTagHandlerClassName(String path,
- ErrorDispatcher err)
- throws JasperException {
+ ErrorDispatcher err)
+ throws JasperException {
String className = null;
int begin = 0;
int index;
-
+
index = path.lastIndexOf(".tag");
if (index == -1) {
err.jspError("jsp.error.tagfile.badSuffix", path);
@@ -875,29 +872,28 @@
className = "org.apache.jsp.tag.web.";
begin = index + WEB_INF_TAGS.length();
} else {
- index = path.indexOf(META_INF_TAGS);
- if (index != -1) {
- className = "org.apache.jsp.tag.meta.";
- begin = index + META_INF_TAGS.length();
- } else {
- err.jspError("jsp.error.tagfile.illegalPath", path);
- }
- }
+ index = path.indexOf(META_INF_TAGS);
+ if (index != -1) {
+ className = "org.apache.jsp.tag.meta.";
+ begin = index + META_INF_TAGS.length();
+ } else {
+ err.jspError("jsp.error.tagfile.illegalPath", path);
+ }
+ }
className += makeJavaPackage(path.substring(begin));
-
- return className;
+
+ return className;
}
/**
* Converts the given path to a Java package or fully-qualified class name
*
* @param path Path to convert
- *
* @return Java package corresponding to the given path
*/
public static final String makeJavaPackage(String path) {
- String classNameComponents[] = split(path,"/");
+ String classNameComponents[] = split(path, "/");
StringBuffer legalClassNames = new StringBuffer();
for (int i = 0; i < classNameComponents.length; i++) {
legalClassNames.append(makeJavaIdentifier(classNameComponents[i]));
@@ -910,42 +906,42 @@
/**
* Splits a string into it's components.
+ *
* @param path String to split
- * @param pat Pattern to split at
+ * @param pat Pattern to split at
* @return the components of the path
*/
- private static final String [] split(String path, String pat) {
+ private static final String[] split(String path, String pat) {
Vector comps = new Vector();
int pos = path.indexOf(pat);
int start = 0;
- while( pos >= 0 ) {
- if(pos > start ) {
- String comp = path.substring(start,pos);
+ while (pos >= 0) {
+ if (pos > start) {
+ String comp = path.substring(start, pos);
comps.add(comp);
}
start = pos + pat.length();
- pos = path.indexOf(pat,start);
+ pos = path.indexOf(pat, start);
}
- if( start < path.length()) {
+ if (start < path.length()) {
comps.add(path.substring(start));
}
- String [] result = new String[comps.size()];
- for(int i=0; i < comps.size(); i++) {
- result[i] = (String)comps.elementAt(i);
+ String[] result = new String[comps.size()];
+ for (int i = 0; i < comps.size(); i++) {
+ result[i] = (String) comps.elementAt(i);
}
return result;
}
-
+
/**
* Converts the given identifier to a legal Java identifier
*
* @param identifier Identifier to convert
- *
* @return Legal Java identifier corresponding to the given identifier
*/
public static final String makeJavaIdentifier(String identifier) {
- StringBuffer modifiedIdentifier =
- new StringBuffer(identifier.length());
+ StringBuffer modifiedIdentifier =
+ new StringBuffer(identifier.length());
if (!Character.isJavaIdentifierStart(identifier.charAt(0))) {
modifiedIdentifier.append('_');
}
@@ -964,7 +960,7 @@
}
return modifiedIdentifier.toString();
}
-
+
/**
* Mangle the specified character to create a legal Java class name.
*/
@@ -985,13 +981,13 @@
int i = 0;
int j = javaKeywords.length;
while (i < j) {
- int k = (i+j)/2;
+ int k = (i + j) / 2;
int result = javaKeywords[k].compareTo(key);
if (result == 0) {
return true;
}
if (result < 0) {
- i = k+1;
+ i = k + 1;
} else {
j = k;
}
@@ -1007,7 +1003,6 @@
* so that we don't have to worry about it being a Java key word.
*
* @param name Identifier to convert
- *
* @return Legal Java identifier corresponding to the given identifier
*/
public static final String makeXmlJavaIdentifier(String name) {
@@ -1021,21 +1016,21 @@
}
static InputStreamReader getReader(String fname, String encoding,
- JarFile jarFile,
- JspCompilationContext ctxt,
- ErrorDispatcher err)
- throws JasperException, IOException {
+ JarFile jarFile,
+ JspCompilationContext ctxt,
+ ErrorDispatcher err)
+ throws JasperException, IOException {
InputStreamReader reader = null;
- InputStream in = getInputStream(fname, jarFile, ctxt, err);
+ InputStream in = getInputStream(fname, jarFile, ctxt, err);
- try {
+ try {
reader = new InputStreamReader(in, encoding);
- } catch (UnsupportedEncodingException ex) {
- err.jspError("jsp.error.unsupported.encoding", encoding);
- }
+ } catch (UnsupportedEncodingException ex) {
+ err.jspError("jsp.error.unsupported.encoding", encoding);
+ }
- return reader;
+ return reader;
}
/**
@@ -1045,43 +1040,62 @@
*/
public static String toJavaSourceType(String type) {
- if (type.charAt(0) != '[') {
- return type;
- }
+ if (type.charAt(0) != '[') {
+ return type;
+ }
- int dims = 1;
- String t = null;
- for (int i = 1; i < type.length(); i++) {
- if (type.charAt(i) == '[') {
- dims++;
- } else {
- switch (type.charAt(i)) {
- case 'Z': t = "boolean"; break;
- case 'B': t = "byte"; break;
- case 'C': t = "char"; break;
- case 'D': t = "double"; break;
- case 'F': t = "float"; break;
- case 'I': t = "int"; break;
- case 'J': t = "long"; break;
- case 'S': t = "short"; break;
- case 'L': t = type.substring(i+1, type.indexOf(';')); break;
- }
- break;
- }
- }
- StringBuffer resultType = new StringBuffer(t);
- for (; dims > 0; dims--) {
- resultType.append("[]");
- }
- return resultType.toString();
+ int dims = 1;
+ String t = null;
+ for (int i = 1; i < type.length(); i++) {
+ if (type.charAt(i) == '[') {
+ dims++;
+ } else {
+ switch (type.charAt(i)) {
+ case 'Z':
+ t = "boolean";
+ break;
+ case 'B':
+ t = "byte";
+ break;
+ case 'C':
+ t = "char";
+ break;
+ case 'D':
+ t = "double";
+ break;
+ case 'F':
+ t = "float";
+ break;
+ case 'I':
+ t = "int";
+ break;
+ case 'J':
+ t = "long";
+ break;
+ case 'S':
+ t = "short";
+ break;
+ case 'L':
+ t = type.substring(i + 1, type.indexOf(';'));
+ break;
+ }
+ break;
+ }
+ }
+ StringBuffer resultType = new StringBuffer(t);
+ for (; dims > 0; dims--) {
+ resultType.append("[]");
+ }
+ return resultType.toString();
}
/**
* Compute the canonical name from a Class instance. Note that a
* simple replacment of '$' with '.' of a binary name would not work,
* as '$' is a legal Java Identifier character.
+ *
* @param c A instance of java.lang.Class
- * @return The canonical name of c.
+ * @return The canonical name of c.
*/
public static String getCanonicalName(Class c) {
@@ -1096,7 +1110,7 @@
do {
buf.setCharAt(c.getName().length(), '.');
c = c.getDeclaringClass();
- } while ( c != null);
+ } while (c != null);
return buf.toString();
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Localizer.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Localizer.java
index ddb4245..fefa11a 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Localizer.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Localizer.java
@@ -30,11 +30,11 @@
public class Localizer {
private static ResourceBundle bundle = null;
-
+
static {
try {
- bundle = ResourceBundle.getBundle(
- "org.apache.struts2.jasper.resources.LocalStrings");
+ bundle = ResourceBundle.getBundle(
+ "org.apache.struts2.jasper.resources.LocalStrings");
} catch (Throwable t) {
t.printStackTrace();
}
@@ -52,12 +52,12 @@
* @return Localized error message
*/
public static String getMessage(String errCode) {
- String errMsg = errCode;
- try {
- errMsg = bundle.getString(errCode);
- } catch (MissingResourceException e) {
- }
- return errMsg;
+ String errMsg = errCode;
+ try {
+ errMsg = bundle.getString(errCode);
+ } catch (MissingResourceException e) {
+ }
+ return errMsg;
}
/*
@@ -73,7 +73,7 @@
* @return Localized error message
*/
public static String getMessage(String errCode, String arg) {
- return getMessage(errCode, new Object[] {arg});
+ return getMessage(errCode, new Object[]{arg});
}
/*
@@ -90,26 +90,26 @@
* @return Localized error message
*/
public static String getMessage(String errCode, String arg1, String arg2) {
- return getMessage(errCode, new Object[] {arg1, arg2});
+ return getMessage(errCode, new Object[]{arg1, arg2});
}
-
+
/*
- * Returns the localized error message corresponding to the given error
- * code.
- *
- * If the given error code is not defined in the resource bundle for
- * localized error messages, it is used as the error message.
- *
- * @param errCode Error code to localize
- * @param arg1 First argument for parametric replacement
- * @param arg2 Second argument for parametric replacement
- * @param arg3 Third argument for parametric replacement
- *
- * @return Localized error message
- */
+ * Returns the localized error message corresponding to the given error
+ * code.
+ *
+ * If the given error code is not defined in the resource bundle for
+ * localized error messages, it is used as the error message.
+ *
+ * @param errCode Error code to localize
+ * @param arg1 First argument for parametric replacement
+ * @param arg2 Second argument for parametric replacement
+ * @param arg3 Third argument for parametric replacement
+ *
+ * @return Localized error message
+ */
public static String getMessage(String errCode, String arg1, String arg2,
- String arg3) {
- return getMessage(errCode, new Object[] {arg1, arg2, arg3});
+ String arg3) {
+ return getMessage(errCode, new Object[]{arg1, arg2, arg3});
}
/*
@@ -128,8 +128,8 @@
* @return Localized error message
*/
public static String getMessage(String errCode, String arg1, String arg2,
- String arg3, String arg4) {
- return getMessage(errCode, new Object[] {arg1, arg2, arg3, arg4});
+ String arg3, String arg4) {
+ return getMessage(errCode, new Object[]{arg1, arg2, arg3, arg4});
}
/*
@@ -145,16 +145,16 @@
* @return Localized error message
*/
public static String getMessage(String errCode, Object[] args) {
- String errMsg = errCode;
- try {
- errMsg = bundle.getString(errCode);
- if (args != null) {
- MessageFormat formatter = new MessageFormat(errMsg);
- errMsg = formatter.format(args);
- }
- } catch (MissingResourceException e) {
- }
-
- return errMsg;
+ String errMsg = errCode;
+ try {
+ errMsg = bundle.getString(errCode);
+ if (args != null) {
+ MessageFormat formatter = new MessageFormat(errMsg);
+ errMsg = formatter.format(args);
+ }
+ } catch (MissingResourceException e) {
+ }
+
+ return errMsg;
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Mark.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Mark.java
index 64ce615..c94adb7 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Mark.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Mark.java
@@ -23,7 +23,7 @@
import java.util.Stack;
/**
- * Mark represents a point in the JSP input.
+ * Mark represents a point in the JSP input.
*
* @author Anil K. Vijendran
*/
@@ -61,11 +61,11 @@
/**
* Constructor
*
- * @param reader JspReader this mark belongs to
- * @param inStream current stream for this mark
- * @param fileId id of requested jsp file
- * @param name JSP file name
- * @param inBaseDir base directory of requested jsp file
+ * @param reader JspReader this mark belongs to
+ * @param inStream current stream for this mark
+ * @param fileId id of requested jsp file
+ * @param name JSP file name
+ * @param inBaseDir base directory of requested jsp file
* @param inEncoding encoding of current file
*/
Mark(JspReader reader, char[] inStream, int fileId, String name,
@@ -103,15 +103,15 @@
// clone includeStack without cloning contents
includeStack = new Stack();
- for ( int i=0; i < other.includeStack.size(); i++ ) {
- includeStack.addElement( other.includeStack.elementAt(i) );
+ for (int i = 0; i < other.includeStack.size(); i++) {
+ includeStack.addElement(other.includeStack.elementAt(i));
}
}
/**
* Constructor
- */
+ */
Mark(JspCompilationContext ctxt, String filename, int line, int col) {
this.reader = null;
@@ -132,18 +132,17 @@
* Sets this mark's state to a new stream.
* It will store the current stream in it's includeStack.
*
- * @param inStream new stream for mark
- * @param inFileId id of new file from which stream comes from
- * @param inBaseDir directory of file
+ * @param inStream new stream for mark
+ * @param inFileId id of new file from which stream comes from
+ * @param inBaseDir directory of file
* @param inEncoding encoding of new file
*/
public void pushStream(char[] inStream, int inFileId, String name,
- String inBaseDir, String inEncoding)
- {
+ String inBaseDir, String inEncoding) {
// store current state in stack
includeStack.push(new IncludeState(cursor, line, col, fileId,
- fileName, baseDir,
- encoding, stream) );
+ fileName, baseDir,
+ encoding, stream));
// set new variables
cursor = 0;
@@ -159,17 +158,18 @@
/**
* Restores this mark's state to a previously stored stream.
+ *
* @return The previous Mark instance when the stream was pushed, or null
- * if there is no previous stream
+ * if there is no previous stream
*/
public Mark popStream() {
// make sure we have something to pop
- if ( includeStack.size() <= 0 ) {
+ if (includeStack.size() <= 0) {
return null;
}
// get previous state in stack
- IncludeState state = (IncludeState) includeStack.pop( );
+ IncludeState state = (IncludeState) includeStack.pop();
// set new variables
cursor = state.cursor;
@@ -202,7 +202,7 @@
}
public String toString() {
- return getFile()+"("+line+","+col+")";
+ return getFile() + "(" + line + "," + col + ")";
}
public String getFile() {
@@ -213,30 +213,29 @@
* Gets the URL of the resource with which this Mark is associated
*
* @return URL of the resource with which this Mark is associated
- *
- * @exception MalformedURLException if the resource pathname is incorrect
+ * @throws MalformedURLException if the resource pathname is incorrect
*/
public URL getURL() throws MalformedURLException {
return ctxt.getResource(getFile());
}
public String toShortString() {
- return "("+line+","+col+")";
+ return "(" + line + "," + col + ")";
}
public boolean equals(Object other) {
- if (other instanceof Mark) {
- Mark m = (Mark) other;
- return this.reader == m.reader && this.fileId == m.fileId
- && this.cursor == m.cursor && this.line == m.line
- && this.col == m.col;
- }
- return false;
+ if (other instanceof Mark) {
+ Mark m = (Mark) other;
+ return this.reader == m.reader && this.fileId == m.fileId
+ && this.cursor == m.cursor && this.line == m.line
+ && this.col == m.col;
+ }
+ return false;
}
/**
* @return true if this Mark is greather than the <code>other</code>
- * Mark, false otherwise.
+ * Mark, false otherwise.
*/
public boolean isGreater(Mark other) {
@@ -265,7 +264,7 @@
String encoding;
char[] stream = null;
- IncludeState(int inCursor, int inLine, int inCol, int inFileId,
+ IncludeState(int inCursor, int inLine, int inCol, int inFileId,
String name, String inBaseDir, String inEncoding,
char[] inStream) {
cursor = inCursor;
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Node.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Node.java
index 544120c..61f6654 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Node.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Node.java
@@ -40,8 +40,8 @@
abstract class Node implements TagConstants {
- private static final VariableInfo[] ZERO_VARIABLE_INFO = { };
-
+ private static final VariableInfo[] ZERO_VARIABLE_INFO = {};
+
protected Attributes attrs;
// xmlns attributes that represent tag libraries (only in XML syntax)
@@ -82,7 +82,7 @@
/**
* Constructor.
*
- * @param start The location of the jsp page
+ * @param start The location of the jsp page
* @param parent The enclosing node
*/
public Node(Mark start, Node parent) {
@@ -94,10 +94,10 @@
/**
* Constructor.
*
- * @param qName The action's qualified name
+ * @param qName The action's qualified name
* @param localName The action's local name
- * @param start The location of the jsp page
- * @param parent The enclosing node
+ * @param start The location of the jsp page
+ * @param parent The enclosing node
*/
public Node(String qName, String localName, Mark start, Node parent) {
this.qName = qName;
@@ -110,11 +110,11 @@
/**
* Constructor for Nodes parsed from standard syntax.
*
- * @param qName The action's qualified name
+ * @param qName The action's qualified name
* @param localName The action's local name
- * @param attrs The attributes for this node
- * @param start The location of the jsp page
- * @param parent The enclosing node
+ * @param attrs The attributes for this node
+ * @param start The location of the jsp page
+ * @param parent The enclosing node
*/
public Node(String qName, String localName, Attributes attrs, Mark start,
Node parent) {
@@ -129,16 +129,16 @@
/**
* Constructor for Nodes parsed from XML syntax.
*
- * @param qName The action's qualified name
- * @param localName The action's local name
- * @param attrs The action's attributes whose name does not start with
- * xmlns
+ * @param qName The action's qualified name
+ * @param localName The action's local name
+ * @param attrs The action's attributes whose name does not start with
+ * xmlns
* @param nonTaglibXmlnsAttrs The action's xmlns attributes that do not
- * represent tag libraries
- * @param taglibAttrs The action's xmlns attributes that represent tag
- * libraries
- * @param start The location of the jsp page
- * @param parent The enclosing node
+ * represent tag libraries
+ * @param taglibAttrs The action's xmlns attributes that represent tag
+ * libraries
+ * @param start The location of the jsp page
+ * @param parent The enclosing node
*/
public Node(String qName, String localName, Attributes attrs,
Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
@@ -219,7 +219,7 @@
/**
* Get the attribute that is non request time expression, either
- * from the attribute of the node, or from a jsp:attrbute
+ * from the attribute of the node, or from a jsp:attrbute
*/
public String getTextAttribute(String name) {
@@ -240,18 +240,18 @@
* Searches all subnodes of this node for jsp:attribute standard
* actions with the given name, and returns the NamedAttribute node
* of the matching named attribute, nor null if no such node is found.
- * <p>
+ * <p/>
* This should always be called and only be called for nodes that
* accept dynamic runtime attribute expressions.
*/
- public NamedAttribute getNamedAttributeNode( String name ) {
+ public NamedAttribute getNamedAttributeNode(String name) {
NamedAttribute result = null;
-
+
// Look for the attribute in NamedAttribute children
Nodes nodes = getNamedAttributeNodes();
int numChildNodes = nodes.size();
- for( int i = 0; i < numChildNodes; i++ ) {
- NamedAttribute na = (NamedAttribute)nodes.getNode( i );
+ for (int i = 0; i < numChildNodes; i++) {
+ NamedAttribute na = (NamedAttribute) nodes.getNode(i);
boolean found = false;
int index = name.indexOf(':');
if (index != -1) {
@@ -265,7 +265,7 @@
break;
}
}
-
+
return result;
}
@@ -274,7 +274,7 @@
* actions, and returns that set of nodes as a Node.Nodes object.
*
* @return Possibly empty Node.Nodes object containing any jsp:attribute
- * subnodes of this Node
+ * subnodes of this Node
*/
public Node.Nodes getNamedAttributeNodes() {
@@ -283,17 +283,16 @@
}
Node.Nodes result = new Node.Nodes();
-
+
// Look for the attribute in NamedAttribute children
Nodes nodes = getBody();
- if( nodes != null ) {
+ if (nodes != null) {
int numChildNodes = nodes.size();
- for( int i = 0; i < numChildNodes; i++ ) {
- Node n = nodes.getNode( i );
- if( n instanceof NamedAttribute ) {
- result.add( n );
- }
- else if (! (n instanceof Comment)) {
+ for (int i = 0; i < numChildNodes; i++) {
+ Node n = nodes.getNode(i);
+ if (n instanceof NamedAttribute) {
+ result.add(n);
+ } else if (!(n instanceof Comment)) {
// Nothing can come before jsp:attribute, and only
// jsp:body can come after it.
break;
@@ -304,7 +303,7 @@
namedAttributeNodes = result;
return result;
}
-
+
public Nodes getBody() {
return body;
}
@@ -364,6 +363,7 @@
/**
* Selects and invokes a method in the visitor class based on the node
* type. This is abstract and should be overrode by the extending classes.
+ *
* @param v The visitor class
*/
abstract void accept(Visitor v) throws JasperException;
@@ -375,6 +375,7 @@
/*
* Adds this Node to the body of the given parent.
*/
+
private void addToParent(Node parent) {
if (parent != null) {
this.parent = parent;
@@ -391,7 +392,7 @@
/*********************************************************************
* Child classes
*/
-
+
/**
* Represents the root of a Jsp page or Jsp document
*/
@@ -402,7 +403,7 @@
// Source encoding of the page containing this Root
private String pageEnc;
-
+
// Page encoding specified in JSP config element
private String jspConfigPageEnc;
@@ -481,7 +482,7 @@
public boolean isDefaultPageEncoding() {
return isDefaultPageEncoding;
}
-
+
public void setIsEncodingSpecifiedInProlog(boolean isSpecified) {
isEncodingSpecifiedInProlog = isSpecified;
}
@@ -492,13 +493,13 @@
/**
* @return The enclosing root to this Root. Usually represents the
- * page that includes this one.
+ * page that includes this one.
*/
public Root getParentRoot() {
return parentRoot;
}
}
-
+
/**
* Represents the root of a Jsp document (XML syntax)
*/
@@ -508,7 +509,7 @@
Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
Mark start, Node parent) {
super(qName, ROOT_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs,
- start, parent);
+ start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -531,7 +532,7 @@
Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start, Node parent) {
super(qName, PAGE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
imports = new Vector();
}
@@ -543,6 +544,7 @@
* Parses the comma-separated list of class or package names in the
* given attribute value and adds each component to this
* PageDirective's vector of imported classes and packages.
+ *
* @param value A comma-separated string of imports.
*/
public void addImport(String value) {
@@ -572,7 +574,7 @@
public IncludeDirective(Attributes attrs, Mark start, Node parent) {
this(JSP_INCLUDE_DIRECTIVE_ACTION, attrs, null, null, start,
- parent);
+ parent);
}
public IncludeDirective(String qName, Attributes attrs,
@@ -580,7 +582,7 @@
Attributes taglibAttrs, Mark start,
Node parent) {
super(qName, INCLUDE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -595,7 +597,7 @@
public TaglibDirective(Attributes attrs, Mark start, Node parent) {
super(JSP_TAGLIB_DIRECTIVE_ACTION, TAGLIB_DIRECTIVE_ACTION, attrs,
- start, parent);
+ start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -617,18 +619,19 @@
Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start, Node parent) {
super(qName, TAG_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
imports = new Vector();
}
public void accept(Visitor v) throws JasperException {
v.visit(this);
}
-
+
/**
* Parses the comma-separated list of class or package names in the
* given attribute value and adds each component to this
* PageDirective's vector of imported classes and packages.
+ *
* @param value A comma-separated string of imports.
*/
public void addImport(String value) {
@@ -645,7 +648,7 @@
imports.add(value.substring(start).trim());
}
}
-
+
public List getImports() {
return imports;
}
@@ -658,7 +661,7 @@
public AttributeDirective(Attributes attrs, Mark start, Node parent) {
this(JSP_ATTRIBUTE_DIRECTIVE_ACTION, attrs, null, null, start,
- parent);
+ parent);
}
public AttributeDirective(String qName, Attributes attrs,
@@ -666,7 +669,7 @@
Attributes taglibAttrs, Mark start,
Node parent) {
super(qName, ATTRIBUTE_DIRECTIVE_ACTION, attrs,
- nonTaglibXmlnsAttrs, taglibAttrs, start, parent);
+ nonTaglibXmlnsAttrs, taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -681,7 +684,7 @@
public VariableDirective(Attributes attrs, Mark start, Node parent) {
this(JSP_VARIABLE_DIRECTIVE_ACTION, attrs, null, null, start,
- parent);
+ parent);
}
public VariableDirective(String qName, Attributes attrs,
@@ -689,7 +692,7 @@
Attributes taglibAttrs,
Mark start, Node parent) {
super(qName, VARIABLE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -710,7 +713,7 @@
Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start, Node parent) {
super(qName, INVOKE_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -731,7 +734,7 @@
Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start, Node parent) {
super(qName, DOBODY_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -769,7 +772,7 @@
Attributes taglibAttrs, Mark start,
Node parent) {
super(qName, localName, null, nonTaglibXmlnsAttrs, taglibAttrs,
- start, parent);
+ start, parent);
}
/**
@@ -777,13 +780,14 @@
* was stored as a String in the "text" field, whereas when this node
* was created from a JSP document, its text was stored as one or more
* TemplateText nodes in its body. This method handles either case.
+ *
* @return The text string
*/
public String getText() {
String ret = text;
if ((ret == null) && (body != null)) {
StringBuffer buf = new StringBuffer();
- for (int i=0; i<body.size(); i++) {
+ for (int i = 0; i < body.size(); i++) {
buf.append(body.getNode(i).getText());
}
ret = buf.toString();
@@ -811,14 +815,14 @@
public Declaration(String text, Mark start, Node parent) {
super(JSP_DECLARATION_ACTION, DECLARATION_ACTION, text, start,
- parent);
+ parent);
}
public Declaration(String qName, Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start,
Node parent) {
super(qName, DECLARATION_ACTION, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -834,14 +838,14 @@
public Expression(String text, Mark start, Node parent) {
super(JSP_EXPRESSION_ACTION, EXPRESSION_ACTION, text, start,
- parent);
+ parent);
}
public Expression(String qName, Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start,
Node parent) {
super(qName, EXPRESSION_ACTION, nonTaglibXmlnsAttrs, taglibAttrs,
- start, parent);
+ start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -862,7 +866,7 @@
Attributes taglibAttrs, Mark start,
Node parent) {
super(qName, SCRIPTLET_ACTION, nonTaglibXmlnsAttrs, taglibAttrs,
- start, parent);
+ start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -910,7 +914,7 @@
Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start, Node parent) {
super(qName, PARAM_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -940,7 +944,7 @@
Attributes taglibAttrs,
Mark start, Node parent) {
super(qName, PARAMS_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs,
- start, parent);
+ start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -962,7 +966,7 @@
Attributes taglibAttrs, Mark start,
Node parent) {
super(qName, FALLBACK_ACTION, null, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -985,7 +989,7 @@
Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start, Node parent) {
super(qName, INCLUDE_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -1016,7 +1020,7 @@
Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start, Node parent) {
super(qName, FORWARD_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -1045,7 +1049,7 @@
Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start, Node parent) {
super(qName, GET_PROPERTY_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -1068,7 +1072,7 @@
Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start, Node parent) {
super(qName, SET_PROPERTY_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -1099,7 +1103,7 @@
Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
Mark start, Node parent) {
super(qName, USE_BEAN_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -1122,7 +1126,7 @@
private JspAttribute width;
private JspAttribute height;
-
+
public PlugIn(Attributes attrs, Mark start, Node parent) {
this(JSP_PLUGIN_ACTION, attrs, null, null, start, parent);
}
@@ -1131,7 +1135,7 @@
Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs,
Mark start, Node parent) {
super(qName, PLUGIN_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -1168,7 +1172,7 @@
Attributes taglibAttrs,
Mark start, Node parent) {
super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs,
- start, parent);
+ start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -1183,7 +1187,7 @@
return jspAttrs;
}
}
-
+
/**
* Represents a <jsp:element>.
*/
@@ -1200,7 +1204,7 @@
Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start, Node parent) {
super(qName, ELEMENT_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -1240,7 +1244,7 @@
Attributes taglibAttrs,
Mark start, Node parent) {
super(qName, OUTPUT_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
+ taglibAttrs, start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -1250,12 +1254,12 @@
/**
* Collected information about child elements. Used by nodes like
- * CustomTag, JspBody, and NamedAttribute. The information is
+ * CustomTag, JspBody, and NamedAttribute. The information is
* set in the Collector.
*/
public static class ChildInfo {
private boolean scriptless; // true if the tag and its body
- // contain no scripting elements.
+ // contain no scripting elements.
private boolean hasUseBean;
private boolean hasIncludeAction;
private boolean hasParamAction;
@@ -1301,7 +1305,7 @@
public boolean hasSetProperty() {
return hasSetProperty;
}
-
+
public void setHasScriptingVars(boolean s) {
hasScriptingVars = s;
}
@@ -1357,7 +1361,7 @@
String uri, Attributes attrs, Mark start, Node parent,
TagInfo tagInfo, Class tagHandlerClass) {
this(qName, prefix, localName, uri, attrs, null, null, start,
- parent, tagInfo, tagHandlerClass);
+ parent, tagInfo, tagHandlerClass);
}
/*
@@ -1370,7 +1374,7 @@
Mark start, Node parent, TagInfo tagInfo,
Class tagHandlerClass) {
super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs,
- start, parent);
+ start, parent);
this.uri = uri;
this.prefix = prefix;
@@ -1379,16 +1383,16 @@
this.customNestingLevel = makeCustomNestingLevel();
this.childInfo = new ChildInfo();
- this.implementsIterationTag =
- IterationTag.class.isAssignableFrom(tagHandlerClass);
+ this.implementsIterationTag =
+ IterationTag.class.isAssignableFrom(tagHandlerClass);
this.implementsBodyTag =
- BodyTag.class.isAssignableFrom(tagHandlerClass);
- this.implementsTryCatchFinally =
- TryCatchFinally.class.isAssignableFrom(tagHandlerClass);
- this.implementsSimpleTag =
- SimpleTag.class.isAssignableFrom(tagHandlerClass);
- this.implementsDynamicAttributes =
- DynamicAttributes.class.isAssignableFrom(tagHandlerClass);
+ BodyTag.class.isAssignableFrom(tagHandlerClass);
+ this.implementsTryCatchFinally =
+ TryCatchFinally.class.isAssignableFrom(tagHandlerClass);
+ this.implementsSimpleTag =
+ SimpleTag.class.isAssignableFrom(tagHandlerClass);
+ this.implementsDynamicAttributes =
+ DynamicAttributes.class.isAssignableFrom(tagHandlerClass);
}
/*
@@ -1398,7 +1402,7 @@
String uri, Attributes attrs, Mark start, Node parent,
TagFileInfo tagFileInfo) {
this(qName, prefix, localName, uri, attrs, null, null, start,
- parent, tagFileInfo);
+ parent, tagFileInfo);
}
/*
@@ -1411,7 +1415,7 @@
Mark start, Node parent, TagFileInfo tagFileInfo) {
super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs,
- start, parent);
+ start, parent);
this.uri = uri;
this.prefix = prefix;
@@ -1452,11 +1456,11 @@
public JspAttribute[] getJspAttributes() {
return jspAttrs;
}
-
+
public ChildInfo getChildInfo() {
return childInfo;
}
-
+
public void setTagData(TagData tagData) {
this.tagData = tagData;
this.varInfos = tagInfo.getVariableInfo(tagData);
@@ -1523,8 +1527,8 @@
public TagVariableInfo[] getTagVariableInfos() {
return tagInfo.getTagVariableInfos();
- }
-
+ }
+
public VariableInfo[] getVariableInfos() {
return varInfos;
}
@@ -1547,15 +1551,15 @@
public void setScriptingVars(Vector vec, int scope) {
switch (scope) {
- case VariableInfo.AT_BEGIN:
- this.atBeginScriptingVars = vec;
- break;
- case VariableInfo.AT_END:
- this.atEndScriptingVars = vec;
- break;
- case VariableInfo.NESTED:
- this.nestedScriptingVars = vec;
- break;
+ case VariableInfo.AT_BEGIN:
+ this.atBeginScriptingVars = vec;
+ break;
+ case VariableInfo.AT_END:
+ this.atEndScriptingVars = vec;
+ break;
+ case VariableInfo.NESTED:
+ this.nestedScriptingVars = vec;
+ break;
}
}
@@ -1567,15 +1571,15 @@
Vector vec = null;
switch (scope) {
- case VariableInfo.AT_BEGIN:
- vec = this.atBeginScriptingVars;
- break;
- case VariableInfo.AT_END:
- vec = this.atEndScriptingVars;
- break;
- case VariableInfo.NESTED:
- vec = this.nestedScriptingVars;
- break;
+ case VariableInfo.AT_BEGIN:
+ vec = this.atBeginScriptingVars;
+ break;
+ case VariableInfo.AT_END:
+ vec = this.atEndScriptingVars;
+ break;
+ case VariableInfo.NESTED:
+ vec = this.nestedScriptingVars;
+ break;
}
return vec;
@@ -1593,18 +1597,18 @@
* Checks to see if the attribute of the given name is of type
* JspFragment.
*/
- public boolean checkIfAttributeIsJspFragment( String name ) {
+ public boolean checkIfAttributeIsJspFragment(String name) {
boolean result = false;
TagAttributeInfo[] attributes = tagInfo.getAttributes();
for (int i = 0; i < attributes.length; i++) {
if (attributes[i].getName().equals(name) &&
- attributes[i].isFragment()) {
+ attributes[i].isFragment()) {
result = true;
break;
}
}
-
+
return result;
}
@@ -1631,7 +1635,7 @@
public Nodes getAtSTag() {
return atSTag;
}
-
+
public void setAtETag(Nodes eTag) {
atETag = eTag;
}
@@ -1639,30 +1643,30 @@
public Nodes getAtETag() {
return atETag;
}
-
+
/*
- * Computes this custom tag's custom nesting level, which corresponds
- * to the number of times this custom tag is nested inside itself.
- *
- * Example:
- *
- * <g:h>
- * <a:b> -- nesting level 0
- * <c:d>
- * <e:f>
- * <a:b> -- nesting level 1
- * <a:b> -- nesting level 2
- * </a:b>
- * </a:b>
- * <a:b> -- nesting level 1
- * </a:b>
- * </e:f>
- * </c:d>
- * </a:b>
- * </g:h>
- *
- * @return Custom tag's nesting level
- */
+ * Computes this custom tag's custom nesting level, which corresponds
+ * to the number of times this custom tag is nested inside itself.
+ *
+ * Example:
+ *
+ * <g:h>
+ * <a:b> -- nesting level 0
+ * <c:d>
+ * <e:f>
+ * <a:b> -- nesting level 1
+ * <a:b> -- nesting level 2
+ * </a:b>
+ * </a:b>
+ * <a:b> -- nesting level 1
+ * </a:b>
+ * </e:f>
+ * </c:d>
+ * </a:b>
+ * </g:h>
+ *
+ * @return Custom tag's nesting level
+ */
private int makeCustomNestingLevel() {
int n = 0;
Node p = parent;
@@ -1679,33 +1683,33 @@
/**
* Returns true if this custom action has an empty body, and false
* otherwise.
- *
- * A custom action is considered to have an empty body if the
+ * <p/>
+ * A custom action is considered to have an empty body if the
* following holds true:
* - getBody() returns null, or
* - all immediate children are jsp:attribute actions, or
* - the action's jsp:body is empty.
*/
- public boolean hasEmptyBody() {
- boolean hasEmptyBody = true;
- Nodes nodes = getBody();
- if (nodes != null) {
- int numChildNodes = nodes.size();
- for (int i=0; i<numChildNodes; i++) {
- Node n = nodes.getNode(i);
- if (!(n instanceof NamedAttribute)) {
- if (n instanceof JspBody) {
- hasEmptyBody = (n.getBody() == null);
- } else {
- hasEmptyBody = false;
- }
- break;
- }
- }
- }
+ public boolean hasEmptyBody() {
+ boolean hasEmptyBody = true;
+ Nodes nodes = getBody();
+ if (nodes != null) {
+ int numChildNodes = nodes.size();
+ for (int i = 0; i < numChildNodes; i++) {
+ Node n = nodes.getNode(i);
+ if (!(n instanceof NamedAttribute)) {
+ if (n instanceof JspBody) {
+ hasEmptyBody = (n.getBody() == null);
+ } else {
+ hasEmptyBody = false;
+ }
+ break;
+ }
+ }
+ }
- return hasEmptyBody;
- }
+ return hasEmptyBody;
+ }
}
/**
@@ -1743,7 +1747,7 @@
public JspText(String qName, Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start, Node parent) {
super(qName, TEXT_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs,
- start, parent);
+ start, parent);
}
public void accept(Visitor v) throws JasperException {
@@ -1761,7 +1765,7 @@
// True if this node is to be trimmed, or false otherwise
private boolean trim = true;
-
+
private ChildInfo childInfo;
private String name;
private String localName;
@@ -1777,8 +1781,8 @@
Mark start, Node parent) {
super(qName, ATTRIBUTE_ACTION, attrs, nonTaglibXmlnsAttrs,
- taglibAttrs, start, parent);
- if( "false".equals( this.getAttributeValue( "trim" ) ) ) {
+ taglibAttrs, start, parent);
+ if ("false".equals(this.getAttributeValue("trim"))) {
// (if null or true, leave default of true)
trim = false;
}
@@ -1790,7 +1794,7 @@
int index = name.indexOf(':');
if (index != -1) {
prefix = name.substring(0, index);
- localName = name.substring(index+1);
+ localName = name.substring(index + 1);
}
}
}
@@ -1810,7 +1814,7 @@
public String getPrefix() {
return this.prefix;
}
-
+
public ChildInfo getChildInfo() {
return this.childInfo;
}
@@ -1821,7 +1825,7 @@
/**
* @return A unique temporary variable name to store the result in.
- * (this probably could go elsewhere, but it's convenient here)
+ * (this probably could go elsewhere, but it's convenient here)
*/
public String getTemporaryVariableName() {
if (temporaryVariableName == null) {
@@ -1839,10 +1843,11 @@
class AttributeVisitor extends Visitor {
String attrValue = null;
+
public void visit(TemplateText txt) {
attrValue = new String(txt.getText());
}
-
+
public String getAttrValue() {
return attrValue;
}
@@ -1860,7 +1865,7 @@
}
text = attributeVisitor.getAttrValue();
}
-
+
return text;
}
}
@@ -1879,7 +1884,7 @@
public JspBody(String qName, Attributes nonTaglibXmlnsAttrs,
Attributes taglibAttrs, Mark start, Node parent) {
super(qName, BODY_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs,
- start, parent);
+ start, parent);
this.childInfo = new ChildInfo();
}
@@ -1927,7 +1932,7 @@
*/
public void rtrim() {
int index = text.length();
- while( (index > 0) && (text.charAt(index-1) <= ' ') ) {
+ while ((index > 0) && (text.charAt(index - 1) <= ' ')) {
index--;
}
text = text.substring(0, index);
@@ -1938,7 +1943,7 @@
*/
public boolean isAllSpace() {
boolean isAllSpace = true;
- for (int i=0; i<text.length(); i++) {
+ for (int i = 0; i < text.length(); i++) {
if (!Character.isWhitespace(text.charAt(i))) {
isAllSpace = false;
break;
@@ -1949,9 +1954,10 @@
/**
* Add a source to Java line mapping
+ *
* @param srcLine The postion of the source line, relative to the line
- * at the start of this node. The corresponding java line is
- * assumed to be consecutive, i.e. one more than the last.
+ * at the start of this node. The corresponding java line is
+ * assumed to be consecutive, i.e. one more than the last.
*/
public void addSmap(int srcLine) {
if (extraSmap == null) {
@@ -1971,7 +1977,7 @@
/**
* Represents attributes that can be request time expressions.
- *
+ * <p/>
* Can either be a plain attribute, an attribute that represents a
* request time expression value, or a named attribute (specified using
* the jsp:attribute standard action).
@@ -1993,7 +1999,7 @@
private NamedAttribute namedAttributeNode;
JspAttribute(String qName, String uri, String localName, String value,
- boolean expr, ELNode.Nodes el, boolean dyn ) {
+ boolean expr, ELNode.Nodes el, boolean dyn) {
this.qName = qName;
this.uri = uri;
this.localName = localName;
@@ -2022,22 +2028,22 @@
}
/**
- * @return The name of the attribute
+ * @return The name of the attribute
*/
public String getName() {
return qName;
}
/**
- * @return The local name of the attribute
+ * @return The local name of the attribute
*/
public String getLocalName() {
return localName;
}
/**
- * @return The namespace of the attribute, or null if in the default
- * namespace
+ * @return The namespace of the attribute, or null if in the default
+ * namespace
*/
public String getURI() {
return uri;
@@ -2048,7 +2054,7 @@
*
* @return the value for the attribute, or the expression string
* (stripped of "<%=", "%>", "%=", or "%"
- * but containing "${" and "}" for EL expressions)
+ * but containing "${" and "}" for EL expressions)
*/
public String getValue() {
return value;
@@ -2078,10 +2084,8 @@
}
/**
- * @return true if the value represents an expression that should
- * be fed to the expression interpreter
* @return false for string literals or rtexprvalues that should
- * not be interpreted or reevaluated
+ * not be interpreted or reevaluated
*/
public boolean isELInterpreterInput() {
return el != null;
@@ -2089,7 +2093,7 @@
/**
* @return true if the value is a string literal known at translation
- * time.
+ * time.
*/
public boolean isLiteral() {
return !expression && (el != null) && !namedAttribute;
@@ -2129,6 +2133,7 @@
/**
* Appends a node to the list
+ *
* @param n The node to add
*/
public void add(Node n) {
@@ -2138,6 +2143,7 @@
/**
* Removes the given node from the list.
+ *
* @param n The node to be removed
*/
public void remove(Node n) {
@@ -2146,6 +2152,7 @@
/**
* Visit the nodes in the list with the supplied visitor
+ *
* @param v The visitor used
*/
public void visit(Visitor v) throws JasperException {
@@ -2168,7 +2175,7 @@
}
return n;
}
-
+
public Node.Root getRoot() {
return root;
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/PageDataImpl.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/PageDataImpl.java
index a3bf2f4..7c13bce 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/PageDataImpl.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/PageDataImpl.java
@@ -30,16 +30,16 @@
/**
* An implementation of <tt>javax.servlet.jsp.tagext.PageData</tt> which
* builds the XML view of a given page.
- *
+ * <p/>
* The XML view is built in two passes:
- *
+ * <p/>
* During the first pass, the FirstPassVisitor collects the attributes of the
* top-level jsp:root and those of the jsp:root elements of any included
* pages, and adds them to the jsp:root element of the XML view.
* In addition, any taglib directives are converted into xmlns: attributes and
* added to the jsp:root element of the XML view.
* This pass ignores any nodes other than JspRoot and TaglibDirective.
- *
+ * <p/>
* During the second pass, the SecondPassVisitor produces the XML view, using
* the combined jsp:root attributes determined in the first pass and any
* remaining pages nodes (this pass ignores any JspRoot and TaglibDirective
@@ -62,18 +62,18 @@
* @param page the page nodes from which to generate the XML view
*/
public PageDataImpl(Node.Nodes page, Compiler compiler)
- throws JasperException {
+ throws JasperException {
// First pass
FirstPassVisitor firstPass = new FirstPassVisitor(page.getRoot(),
- compiler.getPageInfo());
+ compiler.getPageInfo());
page.visit(firstPass);
// Second pass
buf = new StringBuffer();
SecondPassVisitor secondPass
- = new SecondPassVisitor(page.getRoot(), buf, compiler,
- firstPass.getJspIdPrefix());
+ = new SecondPassVisitor(page.getRoot(), buf, compiler,
+ firstPass.getJspIdPrefix());
page.visit(secondPass);
}
@@ -103,7 +103,7 @@
* attributes and adds them to the jsp:root element of the XML view.
*/
static class FirstPassVisitor
- extends Node.Visitor implements TagConstants {
+ extends Node.Visitor implements TagConstants {
private Node.Root root;
private AttributesImpl rootAttrs;
@@ -120,7 +120,7 @@
this.pageInfo = pageInfo;
this.rootAttrs = new AttributesImpl();
this.rootAttrs.addAttribute("", "", "version", "CDATA",
- JSP_VERSION);
+ JSP_VERSION);
this.jspIdPrefix = "jsp";
}
@@ -136,7 +136,7 @@
*/
if (!JSP_URI.equals(rootAttrs.getValue("xmlns:jsp"))) {
rootAttrs.addAttribute("", "", "xmlns:jsp", "CDATA",
- JSP_URI);
+ JSP_URI);
}
if (pageInfo.isJspPrefixHijacked()) {
@@ -153,7 +153,7 @@
jspIdPrefix += "jsp";
}
rootAttrs.addAttribute("", "", "xmlns:" + jspIdPrefix,
- "CDATA", JSP_URI);
+ "CDATA", JSP_URI);
}
root.setAttributes(rootAttrs);
@@ -189,11 +189,11 @@
location = URN_JSPTLD + location;
}
rootAttrs.addAttribute("", "", qName, "CDATA",
- location);
+ location);
} else {
location = attrs.getValue("tagdir");
rootAttrs.addAttribute("", "", qName, "CDATA",
- URN_JSPTAGDIR + location);
+ URN_JSPTAGDIR + location);
}
}
}
@@ -207,19 +207,19 @@
if (attrs != null) {
int len = attrs.getLength();
- for (int i=0; i<len; i++) {
+ for (int i = 0; i < len; i++) {
String qName = attrs.getQName(i);
if ("version".equals(qName)) {
continue;
}
// Bugzilla 35252: http://issues.apache.org/bugzilla/show_bug.cgi?id=35252
- if(rootAttrs.getIndex(qName) == -1) {
+ if (rootAttrs.getIndex(qName) == -1) {
rootAttrs.addAttribute(attrs.getURI(i),
- attrs.getLocalName(i),
- qName,
- attrs.getType(i),
- attrs.getValue(i));
+ attrs.getLocalName(i),
+ qName,
+ attrs.getType(i),
+ attrs.getValue(i));
}
}
}
@@ -232,7 +232,7 @@
* each element a unique jsp:id attribute.
*/
static class SecondPassVisitor extends Node.Visitor
- implements TagConstants {
+ implements TagConstants {
private Node.Root root;
private StringBuffer buf;
@@ -331,7 +331,7 @@
public void visit(Node.IncludeAction n) throws JasperException {
appendTag(n);
}
-
+
public void visit(Node.ForwardAction n) throws JasperException {
appendTag(n);
}
@@ -359,7 +359,7 @@
public void visit(Node.UseBean n) throws JasperException {
appendTag(n);
}
-
+
public void visit(Node.PlugIn n) throws JasperException {
appendTag(n);
}
@@ -367,7 +367,7 @@
public void visit(Node.NamedAttribute n) throws JasperException {
appendTag(n);
}
-
+
public void visit(Node.JspBody n) throws JasperException {
appendTag(n);
}
@@ -407,7 +407,7 @@
public void visit(Node.VariableDirective n) throws JasperException {
appendTag(n);
}
-
+
public void visit(Node.TemplateText n) throws JasperException {
/*
* If the template text came from a JSP page written in JSP syntax,
@@ -441,7 +441,7 @@
buf.append(jspId++).append("\"\n");
if (ROOT_ACTION.equals(n.getLocalName()) || body != null
- || text != null) {
+ || text != null) {
buf.append(">\n");
if (ROOT_ACTION.equals(n.getLocalName())) {
if (compiler.getCompilationContext().isTagFile()) {
@@ -479,7 +479,7 @@
boolean append = false;
Attributes attrs = n.getAttributes();
int len = (attrs == null) ? 0 : attrs.getLength();
- for (int i=0; i<len; i++) {
+ for (int i = 0; i < len; i++) {
String attrName = attrs.getQName(i);
if (!"pageEncoding".equals(attrName)
&& !"contentType".equals(attrName)) {
@@ -499,7 +499,7 @@
buf.append(jspId++).append("\"\n");
// append remaining attributes
- for (int i=0; i<len; i++) {
+ for (int i = 0; i < len; i++) {
String attrName = attrs.getQName(i);
if ("import".equals(attrName) || "contentType".equals(attrName)
|| "pageEncoding".equals(attrName)) {
@@ -553,7 +553,7 @@
buf.append(" ").append("pageEncoding").append("=\"UTF-8\"\n");
buf.append(" ").append("contentType").append("=\"");
buf.append(compiler.getPageInfo().getContentType()).append("\"\n");
- buf.append("/>\n");
+ buf.append("/>\n");
}
/*
@@ -570,7 +570,7 @@
boolean append = false;
Attributes attrs = n.getAttributes();
int len = (attrs == null) ? 0 : attrs.getLength();
- for (int i=0; i<len; i++) {
+ for (int i = 0; i < len; i++) {
String attrName = attrs.getQName(i);
if (!"pageEncoding".equals(attrName)) {
append = true;
@@ -596,7 +596,7 @@
buf.append(" ").append(jspIdPrefix).append(":id").append("=\"");
buf.append(jspId++).append("\"\n");
buf.append(" ").append("pageEncoding").append("=\"UTF-8\"\n");
- buf.append("/>\n");
+ buf.append("/>\n");
}
private void appendText(String text, boolean createJspTextElement) {
@@ -616,11 +616,11 @@
appendCDATA(text);
}
}
-
+
/*
- * Appends the given text as a CDATA section to the XML view, unless
- * the text has already been marked as CDATA.
- */
+ * Appends the given text as a CDATA section to the XML view, unless
+ * the text has already been marked as CDATA.
+ */
private void appendCDATA(String text) {
buf.append(CDATA_START_SECTION);
buf.append(escapeCDATA(text));
@@ -632,14 +632,14 @@
* within the given text, so it can be included in a CDATA section.
*/
private String escapeCDATA(String text) {
- if( text==null ) return "";
+ if (text == null) return "";
int len = text.length();
CharArrayWriter result = new CharArrayWriter(len);
- for (int i=0; i<len; i++) {
- if (((i+2) < len)
+ for (int i = 0; i < len; i++) {
+ if (((i + 2) < len)
&& (text.charAt(i) == ']')
- && (text.charAt(i+1) == ']')
- && (text.charAt(i+2) == '>')) {
+ && (text.charAt(i + 1) == ']')
+ && (text.charAt(i + 2) == '>')) {
// match found
result.write(']');
result.write(']');
@@ -665,7 +665,7 @@
*/
Attributes attrs = n.getTaglibAttributes();
int len = (attrs == null) ? 0 : attrs.getLength();
- for (int i=0; i<len; i++) {
+ for (int i = 0; i < len; i++) {
String name = attrs.getQName(i);
String value = attrs.getValue(i);
buf.append(" ").append(name).append("=\"").append(value).append("\"\n");
@@ -677,7 +677,7 @@
attrs = n.getNonTaglibXmlnsAttributes();
len = (attrs == null) ? 0 : attrs.getLength();
boolean defaultNSSeen = false;
- for (int i=0; i<len; i++) {
+ for (int i = 0; i < len; i++) {
String name = attrs.getQName(i);
String value = attrs.getValue(i);
buf.append(" ").append(name).append("=\"").append(value).append("\"\n");
@@ -693,7 +693,7 @@
*/
attrs = n.getAttributes();
len = (attrs == null) ? 0 : attrs.getLength();
- for (int i=0; i<len; i++) {
+ for (int i = 0; i < len; i++) {
String name = attrs.getQName(i);
String value = attrs.getValue(i);
buf.append(" ").append(name).append("=\"");
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/PageInfo.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/PageInfo.java
index 0d20143..6d0f088 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/PageInfo.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/PageInfo.java
@@ -47,7 +47,7 @@
private String session;
private boolean isSession = true;
private String bufferValue;
- private int buffer = 8*1024; // XXX confirm
+ private int buffer = 8 * 1024; // XXX confirm
private String autoFlush;
private boolean isAutoFlush = true;
private String isThreadSafeValue;
@@ -93,13 +93,14 @@
this.prefixes = new HashSet();
// Enter standard imports
- for(int i = 0; i < Constants.STANDARD_IMPORTS.length; i++)
+ for (int i = 0; i < Constants.STANDARD_IMPORTS.length; i++)
imports.add(Constants.STANDARD_IMPORTS[i]);
}
/**
* Check if the plugin ID has been previously declared. Make a not
* that this Id is now declared.
+ *
* @return true if Id has been declared.
*/
public boolean isPluginDeclared(String id) {
@@ -127,7 +128,7 @@
public void addDependant(String d) {
if (!dependants.contains(d) && !jspFile.equals(d))
- dependants.add(d);
+ dependants.add(d);
}
public List getDependants() {
@@ -348,9 +349,10 @@
/*
* language
*/
+
public void setLanguage(String value, Node n, ErrorDispatcher err,
- boolean pagedir)
- throws JasperException {
+ boolean pagedir)
+ throws JasperException {
if (!"java".equalsIgnoreCase(value)) {
if (pagedir)
@@ -391,12 +393,11 @@
* Gets the value of the 'extends' page directive attribute.
*
* @param useDefault TRUE if the default
- * (org.apache.jasper.runtime.HttpJspBase) should be returned if this
- * attribute has not been set, FALSE otherwise
- *
+ * (org.apache.jasper.runtime.HttpJspBase) should be returned if this
+ * attribute has not been set, FALSE otherwise
* @return The value of the 'extends' page directive attribute, or the
- * default (org.apache.jasper.runtime.HttpJspBase) if this attribute has
- * not been set and useDefault is TRUE
+ * default (org.apache.jasper.runtime.HttpJspBase) if this attribute has
+ * not been set and useDefault is TRUE
*/
public String getExtends(boolean useDefault) {
return (xtends == null && useDefault ? defaultExtends : xtends);
@@ -406,8 +407,8 @@
* Gets the value of the 'extends' page directive attribute.
*
* @return The value of the 'extends' page directive attribute, or the
- * default (org.apache.jasper.runtime.HttpJspBase) if this attribute has
- * not been set
+ * default (org.apache.jasper.runtime.HttpJspBase) if this attribute has
+ * not been set
*/
public String getExtends() {
return getExtends(true);
@@ -430,7 +431,7 @@
* buffer
*/
public void setBufferValue(String value, Node n, ErrorDispatcher err)
- throws JasperException {
+ throws JasperException {
if ("none".equalsIgnoreCase(value))
buffer = 0;
@@ -438,7 +439,7 @@
if (value == null || !value.endsWith("kb"))
err.jspError(n, "jsp.error.page.invalid.buffer");
try {
- Integer k = new Integer(value.substring(0, value.length()-2));
+ Integer k = new Integer(value.substring(0, value.length() - 2));
buffer = k.intValue() * 1024;
} catch (NumberFormatException e) {
err.jspError(n, "jsp.error.page.invalid.buffer");
@@ -461,7 +462,7 @@
* session
*/
public void setSession(String value, Node n, ErrorDispatcher err)
- throws JasperException {
+ throws JasperException {
if ("true".equalsIgnoreCase(value))
isSession = true;
@@ -486,7 +487,7 @@
* autoFlush
*/
public void setAutoFlush(String value, Node n, ErrorDispatcher err)
- throws JasperException {
+ throws JasperException {
if ("true".equalsIgnoreCase(value))
isAutoFlush = true;
@@ -511,7 +512,7 @@
* isThreadSafe
*/
public void setIsThreadSafe(String value, Node n, ErrorDispatcher err)
- throws JasperException {
+ throws JasperException {
if ("true".equalsIgnoreCase(value))
isThreadSafe = true;
@@ -560,7 +561,7 @@
* isErrorPage
*/
public void setIsErrorPage(String value, Node n, ErrorDispatcher err)
- throws JasperException {
+ throws JasperException {
if ("true".equalsIgnoreCase(value))
isErrorPage = true;
@@ -585,8 +586,8 @@
* isELIgnored
*/
public void setIsELIgnored(String value, Node n, ErrorDispatcher err,
- boolean pagedir)
- throws JasperException {
+ boolean pagedir)
+ throws JasperException {
if ("true".equalsIgnoreCase(value))
isELIgnored = true;
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Parser.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Parser.java
index 5785426..c972d06 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Parser.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Parser.java
@@ -37,7 +37,7 @@
* JSP page grammar is included here for reference. The token '#'
* that appears in the production indicates the current input token
* location in the production.
- *
+ *
* @author Kin-man Chung
* @author Shawn Bayern
* @author Mark Roth
@@ -59,12 +59,12 @@
// Virtual body content types, to make parsing a little easier.
// These are not accessible from outside the parser.
- private static final String JAVAX_BODY_CONTENT_PARAM =
- "JAVAX_BODY_CONTENT_PARAM";
- private static final String JAVAX_BODY_CONTENT_PLUGIN =
- "JAVAX_BODY_CONTENT_PLUGIN";
- private static final String JAVAX_BODY_CONTENT_TEMPLATE_TEXT =
- "JAVAX_BODY_CONTENT_TEMPLATE_TEXT";
+ private static final String JAVAX_BODY_CONTENT_PARAM =
+ "JAVAX_BODY_CONTENT_PARAM";
+ private static final String JAVAX_BODY_CONTENT_PLUGIN =
+ "JAVAX_BODY_CONTENT_PLUGIN";
+ private static final String JAVAX_BODY_CONTENT_TEMPLATE_TEXT =
+ "JAVAX_BODY_CONTENT_TEMPLATE_TEXT";
private static final boolean STRICT_QUOTE_ESCAPING = Boolean.valueOf(
System.getProperty(
@@ -91,9 +91,9 @@
/**
* The main entry for Parser
- *
- * @param pc The ParseController, use for getting other objects in compiler
- * and for parsing included pages
+ *
+ * @param pc The ParseController, use for getting other objects in compiler
+ * and for parsing included pages
* @param reader To read the page
* @param parent The parent node to this page, null for top level page
* @return list of nodes representing the parsed page
@@ -107,10 +107,10 @@
String pageEnc,
String jspConfigPageEnc,
boolean isDefaultPageEncoding)
- throws JasperException {
+ throws JasperException {
Parser parser = new Parser(pc, reader, isTagFile, directivesOnly,
- jarFileUrl);
+ jarFileUrl);
Node.Root root = new Node.Root(reader.mark(), parent, false);
root.setPageEncoding(pageEnc);
@@ -156,23 +156,23 @@
*/
public static Attributes parseAttributes(ParserController pc,
JspReader reader)
- throws JasperException {
+ throws JasperException {
Parser tmpParser = new Parser(pc, reader, false, false, null);
return tmpParser.parseAttributes();
}
/**
* Attribute ::= Name S? Eq S?
- * ( '"<%=' RTAttributeValueDouble
- * | '"' AttributeValueDouble
- * | "'<%=" RTAttributeValueSingle
- * | "'" AttributeValueSingle
- * }
+ * ( '"<%=' RTAttributeValueDouble
+ * | '"' AttributeValueDouble
+ * | "'<%=" RTAttributeValueSingle
+ * | "'" AttributeValueSingle
+ * }
* Note: JSP and XML spec does not allow while spaces around Eq. It is
* added to be backward compatible with Tomcat, and with other xml parsers.
*/
private boolean parseAttribute(AttributesImpl attrs)
- throws JasperException {
+ throws JasperException {
// Get the qualified name
String qName = parseName();
@@ -188,25 +188,25 @@
uri = pageInfo.getURI(prefix);
if (uri == null) {
err.jspError(reader.mark(),
- "jsp.error.attribute.invalidPrefix", prefix);
+ "jsp.error.attribute.invalidPrefix", prefix);
}
- localName = qName.substring(index+1);
+ localName = qName.substring(index + 1);
}
- reader.skipSpaces();
+ reader.skipSpaces();
if (!reader.matches("="))
err.jspError(reader.mark(), "jsp.error.attribute.noequal");
- reader.skipSpaces();
+ reader.skipSpaces();
char quote = (char) reader.nextChar();
if (quote != '\'' && quote != '"')
err.jspError(reader.mark(), "jsp.error.attribute.noquote");
- String watchString = "";
+ String watchString = "";
if (reader.matches("<%="))
watchString = "%>";
watchString = watchString + quote;
-
+
String attrValue = parseAttributeValue(watchString);
attrs.addAttribute(uri, localName, qName, "CDATA", attrValue);
return true;
@@ -216,14 +216,14 @@
* Name ::= (Letter | '_' | ':') (Letter | Digit | '.' | '_' | '-' | ':')*
*/
private String parseName() throws JasperException {
- char ch = (char)reader.peekChar();
+ char ch = (char) reader.peekChar();
if (Character.isLetter(ch) || ch == '_' || ch == ':') {
StringBuffer buf = new StringBuffer();
buf.append(ch);
reader.nextChar();
- ch = (char)reader.peekChar();
+ ch = (char) reader.peekChar();
while (Character.isLetter(ch) || Character.isDigit(ch) ||
- ch == '.' || ch == '_' || ch == '-' || ch == ':') {
+ ch == '.' || ch == '_' || ch == '-' || ch == ':') {
buf.append(ch);
reader.nextChar();
ch = (char) reader.peekChar();
@@ -235,9 +235,9 @@
/**
* AttributeValueDouble ::= (QuotedChar - '"')*
- * ('"' | <TRANSLATION_ERROR>)
+ * ('"' | <TRANSLATION_ERROR>)
* RTAttributeValueDouble ::= ((QuotedChar - '"')* - ((QuotedChar-'"')'%>"')
- * ('%>"' | TRANSLATION_ERROR)
+ * ('%>"' | TRANSLATION_ERROR)
*/
private String parseAttributeValue(String watch) throws JasperException {
Mark start = reader.mark();
@@ -258,13 +258,13 @@
/**
* QuotedChar ::= '''
- * | '"'
- * | '\\'
- * | '\"'
- * | "\'"
- * | '\>'
- * | '\$'
- * | Char
+ * | '"'
+ * | '\\'
+ * | '\"'
+ * | "\'"
+ * | '\>'
+ * | '\$'
+ * | Char
*/
private String parseQuoted(Mark start, String tx, char quote)
throws JasperException {
@@ -274,22 +274,22 @@
while (i < size) {
char ch = tx.charAt(i);
if (ch == '&') {
- if (i+5 < size && tx.charAt(i+1) == 'a'
- && tx.charAt(i+2) == 'p' && tx.charAt(i+3) == 'o'
- && tx.charAt(i+4) == 's' && tx.charAt(i+5) == ';') {
+ if (i + 5 < size && tx.charAt(i + 1) == 'a'
+ && tx.charAt(i + 2) == 'p' && tx.charAt(i + 3) == 'o'
+ && tx.charAt(i + 4) == 's' && tx.charAt(i + 5) == ';') {
buf.append('\'');
i += 6;
- } else if (i+5 < size && tx.charAt(i+1) == 'q'
- && tx.charAt(i+2) == 'u' && tx.charAt(i+3) == 'o'
- && tx.charAt(i+4) == 't' && tx.charAt(i+5) == ';') {
+ } else if (i + 5 < size && tx.charAt(i + 1) == 'q'
+ && tx.charAt(i + 2) == 'u' && tx.charAt(i + 3) == 'o'
+ && tx.charAt(i + 4) == 't' && tx.charAt(i + 5) == ';') {
buf.append('"');
i += 6;
} else {
buf.append(ch);
++i;
}
- } else if (ch == '\\' && i+1 < size) {
- ch = tx.charAt(i+1);
+ } else if (ch == '\\' && i + 1 < size) {
+ ch = tx.charAt(i + 1);
if (ch == '\\' || ch == '\"' || ch == '\'' || ch == '>') {
buf.append(ch);
i += 2;
@@ -319,8 +319,8 @@
int i = 0;
while (i < size) {
char ch = tx.charAt(i);
- if (i+2 < size && ch == '%' && tx.charAt(i+1) == '\\'
- && tx.charAt(i+2) == '>') {
+ if (i + 2 < size && ch == '%' && tx.charAt(i + 1) == '\\'
+ && tx.charAt(i + 2) == '>') {
cw.write('%');
cw.write('>');
i += 3;
@@ -336,8 +336,8 @@
/*
* Invokes parserController to parse the included page
*/
- private void processIncludeDirective(String file, Node parent)
- throws JasperException {
+ private void processIncludeDirective(String file, Node parent)
+ throws JasperException {
if (file == null) {
return;
}
@@ -388,7 +388,7 @@
* and include-coda of jsp-config element in web.xml
*/
private void addInclude(Node parent, List files) throws JasperException {
- if( files != null ) {
+ if (files != null) {
Iterator iter = files.iterator();
while (iter.hasNext()) {
String file = (String) iter.next();
@@ -396,8 +396,8 @@
attrs.addAttribute("", "file", "file", "CDATA", file);
// Create a dummy Include directive node
- Node includeNode = new Node.IncludeDirective(attrs,
- reader.mark(), parent);
+ Node includeNode = new Node.IncludeDirective(attrs,
+ reader.mark(), parent);
processIncludeDirective(file, includeNode);
}
}
@@ -416,31 +416,31 @@
Mark prevMark = pageInfo.getNonCustomTagPrefix(prefix);
if (prevMark != null) {
err.jspError(reader.mark(), "jsp.error.prefix.use_before_dcl",
- prefix, prevMark.getFile(), "" + prevMark.getLineNumber());
+ prefix, prevMark.getFile(), "" + prevMark.getLineNumber());
}
if (uri != null) {
String uriPrev = pageInfo.getURI(prefix);
if (uriPrev != null && !uriPrev.equals(uri)) {
err.jspError(reader.mark(), "jsp.error.prefix.refined",
- prefix, uri, uriPrev);
+ prefix, uri, uriPrev);
}
if (pageInfo.getTaglib(uri) == null) {
- TagLibraryInfoImpl impl = null;
- if (ctxt.getOptions().isCaching()) {
- impl = (TagLibraryInfoImpl) ctxt.getOptions().getCache().get(uri);
- }
- if (impl == null) {
- String[] location = ctxt.getTldLocation(uri);
- impl = new TagLibraryInfoImpl(ctxt,
- parserController,
- prefix,
- uri,
- location,
- err);
- if (ctxt.getOptions().isCaching()) {
- ctxt.getOptions().getCache().put(uri, impl);
- }
- }
+ TagLibraryInfoImpl impl = null;
+ if (ctxt.getOptions().isCaching()) {
+ impl = (TagLibraryInfoImpl) ctxt.getOptions().getCache().get(uri);
+ }
+ if (impl == null) {
+ String[] location = ctxt.getTldLocation(uri);
+ impl = new TagLibraryInfoImpl(ctxt,
+ parserController,
+ prefix,
+ uri,
+ location,
+ err);
+ if (ctxt.getOptions().isCaching()) {
+ ctxt.getOptions().getCache().put(uri, impl);
+ }
+ }
pageInfo.addTaglib(uri, impl);
}
pageInfo.addPrefixMapping(prefix, uri);
@@ -450,12 +450,12 @@
String urnTagdir = URN_JSPTAGDIR + tagdir;
if (pageInfo.getTaglib(urnTagdir) == null) {
pageInfo.addTaglib(urnTagdir,
- new ImplicitTagLibraryInfo(
- ctxt,
- parserController,
- prefix,
- tagdir,
- err));
+ new ImplicitTagLibraryInfo(
+ ctxt,
+ parserController,
+ prefix,
+ tagdir,
+ err));
}
pageInfo.addPrefixMapping(prefix, urnTagdir);
}
@@ -487,7 +487,7 @@
directive = "<%@ page";
if (isTagFile) {
err.jspError(reader.mark(), "jsp.error.directive.istagfile",
- directive);
+ directive);
}
parsePageDirective(parent);
} else if (reader.matches("include")) {
@@ -505,21 +505,21 @@
directive = "<%@ tag";
if (!isTagFile) {
err.jspError(reader.mark(), "jsp.error.directive.isnottagfile",
- directive);
+ directive);
}
parseTagDirective(parent);
} else if (reader.matches("attribute")) {
directive = "<%@ attribute";
if (!isTagFile) {
err.jspError(reader.mark(), "jsp.error.directive.isnottagfile",
- directive);
+ directive);
}
parseAttributeDirective(parent);
} else if (reader.matches("variable")) {
directive = "<%@ variable";
if (!isTagFile) {
err.jspError(reader.mark(), "jsp.error.directive.isnottagfile",
- directive);
+ directive);
}
parseVariableDirective(parent);
} else {
@@ -531,75 +531,74 @@
err.jspError(start, "jsp.error.unterminated", directive);
}
}
-
+
/*
- * Parses a directive with the following syntax:
- *
- * XMLJSPDirectiveBody ::= S? ( ( 'page' PageDirectiveAttrList
- * S? ( '/>' | ( '>' S? ETag ) )
- * | ( 'include' IncludeDirectiveAttrList
- * S? ( '/>' | ( '>' S? ETag ) )
- * | <TRANSLATION_ERROR>
- *
- * XMLTagDefDirectiveBody ::= ( ( 'tag' TagDirectiveAttrList
- * S? ( '/>' | ( '>' S? ETag ) )
- * | ( 'include' IncludeDirectiveAttrList
- * S? ( '/>' | ( '>' S? ETag ) )
- * | ( 'attribute' AttributeDirectiveAttrList
- * S? ( '/>' | ( '>' S? ETag ) )
- * | ( 'variable' VariableDirectiveAttrList
- * S? ( '/>' | ( '>' S? ETag ) )
- * )
- * | <TRANSLATION_ERROR>
- */
+ * Parses a directive with the following syntax:
+ *
+ * XMLJSPDirectiveBody ::= S? ( ( 'page' PageDirectiveAttrList
+ * S? ( '/>' | ( '>' S? ETag ) )
+ * | ( 'include' IncludeDirectiveAttrList
+ * S? ( '/>' | ( '>' S? ETag ) )
+ * | <TRANSLATION_ERROR>
+ *
+ * XMLTagDefDirectiveBody ::= ( ( 'tag' TagDirectiveAttrList
+ * S? ( '/>' | ( '>' S? ETag ) )
+ * | ( 'include' IncludeDirectiveAttrList
+ * S? ( '/>' | ( '>' S? ETag ) )
+ * | ( 'attribute' AttributeDirectiveAttrList
+ * S? ( '/>' | ( '>' S? ETag ) )
+ * | ( 'variable' VariableDirectiveAttrList
+ * S? ( '/>' | ( '>' S? ETag ) )
+ * )
+ * | <TRANSLATION_ERROR>
+ */
private void parseXMLDirective(Node parent) throws JasperException {
- reader.skipSpaces();
+ reader.skipSpaces();
String eTag = null;
- if (reader.matches("page")) {
+ if (reader.matches("page")) {
eTag = "jsp:directive.page";
- if (isTagFile) {
- err.jspError(reader.mark(), "jsp.error.directive.istagfile",
- "<" + eTag);
- }
- parsePageDirective(parent);
- } else if (reader.matches("include")) {
- eTag = "jsp:directive.include";
- parseIncludeDirective(parent);
- } else if (reader.matches("tag")) {
- eTag = "jsp:directive.tag";
- if (!isTagFile) {
- err.jspError(reader.mark(), "jsp.error.directive.isnottagfile",
- "<" + eTag);
- }
- parseTagDirective(parent);
- } else if (reader.matches("attribute")) {
- eTag = "jsp:directive.attribute";
- if (!isTagFile) {
- err.jspError(reader.mark(), "jsp.error.directive.isnottagfile",
- "<" + eTag);
- }
- parseAttributeDirective(parent);
- } else if (reader.matches("variable")) {
- eTag = "jsp:directive.variable";
- if (!isTagFile) {
- err.jspError(reader.mark(), "jsp.error.directive.isnottagfile",
- "<" + eTag);
- }
- parseVariableDirective(parent);
- } else {
- err.jspError(reader.mark(), "jsp.error.invalid.directive");
- }
-
- reader.skipSpaces();
- if( reader.matches( ">" ) ) {
- reader.skipSpaces();
- if( !reader.matchesETag( eTag ) ) {
- err.jspError(start, "jsp.error.unterminated", "<" + eTag );
+ if (isTagFile) {
+ err.jspError(reader.mark(), "jsp.error.directive.istagfile",
+ "<" + eTag);
}
+ parsePageDirective(parent);
+ } else if (reader.matches("include")) {
+ eTag = "jsp:directive.include";
+ parseIncludeDirective(parent);
+ } else if (reader.matches("tag")) {
+ eTag = "jsp:directive.tag";
+ if (!isTagFile) {
+ err.jspError(reader.mark(), "jsp.error.directive.isnottagfile",
+ "<" + eTag);
+ }
+ parseTagDirective(parent);
+ } else if (reader.matches("attribute")) {
+ eTag = "jsp:directive.attribute";
+ if (!isTagFile) {
+ err.jspError(reader.mark(), "jsp.error.directive.isnottagfile",
+ "<" + eTag);
+ }
+ parseAttributeDirective(parent);
+ } else if (reader.matches("variable")) {
+ eTag = "jsp:directive.variable";
+ if (!isTagFile) {
+ err.jspError(reader.mark(), "jsp.error.directive.isnottagfile",
+ "<" + eTag);
+ }
+ parseVariableDirective(parent);
+ } else {
+ err.jspError(reader.mark(), "jsp.error.invalid.directive");
}
- else if( !reader.matches( "/>" ) ) {
- err.jspError(start, "jsp.error.unterminated", "<" + eTag );
+
+ reader.skipSpaces();
+ if (reader.matches(">")) {
+ reader.skipSpaces();
+ if (!reader.matchesETag(eTag)) {
+ err.jspError(start, "jsp.error.unterminated", "<" + eTag);
+ }
+ } else if (!reader.matches("/>")) {
+ err.jspError(start, "jsp.error.unterminated", "<" + eTag);
}
}
@@ -646,7 +645,7 @@
/*
* JSPCommentBody ::= (Char* - (Char* '--%>')) '--%>'
*/
- private void parseComment(Node parent) throws JasperException {
+ private void parseComment(Node parent) throws JasperException {
start = reader.mark();
Mark stop = reader.skipUntil("--%>");
if (stop == null) {
@@ -667,7 +666,7 @@
}
new Node.Declaration(parseScriptText(reader.getText(start, stop)),
- start, parent);
+ start, parent);
}
/*
@@ -681,8 +680,8 @@
*/
private void parseXMLDeclaration(Node parent) throws JasperException {
reader.skipSpaces();
- if( !reader.matches( "/>" ) ) {
- if( !reader.matches( ">" ) ) {
+ if (!reader.matches("/>")) {
+ if (!reader.matches(">")) {
err.jspError(start, "jsp.error.unterminated",
"<jsp:declaration>");
}
@@ -693,7 +692,7 @@
stop = reader.skipUntil("<");
if (stop == null) {
err.jspError(start, "jsp.error.unterminated",
- "<jsp:declaration>");
+ "<jsp:declaration>");
}
text = parseScriptText(reader.getText(start, stop));
new Node.Declaration(text, start, parent);
@@ -705,13 +704,12 @@
}
text = parseScriptText(reader.getText(start, stop));
new Node.Declaration(text, start, parent);
- }
- else {
+ } else {
break;
}
}
-
- if (!reader.matchesETagWithoutLessThan( "jsp:declaration" ) ) {
+
+ if (!reader.matchesETagWithoutLessThan("jsp:declaration")) {
err.jspError(start, "jsp.error.unterminated",
"<jsp:declaration>");
}
@@ -729,7 +727,7 @@
}
new Node.Expression(parseScriptText(reader.getText(start, stop)),
- start, parent);
+ start, parent);
}
/*
@@ -739,10 +737,10 @@
*/
private void parseXMLExpression(Node parent) throws JasperException {
reader.skipSpaces();
- if( !reader.matches( "/>" ) ) {
- if( !reader.matches( ">" ) ) {
+ if (!reader.matches("/>")) {
+ if (!reader.matches(">")) {
err.jspError(start, "jsp.error.unterminated",
- "<jsp:expression>");
+ "<jsp:expression>");
}
Mark stop;
String text;
@@ -751,7 +749,7 @@
stop = reader.skipUntil("<");
if (stop == null) {
err.jspError(start, "jsp.error.unterminated",
- "<jsp:expression>");
+ "<jsp:expression>");
}
text = parseScriptText(reader.getText(start, stop));
new Node.Expression(text, start, parent);
@@ -763,14 +761,13 @@
}
text = parseScriptText(reader.getText(start, stop));
new Node.Expression(text, start, parent);
- }
- else {
+ } else {
break;
}
}
- if (!reader.matchesETagWithoutLessThan( "jsp:expression" )) {
+ if (!reader.matchesETagWithoutLessThan("jsp:expression")) {
err.jspError(start, "jsp.error.unterminated",
- "<jsp:expression>");
+ "<jsp:expression>");
}
}
}
@@ -817,7 +814,7 @@
}
new Node.Scriptlet(parseScriptText(reader.getText(start, stop)),
- start, parent);
+ start, parent);
}
/*
@@ -827,10 +824,10 @@
*/
private void parseXMLScriptlet(Node parent) throws JasperException {
reader.skipSpaces();
- if( !reader.matches( "/>" ) ) {
- if( !reader.matches( ">" ) ) {
+ if (!reader.matches("/>")) {
+ if (!reader.matches(">")) {
err.jspError(start, "jsp.error.unterminated",
- "<jsp:scriptlet>");
+ "<jsp:scriptlet>");
}
Mark stop;
String text;
@@ -839,7 +836,7 @@
stop = reader.skipUntil("<");
if (stop == null) {
err.jspError(start, "jsp.error.unterminated",
- "<jsp:scriptlet>");
+ "<jsp:scriptlet>");
}
text = parseScriptText(reader.getText(start, stop));
new Node.Scriptlet(text, start, parent);
@@ -851,19 +848,18 @@
}
text = parseScriptText(reader.getText(start, stop));
new Node.Scriptlet(text, start, parent);
- }
- else {
+ } else {
break;
}
}
- if (!reader.matchesETagWithoutLessThan( "jsp:scriptlet" )) {
+ if (!reader.matchesETagWithoutLessThan("jsp:scriptlet")) {
err.jspError(start, "jsp.error.unterminated",
- "<jsp:scriptlet>");
+ "<jsp:scriptlet>");
}
}
}
-
+
/**
* Param ::= '<jsp:param' S Attributes S? EmptyBody S?
*/
@@ -873,11 +869,11 @@
}
Attributes attrs = parseAttributes();
reader.skipSpaces();
-
- Node paramActionNode = new Node.ParamAction( attrs, start, parent );
-
- parseEmptyBody( paramActionNode, "jsp:param" );
-
+
+ Node paramActionNode = new Node.ParamAction(attrs, start, parent);
+
+ parseEmptyBody(paramActionNode, "jsp:param");
+
reader.skipSpaces();
}
@@ -903,10 +899,10 @@
Attributes attrs = parseAttributes();
reader.skipSpaces();
- Node includeNode = new Node.IncludeAction( attrs, start, parent );
-
- parseOptionalBody(includeNode, "jsp:include",
- JAVAX_BODY_CONTENT_PARAM);
+ Node includeNode = new Node.IncludeAction(attrs, start, parent);
+
+ parseOptionalBody(includeNode, "jsp:include",
+ JAVAX_BODY_CONTENT_PARAM);
}
/*
@@ -917,10 +913,10 @@
Attributes attrs = parseAttributes();
reader.skipSpaces();
- Node forwardNode = new Node.ForwardAction( attrs, start, parent );
-
+ Node forwardNode = new Node.ForwardAction(attrs, start, parent);
+
parseOptionalBody(forwardNode, "jsp:forward",
- JAVAX_BODY_CONTENT_PARAM);
+ JAVAX_BODY_CONTENT_PARAM);
}
private void parseInvoke(Node parent) throws JasperException {
@@ -928,7 +924,7 @@
reader.skipSpaces();
Node invokeNode = new Node.InvokeAction(attrs, start, parent);
-
+
parseEmptyBody(invokeNode, "jsp:invoke");
}
@@ -937,7 +933,7 @@
reader.skipSpaces();
Node doBodyNode = new Node.DoBodyAction(attrs, start, parent);
-
+
parseEmptyBody(doBodyNode, "jsp:doBody");
}
@@ -946,9 +942,9 @@
reader.skipSpaces();
Node elementNode = new Node.JspElement(attrs, start, parent);
-
- parseOptionalBody( elementNode, "jsp:element",
- TagInfo.BODY_CONTENT_JSP );
+
+ parseOptionalBody(elementNode, "jsp:element",
+ TagInfo.BODY_CONTENT_JSP);
}
/*
@@ -959,10 +955,10 @@
Attributes attrs = parseAttributes();
reader.skipSpaces();
- Node getPropertyNode = new Node.GetProperty( attrs, start, parent );
-
+ Node getPropertyNode = new Node.GetProperty(attrs, start, parent);
+
parseOptionalBody(getPropertyNode, "jsp:getProperty",
- TagInfo.BODY_CONTENT_EMPTY);
+ TagInfo.BODY_CONTENT_EMPTY);
}
/*
@@ -973,10 +969,10 @@
Attributes attrs = parseAttributes();
reader.skipSpaces();
- Node setPropertyNode = new Node.SetProperty( attrs, start, parent );
-
+ Node setPropertyNode = new Node.SetProperty(attrs, start, parent);
+
parseOptionalBody(setPropertyNode, "jsp:setProperty",
- TagInfo.BODY_CONTENT_EMPTY);
+ TagInfo.BODY_CONTENT_EMPTY);
}
/*
@@ -984,36 +980,30 @@
* | ( '>' ETag )
* | ( '>' S? '<jsp:attribute' NamedAttributes ETag )
*/
- private void parseEmptyBody( Node parent, String tag )
- throws JasperException
- {
- if( reader.matches("/>") ) {
+ private void parseEmptyBody(Node parent, String tag)
+ throws JasperException {
+ if (reader.matches("/>")) {
// Done
- }
- else if( reader.matches( ">" ) ) {
- if( reader.matchesETag( tag ) ) {
+ } else if (reader.matches(">")) {
+ if (reader.matchesETag(tag)) {
// Done
- }
- else if( reader.matchesOptionalSpacesFollowedBy(
- "<jsp:attribute" ) )
- {
+ } else if (reader.matchesOptionalSpacesFollowedBy(
+ "<jsp:attribute")) {
// Parse the one or more named attribute nodes
- parseNamedAttributes( parent );
- if( !reader.matchesETag( tag ) ) {
+ parseNamedAttributes(parent);
+ if (!reader.matchesETag(tag)) {
// Body not allowed
err.jspError(reader.mark(),
- "jsp.error.jspbody.emptybody.only",
- "<" + tag );
+ "jsp.error.jspbody.emptybody.only",
+ "<" + tag);
}
- }
- else {
+ } else {
err.jspError(reader.mark(), "jsp.error.jspbody.emptybody.only",
- "<" + tag );
+ "<" + tag);
}
- }
- else {
+ } else {
err.jspError(reader.mark(), "jsp.error.unterminated",
- "<" + tag );
+ "<" + tag);
}
}
@@ -1024,11 +1014,11 @@
private void parseUseBean(Node parent) throws JasperException {
Attributes attrs = parseAttributes();
reader.skipSpaces();
-
- Node useBeanNode = new Node.UseBean( attrs, start, parent );
-
- parseOptionalBody( useBeanNode, "jsp:useBean",
- TagInfo.BODY_CONTENT_JSP );
+
+ Node useBeanNode = new Node.UseBean(attrs, start, parent);
+
+ parseOptionalBody(useBeanNode, "jsp:useBean",
+ TagInfo.BODY_CONTENT_JSP);
}
/*
@@ -1057,9 +1047,8 @@
* | ( '>' TagDependentBody ETag )
*
*/
- private void parseOptionalBody( Node parent, String tag, String bodyType )
- throws JasperException
- {
+ private void parseOptionalBody(Node parent, String tag, String bodyType)
+ throws JasperException {
if (reader.matches("/>")) {
// EmptyBody
return;
@@ -1067,65 +1056,63 @@
if (!reader.matches(">")) {
err.jspError(reader.mark(), "jsp.error.unterminated",
- "<" + tag );
+ "<" + tag);
}
-
- if( reader.matchesETag( tag ) ) {
+
+ if (reader.matchesETag(tag)) {
// EmptyBody
return;
}
-
- if( !parseJspAttributeAndBody( parent, tag, bodyType ) ) {
+
+ if (!parseJspAttributeAndBody(parent, tag, bodyType)) {
// Must be ( '>' # Body ETag )
- parseBody(parent, tag, bodyType );
+ parseBody(parent, tag, bodyType);
}
}
-
+
/**
* Attempts to parse 'JspAttributeAndBody' production. Returns true if
* it matched, or false if not. Assumes EmptyBody is okay as well.
- *
+ * <p/>
* JspAttributeAndBody ::=
- * ( '>' # S? ( '<jsp:attribute' NamedAttributes )?
- * '<jsp:body'
- * ( JspBodyBody | <TRANSLATION_ERROR> )
- * S? ETag
- * )
+ * ( '>' # S? ( '<jsp:attribute' NamedAttributes )?
+ * '<jsp:body'
+ * ( JspBodyBody | <TRANSLATION_ERROR> )
+ * S? ETag
+ * )
*/
- private boolean parseJspAttributeAndBody( Node parent, String tag,
- String bodyType )
- throws JasperException
- {
+ private boolean parseJspAttributeAndBody(Node parent, String tag,
+ String bodyType)
+ throws JasperException {
boolean result = false;
-
- if( reader.matchesOptionalSpacesFollowedBy( "<jsp:attribute" ) ) {
+
+ if (reader.matchesOptionalSpacesFollowedBy("<jsp:attribute")) {
// May be an EmptyBody, depending on whether
// There's a "<jsp:body" before the ETag
-
+
// First, parse <jsp:attribute> elements:
- parseNamedAttributes( parent );
-
+ parseNamedAttributes(parent);
+
result = true;
}
-
- if( reader.matchesOptionalSpacesFollowedBy( "<jsp:body" ) ) {
+
+ if (reader.matchesOptionalSpacesFollowedBy("<jsp:body")) {
// ActionBody
- parseJspBody( parent, bodyType );
+ parseJspBody(parent, bodyType);
reader.skipSpaces();
- if( !reader.matchesETag( tag ) ) {
- err.jspError(reader.mark(), "jsp.error.unterminated",
- "<" + tag );
+ if (!reader.matchesETag(tag)) {
+ err.jspError(reader.mark(), "jsp.error.unterminated",
+ "<" + tag);
}
-
+
result = true;
- }
- else if( result && !reader.matchesETag( tag ) ) {
+ } else if (result && !reader.matchesETag(tag)) {
// If we have <jsp:attribute> but something other than
// <jsp:body> or the end tag, translation error.
- err.jspError(reader.mark(), "jsp.error.jspbody.required",
- "<" + tag );
+ err.jspError(reader.mark(), "jsp.error.jspbody.required",
+ "<" + tag);
}
-
+
return result;
}
@@ -1143,7 +1130,7 @@
private void parseJspParams(Node parent) throws JasperException {
Node jspParamsNode = new Node.ParamsAction(start, parent);
parseOptionalBody(jspParamsNode, "jsp:params",
- JAVAX_BODY_CONTENT_PARAM );
+ JAVAX_BODY_CONTENT_PARAM);
}
/*
@@ -1164,8 +1151,8 @@
*/
private void parseFallBack(Node parent) throws JasperException {
Node fallBackNode = new Node.FallBackAction(start, parent);
- parseOptionalBody(fallBackNode, "jsp:fallback",
- JAVAX_BODY_CONTENT_TEMPLATE_TEXT);
+ parseOptionalBody(fallBackNode, "jsp:fallback",
+ JAVAX_BODY_CONTENT_TEMPLATE_TEXT);
}
/*
@@ -1188,42 +1175,42 @@
private void parsePlugin(Node parent) throws JasperException {
Attributes attrs = parseAttributes();
reader.skipSpaces();
-
+
Node pluginNode = new Node.PlugIn(attrs, start, parent);
-
- parseOptionalBody( pluginNode, "jsp:plugin",
- JAVAX_BODY_CONTENT_PLUGIN );
+
+ parseOptionalBody(pluginNode, "jsp:plugin",
+ JAVAX_BODY_CONTENT_PLUGIN);
}
/*
* PluginTags ::= ( '<jsp:params' Params S? )?
* ( '<jsp:fallback' Fallback? S? )?
*/
- private void parsePluginTags( Node parent ) throws JasperException {
+ private void parsePluginTags(Node parent) throws JasperException {
reader.skipSpaces();
-
- if( reader.matches( "<jsp:params" ) ) {
- parseJspParams( parent );
+
+ if (reader.matches("<jsp:params")) {
+ parseJspParams(parent);
reader.skipSpaces();
}
-
- if( reader.matches( "<jsp:fallback" ) ) {
- parseFallBack( parent );
+
+ if (reader.matches("<jsp:fallback")) {
+ parseFallBack(parent);
reader.skipSpaces();
}
}
-
+
/*
- * StandardAction ::= 'include' StdActionContent
- * | 'forward' StdActionContent
- * | 'invoke' StdActionContent
- * | 'doBody' StdActionContent
- * | 'getProperty' StdActionContent
- * | 'setProperty' StdActionContent
- * | 'useBean' StdActionContent
- * | 'plugin' StdActionContent
- * | 'element' StdActionContent
- */
+ * StandardAction ::= 'include' StdActionContent
+ * | 'forward' StdActionContent
+ * | 'invoke' StdActionContent
+ * | 'doBody' StdActionContent
+ * | 'getProperty' StdActionContent
+ * | 'setProperty' StdActionContent
+ * | 'useBean' StdActionContent
+ * | 'plugin' StdActionContent
+ * | 'element' StdActionContent
+ */
private void parseStandardAction(Node parent) throws JasperException {
Mark start = reader.mark();
@@ -1234,13 +1221,13 @@
} else if (reader.matches(INVOKE_ACTION)) {
if (!isTagFile) {
err.jspError(reader.mark(), "jsp.error.action.isnottagfile",
- "<jsp:invoke");
+ "<jsp:invoke");
}
parseInvoke(parent);
} else if (reader.matches(DOBODY_ACTION)) {
if (!isTagFile) {
err.jspError(reader.mark(), "jsp.error.action.isnottagfile",
- "<jsp:doBody");
+ "<jsp:doBody");
}
parseDoBody(parent);
} else if (reader.matches(GET_PROPERTY_ACTION)) {
@@ -1310,7 +1297,7 @@
}
String prefix = tagName.substring(0, i);
- String shortTagName = tagName.substring(i+1);
+ String shortTagName = tagName.substring(i + 1);
// Check if this is a user-defined tag.
String uri = pageInfo.getURI(prefix);
@@ -1334,10 +1321,10 @@
String handlerClassName = tagInfo.getTagClassName();
try {
tagHandlerClass =
- ctxt.getClassLoader().loadClass(handlerClassName);
+ ctxt.getClassLoader().loadClass(handlerClassName);
} catch (Exception e) {
err.jspError(start, "jsp.error.loadclass.taghandler",
- handlerClassName, tagName);
+ handlerClassName, tagName);
}
}
@@ -1348,19 +1335,19 @@
// Parse 'Attributes' production:
Attributes attrs = parseAttributes();
reader.skipSpaces();
-
+
// Parse 'CustomActionEnd' production:
if (reader.matches("/>")) {
if (tagInfo != null) {
new Node.CustomTag(tagName, prefix, shortTagName, uri, attrs,
- start, parent, tagInfo, tagHandlerClass);
+ start, parent, tagInfo, tagHandlerClass);
} else {
new Node.CustomTag(tagName, prefix, shortTagName, uri, attrs,
- start, parent, tagFileInfo);
+ start, parent, tagFileInfo);
}
return true;
}
-
+
// Now we parse one of 'CustomActionTagDependent',
// 'CustomActionJSPContent', or 'CustomActionScriptlessContent'.
// depending on body-content in TLD.
@@ -1378,14 +1365,14 @@
Node tagNode = null;
if (tagInfo != null) {
tagNode = new Node.CustomTag(tagName, prefix, shortTagName, uri,
- attrs, start, parent, tagInfo,
- tagHandlerClass);
+ attrs, start, parent, tagInfo,
+ tagHandlerClass);
} else {
tagNode = new Node.CustomTag(tagName, prefix, shortTagName, uri,
- attrs, start, parent, tagFileInfo);
+ attrs, start, parent, tagFileInfo);
}
- parseOptionalBody( tagNode, tagName, bc );
+ parseOptionalBody(tagNode, tagName, bc);
return true;
}
@@ -1413,8 +1400,7 @@
if (ch == '<') {
reader.pushChar();
break;
- }
- else if( ch == '$' ) {
+ } else if (ch == '$') {
if (!reader.hasMoreInput()) {
ttext.write('$');
break;
@@ -1428,8 +1414,7 @@
ttext.write('$');
reader.pushChar();
continue;
- }
- else if (ch == '\\') {
+ } else if (ch == '\\') {
if (!reader.hasMoreInput()) {
ttext.write('\\');
break;
@@ -1437,10 +1422,10 @@
// Look for \% or \$
// Only recognize \$ if isELIgnored is false, but since it can
// be set in a page directive, it cannot be determined yet.
- char next = (char)reader.peekChar();
+ char next = (char) reader.peekChar();
if (next == '%') {
ch = reader.nextChar();
- } else if(next == '$') {
+ } else if (next == '$') {
// Skip the $ and use a hack to flag this sequence
reader.nextChar();
ch = Constants.HACK_CHAR;
@@ -1450,28 +1435,28 @@
}
new Node.TemplateText(ttext.toString(), start, parent);
}
-
+
/*
- * XMLTemplateText ::= ( S? '/>' )
- * | ( S? '>'
- * ( ( Char* - ( Char* ( '<' | '${' ) ) )
- * ( '${' ELExpressionBody )?
- * CDSect?
- * )* ETag
- * )
- * | <TRANSLATION_ERROR>
- */
+ * XMLTemplateText ::= ( S? '/>' )
+ * | ( S? '>'
+ * ( ( Char* - ( Char* ( '<' | '${' ) ) )
+ * ( '${' ELExpressionBody )?
+ * CDSect?
+ * )* ETag
+ * )
+ * | <TRANSLATION_ERROR>
+ */
private void parseXMLTemplateText(Node parent) throws JasperException {
reader.skipSpaces();
- if( !reader.matches( "/>" ) ) {
- if( !reader.matches( ">" ) ) {
+ if (!reader.matches("/>")) {
+ if (!reader.matches(">")) {
err.jspError(start, "jsp.error.unterminated",
- "<jsp:text>" );
+ "<jsp:text>");
}
CharArrayWriter ttext = new CharArrayWriter();
while (reader.hasMoreInput()) {
int ch = reader.nextChar();
- if( ch == '<' ) {
+ if (ch == '<') {
// Check for <![CDATA[
if (!reader.matches("![CDATA[")) {
break;
@@ -1483,19 +1468,17 @@
}
String text = reader.getText(start, stop);
ttext.write(text, 0, text.length());
- }
- else if( ch == '\\') {
+ } else if (ch == '\\') {
if (!reader.hasMoreInput()) {
ttext.write('\\');
break;
}
ch = reader.nextChar();
- if (ch != '$' ) {
+ if (ch != '$') {
ttext.write('\\');
}
ttext.write(ch);
- }
- else if( ch == '$' ) {
+ } else if (ch == '$') {
if (!reader.hasMoreInput()) {
ttext.write('$');
break;
@@ -1507,7 +1490,7 @@
continue;
}
// Create a template text node
- new Node.TemplateText( ttext.toString(), start, parent);
+ new Node.TemplateText(ttext.toString(), start, parent);
// Mark and parse the EL expression and create its node:
start = reader.mark();
@@ -1515,19 +1498,18 @@
start = reader.mark();
ttext = new CharArrayWriter();
- }
- else {
- ttext.write( ch );
+ } else {
+ ttext.write(ch);
}
}
- new Node.TemplateText( ttext.toString(), start, parent );
+ new Node.TemplateText(ttext.toString(), start, parent);
- if (! reader.hasMoreInput()) {
- err.jspError( start, "jsp.error.unterminated",
- "<jsp:text>" );
- } else if( !reader.matchesETagWithoutLessThan( "jsp:text" ) ) {
- err.jspError( start, "jsp.error.jsptext.badcontent");
+ if (!reader.hasMoreInput()) {
+ err.jspError(start, "jsp.error.unterminated",
+ "<jsp:text>");
+ } else if (!reader.matchesETagWithoutLessThan("jsp:text")) {
+ err.jspError(start, "jsp.error.jsptext.badcontent");
}
}
}
@@ -1549,17 +1531,16 @@
* CustomActionBody )
* | TemplateText
*/
- private void parseElements(Node parent)
- throws JasperException
- {
- if( scriptlessCount > 0 ) {
+ private void parseElements(Node parent)
+ throws JasperException {
+ if (scriptlessCount > 0) {
// vc: ScriptlessBody
// We must follow the ScriptlessBody production if one of
// our parents is ScriptlessBody.
- parseElementsScriptless( parent );
+ parseElementsScriptless(parent);
return;
}
-
+
start = reader.mark();
if (reader.matches("<%--")) {
parseComment(parent);
@@ -1608,13 +1589,12 @@
* CustomActionBody )
* | TemplateText
*/
- private void parseElementsScriptless(Node parent)
- throws JasperException
- {
+ private void parseElementsScriptless(Node parent)
+ throws JasperException {
// Keep track of how many scriptless nodes we've encountered
// so we know whether our child nodes are forced scriptless
scriptlessCount++;
-
+
start = reader.mark();
if (reader.matches("<%--")) {
parseComment(parent);
@@ -1623,17 +1603,17 @@
} else if (reader.matches("<jsp:directive.")) {
parseXMLDirective(parent);
} else if (reader.matches("<%!")) {
- err.jspError( reader.mark(), "jsp.error.no.scriptlets" );
+ err.jspError(reader.mark(), "jsp.error.no.scriptlets");
} else if (reader.matches("<jsp:declaration")) {
- err.jspError( reader.mark(), "jsp.error.no.scriptlets" );
+ err.jspError(reader.mark(), "jsp.error.no.scriptlets");
} else if (reader.matches("<%=")) {
- err.jspError( reader.mark(), "jsp.error.no.scriptlets" );
+ err.jspError(reader.mark(), "jsp.error.no.scriptlets");
} else if (reader.matches("<jsp:expression")) {
- err.jspError( reader.mark(), "jsp.error.no.scriptlets" );
+ err.jspError(reader.mark(), "jsp.error.no.scriptlets");
} else if (reader.matches("<%")) {
- err.jspError( reader.mark(), "jsp.error.no.scriptlets" );
+ err.jspError(reader.mark(), "jsp.error.no.scriptlets");
} else if (reader.matches("<jsp:scriptlet")) {
- err.jspError( reader.mark(), "jsp.error.no.scriptlets" );
+ err.jspError(reader.mark(), "jsp.error.no.scriptlets");
} else if (reader.matches("<jsp:text")) {
parseXMLTemplateText(parent);
} else if (reader.matches("${")) {
@@ -1644,28 +1624,27 @@
checkUnbalancedEndTag();
parseTemplateText(parent);
}
-
+
scriptlessCount--;
}
-
+
/*
- * TemplateTextBody ::= ( '<%--' JSPCommentBody )
- * | ( '<%@' DirectiveBody )
- * | ( '<jsp:directive.' XMLDirectiveBody )
- * | ( '<%!' <TRANSLATION_ERROR> )
- * | ( '<jsp:declaration' <TRANSLATION_ERROR> )
- * | ( '<%=' <TRANSLATION_ERROR> )
- * | ( '<jsp:expression' <TRANSLATION_ERROR> )
- * | ( '<%' <TRANSLATION_ERROR> )
- * | ( '<jsp:scriptlet' <TRANSLATION_ERROR> )
- * | ( '<jsp:text' <TRANSLATION_ERROR> )
- * | ( '${' <TRANSLATION_ERROR> )
- * | ( '<jsp:' <TRANSLATION_ERROR> )
- * | TemplateText
- */
+ * TemplateTextBody ::= ( '<%--' JSPCommentBody )
+ * | ( '<%@' DirectiveBody )
+ * | ( '<jsp:directive.' XMLDirectiveBody )
+ * | ( '<%!' <TRANSLATION_ERROR> )
+ * | ( '<jsp:declaration' <TRANSLATION_ERROR> )
+ * | ( '<%=' <TRANSLATION_ERROR> )
+ * | ( '<jsp:expression' <TRANSLATION_ERROR> )
+ * | ( '<%' <TRANSLATION_ERROR> )
+ * | ( '<jsp:scriptlet' <TRANSLATION_ERROR> )
+ * | ( '<jsp:text' <TRANSLATION_ERROR> )
+ * | ( '${' <TRANSLATION_ERROR> )
+ * | ( '<jsp:' <TRANSLATION_ERROR> )
+ * | TemplateText
+ */
private void parseElementsTemplateText(Node parent)
- throws JasperException
- {
+ throws JasperException {
start = reader.mark();
if (reader.matches("<%--")) {
parseComment(parent);
@@ -1674,35 +1653,35 @@
} else if (reader.matches("<jsp:directive.")) {
parseXMLDirective(parent);
} else if (reader.matches("<%!")) {
- err.jspError( reader.mark(), "jsp.error.not.in.template",
- "Declarations" );
+ err.jspError(reader.mark(), "jsp.error.not.in.template",
+ "Declarations");
} else if (reader.matches("<jsp:declaration")) {
- err.jspError( reader.mark(), "jsp.error.not.in.template",
- "Declarations" );
+ err.jspError(reader.mark(), "jsp.error.not.in.template",
+ "Declarations");
} else if (reader.matches("<%=")) {
- err.jspError( reader.mark(), "jsp.error.not.in.template",
- "Expressions" );
+ err.jspError(reader.mark(), "jsp.error.not.in.template",
+ "Expressions");
} else if (reader.matches("<jsp:expression")) {
- err.jspError( reader.mark(), "jsp.error.not.in.template",
- "Expressions" );
+ err.jspError(reader.mark(), "jsp.error.not.in.template",
+ "Expressions");
} else if (reader.matches("<%")) {
- err.jspError( reader.mark(), "jsp.error.not.in.template",
- "Scriptlets" );
+ err.jspError(reader.mark(), "jsp.error.not.in.template",
+ "Scriptlets");
} else if (reader.matches("<jsp:scriptlet")) {
- err.jspError( reader.mark(), "jsp.error.not.in.template",
- "Scriptlets" );
+ err.jspError(reader.mark(), "jsp.error.not.in.template",
+ "Scriptlets");
} else if (reader.matches("<jsp:text")) {
- err.jspError( reader.mark(), "jsp.error.not.in.template",
- "<jsp:text" );
+ err.jspError(reader.mark(), "jsp.error.not.in.template",
+ "<jsp:text");
} else if (reader.matches("${")) {
- err.jspError( reader.mark(), "jsp.error.not.in.template",
- "Expression language" );
+ err.jspError(reader.mark(), "jsp.error.not.in.template",
+ "Expression language");
} else if (reader.matches("<jsp:")) {
- err.jspError( reader.mark(), "jsp.error.not.in.template",
- "Standard actions" );
+ err.jspError(reader.mark(), "jsp.error.not.in.template",
+ "Standard actions");
} else if (parseCustomTag(parent)) {
- err.jspError( reader.mark(), "jsp.error.not.in.template",
- "Custom actions" );
+ err.jspError(reader.mark(), "jsp.error.not.in.template",
+ "Custom actions");
} else {
checkUnbalancedEndTag();
parseTemplateText(parent);
@@ -1735,25 +1714,24 @@
}
/**
- * TagDependentBody :=
+ * TagDependentBody :=
*/
private void parseTagDependentBody(Node parent, String tag)
- throws JasperException{
+ throws JasperException {
Mark bodyStart = reader.mark();
Mark bodyEnd = reader.skipUntilETag(tag);
if (bodyEnd == null) {
- err.jspError(start, "jsp.error.unterminated", "<"+tag );
+ err.jspError(start, "jsp.error.unterminated", "<" + tag);
}
new Node.TemplateText(reader.getText(bodyStart, bodyEnd), bodyStart,
- parent);
+ parent);
}
/*
* Parses jsp:body action.
*/
- private void parseJspBody(Node parent, String bodyType)
- throws JasperException
- {
+ private void parseJspBody(Node parent, String bodyType)
+ throws JasperException {
Mark start = reader.mark();
Node bodyNode = new Node.JspBody(start, parent);
@@ -1761,9 +1739,9 @@
if (!reader.matches("/>")) {
if (!reader.matches(">")) {
err.jspError(start, "jsp.error.unterminated",
- "<jsp:body");
+ "<jsp:body");
}
- parseBody( bodyNode, "jsp:body", bodyType );
+ parseBody(bodyNode, "jsp:body", bodyType);
}
}
@@ -1772,68 +1750,57 @@
* @param tag The name of the tag whose end tag would terminate the body
* @param bodyType One of the TagInfo body types
*/
- private void parseBody(Node parent, String tag, String bodyType)
- throws JasperException
- {
- if( bodyType.equalsIgnoreCase( TagInfo.BODY_CONTENT_TAG_DEPENDENT ) ) {
- parseTagDependentBody( parent, tag );
- }
- else if( bodyType.equalsIgnoreCase( TagInfo.BODY_CONTENT_EMPTY ) ) {
- if( !reader.matchesETag( tag ) ) {
+ private void parseBody(Node parent, String tag, String bodyType)
+ throws JasperException {
+ if (bodyType.equalsIgnoreCase(TagInfo.BODY_CONTENT_TAG_DEPENDENT)) {
+ parseTagDependentBody(parent, tag);
+ } else if (bodyType.equalsIgnoreCase(TagInfo.BODY_CONTENT_EMPTY)) {
+ if (!reader.matchesETag(tag)) {
err.jspError(start, "jasper.error.emptybodycontent.nonempty",
- tag);
+ tag);
}
- }
- else if( bodyType == JAVAX_BODY_CONTENT_PLUGIN ) {
+ } else if (bodyType == JAVAX_BODY_CONTENT_PLUGIN) {
// (note the == since we won't recognize JAVAX_*
// from outside this module).
parsePluginTags(parent);
- if( !reader.matchesETag( tag ) ) {
- err.jspError( reader.mark(), "jsp.error.unterminated",
- "<" + tag );
+ if (!reader.matchesETag(tag)) {
+ err.jspError(reader.mark(), "jsp.error.unterminated",
+ "<" + tag);
}
- }
- else if( bodyType.equalsIgnoreCase( TagInfo.BODY_CONTENT_JSP ) ||
- bodyType.equalsIgnoreCase( TagInfo.BODY_CONTENT_SCRIPTLESS ) ||
- (bodyType == JAVAX_BODY_CONTENT_PARAM) ||
- (bodyType == JAVAX_BODY_CONTENT_TEMPLATE_TEXT) )
- {
+ } else if (bodyType.equalsIgnoreCase(TagInfo.BODY_CONTENT_JSP) ||
+ bodyType.equalsIgnoreCase(TagInfo.BODY_CONTENT_SCRIPTLESS) ||
+ (bodyType == JAVAX_BODY_CONTENT_PARAM) ||
+ (bodyType == JAVAX_BODY_CONTENT_TEMPLATE_TEXT)) {
while (reader.hasMoreInput()) {
if (reader.matchesETag(tag)) {
return;
}
-
+
// Check for nested jsp:body or jsp:attribute
if (tag.equals("jsp:body") || tag.equals("jsp:attribute")) {
if (reader.matches("<jsp:attribute")) {
err.jspError(reader.mark(), "jsp.error.nested.jspattribute");
- }
- else if (reader.matches("<jsp:body")) {
+ } else if (reader.matches("<jsp:body")) {
err.jspError(reader.mark(), "jsp.error.nested.jspbody");
}
}
- if( bodyType.equalsIgnoreCase( TagInfo.BODY_CONTENT_JSP ) ) {
- parseElements( parent );
- }
- else if( bodyType.equalsIgnoreCase(
- TagInfo.BODY_CONTENT_SCRIPTLESS ) )
- {
- parseElementsScriptless( parent );
- }
- else if( bodyType == JAVAX_BODY_CONTENT_PARAM ) {
+ if (bodyType.equalsIgnoreCase(TagInfo.BODY_CONTENT_JSP)) {
+ parseElements(parent);
+ } else if (bodyType.equalsIgnoreCase(
+ TagInfo.BODY_CONTENT_SCRIPTLESS)) {
+ parseElementsScriptless(parent);
+ } else if (bodyType == JAVAX_BODY_CONTENT_PARAM) {
// (note the == since we won't recognize JAVAX_*
// from outside this module).
reader.skipSpaces();
- parseParam( parent );
- }
- else if (bodyType == JAVAX_BODY_CONTENT_TEMPLATE_TEXT) {
+ parseParam(parent);
+ } else if (bodyType == JAVAX_BODY_CONTENT_TEMPLATE_TEXT) {
parseElementsTemplateText(parent);
}
}
- err.jspError(start, "jsp.error.unterminated", "<"+tag );
- }
- else {
+ err.jspError(start, "jsp.error.unterminated", "<" + tag);
+ } else {
err.jspError(start, "jasper.error.bad.bodycontent.type");
}
}
@@ -1846,32 +1813,32 @@
Mark start = reader.mark();
Attributes attrs = parseAttributes();
Node.NamedAttribute namedAttributeNode =
- new Node.NamedAttribute( attrs, start, parent );
+ new Node.NamedAttribute(attrs, start, parent);
reader.skipSpaces();
if (!reader.matches("/>")) {
if (!reader.matches(">")) {
err.jspError(start, "jsp.error.unterminated",
- "<jsp:attribute");
+ "<jsp:attribute");
}
if (namedAttributeNode.isTrim()) {
reader.skipSpaces();
}
- parseBody(namedAttributeNode, "jsp:attribute",
- getAttributeBodyType(parent,
- attrs.getValue("name")));
+ parseBody(namedAttributeNode, "jsp:attribute",
+ getAttributeBodyType(parent,
+ attrs.getValue("name")));
if (namedAttributeNode.isTrim()) {
Node.Nodes subElems = namedAttributeNode.getBody();
if (subElems != null) {
Node lastNode = subElems.getNode(subElems.size() - 1);
if (lastNode instanceof Node.TemplateText) {
- ((Node.TemplateText)lastNode).rtrim();
+ ((Node.TemplateText) lastNode).rtrim();
}
}
}
}
reader.skipSpaces();
- } while( reader.matches( "<jsp:attribute" ) );
+ } while (reader.matches("<jsp:attribute"));
}
/**
@@ -1880,9 +1847,9 @@
private String getAttributeBodyType(Node n, String name) {
if (n instanceof Node.CustomTag) {
- TagInfo tagInfo = ((Node.CustomTag)n).getTagInfo();
+ TagInfo tagInfo = ((Node.CustomTag) n).getTagInfo();
TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
- for (int i=0; i<tldAttrs.length; i++) {
+ for (int i = 0; i < tldAttrs.length; i++) {
if (name.equals(tldAttrs[i].getName())) {
if (tldAttrs[i].isFragment()) {
return TagInfo.BODY_CONTENT_SCRIPTLESS;
@@ -1927,8 +1894,7 @@
}
private void parseTagFileDirectives(Node parent)
- throws JasperException
- {
+ throws JasperException {
reader.setSingleFile(true);
reader.skipUntil("<");
while (reader.hasMoreInput()) {
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ParserController.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ParserController.java
index ec7de07..231b110 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ParserController.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ParserController.java
@@ -32,7 +32,7 @@
/**
* Controller for the parsing of a JSP page.
- * <p>
+ * <p/>
* The same ParserController instance is used for a JSP page and any JSP
* segments included by it (via an include directive), where each segment may
* be provided in standard or XML syntax. This class selects and invokes the
@@ -59,7 +59,7 @@
* for include directives that refer to relative paths.
*/
private Stack baseDirStack = new Stack();
-
+
private boolean isEncodingSpecifiedInProlog;
private String sourceEnc;
@@ -72,17 +72,17 @@
* Constructor
*/
public ParserController(JspCompilationContext ctxt, Compiler compiler) {
- this.ctxt = ctxt;
- this.compiler = compiler;
- this.err = compiler.getErrorDispatcher();
+ this.ctxt = ctxt;
+ this.compiler = compiler;
+ this.err = compiler.getErrorDispatcher();
}
- public JspCompilationContext getJspCompilationContext () {
- return ctxt;
+ public JspCompilationContext getJspCompilationContext() {
+ return ctxt;
}
- public Compiler getCompiler () {
- return compiler;
+ public Compiler getCompiler() {
+ return compiler;
}
/**
@@ -91,11 +91,11 @@
* @param inFileName The path to the JSP page or tag file to be parsed.
*/
public Node.Nodes parse(String inFileName)
- throws FileNotFoundException, JasperException, IOException {
- // If we're parsing a packaged tag file or a resource included by it
- // (using an include directive), ctxt.getTagFileJar() returns the
- // JAR file from which to read the tag file or included resource,
- // respectively.
+ throws FileNotFoundException, JasperException, IOException {
+ // If we're parsing a packaged tag file or a resource included by it
+ // (using an include directive), ctxt.getTagFileJar() returns the
+ // JAR file from which to read the tag file or included resource,
+ // respectively.
isTagFile = ctxt.isTagFile();
directiveOnly = false;
return doParse(inFileName, null, ctxt.getTagFileJarUrl());
@@ -105,13 +105,13 @@
* Processes an include directive with the given path.
*
* @param inFileName The path to the resource to be included.
- * @param parent The parent node of the include directive.
- * @param jarFile The JAR file from which to read the included resource,
- * or null of the included resource is to be read from the filesystem
+ * @param parent The parent node of the include directive.
+ * @param jarFile The JAR file from which to read the included resource,
+ * or null of the included resource is to be read from the filesystem
*/
public Node.Nodes parse(String inFileName, Node parent,
- URL jarFileUrl)
- throws FileNotFoundException, JasperException, IOException {
+ URL jarFileUrl)
+ throws FileNotFoundException, JasperException, IOException {
// For files that are statically included, isTagfile and directiveOnly
// remain unchanged.
return doParse(inFileName, parent, jarFileUrl);
@@ -120,19 +120,19 @@
/**
* Extracts tag file directive information from the tag file with the
* given name.
- *
- * This is invoked by the compiler
+ * <p/>
+ * This is invoked by the compiler
*
* @param inFileName The name of the tag file to be parsed.
*/
public Node.Nodes parseTagFileDirectives(String inFileName)
- throws FileNotFoundException, JasperException, IOException {
+ throws FileNotFoundException, JasperException, IOException {
boolean isTagFileSave = isTagFile;
boolean directiveOnlySave = directiveOnly;
isTagFile = true;
directiveOnly = true;
Node.Nodes page = doParse(inFileName, null,
- (URL) ctxt.getTagFileJarUrls().get(inFileName));
+ (URL) ctxt.getTagFileJarUrls().get(inFileName));
directiveOnly = directiveOnlySave;
isTagFile = isTagFileSave;
return page;
@@ -141,97 +141,98 @@
/**
* Parses the JSP page or tag file with the given path name.
*
- * @param inFileName The name of the JSP page or tag file to be parsed.
- * @param parent The parent node (non-null when processing an include
- * directive)
- * @param isTagFile true if file to be parsed is tag file, and false if it
- * is a regular JSP page
+ * @param inFileName The name of the JSP page or tag file to be parsed.
+ * @param parent The parent node (non-null when processing an include
+ * directive)
+ * @param isTagFile true if file to be parsed is tag file, and false if it
+ * is a regular JSP page
* @param directivesOnly true if the file to be parsed is a tag file and
- * we are only interested in the directives needed for constructing a
- * TagFileInfo.
- * @param jarFile The JAR file from which to read the JSP page or tag file,
- * or null if the JSP page or tag file is to be read from the filesystem
+ * we are only interested in the directives needed for constructing a
+ * TagFileInfo.
+ * @param jarFile The JAR file from which to read the JSP page or tag file,
+ * or null if the JSP page or tag file is to be read from the filesystem
*/
private Node.Nodes doParse(String inFileName,
Node parent,
URL jarFileUrl)
- throws FileNotFoundException, JasperException, IOException {
+ throws FileNotFoundException, JasperException, IOException {
- Node.Nodes parsedPage = null;
- isEncodingSpecifiedInProlog = false;
- isDefaultPageEncoding = false;
+ Node.Nodes parsedPage = null;
+ isEncodingSpecifiedInProlog = false;
+ isDefaultPageEncoding = false;
- JarFile jarFile = getJarFile(jarFileUrl);
- String absFileName = resolveFileName(inFileName);
- String jspConfigPageEnc = getJspConfigPageEncoding(absFileName);
+ JarFile jarFile = getJarFile(jarFileUrl);
+ String absFileName = resolveFileName(inFileName);
+ String jspConfigPageEnc = getJspConfigPageEncoding(absFileName);
- // Figure out what type of JSP document and encoding type we are
- // dealing with
- determineSyntaxAndEncoding(absFileName, jarFile, jspConfigPageEnc);
+ // Figure out what type of JSP document and encoding type we are
+ // dealing with
+ determineSyntaxAndEncoding(absFileName, jarFile, jspConfigPageEnc);
- if (parent != null) {
- // Included resource, add to dependent list
- compiler.getPageInfo().addDependant(absFileName);
- }
+ if (parent != null) {
+ // Included resource, add to dependent list
+ compiler.getPageInfo().addDependant(absFileName);
+ }
- if (isXml && isEncodingSpecifiedInProlog) {
- /*
- * Make sure the encoding explicitly specified in the XML
- * prolog (if any) matches that in the JSP config element
- * (if any), treating "UTF-16", "UTF-16BE", and "UTF-16LE" as
- * identical.
- */
- if (jspConfigPageEnc != null && !jspConfigPageEnc.equals(sourceEnc)
- && (!jspConfigPageEnc.startsWith("UTF-16")
- || !sourceEnc.startsWith("UTF-16"))) {
- err.jspError("jsp.error.prolog_config_encoding_mismatch",
- sourceEnc, jspConfigPageEnc);
- }
- }
+ if (isXml && isEncodingSpecifiedInProlog) {
+ /*
+ * Make sure the encoding explicitly specified in the XML
+ * prolog (if any) matches that in the JSP config element
+ * (if any), treating "UTF-16", "UTF-16BE", and "UTF-16LE" as
+ * identical.
+ */
+ if (jspConfigPageEnc != null && !jspConfigPageEnc.equals(sourceEnc)
+ && (!jspConfigPageEnc.startsWith("UTF-16")
+ || !sourceEnc.startsWith("UTF-16"))) {
+ err.jspError("jsp.error.prolog_config_encoding_mismatch",
+ sourceEnc, jspConfigPageEnc);
+ }
+ }
- // Dispatch to the appropriate parser
- if (isXml) {
- // JSP document (XML syntax)
+ // Dispatch to the appropriate parser
+ if (isXml) {
+ // JSP document (XML syntax)
// InputStream for jspx page is created and properly closed in
// JspDocumentParser.
parsedPage = JspDocumentParser.parse(this, absFileName,
- jarFile, parent,
- isTagFile, directiveOnly,
- sourceEnc,
- jspConfigPageEnc,
- isEncodingSpecifiedInProlog);
- } else {
- // Standard syntax
- InputStreamReader inStreamReader = null;
- try {
- inStreamReader = JspUtil.getReader(absFileName, sourceEnc,
- jarFile, ctxt, err);
- JspReader jspReader = new JspReader(ctxt, absFileName,
- sourceEnc, inStreamReader,
- err);
+ jarFile, parent,
+ isTagFile, directiveOnly,
+ sourceEnc,
+ jspConfigPageEnc,
+ isEncodingSpecifiedInProlog);
+ } else {
+ // Standard syntax
+ InputStreamReader inStreamReader = null;
+ try {
+ inStreamReader = JspUtil.getReader(absFileName, sourceEnc,
+ jarFile, ctxt, err);
+ JspReader jspReader = new JspReader(ctxt, absFileName,
+ sourceEnc, inStreamReader,
+ err);
parsedPage = Parser.parse(this, jspReader, parent, isTagFile,
- directiveOnly, jarFileUrl,
- sourceEnc, jspConfigPageEnc,
- isDefaultPageEncoding);
+ directiveOnly, jarFileUrl,
+ sourceEnc, jspConfigPageEnc,
+ isDefaultPageEncoding);
} finally {
- if (inStreamReader != null) {
- try {
- inStreamReader.close();
- } catch (Exception any) {
- }
- }
- }
- }
+ if (inStreamReader != null) {
+ try {
+ inStreamReader.close();
+ } catch (Exception any) {
+ }
+ }
+ }
+ }
- if (jarFile != null) {
- try {
- jarFile.close();
- } catch (Throwable t) {}
- }
+ if (jarFile != null) {
+ try {
+ jarFile.close();
+ } catch (Throwable t) {
+ }
+ }
- baseDirStack.pop();
+ baseDirStack.pop();
- return parsedPage;
+ return parsedPage;
}
/*
@@ -247,10 +248,10 @@
private String getJspConfigPageEncoding(String absFileName)
throws JasperException {
- JspConfig jspConfig = ctxt.getOptions().getJspConfig();
- JspConfig.JspProperty jspProperty
- = jspConfig.findJspProperty(absFileName);
- return jspProperty.getPageEncoding();
+ JspConfig jspConfig = ctxt.getOptions().getJspConfig();
+ JspConfig.JspProperty jspProperty
+ = jspConfig.findJspProperty(absFileName);
+ return jspProperty.getPageEncoding();
}
/**
@@ -259,152 +260,152 @@
* instance variables, respectively.
*/
private void determineSyntaxAndEncoding(String absFileName,
- JarFile jarFile,
- String jspConfigPageEnc)
- throws JasperException, IOException {
+ JarFile jarFile,
+ String jspConfigPageEnc)
+ throws JasperException, IOException {
- isXml = false;
+ isXml = false;
- /*
- * 'true' if the syntax (XML or standard) of the file is given
- * from external information: either via a JSP configuration element,
- * the ".jspx" suffix, or the enclosing file (for included resources)
- */
- boolean isExternal = false;
+ /*
+ * 'true' if the syntax (XML or standard) of the file is given
+ * from external information: either via a JSP configuration element,
+ * the ".jspx" suffix, or the enclosing file (for included resources)
+ */
+ boolean isExternal = false;
- /*
- * Indicates whether we need to revert from temporary usage of
- * "ISO-8859-1" back to "UTF-8"
- */
- boolean revert = false;
+ /*
+ * Indicates whether we need to revert from temporary usage of
+ * "ISO-8859-1" back to "UTF-8"
+ */
+ boolean revert = false;
JspConfig jspConfig = ctxt.getOptions().getJspConfig();
JspConfig.JspProperty jspProperty = jspConfig.findJspProperty(
- absFileName);
+ absFileName);
if (jspProperty.isXml() != null) {
// If <is-xml> is specified in a <jsp-property-group>, it is used.
isXml = JspUtil.booleanValue(jspProperty.isXml());
- isExternal = true;
- } else if (absFileName.endsWith(".jspx")
- || absFileName.endsWith(".tagx")) {
- isXml = true;
- isExternal = true;
- }
-
- if (isExternal && !isXml) {
- // JSP (standard) syntax. Use encoding specified in jsp-config
- // if provided.
- sourceEnc = jspConfigPageEnc;
- if (sourceEnc != null) {
- return;
- }
- // We don't know the encoding
- sourceEnc = "ISO-8859-1";
- } else {
- // XML syntax or unknown, (auto)detect encoding ...
- Object[] ret = XMLEncodingDetector.getEncoding(absFileName,
- jarFile, ctxt, err);
- sourceEnc = (String) ret[0];
- if (((Boolean) ret[1]).booleanValue()) {
- isEncodingSpecifiedInProlog = true;
- }
+ isExternal = true;
+ } else if (absFileName.endsWith(".jspx")
+ || absFileName.endsWith(".tagx")) {
+ isXml = true;
+ isExternal = true;
+ }
- if (!isXml && sourceEnc.equals("UTF-8")) {
- /*
- * We don't know if we're dealing with XML or standard syntax.
- * Therefore, we need to check to see if the page contains
- * a <jsp:root> element.
- *
- * We need to be careful, because the page may be encoded in
- * ISO-8859-1 (or something entirely different), and may
- * contain byte sequences that will cause a UTF-8 converter to
- * throw exceptions.
- *
- * It is safe to use a source encoding of ISO-8859-1 in this
- * case, as there are no invalid byte sequences in ISO-8859-1,
- * and the byte/character sequences we're looking for (i.e.,
- * <jsp:root>) are identical in either encoding (both UTF-8
- * and ISO-8859-1 are extensions of ASCII).
- */
- sourceEnc = "ISO-8859-1";
- revert = true;
- }
- }
+ if (isExternal && !isXml) {
+ // JSP (standard) syntax. Use encoding specified in jsp-config
+ // if provided.
+ sourceEnc = jspConfigPageEnc;
+ if (sourceEnc != null) {
+ return;
+ }
+ // We don't know the encoding
+ sourceEnc = "ISO-8859-1";
+ } else {
+ // XML syntax or unknown, (auto)detect encoding ...
+ Object[] ret = XMLEncodingDetector.getEncoding(absFileName,
+ jarFile, ctxt, err);
+ sourceEnc = (String) ret[0];
+ if (((Boolean) ret[1]).booleanValue()) {
+ isEncodingSpecifiedInProlog = true;
+ }
- if (isXml) {
- // (This implies 'isExternal' is TRUE.)
- // We know we're dealing with a JSP document (via JSP config or
- // ".jspx" suffix), so we're done.
- return;
- }
+ if (!isXml && sourceEnc.equals("UTF-8")) {
+ /*
+ * We don't know if we're dealing with XML or standard syntax.
+ * Therefore, we need to check to see if the page contains
+ * a <jsp:root> element.
+ *
+ * We need to be careful, because the page may be encoded in
+ * ISO-8859-1 (or something entirely different), and may
+ * contain byte sequences that will cause a UTF-8 converter to
+ * throw exceptions.
+ *
+ * It is safe to use a source encoding of ISO-8859-1 in this
+ * case, as there are no invalid byte sequences in ISO-8859-1,
+ * and the byte/character sequences we're looking for (i.e.,
+ * <jsp:root>) are identical in either encoding (both UTF-8
+ * and ISO-8859-1 are extensions of ASCII).
+ */
+ sourceEnc = "ISO-8859-1";
+ revert = true;
+ }
+ }
- /*
- * At this point, 'isExternal' or 'isXml' is FALSE.
- * Search for jsp:root action, in order to determine if we're dealing
- * with XML or standard syntax (unless we already know what we're
- * dealing with, i.e., when 'isExternal' is TRUE and 'isXml' is FALSE).
- * No check for XML prolog, since nothing prevents a page from
- * outputting XML and still using JSP syntax (in this case, the
- * XML prolog is treated as template text).
- */
- JspReader jspReader = null;
- try {
- jspReader = new JspReader(ctxt, absFileName, sourceEnc, jarFile,
- err);
- } catch (FileNotFoundException ex) {
- throw new JasperException(ex);
- }
+ if (isXml) {
+ // (This implies 'isExternal' is TRUE.)
+ // We know we're dealing with a JSP document (via JSP config or
+ // ".jspx" suffix), so we're done.
+ return;
+ }
+
+ /*
+ * At this point, 'isExternal' or 'isXml' is FALSE.
+ * Search for jsp:root action, in order to determine if we're dealing
+ * with XML or standard syntax (unless we already know what we're
+ * dealing with, i.e., when 'isExternal' is TRUE and 'isXml' is FALSE).
+ * No check for XML prolog, since nothing prevents a page from
+ * outputting XML and still using JSP syntax (in this case, the
+ * XML prolog is treated as template text).
+ */
+ JspReader jspReader = null;
+ try {
+ jspReader = new JspReader(ctxt, absFileName, sourceEnc, jarFile,
+ err);
+ } catch (FileNotFoundException ex) {
+ throw new JasperException(ex);
+ }
jspReader.setSingleFile(true);
Mark startMark = jspReader.mark();
- if (!isExternal) {
- jspReader.reset(startMark);
- if (hasJspRoot(jspReader)) {
- isXml = true;
- if (revert) sourceEnc = "UTF-8";
- return;
- } else {
- isXml = false;
- }
- }
+ if (!isExternal) {
+ jspReader.reset(startMark);
+ if (hasJspRoot(jspReader)) {
+ isXml = true;
+ if (revert) sourceEnc = "UTF-8";
+ return;
+ } else {
+ isXml = false;
+ }
+ }
- /*
- * At this point, we know we're dealing with JSP syntax.
- * If an XML prolog is provided, it's treated as template text.
- * Determine the page encoding from the page directive, unless it's
- * specified via JSP config.
- */
- sourceEnc = jspConfigPageEnc;
- if (sourceEnc == null) {
- sourceEnc = getPageEncodingForJspSyntax(jspReader, startMark);
- if (sourceEnc == null) {
- // Default to "ISO-8859-1" per JSP spec
- sourceEnc = "ISO-8859-1";
- isDefaultPageEncoding = true;
- }
- }
+ /*
+ * At this point, we know we're dealing with JSP syntax.
+ * If an XML prolog is provided, it's treated as template text.
+ * Determine the page encoding from the page directive, unless it's
+ * specified via JSP config.
+ */
+ sourceEnc = jspConfigPageEnc;
+ if (sourceEnc == null) {
+ sourceEnc = getPageEncodingForJspSyntax(jspReader, startMark);
+ if (sourceEnc == null) {
+ // Default to "ISO-8859-1" per JSP spec
+ sourceEnc = "ISO-8859-1";
+ isDefaultPageEncoding = true;
+ }
+ }
}
-
- /*
- * Determines page source encoding for page or tag file in JSP syntax,
- * by reading (in this order) the value of the 'pageEncoding' page
- * directive attribute, or the charset value of the 'contentType' page
- * directive attribute.
- *
- * @return The page encoding, or null if not found
- */
- private String getPageEncodingForJspSyntax(JspReader jspReader,
- Mark startMark)
- throws JasperException {
- String encoding = null;
+ /*
+ * Determines page source encoding for page or tag file in JSP syntax,
+ * by reading (in this order) the value of the 'pageEncoding' page
+ * directive attribute, or the charset value of the 'contentType' page
+ * directive attribute.
+ *
+ * @return The page encoding, or null if not found
+ */
+ private String getPageEncodingForJspSyntax(JspReader jspReader,
+ Mark startMark)
+ throws JasperException {
+
+ String encoding = null;
String saveEncoding = null;
jspReader.reset(startMark);
- /*
- * Determine page encoding from directive of the form <%@ page %>,
- * <%@ tag %>, <jsp:directive.page > or <jsp:directive.tag >.
- */
+ /*
+ * Determine page encoding from directive of the form <%@ page %>,
+ * <%@ tag %>, <jsp:directive.page > or <jsp:directive.tag >.
+ */
while (true) {
if (jspReader.skipUntil("<") == null) {
break;
@@ -419,36 +420,35 @@
}
boolean isDirective = jspReader.matches("%@");
if (isDirective) {
- jspReader.skipSpaces();
- }
- else {
+ jspReader.skipSpaces();
+ } else {
isDirective = jspReader.matches("jsp:directive.");
}
if (!isDirective) {
continue;
}
- // compare for "tag ", so we don't match "taglib"
- if (jspReader.matches("tag ") || jspReader.matches("page")) {
+ // compare for "tag ", so we don't match "taglib"
+ if (jspReader.matches("tag ") || jspReader.matches("page")) {
- jspReader.skipSpaces();
+ jspReader.skipSpaces();
Attributes attrs = Parser.parseAttributes(this, jspReader);
- encoding = getPageEncodingFromDirective(attrs, "pageEncoding");
+ encoding = getPageEncodingFromDirective(attrs, "pageEncoding");
if (encoding != null) {
break;
}
- encoding = getPageEncodingFromDirective(attrs, "contentType");
+ encoding = getPageEncodingFromDirective(attrs, "contentType");
if (encoding != null) {
saveEncoding = encoding;
}
- }
- }
+ }
+ }
if (encoding == null) {
encoding = saveEncoding;
}
- return encoding;
+ return encoding;
}
/*
@@ -467,7 +467,7 @@
*/
private String getPageEncodingFromDirective(Attributes attrs,
String attrName) {
- String value = attrs.getValue(attrName);
+ String value = attrs.getValue(attrName);
if (attrName.equals("pageEncoding")) {
return value;
}
@@ -476,13 +476,13 @@
String contentType = value;
String encoding = null;
if (contentType != null) {
- int loc = contentType.indexOf(CHARSET);
- if (loc != -1) {
- encoding = contentType.substring(loc + CHARSET.length());
- }
- }
+ int loc = contentType.indexOf(CHARSET);
+ if (loc != -1) {
+ encoding = contentType.substring(loc + CHARSET.length());
+ }
+ }
- return encoding;
+ return encoding;
}
/*
@@ -493,10 +493,10 @@
*/
private String resolveFileName(String inFileName) {
String fileName = inFileName.replace('\\', '/');
- String baseDir =
- fileName.substring(0, fileName.lastIndexOf("/") + 1);
- baseDirStack.push(baseDir);
- return fileName;
+ String baseDir =
+ fileName.substring(0, fileName.lastIndexOf("/") + 1);
+ baseDirStack.push(baseDir);
+ return fileName;
}
/*
@@ -514,67 +514,67 @@
*/
private boolean hasJspRoot(JspReader reader) throws JasperException {
- // <prefix>:root must be the first element
- Mark start = null;
- while ((start = reader.skipUntil("<")) != null) {
- int c = reader.nextChar();
- if (c != '!' && c != '?') break;
- }
- if (start == null) {
- return false;
- }
- Mark stop = reader.skipUntil(":root");
- if (stop == null) {
- return false;
- }
- // call substring to get rid of leading '<'
- String prefix = reader.getText(start, stop).substring(1);
+ // <prefix>:root must be the first element
+ Mark start = null;
+ while ((start = reader.skipUntil("<")) != null) {
+ int c = reader.nextChar();
+ if (c != '!' && c != '?') break;
+ }
+ if (start == null) {
+ return false;
+ }
+ Mark stop = reader.skipUntil(":root");
+ if (stop == null) {
+ return false;
+ }
+ // call substring to get rid of leading '<'
+ String prefix = reader.getText(start, stop).substring(1);
- start = stop;
- stop = reader.skipUntil(">");
- if (stop == null) {
- return false;
- }
+ start = stop;
+ stop = reader.skipUntil(">");
+ if (stop == null) {
+ return false;
+ }
- // Determine namespace associated with <root> element's prefix
- String root = reader.getText(start, stop);
- String xmlnsDecl = "xmlns:" + prefix;
- int index = root.indexOf(xmlnsDecl);
- if (index == -1) {
- return false;
- }
- index += xmlnsDecl.length();
- while (index < root.length()
- && Character.isWhitespace(root.charAt(index))) {
- index++;
- }
- if (index < root.length() && root.charAt(index) == '=') {
- index++;
- while (index < root.length()
- && Character.isWhitespace(root.charAt(index))) {
- index++;
- }
- if (index < root.length() && root.charAt(index++) == '"'
- && root.regionMatches(index, JSP_URI, 0,
- JSP_URI.length())) {
- return true;
- }
- }
+ // Determine namespace associated with <root> element's prefix
+ String root = reader.getText(start, stop);
+ String xmlnsDecl = "xmlns:" + prefix;
+ int index = root.indexOf(xmlnsDecl);
+ if (index == -1) {
+ return false;
+ }
+ index += xmlnsDecl.length();
+ while (index < root.length()
+ && Character.isWhitespace(root.charAt(index))) {
+ index++;
+ }
+ if (index < root.length() && root.charAt(index) == '=') {
+ index++;
+ while (index < root.length()
+ && Character.isWhitespace(root.charAt(index))) {
+ index++;
+ }
+ if (index < root.length() && root.charAt(index++) == '"'
+ && root.regionMatches(index, JSP_URI, 0,
+ JSP_URI.length())) {
+ return true;
+ }
+ }
- return false;
+ return false;
}
private JarFile getJarFile(URL jarFileUrl) throws IOException {
- JarFile jarFile = null;
+ JarFile jarFile = null;
- if (jarFileUrl != null) {
- JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection();
- conn.setUseCaches(false);
- conn.connect();
- jarFile = conn.getJarFile();
- }
+ if (jarFileUrl != null) {
+ JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection();
+ conn.setUseCaches(false);
+ conn.connect();
+ jarFile = conn.getJarFile();
+ }
- return jarFile;
+ return jarFile;
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ScriptingVariabler.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ScriptingVariabler.java
index 77ce15d..17ec3ef 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ScriptingVariabler.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ScriptingVariabler.java
@@ -41,17 +41,17 @@
*/
static class CustomTagCounter extends Node.Visitor {
- private int count;
- private Node.CustomTag parent;
+ private int count;
+ private Node.CustomTag parent;
- public void visit(Node.CustomTag n) throws JasperException {
- n.setCustomTagParent(parent);
- Node.CustomTag tmpParent = parent;
- parent = n;
- visitBody(n);
- parent = tmpParent;
- n.setNumCount(new Integer(count++));
- }
+ public void visit(Node.CustomTag n) throws JasperException {
+ n.setCustomTagParent(parent);
+ Node.CustomTag tmpParent = parent;
+ parent = n;
+ visitBody(n);
+ parent = tmpParent;
+ n.setNumCount(new Integer(count++));
+ }
}
/*
@@ -60,92 +60,92 @@
*/
static class ScriptingVariableVisitor extends Node.Visitor {
- private ErrorDispatcher err;
- private Hashtable scriptVars;
-
- public ScriptingVariableVisitor(ErrorDispatcher err) {
- this.err = err;
- scriptVars = new Hashtable();
- }
+ private ErrorDispatcher err;
+ private Hashtable scriptVars;
- public void visit(Node.CustomTag n) throws JasperException {
- setScriptingVars(n, VariableInfo.AT_BEGIN);
- setScriptingVars(n, VariableInfo.NESTED);
- visitBody(n);
- setScriptingVars(n, VariableInfo.AT_END);
- }
+ public ScriptingVariableVisitor(ErrorDispatcher err) {
+ this.err = err;
+ scriptVars = new Hashtable();
+ }
- private void setScriptingVars(Node.CustomTag n, int scope)
- throws JasperException {
+ public void visit(Node.CustomTag n) throws JasperException {
+ setScriptingVars(n, VariableInfo.AT_BEGIN);
+ setScriptingVars(n, VariableInfo.NESTED);
+ visitBody(n);
+ setScriptingVars(n, VariableInfo.AT_END);
+ }
- TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
- VariableInfo[] varInfos = n.getVariableInfos();
- if (tagVarInfos.length == 0 && varInfos.length == 0) {
- return;
- }
+ private void setScriptingVars(Node.CustomTag n, int scope)
+ throws JasperException {
- Vector vec = new Vector();
+ TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
+ VariableInfo[] varInfos = n.getVariableInfos();
+ if (tagVarInfos.length == 0 && varInfos.length == 0) {
+ return;
+ }
- Integer ownRange = null;
- if (scope == VariableInfo.AT_BEGIN
- || scope == VariableInfo.AT_END) {
- Node.CustomTag parent = n.getCustomTagParent();
- if (parent == null)
- ownRange = MAX_SCOPE;
- else
- ownRange = parent.getNumCount();
- } else {
- // NESTED
- ownRange = n.getNumCount();
- }
+ Vector vec = new Vector();
- if (varInfos.length > 0) {
- for (int i=0; i<varInfos.length; i++) {
- if (varInfos[i].getScope() != scope
- || !varInfos[i].getDeclare()) {
- continue;
- }
- String varName = varInfos[i].getVarName();
-
- Integer currentRange = (Integer) scriptVars.get(varName);
- if (currentRange == null
- || ownRange.compareTo(currentRange) > 0) {
- scriptVars.put(varName, ownRange);
- vec.add(varInfos[i]);
- }
- }
- } else {
- for (int i=0; i<tagVarInfos.length; i++) {
- if (tagVarInfos[i].getScope() != scope
- || !tagVarInfos[i].getDeclare()) {
- continue;
- }
- String varName = tagVarInfos[i].getNameGiven();
- if (varName == null) {
- varName = n.getTagData().getAttributeString(
- tagVarInfos[i].getNameFromAttribute());
- if (varName == null) {
- err.jspError(n, "jsp.error.scripting.variable.missing_name",
- tagVarInfos[i].getNameFromAttribute());
- }
- }
+ Integer ownRange = null;
+ if (scope == VariableInfo.AT_BEGIN
+ || scope == VariableInfo.AT_END) {
+ Node.CustomTag parent = n.getCustomTagParent();
+ if (parent == null)
+ ownRange = MAX_SCOPE;
+ else
+ ownRange = parent.getNumCount();
+ } else {
+ // NESTED
+ ownRange = n.getNumCount();
+ }
- Integer currentRange = (Integer) scriptVars.get(varName);
- if (currentRange == null
- || ownRange.compareTo(currentRange) > 0) {
- scriptVars.put(varName, ownRange);
- vec.add(tagVarInfos[i]);
- }
- }
- }
+ if (varInfos.length > 0) {
+ for (int i = 0; i < varInfos.length; i++) {
+ if (varInfos[i].getScope() != scope
+ || !varInfos[i].getDeclare()) {
+ continue;
+ }
+ String varName = varInfos[i].getVarName();
- n.setScriptingVars(vec, scope);
- }
+ Integer currentRange = (Integer) scriptVars.get(varName);
+ if (currentRange == null
+ || ownRange.compareTo(currentRange) > 0) {
+ scriptVars.put(varName, ownRange);
+ vec.add(varInfos[i]);
+ }
+ }
+ } else {
+ for (int i = 0; i < tagVarInfos.length; i++) {
+ if (tagVarInfos[i].getScope() != scope
+ || !tagVarInfos[i].getDeclare()) {
+ continue;
+ }
+ String varName = tagVarInfos[i].getNameGiven();
+ if (varName == null) {
+ varName = n.getTagData().getAttributeString(
+ tagVarInfos[i].getNameFromAttribute());
+ if (varName == null) {
+ err.jspError(n, "jsp.error.scripting.variable.missing_name",
+ tagVarInfos[i].getNameFromAttribute());
+ }
+ }
+
+ Integer currentRange = (Integer) scriptVars.get(varName);
+ if (currentRange == null
+ || ownRange.compareTo(currentRange) > 0) {
+ scriptVars.put(varName, ownRange);
+ vec.add(tagVarInfos[i]);
+ }
+ }
+ }
+
+ n.setScriptingVars(vec, scope);
+ }
}
public static void set(Node.Nodes page, ErrorDispatcher err)
- throws JasperException {
- page.visit(new CustomTagCounter());
- page.visit(new ScriptingVariableVisitor(err));
+ throws JasperException {
+ page.visit(new CustomTagCounter());
+ page.visit(new ScriptingVariableVisitor(err));
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ServletWriter.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ServletWriter.java
index 4aef0aa..420f6a4 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ServletWriter.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/ServletWriter.java
@@ -20,7 +20,7 @@
import java.io.PrintWriter;
/**
- * This is what is used to generate servlets.
+ * This is what is used to generate servlets.
*
* @author Anil K. Vijendran
* @author Kin-man Chung
@@ -35,20 +35,20 @@
// The sink writer:
PrintWriter writer;
-
+
// servlet line numbers start from 1
private int javaLine = 1;
public ServletWriter(PrintWriter writer) {
- this.writer = writer;
+ this.writer = writer;
}
public void close() throws IOException {
- writer.close();
+ writer.close();
}
-
+
// -------------------- Access informations --------------------
public int getJavaLine() {
@@ -59,30 +59,31 @@
// -------------------- Formatting --------------------
public void pushIndent() {
- virtual_indent += TAB_WIDTH;
- if (virtual_indent >= 0 && virtual_indent <= SPACES.length())
- indent = virtual_indent;
+ virtual_indent += TAB_WIDTH;
+ if (virtual_indent >= 0 && virtual_indent <= SPACES.length())
+ indent = virtual_indent;
}
public void popIndent() {
- virtual_indent -= TAB_WIDTH;
- if (virtual_indent >= 0 && virtual_indent <= SPACES.length())
- indent = virtual_indent;
+ virtual_indent -= TAB_WIDTH;
+ if (virtual_indent >= 0 && virtual_indent <= SPACES.length())
+ indent = virtual_indent;
}
/**
* Print a standard comment for echo outputed chunk.
- * @param start The starting position of the JSP chunk being processed.
- * @param stop The ending position of the JSP chunk being processed.
+ *
+ * @param start The starting position of the JSP chunk being processed.
+ * @param stop The ending position of the JSP chunk being processed.
*/
public void printComment(Mark start, Mark stop, char[] chars) {
if (start != null && stop != null) {
- println("// from="+start);
- println("// to="+stop);
+ println("// from=" + start);
+ println("// to=" + stop);
}
-
+
if (chars != null)
- for(int i = 0; i < chars.length;) {
+ for (int i = 0; i < chars.length;) {
printin();
print("// ");
while (chars[i] != '\n' && i < chars.length)
@@ -95,7 +96,7 @@
*/
public void println(String s) {
javaLine++;
- writer.println(s);
+ writer.println(s);
}
/**
@@ -103,22 +104,22 @@
*/
public void println() {
javaLine++;
- writer.println("");
+ writer.println("");
}
/**
* Prints the current indention
*/
public void printin() {
- writer.print(SPACES.substring(0, indent));
+ writer.print(SPACES.substring(0, indent));
}
/**
* Prints the current indention, followed by the given string
*/
public void printin(String s) {
- writer.print(SPACES.substring(0, indent));
- writer.print(s);
+ writer.print(SPACES.substring(0, indent));
+ writer.print(s);
}
/**
@@ -126,39 +127,39 @@
*/
public void printil(String s) {
javaLine++;
- writer.print(SPACES.substring(0, indent));
- writer.println(s);
+ writer.print(SPACES.substring(0, indent));
+ writer.println(s);
}
/**
* Prints the given char.
- *
+ * <p/>
* Use println() to print a '\n'.
*/
public void print(char c) {
- writer.print(c);
+ writer.print(c);
}
/**
* Prints the given int.
*/
public void print(int i) {
- writer.print(i);
+ writer.print(i);
}
/**
* Prints the given string.
- *
+ * <p/>
* The string must not contain any '\n', otherwise the line count will be
* off.
*/
public void print(String s) {
- writer.print(s);
+ writer.print(s);
}
/**
* Prints the given string.
- *
+ * <p/>
* If the string spans multiple lines, the line count will be adjusted
* accordingly.
*/
@@ -166,11 +167,11 @@
int index = 0;
// look for hidden newlines inside strings
- while ((index=s.indexOf('\n',index)) > -1 ) {
+ while ((index = s.indexOf('\n', index)) > -1) {
javaLine++;
index++;
}
- writer.print(s);
+ writer.print(s);
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/SmapGenerator.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/SmapGenerator.java
index 0bae58e..53e76f4 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/SmapGenerator.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/SmapGenerator.java
@@ -24,7 +24,7 @@
* Represents a source map (SMAP), which serves to associate lines
* of the input JSP file(s) to lines in the generated servlet in the
* final .class file, according to the JSR-045 spec.
- *
+ *
* @author Shawn Bayern
*/
public class SmapGenerator {
@@ -59,7 +59,7 @@
* source file. E.g., "foo$jsp.java".
*/
public synchronized void setOutputFileName(String x) {
- outputFileName = x;
+ outputFileName = x;
}
/**
@@ -69,29 +69,29 @@
* stratum is made the default stratum, overriding any previously
* set default.
*
- * @param stratum the SmapStratum object to add
+ * @param stratum the SmapStratum object to add
* @param defaultStratum if <tt>true</tt>, this SmapStratum is considered
- * to represent the default SMAP stratum unless
- * overwritten
+ * to represent the default SMAP stratum unless
+ * overwritten
*/
public synchronized void addStratum(SmapStratum stratum,
- boolean defaultStratum) {
- strata.add(stratum);
- if (defaultStratum)
- this.defaultStratum = stratum.getStratumName();
+ boolean defaultStratum) {
+ strata.add(stratum);
+ if (defaultStratum)
+ this.defaultStratum = stratum.getStratumName();
}
/**
* Adds the given string as an embedded SMAP with the given stratum name.
*
- * @param smap the SMAP to embed
+ * @param smap the SMAP to embed
* @param stratumName the name of the stratum output by the compilation
* that produced the <tt>smap</tt> to be embedded
*/
public synchronized void addSmap(String smap, String stratumName) {
- embedded.add("*O " + stratumName + "\n"
- + smap
- + "*C " + stratumName + "\n");
+ embedded.add("*O " + stratumName + "\n"
+ + smap
+ + "*C " + stratumName + "\n");
}
/**
@@ -101,71 +101,73 @@
* @param status If <tt>false</tt>, ignore any embedded SMAPs.
*/
public void setDoEmbedded(boolean status) {
- doEmbedded = status;
+ doEmbedded = status;
}
//*********************************************************************
// Methods for serializing the logical SMAP
public synchronized String getString() {
- // check state and initialize buffer
- if (outputFileName == null)
- throw new IllegalStateException();
+ // check state and initialize buffer
+ if (outputFileName == null)
+ throw new IllegalStateException();
StringBuffer out = new StringBuffer();
- // start the SMAP
- out.append("SMAP\n");
- out.append(outputFileName + '\n');
- out.append(defaultStratum + '\n');
+ // start the SMAP
+ out.append("SMAP\n");
+ out.append(outputFileName + '\n');
+ out.append(defaultStratum + '\n');
- // include embedded SMAPs
- if (doEmbedded) {
- int nEmbedded = embedded.size();
- for (int i = 0; i < nEmbedded; i++) {
- out.append(embedded.get(i));
- }
- }
+ // include embedded SMAPs
+ if (doEmbedded) {
+ int nEmbedded = embedded.size();
+ for (int i = 0; i < nEmbedded; i++) {
+ out.append(embedded.get(i));
+ }
+ }
- // print our StratumSections, FileSections, and LineSections
- int nStrata = strata.size();
- for (int i = 0; i < nStrata; i++) {
- SmapStratum s = (SmapStratum) strata.get(i);
- out.append(s.getString());
- }
+ // print our StratumSections, FileSections, and LineSections
+ int nStrata = strata.size();
+ for (int i = 0; i < nStrata; i++) {
+ SmapStratum s = (SmapStratum) strata.get(i);
+ out.append(s.getString());
+ }
- // end the SMAP
- out.append("*E\n");
+ // end the SMAP
+ out.append("*E\n");
- return out.toString();
+ return out.toString();
}
- public String toString() { return getString(); }
+ public String toString() {
+ return getString();
+ }
//*********************************************************************
// For testing (and as an example of use)...
public static void main(String args[]) {
- SmapGenerator g = new SmapGenerator();
- g.setOutputFileName("foo.java");
- SmapStratum s = new SmapStratum("JSP");
- s.addFile("foo.jsp");
- s.addFile("bar.jsp", "/foo/foo/bar.jsp");
- s.addLineData(1, "foo.jsp", 1, 1, 1);
- s.addLineData(2, "foo.jsp", 1, 6, 1);
- s.addLineData(3, "foo.jsp", 2, 10, 5);
- s.addLineData(20, "bar.jsp", 1, 30, 1);
- g.addStratum(s, true);
- System.out.print(g);
+ SmapGenerator g = new SmapGenerator();
+ g.setOutputFileName("foo.java");
+ SmapStratum s = new SmapStratum("JSP");
+ s.addFile("foo.jsp");
+ s.addFile("bar.jsp", "/foo/foo/bar.jsp");
+ s.addLineData(1, "foo.jsp", 1, 1, 1);
+ s.addLineData(2, "foo.jsp", 1, 6, 1);
+ s.addLineData(3, "foo.jsp", 2, 10, 5);
+ s.addLineData(20, "bar.jsp", 1, 30, 1);
+ g.addStratum(s, true);
+ System.out.print(g);
- System.out.println("---");
+ System.out.println("---");
- SmapGenerator embedded = new SmapGenerator();
- embedded.setOutputFileName("blargh.tier2");
- s = new SmapStratum("Tier2");
- s.addFile("1.tier2");
- s.addLineData(1, "1.tier2", 1, 1, 1);
- embedded.addStratum(s, true);
- g.addSmap(embedded.toString(), "JSP");
- System.out.println(g);
+ SmapGenerator embedded = new SmapGenerator();
+ embedded.setOutputFileName("blargh.tier2");
+ s = new SmapStratum("Tier2");
+ s.addFile("1.tier2");
+ s.addLineData(1, "1.tier2", 1, 1, 1);
+ embedded.addStratum(s, true);
+ g.addSmap(embedded.toString(), "JSP");
+ System.out.println(g);
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/SmapStratum.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/SmapStratum.java
index e5973ec..7cb1ad0 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/SmapStratum.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/SmapStratum.java
@@ -44,14 +44,18 @@
private int outputLineIncrement = 1;
private boolean lineFileIDSet = false;
- /** Sets InputStartLine. */
+ /**
+ * Sets InputStartLine.
+ */
public void setInputStartLine(int inputStartLine) {
if (inputStartLine < 0)
throw new IllegalArgumentException("" + inputStartLine);
this.inputStartLine = inputStartLine;
}
- /** Sets OutputStartLine. */
+ /**
+ * Sets OutputStartLine.
+ */
public void setOutputStartLine(int outputStartLine) {
if (outputStartLine < 0)
throw new IllegalArgumentException("" + outputStartLine);
@@ -59,11 +63,11 @@
}
/**
- * Sets lineFileID. Should be called only when different from
- * that of prior LineInfo object (in any given context) or 0
- * if the current LineInfo has no (logical) predecessor.
- * <tt>LineInfo</tt> will print this file number no matter what.
- */
+ * Sets lineFileID. Should be called only when different from
+ * that of prior LineInfo object (in any given context) or 0
+ * if the current LineInfo has no (logical) predecessor.
+ * <tt>LineInfo</tt> will print this file number no matter what.
+ */
public void setLineFileID(int lineFileID) {
if (lineFileID < 0)
throw new IllegalArgumentException("" + lineFileID);
@@ -71,14 +75,18 @@
this.lineFileIDSet = true;
}
- /** Sets InputLineCount. */
+ /**
+ * Sets InputLineCount.
+ */
public void setInputLineCount(int inputLineCount) {
if (inputLineCount < 0)
throw new IllegalArgumentException("" + inputLineCount);
this.inputLineCount = inputLineCount;
}
- /** Sets OutputLineIncrement. */
+ /**
+ * Sets OutputLineIncrement.
+ */
public void setOutputLineIncrement(int outputLineIncrement) {
if (outputLineIncrement < 0)
throw new IllegalArgumentException("" + outputLineIncrement);
@@ -180,19 +188,19 @@
//outputLineIncrement, if possible
int i = 0;
while (i < lineData.size() - 1) {
- LineInfo li = (LineInfo)lineData.get(i);
- LineInfo liNext = (LineInfo)lineData.get(i + 1);
+ LineInfo li = (LineInfo) lineData.get(i);
+ LineInfo liNext = (LineInfo) lineData.get(i + 1);
if (!liNext.lineFileIDSet
- && liNext.inputStartLine == li.inputStartLine
- && liNext.inputLineCount == 1
- && li.inputLineCount == 1
- && liNext.outputStartLine
+ && liNext.inputStartLine == li.inputStartLine
+ && liNext.inputLineCount == 1
+ && li.inputLineCount == 1
+ && liNext.outputStartLine
== li.outputStartLine
- + li.inputLineCount * li.outputLineIncrement) {
+ + li.inputLineCount * li.outputLineIncrement) {
li.setOutputLineIncrement(
- liNext.outputStartLine
- - li.outputStartLine
- + liNext.outputLineIncrement);
+ liNext.outputStartLine
+ - li.outputStartLine
+ + liNext.outputLineIncrement);
lineData.remove(i + 1);
} else {
i++;
@@ -203,14 +211,14 @@
//inputLineCount, if possible
i = 0;
while (i < lineData.size() - 1) {
- LineInfo li = (LineInfo)lineData.get(i);
- LineInfo liNext = (LineInfo)lineData.get(i + 1);
+ LineInfo li = (LineInfo) lineData.get(i);
+ LineInfo liNext = (LineInfo) lineData.get(i + 1);
if (!liNext.lineFileIDSet
- && liNext.inputStartLine == li.inputStartLine + li.inputLineCount
- && liNext.outputLineIncrement == li.outputLineIncrement
- && liNext.outputStartLine
+ && liNext.inputStartLine == li.inputStartLine + li.inputLineCount
+ && liNext.outputLineIncrement == li.outputLineIncrement
+ && liNext.outputStartLine
== li.outputStartLine
- + li.inputLineCount * li.outputLineIncrement) {
+ + li.inputLineCount * li.outputLineIncrement) {
li.setInputLineCount(li.inputLineCount + liNext.inputLineCount);
lineData.remove(i + 1);
} else {
@@ -227,32 +235,32 @@
* not for programmer convenience. Could always add utility methods
* later.)
*
- * @param inputStartLine starting line in the source file
- * (SMAP <tt>InputStartLine</tt>)
- * @param inputFileName the filepath (or name) from which the input comes
- * (yields SMAP <tt>LineFileID</tt>) Use unqualified names
- * carefully, and only when they uniquely identify a file.
- * @param inputLineCount the number of lines in the input to map
- * (SMAP <tt>LineFileCount</tt>)
- * @param outputStartLine starting line in the output file
- * (SMAP <tt>OutputStartLine</tt>)
+ * @param inputStartLine starting line in the source file
+ * (SMAP <tt>InputStartLine</tt>)
+ * @param inputFileName the filepath (or name) from which the input comes
+ * (yields SMAP <tt>LineFileID</tt>) Use unqualified names
+ * carefully, and only when they uniquely identify a file.
+ * @param inputLineCount the number of lines in the input to map
+ * (SMAP <tt>LineFileCount</tt>)
+ * @param outputStartLine starting line in the output file
+ * (SMAP <tt>OutputStartLine</tt>)
* @param outputLineIncrement number of output lines to map to each
- * input line (SMAP <tt>OutputLineIncrement</tt>). <i>Given the
- * fact that the name starts with "output", I continuously have
- * the subconscious urge to call this field
- * <tt>OutputLineExcrement</tt>.</i>
+ * input line (SMAP <tt>OutputLineIncrement</tt>). <i>Given the
+ * fact that the name starts with "output", I continuously have
+ * the subconscious urge to call this field
+ * <tt>OutputLineExcrement</tt>.</i>
*/
public void addLineData(
- int inputStartLine,
- String inputFileName,
- int inputLineCount,
- int outputStartLine,
- int outputLineIncrement) {
+ int inputStartLine,
+ String inputFileName,
+ int inputLineCount,
+ int outputStartLine,
+ int outputLineIncrement) {
// check the input - what are you doing here??
int fileIndex = filePathList.indexOf(inputFileName);
if (fileIndex == -1) // still
throw new IllegalArgumentException(
- "inputFileName: " + inputFileName);
+ "inputFileName: " + inputFileName);
//Jasper incorrectly SMAPs certain Nodes, giving them an
//outputStartLine of 0. This can cause a fatal error in
@@ -308,7 +316,7 @@
out.append("+ " + i + " " + fileNameList.get(i) + "\n");
// Source paths must be relative, not absolute, so we
// remove the leading "/", if one exists.
- String filePath = (String)filePathList.get(i);
+ String filePath = (String) filePathList.get(i);
if (filePath.startsWith("/")) {
filePath = filePath.substring(1);
}
@@ -322,7 +330,7 @@
out.append("*L\n");
bound = lineData.size();
for (int i = 0; i < bound; i++) {
- LineInfo li = (LineInfo)lineData.get(i);
+ LineInfo li = (LineInfo) lineData.get(i);
out.append(li.getString());
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/SmapUtil.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/SmapUtil.java
index 84dbe60..17d0600 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/SmapUtil.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/SmapUtil.java
@@ -17,6 +17,8 @@
package org.apache.struts2.jasper.compiler;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.JasperException;
import org.apache.struts2.jasper.JspCompilationContext;
@@ -28,7 +30,7 @@
/**
* Contains static utilities for generating SMAP data based on the
* current version of Jasper.
- *
+ *
* @author Jayson Falkner
* @author Shawn Bayern
* @author Robert Field (inner SDEInstaller class)
@@ -37,8 +39,7 @@
*/
public class SmapUtil {
- private org.apache.commons.logging.Log log=
- org.apache.commons.logging.LogFactory.getLog( SmapUtil.class );
+ private Logger log = LoggerFactory.getLogger(SmapUtil.class);
//*********************************************************************
// Constants
@@ -52,14 +53,14 @@
* Generates an appropriate SMAP representing the current compilation
* context. (JSR-045.)
*
- * @param ctxt Current compilation context
+ * @param ctxt Current compilation context
* @param pageNodes The current JSP page
* @return a SMAP for the page
*/
public static String[] generateSmap(
- JspCompilationContext ctxt,
- Node.Nodes pageNodes)
- throws IOException {
+ JspCompilationContext ctxt,
+ Node.Nodes pageNodes)
+ throws IOException {
// Scan the nodes for presence of Jasper generated inner classes
PreScanVisitor psVisitor = new PreScanVisitor();
@@ -71,22 +72,22 @@
// set up our SMAP generator
SmapGenerator g = new SmapGenerator();
-
+
/** Disable reading of input SMAP because:
- 1. There is a bug here: getRealPath() is null if .jsp is in a jar
- Bugzilla 14660.
- 2. Mappings from other sources into .jsp files are not supported.
- TODO: fix 1. if 2. is not true.
- // determine if we have an input SMAP
- String smapPath = inputSmapPath(ctxt.getRealPath(ctxt.getJspFile()));
- File inputSmap = new File(smapPath);
- if (inputSmap.exists()) {
- byte[] embeddedSmap = null;
- byte[] subSmap = SDEInstaller.readWhole(inputSmap);
- String subSmapString = new String(subSmap, SMAP_ENCODING);
- g.addSmap(subSmapString, "JSP");
- }
- **/
+ 1. There is a bug here: getRealPath() is null if .jsp is in a jar
+ Bugzilla 14660.
+ 2. Mappings from other sources into .jsp files are not supported.
+ TODO: fix 1. if 2. is not true.
+ // determine if we have an input SMAP
+ String smapPath = inputSmapPath(ctxt.getRealPath(ctxt.getJspFile()));
+ File inputSmap = new File(smapPath);
+ if (inputSmap.exists()) {
+ byte[] embeddedSmap = null;
+ byte[] subSmap = SDEInstaller.readWhole(inputSmap);
+ String subSmapString = new String(subSmap, SMAP_ENCODING);
+ g.addSmap(subSmapString, "JSP");
+ }
+ **/
// now, assemble info about our own stratum (JSP) using JspLineMap
SmapStratum s = new SmapStratum("JSP");
@@ -101,17 +102,17 @@
if (ctxt.getOptions().isSmapDumped()) {
File outSmap = new File(ctxt.getClassFileName() + ".smap");
PrintWriter so =
- new PrintWriter(
- new OutputStreamWriter(
- new FileOutputStream(outSmap),
- SMAP_ENCODING));
+ new PrintWriter(
+ new OutputStreamWriter(
+ new FileOutputStream(outSmap),
+ SMAP_ENCODING));
so.print(g.getString());
so.close();
}
String classFileName = ctxt.getClassFileName();
int innerClassCount = map.size();
- String [] smapInfo = new String[2 + innerClassCount*2];
+ String[] smapInfo = new String[2 + innerClassCount * 2];
smapInfo[0] = classFileName;
smapInfo[1] = g.getString();
@@ -127,20 +128,20 @@
g.addStratum(s, true);
String innerClassFileName =
- classFileName.substring(0, classFileName.indexOf(".class")) +
- '$' + innerClass + ".class";
+ classFileName.substring(0, classFileName.indexOf(".class")) +
+ '$' + innerClass + ".class";
if (ctxt.getOptions().isSmapDumped()) {
File outSmap = new File(innerClassFileName + ".smap");
PrintWriter so =
- new PrintWriter(
- new OutputStreamWriter(
- new FileOutputStream(outSmap),
- SMAP_ENCODING));
+ new PrintWriter(
+ new OutputStreamWriter(
+ new FileOutputStream(outSmap),
+ SMAP_ENCODING));
so.print(g.getString());
so.close();
}
smapInfo[count] = innerClassFileName;
- smapInfo[count+1] = g.getString();
+ smapInfo[count + 1] = g.getString();
count += 2;
}
@@ -148,14 +149,14 @@
}
public static void installSmap(String[] smap)
- throws IOException {
+ throws IOException {
if (smap == null) {
return;
}
for (int i = 0; i < smap.length; i += 2) {
File outServlet = new File(smap[i]);
- SDEInstaller.install(outServlet, smap[i+1].getBytes());
+ SDEInstaller.install(outServlet, smap[i + 1].getBytes());
}
}
@@ -182,8 +183,7 @@
// Installation logic (from Robert Field, JSR-045 spec lead)
private static class SDEInstaller {
- private org.apache.commons.logging.Log log=
- org.apache.commons.logging.LogFactory.getLog( SDEInstaller.class );
+ private Logger log = LoggerFactory.getLogger(SDEInstaller.class);
static final String nameSDE = "SourceDebugExtension";
@@ -201,24 +201,24 @@
install(new File(args[0]), new File(args[1]));
} else if (args.length == 3) {
install(
- new File(args[0]),
- new File(args[1]),
- new File(args[2]));
+ new File(args[0]),
+ new File(args[1]),
+ new File(args[2]));
} else {
System.err.println(
- "Usage: <command> <input class file> "
- + "<attribute file> <output class file name>\n"
- + "<command> <input/output class file> <attribute file>");
+ "Usage: <command> <input class file> "
+ + "<attribute file> <output class file name>\n"
+ + "<command> <input/output class file> <attribute file>");
}
}
static void install(File inClassFile, File attrFile, File outClassFile)
- throws IOException {
+ throws IOException {
new SDEInstaller(inClassFile, attrFile, outClassFile);
}
static void install(File inOutClassFile, File attrFile)
- throws IOException {
+ throws IOException {
File tmpFile = new File(inOutClassFile.getPath() + "tmp");
new SDEInstaller(inOutClassFile, attrFile, tmpFile);
if (!inOutClassFile.delete()) {
@@ -241,7 +241,7 @@
}
SDEInstaller(File inClassFile, byte[] sdeAttr, File outClassFile)
- throws IOException {
+ throws IOException {
if (!inClassFile.exists()) {
throw new FileNotFoundException("no such file: " + inClassFile);
}
@@ -261,13 +261,13 @@
}
SDEInstaller(File inClassFile, File attrFile, File outClassFile)
- throws IOException {
+ throws IOException {
this(inClassFile, readWhole(attrFile), outClassFile);
}
static byte[] readWhole(File input) throws IOException {
FileInputStream inStream = new FileInputStream(input);
- int len = (int)input.length();
+ int len = (int) input.length();
byte[] bytes = new byte[len];
if (inStream.read(bytes, 0, len) != len) {
throw new IOException("expected size: " + len);
@@ -378,7 +378,7 @@
}
int readU1() {
- return ((int)orig[origPos++]) & 0xFF;
+ return ((int) orig[origPos++]) & 0xFF;
}
int readU2() {
@@ -392,7 +392,7 @@
}
void writeU1(int val) {
- gen[genPos++] = (byte)val;
+ gen[genPos++] = (byte) val;
}
void writeU2(int val) {
@@ -426,37 +426,37 @@
}
int copyConstantPool(int constantPoolCount)
- throws UnsupportedEncodingException, IOException {
+ throws UnsupportedEncodingException, IOException {
int sdeIndex = -1;
// copy const pool index zero not in class file
for (int i = 1; i < constantPoolCount; ++i) {
int tag = readU1();
writeU1(tag);
switch (tag) {
- case 7 : // Class
- case 8 : // String
+ case 7: // Class
+ case 8: // String
if (log.isDebugEnabled())
log.debug(i + " copying 2 bytes");
copy(2);
break;
- case 9 : // Field
- case 10 : // Method
- case 11 : // InterfaceMethod
- case 3 : // Integer
- case 4 : // Float
- case 12 : // NameAndType
+ case 9: // Field
+ case 10: // Method
+ case 11: // InterfaceMethod
+ case 3: // Integer
+ case 4: // Float
+ case 12: // NameAndType
if (log.isDebugEnabled())
log.debug(i + " copying 4 bytes");
copy(4);
break;
- case 5 : // Long
- case 6 : // Double
+ case 5: // Long
+ case 6: // Double
if (log.isDebugEnabled())
log.debug(i + " copying 8 bytes");
copy(8);
i++;
break;
- case 1 : // Utf8
+ case 1: // Utf8
int len = readU2();
writeU2(len);
byte[] utf8 = readBytes(len);
@@ -468,7 +468,7 @@
}
writeBytes(utf8);
break;
- default :
+ default:
throw new IOException("unexpected tag: " + tag);
}
}
@@ -486,10 +486,10 @@
}
public static void evaluateNodes(
- Node.Nodes nodes,
- SmapStratum s,
- HashMap innerClassMap,
- boolean breakAtLF) {
+ Node.Nodes nodes,
+ SmapStratum s,
+ HashMap innerClassMap,
+ boolean breakAtLF) {
try {
nodes.visit(new SmapGenVisitor(s, breakAtLF, innerClassMap));
} catch (JasperException ex) {
@@ -616,9 +616,9 @@
//Add a LineInfo that corresponds to the beginning of this node
int iInputStartLine = mark.getLineNumber();
int iOutputStartLine = n.getBeginJavaLine();
- int iOutputLineIncrement = breakAtLF? 1: 0;
- smap.addLineData(iInputStartLine, fileName, 1, iOutputStartLine,
- iOutputLineIncrement);
+ int iOutputLineIncrement = breakAtLF ? 1 : 0;
+ smap.addLineData(iInputStartLine, fileName, 1, iOutputStartLine,
+ iOutputLineIncrement);
// Output additional mappings in the text
java.util.ArrayList extraSmap = n.getExtraSmap();
@@ -627,20 +627,20 @@
for (int i = 0; i < extraSmap.size(); i++) {
iOutputStartLine += iOutputLineIncrement;
smap.addLineData(
- iInputStartLine+((Integer)extraSmap.get(i)).intValue(),
- fileName,
- 1,
- iOutputStartLine,
- iOutputLineIncrement);
+ iInputStartLine + ((Integer) extraSmap.get(i)).intValue(),
+ fileName,
+ 1,
+ iOutputStartLine,
+ iOutputLineIncrement);
}
}
}
private void doSmap(
- Node n,
- int inLineCount,
- int outIncrement,
- int skippedLines) {
+ Node n,
+ int inLineCount,
+ int outIncrement,
+ int skippedLines) {
Mark mark = n.getStart();
if (mark == null) {
return;
@@ -649,11 +649,11 @@
String unqualifiedName = unqualify(mark.getFile());
smap.addFile(unqualifiedName, mark.getFile());
smap.addLineData(
- mark.getLineNumber() + skippedLines,
- mark.getFile(),
- inLineCount - skippedLines,
- n.getBeginJavaLine() + skippedLines,
- outIncrement);
+ mark.getLineNumber() + skippedLines,
+ mark.getFile(),
+ inLineCount - skippedLines,
+ n.getBeginJavaLine() + skippedLines,
+ outIncrement);
}
private void doSmap(Node n) {
@@ -718,5 +718,5 @@
return map;
}
}
-
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TagFileProcessor.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TagFileProcessor.java
index 8063958..25830cd 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TagFileProcessor.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TagFileProcessor.java
@@ -49,35 +49,35 @@
private static class TagFileDirectiveVisitor extends Node.Visitor {
private static final JspUtil.ValidAttribute[] tagDirectiveAttrs = {
- new JspUtil.ValidAttribute("display-name"),
- new JspUtil.ValidAttribute("body-content"),
- new JspUtil.ValidAttribute("dynamic-attributes"),
- new JspUtil.ValidAttribute("small-icon"),
- new JspUtil.ValidAttribute("large-icon"),
- new JspUtil.ValidAttribute("description"),
- new JspUtil.ValidAttribute("example"),
- new JspUtil.ValidAttribute("pageEncoding"),
- new JspUtil.ValidAttribute("language"),
- new JspUtil.ValidAttribute("import"),
- new JspUtil.ValidAttribute("isELIgnored") };
+ new JspUtil.ValidAttribute("display-name"),
+ new JspUtil.ValidAttribute("body-content"),
+ new JspUtil.ValidAttribute("dynamic-attributes"),
+ new JspUtil.ValidAttribute("small-icon"),
+ new JspUtil.ValidAttribute("large-icon"),
+ new JspUtil.ValidAttribute("description"),
+ new JspUtil.ValidAttribute("example"),
+ new JspUtil.ValidAttribute("pageEncoding"),
+ new JspUtil.ValidAttribute("language"),
+ new JspUtil.ValidAttribute("import"),
+ new JspUtil.ValidAttribute("isELIgnored")};
private static final JspUtil.ValidAttribute[] attributeDirectiveAttrs = {
- new JspUtil.ValidAttribute("name", true),
- new JspUtil.ValidAttribute("required"),
- new JspUtil.ValidAttribute("fragment"),
- new JspUtil.ValidAttribute("rtexprvalue"),
- new JspUtil.ValidAttribute("type"),
- new JspUtil.ValidAttribute("description")
+ new JspUtil.ValidAttribute("name", true),
+ new JspUtil.ValidAttribute("required"),
+ new JspUtil.ValidAttribute("fragment"),
+ new JspUtil.ValidAttribute("rtexprvalue"),
+ new JspUtil.ValidAttribute("type"),
+ new JspUtil.ValidAttribute("description")
};
private static final JspUtil.ValidAttribute[] variableDirectiveAttrs = {
- new JspUtil.ValidAttribute("name-given"),
- new JspUtil.ValidAttribute("name-from-attribute"),
- new JspUtil.ValidAttribute("alias"),
- new JspUtil.ValidAttribute("variable-class"),
- new JspUtil.ValidAttribute("scope"),
- new JspUtil.ValidAttribute("declare"),
- new JspUtil.ValidAttribute("description")
+ new JspUtil.ValidAttribute("name-given"),
+ new JspUtil.ValidAttribute("name-from-attribute"),
+ new JspUtil.ValidAttribute("alias"),
+ new JspUtil.ValidAttribute("variable-class"),
+ new JspUtil.ValidAttribute("scope"),
+ new JspUtil.ValidAttribute("declare"),
+ new JspUtil.ValidAttribute("description")
};
private ErrorDispatcher err;
@@ -93,20 +93,20 @@
private String largeIcon = null;
private String dynamicAttrsMapName;
private String example = null;
-
+
private Vector attributeVector;
private Vector variableVector;
private static final String ATTR_NAME =
- "the name attribute of the attribute directive";
+ "the name attribute of the attribute directive";
private static final String VAR_NAME_GIVEN =
- "the name-given attribute of the variable directive";
+ "the name-given attribute of the variable directive";
private static final String VAR_NAME_FROM =
- "the name-from-attribute attribute of the variable directive";
+ "the name-from-attribute attribute of the variable directive";
private static final String VAR_ALIAS =
- "the alias attribute of the variable directive";
+ "the alias attribute of the variable directive";
private static final String TAG_DYNAMIC =
- "the dynamic-attributes attribute of the tag directive";
+ "the dynamic-attributes attribute of the tag directive";
private HashMap nameTable = new HashMap();
private HashMap nameFromTable = new HashMap();
@@ -125,7 +125,7 @@
public void visit(Node.TagDirective n) throws JasperException {
JspUtil.checkAttributes("Tag directive", n, tagDirectiveAttrs,
- err);
+ err);
bodycontent = checkConflict(n, bodycontent, "body-content");
if (bodycontent != null &&
@@ -133,10 +133,10 @@
!bodycontent.equalsIgnoreCase(TagInfo.BODY_CONTENT_TAG_DEPENDENT) &&
!bodycontent.equalsIgnoreCase(TagInfo.BODY_CONTENT_SCRIPTLESS)) {
err.jspError(n, "jsp.error.tagdirective.badbodycontent",
- bodycontent);
+ bodycontent);
}
dynamicAttrsMapName = checkConflict(n, dynamicAttrsMapName,
- "dynamic-attributes");
+ "dynamic-attributes");
if (dynamicAttrsMapName != null) {
checkUniqueName(dynamicAttrsMapName, TAG_DYNAMIC, n);
}
@@ -155,29 +155,29 @@
if (attrValue != null) {
if (oldAttrValue != null && !oldAttrValue.equals(attrValue)) {
err.jspError(n, "jsp.error.tag.conflict.attr", attr,
- oldAttrValue, attrValue);
+ oldAttrValue, attrValue);
}
result = attrValue;
}
return result;
}
-
+
public void visit(Node.AttributeDirective n) throws JasperException {
JspUtil.checkAttributes("Attribute directive", n,
- attributeDirectiveAttrs, err);
+ attributeDirectiveAttrs, err);
String attrName = n.getAttributeValue("name");
boolean required = JspUtil.booleanValue(
- n.getAttributeValue("required"));
+ n.getAttributeValue("required"));
boolean rtexprvalue = true;
String rtexprvalueString = n.getAttributeValue("rtexprvalue");
if (rtexprvalueString != null) {
- rtexprvalue = JspUtil.booleanValue( rtexprvalueString );
+ rtexprvalue = JspUtil.booleanValue(rtexprvalueString);
}
boolean fragment = JspUtil.booleanValue(
- n.getAttributeValue("fragment"));
+ n.getAttributeValue("fragment"));
String type = n.getAttributeValue("type");
if (fragment) {
// type is fixed to "JspFragment" and a translation error
@@ -188,8 +188,8 @@
// rtexprvalue is fixed to "true" and a translation error
// must occur if specified.
rtexprvalue = true;
- if( rtexprvalueString != null ) {
- err.jspError(n, "jsp.error.frgmentwithrtexprvalue" );
+ if (rtexprvalueString != null) {
+ err.jspError(n, "jsp.error.frgmentwithrtexprvalue");
}
} else {
if (type == null)
@@ -198,7 +198,7 @@
TagAttributeInfo tagAttributeInfo =
new TagAttributeInfo(attrName, required, type, rtexprvalue,
- fragment);
+ fragment);
attributeVector.addElement(tagAttributeInfo);
checkUniqueName(attrName, ATTR_NAME, n, tagAttributeInfo);
}
@@ -206,7 +206,7 @@
public void visit(Node.VariableDirective n) throws JasperException {
JspUtil.checkAttributes("Variable directive", n,
- variableDirectiveAttrs, err);
+ variableDirectiveAttrs, err);
String nameGiven = n.getAttributeValue("name-given");
String nameFromAttribute = n.getAttributeValue("name-from-attribute");
@@ -220,7 +220,7 @@
String alias = n.getAttributeValue("alias");
if (nameFromAttribute != null && alias == null ||
- nameFromAttribute == null && alias != null) {
+ nameFromAttribute == null && alias != null) {
err.jspError("jsp.error.variable.alias");
}
@@ -255,18 +255,17 @@
nameGiven = alias;
checkUniqueName(nameFromAttribute, VAR_NAME_FROM, n);
checkUniqueName(alias, VAR_ALIAS, n);
- }
- else {
+ } else {
// name-given specified
checkUniqueName(nameGiven, VAR_NAME_GIVEN, n);
}
-
+
variableVector.addElement(new TagVariableInfo(
- nameGiven,
- nameFromAttribute,
- className,
- declare,
- scope));
+ nameGiven,
+ nameFromAttribute,
+ className,
+ declare,
+ scope));
}
/*
@@ -280,18 +279,18 @@
/*
* Returns the vector of variables corresponding to variable
* directives.
- */
+ */
public Vector getVariablesVector() {
return variableVector;
}
- /*
- * Returns the value of the dynamic-attributes tag directive
- * attribute.
- */
- public String getDynamicAttributesMapName() {
- return dynamicAttrsMapName;
- }
+ /*
+ * Returns the value of the dynamic-attributes tag directive
+ * attribute.
+ */
+ public String getDynamicAttributesMapName() {
+ return dynamicAttrsMapName;
+ }
public TagInfo getTagInfo() throws JasperException {
@@ -306,25 +305,25 @@
String tagClassName = JspUtil.getTagHandlerClassName(path, err);
TagVariableInfo[] tagVariableInfos
- = new TagVariableInfo[variableVector.size()];
+ = new TagVariableInfo[variableVector.size()];
variableVector.copyInto(tagVariableInfos);
TagAttributeInfo[] tagAttributeInfo
- = new TagAttributeInfo[attributeVector.size()];
+ = new TagAttributeInfo[attributeVector.size()];
attributeVector.copyInto(tagAttributeInfo);
return new JasperTagInfo(name,
- tagClassName,
- bodycontent,
- description,
- tagLibInfo,
- tei,
- tagAttributeInfo,
- displayName,
- smallIcon,
- largeIcon,
- tagVariableInfos,
- dynamicAttrsMapName);
+ tagClassName,
+ bodycontent,
+ description,
+ tagLibInfo,
+ tei,
+ tagAttributeInfo,
+ displayName,
+ smallIcon,
+ largeIcon,
+ tagVariableInfos,
+ dynamicAttrsMapName);
}
static class NameEntry {
@@ -338,23 +337,31 @@
this.attr = attr;
}
- String getType() { return type;}
- Node getNode() { return node; }
- TagAttributeInfo getTagAttributeInfo() { return attr; }
+ String getType() {
+ return type;
+ }
+
+ Node getNode() {
+ return node;
+ }
+
+ TagAttributeInfo getTagAttributeInfo() {
+ return attr;
+ }
}
/**
* Reports a translation error if names specified in attributes of
* directives are not unique in this translation unit.
- *
+ * <p/>
* The value of the following attributes must be unique.
- * 1. 'name' attribute of an attribute directive
- * 2. 'name-given' attribute of a variable directive
- * 3. 'alias' attribute of variable directive
- * 4. 'dynamic-attributes' of a tag directive
+ * 1. 'name' attribute of an attribute directive
+ * 2. 'name-given' attribute of a variable directive
+ * 3. 'alias' attribute of variable directive
+ * 4. 'dynamic-attributes' of a tag directive
* except that 'dynamic-attributes' can (and must) have the same
* value when it appears in multiple tag directives.
- *
+ * <p/>
* Also, 'name-from' attribute of a variable directive cannot have
* the same value as that from another variable directive.
*/
@@ -367,13 +374,13 @@
TagAttributeInfo attr)
throws JasperException {
- HashMap table = (type == VAR_NAME_FROM)? nameFromTable: nameTable;
+ HashMap table = (type == VAR_NAME_FROM) ? nameFromTable : nameTable;
NameEntry nameEntry = (NameEntry) table.get(name);
if (nameEntry != null) {
if (type != TAG_DYNAMIC || nameEntry.getType() != TAG_DYNAMIC) {
int line = nameEntry.getNode().getStart().getLineNumber();
err.jspError(n, "jsp.error.tagfile.nameNotUnique",
- type, nameEntry.getType(), Integer.toString(line));
+ type, nameEntry.getType(), Integer.toString(line));
}
} else {
table.put(name, new NameEntry(type, n, attr));
@@ -385,28 +392,28 @@
*/
void postCheck() throws JasperException {
// Check that var.name-from-attributes has valid values.
- Iterator iter = nameFromTable.keySet().iterator();
+ Iterator iter = nameFromTable.keySet().iterator();
while (iter.hasNext()) {
String nameFrom = (String) iter.next();
NameEntry nameEntry = (NameEntry) nameTable.get(nameFrom);
NameEntry nameFromEntry =
- (NameEntry) nameFromTable.get(nameFrom);
+ (NameEntry) nameFromTable.get(nameFrom);
Node nameFromNode = nameFromEntry.getNode();
if (nameEntry == null) {
err.jspError(nameFromNode,
- "jsp.error.tagfile.nameFrom.noAttribute",
- nameFrom);
+ "jsp.error.tagfile.nameFrom.noAttribute",
+ nameFrom);
} else {
Node node = nameEntry.getNode();
TagAttributeInfo tagAttr = nameEntry.getTagAttributeInfo();
- if (! "java.lang.String".equals(tagAttr.getTypeName())
- || ! tagAttr.isRequired()
- || tagAttr.canBeRequestTime()){
+ if (!"java.lang.String".equals(tagAttr.getTypeName())
+ || !tagAttr.isRequired()
+ || tagAttr.canBeRequestTime()) {
err.jspError(nameFromNode,
- "jsp.error.tagfile.nameFrom.badAttribute",
- nameFrom,
- Integer.toString(node.getStart().getLineNumber()));
- }
+ "jsp.error.tagfile.nameFrom.badAttribute",
+ nameFrom,
+ Integer.toString(node.getStart().getLineNumber()));
+ }
}
}
}
@@ -414,21 +421,21 @@
/**
* Parses the tag file, and collects information on the directives included
- * in it. The method is used to obtain the info on the tag file, when the
+ * in it. The method is used to obtain the info on the tag file, when the
* handler that it represents is referenced. The tag file is not compiled
* here.
*
- * @param pc the current ParserController used in this compilation
- * @param name the tag name as specified in the TLD
- * @param tagfile the path for the tagfile
+ * @param pc the current ParserController used in this compilation
+ * @param name the tag name as specified in the TLD
+ * @param tagfile the path for the tagfile
* @param tagLibInfo the TagLibraryInfo object associated with this TagInfo
* @return a TagInfo object assembled from the directives in the tag file.
*/
public static TagInfo parseTagFileDirectives(ParserController pc,
- String name,
- String path,
- TagLibraryInfo tagLibInfo)
- throws JasperException {
+ String name,
+ String path,
+ TagLibraryInfo tagLibInfo)
+ throws JasperException {
ErrorDispatcher err = pc.getCompiler().getErrorDispatcher();
@@ -442,8 +449,8 @@
}
TagFileDirectiveVisitor tagFileVisitor
- = new TagFileDirectiveVisitor(pc.getCompiler(), tagLibInfo, name,
- path);
+ = new TagFileDirectiveVisitor(pc.getCompiler(), tagLibInfo, name,
+ path);
page.visit(tagFileVisitor);
tagFileVisitor.postCheck();
@@ -456,29 +463,28 @@
private Class loadTagFile(Compiler compiler,
String tagFilePath, TagInfo tagInfo,
PageInfo parentPageInfo)
- throws JasperException {
+ throws JasperException {
JspCompilationContext ctxt = compiler.getCompilationContext();
JspRuntimeContext rctxt = ctxt.getRuntimeContext();
JspServletWrapper wrapper =
(JspServletWrapper) rctxt.getWrapper(tagFilePath);
- synchronized(rctxt) {
+ synchronized (rctxt) {
if (wrapper == null) {
wrapper = new JspServletWrapper(ctxt.getServletContext(),
- ctxt.getOptions(),
- tagFilePath,
- tagInfo,
- ctxt.getRuntimeContext(),
- (URL) ctxt.getTagFileJarUrls().get(tagFilePath));
- rctxt.addWrapper(tagFilePath,wrapper);
+ ctxt.getOptions(),
+ tagFilePath,
+ tagInfo,
+ ctxt.getRuntimeContext(),
+ (URL) ctxt.getTagFileJarUrls().get(tagFilePath));
+ rctxt.addWrapper(tagFilePath, wrapper);
- // Use same classloader and classpath for compiling tag files
- wrapper.getJspEngineContext().setClassLoader(
- (URLClassLoader) ctxt.getClassLoader());
- wrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
- }
- else {
+ // Use same classloader and classpath for compiling tag files
+ wrapper.getJspEngineContext().setClassLoader(
+ (URLClassLoader) ctxt.getClassLoader());
+ wrapper.getJspEngineContext().setClassPath(ctxt.getClassPath());
+ } else {
// Make sure that JspCompilationContext gets the latest TagInfo
// for the tag file. TagInfo instance was created the last
// time the tag file was scanned for directives, and the tag
@@ -496,38 +502,38 @@
// recursion.
JspServletWrapper tempWrapper
- = new JspServletWrapper(ctxt.getServletContext(),
- ctxt.getOptions(),
- tagFilePath,
- tagInfo,
- ctxt.getRuntimeContext(),
- (URL) ctxt.getTagFileJarUrls().get(tagFilePath));
+ = new JspServletWrapper(ctxt.getServletContext(),
+ ctxt.getOptions(),
+ tagFilePath,
+ tagInfo,
+ ctxt.getRuntimeContext(),
+ (URL) ctxt.getTagFileJarUrls().get(tagFilePath));
tagClazz = tempWrapper.loadTagFilePrototype();
tempVector.add(
- tempWrapper.getJspEngineContext().getCompiler());
+ tempWrapper.getJspEngineContext().getCompiler());
} else {
tagClazz = wrapper.loadTagFile();
}
} finally {
wrapper.decTripCount();
}
-
+
// Add the dependants for this tag file to its parent's
// dependant list. The only reliable dependency information
// can only be obtained from the tag instance.
try {
Object tagIns = tagClazz.newInstance();
if (tagIns instanceof JspSourceDependent) {
- Iterator iter =
- ((List) ((JspSourceDependent) tagIns).getDependants()).iterator();
+ Iterator iter =
+ ((List) ((JspSourceDependent) tagIns).getDependants()).iterator();
while (iter.hasNext()) {
- parentPageInfo.addDependant((String)iter.next());
+ parentPageInfo.addDependant((String) iter.next());
}
}
} catch (Exception e) {
// ignore errors
}
-
+
return tagClazz;
}
}
@@ -536,14 +542,14 @@
/*
* Visitor which scans the page and looks for tag handlers that are tag
* files, compiling (if necessary) and loading them.
- */
+ */
private class TagFileLoaderVisitor extends Node.Visitor {
private Compiler compiler;
private PageInfo pageInfo;
TagFileLoaderVisitor(Compiler compiler) {
-
+
this.compiler = compiler;
this.pageInfo = compiler.getPageInfo();
}
@@ -552,13 +558,13 @@
TagFileInfo tagFileInfo = n.getTagFileInfo();
if (tagFileInfo != null) {
String tagFilePath = tagFileInfo.getPath();
- JspCompilationContext ctxt = compiler.getCompilationContext();
- if (ctxt.getTagFileJarUrls().get(tagFilePath) == null) {
- // Omit tag file dependency info on jar files for now.
+ JspCompilationContext ctxt = compiler.getCompilationContext();
+ if (ctxt.getTagFileJarUrls().get(tagFilePath) == null) {
+ // Omit tag file dependency info on jar files for now.
pageInfo.addDependant(tagFilePath);
- }
+ }
Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(),
- pageInfo);
+ pageInfo);
n.setTagHandlerClass(c);
}
visitBody(n);
@@ -572,17 +578,18 @@
* in the CustomTag nodes.
*/
public void loadTagFiles(Compiler compiler, Node.Nodes page)
- throws JasperException {
+ throws JasperException {
tempVector = new Vector();
page.visit(new TagFileLoaderVisitor(compiler));
}
/**
- * Removed the java and class files for the tag prototype
+ * Removed the java and class files for the tag prototype
* generated from the current compilation.
+ *
* @param classFileName If non-null, remove only the class file with
- * with this name.
+ * with this name.
*/
public void removeProtoTypeFiles(String classFileName) {
Iterator iter = tempVector.iterator();
@@ -591,7 +598,7 @@
if (classFileName == null) {
c.removeGeneratedClassFiles();
} else if (classFileName.equals(
- c.getCompilationContext().getClassFileName())) {
+ c.getCompilationContext().getClassFileName())) {
c.removeGeneratedClassFiles();
tempVector.remove(c);
return;
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TagLibraryInfoImpl.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TagLibraryInfoImpl.java
index e29975e..a159530 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TagLibraryInfoImpl.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TagLibraryInfoImpl.java
@@ -17,8 +17,8 @@
package org.apache.struts2.jasper.compiler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.JasperException;
import org.apache.struts2.jasper.JspCompilationContext;
import org.apache.struts2.jasper.xmlparser.ParserUtils;
@@ -33,7 +33,7 @@
import java.util.zip.ZipEntry;
/**
- * Implementation of the TagLibraryInfo class from the JSP spec.
+ * Implementation of the TagLibraryInfo class from the JSP spec.
*
* @author Anil K. Vijendran
* @author Mandar Raje
@@ -44,7 +44,7 @@
class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants {
// Logger
- private Log log = LogFactory.getLog(TagLibraryInfoImpl.class);
+ private Logger log = LoggerFactory.getLogger(TagLibraryInfoImpl.class);
private Hashtable jarEntries;
private JspCompilationContext ctxt;
@@ -53,7 +53,7 @@
private final void print(String name, String value, PrintWriter w) {
if (value != null) {
- w.print(name+" = {\n\t");
+ w.print(name + " = {\n\t");
w.print(value);
w.print("\n}\n");
}
@@ -70,25 +70,24 @@
print("uri", uri, out);
print("tagLibraryValidator", "" + tagLibraryValidator, out);
- for(int i = 0; i < tags.length; i++)
+ for (int i = 0; i < tags.length; i++)
out.println(tags[i].toString());
-
- for(int i = 0; i < tagFiles.length; i++)
+
+ for (int i = 0; i < tagFiles.length; i++)
out.println(tagFiles[i].toString());
-
- for(int i = 0; i < functions.length; i++)
+
+ for (int i = 0; i < functions.length; i++)
out.println(functions[i].toString());
-
+
return sw.toString();
}
-
+
// XXX FIXME
// resolveRelativeUri and/or getResourceAsStream don't seem to properly
// handle relative paths when dealing when home and getDocBase are set
// the following is a workaround until these problems are resolved.
- private InputStream getResourceAsStream(String uri)
- throws FileNotFoundException
- {
+ private InputStream getResourceAsStream(String uri)
+ throws FileNotFoundException {
try {
// see if file exists on the filesystem first
String real = ctxt.getRealPath(uri);
@@ -103,7 +102,7 @@
// the context
return ctxt.getResourceAsStream(uri);
}
-
+
}
/**
@@ -111,7 +110,7 @@
*/
public TagLibraryInfoImpl(JspCompilationContext ctxt,
ParserController pc,
- String prefix,
+ String prefix,
String uriIn,
String[] location,
ErrorDispatcher err) throws JasperException {
@@ -152,7 +151,7 @@
try {
URL jarFileUrl = new URL("jar:" + location[0] + "!/");
JarURLConnection conn =
- (JarURLConnection) jarFileUrl.openConnection();
+ (JarURLConnection) jarFileUrl.openConnection();
conn.setUseCaches(false);
conn.connect();
jarFile = conn.getJarFile();
@@ -161,35 +160,36 @@
parseTLD(ctxt, location[0], in, jarFileUrl);
} catch (Exception ex) {
err.jspError("jsp.error.tld.unable_to_read", location[0],
- location[1], ex.toString());
+ location[1], ex.toString());
}
}
} finally {
if (in != null) {
try {
in.close();
- } catch (Throwable t) {}
+ } catch (Throwable t) {
+ }
}
if (jarFile != null) {
try {
jarFile.close();
- } catch (Throwable t) {}
+ } catch (Throwable t) {
+ }
}
}
}
-
+
/*
- * @param ctxt The JSP compilation context
- * @param uri The TLD's uri
- * @param in The TLD's input stream
- * @param jarFileUrl The JAR file containing the TLD, or null if the tag
- * library is not packaged in a JAR
- */
+ * @param ctxt The JSP compilation context
+ * @param uri The TLD's uri
+ * @param in The TLD's input stream
+ * @param jarFileUrl The JAR file containing the TLD, or null if the tag
+ * library is not packaged in a JAR
+ */
private void parseTLD(JspCompilationContext ctxt,
- String uri, InputStream in, URL jarFileUrl)
- throws JasperException
- {
+ String uri, InputStream in, URL jarFileUrl)
+ throws JasperException {
Vector tagVector = new Vector();
Vector tagFileVector = new Vector();
Hashtable functionTable = new Hashtable();
@@ -211,18 +211,18 @@
String tname = element.getName();
if ("tlibversion".equals(tname) // JSP 1.1
- || "tlib-version".equals(tname)) { // JSP 1.2
+ || "tlib-version".equals(tname)) { // JSP 1.2
this.tlibversion = element.getBody();
} else if ("jspversion".equals(tname)
- || "jsp-version".equals(tname)) {
+ || "jsp-version".equals(tname)) {
this.jspversion = element.getBody();
} else if ("shortname".equals(tname) ||
- "short-name".equals(tname))
+ "short-name".equals(tname))
this.shortname = element.getBody();
else if ("uri".equals(tname))
this.urn = element.getBody();
else if ("info".equals(tname) ||
- "description".equals(tname))
+ "description".equals(tname))
this.info = element.getBody();
else if ("validator".equals(tname))
this.tagLibraryValidator = createValidator(element);
@@ -230,21 +230,21 @@
tagVector.addElement(createTagInfo(element, jspversion));
else if ("tag-file".equals(tname)) {
TagFileInfo tagFileInfo = createTagFileInfo(element, uri,
- jarFileUrl);
+ jarFileUrl);
tagFileVector.addElement(tagFileInfo);
} else if ("function".equals(tname)) { // JSP2.0
FunctionInfo funcInfo = createFunctionInfo(element);
String funcName = funcInfo.getName();
if (functionTable.containsKey(funcName)) {
err.jspError("jsp.error.tld.fn.duplicate.name",
- funcName, uri);
+ funcName, uri);
}
functionTable.put(funcName, funcInfo);
} else if ("display-name".equals(tname) || // Ignored elements
- "small-icon".equals(tname) ||
- "large-icon".equals(tname) ||
- "listener".equals(tname)) {
+ "small-icon".equals(tname) ||
+ "large-icon".equals(tname) ||
+ "listener".equals(tname)) {
;
} else if ("taglib-extension".equals(tname)) {
// Recognized but ignored
@@ -258,45 +258,45 @@
}
if (tlibversion == null) {
- err.jspError("jsp.error.tld.mandatory.element.missing",
- "tlib-version");
+ err.jspError("jsp.error.tld.mandatory.element.missing",
+ "tlib-version");
}
if (jspversion == null) {
err.jspError("jsp.error.tld.mandatory.element.missing",
- "jsp-version");
+ "jsp-version");
}
this.tags = new TagInfo[tagVector.size()];
- tagVector.copyInto (this.tags);
+ tagVector.copyInto(this.tags);
this.tagFiles = new TagFileInfo[tagFileVector.size()];
- tagFileVector.copyInto (this.tagFiles);
+ tagFileVector.copyInto(this.tagFiles);
this.functions = new FunctionInfo[functionTable.size()];
- int i=0;
+ int i = 0;
Enumeration enumeration = functionTable.elements();
while (enumeration.hasMoreElements()) {
this.functions[i++] = (FunctionInfo) enumeration.nextElement();
}
}
-
+
/*
- * @param uri The uri of the TLD
- * @param ctxt The compilation context
- *
- * @return String array whose first element denotes the 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, which is hardcoded
- * to META-INF/taglib.tld.
- */
+ * @param uri The uri of the TLD
+ * @param ctxt The compilation context
+ *
+ * @return String array whose first element denotes the 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, which is hardcoded
+ * to META-INF/taglib.tld.
+ */
private String[] generateTLDLocation(String uri,
JspCompilationContext ctxt)
- throws JasperException {
+ throws JasperException {
int uriType = TldLocationsCache.uriType(uri);
if (uriType == TldLocationsCache.ABS_URI) {
err.jspError("jsp.error.taglibDirective.absUriCannotBeResolved",
- uri);
+ uri);
} else if (uriType == TldLocationsCache.NOROOT_REL_URI) {
//TODO: implement for tld
//uri = ctxt.resolveRelativeUri(uri);
@@ -310,7 +310,7 @@
url = ctxt.getResource(location[0]);
} catch (Exception ex) {
err.jspError("jsp.error.tld.unable_to_get_jar", location[0],
- ex.toString());
+ ex.toString());
}
if (url == null) {
err.jspError("jsp.error.tld.missing_jar", location[0]);
@@ -341,7 +341,7 @@
String smallIcon = null;
String largeIcon = null;
boolean dynamicAttributes = false;
-
+
Vector attributeVector = new Vector();
Vector variableVector = new Vector();
Iterator list = elem.findChildren();
@@ -352,13 +352,13 @@
if ("name".equals(tname)) {
tagName = element.getBody();
} else if ("tagclass".equals(tname) ||
- "tag-class".equals(tname)) {
+ "tag-class".equals(tname)) {
tagClassName = element.getBody();
} else if ("teiclass".equals(tname) ||
- "tei-class".equals(tname)) {
+ "tei-class".equals(tname)) {
teiClassName = element.getBody();
} else if ("bodycontent".equals(tname) ||
- "body-content".equals(tname)) {
+ "body-content".equals(tname)) {
bodycontent = element.getBody();
} else if ("display-name".equals(tname)) {
displayName = element.getBody();
@@ -376,7 +376,7 @@
largeIcon = icon.getBody();
}
} else if ("info".equals(tname) ||
- "description".equals(tname)) {
+ "description".equals(tname)) {
info = element.getBody();
} else if ("variable".equals(tname)) {
variableVector.addElement(createVariable(element));
@@ -403,30 +403,30 @@
tei = (TagExtraInfo) teiClass.newInstance();
} catch (Exception e) {
err.jspError("jsp.error.teiclass.instantiation", teiClassName,
- e);
+ e);
}
}
TagAttributeInfo[] tagAttributeInfo
- = new TagAttributeInfo[attributeVector.size()];
+ = new TagAttributeInfo[attributeVector.size()];
attributeVector.copyInto(tagAttributeInfo);
TagVariableInfo[] tagVariableInfos
- = new TagVariableInfo[variableVector.size()];
+ = new TagVariableInfo[variableVector.size()];
variableVector.copyInto(tagVariableInfos);
TagInfo taginfo = new TagInfo(tagName,
- tagClassName,
- bodycontent,
- info,
- this,
- tei,
- tagAttributeInfo,
- displayName,
- smallIcon,
- largeIcon,
- tagVariableInfos,
- dynamicAttributes);
+ tagClassName,
+ bodycontent,
+ info,
+ this,
+ tei,
+ tagAttributeInfo,
+ displayName,
+ smallIcon,
+ largeIcon,
+ tagVariableInfos,
+ dynamicAttributes);
return taginfo;
}
@@ -443,7 +443,7 @@
*/
private TagFileInfo createTagFileInfo(TreeNode elem, String uri,
URL jarFileUrl)
- throws JasperException {
+ throws JasperException {
String name = null;
String path = null;
@@ -461,8 +461,8 @@
} else if ("tag-extension".equals(tname)) {
// Ignore <tag-extension> element: Bugzilla 33538
} else if ("icon".equals(tname) ||
- "display-name".equals(tname) ||
- "description".equals(tname)) {
+ "display-name".equals(tname) ||
+ "description".equals(tname)) {
// Ignore these elements: Bugzilla 38015
} else {
if (log.isWarnEnabled()) {
@@ -484,8 +484,8 @@
}
TagInfo tagInfo
- = TagFileProcessor.parseTagFileDirectives(parserController, name,
- path, this);
+ = TagFileProcessor.parseTagFileDirectives(parserController, name,
+ path, this);
return new TagFileInfo(name, path, tagInfo);
}
@@ -493,8 +493,8 @@
String name = null;
String type = null;
boolean required = false, rtexprvalue = false, reqTime = false,
- isFragment = false;
-
+ isFragment = false;
+
Iterator list = elem.findChildren();
while (list.hasNext()) {
TreeNode element = (TreeNode) list.next();
@@ -514,15 +514,15 @@
type = element.getBody();
if ("1.2".equals(jspVersion)
&& (type.equals("Boolean")
- || type.equals("Byte")
- || type.equals("Character")
- || type.equals("Double")
- || type.equals("Float")
- || type.equals("Integer")
- || type.equals("Long")
- || type.equals("Object")
- || type.equals("Short")
- || type.equals("String"))) {
+ || type.equals("Byte")
+ || type.equals("Character")
+ || type.equals("Double")
+ || type.equals("Float")
+ || type.equals("Integer")
+ || type.equals("Long")
+ || type.equals("Object")
+ || type.equals("Short")
+ || type.equals("String"))) {
type = "java.lang." + type;
}
} else if ("fragment".equals(tname)) {
@@ -531,7 +531,7 @@
isFragment = JspUtil.booleanValue(s);
}
} else if ("description".equals(tname) || // Ignored elements
- false) {
+ false) {
;
} else {
if (log.isWarnEnabled()) {
@@ -551,9 +551,9 @@
* fixed at true. See also JSP.8.5.2.
*/
type = "javax.servlet.jsp.tagext.JspFragment";
- rtexprvalue = true;
+ rtexprvalue = true;
}
-
+
if (!rtexprvalue) {
// According to JSP spec, for static values (those determined at
// translation time) the type is fixed at java.lang.String.
@@ -561,7 +561,7 @@
}
return new TagAttributeInfo(name, required, type, rtexprvalue,
- isFragment);
+ isFragment);
}
TagVariableInfo createVariable(TreeNode elem) {
@@ -597,7 +597,7 @@
}
}
} else if ("description".equals(tname) || // Ignored elements
- false ) {
+ false) {
} else {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage(
@@ -606,7 +606,7 @@
}
}
return new TagVariableInfo(nameGiven, nameFromAttribute,
- className, declare, scope);
+ className, declare, scope);
}
private TagLibraryValidator createValidator(TreeNode elem)
@@ -625,7 +625,7 @@
String[] initParam = createInitParam(element);
initParams.put(initParam[0], initParam[1]);
} else if ("description".equals(tname) || // Ignored elements
- false ) {
+ false) {
} else {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage(
@@ -637,12 +637,12 @@
TagLibraryValidator tlv = null;
if (validatorClass != null && !validatorClass.equals("")) {
try {
- Class tlvClass =
- ctxt.getClassLoader().loadClass(validatorClass);
- tlv = (TagLibraryValidator)tlvClass.newInstance();
+ Class tlvClass =
+ ctxt.getClassLoader().loadClass(validatorClass);
+ tlv = (TagLibraryValidator) tlvClass.newInstance();
} catch (Exception e) {
err.jspError("jsp.error.tlvclass.instantiation",
- validatorClass, e);
+ validatorClass, e);
}
}
if (tlv != null) {
@@ -653,7 +653,7 @@
String[] createInitParam(TreeNode elem) {
String[] initParam = new String[2];
-
+
Iterator list = elem.findChildren();
while (list.hasNext()) {
TreeNode element = (TreeNode) list.next();
@@ -692,14 +692,14 @@
} else if ("function-signature".equals(tname)) {
signature = element.getBody();
} else if ("display-name".equals(tname) || // Ignored elements
- "small-icon".equals(tname) ||
- "large-icon".equals(tname) ||
- "description".equals(tname) ||
- "example".equals(tname)) {
+ "small-icon".equals(tname) ||
+ "large-icon".equals(tname) ||
+ "description".equals(tname) ||
+ "example".equals(tname)) {
} else {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage(
- "jsp.warning.unknown.element.in.function", tname));
+ "jsp.warning.unknown.element.in.function", tname));
}
}
}
@@ -713,7 +713,7 @@
/**
* The instance (if any) for the TagLibraryValidator class.
- *
+ *
* @return The TagLibraryValidator instance, if any.
*/
public TagLibraryValidator getTagLibraryValidator() {
@@ -723,7 +723,7 @@
/**
* Translation-time validation of the XML document
* associated with the JSP page.
- * This is a convenience method on the associated
+ * This is a convenience method on the associated
* TagLibraryValidator class.
*
* @param thePage The JSP page object
@@ -741,5 +741,5 @@
return tlv.validate(getPrefixString(), uri, thePage);
}
- protected TagLibraryValidator tagLibraryValidator;
+ protected TagLibraryValidator tagLibraryValidator;
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TagPluginManager.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TagPluginManager.java
index 74c713c..e98059f 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TagPluginManager.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TagPluginManager.java
@@ -30,6 +30,7 @@
/**
* Manages tag plugin optimizations.
+ *
* @author Kin-man Chung
*/
@@ -44,18 +45,18 @@
private PageInfo pageInfo;
public TagPluginManager(ServletContext ctxt) {
- this.ctxt = ctxt;
+ this.ctxt = ctxt;
}
public void apply(Node.Nodes page, ErrorDispatcher err, PageInfo pageInfo)
- throws JasperException {
+ throws JasperException {
- init(err);
- if (tagPlugins == null || tagPlugins.size() == 0) {
- return;
- }
+ init(err);
+ if (tagPlugins == null || tagPlugins.size() == 0) {
+ return;
+ }
- this.pageInfo = pageInfo;
+ this.pageInfo = pageInfo;
page.visit(new Node.Visitor() {
public void visit(Node.CustomTag n)
@@ -66,176 +67,176 @@
});
}
-
+
private void init(ErrorDispatcher err) throws JasperException {
- if (initialized)
- return;
+ if (initialized)
+ return;
- InputStream is = ctxt.getResourceAsStream(TAG_PLUGINS_XML);
- if (is == null)
- return;
+ InputStream is = ctxt.getResourceAsStream(TAG_PLUGINS_XML);
+ if (is == null)
+ return;
- TreeNode root = (new ParserUtils()).parseXMLDocument(TAG_PLUGINS_XML,
- is);
- if (root == null) {
- return;
- }
+ TreeNode root = (new ParserUtils()).parseXMLDocument(TAG_PLUGINS_XML,
+ is);
+ if (root == null) {
+ return;
+ }
- if (!TAG_PLUGINS_ROOT_ELEM.equals(root.getName())) {
- err.jspError("jsp.error.plugin.wrongRootElement", TAG_PLUGINS_XML,
- TAG_PLUGINS_ROOT_ELEM);
- }
+ if (!TAG_PLUGINS_ROOT_ELEM.equals(root.getName())) {
+ err.jspError("jsp.error.plugin.wrongRootElement", TAG_PLUGINS_XML,
+ TAG_PLUGINS_ROOT_ELEM);
+ }
- tagPlugins = new HashMap();
- Iterator pluginList = root.findChildren("tag-plugin");
- while (pluginList.hasNext()) {
- TreeNode pluginNode = (TreeNode) pluginList.next();
+ tagPlugins = new HashMap();
+ Iterator pluginList = root.findChildren("tag-plugin");
+ while (pluginList.hasNext()) {
+ TreeNode pluginNode = (TreeNode) pluginList.next();
TreeNode tagClassNode = pluginNode.findChild("tag-class");
- if (tagClassNode == null) {
- // Error
- return;
- }
- String tagClass = tagClassNode.getBody().trim();
- TreeNode pluginClassNode = pluginNode.findChild("plugin-class");
- if (pluginClassNode == null) {
- // Error
- return;
- }
+ if (tagClassNode == null) {
+ // Error
+ return;
+ }
+ String tagClass = tagClassNode.getBody().trim();
+ TreeNode pluginClassNode = pluginNode.findChild("plugin-class");
+ if (pluginClassNode == null) {
+ // Error
+ return;
+ }
- String pluginClassStr = pluginClassNode.getBody();
- TagPlugin tagPlugin = null;
- try {
- Class pluginClass = Class.forName(pluginClassStr);
- tagPlugin = (TagPlugin) pluginClass.newInstance();
- } catch (Exception e) {
- throw new JasperException(e);
- }
- if (tagPlugin == null) {
- return;
- }
- tagPlugins.put(tagClass, tagPlugin);
- }
- initialized = true;
+ String pluginClassStr = pluginClassNode.getBody();
+ TagPlugin tagPlugin = null;
+ try {
+ Class pluginClass = Class.forName(pluginClassStr);
+ tagPlugin = (TagPlugin) pluginClass.newInstance();
+ } catch (Exception e) {
+ throw new JasperException(e);
+ }
+ if (tagPlugin == null) {
+ return;
+ }
+ tagPlugins.put(tagClass, tagPlugin);
+ }
+ initialized = true;
}
/**
- * Invoke tag plugin for the given custom tag, if a plugin exists for
+ * Invoke tag plugin for the given custom tag, if a plugin exists for
* the custom tag's tag handler.
- *
+ * <p/>
* The given custom tag node will be manipulated by the plugin.
*/
private void invokePlugin(Node.CustomTag n) {
- TagPlugin tagPlugin = (TagPlugin)
- tagPlugins.get(n.getTagHandlerClass().getName());
- if (tagPlugin == null) {
- return;
- }
+ TagPlugin tagPlugin = (TagPlugin)
+ tagPlugins.get(n.getTagHandlerClass().getName());
+ if (tagPlugin == null) {
+ return;
+ }
- TagPluginContext tagPluginContext = new TagPluginContextImpl(n, pageInfo);
- n.setTagPluginContext(tagPluginContext);
- tagPlugin.doTag(tagPluginContext);
+ TagPluginContext tagPluginContext = new TagPluginContextImpl(n, pageInfo);
+ n.setTagPluginContext(tagPluginContext);
+ tagPlugin.doTag(tagPluginContext);
}
static class TagPluginContextImpl implements TagPluginContext {
- private Node.CustomTag node;
- private Node.Nodes curNodes;
- private PageInfo pageInfo;
- private HashMap pluginAttributes;
+ private Node.CustomTag node;
+ private Node.Nodes curNodes;
+ private PageInfo pageInfo;
+ private HashMap pluginAttributes;
- TagPluginContextImpl(Node.CustomTag n, PageInfo pageInfo) {
- this.node = n;
- this.pageInfo = pageInfo;
- curNodes = new Node.Nodes();
- n.setAtETag(curNodes);
- curNodes = new Node.Nodes();
- n.setAtSTag(curNodes);
- n.setUseTagPlugin(true);
- pluginAttributes = new HashMap();
- }
+ TagPluginContextImpl(Node.CustomTag n, PageInfo pageInfo) {
+ this.node = n;
+ this.pageInfo = pageInfo;
+ curNodes = new Node.Nodes();
+ n.setAtETag(curNodes);
+ curNodes = new Node.Nodes();
+ n.setAtSTag(curNodes);
+ n.setUseTagPlugin(true);
+ pluginAttributes = new HashMap();
+ }
- public TagPluginContext getParentContext() {
- Node parent = node.getParent();
- if (! (parent instanceof Node.CustomTag)) {
- return null;
- }
- return ((Node.CustomTag) parent).getTagPluginContext();
- }
+ public TagPluginContext getParentContext() {
+ Node parent = node.getParent();
+ if (!(parent instanceof Node.CustomTag)) {
+ return null;
+ }
+ return ((Node.CustomTag) parent).getTagPluginContext();
+ }
- public void setPluginAttribute(String key, Object value) {
- pluginAttributes.put(key, value);
- }
+ public void setPluginAttribute(String key, Object value) {
+ pluginAttributes.put(key, value);
+ }
- public Object getPluginAttribute(String key) {
- return pluginAttributes.get(key);
- }
+ public Object getPluginAttribute(String key) {
+ return pluginAttributes.get(key);
+ }
- public boolean isScriptless() {
- return node.getChildInfo().isScriptless();
- }
+ public boolean isScriptless() {
+ return node.getChildInfo().isScriptless();
+ }
- public boolean isConstantAttribute(String attribute) {
- Node.JspAttribute attr = getNodeAttribute(attribute);
- if (attr == null)
- return false;
- return attr.isLiteral();
- }
-
- public String getConstantAttribute(String attribute) {
- Node.JspAttribute attr = getNodeAttribute(attribute);
+ public boolean isConstantAttribute(String attribute) {
+ Node.JspAttribute attr = getNodeAttribute(attribute);
if (attr == null)
- return null;
- return attr.getValue();
- }
+ return false;
+ return attr.isLiteral();
+ }
- public boolean isAttributeSpecified(String attribute) {
- return getNodeAttribute(attribute) != null;
- }
+ public String getConstantAttribute(String attribute) {
+ Node.JspAttribute attr = getNodeAttribute(attribute);
+ if (attr == null)
+ return null;
+ return attr.getValue();
+ }
- public String getTemporaryVariableName() {
- return JspUtil.nextTemporaryVariableName();
- }
+ public boolean isAttributeSpecified(String attribute) {
+ return getNodeAttribute(attribute) != null;
+ }
- public void generateImport(String imp) {
- pageInfo.addImport(imp);
- }
+ public String getTemporaryVariableName() {
+ return JspUtil.nextTemporaryVariableName();
+ }
- public void generateDeclaration(String id, String text) {
- if (pageInfo.isPluginDeclared(id)) {
- return;
- }
- curNodes.add(new Node.Declaration(text, node.getStart(), null));
- }
+ public void generateImport(String imp) {
+ pageInfo.addImport(imp);
+ }
- public void generateJavaSource(String sourceCode) {
- curNodes.add(new Node.Scriptlet(sourceCode, node.getStart(),
- null));
- }
+ public void generateDeclaration(String id, String text) {
+ if (pageInfo.isPluginDeclared(id)) {
+ return;
+ }
+ curNodes.add(new Node.Declaration(text, node.getStart(), null));
+ }
- public void generateAttribute(String attributeName) {
- curNodes.add(new Node.AttributeGenerator(node.getStart(),
- attributeName,
- node));
- }
+ public void generateJavaSource(String sourceCode) {
+ curNodes.add(new Node.Scriptlet(sourceCode, node.getStart(),
+ null));
+ }
- public void dontUseTagPlugin() {
- node.setUseTagPlugin(false);
- }
+ public void generateAttribute(String attributeName) {
+ curNodes.add(new Node.AttributeGenerator(node.getStart(),
+ attributeName,
+ node));
+ }
- public void generateBody() {
- // Since we'll generate the body anyway, this is really a nop,
- // except for the fact that it lets us put the Java sources the
- // plugins produce in the correct order (w.r.t the body).
- curNodes = node.getAtETag();
- }
+ public void dontUseTagPlugin() {
+ node.setUseTagPlugin(false);
+ }
- private Node.JspAttribute getNodeAttribute(String attribute) {
- Node.JspAttribute[] attrs = node.getJspAttributes();
- for (int i=0; attrs != null && i < attrs.length; i++) {
- if (attrs[i].getName().equals(attribute)) {
- return attrs[i];
- }
- }
- return null;
- }
+ public void generateBody() {
+ // Since we'll generate the body anyway, this is really a nop,
+ // except for the fact that it lets us put the Java sources the
+ // plugins produce in the correct order (w.r.t the body).
+ curNodes = node.getAtETag();
+ }
+
+ private Node.JspAttribute getNodeAttribute(String attribute) {
+ Node.JspAttribute[] attrs = node.getJspAttributes();
+ for (int i = 0; attrs != null && i < attrs.length; i++) {
+ if (attrs[i].getName().equals(attribute)) {
+ return attrs[i];
+ }
+ }
+ return null;
+ }
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TextOptimizer.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TextOptimizer.java
index cd9ab29..bd151d1 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TextOptimizer.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TextOptimizer.java
@@ -42,9 +42,9 @@
collectText();
}
- /*
- * The following directis are ignored in text concatenation
- */
+ /*
+ * The following directis are ignored in text concatenation
+ */
public void visit(Node.PageDirective n) throws JasperException {
}
@@ -88,7 +88,7 @@
/**
* This method breaks concatenation mode. As a side effect it copies
- * the concatenated string to the first text node
+ * the concatenated string to the first text node
*/
private void collectText() {
@@ -107,7 +107,7 @@
TextCatVisitor v = new TextCatVisitor(compiler);
page.visit(v);
- // Cleanup, in case the page ends with a template text
+ // Cleanup, in case the page ends with a template text
v.collectText();
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TldLocationsCache.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TldLocationsCache.java
index 3e77cef..faaea3e 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TldLocationsCache.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/TldLocationsCache.java
@@ -17,9 +17,9 @@
package org.apache.struts2.jasper.compiler;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.struts2.jasper.Constants;
import org.apache.struts2.jasper.JasperException;
import org.apache.struts2.jasper.xmlparser.ParserUtils;
@@ -37,16 +37,16 @@
/**
* A container for all tag libraries that are defined "globally"
* for the web application.
- *
+ * <p/>
* Tag Libraries can be defined globally in one of two ways:
- * 1. Via <taglib> elements in web.xml:
- * the uri and location of the tag-library are specified in
- * the <taglib> element.
- * 2. Via packaged jar files that contain .tld files
- * within the META-INF directory, or some subdirectory
- * of it. The taglib is 'global' if it has the <uri>
- * element defined.
- *
+ * 1. Via <taglib> elements in web.xml:
+ * the uri and location of the tag-library are specified in
+ * the <taglib> element.
+ * 2. Via packaged jar files that contain .tld files
+ * within the META-INF directory, or some subdirectory
+ * of it. The taglib is 'global' if it has the <uri>
+ * element defined.
+ * <p/>
* A mapping between the taglib URI and its associated TaglibraryInfoImpl
* is maintained in this container.
* Actually, that's what we'd like to do. However, because of the
@@ -55,7 +55,7 @@
* across page invocations. A bug has been submitted to the spec lead.
* In the mean time, all we do is save the 'location' where the
* TLD associated with a taglib URI can be found.
- *
+ * <p/>
* When a JSP page has a taglib directive, the mappings in this container
* are first searched (see method getLocation()).
* If a mapping is found, then the location of the TLD is returned.
@@ -70,7 +70,7 @@
public class TldLocationsCache {
// Logger
- private Log log = LogFactory.getLog(TldLocationsCache.class);
+ private Logger log = LoggerFactory.getLogger(TldLocationsCache.class);
/**
* The types of URI one may specify for a tag library
@@ -90,8 +90,8 @@
* The mapping of the 'global' tag library URI to the location (resource
* path) of the TLD associated with that tag library. The location is
* returned as a String array:
- * [0] The location
- * [1] If the location is a jar file, this is the location of the tld.
+ * [0] The location
+ * [1] If the location is a jar file, this is the location of the tld.
*/
private Hashtable mappings;
@@ -105,6 +105,7 @@
/*
* Initializes the set of JARs that are known not to contain any TLDs
*/
+
static {
noTldJars = new HashSet();
noTldJars.add("ant.jar");
@@ -157,20 +158,21 @@
noTldJars.add("localedata.jar");
noTldJars.add("dnsns.jar");
}
-
+
public TldLocationsCache(ServletContext ctxt) {
this(ctxt, true);
}
- /** Constructor.
+ /**
+ * Constructor.
*
- * @param ctxt the servlet context of the web application in which Jasper
- * is running
- * @param redeployMode if true, then the compiler will allow redeploying
- * a tag library from the same jar, at the expense of slowing down the
- * server a bit. Note that this may only work on JDK 1.3.1_01a and later,
- * because of JDK bug 4211817 fixed in this release.
- * If redeployMode is false, a faster but less capable mode will be used.
+ * @param ctxt the servlet context of the web application in which Jasper
+ * is running
+ * @param redeployMode if true, then the compiler will allow redeploying
+ * a tag library from the same jar, at the expense of slowing down the
+ * server a bit. Note that this may only work on JDK 1.3.1_01a and later,
+ * because of JDK bug 4211817 fixed in this release.
+ * If redeployMode is false, a faster but less capable mode will be used.
*/
public TldLocationsCache(ServletContext ctxt, boolean redeployMode) {
this.ctxt = ctxt;
@@ -182,8 +184,8 @@
/**
* Sets the list of JARs that are known not to contain any TLDs.
*
- * @param jarNames List of comma-separated names of JAR files that are
- * known not to contain any TLDs
+ * @param jarNames List of comma-separated names of JAR files that are
+ * known not to contain any TLDs
*/
public static void setNoTldJars(String jarNames) {
if (jarNames != null) {
@@ -197,19 +199,18 @@
/**
* Gets the 'location' of the TLD associated with the given taglib 'uri'.
- *
+ * <p/>
* Returns null if the uri is not associated with any tag library 'exposed'
* in the web application. A tag library is 'exposed' either explicitly in
* web.xml or implicitly via the uri tag in the TLD of a taglib deployed
* in a jar file (WEB-INF/lib).
- *
- * @param uri The taglib uri
*
+ * @param uri The taglib uri
* @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 uri is not associated with any tag library 'exposed'
- * in the web application.
+ * 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 uri is not associated with any tag library 'exposed'
+ * in the web application.
*/
public String[] getLocation(String uri) throws JasperException {
if (!initialized) {
@@ -236,11 +237,11 @@
return paths;
}
- /**
+ /**
* Returns the type of a URI:
- * ABS_URI
- * ROOT_REL_URI
- * NOROOT_REL_URI
+ * ABS_URI
+ * ROOT_REL_URI
+ * NOROOT_REL_URI
*/
public static int uriType(String uri) {
if (uri.indexOf(':') != -1) {
@@ -267,33 +268,28 @@
/*
* Populates taglib map described in web.xml.
- */
+ */
private void processWebDotXml() throws Exception {
InputStream is = null;
try {
// Acquire input stream to web application deployment descriptor
- String altDDName = (String)ctxt.getAttribute(
- Constants.ALT_DD_ATTR);
+ String altDDName = (String) ctxt.getAttribute(
+ Constants.ALT_DD_ATTR);
URL uri = null;
if (altDDName != null) {
try {
- uri = new URL(FILE_PROTOCOL+altDDName.replace('\\', '/'));
+ uri = new URL(FILE_PROTOCOL + altDDName.replace('\\', '/'));
} catch (MalformedURLException e) {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage(
- "jsp.error.internal.filenotfound",
- altDDName));
+ "jsp.error.internal.filenotfound",
+ altDDName));
}
}
} else {
uri = ctxt.getResource(WEB_XML);
- if (uri == null && log.isWarnEnabled()) {
- log.warn(Localizer.getMessage(
- "jsp.error.internal.filenotfound",
- WEB_XML));
- }
}
if (uri == null) {
@@ -301,7 +297,7 @@
}
is = uri.openStream();
InputSource ip = new InputSource(is);
- ip.setSystemId(uri.toExternalForm());
+ ip.setSystemId(uri.toExternalForm());
// Parse the web application deployment descriptor
TreeNode webtld = null;
@@ -341,13 +337,14 @@
tagLoc = ctxt.getResource(tagLoc).toString();
tagLoc2 = "META-INF/taglib.tld";
}
- mappings.put(tagUri, new String[] { tagLoc, tagLoc2 });
+ mappings.put(tagUri, new String[]{tagLoc, tagLoc2});
}
} finally {
if (is != null) {
try {
is.close();
- } catch (Throwable t) {}
+ } catch (Throwable t) {
+ }
}
}
}
@@ -357,12 +354,12 @@
* (or a subdirectory of it), adding an implicit map entry to the taglib
* map for any TLD that has a <uri> element.
*
- * @param conn The JarURLConnection to the JAR file to scan
+ * @param conn The JarURLConnection to the JAR file to scan
* @param ignore true if any exceptions raised when processing the given
- * JAR should be ignored, false otherwise
+ * JAR should be ignored, false otherwise
*/
private void scanJar(JarURLConnection conn, boolean ignore)
- throws JasperException {
+ throws JasperException {
JarFile jarFile = null;
String resourcePath = conn.getJarFileURL().toString();
@@ -383,7 +380,7 @@
// Add implicit map entry only if its uri is not already
// present in the map
if (uri != null && mappings.get(uri) == null) {
- mappings.put(uri, new String[]{ resourcePath, name });
+ mappings.put(uri, new String[]{resourcePath, name});
}
} finally {
if (stream != null) {
@@ -458,7 +455,7 @@
// Add implicit map entry only if its uri is not already
// present in the map
if (uri != null && mappings.get(uri) == null) {
- mappings.put(uri, new String[] { path, null });
+ mappings.put(uri, new String[]{path, null});
}
}
}
@@ -468,9 +465,8 @@
* Returns the value of the uri element of the given TLD, or null if the
* given TLD does not contain any such element.
*/
- private String getUriFromTld(String resourcePath, InputStream in)
- throws JasperException
- {
+ private String getUriFromTld(String resourcePath, InputStream in)
+ throws JasperException {
// Parse the tag library descriptor at the specified resource path
TreeNode tld = new ParserUtils().parseXMLDocument(resourcePath, in);
TreeNode uri = tld.findChild("uri");
@@ -505,17 +501,17 @@
private void scanJars() throws Exception {
ClassLoader webappLoader
- = Thread.currentThread().getContextClassLoader();
+ = Thread.currentThread().getContextClassLoader();
ClassLoader loader = webappLoader;
while (loader != null) {
if (loader instanceof URLClassLoader) {
URL[] urls = ((URLClassLoader) loader).getURLs();
- for (int i=0; i<urls.length; i++) {
+ for (int i = 0; i < urls.length; i++) {
URLConnection conn = urls[i].openConnection();
if (conn instanceof JarURLConnection) {
if (needScanJar(loader, webappLoader,
- ((JarURLConnection) conn).getJarFile().getName())) {
+ ((JarURLConnection) conn).getJarFile().getName())) {
scanJar((JarURLConnection) conn, true);
}
} else {
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Validator.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Validator.java
index d0c72c5..bedfd6c 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Validator.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/Validator.java
@@ -51,19 +51,19 @@
private ErrorDispatcher err;
private static final JspUtil.ValidAttribute[] pageDirectiveAttrs = {
- new JspUtil.ValidAttribute("language"),
- new JspUtil.ValidAttribute("extends"),
- new JspUtil.ValidAttribute("import"),
- new JspUtil.ValidAttribute("session"),
- new JspUtil.ValidAttribute("buffer"),
- new JspUtil.ValidAttribute("autoFlush"),
- new JspUtil.ValidAttribute("isThreadSafe"),
- new JspUtil.ValidAttribute("info"),
- new JspUtil.ValidAttribute("errorPage"),
- new JspUtil.ValidAttribute("isErrorPage"),
- new JspUtil.ValidAttribute("contentType"),
- new JspUtil.ValidAttribute("pageEncoding"),
- new JspUtil.ValidAttribute("isELIgnored")
+ new JspUtil.ValidAttribute("language"),
+ new JspUtil.ValidAttribute("extends"),
+ new JspUtil.ValidAttribute("import"),
+ new JspUtil.ValidAttribute("session"),
+ new JspUtil.ValidAttribute("buffer"),
+ new JspUtil.ValidAttribute("autoFlush"),
+ new JspUtil.ValidAttribute("isThreadSafe"),
+ new JspUtil.ValidAttribute("info"),
+ new JspUtil.ValidAttribute("errorPage"),
+ new JspUtil.ValidAttribute("isErrorPage"),
+ new JspUtil.ValidAttribute("contentType"),
+ new JspUtil.ValidAttribute("pageEncoding"),
+ new JspUtil.ValidAttribute("isELIgnored")
};
private boolean pageEncodingSeen = false;
@@ -85,10 +85,10 @@
pageEncodingSeen = pageEncodingSeenSave;
}
- public void visit(Node.PageDirective n) throws JasperException {
+ public void visit(Node.PageDirective n) throws JasperException {
JspUtil.checkAttributes("Page directive", n,
- pageDirectiveAttrs, err);
+ pageDirectiveAttrs, err);
// JSP.2.10.1
Attributes attrs = n.getAttributes();
@@ -101,80 +101,80 @@
pageInfo.setLanguage(value, n, err, true);
} else if (!pageInfo.getLanguage(false).equals(value)) {
err.jspError(n, "jsp.error.page.conflict.language",
- pageInfo.getLanguage(false), value);
+ pageInfo.getLanguage(false), value);
}
} else if ("extends".equals(attr)) {
if (pageInfo.getExtends(false) == null) {
pageInfo.setExtends(value, n);
} else if (!pageInfo.getExtends(false).equals(value)) {
err.jspError(n, "jsp.error.page.conflict.extends",
- pageInfo.getExtends(false), value);
+ pageInfo.getExtends(false), value);
}
} else if ("contentType".equals(attr)) {
if (pageInfo.getContentType() == null) {
pageInfo.setContentType(value);
} else if (!pageInfo.getContentType().equals(value)) {
err.jspError(n, "jsp.error.page.conflict.contenttype",
- pageInfo.getContentType(), value);
+ pageInfo.getContentType(), value);
}
} else if ("session".equals(attr)) {
if (pageInfo.getSession() == null) {
pageInfo.setSession(value, n, err);
} else if (!pageInfo.getSession().equals(value)) {
err.jspError(n, "jsp.error.page.conflict.session",
- pageInfo.getSession(), value);
+ pageInfo.getSession(), value);
}
} else if ("buffer".equals(attr)) {
if (pageInfo.getBufferValue() == null) {
pageInfo.setBufferValue(value, n, err);
} else if (!pageInfo.getBufferValue().equals(value)) {
err.jspError(n, "jsp.error.page.conflict.buffer",
- pageInfo.getBufferValue(), value);
+ pageInfo.getBufferValue(), value);
}
} else if ("autoFlush".equals(attr)) {
if (pageInfo.getAutoFlush() == null) {
pageInfo.setAutoFlush(value, n, err);
} else if (!pageInfo.getAutoFlush().equals(value)) {
err.jspError(n, "jsp.error.page.conflict.autoflush",
- pageInfo.getAutoFlush(), value);
+ pageInfo.getAutoFlush(), value);
}
} else if ("isThreadSafe".equals(attr)) {
if (pageInfo.getIsThreadSafe() == null) {
pageInfo.setIsThreadSafe(value, n, err);
} else if (!pageInfo.getIsThreadSafe().equals(value)) {
err.jspError(n, "jsp.error.page.conflict.isthreadsafe",
- pageInfo.getIsThreadSafe(), value);
+ pageInfo.getIsThreadSafe(), value);
}
} else if ("isELIgnored".equals(attr)) {
if (pageInfo.getIsELIgnored() == null) {
pageInfo.setIsELIgnored(value, n, err, true);
} else if (!pageInfo.getIsELIgnored().equals(value)) {
err.jspError(n, "jsp.error.page.conflict.iselignored",
- pageInfo.getIsELIgnored(), value);
+ pageInfo.getIsELIgnored(), value);
}
} else if ("isErrorPage".equals(attr)) {
if (pageInfo.getIsErrorPage() == null) {
pageInfo.setIsErrorPage(value, n, err);
} else if (!pageInfo.getIsErrorPage().equals(value)) {
err.jspError(n, "jsp.error.page.conflict.iserrorpage",
- pageInfo.getIsErrorPage(), value);
+ pageInfo.getIsErrorPage(), value);
}
} else if ("errorPage".equals(attr)) {
if (pageInfo.getErrorPage() == null) {
pageInfo.setErrorPage(value);
} else if (!pageInfo.getErrorPage().equals(value)) {
err.jspError(n, "jsp.error.page.conflict.errorpage",
- pageInfo.getErrorPage(), value);
+ pageInfo.getErrorPage(), value);
}
} else if ("info".equals(attr)) {
if (pageInfo.getInfo() == null) {
pageInfo.setInfo(value);
} else if (!pageInfo.getInfo().equals(value)) {
err.jspError(n, "jsp.error.page.conflict.info",
- pageInfo.getInfo(), value);
+ pageInfo.getInfo(), value);
}
} else if ("pageEncoding".equals(attr)) {
- if (pageEncodingSeen)
+ if (pageEncodingSeen)
err.jspError(n, "jsp.error.page.multi.pageencoding");
// 'pageEncoding' can occur at most once per file
pageEncodingSeen = true;
@@ -195,9 +195,9 @@
// Note: Most of the validation is done in TagFileProcessor
// when it created a TagInfo object from the
// tag file in which the directive appeared.
-
+
// This method does additional processing to collect page info
-
+
Attributes attrs = n.getAttributes();
for (int i = 0; attrs != null && i < attrs.getLength(); i++) {
String attr = attrs.getQName(i);
@@ -208,17 +208,17 @@
pageInfo.setLanguage(value, n, err, false);
} else if (!pageInfo.getLanguage(false).equals(value)) {
err.jspError(n, "jsp.error.tag.conflict.language",
- pageInfo.getLanguage(false), value);
+ pageInfo.getLanguage(false), value);
}
} else if ("isELIgnored".equals(attr)) {
if (pageInfo.getIsELIgnored() == null) {
pageInfo.setIsELIgnored(value, n, err, false);
} else if (!pageInfo.getIsELIgnored().equals(value)) {
err.jspError(n, "jsp.error.tag.conflict.iselignored",
- pageInfo.getIsELIgnored(), value);
+ pageInfo.getIsELIgnored(), value);
}
} else if ("pageEncoding".equals(attr)) {
- if (pageEncodingSeen)
+ if (pageEncodingSeen)
err.jspError(n, "jsp.error.tag.multi.pageencoding");
pageEncodingSeen = true;
n.getRoot().setPageEncoding(value);
@@ -265,12 +265,12 @@
* pattern matches this page.
* Treat "UTF-16", "UTF-16BE", and "UTF-16LE" as identical.
*/
- if (configEnc != null && !pageDirEnc.equals(configEnc)
+ if (configEnc != null && !pageDirEnc.equals(configEnc)
&& (!pageDirEnc.startsWith("UTF-16")
- || !configEnc.startsWith("UTF-16"))) {
+ || !configEnc.startsWith("UTF-16"))) {
err.jspError(pageDir,
- "jsp.error.config_pagedir_encoding_mismatch",
- configEnc, pageDirEnc);
+ "jsp.error.config_pagedir_encoding_mismatch",
+ configEnc, pageDirEnc);
}
/*
@@ -282,12 +282,12 @@
*/
if (root.isXmlSyntax() && root.isEncodingSpecifiedInProlog()) {
String pageEnc = root.getPageEncoding();
- if (!pageDirEnc.equals(pageEnc)
+ if (!pageDirEnc.equals(pageEnc)
&& (!pageDirEnc.startsWith("UTF-16")
- || !pageEnc.startsWith("UTF-16"))) {
+ || !pageEnc.startsWith("UTF-16"))) {
err.jspError(pageDir,
- "jsp.error.prolog_pagedir_encoding_mismatch",
- pageEnc, pageDirEnc);
+ "jsp.error.prolog_pagedir_encoding_mismatch",
+ pageEnc, pageDirEnc);
}
}
}
@@ -303,80 +303,80 @@
private ClassLoader loader;
private static final JspUtil.ValidAttribute[] jspRootAttrs = {
- new JspUtil.ValidAttribute("xsi:schemaLocation"),
- new JspUtil.ValidAttribute("version", true) };
+ new JspUtil.ValidAttribute("xsi:schemaLocation"),
+ new JspUtil.ValidAttribute("version", true)};
private static final JspUtil.ValidAttribute[] includeDirectiveAttrs = {
- new JspUtil.ValidAttribute("file", true) };
+ new JspUtil.ValidAttribute("file", true)};
private static final JspUtil.ValidAttribute[] taglibDirectiveAttrs = {
- new JspUtil.ValidAttribute("uri"),
- new JspUtil.ValidAttribute("tagdir"),
- new JspUtil.ValidAttribute("prefix", true) };
+ new JspUtil.ValidAttribute("uri"),
+ new JspUtil.ValidAttribute("tagdir"),
+ new JspUtil.ValidAttribute("prefix", true)};
private static final JspUtil.ValidAttribute[] includeActionAttrs = {
- new JspUtil.ValidAttribute("page", true, true),
- new JspUtil.ValidAttribute("flush") };
+ new JspUtil.ValidAttribute("page", true, true),
+ new JspUtil.ValidAttribute("flush")};
private static final JspUtil.ValidAttribute[] paramActionAttrs = {
- new JspUtil.ValidAttribute("name", true),
- new JspUtil.ValidAttribute("value", true, true) };
+ new JspUtil.ValidAttribute("name", true),
+ new JspUtil.ValidAttribute("value", true, true)};
private static final JspUtil.ValidAttribute[] forwardActionAttrs = {
- new JspUtil.ValidAttribute("page", true, true) };
+ new JspUtil.ValidAttribute("page", true, true)};
private static final JspUtil.ValidAttribute[] getPropertyAttrs = {
- new JspUtil.ValidAttribute("name", true),
- new JspUtil.ValidAttribute("property", true) };
+ new JspUtil.ValidAttribute("name", true),
+ new JspUtil.ValidAttribute("property", true)};
private static final JspUtil.ValidAttribute[] setPropertyAttrs = {
- new JspUtil.ValidAttribute("name", true),
- new JspUtil.ValidAttribute("property", true),
- new JspUtil.ValidAttribute("value", false, true),
- new JspUtil.ValidAttribute("param") };
+ new JspUtil.ValidAttribute("name", true),
+ new JspUtil.ValidAttribute("property", true),
+ new JspUtil.ValidAttribute("value", false, true),
+ new JspUtil.ValidAttribute("param")};
private static final JspUtil.ValidAttribute[] useBeanAttrs = {
- new JspUtil.ValidAttribute("id", true),
- new JspUtil.ValidAttribute("scope"),
- new JspUtil.ValidAttribute("class"),
- new JspUtil.ValidAttribute("type"),
- new JspUtil.ValidAttribute("beanName", false, true) };
+ new JspUtil.ValidAttribute("id", true),
+ new JspUtil.ValidAttribute("scope"),
+ new JspUtil.ValidAttribute("class"),
+ new JspUtil.ValidAttribute("type"),
+ new JspUtil.ValidAttribute("beanName", false, true)};
private static final JspUtil.ValidAttribute[] plugInAttrs = {
- new JspUtil.ValidAttribute("type",true),
- new JspUtil.ValidAttribute("code", true),
- new JspUtil.ValidAttribute("codebase"),
- new JspUtil.ValidAttribute("align"),
- new JspUtil.ValidAttribute("archive"),
- new JspUtil.ValidAttribute("height", false, true),
- new JspUtil.ValidAttribute("hspace"),
- new JspUtil.ValidAttribute("jreversion"),
- new JspUtil.ValidAttribute("name"),
- new JspUtil.ValidAttribute("vspace"),
- new JspUtil.ValidAttribute("width", false, true),
- new JspUtil.ValidAttribute("nspluginurl"),
- new JspUtil.ValidAttribute("iepluginurl") };
-
+ new JspUtil.ValidAttribute("type", true),
+ new JspUtil.ValidAttribute("code", true),
+ new JspUtil.ValidAttribute("codebase"),
+ new JspUtil.ValidAttribute("align"),
+ new JspUtil.ValidAttribute("archive"),
+ new JspUtil.ValidAttribute("height", false, true),
+ new JspUtil.ValidAttribute("hspace"),
+ new JspUtil.ValidAttribute("jreversion"),
+ new JspUtil.ValidAttribute("name"),
+ new JspUtil.ValidAttribute("vspace"),
+ new JspUtil.ValidAttribute("width", false, true),
+ new JspUtil.ValidAttribute("nspluginurl"),
+ new JspUtil.ValidAttribute("iepluginurl")};
+
private static final JspUtil.ValidAttribute[] attributeAttrs = {
- new JspUtil.ValidAttribute("name", true),
- new JspUtil.ValidAttribute("trim") };
-
+ new JspUtil.ValidAttribute("name", true),
+ new JspUtil.ValidAttribute("trim")};
+
private static final JspUtil.ValidAttribute[] invokeAttrs = {
- new JspUtil.ValidAttribute("fragment", true),
- new JspUtil.ValidAttribute("var"),
- new JspUtil.ValidAttribute("varReader"),
- new JspUtil.ValidAttribute("scope") };
+ new JspUtil.ValidAttribute("fragment", true),
+ new JspUtil.ValidAttribute("var"),
+ new JspUtil.ValidAttribute("varReader"),
+ new JspUtil.ValidAttribute("scope")};
private static final JspUtil.ValidAttribute[] doBodyAttrs = {
- new JspUtil.ValidAttribute("var"),
- new JspUtil.ValidAttribute("varReader"),
- new JspUtil.ValidAttribute("scope") };
+ new JspUtil.ValidAttribute("var"),
+ new JspUtil.ValidAttribute("varReader"),
+ new JspUtil.ValidAttribute("scope")};
private static final JspUtil.ValidAttribute[] jspOutputAttrs = {
- new JspUtil.ValidAttribute("omit-xml-declaration"),
- new JspUtil.ValidAttribute("doctype-root-element"),
- new JspUtil.ValidAttribute("doctype-public"),
- new JspUtil.ValidAttribute("doctype-system") };
+ new JspUtil.ValidAttribute("omit-xml-declaration"),
+ new JspUtil.ValidAttribute("doctype-root-element"),
+ new JspUtil.ValidAttribute("doctype-public"),
+ new JspUtil.ValidAttribute("doctype-system")};
/*
* Constructor
@@ -389,7 +389,7 @@
public void visit(Node.JspRoot n) throws JasperException {
JspUtil.checkAttributes("Jsp:root", n,
- jspRootAttrs, err);
+ jspRootAttrs, err);
String version = n.getTextAttribute("version");
if (!version.equals("1.2") && !version.equals("2.0")) {
err.jspError(n, "jsp.error.jsproot.version.invalid", version);
@@ -399,13 +399,13 @@
public void visit(Node.IncludeDirective n) throws JasperException {
JspUtil.checkAttributes("Include directive", n,
- includeDirectiveAttrs, err);
+ includeDirectiveAttrs, err);
visitBody(n);
}
public void visit(Node.TaglibDirective n) throws JasperException {
JspUtil.checkAttributes("Taglib directive", n,
- taglibDirectiveAttrs, err);
+ taglibDirectiveAttrs, err);
// Either 'uri' or 'tagdir' attribute must be specified
String uri = n.getAttributeValue("uri");
String tagdir = n.getAttributeValue("tagdir");
@@ -419,14 +419,14 @@
public void visit(Node.ParamAction n) throws JasperException {
JspUtil.checkAttributes("Param action", n,
- paramActionAttrs, err);
+ paramActionAttrs, err);
// make sure the value of the 'name' attribute is not a
// request-time expression
throwErrorIfExpression(n, "name", "jsp:param");
n.setValue(getJspAttribute("value", null, null,
- n.getAttributeValue("value"),
- java.lang.String.class,
- n, false));
+ n.getAttributeValue("value"),
+ java.lang.String.class,
+ n, false));
visitBody(n);
}
@@ -441,59 +441,61 @@
public void visit(Node.IncludeAction n) throws JasperException {
JspUtil.checkAttributes("Include action", n,
- includeActionAttrs, err);
+ includeActionAttrs, err);
n.setPage(getJspAttribute("page", null, null,
- n.getAttributeValue("page"),
- java.lang.String.class, n, false));
+ n.getAttributeValue("page"),
+ java.lang.String.class, n, false));
visitBody(n);
- };
+ }
+
+ ;
public void visit(Node.ForwardAction n) throws JasperException {
JspUtil.checkAttributes("Forward", n,
- forwardActionAttrs, err);
+ forwardActionAttrs, err);
n.setPage(getJspAttribute("page", null, null,
- n.getAttributeValue("page"),
- java.lang.String.class, n, false));
+ n.getAttributeValue("page"),
+ java.lang.String.class, n, false));
visitBody(n);
}
public void visit(Node.GetProperty n) throws JasperException {
JspUtil.checkAttributes("GetProperty", n,
- getPropertyAttrs, err);
+ getPropertyAttrs, err);
}
public void visit(Node.SetProperty n) throws JasperException {
JspUtil.checkAttributes("SetProperty", n,
- setPropertyAttrs, err);
+ setPropertyAttrs, err);
String property = n.getTextAttribute("property");
String param = n.getTextAttribute("param");
String value = n.getAttributeValue("value");
- n.setValue(getJspAttribute("value", null, null, value,
- java.lang.Object.class, n, false));
+ n.setValue(getJspAttribute("value", null, null, value,
+ java.lang.Object.class, n, false));
boolean valueSpecified = n.getValue() != null;
- if ("*".equals(property)) {
+ if ("*".equals(property)) {
if (param != null || valueSpecified)
err.jspError(n, "jsp.error.setProperty.invalid");
-
+
} else if (param != null && valueSpecified) {
err.jspError(n, "jsp.error.setProperty.invalid");
}
-
+
visitBody(n);
}
public void visit(Node.UseBean n) throws JasperException {
JspUtil.checkAttributes("UseBean", n,
- useBeanAttrs, err);
+ useBeanAttrs, err);
- String name = n.getTextAttribute ("id");
- String scope = n.getTextAttribute ("scope");
+ String name = n.getTextAttribute("id");
+ String scope = n.getTextAttribute("scope");
JspUtil.checkScope(scope, n, err);
- String className = n.getTextAttribute ("class");
- String type = n.getTextAttribute ("type");
+ String className = n.getTextAttribute("class");
+ String type = n.getTextAttribute("type");
BeanRepository beanInfo = pageInfo.getBeanRepository();
if (className == null && type == null)
@@ -506,9 +508,9 @@
err.jspError(n, "jsp.error.usebean.noSession");
Node.JspAttribute jattr
- = getJspAttribute("beanName", null, null,
- n.getAttributeValue("beanName"),
- java.lang.String.class, n, false);
+ = getJspAttribute("beanName", null, null,
+ n.getAttributeValue("beanName"),
+ java.lang.String.class, n, false);
n.setBeanName(jattr);
if (className != null && jattr != null)
err.jspError(n, "jsp.error.usebean.notBoth");
@@ -543,32 +545,32 @@
err.jspError(n, "jsp.error.plugin.badtype");
if (n.getTextAttribute("code") == null)
err.jspError(n, "jsp.error.plugin.nocode");
-
+
Node.JspAttribute width
- = getJspAttribute("width", null, null,
- n.getAttributeValue("width"),
- java.lang.String.class, n, false);
- n.setWidth( width );
-
+ = getJspAttribute("width", null, null,
+ n.getAttributeValue("width"),
+ java.lang.String.class, n, false);
+ n.setWidth(width);
+
Node.JspAttribute height
- = getJspAttribute("height", null, null,
- n.getAttributeValue("height"),
- java.lang.String.class, n, false);
- n.setHeight( height );
+ = getJspAttribute("height", null, null,
+ n.getAttributeValue("height"),
+ java.lang.String.class, n, false);
+ n.setHeight(height);
visitBody(n);
}
public void visit(Node.NamedAttribute n) throws JasperException {
JspUtil.checkAttributes("Attribute", n,
- attributeAttrs, err);
+ attributeAttrs, err);
visitBody(n);
}
-
+
public void visit(Node.JspBody n) throws JasperException {
visitBody(n);
}
-
+
public void visit(Node.Declaration n) throws JasperException {
if (pageInfo.isScriptingInvalid()) {
err.jspError(n.getStart(), "jsp.error.no.scriptlets");
@@ -588,17 +590,17 @@
}
public void visit(Node.ELExpression n) throws JasperException {
- if ( !pageInfo.isELIgnored() ) {
+ if (!pageInfo.isELIgnored()) {
String expressions = "${" + new String(n.getText()) + "}";
ELNode.Nodes el = ELParser.parse(expressions);
validateFunctions(el, n);
JspUtil.validateExpressions(
- n.getStart(),
- expressions,
- java.lang.String.class, // XXX - Should template text
- // always evaluate to String?
- getFunctionMapper(el),
- err);
+ n.getStart(),
+ expressions,
+ java.lang.String.class, // XXX - Should template text
+ // always evaluate to String?
+ getFunctionMapper(el),
+ err);
n.setEL(el);
}
}
@@ -612,14 +614,14 @@
if (attrs != null) {
int attrSize = attrs.getLength();
Node.JspAttribute[] jspAttrs = new Node.JspAttribute[attrSize];
- for (int i=0; i < attrSize; i++) {
+ for (int i = 0; i < attrSize; i++) {
jspAttrs[i] = getJspAttribute(attrs.getQName(i),
- attrs.getURI(i),
- attrs.getLocalName(i),
- attrs.getValue(i),
- java.lang.Object.class,
- n,
- false);
+ attrs.getURI(i),
+ attrs.getLocalName(i),
+ attrs.getValue(i),
+ java.lang.Object.class,
+ n,
+ false);
}
n.setJspAttributes(jspAttrs);
}
@@ -638,7 +640,7 @@
* The bodyconet of a SimpleTag cannot be JSP.
*/
if (n.implementsSimpleTag() &&
- tagInfo.getBodyContent().equalsIgnoreCase(TagInfo.BODY_CONTENT_JSP)) {
+ tagInfo.getBodyContent().equalsIgnoreCase(TagInfo.BODY_CONTENT_JSP)) {
err.jspError(n, "jsp.error.simpletag.badbodycontent",
tagInfo.getTagClassName());
}
@@ -651,7 +653,7 @@
if (tagInfo.hasDynamicAttributes()
&& !n.implementsDynamicAttributes()) {
err.jspError(n, "jsp.error.dynamic.attributes.not.implemented",
- n.getQName());
+ n.getQName());
}
/*
@@ -664,25 +666,25 @@
String customActionUri = n.getURI();
Attributes attrs = n.getAttributes();
int attrsSize = (attrs == null) ? 0 : attrs.getLength();
- for (int i=0; i<tldAttrs.length; i++) {
+ for (int i = 0; i < tldAttrs.length; i++) {
String attr = null;
if (attrs != null) {
attr = attrs.getValue(tldAttrs[i].getName());
if (attr == null) {
attr = attrs.getValue(customActionUri,
- tldAttrs[i].getName());
+ tldAttrs[i].getName());
}
}
Node.NamedAttribute na =
n.getNamedAttributeNode(tldAttrs[i].getName());
-
+
if (tldAttrs[i].isRequired() && attr == null && na == null) {
err.jspError(n, "jsp.error.missing_attribute",
- tldAttrs[i].getName(), n.getLocalName());
+ tldAttrs[i].getName(), n.getLocalName());
}
if (attr != null && na != null) {
err.jspError(n, "jsp.error.duplicate.name.jspattribute",
- tldAttrs[i].getName());
+ tldAttrs[i].getName());
}
}
@@ -708,7 +710,7 @@
&& tei.getVariableInfo(tagData).length > 0
&& tagInfo.getTagVariableInfos().length > 0) {
err.jspError("jsp.error.non_null_tei_and_var_subelems",
- n.getQName());
+ n.getQName());
}
n.setTagData(tagData);
@@ -729,31 +731,31 @@
// XML-style 'name' attribute, which is mandatory, must not be
// included in JspAttribute array
- int jspAttrSize = xmlAttrLen-1 + namedAttrs.size();
+ int jspAttrSize = xmlAttrLen - 1 + namedAttrs.size();
Node.JspAttribute[] jspAttrs = new Node.JspAttribute[jspAttrSize];
int jspAttrIndex = 0;
// Process XML-style attributes
- for (int i=0; i<xmlAttrLen; i++) {
+ for (int i = 0; i < xmlAttrLen; i++) {
if ("name".equals(attrs.getLocalName(i))) {
n.setNameAttribute(getJspAttribute(attrs.getQName(i),
- attrs.getURI(i),
- attrs.getLocalName(i),
- attrs.getValue(i),
- java.lang.String.class,
- n,
- false));
+ attrs.getURI(i),
+ attrs.getLocalName(i),
+ attrs.getValue(i),
+ java.lang.String.class,
+ n,
+ false));
} else {
- if (jspAttrIndex<jspAttrSize) {
+ if (jspAttrIndex < jspAttrSize) {
jspAttrs[jspAttrIndex++]
- = getJspAttribute(attrs.getQName(i),
- attrs.getURI(i),
- attrs.getLocalName(i),
- attrs.getValue(i),
- java.lang.Object.class,
- n,
- false);
+ = getJspAttribute(attrs.getQName(i),
+ attrs.getURI(i),
+ attrs.getLocalName(i),
+ attrs.getValue(i),
+ java.lang.Object.class,
+ n,
+ false);
}
}
}
@@ -762,9 +764,9 @@
}
// Process named attributes
- for (int i=0; i<namedAttrs.size(); i++) {
+ for (int i = 0; i < namedAttrs.size(); i++) {
Node.NamedAttribute na =
- (Node.NamedAttribute) namedAttrs.getNode(i);
+ (Node.NamedAttribute) namedAttrs.getNode(i);
jspAttrs[jspAttrIndex++] = new Node.JspAttribute(na, false);
}
@@ -791,31 +793,31 @@
String doctypeSystemOld = pageInfo.getDoctypeSystem();
if (omitXmlDecl != null && omitXmlDeclOld != null &&
- !omitXmlDecl.equals(omitXmlDeclOld) ) {
+ !omitXmlDecl.equals(omitXmlDeclOld)) {
err.jspError(n, "jsp.error.jspoutput.conflict",
"omit-xml-declaration", omitXmlDeclOld, omitXmlDecl);
}
if (doctypeName != null && doctypeNameOld != null &&
- !doctypeName.equals(doctypeNameOld) ) {
+ !doctypeName.equals(doctypeNameOld)) {
err.jspError(n, "jsp.error.jspoutput.conflict",
"doctype-root-element", doctypeNameOld, doctypeName);
}
if (doctypePublic != null && doctypePublicOld != null &&
- !doctypePublic.equals(doctypePublicOld) ) {
+ !doctypePublic.equals(doctypePublicOld)) {
err.jspError(n, "jsp.error.jspoutput.conflict",
"doctype-public", doctypePublicOld, doctypePublic);
}
if (doctypeSystem != null && doctypeSystemOld != null &&
- !doctypeSystem.equals(doctypeSystemOld) ) {
+ !doctypeSystem.equals(doctypeSystemOld)) {
err.jspError(n, "jsp.error.jspoutput.conflict",
"doctype-system", doctypeSystemOld, doctypeSystem);
}
if (doctypeName == null && doctypeSystem != null ||
- doctypeName != null && doctypeSystem == null) {
+ doctypeName != null && doctypeSystem == null) {
err.jspError(n, "jsp.error.jspoutput.doctypenamesystem");
}
@@ -841,7 +843,7 @@
JspUtil.checkAttributes("Invoke", n, invokeAttrs, err);
- String scope = n.getTextAttribute ("scope");
+ String scope = n.getTextAttribute("scope");
JspUtil.checkScope(scope, n, err);
String var = n.getTextAttribute("var");
@@ -858,7 +860,7 @@
JspUtil.checkAttributes("DoBody", n, doBodyAttrs, err);
- String scope = n.getTextAttribute ("scope");
+ String scope = n.getTextAttribute("scope");
JspUtil.checkScope(scope, n, err);
String var = n.getTextAttribute("var");
@@ -904,37 +906,36 @@
TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
Attributes attrs = n.getAttributes();
- for (int i=0; attrs != null && i<attrs.getLength(); i++) {
+ for (int i = 0; attrs != null && i < attrs.getLength(); i++) {
boolean found = false;
- for (int j=0; tldAttrs != null && j<tldAttrs.length; j++) {
+ for (int j = 0; tldAttrs != null && j < tldAttrs.length; j++) {
if (attrs.getLocalName(i).equals(tldAttrs[j].getName())
&& (attrs.getURI(i) == null
- || attrs.getURI(i).length() == 0
- || attrs.getURI(i).equals(n.getURI()))) {
+ || attrs.getURI(i).length() == 0
+ || attrs.getURI(i).equals(n.getURI()))) {
if (tldAttrs[j].canBeRequestTime()) {
Class expectedType = String.class;
try {
String typeStr = tldAttrs[j].getTypeName();
- if( tldAttrs[j].isFragment() ) {
+ if (tldAttrs[j].isFragment()) {
expectedType = JspFragment.class;
- }
- else if( typeStr != null ) {
+ } else if (typeStr != null) {
expectedType = JspUtil.toClass(typeStr,
- loader);
+ loader);
}
jspAttrs[i]
- = getJspAttribute(attrs.getQName(i),
- attrs.getURI(i),
- attrs.getLocalName(i),
- attrs.getValue(i),
- expectedType,
- n,
- false);
+ = getJspAttribute(attrs.getQName(i),
+ attrs.getURI(i),
+ attrs.getLocalName(i),
+ attrs.getValue(i),
+ expectedType,
+ n,
+ false);
} catch (ClassNotFoundException e) {
- err.jspError(n,
- "jsp.error.unknown_attribute_type",
- tldAttrs[j].getName(),
- tldAttrs[j].getTypeName() );
+ err.jspError(n,
+ "jsp.error.unknown_attribute_type",
+ tldAttrs[j].getName(),
+ tldAttrs[j].getTypeName());
}
} else {
// Attribute does not accept any expressions.
@@ -942,23 +943,23 @@
if (isExpression(n, attrs.getValue(i))) {
err.jspError(n,
"jsp.error.attribute.custom.non_rt_with_expr",
- tldAttrs[j].getName());
+ tldAttrs[j].getName());
}
jspAttrs[i]
- = new Node.JspAttribute(attrs.getQName(i),
- attrs.getURI(i),
- attrs.getLocalName(i),
- attrs.getValue(i),
- false,
- null,
- false);
+ = new Node.JspAttribute(attrs.getQName(i),
+ attrs.getURI(i),
+ attrs.getLocalName(i),
+ attrs.getValue(i),
+ false,
+ null,
+ false);
}
if (isExpression(n, attrs.getValue(i))) {
tagDataAttrs.put(attrs.getQName(i),
- TagData.REQUEST_TIME_VALUE);
+ TagData.REQUEST_TIME_VALUE);
} else {
tagDataAttrs.put(attrs.getQName(i),
- attrs.getValue(i));
+ attrs.getValue(i));
}
found = true;
break;
@@ -967,15 +968,15 @@
if (!found) {
if (tagInfo.hasDynamicAttributes()) {
jspAttrs[i] = getJspAttribute(attrs.getQName(i),
- attrs.getURI(i),
- attrs.getLocalName(i),
- attrs.getValue(i),
- java.lang.Object.class,
- n,
- true);
+ attrs.getURI(i),
+ attrs.getLocalName(i),
+ attrs.getValue(i),
+ java.lang.Object.class,
+ n,
+ true);
} else {
err.jspError(n, "jsp.error.bad_attribute",
- attrs.getQName(i), n.getLocalName());
+ attrs.getQName(i), n.getLocalName());
}
}
}
@@ -998,11 +999,11 @@
TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
Node.Nodes naNodes = n.getNamedAttributeNodes();
- for (int i=0; i<naNodes.size(); i++) {
+ for (int i = 0; i < naNodes.size(); i++) {
Node.NamedAttribute na = (Node.NamedAttribute)
- naNodes.getNode(i);
+ naNodes.getNode(i);
boolean found = false;
- for (int j=0; j<tldAttrs.length; j++) {
+ for (int j = 0; j < tldAttrs.length; j++) {
/*
* See above comment about namespace matches. For named
* attributes, we use the prefix instead of URI as the
@@ -1015,7 +1016,7 @@
String attrPrefix = na.getPrefix();
if (na.getLocalName().equals(tldAttrs[j].getName())
&& (attrPrefix == null || attrPrefix.length() == 0
- || attrPrefix.equals(n.getPrefix()))) {
+ || attrPrefix.equals(n.getPrefix()))) {
jspAttrs[start + i] = new Node.JspAttribute(na, false);
NamedAttributeVisitor nav = null;
if (na.getBody() != null) {
@@ -1024,9 +1025,9 @@
}
if (nav != null && nav.hasDynamicContent()) {
tagDataAttrs.put(na.getName(),
- TagData.REQUEST_TIME_VALUE);
+ TagData.REQUEST_TIME_VALUE);
} else {
- tagDataAttrs.put(na.getName(), na.getText());
+ tagDataAttrs.put(na.getName(), na.getText());
}
found = true;
break;
@@ -1037,7 +1038,7 @@
jspAttrs[start + i] = new Node.JspAttribute(na, true);
} else {
err.jspError(n, "jsp.error.bad_attribute",
- na.getName(), n.getLocalName());
+ na.getName(), n.getLocalName());
}
}
}
@@ -1046,7 +1047,7 @@
/**
* Preprocess attributes that can be expressions. Expression
* delimiters are stripped.
- * <p>
+ * <p/>
* If value is null, checks if there are any
* NamedAttribute subelements in the tree node, and if so,
* constructs a JspAttribute out of a child NamedAttribute node.
@@ -1069,25 +1070,23 @@
if (value != null) {
if (n.getRoot().isXmlSyntax() && value.startsWith("%=")) {
result = new Node.JspAttribute(
- qName,
- uri,
- localName,
- value.substring(2, value.length()-1),
- true,
- null,
- dynamic);
- }
- else if(!n.getRoot().isXmlSyntax() && value.startsWith("<%=")) {
+ qName,
+ uri,
+ localName,
+ value.substring(2, value.length() - 1),
+ true,
+ null,
+ dynamic);
+ } else if (!n.getRoot().isXmlSyntax() && value.startsWith("<%=")) {
result = new Node.JspAttribute(
- qName,
- uri,
- localName,
- value.substring(3, value.length()-2),
- true,
- null,
- dynamic);
- }
- else {
+ qName,
+ uri,
+ localName,
+ value.substring(3, value.length() - 2),
+ true,
+ null,
+ dynamic);
+ } else {
// The attribute can contain expressions but is not a
// scriptlet expression; thus, we want to run it through
// the expression interpreter
@@ -1098,34 +1097,33 @@
if (el.containsEL() && !pageInfo.isELIgnored()) {
validateFunctions(el, n);
JspUtil.validateExpressions(
- n.getStart(),
- value,
- expectedType,
- getFunctionMapper(el),
- this.err);
+ n.getStart(),
+ value,
+ expectedType,
+ getFunctionMapper(el),
+ this.err);
-
+
result = new Node.JspAttribute(qName, uri, localName,
- value, false, el,
- dynamic);
+ value, false, el,
+ dynamic);
} else {
value = value.replace(Constants.HACK_CHAR, '$');
result = new Node.JspAttribute(qName, uri, localName,
- value, false, null,
- dynamic);
+ value, false, null,
+ dynamic);
}
}
- }
- else {
+ } else {
// Value is null. Check for any NamedAttribute subnodes
// that might contain the value for this attribute.
// Otherwise, the attribute wasn't found so we return null.
Node.NamedAttribute namedAttributeNode =
- n.getNamedAttributeNode( qName );
- if( namedAttributeNode != null ) {
+ n.getNamedAttributeNode(qName);
+ if (namedAttributeNode != null) {
result = new Node.JspAttribute(namedAttributeNode,
- dynamic);
+ dynamic);
}
}
@@ -1152,13 +1150,13 @@
*/
private void throwErrorIfExpression(Node n, String attrName,
String actionName)
- throws JasperException {
+ throws JasperException {
if (n.getAttributes() != null
&& n.getAttributes().getValue(attrName) != null
&& isExpression(n, n.getAttributes().getValue(attrName))) {
err.jspError(n,
- "jsp.error.attribute.standard.non_rt_with_expr",
- attrName, actionName);
+ "jsp.error.attribute.standard.non_rt_with_expr",
+ attrName, actionName);
}
}
@@ -1172,7 +1170,7 @@
}
visitBody(n);
}
-
+
public boolean hasDynamicContent() {
return hasDynamicContent;
}
@@ -1191,9 +1189,9 @@
if (prefix == null && k < 0) {
// prefix not specified and a default ns found
return attrs.getValue(i);
- }
+ }
if (prefix != null && k >= 0 &&
- prefix.equals(name.substring(k+1))) {
+ prefix.equals(name.substring(k + 1))) {
return attrs.getValue(i);
}
}
@@ -1204,7 +1202,7 @@
/**
* Validate functions in EL expressions
*/
- private void validateFunctions(ELNode.Nodes el, Node n)
+ private void validateFunctions(ELNode.Nodes el, Node n)
throws JasperException {
class FVVisitor extends ELNode.Visitor {
@@ -1229,11 +1227,10 @@
if (uri == null) {
if (prefix == null) {
err.jspError(n, "jsp.error.noFunctionPrefix",
- function);
- }
- else {
+ function);
+ } else {
err.jspError(n,
- "jsp.error.attribute.invalidPrefix", prefix);
+ "jsp.error.attribute.invalidPrefix", prefix);
}
}
TagLibraryInfo taglib = pageInfo.getTaglib(uri);
@@ -1267,25 +1264,26 @@
throws JasperException {
FunctionInfo funcInfo = func.getFunctionInfo();
String signature = funcInfo.getFunctionSignature();
-
+
int start = signature.indexOf(' ');
if (start < 0) {
err.jspError("jsp.error.tld.fn.invalid.signature",
- func.getPrefix(), func.getName());
+ func.getPrefix(), func.getName());
}
int end = signature.indexOf('(');
if (end < 0) {
err.jspError("jsp.error.tld.fn.invalid.signature.parenexpected",
- func.getPrefix(), func.getName());
+ func.getPrefix(), func.getName());
}
- return signature.substring(start+1, end).trim();
+ return signature.substring(start + 1, end).trim();
}
/**
* Get the parameters types from the function signature.
+ *
* @return An array of parameter class names
*/
- private String[] getParameters(ELNode.Function func)
+ private String[] getParameters(ELNode.Function func)
throws JasperException {
FunctionInfo funcInfo = func.getFunctionInfo();
String signature = funcInfo.getFunctionSignature();
@@ -1301,7 +1299,7 @@
p = signature.indexOf(')', start);
if (p < 0) {
err.jspError("jsp.error.tld.fn.invalid.signature",
- func.getPrefix(), func.getName());
+ func.getPrefix(), func.getName());
}
lastArg = true;
}
@@ -1312,7 +1310,7 @@
if (lastArg) {
break;
}
- start = p+1;
+ start = p + 1;
}
return (String[]) params.toArray(new String[params.size()]);
}
@@ -1323,6 +1321,7 @@
class ValidateFunctionMapper implements FunctionMapper {
private HashMap fnmap = new java.util.HashMap();
+
public void mapFunction(String fnQName, Method method) {
fnmap.put(fnQName, method);
}
@@ -1349,9 +1348,9 @@
n.getFunctionInfo().getFunctionClass());
} catch (ClassNotFoundException e) {
err.jspError("jsp.error.function.classnotfound",
- n.getFunctionInfo().getFunctionClass(),
- n.getPrefix() + ':' + n.getName(),
- e.getMessage());
+ n.getFunctionInfo().getFunctionClass(),
+ n.getPrefix() + ':' + n.getName(),
+ e.getMessage());
}
String paramTypes[] = n.getParameters();
int size = paramTypes.length;
@@ -1362,19 +1361,19 @@
params[i] = JspUtil.toClass(paramTypes[i], loader);
}
method = c.getDeclaredMethod(n.getMethodName(),
- params);
+ params);
} catch (ClassNotFoundException e) {
err.jspError("jsp.error.signature.classnotfound",
- paramTypes[i],
- n.getPrefix() + ':' + n.getName(),
- e.getMessage());
- } catch (NoSuchMethodException e ) {
+ paramTypes[i],
+ n.getPrefix() + ':' + n.getName(),
+ e.getMessage());
+ } catch (NoSuchMethodException e) {
err.jspError("jsp.error.noFunctionMethod",
- n.getMethodName(), n.getName(),
- c.getName());
+ n.getMethodName(), n.getName(),
+ c.getName());
}
fmapper.mapFunction(n.getPrefix() + ':' + n.getName(),
- method);
+ method);
}
}
@@ -1411,7 +1410,7 @@
errMsg.append(Localizer.getMessage(
"jsp.error.tei.invalid.attributes", n.getQName()));
errMsg.append("</h3>");
- for (int i=0; i<errors.length; i++) {
+ for (int i = 0; i < errors.length; i++) {
errMsg.append("<p>");
if (errors[i].getId() != null) {
errMsg.append(errors[i].getId());
@@ -1445,7 +1444,7 @@
boolean isXml = page.getRoot().isXmlSyntax();
String defaultType;
if (contentType == null) {
- defaultType = isXml? "text/xml": "text/html";
+ defaultType = isXml ? "text/xml" : "text/html";
} else {
defaultType = contentType;
}
@@ -1497,13 +1496,13 @@
* imported tag libraries.
*/
private static void validateXmlView(PageData xmlView, Compiler compiler)
- throws JasperException {
+ throws JasperException {
StringBuffer errMsg = null;
ErrorDispatcher errDisp = compiler.getErrorDispatcher();
- for (Iterator iter=compiler.getPageInfo().getTaglibs().iterator();
- iter.hasNext(); ) {
+ for (Iterator iter = compiler.getPageInfo().getTaglibs().iterator();
+ iter.hasNext();) {
Object o = iter.next();
if (!(o instanceof TagLibraryInfoImpl))
@@ -1520,7 +1519,7 @@
tli.getShortName(),
compiler.getPageInfo().getJspFile()));
errMsg.append("</h3>");
- for (int i=0; i<errors.length; i++) {
+ for (int i = 0; i < errors.length; i++) {
if (errors[i] != null) {
errMsg.append("<p>");
errMsg.append(errors[i].getId());
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/tagplugin/TagPlugin.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/tagplugin/TagPlugin.java
index b798874..57ef8e7 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/tagplugin/TagPlugin.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/tagplugin/TagPlugin.java
@@ -21,7 +21,7 @@
* This interface is to be implemented by the plugin author, to supply
* an alternate implementation of the tag handlers. It can be used to
* specify the Java codes to be generated when a tag is invoked.
- *
+ * <p/>
* An implementation of this interface must be registered in a file
* named "tagPlugins.xml" under WEB-INF.
*/
@@ -30,6 +30,7 @@
/**
* Generate codes for a custom tag.
+ *
* @param ctxt a TagPluginContext for accessing Jasper functions
*/
void doTag(TagPluginContext ctxt);
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/tagplugin/TagPluginContext.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/tagplugin/TagPluginContext.java
index 30e0a60..2ddd73f 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/tagplugin/TagPluginContext.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/compiler/tagplugin/TagPluginContext.java
@@ -43,6 +43,7 @@
/**
* Generate an import statement
+ *
* @param s Name of the import class, '*' allowed.
*/
void generateImport(String s);
@@ -50,13 +51,14 @@
/**
* Generate a declaration in the of the generated class. This can be
* used to declare an innter class, a method, or a class variable.
- * @param id An unique ID identifying the declaration. It is not
- * part of the declaration, and is used to ensure that the
- * declaration will only appear once. If this method is
- * invoked with the same id more than once in the translation
- * unit, only the first declaration will be taken.
+ *
+ * @param id An unique ID identifying the declaration. It is not
+ * part of the declaration, and is used to ensure that the
+ * declaration will only appear once. If this method is
+ * invoked with the same id more than once in the translation
+ * unit, only the first declaration will be taken.
* @param text The text of the declaration.
- **/
+ */
void generateDeclaration(String id, String text);
/**
@@ -81,6 +83,7 @@
* Generate codesto evaluate value of a attribute in the custom tag
* The codes is a Java expression.
* NOTE: Currently cannot handle attributes that are fragments.
+ *
* @param attribute The specified attribute
*/
void generateAttribute(String attribute);
@@ -103,6 +106,7 @@
* The operations available for PluginContext so obtained is limited
* to getPluginAttribute and setPluginAttribute, and queries (e.g.
* isScriptless(). There should be no calls to generate*().
+ *
* @return The pluginContext for the parent node.
* null if the parent is not a custom tag, or if the pluginConxt
* if not available (because useTagPlugin is false, e.g).
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/BodyContentImpl.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/BodyContentImpl.java
index 9c0eebb..4aa07dc 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/BodyContentImpl.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/BodyContentImpl.java
@@ -29,30 +29,30 @@
/**
* Write text to a character-output stream, buffering characters so as
* to provide for the efficient writing of single characters, arrays,
- * and strings.
- *
- * Provide support for discarding for the output that has been buffered.
+ * and strings.
+ * <p/>
+ * Provide support for discarding for the output that has been buffered.
*
* @author Rajiv Mordani
* @author Jan Luehe
*/
public class BodyContentImpl extends BodyContent {
-
- private static final String LINE_SEPARATOR =
- System.getProperty("line.separator");
- private static final boolean LIMIT_BUFFER =
- Boolean.valueOf(System.getProperty("org.apache.struts2.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "false")).booleanValue();
-
+
+ private static final String LINE_SEPARATOR =
+ System.getProperty("line.separator");
+ private static final boolean LIMIT_BUFFER =
+ Boolean.valueOf(System.getProperty("org.apache.struts2.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "false")).booleanValue();
+
private char[] cb;
private int nextChar;
private boolean closed;
-
+
// Enclosed writer to which any output is written
private Writer writer;
-
+
// See comment in setWriter()
private int bufferSizeSave;
-
+
/**
* Constructor.
*/
@@ -63,7 +63,7 @@
nextChar = 0;
closed = false;
}
-
+
/**
* Write a single character.
*/
@@ -73,15 +73,15 @@
} else {
ensureOpen();
if (nextChar >= bufferSize) {
- reAllocBuff (1);
+ reAllocBuff(1);
}
cb[nextChar++] = (char) c;
}
}
-
+
/**
* Write a portion of an array of characters.
- *
+ * <p/>
* <p> Ordinarily this method stores characters from the given array into
* this stream's buffer, flushing the buffer to the underlying stream as
* needed. If the requested length is at least as large as the buffer,
@@ -91,30 +91,30 @@
* unnecessarily.
*
* @param cbuf A character array
- * @param off Offset from which to start reading characters
- * @param len Number of characters to write
+ * @param off Offset from which to start reading characters
+ * @param len Number of characters to write
*/
public void write(char[] cbuf, int off, int len) throws IOException {
if (writer != null) {
writer.write(cbuf, off, len);
} else {
ensureOpen();
-
+
if ((off < 0) || (off > cbuf.length) || (len < 0) ||
((off + len) > cbuf.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return;
- }
-
+ }
+
if (len >= bufferSize - nextChar)
- reAllocBuff (len);
-
+ reAllocBuff(len);
+
System.arraycopy(cbuf, off, cb, nextChar, len);
- nextChar+=len;
+ nextChar += len;
}
}
-
+
/**
* Write an array of characters. This method cannot be inherited from the
* Writer class because it must suppress I/O exceptions.
@@ -126,11 +126,11 @@
write(buf, 0, buf.length);
}
}
-
+
/**
* Write a portion of a String.
*
- * @param s String to be written
+ * @param s String to be written
* @param off Offset from which to start reading characters
* @param len Number of characters to be written
*/
@@ -141,12 +141,12 @@
ensureOpen();
if (len >= bufferSize - nextChar)
reAllocBuff(len);
-
+
s.getChars(off, off + len, cb, nextChar);
nextChar += len;
}
}
-
+
/**
* Write a string. This method cannot be inherited from the Writer class
* because it must suppress I/O exceptions.
@@ -158,7 +158,7 @@
write(s, 0, s.length());
}
}
-
+
/**
* Write a line separator. The line separator string is defined by the
* system property <tt>line.separator</tt>, and is not necessarily a single
@@ -173,7 +173,7 @@
write(LINE_SEPARATOR);
}
}
-
+
/**
* Print a boolean value. The string produced by <code>{@link
* java.lang.String#valueOf(boolean)}</code> is translated into bytes
@@ -191,7 +191,7 @@
write(b ? "true" : "false");
}
}
-
+
/**
* Print a character. The character is translated into one or more bytes
* according to the platform's default character encoding, and these bytes
@@ -208,7 +208,7 @@
write(String.valueOf(c));
}
}
-
+
/**
* Print an integer. The string produced by <code>{@link
* java.lang.String#valueOf(int)}</code> is translated into bytes according
@@ -226,7 +226,7 @@
write(String.valueOf(i));
}
}
-
+
/**
* Print a long integer. The string produced by <code>{@link
* java.lang.String#valueOf(long)}</code> is translated into bytes
@@ -244,7 +244,7 @@
write(String.valueOf(l));
}
}
-
+
/**
* Print a floating-point number. The string produced by <code>{@link
* java.lang.String#valueOf(float)}</code> is translated into bytes
@@ -262,7 +262,7 @@
write(String.valueOf(f));
}
}
-
+
/**
* Print a double-precision floating-point number. The string produced by
* <code>{@link java.lang.String#valueOf(double)}</code> is translated into
@@ -280,7 +280,7 @@
write(String.valueOf(d));
}
}
-
+
/**
* Print an array of characters. The characters are converted into bytes
* according to the platform's default character encoding, and these bytes
@@ -288,7 +288,6 @@
* <code>{@link #write(int)}</code> method.
*
* @param s The array of chars to be printed
- *
* @throws NullPointerException If <code>s</code> is <code>null</code>
* @throws IOException
*/
@@ -299,7 +298,7 @@
write(s);
}
}
-
+
/**
* Print a string. If the argument is <code>null</code> then the string
* <code>"null"</code> is printed. Otherwise, the string's characters are
@@ -318,7 +317,7 @@
write(s);
}
}
-
+
/**
* Print an object. The string produced by the <code>{@link
* java.lang.String#valueOf(Object)}</code> method is translated into bytes
@@ -336,7 +335,7 @@
write(String.valueOf(obj));
}
}
-
+
/**
* Terminate the current line by writing the line separator string. The
* line separator string is defined by the system property
@@ -348,7 +347,7 @@
public void println() throws IOException {
newLine();
}
-
+
/**
* Print a boolean value and then terminate the line. This method behaves
* as though it invokes <code>{@link #print(boolean)}</code> and then
@@ -360,7 +359,7 @@
print(x);
println();
}
-
+
/**
* Print a character and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(char)}</code> and then
@@ -372,7 +371,7 @@
print(x);
println();
}
-
+
/**
* Print an integer and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(int)}</code> and then
@@ -384,7 +383,7 @@
print(x);
println();
}
-
+
/**
* Print a long integer and then terminate the line. This method behaves
* as though it invokes <code>{@link #print(long)}</code> and then
@@ -396,7 +395,7 @@
print(x);
println();
}
-
+
/**
* Print a floating-point number and then terminate the line. This method
* behaves as though it invokes <code>{@link #print(float)}</code> and then
@@ -408,7 +407,7 @@
print(x);
println();
}
-
+
/**
* Print a double-precision floating-point number and then terminate the
* line. This method behaves as though it invokes <code>{@link
@@ -416,11 +415,11 @@
*
* @throws IOException
*/
- public void println(double x) throws IOException{
+ public void println(double x) throws IOException {
print(x);
println();
}
-
+
/**
* Print an array of characters and then terminate the line. This method
* behaves as though it invokes <code>{@link #print(char[])}</code> and
@@ -432,7 +431,7 @@
print(x);
println();
}
-
+
/**
* Print a String and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(String)}</code> and then
@@ -444,7 +443,7 @@
print(x);
println();
}
-
+
/**
* Print an Object and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(Object)}</code> and then
@@ -456,11 +455,11 @@
print(x);
println();
}
-
+
/**
* Clear the contents of the buffer. If the buffer has been already
* been flushed then the clear operation shall throw an IOException
- * to signal the fact that some data has already been irrevocably
+ * to signal the fact that some data has already been irrevocably
* written to the client response stream.
*
* @throws IOException If an I/O error occurs
@@ -476,7 +475,7 @@
}
}
}
-
+
/**
* Clears the current contents of the buffer. Unlike clear(), this
* mehtod will not throw an IOException if the buffer has already been
@@ -490,7 +489,7 @@
this.clear();
}
}
-
+
/**
* Close the stream, flushing it first. Once a stream has been closed,
* further write() or flush() invocations will cause an IOException to be
@@ -505,14 +504,14 @@
closed = true;
}
}
-
+
/**
* @return the number of bytes unused in the buffer
*/
public int getRemaining() {
- return (writer == null) ? bufferSize-nextChar : 0;
+ return (writer == null) ? bufferSize - nextChar : 0;
}
-
+
/**
* Return the value of this BodyJspWriter as a Reader.
* Note: this is after evaluation!! There are no scriptlets,
@@ -521,9 +520,9 @@
* @return the value of this BodyJspWriter as a Reader
*/
public Reader getReader() {
- return (writer == null) ? new CharArrayReader (cb, 0, nextChar) : null;
+ return (writer == null) ? new CharArrayReader(cb, 0, nextChar) : null;
}
-
+
/**
* Return the value of the BodyJspWriter as a String.
* Note: this is after evaluation!! There are no scriptlets,
@@ -534,14 +533,14 @@
public String getString() {
return (writer == null) ? new String(cb, 0, nextChar) : null;
}
-
+
/**
* Write the contents of this BodyJspWriter into a Writer.
* Subclasses are likely to do interesting things with the
* implementation so some things are extra efficient.
*
* @param out The writer into which to place the contents of this body
- * evaluation
+ * evaluation
*/
public void writeOut(Writer out) throws IOException {
if (writer == null) {
@@ -550,7 +549,7 @@
// it doesn't allow to flush.
}
}
-
+
/**
* Sets the writer to which all output is written.
*/
@@ -576,33 +575,33 @@
clearBody();
}
}
-
+
private void ensureOpen() throws IOException {
if (closed) throw new IOException("Stream closed");
}
-
+
/**
* Reallocates buffer since the spec requires it to be unbounded.
*/
private void reAllocBuff(int len) {
-
+
if (bufferSize + len <= cb.length) {
bufferSize = cb.length;
return;
}
-
+
if (len < cb.length) {
len = cb.length;
}
-
+
bufferSize = cb.length + len;
char[] tmp = new char[bufferSize];
-
+
System.arraycopy(cb, 0, tmp, 0, cb.length);
cb = tmp;
tmp = null;
-
+
}
-
-
+
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/HttpJspBase.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/HttpJspBase.java
index 49087b2..95444dc 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/HttpJspBase.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/HttpJspBase.java
@@ -33,35 +33,35 @@
*
* @author Anil K. Vijendran
*/
-public abstract class HttpJspBase
- extends HttpServlet
- implements HttpJspPage
-
-
+public abstract class HttpJspBase
+ extends HttpServlet
+ implements HttpJspPage
+
+
{
-
+
static {
- if( JspFactory.getDefaultFactory() == null ) {
+ if (JspFactory.getDefaultFactory() == null) {
JspFactoryImpl factory = new JspFactoryImpl();
- if( System.getSecurityManager() != null ) {
+ if (System.getSecurityManager() != null) {
String basePackage = "org.apache.struts2.jasper.";
try {
- factory.getClass().getClassLoader().loadClass( basePackage +
- "runtime.JspFactoryImpl$PrivilegedGetPageContext");
- factory.getClass().getClassLoader().loadClass( basePackage +
- "runtime.JspFactoryImpl$PrivilegedReleasePageContext");
- factory.getClass().getClassLoader().loadClass( basePackage +
- "runtime.JspRuntimeLibrary");
- factory.getClass().getClassLoader().loadClass( basePackage +
- "runtime.JspRuntimeLibrary$PrivilegedIntrospectHelper");
- factory.getClass().getClassLoader().loadClass( basePackage +
- "runtime.ServletResponseWrapperInclude");
- factory.getClass().getClassLoader().loadClass( basePackage +
- "servlet.JspServletWrapper");
+ factory.getClass().getClassLoader().loadClass(basePackage +
+ "runtime.JspFactoryImpl$PrivilegedGetPageContext");
+ factory.getClass().getClassLoader().loadClass(basePackage +
+ "runtime.JspFactoryImpl$PrivilegedReleasePageContext");
+ factory.getClass().getClassLoader().loadClass(basePackage +
+ "runtime.JspRuntimeLibrary");
+ factory.getClass().getClassLoader().loadClass(basePackage +
+ "runtime.JspRuntimeLibrary$PrivilegedIntrospectHelper");
+ factory.getClass().getClassLoader().loadClass(basePackage +
+ "runtime.ServletResponseWrapperInclude");
+ factory.getClass().getClassLoader().loadClass(basePackage +
+ "servlet.JspServletWrapper");
} catch (ClassNotFoundException ex) {
- org.apache.commons.logging.LogFactory.getLog( HttpJspBase.class )
- .error("Jasper JspRuntimeContext preload of class failed: " +
- ex.getMessage(), ex);
+ org.apache.commons.logging.LogFactory.getLog(HttpJspBase.class)
+ .error("Jasper JspRuntimeContext preload of class failed: " +
+ ex.getMessage(), ex);
}
}
JspFactory.setDefaultFactory(factory);
@@ -71,32 +71,30 @@
protected HttpJspBase() {
}
- public final void init(ServletConfig config)
- throws ServletException
- {
+ public final void init(ServletConfig config)
+ throws ServletException {
super.init(config);
- jspInit();
+ jspInit();
_jspInit();
}
-
+
public String getServletInfo() {
- return Localizer.getMessage("jsp.engine.info");
+ return Localizer.getMessage("jsp.engine.info");
}
public final void destroy() {
- jspDestroy();
- _jspDestroy();
+ jspDestroy();
+ _jspDestroy();
}
/**
* Entry point into service.
*/
- public final void service(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException
- {
+ public final void service(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
_jspService(request, response);
}
-
+
public void jspInit() {
}
@@ -109,7 +107,7 @@
protected void _jspDestroy() {
}
- public abstract void _jspService(HttpServletRequest request,
- HttpServletResponse response)
- throws ServletException, IOException;
+ public abstract void _jspService(HttpServletRequest request,
+ HttpServletResponse response)
+ throws ServletException, IOException;
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspContextWrapper.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspContextWrapper.java
index cb88cd8..49ca0d7 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspContextWrapper.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspContextWrapper.java
@@ -36,7 +36,7 @@
/**
* Implementation of a JSP Context Wrapper.
- *
+ * <p/>
* The JSP Context Wrapper is a JspContext created and maintained by a tag
* handler implementation. It wraps the Invoking JSP Context, that is, the
* JspContext instance passed to the tag handler by the invoking page via
@@ -46,12 +46,12 @@
* @author Jan Luehe
*/
public class JspContextWrapper
- extends PageContext implements VariableResolver {
+ extends PageContext implements VariableResolver {
// Invoking JSP context
private PageContext invokingJspCtxt;
- private transient Hashtable pageAttributes;
+ private transient Hashtable pageAttributes;
// ArrayList of NESTED scripting variables
private ArrayList nestedVars;
@@ -70,225 +70,222 @@
* The variable resolver, for evaluating EL expressions.
*/
private VariableResolverImpl variableResolver
- = new VariableResolverImpl(this);
+ = new VariableResolverImpl(this);
public JspContextWrapper(JspContext jspContext, ArrayList nestedVars,
- ArrayList atBeginVars, ArrayList atEndVars,
- Map aliases) {
+ ArrayList atBeginVars, ArrayList atEndVars,
+ Map aliases) {
this.invokingJspCtxt = (PageContext) jspContext;
- this.nestedVars = nestedVars;
- this.atBeginVars = atBeginVars;
- this.atEndVars = atEndVars;
- this.pageAttributes = new Hashtable(16);
- this.aliases = aliases;
+ this.nestedVars = nestedVars;
+ this.atBeginVars = atBeginVars;
+ this.atEndVars = atEndVars;
+ this.pageAttributes = new Hashtable(16);
+ this.aliases = aliases;
- if (nestedVars != null) {
- this.originalNestedVars = new Hashtable(nestedVars.size());
- }
- syncBeginTagFile();
+ if (nestedVars != null) {
+ this.originalNestedVars = new Hashtable(nestedVars.size());
+ }
+ syncBeginTagFile();
}
public void initialize(Servlet servlet, ServletRequest request,
ServletResponse response, String errorPageURL,
boolean needsSession, int bufferSize,
boolean autoFlush)
- throws IOException, IllegalStateException, IllegalArgumentException
- {
+ throws IOException, IllegalStateException, IllegalArgumentException {
}
-
+
public Object getAttribute(String name) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
- return pageAttributes.get(name);
+ return pageAttributes.get(name);
}
public Object getAttribute(String name, int scope) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
- if (scope == PAGE_SCOPE) {
- return pageAttributes.get(name);
- }
+ if (scope == PAGE_SCOPE) {
+ return pageAttributes.get(name);
+ }
- return invokingJspCtxt.getAttribute(name, scope);
+ return invokingJspCtxt.getAttribute(name, scope);
}
public void setAttribute(String name, Object value) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
- if (value != null) {
- pageAttributes.put(name, value);
- } else {
- removeAttribute(name, PAGE_SCOPE);
- }
+ if (value != null) {
+ pageAttributes.put(name, value);
+ } else {
+ removeAttribute(name, PAGE_SCOPE);
+ }
}
public void setAttribute(String name, Object value, int scope) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
- if (scope == PAGE_SCOPE) {
- if (value != null) {
- pageAttributes.put(name, value);
- } else {
- removeAttribute(name, PAGE_SCOPE);
- }
- } else {
- invokingJspCtxt.setAttribute(name, value, scope);
- }
+ if (scope == PAGE_SCOPE) {
+ if (value != null) {
+ pageAttributes.put(name, value);
+ } else {
+ removeAttribute(name, PAGE_SCOPE);
+ }
+ } else {
+ invokingJspCtxt.setAttribute(name, value, scope);
+ }
}
public Object findAttribute(String name) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
Object o = pageAttributes.get(name);
if (o == null) {
- o = invokingJspCtxt.getAttribute(name, REQUEST_SCOPE);
- if (o == null) {
- if (getSession() != null) {
- o = invokingJspCtxt.getAttribute(name, SESSION_SCOPE);
- }
- if (o == null) {
- o = invokingJspCtxt.getAttribute(name, APPLICATION_SCOPE);
- }
- }
- }
+ o = invokingJspCtxt.getAttribute(name, REQUEST_SCOPE);
+ if (o == null) {
+ if (getSession() != null) {
+ o = invokingJspCtxt.getAttribute(name, SESSION_SCOPE);
+ }
+ if (o == null) {
+ o = invokingJspCtxt.getAttribute(name, APPLICATION_SCOPE);
+ }
+ }
+ }
- return o;
+ return o;
}
public void removeAttribute(String name) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
- pageAttributes.remove(name);
- invokingJspCtxt.removeAttribute(name, REQUEST_SCOPE);
- if (getSession() != null) {
- invokingJspCtxt.removeAttribute(name, SESSION_SCOPE);
- }
- invokingJspCtxt.removeAttribute(name, APPLICATION_SCOPE);
+ pageAttributes.remove(name);
+ invokingJspCtxt.removeAttribute(name, REQUEST_SCOPE);
+ if (getSession() != null) {
+ invokingJspCtxt.removeAttribute(name, SESSION_SCOPE);
+ }
+ invokingJspCtxt.removeAttribute(name, APPLICATION_SCOPE);
}
public void removeAttribute(String name, int scope) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
- if (scope == PAGE_SCOPE){
- pageAttributes.remove(name);
- } else {
- invokingJspCtxt.removeAttribute(name, scope);
- }
+ if (scope == PAGE_SCOPE) {
+ pageAttributes.remove(name);
+ } else {
+ invokingJspCtxt.removeAttribute(name, scope);
+ }
}
public int getAttributesScope(String name) {
- if (name == null) {
- throw new NullPointerException(
- Localizer.getMessage("jsp.error.attribute.null_name"));
- }
+ if (name == null) {
+ throw new NullPointerException(
+ Localizer.getMessage("jsp.error.attribute.null_name"));
+ }
- if (pageAttributes.get(name) != null) {
- return PAGE_SCOPE;
- } else {
- return invokingJspCtxt.getAttributesScope(name);
- }
+ if (pageAttributes.get(name) != null) {
+ return PAGE_SCOPE;
+ } else {
+ return invokingJspCtxt.getAttributesScope(name);
+ }
}
public Enumeration getAttributeNamesInScope(int scope) {
if (scope == PAGE_SCOPE) {
return pageAttributes.keys();
- }
+ }
- return invokingJspCtxt.getAttributeNamesInScope(scope);
+ return invokingJspCtxt.getAttributeNamesInScope(scope);
}
public void release() {
- invokingJspCtxt.release();
+ invokingJspCtxt.release();
}
public JspWriter getOut() {
- return invokingJspCtxt.getOut();
+ return invokingJspCtxt.getOut();
}
public HttpSession getSession() {
- return invokingJspCtxt.getSession();
+ return invokingJspCtxt.getSession();
}
public Object getPage() {
- return invokingJspCtxt.getPage();
+ return invokingJspCtxt.getPage();
}
public ServletRequest getRequest() {
- return invokingJspCtxt.getRequest();
+ return invokingJspCtxt.getRequest();
}
public ServletResponse getResponse() {
- return invokingJspCtxt.getResponse();
+ return invokingJspCtxt.getResponse();
}
public Exception getException() {
- return invokingJspCtxt.getException();
+ return invokingJspCtxt.getException();
}
public ServletConfig getServletConfig() {
- return invokingJspCtxt.getServletConfig();
+ return invokingJspCtxt.getServletConfig();
}
public ServletContext getServletContext() {
- return invokingJspCtxt.getServletContext();
+ return invokingJspCtxt.getServletContext();
}
public void forward(String relativeUrlPath)
- throws ServletException, IOException
- {
- invokingJspCtxt.forward(relativeUrlPath);
+ throws ServletException, IOException {
+ invokingJspCtxt.forward(relativeUrlPath);
}
public void include(String relativeUrlPath)
- throws ServletException, IOException
- {
- invokingJspCtxt.include(relativeUrlPath);
+ throws ServletException, IOException {
+ invokingJspCtxt.include(relativeUrlPath);
}
- public void include(String relativeUrlPath, boolean flush)
- throws ServletException, IOException {
- include(relativeUrlPath, false); // XXX
+ public void include(String relativeUrlPath, boolean flush)
+ throws ServletException, IOException {
+ include(relativeUrlPath, false); // XXX
}
public VariableResolver getVariableResolver() {
- return this;
+ return this;
}
public BodyContent pushBody() {
- return invokingJspCtxt.pushBody();
+ return invokingJspCtxt.pushBody();
}
public JspWriter pushBody(Writer writer) {
- return invokingJspCtxt.pushBody(writer);
+ return invokingJspCtxt.pushBody(writer);
}
public JspWriter popBody() {
@@ -296,28 +293,25 @@
}
public ExpressionEvaluator getExpressionEvaluator() {
- return invokingJspCtxt.getExpressionEvaluator();
+ return invokingJspCtxt.getExpressionEvaluator();
}
public void handlePageException(Exception ex)
- throws IOException, ServletException
- {
- // Should never be called since handleException() called with a
- // Throwable in the generated servlet.
- handlePageException((Throwable) ex);
+ throws IOException, ServletException {
+ // Should never be called since handleException() called with a
+ // Throwable in the generated servlet.
+ handlePageException((Throwable) ex);
}
public void handlePageException(Throwable t)
- throws IOException, ServletException
- {
- invokingJspCtxt.handlePageException(t);
+ throws IOException, ServletException {
+ invokingJspCtxt.handlePageException(t);
}
/**
* VariableResolver interface
*/
- public Object resolveVariable( String pName ) throws ELException
- {
+ public Object resolveVariable(String pName) throws ELException {
return variableResolver.resolveVariable(pName);
}
@@ -325,24 +319,24 @@
* Synchronize variables at begin of tag file
*/
public void syncBeginTagFile() {
- saveNestedVariables();
+ saveNestedVariables();
}
/**
* Synchronize variables before fragment invokation
*/
public void syncBeforeInvoke() {
- copyTagToPageScope(VariableInfo.NESTED);
- copyTagToPageScope(VariableInfo.AT_BEGIN);
+ copyTagToPageScope(VariableInfo.NESTED);
+ copyTagToPageScope(VariableInfo.AT_BEGIN);
}
/**
* Synchronize variables at end of tag file
*/
public void syncEndTagFile() {
- copyTagToPageScope(VariableInfo.AT_BEGIN);
- copyTagToPageScope(VariableInfo.AT_END);
- restoreNestedVariables();
+ copyTagToPageScope(VariableInfo.AT_BEGIN);
+ copyTagToPageScope(VariableInfo.AT_END);
+ restoreNestedVariables();
}
/**
@@ -352,36 +346,36 @@
* @param scope variable scope (one of NESTED, AT_BEGIN, or AT_END)
*/
private void copyTagToPageScope(int scope) {
- Iterator iter = null;
+ Iterator iter = null;
- switch (scope) {
- case VariableInfo.NESTED:
- if (nestedVars != null) {
- iter = nestedVars.iterator();
- }
- break;
- case VariableInfo.AT_BEGIN:
- if (atBeginVars != null) {
- iter = atBeginVars.iterator();
- }
- break;
- case VariableInfo.AT_END:
- if (atEndVars != null) {
- iter = atEndVars.iterator();
- }
- break;
- }
+ switch (scope) {
+ case VariableInfo.NESTED:
+ if (nestedVars != null) {
+ iter = nestedVars.iterator();
+ }
+ break;
+ case VariableInfo.AT_BEGIN:
+ if (atBeginVars != null) {
+ iter = atBeginVars.iterator();
+ }
+ break;
+ case VariableInfo.AT_END:
+ if (atEndVars != null) {
+ iter = atEndVars.iterator();
+ }
+ break;
+ }
- while ((iter != null) && iter.hasNext()) {
- String varName = (String) iter.next();
- Object obj = getAttribute(varName);
- varName = findAlias(varName);
- if (obj != null) {
- invokingJspCtxt.setAttribute(varName, obj);
- } else {
- invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
- }
- }
+ while ((iter != null) && iter.hasNext()) {
+ String varName = (String) iter.next();
+ Object obj = getAttribute(varName);
+ varName = findAlias(varName);
+ if (obj != null) {
+ invokingJspCtxt.setAttribute(varName, obj);
+ } else {
+ invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
+ }
+ }
}
/**
@@ -389,17 +383,17 @@
* the invoking JSP context, so they can later be restored.
*/
private void saveNestedVariables() {
- if (nestedVars != null) {
- Iterator iter = nestedVars.iterator();
- while (iter.hasNext()) {
- String varName = (String) iter.next();
- varName = findAlias(varName);
- Object obj = invokingJspCtxt.getAttribute(varName);
- if (obj != null) {
- originalNestedVars.put(varName, obj);
- }
- }
- }
+ if (nestedVars != null) {
+ Iterator iter = nestedVars.iterator();
+ while (iter.hasNext()) {
+ String varName = (String) iter.next();
+ varName = findAlias(varName);
+ Object obj = invokingJspCtxt.getAttribute(varName);
+ if (obj != null) {
+ originalNestedVars.put(varName, obj);
+ }
+ }
+ }
}
/**
@@ -407,19 +401,19 @@
* context.
*/
private void restoreNestedVariables() {
- if (nestedVars != null) {
- Iterator iter = nestedVars.iterator();
- while (iter.hasNext()) {
- String varName = (String) iter.next();
- varName = findAlias(varName);
- Object obj = originalNestedVars.get(varName);
- if (obj != null) {
- invokingJspCtxt.setAttribute(varName, obj);
- } else {
- invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
- }
- }
- }
+ if (nestedVars != null) {
+ Iterator iter = nestedVars.iterator();
+ while (iter.hasNext()) {
+ String varName = (String) iter.next();
+ varName = findAlias(varName);
+ Object obj = originalNestedVars.get(varName);
+ if (obj != null) {
+ invokingJspCtxt.setAttribute(varName, obj);
+ } else {
+ invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE);
+ }
+ }
+ }
}
/**
@@ -428,18 +422,18 @@
*
* @param varName The variable name to check
* @return The variable name for which varName is used as an alias, or
- * varName if it is not being used as an alias
+ * varName if it is not being used as an alias
*/
private String findAlias(String varName) {
- if (aliases == null)
- return varName;
+ if (aliases == null)
+ return varName;
- String alias = (String) aliases.get(varName);
- if (alias == null) {
- return varName;
- }
- return alias;
+ String alias = (String) aliases.get(varName);
+ if (alias == null) {
+ return varName;
+ }
+ return alias;
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFactoryImpl.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFactoryImpl.java
index 6c0dee1..8d68de8 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFactoryImpl.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFactoryImpl.java
@@ -16,8 +16,8 @@
*/
package org.apache.struts2.jasper.runtime;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.util.SimplePool;
import javax.servlet.Servlet;
@@ -37,72 +37,72 @@
public class JspFactoryImpl extends JspFactory {
// Logger
- private Log log = LogFactory.getLog(JspFactoryImpl.class);
+ private Logger log = LoggerFactory.getLogger(JspFactoryImpl.class);
private static final String SPEC_VERSION = "2.0";
- private static final boolean USE_POOL =
- Boolean.valueOf(System.getProperty("org.apache.struts2.jasper.runtime.JspFactoryImpl.USE_POOL", "true")).booleanValue();
+ private static final boolean USE_POOL =
+ Boolean.valueOf(System.getProperty("org.apache.struts2.jasper.runtime.JspFactoryImpl.USE_POOL", "true")).booleanValue();
private SimplePool pool = new SimplePool(100);
-
+
public PageContext getPageContext(Servlet servlet,
- ServletRequest request,
+ ServletRequest request,
ServletResponse response,
- String errorPageURL,
+ String errorPageURL,
boolean needsSession,
- int bufferSize,
+ int bufferSize,
boolean autoflush) {
- if( System.getSecurityManager() != null ) {
- PrivilegedGetPageContext dp = new PrivilegedGetPageContext(
- (JspFactoryImpl)this, servlet, request, response, errorPageURL,
- needsSession, bufferSize, autoflush);
- return (PageContext)AccessController.doPrivileged(dp);
- } else {
- return internalGetPageContext(servlet, request, response,
- errorPageURL, needsSession,
- bufferSize, autoflush);
- }
+ if (System.getSecurityManager() != null) {
+ PrivilegedGetPageContext dp = new PrivilegedGetPageContext(
+ (JspFactoryImpl) this, servlet, request, response, errorPageURL,
+ needsSession, bufferSize, autoflush);
+ return (PageContext) AccessController.doPrivileged(dp);
+ } else {
+ return internalGetPageContext(servlet, request, response,
+ errorPageURL, needsSession,
+ bufferSize, autoflush);
+ }
}
public void releasePageContext(PageContext pc) {
- if( pc == null )
- return;
- if( System.getSecurityManager() != null ) {
+ if (pc == null)
+ return;
+ if (System.getSecurityManager() != null) {
PrivilegedReleasePageContext dp = new PrivilegedReleasePageContext(
- (JspFactoryImpl)this,pc);
+ (JspFactoryImpl) this, pc);
AccessController.doPrivileged(dp);
} else {
internalReleasePageContext(pc);
- }
+ }
}
public JspEngineInfo getEngineInfo() {
return new JspEngineInfo() {
- public String getSpecificationVersion() {
- return SPEC_VERSION;
- }
- };
+ public String getSpecificationVersion() {
+ return SPEC_VERSION;
+ }
+ };
}
private PageContext internalGetPageContext(Servlet servlet,
- ServletRequest request,
- ServletResponse response,
- String errorPageURL,
- boolean needsSession,
- int bufferSize,
- boolean autoflush) {
+ ServletRequest request,
+ ServletResponse response,
+ String errorPageURL,
+ boolean needsSession,
+ int bufferSize,
+ boolean autoflush) {
try {
- PageContext pc;
- if( USE_POOL ) {
+ PageContext pc;
+ if (USE_POOL) {
pc = (PageContext) pool.get();
- if( pc == null ) {
- pc= new PageContextImpl(this);
- }
- } else {
- pc = new PageContextImpl(this);
- }
- pc.initialize(servlet, request, response, errorPageURL,
- needsSession, bufferSize, autoflush);
+ if (pc == null) {
+ pc = new PageContextImpl(this);
+ }
+ } else {
+ pc = new PageContextImpl(this);
+ }
+ pc.initialize(servlet, request, response, errorPageURL,
+ needsSession, bufferSize, autoflush);
return pc;
} catch (Throwable ex) {
/* FIXME: need to do something reasonable here!! */
@@ -113,65 +113,65 @@
private void internalReleasePageContext(PageContext pc) {
pc.release();
- if (USE_POOL && (pc instanceof PageContextImpl)) {
- pool.put( pc );
- }
+ if (USE_POOL && (pc instanceof PageContextImpl)) {
+ pool.put(pc);
+ }
}
private class PrivilegedGetPageContext implements PrivilegedAction {
- private JspFactoryImpl factory;
- private Servlet servlet;
- private ServletRequest request;
- private ServletResponse response;
- private String errorPageURL;
- private boolean needsSession;
- private int bufferSize;
- private boolean autoflush;
+ private JspFactoryImpl factory;
+ private Servlet servlet;
+ private ServletRequest request;
+ private ServletResponse response;
+ private String errorPageURL;
+ private boolean needsSession;
+ private int bufferSize;
+ private boolean autoflush;
- PrivilegedGetPageContext(JspFactoryImpl factory,
- Servlet servlet,
- ServletRequest request,
- ServletResponse response,
- String errorPageURL,
- boolean needsSession,
- int bufferSize,
- boolean autoflush) {
- this.factory = factory;
- this.servlet = servlet;
- this.request = request;
- this.response = response;
- this.errorPageURL = errorPageURL;
- this.needsSession = needsSession;
- this.bufferSize = bufferSize;
- this.autoflush = autoflush;
- }
-
- public Object run() {
- return factory.internalGetPageContext(servlet,
- request,
- response,
- errorPageURL,
- needsSession,
- bufferSize,
- autoflush);
- }
+ PrivilegedGetPageContext(JspFactoryImpl factory,
+ Servlet servlet,
+ ServletRequest request,
+ ServletResponse response,
+ String errorPageURL,
+ boolean needsSession,
+ int bufferSize,
+ boolean autoflush) {
+ this.factory = factory;
+ this.servlet = servlet;
+ this.request = request;
+ this.response = response;
+ this.errorPageURL = errorPageURL;
+ this.needsSession = needsSession;
+ this.bufferSize = bufferSize;
+ this.autoflush = autoflush;
+ }
+
+ public Object run() {
+ return factory.internalGetPageContext(servlet,
+ request,
+ response,
+ errorPageURL,
+ needsSession,
+ bufferSize,
+ autoflush);
+ }
}
private class PrivilegedReleasePageContext implements PrivilegedAction {
private JspFactoryImpl factory;
- private PageContext pageContext;
+ private PageContext pageContext;
PrivilegedReleasePageContext(JspFactoryImpl factory,
- PageContext pageContext) {
+ PageContext pageContext) {
this.factory = factory;
this.pageContext = pageContext;
}
public Object run() {
factory.internalReleasePageContext(pageContext);
- return null;
+ return null;
}
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFragmentHelper.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFragmentHelper.java
index bd7db42..d354be2 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFragmentHelper.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspFragmentHelper.java
@@ -27,39 +27,37 @@
* This class allows for the emulation of numerous fragments within
* a single class, which in turn reduces the load on the class loader
* since there are potentially many JspFragments in a single page.
- * <p>
+ * <p/>
* The class also provides various utility methods for JspFragment
* implementations.
*
* @author Mark Roth
*/
-public abstract class JspFragmentHelper
- extends JspFragment
-{
-
+public abstract class JspFragmentHelper
+ extends JspFragment {
+
protected int discriminator;
protected JspContext jspContext;
protected PageContext _jspx_page_context;
protected JspTag parentTag;
- public JspFragmentHelper( int discriminator, JspContext jspContext,
- JspTag parentTag )
- {
+ public JspFragmentHelper(int discriminator, JspContext jspContext,
+ JspTag parentTag) {
this.discriminator = discriminator;
this.jspContext = jspContext;
this._jspx_page_context = null;
- if( jspContext instanceof PageContext ) {
- _jspx_page_context = (PageContext)jspContext;
+ if (jspContext instanceof PageContext) {
+ _jspx_page_context = (PageContext) jspContext;
}
this.parentTag = parentTag;
}
-
+
public JspContext getJspContext() {
return this.jspContext;
}
-
+
public JspTag getParentTag() {
return this.parentTag;
}
-
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspRuntimeLibrary.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspRuntimeLibrary.java
index 3c6a3f7..0815962 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspRuntimeLibrary.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspRuntimeLibrary.java
@@ -41,8 +41,8 @@
/**
* Bunch of util methods that are used by code generated for useBean,
- * getProperty and setProperty.
- *
+ * getProperty and setProperty.
+ * <p/>
* The __begin, __end stuff is there so that the JSP engine can
* actually parse this file and inline them if people don't want
* runtime dependencies on this class. However, I'm not sure if that
@@ -52,14 +52,14 @@
* @author Shawn Bayern
*/
public class JspRuntimeLibrary {
-
+
private static final String SERVLET_EXCEPTION
- = "javax.servlet.error.exception";
+ = "javax.servlet.error.exception";
private static final String JSP_EXCEPTION
- = "javax.servlet.jsp.jspException";
+ = "javax.servlet.jsp.jspException";
protected static class PrivilegedIntrospectHelper
- implements PrivilegedExceptionAction {
+ implements PrivilegedExceptionAction {
private Object bean;
private String prop;
@@ -70,8 +70,7 @@
PrivilegedIntrospectHelper(Object bean, String prop,
String value, ServletRequest request,
- String param, boolean ignoreMethodNF)
- {
+ String param, boolean ignoreMethodNF) {
this.bean = bean;
this.prop = prop;
this.value = value;
@@ -79,10 +78,10 @@
this.param = param;
this.ignoreMethodNF = ignoreMethodNF;
}
-
+
public Object run() throws JasperException {
internalIntrospecthelper(
- bean,prop,value,request,param,ignoreMethodNF);
+ bean, prop, value, request, param, ignoreMethodNF);
return null;
}
}
@@ -91,7 +90,7 @@
* Returns the value of the javax.servlet.error.exception request
* attribute value, if present, otherwise the value of the
* javax.servlet.jsp.jspException request attribute value.
- *
+ * <p/>
* This method is called at the beginning of the generated servlet code
* for a JSP error page, when the "exception" implicit scripting language
* variable is initialized.
@@ -134,7 +133,7 @@
return (char) 0;
} else {
// this trick avoids escaping issues
- return (char)(int) s.charAt(0);
+ return (char) (int) s.charAt(0);
}
}
@@ -190,7 +189,7 @@
} else if (target == Character.class) {
if (isNullOrEmpty)
return new Character((char) 0);
- else
+ else
return new Character(s.charAt(0));
} else if (target == Double.class) {
if (isNullOrEmpty)
@@ -222,11 +221,10 @@
}
}
- // __begin convertMethod
+ // __begin convertMethod
public static Object convert(String propertyName, String s, Class t,
- Class propertyEditorClass)
- throws JasperException
- {
+ Class propertyEditorClass)
+ throws JasperException {
try {
if (s == null) {
if (t.equals(Boolean.class) || t.equals(Boolean.TYPE))
@@ -236,36 +234,36 @@
}
if (propertyEditorClass != null) {
return getValueFromBeanInfoPropertyEditor(
- t, propertyName, s, propertyEditorClass);
- } else if ( t.equals(Boolean.class) || t.equals(Boolean.TYPE) ) {
+ t, propertyName, s, propertyEditorClass);
+ } else if (t.equals(Boolean.class) || t.equals(Boolean.TYPE)) {
if (s.equalsIgnoreCase("on") || s.equalsIgnoreCase("true"))
s = "true";
else
s = "false";
return new Boolean(s);
- } else if ( t.equals(Byte.class) || t.equals(Byte.TYPE) ) {
+ } else if (t.equals(Byte.class) || t.equals(Byte.TYPE)) {
return new Byte(s);
} else if (t.equals(Character.class) || t.equals(Character.TYPE)) {
return s.length() > 0 ? new Character(s.charAt(0)) : null;
- } else if ( t.equals(Short.class) || t.equals(Short.TYPE) ) {
+ } else if (t.equals(Short.class) || t.equals(Short.TYPE)) {
return new Short(s);
- } else if ( t.equals(Integer.class) || t.equals(Integer.TYPE) ) {
+ } else if (t.equals(Integer.class) || t.equals(Integer.TYPE)) {
return new Integer(s);
- } else if ( t.equals(Float.class) || t.equals(Float.TYPE) ) {
+ } else if (t.equals(Float.class) || t.equals(Float.TYPE)) {
return new Float(s);
- } else if ( t.equals(Long.class) || t.equals(Long.TYPE) ) {
+ } else if (t.equals(Long.class) || t.equals(Long.TYPE)) {
return new Long(s);
- } else if ( t.equals(Double.class) || t.equals(Double.TYPE) ) {
+ } else if (t.equals(Double.class) || t.equals(Double.TYPE)) {
return new Double(s);
- } else if ( t.equals(String.class) ) {
+ } else if (t.equals(String.class)) {
return s;
- } else if ( t.equals(java.io.File.class) ) {
+ } else if (t.equals(java.io.File.class)) {
return new java.io.File(s);
} else if (t.getName().equals("java.lang.Object")) {
- return new Object[] {s};
+ return new Object[]{s};
} else {
return getValueFromPropertyEditorManager(
- t, propertyName, s);
+ t, propertyName, s);
}
} catch (Exception ex) {
throw new JasperException(ex);
@@ -274,84 +272,83 @@
// __end convertMethod
// __begin introspectMethod
+
public static void introspect(Object bean, ServletRequest request)
- throws JasperException
- {
+ throws JasperException {
Enumeration e = request.getParameterNames();
- while ( e.hasMoreElements() ) {
- String name = (String) e.nextElement();
+ while (e.hasMoreElements()) {
+ String name = (String) e.nextElement();
String value = request.getParameter(name);
introspecthelper(bean, name, value, request, name, true);
}
}
// __end introspectMethod
-
+
// __begin introspecthelperMethod
+
public static void introspecthelper(Object bean, String prop,
String value, ServletRequest request,
String param, boolean ignoreMethodNF)
- throws JasperException
- {
- if( System.getSecurityManager() != null ) {
+ throws JasperException {
+ if (System.getSecurityManager() != null) {
try {
PrivilegedIntrospectHelper dp =
- new PrivilegedIntrospectHelper(
- bean,prop,value,request,param,ignoreMethodNF);
+ new PrivilegedIntrospectHelper(
+ bean, prop, value, request, param, ignoreMethodNF);
AccessController.doPrivileged(dp);
- } catch( PrivilegedActionException pe) {
+ } catch (PrivilegedActionException pe) {
Exception e = pe.getException();
- throw (JasperException)e;
+ throw (JasperException) e;
}
} else {
internalIntrospecthelper(
- bean,prop,value,request,param,ignoreMethodNF);
+ bean, prop, value, request, param, ignoreMethodNF);
}
}
private static void internalIntrospecthelper(Object bean, String prop,
- String value, ServletRequest request,
- String param, boolean ignoreMethodNF)
- throws JasperException
- {
+ String value, ServletRequest request,
+ String param, boolean ignoreMethodNF)
+ throws JasperException {
Method method = null;
Class type = null;
Class propertyEditorClass = null;
try {
java.beans.BeanInfo info
- = java.beans.Introspector.getBeanInfo(bean.getClass());
- if ( info != null ) {
+ = java.beans.Introspector.getBeanInfo(bean.getClass());
+ if (info != null) {
java.beans.PropertyDescriptor pd[]
- = info.getPropertyDescriptors();
- for (int i = 0 ; i < pd.length ; i++) {
- if ( pd[i].getName().equals(prop) ) {
+ = info.getPropertyDescriptors();
+ for (int i = 0; i < pd.length; i++) {
+ if (pd[i].getName().equals(prop)) {
method = pd[i].getWriteMethod();
- type = pd[i].getPropertyType();
+ type = pd[i].getPropertyType();
propertyEditorClass = pd[i].getPropertyEditorClass();
break;
}
}
}
- if ( method != null ) {
+ if (method != null) {
if (type.isArray()) {
if (request == null) {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.setproperty.noindexset"));
+ Localizer.getMessage("jsp.error.beans.setproperty.noindexset"));
}
Class t = type.getComponentType();
String[] values = request.getParameterValues(param);
//XXX Please check.
- if(values == null) return;
- if(t.equals(String.class)) {
- method.invoke(bean, new Object[] { values });
+ if (values == null) return;
+ if (t.equals(String.class)) {
+ method.invoke(bean, new Object[]{values});
} else {
- createTypedArray (prop, bean, method, values, t,
- propertyEditorClass);
+ createTypedArray(prop, bean, method, values, t,
+ propertyEditorClass);
}
} else {
- if(value == null || (param != null && value.equals(""))) return;
+ if (value == null || (param != null && value.equals(""))) return;
Object oval = convert(prop, value, type, propertyEditorClass);
- if ( oval != null )
- method.invoke(bean, new Object[] { oval });
+ if (oval != null)
+ method.invoke(bean, new Object[]{oval});
}
}
} catch (Exception ex) {
@@ -360,24 +357,25 @@
if (!ignoreMethodNF && (method == null)) {
if (type == null) {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.noproperty",
- prop,
- bean.getClass().getName()));
+ Localizer.getMessage("jsp.error.beans.noproperty",
+ prop,
+ bean.getClass().getName()));
} else {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
- prop,
- type.getName(),
- bean.getClass().getName()));
+ Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
+ prop,
+ type.getName(),
+ bean.getClass().getName()));
}
}
}
// __end introspecthelperMethod
-
+
//-------------------------------------------------------------------
// functions to convert builtin Java data types to string.
//-------------------------------------------------------------------
// __begin toStringMethod
+
public static String toString(Object o) {
return String.valueOf(o);
}
@@ -427,174 +425,176 @@
String[] values,
Class t,
Class propertyEditorClass)
- throws JasperException {
+ throws JasperException {
try {
if (propertyEditorClass != null) {
Object[] tmpval = new Integer[values.length];
- for (int i=0; i<values.length; i++) {
+ for (int i = 0; i < values.length; i++) {
tmpval[i] = getValueFromBeanInfoPropertyEditor(
t, propertyName, values[i], propertyEditorClass);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Integer.class)) {
- Integer []tmpval = new Integer[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Integer (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ Integer[] tmpval = new Integer[values.length];
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Integer(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Byte.class)) {
Byte[] tmpval = new Byte[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Byte (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Byte(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Boolean.class)) {
Boolean[] tmpval = new Boolean[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Boolean (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Boolean(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Short.class)) {
Short[] tmpval = new Short[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Short (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Short(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Long.class)) {
Long[] tmpval = new Long[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Long (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Long(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Double.class)) {
Double[] tmpval = new Double[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Double (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Double(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Float.class)) {
Float[] tmpval = new Float[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = new Float (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = new Float(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(Character.class)) {
Character[] tmpval = new Character[values.length];
- for (int i = 0 ; i < values.length; i++)
+ for (int i = 0; i < values.length; i++)
tmpval[i] = new Character(values[i].charAt(0));
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(int.class)) {
- int []tmpval = new int[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = Integer.parseInt (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ int[] tmpval = new int[values.length];
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = Integer.parseInt(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(byte.class)) {
byte[] tmpval = new byte[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = Byte.parseByte (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = Byte.parseByte(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(boolean.class)) {
boolean[] tmpval = new boolean[values.length];
- for (int i = 0 ; i < values.length; i++)
+ for (int i = 0; i < values.length; i++)
tmpval[i] = (Boolean.valueOf(values[i])).booleanValue();
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(short.class)) {
short[] tmpval = new short[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = Short.parseShort (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = Short.parseShort(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(long.class)) {
long[] tmpval = new long[values.length];
- for (int i = 0 ; i < values.length; i++)
- tmpval[i] = Long.parseLong (values[i]);
- method.invoke (bean, new Object[] {tmpval});
+ for (int i = 0; i < values.length; i++)
+ tmpval[i] = Long.parseLong(values[i]);
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(double.class)) {
double[] tmpval = new double[values.length];
- for (int i = 0 ; i < values.length; i++)
+ for (int i = 0; i < values.length; i++)
tmpval[i] = Double.valueOf(values[i]).doubleValue();
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(float.class)) {
float[] tmpval = new float[values.length];
- for (int i = 0 ; i < values.length; i++)
+ for (int i = 0; i < values.length; i++)
tmpval[i] = Float.valueOf(values[i]).floatValue();
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
} else if (t.equals(char.class)) {
char[] tmpval = new char[values.length];
- for (int i = 0 ; i < values.length; i++)
+ for (int i = 0; i < values.length; i++)
tmpval[i] = values[i].charAt(0);
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
} else {
Object[] tmpval = new Integer[values.length];
- for (int i=0; i<values.length; i++) {
- tmpval[i] =
- getValueFromPropertyEditorManager(
- t, propertyName, values[i]);
+ for (int i = 0; i < values.length; i++) {
+ tmpval[i] =
+ getValueFromPropertyEditorManager(
+ t, propertyName, values[i]);
}
- method.invoke (bean, new Object[] {tmpval});
+ method.invoke(bean, new Object[]{tmpval});
}
} catch (Exception ex) {
- throw new JasperException ("error in invoking method", ex);
+ throw new JasperException("error in invoking method", ex);
}
}
/**
* Escape special shell characters.
+ *
* @param unescString The string to shell-escape
* @return The escaped shell string.
*/
public static String escapeQueryString(String unescString) {
- if ( unescString == null )
- return null;
-
- String escString = "";
- String shellSpChars = "&;`'\"|*?~<>^()[]{}$\\\n";
-
- for(int index=0; index<unescString.length(); index++) {
- char nextChar = unescString.charAt(index);
+ if (unescString == null)
+ return null;
- if( shellSpChars.indexOf(nextChar) != -1 )
- escString += "\\";
+ String escString = "";
+ String shellSpChars = "&;`'\"|*?~<>^()[]{}$\\\n";
- escString += nextChar;
- }
- return escString;
+ for (int index = 0; index < unescString.length(); index++) {
+ char nextChar = unescString.charAt(index);
+
+ if (shellSpChars.indexOf(nextChar) != -1)
+ escString += "\\";
+
+ escString += nextChar;
+ }
+ return escString;
}
/**
* Decode an URL formatted string.
+ *
* @param encoded The string to decode.
* @return The decoded string.
*/
public static String decode(String encoded) {
// speedily leave if we're not needed
- if (encoded == null) return null;
+ if (encoded == null) return null;
if (encoded.indexOf('%') == -1 && encoded.indexOf('+') == -1)
- return encoded;
+ return encoded;
- //allocate the buffer - use byte[] to avoid calls to new.
+ //allocate the buffer - use byte[] to avoid calls to new.
byte holdbuffer[] = new byte[encoded.length()];
int bufcount = 0;
for (int count = 0; count < encoded.length(); count++) {
- char cur = encoded.charAt(count);
+ char cur = encoded.charAt(count);
if (cur == '%') {
- holdbuffer[bufcount++] =
- (byte)Integer.parseInt(encoded.substring(count+1,count+3),16);
+ holdbuffer[bufcount++] =
+ (byte) Integer.parseInt(encoded.substring(count + 1, count + 3), 16);
if (count + 2 >= encoded.length())
count = encoded.length();
else
count += 2;
} else if (cur == '+') {
- holdbuffer[bufcount++] = (byte) ' ';
- } else {
- holdbuffer[bufcount++] = (byte) cur;
+ holdbuffer[bufcount++] = (byte) ' ';
+ } else {
+ holdbuffer[bufcount++] = (byte) cur;
}
}
// REVISIT -- remedy for Deprecated warning.
- //return new String(holdbuffer,0,0,bufcount);
- return new String(holdbuffer,0,bufcount);
+ //return new String(holdbuffer,0,0,bufcount);
+ return new String(holdbuffer, 0, bufcount);
}
// __begin lookupReadMethodMethod
public static Object handleGetProperty(Object o, String prop)
- throws JasperException {
+ throws JasperException {
if (o == null) {
throw new JasperException(
Localizer.getMessage("jsp.error.beans.nullbean"));
@@ -604,48 +604,49 @@
Method method = getReadMethod(o.getClass(), prop);
value = method.invoke(o, null);
} catch (Exception ex) {
- throw new JasperException (ex);
+ throw new JasperException(ex);
}
return value;
}
// __end lookupReadMethodMethod
// handles <jsp:setProperty> with EL expression for 'value' attribute
-/** Use proprietaryEvaluate
+
+ /**
+ * Use proprietaryEvaluate
+ * public static void handleSetPropertyExpression(Object bean,
+ * String prop, String expression, PageContext pageContext,
+ * VariableResolver variableResolver, FunctionMapper functionMapper )
+ * throws JasperException
+ * {
+ * try {
+ * Method method = getWriteMethod(bean.getClass(), prop);
+ * method.invoke(bean, new Object[] {
+ * pageContext.getExpressionEvaluator().evaluate(
+ * expression,
+ * method.getParameterTypes()[0],
+ * variableResolver,
+ * functionMapper,
+ * null )
+ * });
+ * } catch (Exception ex) {
+ * throw new JasperException(ex);
+ * }
+ * }
+ */
public static void handleSetPropertyExpression(Object bean,
- String prop, String expression, PageContext pageContext,
- VariableResolver variableResolver, FunctionMapper functionMapper )
- throws JasperException
- {
+ String prop, String expression, PageContext pageContext,
+ ProtectedFunctionMapper functionMapper)
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] {
- pageContext.getExpressionEvaluator().evaluate(
- expression,
- method.getParameterTypes()[0],
- variableResolver,
- functionMapper,
- null )
- });
- } catch (Exception ex) {
- throw new JasperException(ex);
- }
- }
-**/
- public static void handleSetPropertyExpression(Object bean,
- String prop, String expression, PageContext pageContext,
- ProtectedFunctionMapper functionMapper )
- throws JasperException
- {
- try {
- Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] {
- PageContextImpl.proprietaryEvaluate(
- expression,
- method.getParameterTypes()[0],
- pageContext,
- functionMapper,
- false )
+ method.invoke(bean, new Object[]{
+ PageContextImpl.proprietaryEvaluate(
+ expression,
+ method.getParameterTypes()[0],
+ pageContext,
+ functionMapper,
+ false)
});
} catch (Exception ex) {
throw new JasperException(ex);
@@ -654,150 +655,141 @@
public static void handleSetProperty(Object bean, String prop,
Object value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { value });
+ method.invoke(bean, new Object[]{value});
} catch (Exception ex) {
throw new JasperException(ex);
}
}
-
+
public static void handleSetProperty(Object bean, String prop,
int value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Integer(value) });
+ method.invoke(bean, new Object[]{new Integer(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
-
+
public static void handleSetProperty(Object bean, String prop,
short value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Short(value) });
+ method.invoke(bean, new Object[]{new Short(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
-
+
public static void handleSetProperty(Object bean, String prop,
long value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Long(value) });
+ method.invoke(bean, new Object[]{new Long(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
- }
-
+ }
+ }
+
public static void handleSetProperty(Object bean, String prop,
double value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Double(value) });
+ method.invoke(bean, new Object[]{new Double(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
-
+
public static void handleSetProperty(Object bean, String prop,
float value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Float(value) });
+ method.invoke(bean, new Object[]{new Float(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
-
+
public static void handleSetProperty(Object bean, String prop,
char value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Character(value) });
+ method.invoke(bean, new Object[]{new Character(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
public static void handleSetProperty(Object bean, String prop,
byte value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Byte(value) });
+ method.invoke(bean, new Object[]{new Byte(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
-
+
public static void handleSetProperty(Object bean, String prop,
boolean value)
- throws JasperException
- {
+ throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
- method.invoke(bean, new Object[] { new Boolean(value) });
+ method.invoke(bean, new Object[]{new Boolean(value)});
} catch (Exception ex) {
throw new JasperException(ex);
- }
+ }
}
-
+
public static Method getWriteMethod(Class beanClass, String prop)
- throws JasperException {
- Method method = null;
+ throws JasperException {
+ Method method = null;
Class type = null;
try {
java.beans.BeanInfo info
- = java.beans.Introspector.getBeanInfo(beanClass);
- if ( info != null ) {
+ = java.beans.Introspector.getBeanInfo(beanClass);
+ if (info != null) {
java.beans.PropertyDescriptor pd[]
- = info.getPropertyDescriptors();
- for (int i = 0 ; i < pd.length ; i++) {
- if ( pd[i].getName().equals(prop) ) {
+ = info.getPropertyDescriptors();
+ for (int i = 0; i < pd.length; i++) {
+ if (pd[i].getName().equals(prop)) {
method = pd[i].getWriteMethod();
- type = pd[i].getPropertyType();
+ type = pd[i].getPropertyType();
break;
}
}
- } else {
+ } else {
// just in case introspection silently fails.
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.nobeaninfo",
- beanClass.getName()));
+ Localizer.getMessage("jsp.error.beans.nobeaninfo",
+ beanClass.getName()));
}
} catch (Exception ex) {
- throw new JasperException (ex);
+ throw new JasperException(ex);
}
if (method == null) {
if (type == null) {
throw new JasperException(
Localizer.getMessage("jsp.error.beans.noproperty",
- prop,
- beanClass.getName()));
+ prop,
+ beanClass.getName()));
} else {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
- prop,
- type.getName(),
- beanClass.getName()));
+ Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
+ prop,
+ type.getName(),
+ beanClass.getName()));
}
}
return method;
@@ -806,39 +798,39 @@
public static Method getReadMethod(Class beanClass, String prop)
throws JasperException {
- Method method = null;
+ Method method = null;
Class type = null;
try {
java.beans.BeanInfo info
- = java.beans.Introspector.getBeanInfo(beanClass);
- if ( info != null ) {
+ = java.beans.Introspector.getBeanInfo(beanClass);
+ if (info != null) {
java.beans.PropertyDescriptor pd[]
- = info.getPropertyDescriptors();
- for (int i = 0 ; i < pd.length ; i++) {
- if ( pd[i].getName().equals(prop) ) {
+ = info.getPropertyDescriptors();
+ for (int i = 0; i < pd.length; i++) {
+ if (pd[i].getName().equals(prop)) {
method = pd[i].getReadMethod();
- type = pd[i].getPropertyType();
+ type = pd[i].getPropertyType();
break;
}
}
- } else {
+ } else {
// just in case introspection silently fails.
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.nobeaninfo",
- beanClass.getName()));
+ Localizer.getMessage("jsp.error.beans.nobeaninfo",
+ beanClass.getName()));
}
} catch (Exception ex) {
- throw new JasperException (ex);
+ throw new JasperException(ex);
}
if (method == null) {
if (type == null) {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.noproperty", prop,
- beanClass.getName()));
+ Localizer.getMessage("jsp.error.beans.noproperty", prop,
+ beanClass.getName()));
} else {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.nomethod", prop,
- beanClass.getName()));
+ Localizer.getMessage("jsp.error.beans.nomethod", prop,
+ beanClass.getName()));
}
}
@@ -849,41 +841,39 @@
// PropertyEditor Support
public static Object getValueFromBeanInfoPropertyEditor(
- Class attrClass, String attrName, String attrValue,
- Class propertyEditorClass)
- throws JasperException
- {
+ Class attrClass, String attrName, String attrValue,
+ Class propertyEditorClass)
+ throws JasperException {
try {
- PropertyEditor pe = (PropertyEditor)propertyEditorClass.newInstance();
+ PropertyEditor pe = (PropertyEditor) propertyEditorClass.newInstance();
pe.setAsText(attrValue);
return pe.getValue();
} catch (Exception ex) {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.property.conversion",
- attrValue, attrClass.getName(), attrName,
- ex.getMessage()));
+ Localizer.getMessage("jsp.error.beans.property.conversion",
+ attrValue, attrClass.getName(), attrName,
+ ex.getMessage()));
}
}
public static Object getValueFromPropertyEditorManager(
- Class attrClass, String attrName, String attrValue)
- throws JasperException
- {
+ Class attrClass, String attrName, String attrValue)
+ throws JasperException {
try {
- PropertyEditor propEditor =
- PropertyEditorManager.findEditor(attrClass);
+ PropertyEditor propEditor =
+ PropertyEditorManager.findEditor(attrClass);
if (propEditor != null) {
propEditor.setAsText(attrValue);
return propEditor.getValue();
} else {
throw new IllegalArgumentException(
- Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
+ Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
}
} catch (IllegalArgumentException ex) {
throw new JasperException(
- Localizer.getMessage("jsp.error.beans.property.conversion",
- attrValue, attrClass.getName(), attrName,
- ex.getMessage()));
+ Localizer.getMessage("jsp.error.beans.property.conversion",
+ attrValue, attrClass.getName(), attrName,
+ ex.getMessage()));
}
}
@@ -897,7 +887,7 @@
* Convert a possibly relative resource path into a context-relative
* resource path that starts with a '/'.
*
- * @param request The servlet request we are processing
+ * @param request The servlet request we are processing
* @param relativePath The possibly relative resource path
*/
public static String getContextRelativePath(ServletRequest request,
@@ -909,18 +899,17 @@
return (relativePath);
HttpServletRequest hrequest = (HttpServletRequest) request;
String uri = (String)
- request.getAttribute("javax.servlet.include.servlet_path");
+ request.getAttribute("javax.servlet.include.servlet_path");
if (uri != null) {
String pathInfo = (String)
- request.getAttribute("javax.servlet.include.path_info");
+ request.getAttribute("javax.servlet.include.path_info");
if (pathInfo == null) {
- if (uri.lastIndexOf('/') >= 0)
+ if (uri.lastIndexOf('/') >= 0)
uri = uri.substring(0, uri.lastIndexOf('/'));
}
- }
- else {
+ } else {
uri = hrequest.getServletPath();
- if (uri.lastIndexOf('/') >= 0)
+ if (uri.lastIndexOf('/') >= 0)
uri = uri.substring(0, uri.lastIndexOf('/'));
}
return uri + '/' + relativePath;
@@ -932,21 +921,20 @@
* Perform a RequestDispatcher.include() operation, with optional flushing
* of the response beforehand.
*
- * @param request The servlet request we are processing
- * @param response The servlet response we are processing
+ * @param request The servlet request we are processing
+ * @param response The servlet response we are processing
* @param relativePath The relative path of the resource to be included
- * @param out The Writer to whom we are currently writing
- * @param flush Should we flush before the include is processed?
- *
- * @exception IOException if thrown by the included servlet
- * @exception ServletException if thrown by the included servlet
+ * @param out The Writer to whom we are currently writing
+ * @param flush Should we flush before the include is processed?
+ * @throws IOException if thrown by the included servlet
+ * @throws ServletException if thrown by the included servlet
*/
public static void include(ServletRequest request,
ServletResponse response,
String relativePath,
JspWriter out,
boolean flush)
- throws IOException, ServletException {
+ throws IOException, ServletException {
if (flush && !(out instanceof BodyContent))
out.flush();
@@ -962,7 +950,7 @@
RequestDispatcher rd = request.getRequestDispatcher(resourcePath);
rd.include(request,
- new ServletResponseWrapperInclude(response, out));
+ new ServletResponseWrapperInclude(response, out));
}
@@ -971,8 +959,9 @@
* This performs the same function as java.next.URLEncode.encode
* in J2SDK1.4, and should be removed if the only platform supported
* is 1.4 or higher.
- * @param s The String to be URL encoded.
- * @param enc The character encoding
+ *
+ * @param s The String to be URL encoded.
+ * @param enc The character encoding
* @return The URL encoded String
*/
public static String URLEncode(String s, String enc) {
@@ -994,19 +983,19 @@
// Use the default encoding?
writer = new OutputStreamWriter(buf);
}
-
+
for (int i = 0; i < s.length(); i++) {
int c = s.charAt(i);
if (c == ' ') {
out.append('+');
} else if (isSafeChar(c)) {
- out.append((char)c);
+ out.append((char) c);
} else {
// convert to external encoding before hex conversion
try {
writer.write(c);
writer.flush();
- } catch(IOException e) {
+ } catch (IOException e) {
buf.reset();
continue;
}
@@ -1014,7 +1003,7 @@
for (int j = 0; j < ba.length; j++) {
out.append('%');
// Converting each byte in the buffer
- out.append(Character.forDigit((ba[j]>>4) & 0xf, 16));
+ out.append(Character.forDigit((ba[j] >> 4) & 0xf, 16));
out.append(Character.forDigit(ba[j] & 0xf, 16));
}
buf.reset();
@@ -1034,7 +1023,7 @@
return true;
}
if (c == '-' || c == '_' || c == '.' || c == '!' ||
- c == '~' || c == '*' || c == '\'' || c == '(' || c == ')') {
+ c == '~' || c == '*' || c == '\'' || c == '(' || c == ')') {
return true;
}
return false;
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspSourceDependent.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspSourceDependent.java
index 221d388..f4195bf 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspSourceDependent.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspSourceDependent.java
@@ -28,10 +28,10 @@
public interface JspSourceDependent {
- /**
- * Returns a list of files names that the current page has a source
- * dependency on.
- */
+ /**
+ * Returns a list of files names that the current page has a source
+ * dependency on.
+ */
// FIXME: Type used is Object due to very weird behavior
// with Eclipse JDT 3.1 in Java 5 mode
public Object getDependants();
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspWriterImpl.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspWriterImpl.java
index 562adfb..a876564 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspWriterImpl.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/JspWriterImpl.java
@@ -31,50 +31,49 @@
/**
* Write text to a character-output stream, buffering characters so as
* to provide for the efficient writing of single characters, arrays,
- * and strings.
- *
- * Provide support for discarding for the output that has been
- * buffered.
- *
+ * and strings.
+ * <p/>
+ * Provide support for discarding for the output that has been
+ * buffered.
+ * <p/>
* This needs revisiting when the buffering problems in the JSP spec
- * are fixed -akv
+ * are fixed -akv
*
* @author Anil K. Vijendran
*/
public class JspWriterImpl extends JspWriter {
-
+
private Writer out;
- private ServletResponse response;
+ private ServletResponse response;
private char cb[];
private int nextChar;
private boolean flushed = false;
private boolean closed = false;
-
+
public JspWriterImpl() {
- super( Constants.DEFAULT_BUFFER_SIZE, true );
+ super(Constants.DEFAULT_BUFFER_SIZE, true);
}
-
+
/**
* Create a buffered character-output stream that uses a default-sized
* output buffer.
*
- * @param response A Servlet Response
+ * @param response A Servlet Response
*/
public JspWriterImpl(ServletResponse response) {
this(response, Constants.DEFAULT_BUFFER_SIZE, true);
}
-
+
/**
* Create a new buffered character-output stream that uses an output
* buffer of the given size.
*
- * @param response A Servlet Response
- * @param sz Output-buffer size, a positive integer
- *
- * @exception IllegalArgumentException If sz is <= 0
+ * @param response A Servlet Response
+ * @param sz Output-buffer size, a positive integer
+ * @throws IllegalArgumentException If sz is <= 0
*/
- public JspWriterImpl(ServletResponse response, int sz,
- boolean autoFlush) {
+ public JspWriterImpl(ServletResponse response, int sz,
+ boolean autoFlush) {
super(sz, autoFlush);
if (sz < 0)
throw new IllegalArgumentException("Buffer size <= 0");
@@ -82,17 +81,18 @@
cb = sz == 0 ? null : new char[sz];
nextChar = 0;
}
-
- void init( ServletResponse response, int sz, boolean autoFlush ) {
- this.response= response;
- if( sz > 0 && ( cb == null || sz > cb.length ) )
- cb=new char[sz];
+
+ void init(ServletResponse response, int sz, boolean autoFlush) {
+ this.response = response;
+ if (sz > 0 && (cb == null || sz > cb.length))
+ cb = new char[sz];
nextChar = 0;
- this.autoFlush=autoFlush;
- this.bufferSize=sz;
+ this.autoFlush = autoFlush;
+ this.bufferSize = sz;
}
-
- /** Package-level access
+
+ /**
+ * Package-level access
*/
void recycle() {
flushed = false;
@@ -101,7 +101,7 @@
nextChar = 0;
response = null;
}
-
+
/**
* Flush the output buffer to the underlying character stream, without
* flushing the stream itself. This method is non-private only so that it
@@ -118,25 +118,25 @@
out.write(cb, 0, nextChar);
nextChar = 0;
}
-
+
private void initOut() throws IOException {
if (out == null) {
out = response.getWriter();
}
}
-
- private String getLocalizeMessage(final String message){
- if (SecurityUtil.isPackageProtectionEnabled()){
- return (String)AccessController.doPrivileged(new PrivilegedAction(){
- public Object run(){
- return Localizer.getMessage(message);
+
+ private String getLocalizeMessage(final String message) {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ return (String) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return Localizer.getMessage(message);
}
});
} else {
return Localizer.getMessage(message);
}
}
-
+
/**
* Discard the output buffer.
*/
@@ -151,7 +151,7 @@
ensureOpen();
nextChar = 0;
}
-
+
public void clearBuffer() throws IOException {
if (bufferSize == 0)
throw new IllegalStateException(
@@ -159,25 +159,23 @@
ensureOpen();
nextChar = 0;
}
-
+
private final void bufferOverflow() throws IOException {
throw new IOException(getLocalizeMessage("jsp.error.overflow"));
}
-
+
/**
* Flush the stream.
- *
*/
- public void flush() throws IOException {
+ public void flush() throws IOException {
flushBuffer();
if (out != null) {
out.flush();
}
}
-
+
/**
* Close the stream.
- *
*/
public void close() throws IOException {
if (response == null || closed)
@@ -189,21 +187,23 @@
out = null;
closed = true;
}
-
+
/**
* @return the number of bytes unused in the buffer
*/
public int getRemaining() {
return bufferSize - nextChar;
}
-
- /** check to make sure that the stream has not been closed */
+
+ /**
+ * check to make sure that the stream has not been closed
+ */
private void ensureOpen() throws IOException {
if (response == null || closed)
throw new IOException("Stream closed");
}
-
-
+
+
/**
* Write a single character.
*/
@@ -212,8 +212,7 @@
if (bufferSize == 0) {
initOut();
out.write(c);
- }
- else {
+ } else {
if (nextChar >= bufferSize)
if (autoFlush)
flushBuffer();
@@ -222,7 +221,7 @@
cb[nextChar++] = (char) c;
}
}
-
+
/**
* Our own little min method, to avoid loading java.lang.Math if we've run
* out of file descriptors and we're trying to print a stack trace.
@@ -231,10 +230,10 @@
if (a < b) return a;
return b;
}
-
+
/**
* Write a portion of an array of characters.
- *
+ * <p/>
* <p> Ordinarily this method stores characters from the given array into
* this stream's buffer, flushing the buffer to the underlying stream as
* needed. If the requested length is at least as large as the buffer,
@@ -242,28 +241,27 @@
* directly to the underlying stream. Thus redundant
* <code>DiscardableBufferedWriter</code>s will not copy data unnecessarily.
*
- * @param cbuf A character array
- * @param off Offset from which to start reading characters
- * @param len Number of characters to write
+ * @param cbuf A character array
+ * @param off Offset from which to start reading characters
+ * @param len Number of characters to write
*/
- public void write(char cbuf[], int off, int len)
- throws IOException
- {
+ public void write(char cbuf[], int off, int len)
+ throws IOException {
ensureOpen();
-
+
if (bufferSize == 0) {
initOut();
out.write(cbuf, off, len);
return;
}
-
+
if ((off < 0) || (off > cbuf.length) || (len < 0) ||
((off + len) > cbuf.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return;
- }
-
+ }
+
if (len >= bufferSize) {
/* If the request length exceeds the size of the output buffer,
flush the buffer and then write the data directly. In this
@@ -276,22 +274,22 @@
out.write(cbuf, off, len);
return;
}
-
+
int b = off, t = off + len;
while (b < t) {
int d = min(bufferSize - nextChar, t - b);
System.arraycopy(cbuf, b, cb, nextChar, d);
b += d;
nextChar += d;
- if (nextChar >= bufferSize)
+ if (nextChar >= bufferSize)
if (autoFlush)
flushBuffer();
else
bufferOverflow();
}
-
+
}
-
+
/**
* Write an array of characters. This method cannot be inherited from the
* Writer class because it must suppress I/O exceptions.
@@ -299,13 +297,13 @@
public void write(char buf[]) throws IOException {
write(buf, 0, buf.length);
}
-
+
/**
* Write a portion of a String.
*
- * @param s String to be written
- * @param off Offset from which to start reading characters
- * @param len Number of characters to be written
+ * @param s String to be written
+ * @param off Offset from which to start reading characters
+ * @param len Number of characters to be written
*/
public void write(String s, int off, int len) throws IOException {
ensureOpen();
@@ -320,14 +318,14 @@
s.getChars(b, b + d, cb, nextChar);
b += d;
nextChar += d;
- if (nextChar >= bufferSize)
+ if (nextChar >= bufferSize)
if (autoFlush)
flushBuffer();
else
bufferOverflow();
}
}
-
+
/**
* Write a string. This method cannot be inherited from the Writer class
* because it must suppress I/O exceptions.
@@ -335,31 +333,31 @@
public void write(String s) throws IOException {
// Simple fix for Bugzilla 35410
// Calling the other write function so as to init the buffer anyways
- if(s == null) {
+ if (s == null) {
write(s, 0, 0);
} else {
write(s, 0, s.length());
}
}
-
-
+
+
static String lineSeparator = System.getProperty("line.separator");
-
+
/**
* Write a line separator. The line separator string is defined by the
* system property <tt>line.separator</tt>, and is not necessarily a single
* newline ('\n') character.
*
- * @exception IOException If an I/O error occurs
+ * @throws IOException If an I/O error occurs
*/
-
+
public void newLine() throws IOException {
write(lineSeparator);
}
-
-
+
+
/* Methods that do not terminate lines */
-
+
/**
* Print a boolean value. The string produced by <code>{@link
* java.lang.String#valueOf(boolean)}</code> is translated into bytes
@@ -367,24 +365,24 @@
* are written in exactly the manner of the <code>{@link
* #write(int)}</code> method.
*
- * @param b The <code>boolean</code> to be printed
+ * @param b The <code>boolean</code> to be printed
*/
public void print(boolean b) throws IOException {
write(b ? "true" : "false");
}
-
+
/**
* Print a character. The character is translated into one or more bytes
* according to the platform's default character encoding, and these bytes
* are written in exactly the manner of the <code>{@link
* #write(int)}</code> method.
*
- * @param c The <code>char</code> to be printed
+ * @param c The <code>char</code> to be printed
*/
public void print(char c) throws IOException {
write(String.valueOf(c));
}
-
+
/**
* Print an integer. The string produced by <code>{@link
* java.lang.String#valueOf(int)}</code> is translated into bytes according
@@ -392,12 +390,12 @@
* written in exactly the manner of the <code>{@link #write(int)}</code>
* method.
*
- * @param i The <code>int</code> to be printed
+ * @param i The <code>int</code> to be printed
*/
public void print(int i) throws IOException {
write(String.valueOf(i));
}
-
+
/**
* Print a long integer. The string produced by <code>{@link
* java.lang.String#valueOf(long)}</code> is translated into bytes
@@ -405,12 +403,12 @@
* are written in exactly the manner of the <code>{@link #write(int)}</code>
* method.
*
- * @param l The <code>long</code> to be printed
+ * @param l The <code>long</code> to be printed
*/
public void print(long l) throws IOException {
write(String.valueOf(l));
}
-
+
/**
* Print a floating-point number. The string produced by <code>{@link
* java.lang.String#valueOf(float)}</code> is translated into bytes
@@ -418,12 +416,12 @@
* are written in exactly the manner of the <code>{@link #write(int)}</code>
* method.
*
- * @param f The <code>float</code> to be printed
+ * @param f The <code>float</code> to be printed
*/
public void print(float f) throws IOException {
write(String.valueOf(f));
}
-
+
/**
* Print a double-precision floating-point number. The string produced by
* <code>{@link java.lang.String#valueOf(double)}</code> is translated into
@@ -431,26 +429,25 @@
* bytes are written in exactly the manner of the <code>{@link
* #write(int)}</code> method.
*
- * @param d The <code>double</code> to be printed
+ * @param d The <code>double</code> to be printed
*/
public void print(double d) throws IOException {
write(String.valueOf(d));
}
-
+
/**
* Print an array of characters. The characters are converted into bytes
* according to the platform's default character encoding, and these bytes
* are written in exactly the manner of the <code>{@link #write(int)}</code>
* method.
*
- * @param s The array of chars to be printed
- *
- * @throws NullPointerException If <code>s</code> is <code>null</code>
+ * @param s The array of chars to be printed
+ * @throws NullPointerException If <code>s</code> is <code>null</code>
*/
public void print(char s[]) throws IOException {
write(s);
}
-
+
/**
* Print a string. If the argument is <code>null</code> then the string
* <code>"null"</code> is printed. Otherwise, the string's characters are
@@ -458,7 +455,7 @@
* encoding, and these bytes are written in exactly the manner of the
* <code>{@link #write(int)}</code> method.
*
- * @param s The <code>String</code> to be printed
+ * @param s The <code>String</code> to be printed
*/
public void print(String s) throws IOException {
if (s == null) {
@@ -466,7 +463,7 @@
}
write(s);
}
-
+
/**
* Print an object. The string produced by the <code>{@link
* java.lang.String#valueOf(Object)}</code> method is translated into bytes
@@ -474,28 +471,28 @@
* are written in exactly the manner of the <code>{@link #write(int)}</code>
* method.
*
- * @param obj The <code>Object</code> to be printed
+ * @param obj The <code>Object</code> to be printed
*/
public void print(Object obj) throws IOException {
write(String.valueOf(obj));
}
-
+
/* Methods that do terminate lines */
-
+
/**
* Terminate the current line by writing the line separator string. The
* line separator string is defined by the system property
* <code>line.separator</code>, and is not necessarily a single newline
* character (<code>'\n'</code>).
- *
+ * <p/>
* Need to change this from PrintWriter because the default
* println() writes to the sink directly instead of through the
- * write method...
+ * write method...
*/
public void println() throws IOException {
newLine();
}
-
+
/**
* Print a boolean value and then terminate the line. This method behaves
* as though it invokes <code>{@link #print(boolean)}</code> and then
@@ -505,7 +502,7 @@
print(x);
println();
}
-
+
/**
* Print a character and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(char)}</code> and then <code>{@link
@@ -515,7 +512,7 @@
print(x);
println();
}
-
+
/**
* Print an integer and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(int)}</code> and then <code>{@link
@@ -525,7 +522,7 @@
print(x);
println();
}
-
+
/**
* Print a long integer and then terminate the line. This method behaves
* as though it invokes <code>{@link #print(long)}</code> and then
@@ -535,7 +532,7 @@
print(x);
println();
}
-
+
/**
* Print a floating-point number and then terminate the line. This method
* behaves as though it invokes <code>{@link #print(float)}</code> and then
@@ -545,7 +542,7 @@
print(x);
println();
}
-
+
/**
* Print a double-precision floating-point number and then terminate the
* line. This method behaves as though it invokes <code>{@link
@@ -555,7 +552,7 @@
print(x);
println();
}
-
+
/**
* Print an array of characters and then terminate the line. This method
* behaves as though it invokes <code>{@link #print(char[])}</code> and then
@@ -565,7 +562,7 @@
print(x);
println();
}
-
+
/**
* Print a String and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(String)}</code> and then
@@ -575,7 +572,7 @@
print(x);
println();
}
-
+
/**
* Print an Object and then terminate the line. This method behaves as
* though it invokes <code>{@link #print(Object)}</code> and then
@@ -585,5 +582,5 @@
print(x);
println();
}
-
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/PageContextImpl.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/PageContextImpl.java
index aa14de4..abaeb35 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/PageContextImpl.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/PageContextImpl.java
@@ -59,7 +59,7 @@
// The expression evaluator, for evaluating EL expressions.
private static ExpressionEvaluatorImpl elExprEval
- = new ExpressionEvaluatorImpl(false);
+ = new ExpressionEvaluatorImpl(false);
// The variable resolver, for evaluating EL expressions.
private VariableResolverImpl variableResolver;
@@ -74,7 +74,7 @@
private String errorPageURL;
// page-scope attributes
- private transient Hashtable attributes;
+ private transient Hashtable attributes;
// per-request state
private transient ServletRequest request;
@@ -105,7 +105,7 @@
boolean autoFlush) throws IOException {
_initialize(servlet, request, response, errorPageURL, needsSession,
- bufferSize, autoFlush);
+ bufferSize, autoFlush);
}
private void _initialize(Servlet servlet,
@@ -127,10 +127,10 @@
// Setup session (if required)
if (request instanceof HttpServletRequest && needsSession)
- this.session = ((HttpServletRequest)request).getSession();
+ this.session = ((HttpServletRequest) request).getSession();
if (needsSession && session == null)
throw new IllegalStateException
- ("Page needs a session and none is available");
+ ("Page needs a session and none is available");
// initialize the initial out ...
depth = -1;
@@ -155,14 +155,14 @@
setAttribute(APPLICATION, context);
isIncluded = request.getAttribute(
- "javax.servlet.include.servlet_path") != null;
+ "javax.servlet.include.servlet_path") != null;
}
public void release() {
out = baseOut;
try {
if (isIncluded) {
- ((JspWriterImpl)out).flushBuffer();
+ ((JspWriterImpl) out).flushBuffer();
// push it into the including jspWriter
} else {
// Old code:
@@ -170,11 +170,11 @@
// Do not flush the buffer even if we're not included (i.e.
// we are the main page. The servlet will flush it and close
// the stream.
- ((JspWriterImpl)out).flushBuffer();
+ ((JspWriterImpl) out).flushBuffer();
}
} catch (IOException ex) {
context.log(
- "PageContextImpl.release(): Internal error flushing buffer");
+ "PageContextImpl.release(): Internal error flushing buffer");
}
servlet = null;
@@ -197,9 +197,9 @@
Localizer.getMessage("jsp.error.attribute.null_name"));
}
- if (SecurityUtil.isPackageProtectionEnabled()){
- return AccessController.doPrivileged(new PrivilegedAction(){
- public Object run(){
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ return AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
return doGetAttribute(name);
}
});
@@ -209,7 +209,7 @@
}
- private Object doGetAttribute(String name){
+ private Object doGetAttribute(String name) {
return attributes.get(name);
}
@@ -220,9 +220,9 @@
Localizer.getMessage("jsp.error.attribute.null_name"));
}
- if (SecurityUtil.isPackageProtectionEnabled()){
- return AccessController.doPrivileged(new PrivilegedAction(){
- public Object run(){
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ return AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
return doGetAttribute(name, scope);
}
});
@@ -232,26 +232,26 @@
}
- private Object doGetAttribute(String name, int scope){
+ private Object doGetAttribute(String name, int scope) {
switch (scope) {
case PAGE_SCOPE:
- return attributes.get(name);
+ return attributes.get(name);
case REQUEST_SCOPE:
- return request.getAttribute(name);
+ return request.getAttribute(name);
case SESSION_SCOPE:
- if (session == null) {
- throw new IllegalStateException(
- Localizer.getMessage("jsp.error.page.noSession"));
- }
- return session.getAttribute(name);
+ if (session == null) {
+ throw new IllegalStateException(
+ Localizer.getMessage("jsp.error.page.noSession"));
+ }
+ return session.getAttribute(name);
case APPLICATION_SCOPE:
- return context.getAttribute(name);
+ return context.getAttribute(name);
default:
- throw new IllegalArgumentException("Invalid scope");
+ throw new IllegalArgumentException("Invalid scope");
}
}
@@ -262,9 +262,9 @@
Localizer.getMessage("jsp.error.attribute.null_name"));
}
- if (SecurityUtil.isPackageProtectionEnabled()){
- AccessController.doPrivileged(new PrivilegedAction(){
- public Object run(){
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
doSetAttribute(name, attribute);
return null;
}
@@ -274,7 +274,7 @@
}
}
- private void doSetAttribute(String name, Object attribute){
+ private void doSetAttribute(String name, Object attribute) {
if (attribute != null) {
attributes.put(name, attribute);
} else {
@@ -289,9 +289,9 @@
Localizer.getMessage("jsp.error.attribute.null_name"));
}
- if (SecurityUtil.isPackageProtectionEnabled()){
- AccessController.doPrivileged(new PrivilegedAction(){
- public Object run(){
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
doSetAttribute(name, o, scope);
return null;
}
@@ -302,31 +302,31 @@
}
- private void doSetAttribute(String name, Object o, int scope ){
+ private void doSetAttribute(String name, Object o, int scope) {
if (o != null) {
switch (scope) {
- case PAGE_SCOPE:
- attributes.put(name, o);
- break;
+ case PAGE_SCOPE:
+ attributes.put(name, o);
+ break;
- case REQUEST_SCOPE:
- request.setAttribute(name, o);
- break;
+ case REQUEST_SCOPE:
+ request.setAttribute(name, o);
+ break;
- case SESSION_SCOPE:
- if (session == null) {
- throw new IllegalStateException(
- Localizer.getMessage("jsp.error.page.noSession"));
- }
- session.setAttribute(name, o);
- break;
+ case SESSION_SCOPE:
+ if (session == null) {
+ throw new IllegalStateException(
+ Localizer.getMessage("jsp.error.page.noSession"));
+ }
+ session.setAttribute(name, o);
+ break;
- case APPLICATION_SCOPE:
- context.setAttribute(name, o);
- break;
+ case APPLICATION_SCOPE:
+ context.setAttribute(name, o);
+ break;
- default:
- throw new IllegalArgumentException("Invalid scope");
+ default:
+ throw new IllegalArgumentException("Invalid scope");
}
} else {
removeAttribute(name, scope);
@@ -339,9 +339,9 @@
throw new NullPointerException(
Localizer.getMessage("jsp.error.attribute.null_name"));
}
- if (SecurityUtil.isPackageProtectionEnabled()){
- AccessController.doPrivileged(new PrivilegedAction(){
- public Object run(){
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
doRemoveAttribute(name, scope);
return null;
}
@@ -351,30 +351,30 @@
}
}
- private void doRemoveAttribute(String name, int scope){
+ private void doRemoveAttribute(String name, int scope) {
switch (scope) {
- case PAGE_SCOPE:
- attributes.remove(name);
- break;
+ case PAGE_SCOPE:
+ attributes.remove(name);
+ break;
- case REQUEST_SCOPE:
- request.removeAttribute(name);
- break;
+ case REQUEST_SCOPE:
+ request.removeAttribute(name);
+ break;
- case SESSION_SCOPE:
- if (session == null) {
- throw new IllegalStateException(
- Localizer.getMessage("jsp.error.page.noSession"));
- }
- session.removeAttribute(name);
- break;
+ case SESSION_SCOPE:
+ if (session == null) {
+ throw new IllegalStateException(
+ Localizer.getMessage("jsp.error.page.noSession"));
+ }
+ session.removeAttribute(name);
+ break;
- case APPLICATION_SCOPE:
- context.removeAttribute(name);
- break;
-
- default:
- throw new IllegalArgumentException("Invalid scope");
+ case APPLICATION_SCOPE:
+ context.removeAttribute(name);
+ break;
+
+ default:
+ throw new IllegalArgumentException("Invalid scope");
}
}
@@ -385,9 +385,9 @@
Localizer.getMessage("jsp.error.attribute.null_name"));
}
- if (SecurityUtil.isPackageProtectionEnabled()){
- return ((Integer)AccessController.doPrivileged(new PrivilegedAction(){
- public Object run(){
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ return ((Integer) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
return new Integer(doGetAttributeScope(name));
}
})).intValue();
@@ -396,7 +396,7 @@
}
}
- private int doGetAttributeScope(String name){
+ private int doGetAttributeScope(String name) {
if (attributes.get(name) != null)
return PAGE_SCOPE;
@@ -407,7 +407,7 @@
try {
if (session.getAttribute(name) != null)
return SESSION_SCOPE;
- } catch(IllegalStateException ise) {
+ } catch (IllegalStateException ise) {
// Session has been invalidated.
// Ignore and fall through to application scope.
}
@@ -420,9 +420,9 @@
}
public Object findAttribute(final String name) {
- if (SecurityUtil.isPackageProtectionEnabled()){
- return AccessController.doPrivileged(new PrivilegedAction(){
- public Object run(){
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ return AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
if (name == null) {
throw new NullPointerException(
Localizer.getMessage("jsp.error.attribute.null_name"));
@@ -441,7 +441,7 @@
}
}
- private Object doFindAttribute(String name){
+ private Object doFindAttribute(String name) {
Object o = attributes.get(name);
if (o != null)
@@ -454,7 +454,7 @@
if (session != null) {
try {
o = session.getAttribute(name);
- } catch(IllegalStateException ise) {
+ } catch (IllegalStateException ise) {
// Session has been invalidated.
// Ignore and fall through to application scope.
}
@@ -467,38 +467,38 @@
public Enumeration getAttributeNamesInScope(final int scope) {
- if (SecurityUtil.isPackageProtectionEnabled()){
+ if (SecurityUtil.isPackageProtectionEnabled()) {
return (Enumeration)
- AccessController.doPrivileged(new PrivilegedAction(){
- public Object run(){
- return doGetAttributeNamesInScope(scope);
- }
- });
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return doGetAttributeNamesInScope(scope);
+ }
+ });
} else {
return doGetAttributeNamesInScope(scope);
}
}
- private Enumeration doGetAttributeNamesInScope(int scope){
+ private Enumeration doGetAttributeNamesInScope(int scope) {
switch (scope) {
- case PAGE_SCOPE:
- return attributes.keys();
-
- case REQUEST_SCOPE:
- return request.getAttributeNames();
+ case PAGE_SCOPE:
+ return attributes.keys();
- case SESSION_SCOPE:
- if (session == null) {
- throw new IllegalStateException(
- Localizer.getMessage("jsp.error.page.noSession"));
- }
- return session.getAttributeNames();
+ case REQUEST_SCOPE:
+ return request.getAttributeNames();
- case APPLICATION_SCOPE:
- return context.getAttributeNames();
+ case SESSION_SCOPE:
+ if (session == null) {
+ throw new IllegalStateException(
+ Localizer.getMessage("jsp.error.page.noSession"));
+ }
+ return session.getAttributeNames();
- default:
- throw new IllegalArgumentException("Invalid scope");
+ case APPLICATION_SCOPE:
+ return context.getAttributeNames();
+
+ default:
+ throw new IllegalArgumentException("Invalid scope");
}
}
@@ -509,9 +509,9 @@
Localizer.getMessage("jsp.error.attribute.null_name"));
}
- if (SecurityUtil.isPackageProtectionEnabled()){
- AccessController.doPrivileged(new PrivilegedAction(){
- public Object run(){
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
doRemoveAttribute(name);
return null;
}
@@ -519,16 +519,16 @@
} else {
doRemoveAttribute(name);
}
- }
+ }
- private void doRemoveAttribute(String name){
+ private void doRemoveAttribute(String name) {
removeAttribute(name, PAGE_SCOPE);
removeAttribute(name, REQUEST_SCOPE);
- if( session != null ) {
+ if (session != null) {
try {
removeAttribute(name, SESSION_SCOPE);
- } catch(IllegalStateException ise) {
+ } catch (IllegalStateException ise) {
// Session has been invalidated.
// Ignore and fall throw to application scope.
}
@@ -540,14 +540,29 @@
return out;
}
- public HttpSession getSession() { return session; }
- public Servlet getServlet() { return servlet; }
- public ServletConfig getServletConfig() { return config; }
+ public HttpSession getSession() {
+ return session;
+ }
+
+ public Servlet getServlet() {
+ return servlet;
+ }
+
+ public ServletConfig getServletConfig() {
+ return config;
+ }
+
public ServletContext getServletContext() {
return config.getServletContext();
}
- public ServletRequest getRequest() { return request; }
- public ServletResponse getResponse() { return response; }
+
+ public ServletRequest getRequest() {
+ return request;
+ }
+
+ public ServletResponse getResponse() {
+ return response;
+ }
/**
@@ -563,7 +578,7 @@
Throwable t = JspRuntimeLibrary.getThrowable(request);
// Only wrap if needed
- if((t != null) && (! (t instanceof Exception))) {
+ if ((t != null) && (!(t instanceof Exception))) {
t = new JspException(t);
}
@@ -571,7 +586,9 @@
}
- public Object getPage() { return servlet; }
+ public Object getPage() {
+ return servlet;
+ }
private final String getAbsolutePathRelativeToContext(String relativeUrlPath) {
@@ -579,38 +596,38 @@
if (!path.startsWith("/")) {
String uri = (String)
- request.getAttribute("javax.servlet.include.servlet_path");
+ request.getAttribute("javax.servlet.include.servlet_path");
if (uri == null)
uri = ((HttpServletRequest) request).getServletPath();
String baseURI = uri.substring(0, uri.lastIndexOf('/'));
- path = baseURI+'/'+path;
+ path = baseURI + '/' + path;
}
return path;
}
public void include(String relativeUrlPath)
- throws ServletException, IOException {
+ throws ServletException, IOException {
JspRuntimeLibrary.include(request, response, relativeUrlPath, out,
- true);
+ true);
}
public void include(final String relativeUrlPath, final boolean flush)
- throws ServletException, IOException {
- if (SecurityUtil.isPackageProtectionEnabled()){
- try{
- AccessController.doPrivileged(new PrivilegedExceptionAction(){
- public Object run() throws Exception{
+ throws ServletException, IOException {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws Exception {
doInclude(relativeUrlPath, flush);
return null;
}
});
- } catch (PrivilegedActionException e){
- Exception ex = e.getException();
- if (ex instanceof IOException){
- throw (IOException)ex;
+ } catch (PrivilegedActionException e) {
+ Exception ex = e.getException();
+ if (ex instanceof IOException) {
+ throw (IOException) ex;
} else {
- throw (ServletException)ex;
+ throw (ServletException) ex;
}
}
} else {
@@ -619,9 +636,9 @@
}
private void doInclude(String relativeUrlPath, boolean flush)
- throws ServletException, IOException {
+ throws ServletException, IOException {
JspRuntimeLibrary.include(request, response, relativeUrlPath, out,
- flush);
+ flush);
}
public VariableResolver getVariableResolver() {
@@ -629,21 +646,21 @@
}
public void forward(final String relativeUrlPath)
- throws ServletException, IOException {
- if (SecurityUtil.isPackageProtectionEnabled()){
- try{
- AccessController.doPrivileged(new PrivilegedExceptionAction(){
- public Object run() throws Exception{
+ throws ServletException, IOException {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws Exception {
doForward(relativeUrlPath);
return null;
}
});
- } catch (PrivilegedActionException e){
- Exception ex = e.getException();
- if (ex instanceof IOException){
- throw (IOException)ex;
+ } catch (PrivilegedActionException e) {
+ Exception ex = e.getException();
+ if (ex instanceof IOException) {
+ throw (IOException) ex;
} else {
- throw (ServletException)ex;
+ throw (ServletException) ex;
}
}
} else {
@@ -652,14 +669,14 @@
}
private void doForward(String relativeUrlPath)
- throws ServletException, IOException{
+ throws ServletException, IOException {
// JSP.4.5 If the buffer was flushed, throw IllegalStateException
try {
out.clear();
} catch (IOException ex) {
IllegalStateException ise =
- new IllegalStateException(Localizer.getMessage(
+ new IllegalStateException(Localizer.getMessage(
"jsp.error.attempt_to_clear_flushed_buffer"));
ise.initCause(ex);
throw ise;
@@ -667,13 +684,13 @@
// Make sure that the response object is not the wrapper for include
while (response instanceof ServletResponseWrapperInclude) {
- response = ((ServletResponseWrapperInclude)response).getResponse();
+ response = ((ServletResponseWrapperInclude) response).getResponse();
}
final String path = getAbsolutePathRelativeToContext(relativeUrlPath);
String includeUri
- = (String) request.getAttribute(Constants.INC_SERVLET_PATH);
-
+ = (String) request.getAttribute(Constants.INC_SERVLET_PATH);
+
if (includeUri != null)
request.removeAttribute(Constants.INC_SERVLET_PATH);
try {
@@ -693,7 +710,7 @@
depth++;
if (depth >= outs.length) {
BodyContentImpl[] newOuts = new BodyContentImpl[depth + 1];
- for (int i=0; i<outs.length; i++) {
+ for (int i = 0; i < outs.length; i++) {
newOuts[i] = outs[i];
}
newOuts[depth] = new BodyContentImpl(out);
@@ -735,33 +752,31 @@
}
public void handlePageException(Exception ex)
- throws IOException, ServletException
- {
+ throws IOException, ServletException {
// Should never be called since handleException() called with a
// Throwable in the generated servlet.
handlePageException((Throwable) ex);
}
public void handlePageException(final Throwable t)
- throws IOException, ServletException
- {
+ throws IOException, ServletException {
if (t == null)
throw new NullPointerException("null Throwable");
- if (SecurityUtil.isPackageProtectionEnabled()){
- try{
- AccessController.doPrivileged(new PrivilegedExceptionAction(){
- public Object run() throws Exception{
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws Exception {
doHandlePageException(t);
return null;
}
});
- } catch (PrivilegedActionException e){
- Exception ex = e.getException();
- if (ex instanceof IOException){
- throw (IOException)ex;
+ } catch (PrivilegedActionException e) {
+ Exception ex = e.getException();
+ if (ex instanceof IOException) {
+ throw (IOException) ex;
} else {
- throw (ServletException)ex;
+ throw (ServletException) ex;
}
}
} else {
@@ -771,7 +786,7 @@
}
private void doHandlePageException(Throwable t)
- throws IOException, ServletException {
+ throws IOException, ServletException {
if (errorPageURL != null && !errorPageURL.equals("")) {
@@ -786,11 +801,11 @@
*/
request.setAttribute("javax.servlet.jsp.jspException", t);
request.setAttribute("javax.servlet.error.status_code",
- new Integer(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
+ new Integer(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
request.setAttribute("javax.servlet.error.request_uri",
- ((HttpServletRequest) request).getRequestURI());
+ ((HttpServletRequest) request).getRequestURI());
request.setAttribute("javax.servlet.error.servlet_name",
- config.getServletName());
+ config.getServletName());
try {
forward(errorPageURL);
} catch (IllegalStateException ise) {
@@ -802,7 +817,7 @@
Object newException = request.getAttribute("javax.servlet.error.exception");
// t==null means the attribute was not set.
- if( (newException!= null) && (newException==t) ) {
+ if ((newException != null) && (newException == t)) {
request.removeAttribute("javax.servlet.error.exception");
}
@@ -816,9 +831,9 @@
// Otherwise throw the exception wrapped inside a ServletException.
// Set the exception as the root cause in the ServletException
// to get a stack trace for the real problem
- if (t instanceof IOException) throw (IOException)t;
- if (t instanceof ServletException) throw (ServletException)t;
- if (t instanceof RuntimeException) throw (RuntimeException)t;
+ if (t instanceof IOException) throw (IOException) t;
+ if (t instanceof ServletException) throw (ServletException) t;
+ if (t instanceof RuntimeException) throw (RuntimeException) t;
Throwable rootCause = null;
if (t instanceof JspException) {
@@ -828,10 +843,10 @@
}
if (rootCause != null) {
- throw new ServletException(t.getClass().getName() + ": " +
- t.getMessage(), rootCause);
+ throw new ServletException(t.getClass().getName() + ": " +
+ t.getMessage(), rootCause);
}
-
+
throw new ServletException(t);
}
}
@@ -855,7 +870,7 @@
}
StringBuffer sb = new StringBuffer();
- for(int i = 0; i < s.length(); i++) {
+ for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '<') {
sb.append("<");
@@ -880,32 +895,31 @@
* out of JSTL and into its own project. For now, this is necessary
* because the standard machinery is too slow.
*
- * @param expression The expression to be evaluated
+ * @param expression The expression to be evaluated
* @param expectedType The expected resulting type
- * @param pageContext The page context
- * @param functionMap Maps prefix and name to Method
+ * @param pageContext The page context
+ * @param functionMap Maps prefix and name to Method
* @return The result of the evaluation
*/
- public static Object proprietaryEvaluate(final String expression,
+ public static Object proprietaryEvaluate(final String expression,
final Class expectedType,
final PageContext pageContext,
final ProtectedFunctionMapper functionMap,
final boolean escape)
- throws ELException
- {
+ throws ELException {
Object retValue;
- if (SecurityUtil.isPackageProtectionEnabled()){
+ if (SecurityUtil.isPackageProtectionEnabled()) {
try {
retValue = AccessController.doPrivileged(
- new PrivilegedExceptionAction(){
+ new PrivilegedExceptionAction() {
- public Object run() throws Exception{
- return elExprEval.evaluate(expression,
- expectedType,
- pageContext.getVariableResolver(),
- functionMap);
- }
- });
+ public Object run() throws Exception {
+ return elExprEval.evaluate(expression,
+ expectedType,
+ pageContext.getVariableResolver(),
+ functionMap);
+ }
+ });
} catch (PrivilegedActionException ex) {
Exception realEx = ex.getException();
if (realEx instanceof ELException) {
@@ -916,9 +930,9 @@
}
} else {
retValue = elExprEval.evaluate(expression,
- expectedType,
- pageContext.getVariableResolver(),
- functionMap);
+ expectedType,
+ pageContext.getVariableResolver(),
+ functionMap);
}
if (escape) {
retValue = XmlEscape(retValue.toString());
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/PerThreadTagHandlerPool.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/PerThreadTagHandlerPool.java
index 6a697c1..febb353 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/PerThreadTagHandlerPool.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/PerThreadTagHandlerPool.java
@@ -79,22 +79,20 @@
* instantiating one if this tag handler pool is empty.
*
* @param handlerClass Tag handler class
- *
* @return Reused or newly instantiated tag handler
- *
* @throws JspException if a tag handler cannot be instantiated
*/
public Tag get(Class handlerClass) throws JspException {
- PerThreadData ptd = (PerThreadData)perThread.get();
- if(ptd.current >=0 ) {
+ PerThreadData ptd = (PerThreadData) perThread.get();
+ if (ptd.current >= 0) {
return ptd.handlers[ptd.current--];
} else {
- try {
- return (Tag) handlerClass.newInstance();
- } catch (Exception e) {
- throw new JspException(e.getMessage(), e);
- }
- }
+ try {
+ return (Tag) handlerClass.newInstance();
+ } catch (Exception e) {
+ throw new JspException(e.getMessage(), e);
+ }
+ }
}
/**
@@ -105,9 +103,9 @@
* @param handler Tag handler to add to this tag handler pool
*/
public void reuse(Tag handler) {
- PerThreadData ptd=(PerThreadData)perThread.get();
- if (ptd.current < (ptd.handlers.length - 1)) {
- ptd.handlers[++ptd.current] = handler;
+ PerThreadData ptd = (PerThreadData) perThread.get();
+ if (ptd.current < (ptd.handlers.length - 1)) {
+ ptd.handlers[++ptd.current] = handler;
} else {
handler.release();
}
@@ -116,15 +114,15 @@
/**
* Calls the release() method of all tag handlers in this tag handler pool.
*/
- public void release() {
+ public void release() {
Enumeration enumeration = perThreadDataVector.elements();
while (enumeration.hasMoreElements()) {
- PerThreadData ptd = (PerThreadData)enumeration.nextElement();
+ PerThreadData ptd = (PerThreadData) enumeration.nextElement();
if (ptd.handlers != null) {
- for (int i=ptd.current; i>=0; i--) {
+ for (int i = ptd.current; i >= 0; i--) {
if (ptd.handlers[i] != null) {
ptd.handlers[i].release();
- }
+ }
}
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/ProtectedFunctionMapper.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/ProtectedFunctionMapper.java
index e90f0d7..b494623 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/ProtectedFunctionMapper.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/ProtectedFunctionMapper.java
@@ -37,7 +37,7 @@
*/
public final class ProtectedFunctionMapper implements FunctionMapper {
- /**
+ /**
* Maps "prefix:name" to java.lang.Method objects.
*/
private HashMap fnmap = null;
@@ -63,59 +63,58 @@
*/
public static ProtectedFunctionMapper getInstance() {
ProtectedFunctionMapper funcMapper;
- if (SecurityUtil.isPackageProtectionEnabled()) {
- funcMapper = (ProtectedFunctionMapper)AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return new ProtectedFunctionMapper();
- }
- } );
- } else {
- funcMapper = new ProtectedFunctionMapper();
- }
- funcMapper.fnmap = new java.util.HashMap();
- return funcMapper;
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ funcMapper = (ProtectedFunctionMapper) AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public Object run() {
+ return new ProtectedFunctionMapper();
+ }
+ });
+ } else {
+ funcMapper = new ProtectedFunctionMapper();
+ }
+ funcMapper.fnmap = new java.util.HashMap();
+ return funcMapper;
}
/**
- * Stores a mapping from the given EL function prefix and name to
+ * Stores a mapping from the given EL function prefix and name to
* the given Java method.
*
- * @param fnQName The EL function qualified name (including prefix)
- * @param c The class containing the Java method
+ * @param fnQName The EL function qualified name (including prefix)
+ * @param c The class containing the Java method
* @param methodName The name of the Java method
- * @param args The arguments of the Java method
+ * @param args The arguments of the Java method
* @throws RuntimeException if no method with the given signature
- * could be found.
+ * could be found.
*/
public void mapFunction(String fnQName, final Class c,
- final String methodName, final Class[] args )
- {
- java.lang.reflect.Method method;
- if (SecurityUtil.isPackageProtectionEnabled()){
- try{
- method = (java.lang.reflect.Method)AccessController.doPrivileged(new PrivilegedExceptionAction(){
+ final String methodName, final Class[] args) {
+ java.lang.reflect.Method method;
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ try {
+ method = (java.lang.reflect.Method) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws Exception{
+ public Object run() throws Exception {
return c.getDeclaredMethod(methodName, args);
- }
- });
- } catch (PrivilegedActionException ex){
+ }
+ });
+ } catch (PrivilegedActionException ex) {
throw new RuntimeException(
- "Invalid function mapping - no such method: "
- + ex.getException().getMessage());
+ "Invalid function mapping - no such method: "
+ + ex.getException().getMessage());
}
} else {
- try {
+ try {
method = c.getDeclaredMethod(methodName, args);
- } catch( NoSuchMethodException e ) {
+ } catch (NoSuchMethodException e) {
throw new RuntimeException(
- "Invalid function mapping - no such method: "
- + e.getMessage());
+ "Invalid function mapping - no such method: "
+ + e.getMessage());
}
}
- this.fnmap.put(fnQName, method );
+ this.fnmap.put(fnQName, method);
}
/**
@@ -123,67 +122,66 @@
* the given EL function prefix and name. This method is used for
* the case when there is only one function in the EL expression.
*
- * @param fnQName The EL function qualified name (including prefix)
- * @param c The class containing the Java method
+ * @param fnQName The EL function qualified name (including prefix)
+ * @param c The class containing the Java method
* @param methodName The name of the Java method
- * @param args The arguments of the Java method
+ * @param args The arguments of the Java method
* @throws RuntimeException if no method with the given signature
- * could be found.
+ * could be found.
*/
public static ProtectedFunctionMapper getMapForFunction(
- String fnQName, final Class c,
- final String methodName, final Class[] args )
- {
+ String fnQName, final Class c,
+ final String methodName, final Class[] args) {
java.lang.reflect.Method method;
ProtectedFunctionMapper funcMapper;
- if (SecurityUtil.isPackageProtectionEnabled()){
- funcMapper = (ProtectedFunctionMapper)AccessController.doPrivileged(
- new PrivilegedAction(){
- public Object run() {
- return new ProtectedFunctionMapper();
- }
- });
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ funcMapper = (ProtectedFunctionMapper) AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public Object run() {
+ return new ProtectedFunctionMapper();
+ }
+ });
- try{
- method = (java.lang.reflect.Method)AccessController.doPrivileged
-(new PrivilegedExceptionAction(){
+ try {
+ method = (java.lang.reflect.Method) AccessController.doPrivileged
+ (new PrivilegedExceptionAction() {
- public Object run() throws Exception{
- return c.getDeclaredMethod(methodName, args);
- }
- });
- } catch (PrivilegedActionException ex){
+ public Object run() throws Exception {
+ return c.getDeclaredMethod(methodName, args);
+ }
+ });
+ } catch (PrivilegedActionException ex) {
throw new RuntimeException(
- "Invalid function mapping - no such method: "
- + ex.getException().getMessage());
+ "Invalid function mapping - no such method: "
+ + ex.getException().getMessage());
}
} else {
- funcMapper = new ProtectedFunctionMapper();
- try {
+ funcMapper = new ProtectedFunctionMapper();
+ try {
method = c.getDeclaredMethod(methodName, args);
- } catch( NoSuchMethodException e ) {
+ } catch (NoSuchMethodException e) {
throw new RuntimeException(
- "Invalid function mapping - no such method: "
- + e.getMessage());
+ "Invalid function mapping - no such method: "
+ + e.getMessage());
}
}
funcMapper.theMethod = method;
- return funcMapper;
+ return funcMapper;
}
/**
* Resolves the specified local name and prefix into a Java.lang.Method.
* Returns null if the prefix and local name are not found.
- *
- * @param prefix the prefix of the function
+ *
+ * @param prefix the prefix of the function
* @param localName the short name of the function
* @return the result of the method mapping. Null means no entry found.
- **/
+ */
public Method resolveFunction(String prefix, String localName) {
if (this.fnmap != null) {
return (Method) this.fnmap.get(prefix + ":" + localName);
}
- return theMethod;
+ return theMethod;
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/ServletResponseWrapperInclude.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/ServletResponseWrapperInclude.java
index 35cc90d..86da343 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/ServletResponseWrapperInclude.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/ServletResponseWrapperInclude.java
@@ -27,7 +27,7 @@
/**
* ServletResponseWrapper used by the JSP 'include' action.
- *
+ * <p/>
* This wrapper response object is passed to RequestDispatcher.include(), so
* that the output of the included resource is appended to that of the
* including page.
@@ -44,22 +44,22 @@
private JspWriter jspWriter;
- public ServletResponseWrapperInclude(ServletResponse response,
- JspWriter jspWriter) {
- super((HttpServletResponse)response);
- this.printWriter = new PrintWriter(jspWriter);
- this.jspWriter = jspWriter;
+ public ServletResponseWrapperInclude(ServletResponse response,
+ JspWriter jspWriter) {
+ super((HttpServletResponse) response);
+ this.printWriter = new PrintWriter(jspWriter);
+ this.jspWriter = jspWriter;
}
/**
* Returns a wrapper around the JspWriter of the including page.
*/
public PrintWriter getWriter() throws IOException {
- return printWriter;
+ return printWriter;
}
public ServletOutputStream getOutputStream() throws IOException {
- throw new IllegalStateException();
+ throw new IllegalStateException();
}
/**
@@ -67,9 +67,9 @@
* page.
*/
public void resetBuffer() {
- try {
- jspWriter.clearBuffer();
- } catch (IOException ioe) {
- }
+ try {
+ jspWriter.clearBuffer();
+ } catch (IOException ioe) {
+ }
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/TagHandlerPool.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/TagHandlerPool.java
index f77b978..782a789 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/TagHandlerPool.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/runtime/TagHandlerPool.java
@@ -32,43 +32,43 @@
private Tag[] handlers;
- public static String OPTION_TAGPOOL="tagpoolClassName";
- public static String OPTION_MAXSIZE="tagpoolMaxSize";
+ public static String OPTION_TAGPOOL = "tagpoolClassName";
+ public static String OPTION_MAXSIZE = "tagpoolMaxSize";
// index of next available tag handler
private int current;
- public static TagHandlerPool getTagHandlerPool( ServletConfig config) {
- TagHandlerPool result=null;
+ public static TagHandlerPool getTagHandlerPool(ServletConfig config) {
+ TagHandlerPool result = null;
- String tpClassName=getOption( config, OPTION_TAGPOOL, null);
- if( tpClassName != null ) {
+ String tpClassName = getOption(config, OPTION_TAGPOOL, null);
+ if (tpClassName != null) {
try {
- Class c=Class.forName( tpClassName );
- result=(TagHandlerPool)c.newInstance();
+ Class c = Class.forName(tpClassName);
+ result = (TagHandlerPool) c.newInstance();
} catch (Exception e) {
e.printStackTrace();
- result=null;
+ result = null;
}
}
- if( result==null ) result=new TagHandlerPool();
+ if (result == null) result = new TagHandlerPool();
result.init(config);
return result;
}
- protected void init( ServletConfig config ) {
- int maxSize=-1;
- String maxSizeS=getOption(config, OPTION_MAXSIZE, null);
- if( maxSizeS != null ) {
+ protected void init(ServletConfig config) {
+ int maxSize = -1;
+ String maxSizeS = getOption(config, OPTION_MAXSIZE, null);
+ if (maxSizeS != null) {
try {
- maxSize=Integer.parseInt(maxSizeS);
- } catch( Exception ex) {
- maxSize=-1;
+ maxSize = Integer.parseInt(maxSizeS);
+ } catch (Exception ex) {
+ maxSize = -1;
}
}
- if( maxSize <0 ) {
- maxSize=Constants.MAX_POOL_SIZE;
+ if (maxSize < 0) {
+ maxSize = Constants.MAX_POOL_SIZE;
}
this.handlers = new Tag[maxSize];
this.current = -1;
@@ -78,7 +78,7 @@
* Constructs a tag handler pool with the default capacity.
*/
public TagHandlerPool() {
- // Nothing - jasper generated servlets call the other constructor,
+ // Nothing - jasper generated servlets call the other constructor,
// this should be used in future + init .
}
@@ -89,8 +89,8 @@
* @deprecated Use static getTagHandlerPool
*/
public TagHandlerPool(int capacity) {
- this.handlers = new Tag[capacity];
- this.current = -1;
+ this.handlers = new Tag[capacity];
+ this.current = -1;
}
/**
@@ -98,14 +98,12 @@
* instantiating one if this tag handler pool is empty.
*
* @param handlerClass Tag handler class
- *
* @return Reused or newly instantiated tag handler
- *
* @throws JspException if a tag handler cannot be instantiated
*/
public Tag get(Class handlerClass) throws JspException {
- Tag handler = null;
- synchronized( this ) {
+ Tag handler = null;
+ synchronized (this) {
if (current >= 0) {
handler = handlers[current--];
return handler;
@@ -129,7 +127,7 @@
* @param handler Tag handler to add to this tag handler pool
*/
public void reuse(Tag handler) {
- synchronized( this ) {
+ synchronized (this) {
if (current < (handlers.length - 1)) {
handlers[++current] = handler;
return;
@@ -144,20 +142,20 @@
* handler pool.
*/
public synchronized void release() {
- for (int i=current; i>=0; i--) {
- handlers[i].release();
- }
+ for (int i = current; i >= 0; i--) {
+ handlers[i].release();
+ }
}
- protected static String getOption( ServletConfig config, String name, String defaultV) {
- if( config == null ) return defaultV;
+ protected static String getOption(ServletConfig config, String name, String defaultV) {
+ if (config == null) return defaultV;
- String value=config.getInitParameter(name);
- if( value != null ) return value;
- if( config.getServletContext() ==null )
+ String value = config.getInitParameter(name);
+ if (value != null) return value;
+ if (config.getServletContext() == null)
return defaultV;
- value=config.getServletContext().getInitParameter(name);
- if( value!=null ) return value;
+ value = config.getServletContext().getInitParameter(name);
+ if (value != null) return value;
return defaultV;
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/security/SecurityClassLoad.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/security/SecurityClassLoad.java
index 3bc4e41..5969b6e 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/security/SecurityClassLoad.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/security/SecurityClassLoad.java
@@ -18,6 +18,9 @@
package org.apache.struts2.jasper.security;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+
/**
* Static class used to preload java classes when using the
* Java SecurityManager so that the defineClassInPackage
@@ -28,82 +31,81 @@
public final class SecurityClassLoad {
- private static org.apache.commons.logging.Log log=
- org.apache.commons.logging.LogFactory.getLog( SecurityClassLoad.class );
+ private static Logger log = LoggerFactory.getLogger(SecurityClassLoad.class);
- public static void securityClassLoad(ClassLoader loader){
+ public static void securityClassLoad(ClassLoader loader) {
- if( System.getSecurityManager() == null ){
+ if (System.getSecurityManager() == null) {
return;
}
String basePackage = "org.apache.struts2.jasper.";
try {
- loader.loadClass( basePackage +
- "runtime.JspFactoryImpl$PrivilegedGetPageContext");
- loader.loadClass( basePackage +
- "runtime.JspFactoryImpl$PrivilegedReleasePageContext");
+ loader.loadClass(basePackage +
+ "runtime.JspFactoryImpl$PrivilegedGetPageContext");
+ loader.loadClass(basePackage +
+ "runtime.JspFactoryImpl$PrivilegedReleasePageContext");
- loader.loadClass( basePackage +
- "runtime.JspRuntimeLibrary");
- loader.loadClass( basePackage +
- "runtime.JspRuntimeLibrary$PrivilegedIntrospectHelper");
-
- loader.loadClass( basePackage +
- "runtime.ServletResponseWrapperInclude");
- loader.loadClass( basePackage +
- "runtime.TagHandlerPool");
- loader.loadClass( basePackage +
- "runtime.JspFragmentHelper");
+ loader.loadClass(basePackage +
+ "runtime.JspRuntimeLibrary");
+ loader.loadClass(basePackage +
+ "runtime.JspRuntimeLibrary$PrivilegedIntrospectHelper");
- loader.loadClass( basePackage +
- "runtime.ProtectedFunctionMapper");
- loader.loadClass( basePackage +
- "runtime.ProtectedFunctionMapper$1");
- loader.loadClass( basePackage +
- "runtime.ProtectedFunctionMapper$2");
- loader.loadClass( basePackage +
- "runtime.ProtectedFunctionMapper$3");
- loader.loadClass( basePackage +
- "runtime.ProtectedFunctionMapper$4");
+ loader.loadClass(basePackage +
+ "runtime.ServletResponseWrapperInclude");
+ loader.loadClass(basePackage +
+ "runtime.TagHandlerPool");
+ loader.loadClass(basePackage +
+ "runtime.JspFragmentHelper");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl$1");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl$2");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl$3");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl$4");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl$5");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl$6");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl$7");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl$8");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl$9");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl$10");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl$11");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl$12");
- loader.loadClass( basePackage +
- "runtime.PageContextImpl$13");
+ loader.loadClass(basePackage +
+ "runtime.ProtectedFunctionMapper");
+ loader.loadClass(basePackage +
+ "runtime.ProtectedFunctionMapper$1");
+ loader.loadClass(basePackage +
+ "runtime.ProtectedFunctionMapper$2");
+ loader.loadClass(basePackage +
+ "runtime.ProtectedFunctionMapper$3");
+ loader.loadClass(basePackage +
+ "runtime.ProtectedFunctionMapper$4");
- loader.loadClass( basePackage +
- "runtime.JspContextWrapper");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl$1");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl$2");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl$3");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl$4");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl$5");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl$6");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl$7");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl$8");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl$9");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl$10");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl$11");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl$12");
+ loader.loadClass(basePackage +
+ "runtime.PageContextImpl$13");
- loader.loadClass( basePackage +
- "servlet.JspServletWrapper");
+ loader.loadClass(basePackage +
+ "runtime.JspContextWrapper");
- loader.loadClass( basePackage +
- "runtime.JspWriterImpl$1");
+ loader.loadClass(basePackage +
+ "servlet.JspServletWrapper");
+
+ loader.loadClass(basePackage +
+ "runtime.JspWriterImpl$1");
} catch (ClassNotFoundException ex) {
log.error("SecurityClassLoad", ex);
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/security/SecurityUtil.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/security/SecurityUtil.java
index 8333693..dc4e293 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/security/SecurityUtil.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/security/SecurityUtil.java
@@ -22,21 +22,21 @@
* @author Jean-Francois Arcand
*/
-public final class SecurityUtil{
-
- private static boolean packageDefinitionEnabled =
- System.getProperty("package.definition") == null ? false : true;
-
+public final class SecurityUtil {
+
+ private static boolean packageDefinitionEnabled =
+ System.getProperty("package.definition") == null ? false : true;
+
/**
* Return the <code>SecurityManager</code> only if Security is enabled AND
* package protection mechanism is enabled.
*/
- public static boolean isPackageProtectionEnabled(){
- if (packageDefinitionEnabled && System.getSecurityManager() != null){
+ public static boolean isPackageProtectionEnabled() {
+ if (packageDefinitionEnabled && System.getSecurityManager() != null) {
return true;
}
return false;
}
-
-
+
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JasperLoader.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JasperLoader.java
index 54241ec..19806b4 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JasperLoader.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JasperLoader.java
@@ -27,7 +27,7 @@
import java.security.PermissionCollection;
/**
- * Class loader for loading servlet class files (corresponding to JSP files)
+ * Class loader for loading servlet class files (corresponding to JSP files)
* and tag handler class files (corresponding to tag files).
*
* @author Anil K. Vijendran
@@ -41,12 +41,12 @@
private SecurityManager securityManager;
public JasperLoader(URL[] urls, ClassLoader parent,
- PermissionCollection permissionCollection,
- CodeSource codeSource) {
- super(urls, parent);
- this.permissionCollection = permissionCollection;
- this.parent = parent;
- this.securityManager = System.getSecurityManager();
+ PermissionCollection permissionCollection,
+ CodeSource codeSource) {
+ super(urls, parent);
+ this.permissionCollection = permissionCollection;
+ this.parent = parent;
+ this.securityManager = System.getSecurityManager();
}
/**
@@ -55,8 +55,7 @@
* with <code>false</code> as the second argument.
*
* @param name Name of the class to be loaded
- *
- * @exception ClassNotFoundException if the class was not found
+ * @throws ClassNotFoundException if the class was not found
*/
public Class loadClass(String name) throws ClassNotFoundException {
@@ -69,72 +68,71 @@
* be found, returns <code>ClassNotFoundException</code>.
* <ul>
* <li>Call <code>findLoadedClass(String)</code> to check if the
- * class has already been loaded. If it has, the same
- * <code>Class</code> object is returned.</li>
+ * class has already been loaded. If it has, the same
+ * <code>Class</code> object is returned.</li>
* <li>If the <code>delegate</code> property is set to <code>true</code>,
- * call the <code>loadClass()</code> method of the parent class
- * loader, if any.</li>
+ * call the <code>loadClass()</code> method of the parent class
+ * loader, if any.</li>
* <li>Call <code>findClass()</code> to find this class in our locally
- * defined repositories.</li>
+ * defined repositories.</li>
* <li>Call the <code>loadClass()</code> method of our parent
- * class loader, if any.</li>
+ * class loader, if any.</li>
* </ul>
* If the class was found using the above steps, and the
* <code>resolve</code> flag is <code>true</code>, this method will then
* call <code>resolveClass(Class)</code> on the resulting Class object.
- *
- * @param name Name of the class to be loaded
+ *
+ * @param name Name of the class to be loaded
* @param resolve If <code>true</code> then resolve the class
- *
- * @exception ClassNotFoundException if the class was not found
- */
+ * @throws ClassNotFoundException if the class was not found
+ */
public Class loadClass(final String name, boolean resolve)
- throws ClassNotFoundException {
+ throws ClassNotFoundException {
- Class clazz = null;
-
+ Class clazz = null;
+
// (0) Check our previously loaded class cache
- clazz = findLoadedClass(name);
- if (clazz != null) {
- if (resolve)
- resolveClass(clazz);
- return (clazz);
- }
-
+ clazz = findLoadedClass(name);
+ if (clazz != null) {
+ if (resolve)
+ resolveClass(clazz);
+ return (clazz);
+ }
+
// (.5) Permission to access this class when using a SecurityManager
- if (securityManager != null) {
+ if (securityManager != null) {
int dot = name.lastIndexOf('.');
- if (dot >= 0) {
- try {
+ if (dot >= 0) {
+ try {
// Do not call the security manager since by default, we grant that package.
- if (!"org.apache.struts2.jasper.runtime".equalsIgnoreCase(name.substring(0,dot))){
- securityManager.checkPackageAccess(name.substring(0,dot));
+ if (!"org.apache.struts2.jasper.runtime".equalsIgnoreCase(name.substring(0, dot))) {
+ securityManager.checkPackageAccess(name.substring(0, dot));
}
} catch (SecurityException se) {
String error = "Security Violation, attempt to use " +
- "Restricted Class: " + name;
+ "Restricted Class: " + name;
se.printStackTrace();
throw new ClassNotFoundException(error);
- }
- }
+ }
+ }
}
- if( !name.startsWith(Constants.JSP_PACKAGE_NAME) ) {
+ if (!name.startsWith(Constants.JSP_PACKAGE_NAME)) {
// Class is not in org.apache.jsp, therefore, have our
// parent load it
- clazz = parent.loadClass(name);
- if( resolve )
- resolveClass(clazz);
- return clazz;
- }
+ clazz = parent.loadClass(name);
+ if (resolve)
+ resolveClass(clazz);
+ return clazz;
+ }
- return findClass(name);
+ return findClass(name);
}
-
+
/**
* Delegate to parent
- *
+ *
* @see java.lang.ClassLoader#getResourceAsStream(java.lang.String)
*/
public InputStream getResourceAsStream(String name) {
@@ -151,11 +149,11 @@
}
return is;
}
-
-
+
+
/**
* Get the Permissions for a CodeSource.
- *
+ * <p/>
* Since this ClassLoader is only used for a JSP page in
* a web application context, we just return our preset
* PermissionCollection for the web app context.
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JspCServletContext.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JspCServletContext.java
index 1bb6ceb..d7b8552 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JspCServletContext.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JspCServletContext.java
@@ -19,6 +19,7 @@
import com.opensymphony.xwork2.util.finder.ClassLoaderInterface;
+import com.opensymphony.xwork2.ActionContext;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
@@ -31,6 +32,8 @@
import java.net.URL;
import java.util.*;
+import org.apache.struts2.ServletActionContext;
+
/**
* Simple <code>ServletContext</code> implementation without
@@ -57,6 +60,7 @@
protected PrintWriter myLogWriter;
private ClassLoaderInterface classLoaderInterface;
+ private static final String WEB_XML = "/WEB-INF/web.xml";
// ----------------------------------------------------------- Constructors
@@ -188,14 +192,14 @@
public String getRealPath(String path) {
try {
return
- (getResource(path).getFile().replace('/', File.separatorChar));
+ (getResource(path).getFile().replace('/', File.separatorChar));
} catch (Throwable t) {
return (null);
}
}
-
-
+
+
/**
* Return a request dispatcher for the specified context-relative path.
*
@@ -213,11 +217,18 @@
* specified context-relative path.
*
* @param path Context-relative path of the desired resource
- *
- * @exception MalformedURLException if the resource path is
- * not properly formed
+ * @throws MalformedURLException if the resource path is
+ * not properly formed
*/
public URL getResource(String path) throws MalformedURLException {
+ if (WEB_XML.equals(path)) {
+ if (ActionContext.getContext() != null) {
+ ServletContext context = ServletActionContext.getServletContext();
+ return context.getResource(path);
+ }
+
+ return null;
+ }
return classLoaderInterface.getResource(path);
}
@@ -283,7 +294,6 @@
* Return a null reference for the specified servlet name.
*
* @param name Name of the requested servlet
- *
* @deprecated This method has been deprecated with no replacement
*/
public Servlet getServlet(String name) throws ServletException {
@@ -343,8 +353,7 @@
* Log the specified message and exception.
*
* @param exception The exception to be logged
- * @param message The message to be logged
- *
+ * @param message The message to be logged
* @deprecated Use log(String,Throwable) instead
*/
public void log(Exception exception, String message) {
@@ -357,7 +366,7 @@
/**
* Log the specified message and exception.
*
- * @param message The message to be logged
+ * @param message The message to be logged
* @param exception The exception to be logged
*/
public void log(String message, Throwable exception) {
@@ -383,7 +392,7 @@
/**
* Set or replace the specified context attribute.
*
- * @param name Name of the context attribute to set
+ * @param name Name of the context attribute to set
* @param value Corresponding attribute value
*/
public void setAttribute(String name, Object value) {
@@ -393,5 +402,4 @@
}
-
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JspServlet.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JspServlet.java
index 13ffd9f..dddec77 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JspServlet.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JspServlet.java
@@ -17,8 +17,8 @@
package org.apache.struts2.jasper.servlet;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.Constants;
import org.apache.struts2.jasper.EmbeddedServletOptions;
import org.apache.struts2.jasper.Options;
@@ -37,7 +37,7 @@
/**
* The JSP engine (a.k.a Jasper).
- *
+ * <p/>
* The servlet container is responsible for providing a
* URLClassLoader for the web application context Jasper
* is being used in. Jasper will try get the Tomcat
@@ -54,7 +54,7 @@
public class JspServlet extends HttpServlet {
// Logger
- private Log log = LogFactory.getLog(JspServlet.class);
+ private Logger log = LoggerFactory.getLogger(JspServlet.class);
private ServletContext context;
private ServletConfig config;
@@ -66,24 +66,24 @@
* Initializes this JspServlet.
*/
public void init(ServletConfig config) throws ServletException {
-
+
super.init(config);
this.config = config;
this.context = config.getServletContext();
-
+
// Initialize the JSP Runtime Context
// Check for a custom Options implementation
- String engineOptionsName =
- config.getInitParameter("engineOptionsClass");
+ String engineOptionsName =
+ config.getInitParameter("engineOptionsClass");
if (engineOptionsName != null) {
// Instantiate the indicated Options implementation
try {
ClassLoader loader = Thread.currentThread()
.getContextClassLoader();
Class engineOptionsClass = loader.loadClass(engineOptionsName);
- Class[] ctorSig = { ServletConfig.class, ServletContext.class };
+ Class[] ctorSig = {ServletConfig.class, ServletContext.class};
Constructor ctor = engineOptionsClass.getConstructor(ctorSig);
- Object[] args = { config, context };
+ Object[] args = {config, context};
options = (Options) ctor.newInstance(args);
} catch (Throwable e) {
// Need to localize this.
@@ -96,7 +96,7 @@
options = new EmbeddedServletOptions(config, context);
}
rctxt = new JspRuntimeContext(context, options);
-
+
if (log.isDebugEnabled()) {
log.debug(Localizer.getMessage("jsp.message.scratch.dir.is",
options.getScratchDir().toString()));
@@ -109,11 +109,11 @@
* Returns the number of JSPs for which JspServletWrappers exist, i.e.,
* the number of JSPs that have been loaded into the webapp with which
* this JspServlet is associated.
- *
+ * <p/>
* <p>This info may be used for monitoring purposes.
*
* @return The number of JSPs that have been loaded into the webapp with
- * which this JspServlet is associated
+ * which this JspServlet is associated
*/
public int getJspCount() {
return this.rctxt.getJspCount();
@@ -132,11 +132,11 @@
/**
* Gets the number of JSPs that have been reloaded.
- *
+ * <p/>
* <p>This info may be used for monitoring purposes.
*
* @return The number of JSPs (in the webapp with which this JspServlet is
- * associated) that have been reloaded
+ * associated) that have been reloaded
*/
public int getJspReloadCount() {
return this.rctxt.getJspReloadCount();
@@ -152,9 +152,8 @@
* <code>request.setCharacterEncoding()</code> first.</p>
*
* @param request The servlet requset we are processing
- *
- * @exception ServletException if an invalid parameter value for the
- * <code>jsp_precompile</code> parameter name is specified
+ * @throws ServletException if an invalid parameter value for the
+ * <code>jsp_precompile</code> parameter name is specified
*/
boolean preCompile(HttpServletRequest request) throws ServletException {
@@ -167,7 +166,7 @@
return (false);
}
queryString =
- queryString.substring(start + Constants.PRECOMPILE.length());
+ queryString.substring(start + Constants.PRECOMPILE.length());
if (queryString.length() == 0) {
return (true); // ?jsp_precompile
}
@@ -194,16 +193,16 @@
return (true); // ?jsp_precompile=false
} else {
throw new ServletException("Cannot have request parameter " +
- Constants.PRECOMPILE + " set to " +
- value);
+ Constants.PRECOMPILE + " set to " +
+ value);
}
}
-
- public void service (HttpServletRequest request,
- HttpServletResponse response)
- throws ServletException, IOException {
+
+ public void service(HttpServletRequest request,
+ HttpServletResponse response)
+ throws ServletException, IOException {
String jspUri = null;
@@ -224,7 +223,7 @@
* relevant javax.servlet.include.* request attributes
*/
String pathInfo = (String) request.getAttribute(
- "javax.servlet.include.path_info");
+ "javax.servlet.include.path_info");
if (pathInfo != null) {
jspUri += pathInfo;
}
@@ -253,8 +252,8 @@
Enumeration e = request.getParameterNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
- log.debug("\t\t " + name + " = "
- + request.getParameter(name));
+ log.debug("\t\t " + name + " = "
+ + request.getParameter(name));
}
}
@@ -287,39 +286,39 @@
private void serviceJspFile(HttpServletRequest request,
HttpServletResponse response, String jspUri,
Throwable exception, boolean precompile)
- throws ServletException, IOException {
+ throws ServletException, IOException {
JspServletWrapper wrapper =
- (JspServletWrapper) rctxt.getWrapper(jspUri);
+ (JspServletWrapper) rctxt.getWrapper(jspUri);
if (wrapper == null) {
- synchronized(this) {
+ synchronized (this) {
wrapper = (JspServletWrapper) rctxt.getWrapper(jspUri);
if (wrapper == null) {
// Check if the requested JSP page exists, to avoid
// creating unnecessary directories and files.
if (null == context.getResource(jspUri)) {
String includeRequestUri = (String)
- request.getAttribute("javax.servlet.include.request_uri");
+ request.getAttribute("javax.servlet.include.request_uri");
if (includeRequestUri != null) {
// This file was included. Throw an exception as
// a response.sendError() will be ignored
throw new ServletException(Localizer.getMessage(
- "jsp.error.file.not.found",jspUri));
+ "jsp.error.file.not.found", jspUri));
} else {
try {
response.sendError(HttpServletResponse.SC_NOT_FOUND,
request.getRequestURI());
- } catch (IllegalStateException ise) {
- log.error(Localizer.getMessage("jsp.error.file.not.found",
- jspUri));
+ } catch (IllegalStateException ise) {
+ log.error(Localizer.getMessage("jsp.error.file.not.found",
+ jspUri));
+ }
}
- }
return;
}
boolean isErrorPage = exception != null;
wrapper = new JspServletWrapper(config, options, jspUri,
- isErrorPage, rctxt);
- rctxt.addWrapper(jspUri,wrapper);
+ isErrorPage, rctxt);
+ rctxt.addWrapper(jspUri, wrapper);
}
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JspServletWrapper.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JspServletWrapper.java
index 5f5c643..1a62e6f 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JspServletWrapper.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/JspServletWrapper.java
@@ -36,7 +36,7 @@
/**
* The JSP engine (a.k.a Jasper).
- *
+ * <p/>
* The servlet container is responsible for providing a
* URLClassLoader for the web application context Jasper
* is being used in. Jasper will try get the Tomcat
@@ -77,34 +77,34 @@
boolean isErrorPage, JspRuntimeContext rctxt)
throws JasperException {
- this.isTagFile = false;
+ this.isTagFile = false;
this.config = config;
this.options = options;
this.jspUri = jspUri;
ctxt = new JspCompilationContext(jspUri, isErrorPage, options,
- config.getServletContext(),
- this, rctxt, null);
+ config.getServletContext(),
+ this, rctxt, null);
}
/*
* JspServletWrapper for tag files.
*/
public JspServletWrapper(ServletContext servletContext,
- Options options,
- String tagFilePath,
- TagInfo tagInfo,
- JspRuntimeContext rctxt,
- URL tagFileJarUrl)
- throws JasperException {
+ Options options,
+ String tagFilePath,
+ TagInfo tagInfo,
+ JspRuntimeContext rctxt,
+ URL tagFileJarUrl)
+ throws JasperException {
- this.isTagFile = true;
- this.config = null; // not used
+ this.isTagFile = true;
+ this.config = null; // not used
this.options = options;
- this.jspUri = tagFilePath;
- this.tripCount = 0;
+ this.jspUri = tagFilePath;
+ this.tripCount = 0;
ctxt = new JspCompilationContext(jspUri, tagInfo, options,
- servletContext, this, rctxt,
- tagFileJarUrl);
+ servletContext, this, rctxt,
+ tagFileJarUrl);
}
public JspCompilationContext getJspEngineContext() {
@@ -116,8 +116,7 @@
}
public Servlet getServlet()
- throws ServletException, IOException, FileNotFoundException
- {
+ throws ServletException, IOException, FileNotFoundException {
if (reload) {
synchronized (this) {
// Synchronizing on jsw enables simultaneous loading
@@ -125,17 +124,17 @@
if (reload) {
// This is to maintain the original protocol.
destroy();
-
+
Servlet servlet = null;
try {
servletClass = ctxt.load();
servlet = (Servlet) servletClass.newInstance();
- } catch( IllegalAccessException ex1 ) {
- throw new JasperException( ex1 );
- } catch( InstantiationException ex ) {
- throw new JasperException( ex );
+ } catch (IllegalAccessException ex1) {
+ throw new JasperException(ex1);
+ } catch (InstantiationException ex) {
+ throw new JasperException(ex);
}
-
+
servlet.init(config);
if (!firstTime) {
@@ -145,7 +144,7 @@
theServlet = servlet;
reload = false;
}
- }
+ }
}
return theServlet;
}
@@ -189,7 +188,7 @@
if (ctxt.isRemoved()) {
throw new FileNotFoundException(jspUri);
}
- if (options.getDevelopment() || firstTime ) {
+ if (options.getDevelopment() || firstTime) {
synchronized (this) {
firstTime = false;
ctxt.compile();
@@ -206,9 +205,9 @@
}
} catch (FileNotFoundException ex) {
throw new JasperException(ex);
- }
+ }
- return tagHandlerClass;
+ return tagHandlerClass;
}
/**
@@ -219,53 +218,53 @@
*/
public Class loadTagFilePrototype() throws JasperException {
- ctxt.setPrototypeMode(true);
- try {
- return loadTagFile();
- } finally {
- ctxt.setPrototypeMode(false);
- }
+ ctxt.setPrototypeMode(true);
+ try {
+ return loadTagFile();
+ } finally {
+ ctxt.setPrototypeMode(false);
+ }
}
/**
* Get a list of files that the current page has source dependency on.
*/
public java.util.List getDependants() {
- try {
- Object target;
- if (isTagFile) {
+ try {
+ Object target;
+ if (isTagFile) {
if (reload) {
tagHandlerClass = ctxt.load();
reload = false;
}
- target = tagHandlerClass.newInstance();
- } else {
- target = getServlet();
- }
- if (target != null && target instanceof JspSourceDependent) {
- return ((java.util.List) ((JspSourceDependent) target).getDependants());
- }
- } catch (Throwable ex) {
- }
- return null;
+ target = tagHandlerClass.newInstance();
+ } else {
+ target = getServlet();
+ }
+ if (target != null && target instanceof JspSourceDependent) {
+ return ((java.util.List) ((JspSourceDependent) target).getDependants());
+ }
+ } catch (Throwable ex) {
+ }
+ return null;
}
public boolean isTagFile() {
- return this.isTagFile;
+ return this.isTagFile;
}
public int incTripCount() {
- return tripCount++;
+ return tripCount++;
}
public int decTripCount() {
- return tripCount--;
+ return tripCount--;
}
- public void service(HttpServletRequest request,
+ public void service(HttpServletRequest request,
HttpServletResponse response,
boolean precompile)
- throws ServletException, IOException, FileNotFoundException {
+ throws ServletException, IOException, FileNotFoundException {
try {
if (ctxt.isRemoved()) {
@@ -276,8 +275,8 @@
if (available > System.currentTimeMillis()) {
response.setDateHeader("Retry-After", available);
response.sendError
- (HttpServletResponse.SC_SERVICE_UNAVAILABLE,
- Localizer.getMessage("jsp.error.unavailable"));
+ (HttpServletResponse.SC_SERVICE_UNAVAILABLE,
+ Localizer.getMessage("jsp.error.unavailable"));
return;
} else {
// Wait period has expired. Reset.
@@ -288,7 +287,7 @@
/*
* (1) Compile
*/
- if (options.getDevelopment() || firstTime ) {
+ if (options.getDevelopment() || firstTime) {
synchronized (this) {
firstTime = false;
@@ -316,10 +315,10 @@
* (3) Service request
*/
if (theServlet instanceof SingleThreadModel) {
- // sync on the wrapper so that the freshness
- // of the page is determined right before servicing
- synchronized (this) {
- theServlet.service(request, response);
+ // sync on the wrapper so that the freshness
+ // of the page is determined right before servicing
+ synchronized (this) {
+ theServlet.service(request, response);
}
} else {
theServlet.service(request, response);
@@ -327,7 +326,7 @@
} catch (UnavailableException ex) {
String includeRequestUri = (String)
- request.getAttribute("javax.servlet.include.request_uri");
+ request.getAttribute("javax.servlet.include.request_uri");
if (includeRequestUri != null) {
// This file was included. Throw an exception as
// a response.sendError() will be ignored by the
@@ -339,31 +338,31 @@
unavailableSeconds = 60; // Arbitrary default
}
available = System.currentTimeMillis() +
- (unavailableSeconds * 1000L);
+ (unavailableSeconds * 1000L);
response.sendError
- (HttpServletResponse.SC_SERVICE_UNAVAILABLE,
- ex.getMessage());
+ (HttpServletResponse.SC_SERVICE_UNAVAILABLE,
+ ex.getMessage());
}
} catch (ServletException ex) {
- if(options.getDevelopment()) {
+ if (options.getDevelopment()) {
throw handleJspException(ex);
} else {
throw ex;
}
} catch (IOException ex) {
- if(options.getDevelopment()) {
+ if (options.getDevelopment()) {
throw handleJspException(ex);
} else {
throw ex;
}
} catch (IllegalStateException ex) {
- if(options.getDevelopment()) {
+ if (options.getDevelopment()) {
throw handleJspException(ex);
} else {
throw ex;
}
} catch (Exception ex) {
- if(options.getDevelopment()) {
+ if (options.getDevelopment()) {
throw handleJspException(ex);
} else {
throw new JasperException(ex);
@@ -383,6 +382,7 @@
public long getLastModificationTest() {
return lastModificationTest;
}
+
/**
* @param lastModificationTest The lastModificationTest to set.
*/
@@ -398,7 +398,7 @@
* information, and a snippet of the JSP to help debugging.
* Please see http://issues.apache.org/bugzilla/show_bug.cgi?id=37062 and
* http://www.tfenne.com/jasper/ for more details.
- *</p>
+ * </p>
*
* @param ex the exception that was the cause of the problem.
* @return a JasperException with more detailed information
@@ -414,8 +414,8 @@
StackTraceElement[] frames = realException.getStackTrace();
StackTraceElement jspFrame = null;
- for (int i=0; i<frames.length; ++i) {
- if ( frames[i].getClassName().equals(this.getServlet().getClass().getName()) ) {
+ for (int i = 0; i < frames.length; ++i) {
+ if (frames[i].getClassName().equals(this.getServlet().getClass().getName())) {
jspFrame = frames[i];
break;
}
@@ -425,8 +425,7 @@
// If we couldn't find a frame in the stack trace corresponding
// to the generated servlet class, we can't really add anything
return new JasperException(ex);
- }
- else {
+ } else {
int javaLineNumber = jspFrame.getLineNumber();
JavacErrorDetail detail = ErrorDispatcher.createJavacError(
jspFrame.getMethodName(),
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/mbeans-descriptors.xml b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/mbeans-descriptors.xml
index 69781ea..bd83ecb 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/mbeans-descriptors.xml
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/servlet/mbeans-descriptors.xml
@@ -17,20 +17,20 @@
-->
<mbeans-descriptors>
- <mbean name="JspMonitor"
- description="JSP Monitoring"
- domain="Catalina"
- group="Monitoring"
- type="org.apache.struts2.jasper.servlet.JspServlet">
+ <mbean name="JspMonitor"
+ description="JSP Monitoring"
+ domain="Catalina"
+ group="Monitoring"
+ type="org.apache.struts2.jasper.servlet.JspServlet">
- <attribute name="jspCount"
- description="The number of JSPs that have been loaded into a webapp"
- type="int"/>
+ <attribute name="jspCount"
+ description="The number of JSPs that have been loaded into a webapp"
+ type="int"/>
- <attribute name="jspReloadCount"
- description="The number of JSPs that have been reloaded"
- type="int"/>
+ <attribute name="jspReloadCount"
+ description="The number of JSPs that have been reloaded"
+ type="int"/>
- </mbean>
+ </mbean>
</mbeans-descriptors>
\ No newline at end of file
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/Util.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/Util.java
index de914fe..70371b8 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/Util.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/Util.java
@@ -34,17 +34,17 @@
*/
public class Util {
-
- public static final String VALID_SCHEME_CHAR =
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+.-";
-
- public static final String DEFAULT_ENCODING =
- "ISO-8859-1";
-
+
+ public static final String VALID_SCHEME_CHAR =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+.-";
+
+ public static final String DEFAULT_ENCODING =
+ "ISO-8859-1";
+
public static final int HIGHEST_SPECIAL = '>';
-
+
public static char[][] specialCharactersRepresentation = new char[HIGHEST_SPECIAL + 1][];
-
+
static {
specialCharactersRepresentation['&'] = "&".toCharArray();
specialCharactersRepresentation['<'] = "<".toCharArray();
@@ -52,58 +52,57 @@
specialCharactersRepresentation['"'] = """.toCharArray();
specialCharactersRepresentation['\''] = "'".toCharArray();
}
-
+
/**
* Converts the given string description of a scope to the corresponding
* PageContext constant.
- *
+ * <p/>
* The validity of the given scope has already been checked by the
* appropriate TLV.
*
* @param scope String description of scope
- *
* @return PageContext constant corresponding to given scope description
- *
- * taken from org.apache.taglibs.standard.tag.common.core.Util
+ * <p/>
+ * taken from org.apache.taglibs.standard.tag.common.core.Util
*/
- public static int getScope(String scope){
+ public static int getScope(String scope) {
int ret = PageContext.PAGE_SCOPE;
-
- if("request".equalsIgnoreCase(scope)){
+
+ if ("request".equalsIgnoreCase(scope)) {
ret = PageContext.REQUEST_SCOPE;
- }else if("session".equalsIgnoreCase(scope)){
+ } else if ("session".equalsIgnoreCase(scope)) {
ret = PageContext.SESSION_SCOPE;
- }else if("application".equalsIgnoreCase(scope)){
+ } else if ("application".equalsIgnoreCase(scope)) {
ret = PageContext.APPLICATION_SCOPE;
}
-
+
return ret;
}
-
+
/**
* Returns <tt>true</tt> if our current URL is absolute,
* <tt>false</tt> otherwise.
* taken from org.apache.taglibs.standard.tag.common.core.ImportSupport
*/
- public static boolean isAbsoluteUrl(String url){
- if(url == null){
+ public static boolean isAbsoluteUrl(String url) {
+ if (url == null) {
return false;
}
-
+
int colonPos = url.indexOf(":");
- if(colonPos == -1){
+ if (colonPos == -1) {
return false;
}
-
- for(int i=0;i<colonPos;i++){
- if(VALID_SCHEME_CHAR.indexOf(url.charAt(i)) == -1){
+
+ for (int i = 0; i < colonPos; i++) {
+ if (VALID_SCHEME_CHAR.indexOf(url.charAt(i)) == -1) {
return false;
}
}
-
+
return true;
}
-
+
/**
* Get the value associated with a content-type attribute.
* Syntax defined in RFC 2045, section 5.1.
@@ -119,7 +118,7 @@
if (index == -1) return null;
index += 1; // positioned after the '='
input = input.substring(index).trim();
-
+
if (input.charAt(0) == '"') {
// attribute value is a quoted string
begin = 1;
@@ -133,13 +132,13 @@
}
return input.substring(begin, end).trim();
}
-
+
/**
* Strips a servlet session ID from <tt>url</tt>. The session ID
* is encoded as a URL "path parameter" beginning with "jsessionid=".
* We thus remove anything we find between ";jsessionid=" (inclusive)
* and either EOS or a subsequent ';' (exclusive).
- *
+ * <p/>
* taken from org.apache.taglibs.standard.tag.common.core.ImportSupport
*/
public static String stripSession(String url) {
@@ -149,26 +148,26 @@
int sessionEnd = u.toString().indexOf(";", sessionStart + 1);
if (sessionEnd == -1)
sessionEnd = u.toString().indexOf("?", sessionStart + 1);
- if (sessionEnd == -1) // still
+ if (sessionEnd == -1) // still
sessionEnd = u.length();
u.delete(sessionStart, sessionEnd);
}
return u.toString();
}
-
-
+
+
/**
* Performs the following substring replacements
* (to facilitate output to XML/HTML pages):
- *
- * & -> &
- * < -> <
- * > -> >
- * " -> "
- * ' -> '
- *
+ * <p/>
+ * & -> &
+ * < -> <
+ * > -> >
+ * " -> "
+ * ' -> '
+ * <p/>
* See also OutSupport.writeEscapedXml().
- *
+ * <p/>
* taken from org.apache.taglibs.standard.tag.common.core.Util
*/
public static String escapeXml(String buffer) {
@@ -176,7 +175,7 @@
int length = buffer.length();
char[] arrayBuffer = buffer.toCharArray();
StringBuffer escapedBuffer = null;
-
+
for (int i = 0; i < length; i++) {
char c = arrayBuffer[i];
if (c <= HIGHEST_SPECIAL) {
@@ -188,7 +187,7 @@
}
// add unescaped portion
if (start < i) {
- escapedBuffer.append(arrayBuffer,start,i-start);
+ escapedBuffer.append(arrayBuffer, start, i - start);
}
start = i + 1;
// add escaped xml
@@ -202,24 +201,25 @@
}
// add rest of unescaped portion
if (start < length) {
- escapedBuffer.append(arrayBuffer,start,length-start);
+ escapedBuffer.append(arrayBuffer, start, length - start);
}
return escapedBuffer.toString();
}
-
- /** Utility methods
+
+ /**
+ * Utility methods
* taken from org.apache.taglibs.standard.tag.common.core.UrlSupport
*/
public static String resolveUrl(
String url, String context, PageContext pageContext)
- throws JspException {
+ throws JspException {
// don't touch absolute URLs
if (isAbsoluteUrl(url))
return url;
-
+
// normalize relative URLs against a context root
HttpServletRequest request =
- (HttpServletRequest) pageContext.getRequest();
+ (HttpServletRequest) pageContext.getRequest();
if (context == null) {
if (url.startsWith("/"))
return (request.getContextPath() + url);
@@ -228,7 +228,7 @@
} else {
if (!context.startsWith("/") || !url.startsWith("/")) {
throw new JspTagException(
- "In URL tags, when the \"context\" attribute is specified, values of both \"context\" and \"url\" must start with \"/\".");
+ "In URL tags, when the \"context\" attribute is specified, values of both \"context\" and \"url\" must start with \"/\".");
}
if (context.equals("/")) {
// Don't produce string starting with '//', many
@@ -240,12 +240,13 @@
}
}
}
-
- /** Wraps responses to allow us to retrieve results as Strings.
- * mainly taken from org.apache.taglibs.standard.tag.common.core.importSupport
+
+ /**
+ * Wraps responses to allow us to retrieve results as Strings.
+ * mainly taken from org.apache.taglibs.standard.tag.common.core.importSupport
*/
- public static class ImportResponseWrapper extends HttpServletResponseWrapper{
-
+ public static class ImportResponseWrapper extends HttpServletResponseWrapper {
+
private StringWriter sw = new StringWriter();
private ByteArrayOutputStream bos = new ByteArrayOutputStream();
private ServletOutputStream sos = new ServletOutputStream() {
@@ -257,54 +258,58 @@
private boolean isStreamUsed;
private int status = 200;
private String charEncoding;
-
+
public ImportResponseWrapper(HttpServletResponse arg0) {
super(arg0);
// TODO Auto-generated constructor stub
}
-
+
public PrintWriter getWriter() {
if (isStreamUsed)
throw new IllegalStateException("Unexpected internal error during <import>: " +
- "Target servlet called getWriter(), then getOutputStream()");
+ "Target servlet called getWriter(), then getOutputStream()");
isWriterUsed = true;
return new PrintWriter(sw);
}
-
+
public ServletOutputStream getOutputStream() {
if (isWriterUsed)
throw new IllegalStateException("Unexpected internal error during <import>: " +
- "Target servlet called getOutputStream(), then getWriter()");
+ "Target servlet called getOutputStream(), then getWriter()");
isStreamUsed = true;
return sos;
}
-
- /** Has no effect. */
+
+ /**
+ * Has no effect.
+ */
public void setContentType(String x) {
// ignore
}
-
- /** Has no effect. */
+
+ /**
+ * Has no effect.
+ */
public void setLocale(Locale x) {
// ignore
}
-
+
public void setStatus(int status) {
this.status = status;
}
-
+
public int getStatus() {
return status;
}
-
- public String getCharEncoding(){
+
+ public String getCharEncoding() {
return this.charEncoding;
}
-
- public void setCharEncoding(String ce){
+
+ public void setCharEncoding(String ce) {
this.charEncoding = ce;
}
-
+
public String getString() throws UnsupportedEncodingException {
if (isWriterUsed)
return sw.toString();
@@ -314,8 +319,8 @@
else
return bos.toString("ISO-8859-1");
} else
- return ""; // target didn't write anything
+ return ""; // target didn't write anything
}
}
-
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Catch.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Catch.java
index e99b213..4932143 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Catch.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Catch.java
@@ -22,51 +22,51 @@
import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
public class Catch implements TagPlugin {
-
+
public void doTag(TagPluginContext ctxt) {
-
+
//flag for the existence of the var attribute
boolean hasVar = ctxt.isAttributeSpecified("var");
-
+
//temp name for exception and caught
String exceptionName = ctxt.getTemporaryVariableName();
String caughtName = ctxt.getTemporaryVariableName();
-
+
//main part to generate code
ctxt.generateJavaSource("boolean " + caughtName + " = false;");
ctxt.generateJavaSource("try{");
ctxt.generateBody();
ctxt.generateJavaSource("}");
-
+
//do catch
ctxt.generateJavaSource("catch(Throwable " + exceptionName + "){");
-
+
//if the var specified, the exception object should
//be set to the attribute "var" defines in page scope
- if(hasVar){
+ if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
- ctxt.generateJavaSource(" pageContext.setAttribute(\"" + strVar + "\", "
+ ctxt.generateJavaSource(" pageContext.setAttribute(\"" + strVar + "\", "
+ exceptionName + ", PageContext.PAGE_SCOPE);");
}
-
+
//whenever there's exception caught,
//the flag caught should be set true;
ctxt.generateJavaSource(" " + caughtName + " = true;");
ctxt.generateJavaSource("}");
-
+
//do finally
ctxt.generateJavaSource("finally{");
-
+
//if var specified, the attribute it defines
//in page scope should be removed
- if(hasVar){
+ if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
ctxt.generateJavaSource(" if(!" + caughtName + "){");
ctxt.generateJavaSource(" pageContext.removeAttribute(\"" + strVar + "\", PageContext.PAGE_SCOPE);");
ctxt.generateJavaSource(" }");
}
-
+
ctxt.generateJavaSource("}");
}
-
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Choose.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Choose.java
index 786edd1..223afa6 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Choose.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Choose.java
@@ -22,12 +22,12 @@
import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
public final class Choose implements TagPlugin {
-
+
public void doTag(TagPluginContext ctxt) {
-
+
// Not much to do here, much of the work will be done in the
// containing tags, <c:when> and <c:otherwise>.
-
+
ctxt.generateBody();
// See comments in When.java for the reason "}" is generated here.
ctxt.generateJavaSource("}");
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/ForEach.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/ForEach.java
index e03a68e..613dfc7 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/ForEach.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/ForEach.java
@@ -22,30 +22,30 @@
import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
public final class ForEach implements TagPlugin {
-
+
private boolean hasVar, hasBegin, hasEnd, hasStep;
-
+
public void doTag(TagPluginContext ctxt) {
-
+
String index = null;
-
+
boolean hasVarStatus = ctxt.isAttributeSpecified("varStatus");
if (hasVarStatus) {
ctxt.dontUseTagPlugin();
return;
}
-
+
hasVar = ctxt.isAttributeSpecified("var");
hasBegin = ctxt.isAttributeSpecified("begin");
hasEnd = ctxt.isAttributeSpecified("end");
hasStep = ctxt.isAttributeSpecified("step");
-
+
boolean hasItems = ctxt.isAttributeSpecified("items");
if (hasItems) {
doCollection(ctxt);
return;
}
-
+
// We must have a begin and end attributes
index = ctxt.getTemporaryVariableName();
ctxt.generateJavaSource("for (int " + index + " = ");
@@ -56,11 +56,10 @@
ctxt.generateJavaSource("; " + index + "+=");
ctxt.generateAttribute("step");
ctxt.generateJavaSource(") {");
- }
- else {
+ } else {
ctxt.generateJavaSource("; " + index + "++) {");
}
-
+
// If var is specified and the body contains an EL, then sycn
// the var attribute
if (hasVar /* && ctxt.hasEL() */) {
@@ -71,22 +70,22 @@
ctxt.generateBody();
ctxt.generateJavaSource("}");
}
-
+
/**
* Generate codes for Collections
* The pseudo code is:
*/
private void doCollection(TagPluginContext ctxt) {
-
+
ctxt.generateImport("java.util.*");
generateIterators(ctxt);
-
+
String itemsV = ctxt.getTemporaryVariableName();
ctxt.generateJavaSource("Object " + itemsV + "= ");
ctxt.generateAttribute("items");
ctxt.generateJavaSource(";");
-
- String indexV=null, beginV=null, endV=null, stepV=null;
+
+ String indexV = null, beginV = null, endV = null, stepV = null;
if (hasBegin) {
beginV = ctxt.getTemporaryVariableName();
ctxt.generateJavaSource("int " + beginV + " = ");
@@ -107,7 +106,7 @@
ctxt.generateAttribute("step");
ctxt.generateJavaSource(";");
}
-
+
String iterV = ctxt.getTemporaryVariableName();
ctxt.generateJavaSource("Iterator " + iterV + " = null;");
// Object[]
@@ -137,23 +136,23 @@
// double[]
ctxt.generateJavaSource("else if (" + itemsV + " instanceof double[])");
ctxt.generateJavaSource(iterV + "=toIterator((double[])" + itemsV + ");");
-
+
// Collection
ctxt.generateJavaSource("else if (" + itemsV + " instanceof Collection)");
ctxt.generateJavaSource(iterV + "=((Collection)" + itemsV + ").iterator();");
-
+
// Iterator
ctxt.generateJavaSource("else if (" + itemsV + " instanceof Iterator)");
ctxt.generateJavaSource(iterV + "=(Iterator)" + itemsV + ";");
-
+
// Enumeration
ctxt.generateJavaSource("else if (" + itemsV + " instanceof Enumeration)");
ctxt.generateJavaSource(iterV + "=toIterator((Enumeration)" + itemsV + ");");
-
+
// Map
ctxt.generateJavaSource("else if (" + itemsV + " instanceof Map)");
ctxt.generateJavaSource(iterV + "=((Map)" + itemsV + ").entrySet().iterator();");
-
+
if (hasBegin) {
String tV = ctxt.getTemporaryVariableName();
ctxt.generateJavaSource("for (int " + tV + "=" + beginV + ";" +
@@ -161,16 +160,16 @@
tV + "--)");
ctxt.generateJavaSource(iterV + ".next();");
}
-
+
ctxt.generateJavaSource("while (" + iterV + ".hasNext()){");
if (hasVar) {
ctxt.generateJavaSource("_jspx_page_context.setAttribute(");
ctxt.generateAttribute("var");
ctxt.generateJavaSource(", " + iterV + ".next());");
}
-
+
ctxt.generateBody();
-
+
if (hasStep) {
String tV = ctxt.getTemporaryVariableName();
ctxt.generateJavaSource("for (int " + tV + "=" + stepV + "-1;" +
@@ -181,165 +180,163 @@
if (hasEnd) {
if (hasStep) {
ctxt.generateJavaSource(indexV + "+=" + stepV + ";");
- }
- else {
+ } else {
ctxt.generateJavaSource(indexV + "++;");
}
if (hasBegin) {
ctxt.generateJavaSource("if(" + beginV + "+" + indexV +
- ">"+ endV + ")");
- }
- else {
+ ">" + endV + ")");
+ } else {
ctxt.generateJavaSource("if(" + indexV + ">" + endV + ")");
}
ctxt.generateJavaSource("break;");
}
- ctxt.generateJavaSource("}"); // while
+ ctxt.generateJavaSource("}"); // while
}
-
+
/**
* Generate iterators for data types supported in items
*/
private void generateIterators(TagPluginContext ctxt) {
-
+
// Object[]
- ctxt.generateDeclaration("ObjectArrayIterator",
+ ctxt.generateDeclaration("ObjectArrayIterator",
"private Iterator toIterator(final Object[] a){\n" +
- " return (new Iterator() {\n" +
- " int index=0;\n" +
- " public boolean hasNext() {\n" +
- " return index < a.length;}\n" +
- " public Object next() {\n" +
- " return a[index++];}\n" +
- " public void remove() {}\n" +
- " });\n" +
- "}"
+ " return (new Iterator() {\n" +
+ " int index=0;\n" +
+ " public boolean hasNext() {\n" +
+ " return index < a.length;}\n" +
+ " public Object next() {\n" +
+ " return a[index++];}\n" +
+ " public void remove() {}\n" +
+ " });\n" +
+ "}"
);
-
+
// boolean[]
- ctxt.generateDeclaration("booleanArrayIterator",
+ ctxt.generateDeclaration("booleanArrayIterator",
"private Iterator toIterator(final boolean[] a){\n" +
- " return (new Iterator() {\n" +
- " int index=0;\n" +
- " public boolean hasNext() {\n" +
- " return index < a.length;}\n" +
- " public Object next() {\n" +
- " return new Boolean(a[index++]);}\n" +
- " public void remove() {}\n" +
- " });\n" +
- "}"
+ " return (new Iterator() {\n" +
+ " int index=0;\n" +
+ " public boolean hasNext() {\n" +
+ " return index < a.length;}\n" +
+ " public Object next() {\n" +
+ " return new Boolean(a[index++]);}\n" +
+ " public void remove() {}\n" +
+ " });\n" +
+ "}"
);
-
+
// byte[]
- ctxt.generateDeclaration("byteArrayIterator",
+ ctxt.generateDeclaration("byteArrayIterator",
"private Iterator toIterator(final byte[] a){\n" +
- " return (new Iterator() {\n" +
- " int index=0;\n" +
- " public boolean hasNext() {\n" +
- " return index < a.length;}\n" +
- " public Object next() {\n" +
- " return new Byte(a[index++]);}\n" +
- " public void remove() {}\n" +
- " });\n" +
- "}"
+ " return (new Iterator() {\n" +
+ " int index=0;\n" +
+ " public boolean hasNext() {\n" +
+ " return index < a.length;}\n" +
+ " public Object next() {\n" +
+ " return new Byte(a[index++]);}\n" +
+ " public void remove() {}\n" +
+ " });\n" +
+ "}"
);
-
+
// char[]
- ctxt.generateDeclaration("charArrayIterator",
+ ctxt.generateDeclaration("charArrayIterator",
"private Iterator toIterator(final char[] a){\n" +
- " return (new Iterator() {\n" +
- " int index=0;\n" +
- " public boolean hasNext() {\n" +
- " return index < a.length;}\n" +
- " public Object next() {\n" +
- " return new Character(a[index++]);}\n" +
- " public void remove() {}\n" +
- " });\n" +
- "}"
+ " return (new Iterator() {\n" +
+ " int index=0;\n" +
+ " public boolean hasNext() {\n" +
+ " return index < a.length;}\n" +
+ " public Object next() {\n" +
+ " return new Character(a[index++]);}\n" +
+ " public void remove() {}\n" +
+ " });\n" +
+ "}"
);
-
+
// short[]
- ctxt.generateDeclaration("shortArrayIterator",
+ ctxt.generateDeclaration("shortArrayIterator",
"private Iterator toIterator(final short[] a){\n" +
- " return (new Iterator() {\n" +
- " int index=0;\n" +
- " public boolean hasNext() {\n" +
- " return index < a.length;}\n" +
- " public Object next() {\n" +
- " return new Short(a[index++]);}\n" +
- " public void remove() {}\n" +
- " });\n" +
- "}"
+ " return (new Iterator() {\n" +
+ " int index=0;\n" +
+ " public boolean hasNext() {\n" +
+ " return index < a.length;}\n" +
+ " public Object next() {\n" +
+ " return new Short(a[index++]);}\n" +
+ " public void remove() {}\n" +
+ " });\n" +
+ "}"
);
-
+
// int[]
- ctxt.generateDeclaration("intArrayIterator",
+ ctxt.generateDeclaration("intArrayIterator",
"private Iterator toIterator(final int[] a){\n" +
- " return (new Iterator() {\n" +
- " int index=0;\n" +
- " public boolean hasNext() {\n" +
- " return index < a.length;}\n" +
- " public Object next() {\n" +
- " return new Integer(a[index++]);}\n" +
- " public void remove() {}\n" +
- " });\n" +
- "}"
+ " return (new Iterator() {\n" +
+ " int index=0;\n" +
+ " public boolean hasNext() {\n" +
+ " return index < a.length;}\n" +
+ " public Object next() {\n" +
+ " return new Integer(a[index++]);}\n" +
+ " public void remove() {}\n" +
+ " });\n" +
+ "}"
);
-
+
// long[]
- ctxt.generateDeclaration("longArrayIterator",
+ ctxt.generateDeclaration("longArrayIterator",
"private Iterator toIterator(final long[] a){\n" +
- " return (new Iterator() {\n" +
- " int index=0;\n" +
- " public boolean hasNext() {\n" +
- " return index < a.length;}\n" +
- " public Object next() {\n" +
- " return new Long(a[index++]);}\n" +
- " public void remove() {}\n" +
- " });\n" +
- "}"
+ " return (new Iterator() {\n" +
+ " int index=0;\n" +
+ " public boolean hasNext() {\n" +
+ " return index < a.length;}\n" +
+ " public Object next() {\n" +
+ " return new Long(a[index++]);}\n" +
+ " public void remove() {}\n" +
+ " });\n" +
+ "}"
);
-
+
// float[]
ctxt.generateDeclaration("floatArrayIterator",
"private Iterator toIterator(final float[] a){\n" +
- " return (new Iterator() {\n" +
- " int index=0;\n" +
- " public boolean hasNext() {\n" +
- " return index < a.length;}\n" +
- " public Object next() {\n" +
- " return new Float(a[index++]);}\n" +
- " public void remove() {}\n" +
- " });\n" +
- "}"
+ " return (new Iterator() {\n" +
+ " int index=0;\n" +
+ " public boolean hasNext() {\n" +
+ " return index < a.length;}\n" +
+ " public Object next() {\n" +
+ " return new Float(a[index++]);}\n" +
+ " public void remove() {}\n" +
+ " });\n" +
+ "}"
);
-
+
// double[]
ctxt.generateDeclaration("doubleArrayIterator",
"private Iterator toIterator(final double[] a){\n" +
- " return (new Iterator() {\n" +
- " int index=0;\n" +
- " public boolean hasNext() {\n" +
- " return index < a.length;}\n" +
- " public Object next() {\n" +
- " return new Double(a[index++]);}\n" +
- " public void remove() {}\n" +
- " });\n" +
- "}"
+ " return (new Iterator() {\n" +
+ " int index=0;\n" +
+ " public boolean hasNext() {\n" +
+ " return index < a.length;}\n" +
+ " public Object next() {\n" +
+ " return new Double(a[index++]);}\n" +
+ " public void remove() {}\n" +
+ " });\n" +
+ "}"
);
-
+
// Enumeration
ctxt.generateDeclaration("enumIterator",
"private Iterator toIterator(final Enumeration e){\n" +
- " return (new Iterator() {\n" +
- " public boolean hasNext() {\n" +
- " return e.hasMoreElements();}\n" +
- " public Object next() {\n" +
- " return e.nextElement();}\n" +
- " public void remove() {}\n" +
- " });\n" +
- "}"
+ " return (new Iterator() {\n" +
+ " public boolean hasNext() {\n" +
+ " return e.hasMoreElements();}\n" +
+ " public Object next() {\n" +
+ " return e.nextElement();}\n" +
+ " public void remove() {}\n" +
+ " });\n" +
+ "}"
);
-
+
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/ForTokens.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/ForTokens.java
index fc0ba94..ced5920 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/ForTokens.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/ForTokens.java
@@ -22,64 +22,64 @@
import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
public class ForTokens implements TagPlugin {
-
+
public void doTag(TagPluginContext ctxt) {
boolean hasVar, hasVarStatus, hasBegin, hasEnd, hasStep;
-
+
//init the flags
hasVar = ctxt.isAttributeSpecified("var");
hasVarStatus = ctxt.isAttributeSpecified("varStatus");
hasBegin = ctxt.isAttributeSpecified("begin");
hasEnd = ctxt.isAttributeSpecified("end");
hasStep = ctxt.isAttributeSpecified("step");
-
- if(hasVarStatus){
+
+ if (hasVarStatus) {
ctxt.dontUseTagPlugin();
return;
}
-
+
//define all the temp variables' names
String itemsName = ctxt.getTemporaryVariableName();
String delimsName = ctxt.getTemporaryVariableName();
String stName = ctxt.getTemporaryVariableName();
String beginName = ctxt.getTemporaryVariableName();
- String endName = ctxt.getTemporaryVariableName();
+ String endName = ctxt.getTemporaryVariableName();
String stepName = ctxt.getTemporaryVariableName();
String index = ctxt.getTemporaryVariableName();
- String temp = ctxt.getTemporaryVariableName();
+ String temp = ctxt.getTemporaryVariableName();
String tokensCountName = ctxt.getTemporaryVariableName();
-
+
//get the value of the "items" attribute
ctxt.generateJavaSource("String " + itemsName + " = (String)");
ctxt.generateAttribute("items");
ctxt.generateJavaSource(";");
-
+
//get the value of the "delim" attribute
ctxt.generateJavaSource("String " + delimsName + " = (String)");
ctxt.generateAttribute("delims");
ctxt.generateJavaSource(";");
-
+
//new a StringTokenizer Object according to the "items" and the "delim"
ctxt.generateJavaSource("java.util.StringTokenizer " + stName + " = " +
"new java.util.StringTokenizer(" + itemsName + ", " + delimsName + ");");
-
+
//if "begin" specified, move the token to the "begin" place
//and record the begin index. default begin place is 0.
ctxt.generateJavaSource("int " + tokensCountName + " = " + stName + ".countTokens();");
- if(hasBegin){
- ctxt.generateJavaSource("int " + beginName + " = " );
+ if (hasBegin) {
+ ctxt.generateJavaSource("int " + beginName + " = ");
ctxt.generateAttribute("begin");
ctxt.generateJavaSource(";");
ctxt.generateJavaSource("for(int " + index + " = 0; " + index + " < " + beginName + " && " + stName + ".hasMoreTokens(); " + index + "++, " + stName + ".nextToken()){}");
- }else{
+ } else {
ctxt.generateJavaSource("int " + beginName + " = 0;");
}
-
+
//when "end" is specified, if the "end" is more than the last index,
//record the end place as the last index, otherwise, record it as "end";
//default end place is the last index
- if(hasEnd){
- ctxt.generateJavaSource("int " + endName + " = 0;" );
+ if (hasEnd) {
+ ctxt.generateJavaSource("int " + endName + " = 0;");
ctxt.generateJavaSource("if((" + tokensCountName + " - 1) < ");
ctxt.generateAttribute("end");
ctxt.generateJavaSource("){");
@@ -88,26 +88,26 @@
ctxt.generateJavaSource(" " + endName + " = ");
ctxt.generateAttribute("end");
ctxt.generateJavaSource(";}");
- }else{
+ } else {
ctxt.generateJavaSource("int " + endName + " = " + tokensCountName + " - 1;");
}
-
+
//get the step value from "step" if specified.
//default step value is 1.
- if(hasStep){
- ctxt.generateJavaSource("int " + stepName + " = " );
+ if (hasStep) {
+ ctxt.generateJavaSource("int " + stepName + " = ");
ctxt.generateAttribute("step");
ctxt.generateJavaSource(";");
- }else{
+ } else {
ctxt.generateJavaSource("int " + stepName + " = 1;");
}
-
+
//the loop
ctxt.generateJavaSource("for(int " + index + " = " + beginName + "; " + index + " <= " + endName + "; " + index + "++){");
ctxt.generateJavaSource(" String " + temp + " = " + stName + ".nextToken();");
ctxt.generateJavaSource(" if(((" + index + " - " + beginName + ") % " + stepName + ") == 0){");
//if var specified, put the current token into the attribute "var" defines.
- if(hasVar){
+ if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
ctxt.generateJavaSource(" pageContext.setAttribute(\"" + strVar + "\", " + temp + ");");
}
@@ -115,5 +115,5 @@
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource("}");
}
-
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/If.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/If.java
index 3955775..e84ee6b 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/If.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/If.java
@@ -22,7 +22,7 @@
import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
public final class If implements TagPlugin {
-
+
public void doTag(TagPluginContext ctxt) {
String condV = ctxt.getTemporaryVariableName();
ctxt.generateJavaSource("boolean " + condV + "=");
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Import.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Import.java
index 9499b03..ce5492a 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Import.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Import.java
@@ -23,24 +23,24 @@
import org.apache.struts2.jasper.tagplugins.jstl.Util;
public class Import implements TagPlugin {
-
+
public void doTag(TagPluginContext ctxt) {
boolean hasContext, hasVar, hasScope, hasVarReader, hasCharEncoding;
-
+
//flags
- hasContext = ctxt.isAttributeSpecified("context");
+ hasContext = ctxt.isAttributeSpecified("context");
hasVar = ctxt.isAttributeSpecified("var");
hasScope = ctxt.isAttributeSpecified("scope");
hasVarReader = ctxt.isAttributeSpecified("varReader");
hasCharEncoding = ctxt.isAttributeSpecified("charEncoding");
-
+
//variables' names
- String urlName = ctxt.getTemporaryVariableName();
- String contextName = ctxt.getTemporaryVariableName();
+ String urlName = ctxt.getTemporaryVariableName();
+ String contextName = ctxt.getTemporaryVariableName();
String iauName = ctxt.getTemporaryVariableName(); // is absolute url
String urlObjName = ctxt.getTemporaryVariableName(); //URL object
String ucName = ctxt.getTemporaryVariableName(); //URLConnection
- String inputStreamName = ctxt.getTemporaryVariableName();
+ String inputStreamName = ctxt.getTemporaryVariableName();
String tempReaderName = ctxt.getTemporaryVariableName();
String tempReaderName2 = ctxt.getTemporaryVariableName();
String charSetName = ctxt.getTemporaryVariableName();
@@ -54,115 +54,115 @@
String brName = ctxt.getTemporaryVariableName(); //BufferedReader name
String sbName = ctxt.getTemporaryVariableName(); //StringBuffer name
String tempStringName = ctxt.getTemporaryVariableName();
-
+
//is absolute url
ctxt.generateJavaSource("boolean " + iauName + ";");
-
+
//get the url value
ctxt.generateJavaSource("String " + urlName + " = ");
ctxt.generateAttribute("url");
ctxt.generateJavaSource(";");
-
+
//validate the url
ctxt.generateJavaSource("if(" + urlName + " == null || " + urlName + ".equals(\"\")){");
ctxt.generateJavaSource(" throw new JspTagException(\"The \\\"url\\\" attribute " +
- "illegally evaluated to \\\"null\\\" or \\\"\\\" in <import>\");");
+ "illegally evaluated to \\\"null\\\" or \\\"\\\" in <import>\");");
ctxt.generateJavaSource("}");
-
+
//initialize the is_absolute_url
ctxt.generateJavaSource(iauName + " = " +
"org.apache.struts2.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + urlName + ");");
-
+
//validate the context
- if(hasContext){
-
+ if (hasContext) {
+
ctxt.generateJavaSource("String " + contextName + " = ");
ctxt.generateAttribute("context");
ctxt.generateJavaSource(";");
-
+
ctxt.generateJavaSource("if((!" + contextName + ".startsWith(\"/\")) " +
"|| (!" + urlName + ".startsWith(\"/\"))){");
ctxt.generateJavaSource(" throw new JspTagException" +
"(\"In URL tags, when the \\\"context\\\" attribute is specified, " +
- "values of both \\\"context\\\" and \\\"url\\\" must start with \\\"/\\\".\");");
+ "values of both \\\"context\\\" and \\\"url\\\" must start with \\\"/\\\".\");");
ctxt.generateJavaSource("}");
-
+
}
-
+
//define charset
ctxt.generateJavaSource("String " + charSetName + " = null;");
-
+
//if the charEncoding attribute is specified
- if(hasCharEncoding){
-
+ if (hasCharEncoding) {
+
//initialize the charEncoding
ctxt.generateJavaSource("String " + charEncodingName + " = ");
ctxt.generateAttribute("charEncoding");
ctxt.generateJavaSource(";");
-
+
//assign appropriate value tp the charset
ctxt.generateJavaSource("if(null != " + charEncodingName + " " +
"&& !" + charEncodingName + ".equals(\"\")){");
- ctxt.generateJavaSource(" " + charSetName + " = "
+ ctxt.generateJavaSource(" " + charSetName + " = "
+ charEncodingName + ";");
ctxt.generateJavaSource("}");
}
-
+
//reshape the url string
- ctxt.generateJavaSource("if(!"+iauName+"){");
+ ctxt.generateJavaSource("if(!" + iauName + "){");
ctxt.generateJavaSource(" if(!" + urlName + ".startsWith(\"/\")){");
ctxt.generateJavaSource(" String " + servletPathName + " = " +
- "((HttpServletRequest)pageContext.getRequest()).getServletPath();");
- ctxt.generateJavaSource(" " + urlName + " = "
+ "((HttpServletRequest)pageContext.getRequest()).getServletPath();");
+ ctxt.generateJavaSource(" " + urlName + " = "
+ servletPathName + ".substring(0," + servletPathName + ".lastIndexOf('/')) + '/' + " + urlName + ";");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource("}");
-
+
//if the varReader attribute specified
- if(hasVarReader){
-
+ if (hasVarReader) {
+
//get the String value of varReader
ctxt.generateJavaSource("String " + varReaderName + " = ");
ctxt.generateAttribute("varReader");
ctxt.generateJavaSource(";");
-
+
//if the url is absolute url
ctxt.generateJavaSource("if(" + iauName + "){");
-
+
//get the content of the target
ctxt.generateJavaSource(" java.net.URL " + urlObjName + " = new java.net.URL(" + urlName + ");");
- ctxt.generateJavaSource(" java.net.URLConnection " + ucName + " = "
+ ctxt.generateJavaSource(" java.net.URLConnection " + ucName + " = "
+ urlObjName + ".openConnection();");
- ctxt.generateJavaSource(" java.io.InputStream " + inputStreamName + " = "
+ ctxt.generateJavaSource(" java.io.InputStream " + inputStreamName + " = "
+ ucName + ".getInputStream();");
-
+
ctxt.generateJavaSource(" if(" + charSetName + " == null){");
- ctxt.generateJavaSource(" String " + contentTypeName + " = "
+ ctxt.generateJavaSource(" String " + contentTypeName + " = "
+ ucName + ".getContentType();");
ctxt.generateJavaSource(" if(null != " + contentTypeName + "){");
ctxt.generateJavaSource(" " + charSetName + " = " +
"org.apache.struts2.jasper.tagplugins.jstl.Util.getContentTypeAttribute(" + contentTypeName + ", \"charset\");");
- ctxt.generateJavaSource(" if(" + charSetName + " == null) "
+ ctxt.generateJavaSource(" if(" + charSetName + " == null) "
+ charSetName + " = org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
ctxt.generateJavaSource(" }else{");
ctxt.generateJavaSource(" " + charSetName + " = org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" }");
-
- if(!hasCharEncoding){
+
+ if (!hasCharEncoding) {
ctxt.generateJavaSource(" String " + contentTypeName + " = " + ucName + ".getContentType();");
}
-
+
//define the Reader
ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = null;");
-
+
//initialize the Reader object
ctxt.generateJavaSource(" try{");
ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + ", " + charSetName + ");");
ctxt.generateJavaSource(" }catch(Exception ex){");
ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + ", org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING);");
ctxt.generateJavaSource(" }");
-
+
//validate the response
ctxt.generateJavaSource(" if(" + ucName + " instanceof java.net.HttpURLConnection){");
ctxt.generateJavaSource(" int status = ((java.net.HttpURLConnection) " + ucName + ").getResponseCode();");
@@ -170,44 +170,44 @@
ctxt.generateJavaSource(" throw new JspTagException(status + \" \" + " + urlName + ");");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" }");
-
+
//set attribute in the page context scope
ctxt.generateJavaSource(" pageContext.setAttribute(" + varReaderName + ", " + tempReaderName + ");");
-
+
//if the url is relative
ctxt.generateJavaSource("}else{");
-
+
//if the url is relative, http request is needed
ctxt.generateJavaSource(" if (!(pageContext.getRequest() instanceof HttpServletRequest " +
- "&& pageContext.getResponse() instanceof HttpServletResponse)){");
+ "&& pageContext.getResponse() instanceof HttpServletResponse)){");
ctxt.generateJavaSource(" throw new JspTagException(\"Relative <import> from non-HTTP request not allowed\");");
ctxt.generateJavaSource(" }");
-
+
//get the servlet context of the context defined in the context attribute
ctxt.generateJavaSource(" ServletContext " + servletContextName + " = null;");
- if(hasContext){
+ if (hasContext) {
ctxt.generateJavaSource(" if(null != " + contextName + "){");
- ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext().getContext(" + contextName + ");" );
+ ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext().getContext(" + contextName + ");");
ctxt.generateJavaSource(" }else{");
ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();");
ctxt.generateJavaSource(" }");
- }else{
+ } else {
ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();");
}
-
+
//
ctxt.generateJavaSource(" if(" + servletContextName + " == null){");
- if(hasContext){
+ if (hasContext) {
ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for Context: \\\" \"+" + contextName + "+\" \\\" and URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
- }else{
+ } else {
ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
}
ctxt.generateJavaSource(" }");
-
+
//get the request dispatcher
- ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName + ".getRequestDispatcher(org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));");
- ctxt.generateJavaSource(" if(" + requestDispatcherName + " == null) throw new JspTagException(org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));");
-
+ ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName + ".getRequestDispatcher(org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
+ ctxt.generateJavaSource(" if(" + requestDispatcherName + " == null) throw new JspTagException(org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
+
//initialize a ImportResponseWrapper to include the resource
ctxt.generateJavaSource(" org.apache.struts2.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName + " = new org.apache.struts2.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse) pageContext.getResponse());");
ctxt.generateJavaSource(" if(" + charSetName + " == null){");
@@ -227,70 +227,70 @@
ctxt.generateJavaSource(" else");
ctxt.generateJavaSource(" throw new JspException(rc);");
ctxt.generateJavaSource(" }");
-
+
//validate the response status
ctxt.generateJavaSource(" if(" + irwName + ".getStatus() < 200 || " + irwName + ".getStatus() > 299){");
ctxt.generateJavaSource(" throw new JspTagException(" + irwName + ".getStatus()+\" \" + org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
ctxt.generateJavaSource(" }");
-
+
//push in the page context
ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = new java.io.StringReader(" + irwName + ".getString());");
ctxt.generateJavaSource(" pageContext.setAttribute(" + varReaderName + ", " + tempReaderName + ");");
-
+
ctxt.generateJavaSource("}");
-
+
//execute the body action
ctxt.generateBody();
-
+
//close the reader
ctxt.generateJavaSource("java.io.Reader " + tempReaderName2 + " = (java.io.Reader)pageContext.getAttribute(" + varReaderName + ");");
ctxt.generateJavaSource("if(" + tempReaderName2 + " != null) " + tempReaderName2 + ".close();");
ctxt.generateJavaSource("pageContext.removeAttribute(" + varReaderName + ",1);");
}
-
+
//if the varReader is not specified
- else{
-
+ else {
+
ctxt.generateJavaSource("pageContext.setAttribute(\"url_without_param\"," + urlName + ");");
ctxt.generateBody();
ctxt.generateJavaSource(urlName + " = (String)pageContext.getAttribute(\"url_without_param\");");
ctxt.generateJavaSource("pageContext.removeAttribute(\"url_without_param\");");
String strScope = "page";
- if(hasScope){
+ if (hasScope) {
strScope = ctxt.getConstantAttribute("scope");
}
int iScope = Util.getScope(strScope);
-
+
ctxt.generateJavaSource("String " + tempStringName + " = null;");
-
+
ctxt.generateJavaSource("if(" + iauName + "){");
-
+
//get the content of the target
ctxt.generateJavaSource(" java.net.URL " + urlObjName + " = new java.net.URL(" + urlName + ");");
ctxt.generateJavaSource(" java.net.URLConnection " + ucName + " = " + urlObjName + ".openConnection();");
ctxt.generateJavaSource(" java.io.InputStream " + inputStreamName + " = " + ucName + ".getInputStream();");
ctxt.generateJavaSource(" java.io.Reader " + tempReaderName + " = null;");
-
+
ctxt.generateJavaSource(" if(" + charSetName + " == null){");
- ctxt.generateJavaSource(" String " + contentTypeName + " = "
+ ctxt.generateJavaSource(" String " + contentTypeName + " = "
+ ucName + ".getContentType();");
ctxt.generateJavaSource(" if(null != " + contentTypeName + "){");
ctxt.generateJavaSource(" " + charSetName + " = " +
"org.apache.struts2.jasper.tagplugins.jstl.Util.getContentTypeAttribute(" + contentTypeName + ", \"charset\");");
- ctxt.generateJavaSource(" if(" + charSetName + " == null) "
+ ctxt.generateJavaSource(" if(" + charSetName + " == null) "
+ charSetName + " = org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
ctxt.generateJavaSource(" }else{");
ctxt.generateJavaSource(" " + charSetName + " = org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING;");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" }");
-
+
ctxt.generateJavaSource(" try{");
ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + "," + charSetName + ");");
ctxt.generateJavaSource(" }catch(Exception ex){");
//ctxt.generateJavaSource(" throw new JspTagException(ex.toString());");
ctxt.generateJavaSource(" " + tempReaderName + " = new java.io.InputStreamReader(" + inputStreamName + ",org.apache.struts2.jasper.tagplugins.jstl.Util.DEFAULT_ENCODING);");
ctxt.generateJavaSource(" }");
-
+
//validate the response
ctxt.generateJavaSource(" if(" + ucName + " instanceof java.net.HttpURLConnection){");
ctxt.generateJavaSource(" int status = ((java.net.HttpURLConnection) " + ucName + ").getResponseCode();");
@@ -298,47 +298,47 @@
ctxt.generateJavaSource(" throw new JspTagException(status + \" \" + " + urlName + ");");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" }");
-
+
ctxt.generateJavaSource(" java.io.BufferedReader " + brName + " = new java.io.BufferedReader(" + tempReaderName + ");");
ctxt.generateJavaSource(" StringBuffer " + sbName + " = new StringBuffer();");
String index = ctxt.getTemporaryVariableName();
ctxt.generateJavaSource(" int " + index + ";");
- ctxt.generateJavaSource(" while(("+index+" = "+brName+".read()) != -1) "+sbName+".append((char)"+index+");");
- ctxt.generateJavaSource(" " + tempStringName + " = " +sbName + ".toString();");
-
+ ctxt.generateJavaSource(" while((" + index + " = " + brName + ".read()) != -1) " + sbName + ".append((char)" + index + ");");
+ ctxt.generateJavaSource(" " + tempStringName + " = " + sbName + ".toString();");
+
ctxt.generateJavaSource("}else{");
-
+
//if the url is relative, http request is needed.
ctxt.generateJavaSource(" if (!(pageContext.getRequest() instanceof HttpServletRequest " +
- "&& pageContext.getResponse() instanceof HttpServletResponse)){");
+ "&& pageContext.getResponse() instanceof HttpServletResponse)){");
ctxt.generateJavaSource(" throw new JspTagException(\"Relative <import> from non-HTTP request not allowed\");");
ctxt.generateJavaSource(" }");
-
+
//get the servlet context of the context defined in the context attribute
ctxt.generateJavaSource(" ServletContext " + servletContextName + " = null;");
- if(hasContext){
+ if (hasContext) {
ctxt.generateJavaSource(" if(null != " + contextName + "){");
- ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext().getContext(" + contextName + ");" );
+ ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext().getContext(" + contextName + ");");
ctxt.generateJavaSource(" }else{");
ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();");
ctxt.generateJavaSource(" }");
- }else{
+ } else {
ctxt.generateJavaSource(" " + servletContextName + " = pageContext.getServletContext();");
}
-
+
//
ctxt.generateJavaSource(" if(" + servletContextName + " == null){");
- if(hasContext){
+ if (hasContext) {
ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for Context: \\\" \" +" + contextName + "+ \" \\\" and URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
- }else{
+ } else {
ctxt.generateJavaSource(" throw new JspTagException(\"Unable to get RequestDispatcher for URL: \\\" \" +" + urlName + "+ \" \\\". Verify values and/or enable cross context access.\");");
}
ctxt.generateJavaSource(" }");
-
+
//get the request dispatcher
- ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName + ".getRequestDispatcher(org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));");
- ctxt.generateJavaSource(" if(" + requestDispatcherName + " == null) throw new JspTagException(org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession("+urlName+"));");
-
+ ctxt.generateJavaSource(" RequestDispatcher " + requestDispatcherName + " = " + servletContextName + ".getRequestDispatcher(org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
+ ctxt.generateJavaSource(" if(" + requestDispatcherName + " == null) throw new JspTagException(org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
+
//initialize a ImportResponseWrapper to include the resource
ctxt.generateJavaSource(" org.apache.struts2.jasper.tagplugins.jstl.Util.ImportResponseWrapper " + irwName + " = new org.apache.struts2.jasper.tagplugins.jstl.Util.ImportResponseWrapper((HttpServletResponse) pageContext.getResponse());");
ctxt.generateJavaSource(" if(" + charSetName + " == null){");
@@ -358,25 +358,24 @@
ctxt.generateJavaSource(" else");
ctxt.generateJavaSource(" throw new JspException(rc);");
ctxt.generateJavaSource(" }");
-
+
//validate the response status
ctxt.generateJavaSource(" if(" + irwName + ".getStatus() < 200 || " + irwName + ".getStatus() > 299){");
ctxt.generateJavaSource(" throw new JspTagException(" + irwName + ".getStatus()+\" \" + org.apache.struts2.jasper.tagplugins.jstl.Util.stripSession(" + urlName + "));");
ctxt.generateJavaSource(" }");
-
+
ctxt.generateJavaSource(" " + tempStringName + " = " + irwName + ".getString();");
-
+
ctxt.generateJavaSource("}");
-
- if(hasVar){
+
+ if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
- ctxt.generateJavaSource("pageContext.setAttribute(\""+strVar+"\"," + tempStringName + "," + iScope + ");");
- }else{
+ ctxt.generateJavaSource("pageContext.setAttribute(\"" + strVar + "\"," + tempStringName + "," + iScope + ");");
+ } else {
ctxt.generateJavaSource("pageContext.getOut().print(" + tempStringName + ");");
}
}
}
-
-
-
+
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Otherwise.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Otherwise.java
index 0d51e08..acf133e 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Otherwise.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Otherwise.java
@@ -22,9 +22,9 @@
import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
public final class Otherwise implements TagPlugin {
-
+
public void doTag(TagPluginContext ctxt) {
-
+
// See When.java for the reason whey "}" is need at the beginng and
// not at the end.
ctxt.generateJavaSource("} else {");
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Out.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Out.java
index 96e8259..4fe4429 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Out.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Out.java
@@ -23,21 +23,21 @@
public final class Out implements TagPlugin {
-
+
public void doTag(TagPluginContext ctxt) {
-
+
//these two data member are to indicate
//whether the corresponding attribute is specified
- boolean hasDefault=false, hasEscapeXml=false;
+ boolean hasDefault = false, hasEscapeXml = false;
hasDefault = ctxt.isAttributeSpecified("default");
hasEscapeXml = ctxt.isAttributeSpecified("escapeXml");
-
+
//strValName, strEscapeXmlName & strDefName are two variables' name
//standing for value, escapeXml and default attribute
String strValName = ctxt.getTemporaryVariableName();
String strDefName = ctxt.getTemporaryVariableName();
String strEscapeXmlName = ctxt.getTemporaryVariableName();
-
+
//according to the tag file, the value attribute is mandatory.
ctxt.generateJavaSource("String " + strValName + " = null;");
ctxt.generateJavaSource("if(");
@@ -47,11 +47,11 @@
ctxt.generateAttribute("value");
ctxt.generateJavaSource(").toString();");
ctxt.generateJavaSource("}");
-
+
//initiate the strDefName with null.
//if the default has been specified, then assign the value to it;
ctxt.generateJavaSource("String " + strDefName + " = null;\n");
- if(hasDefault){
+ if (hasDefault) {
ctxt.generateJavaSource("if(");
ctxt.generateAttribute("default");
ctxt.generateJavaSource(" != null){");
@@ -60,18 +60,18 @@
ctxt.generateJavaSource(").toString();");
ctxt.generateJavaSource("}");
}
-
+
//initiate the strEscapeXmlName with true;
//if the escapeXml is specified, assign the value to it;
ctxt.generateJavaSource("boolean " + strEscapeXmlName + " = true;");
- if(hasEscapeXml){
+ if (hasEscapeXml) {
ctxt.generateJavaSource(strEscapeXmlName + " = Boolean.parseBoolean((");
ctxt.generateAttribute("default");
ctxt.generateJavaSource(").toString());");
}
-
+
//main part.
- ctxt.generateJavaSource("if(null != " + strValName +"){");
+ ctxt.generateJavaSource("if(null != " + strValName + "){");
ctxt.generateJavaSource(" if(" + strEscapeXmlName + "){");
ctxt.generateJavaSource(" " + strValName + " = org.apache.struts2.jasper.tagplugins.jstl.Util.escapeXml(" + strValName + ");");
ctxt.generateJavaSource(" }");
@@ -85,6 +85,6 @@
ctxt.generateJavaSource(" }else{");
ctxt.generateBody();
ctxt.generateJavaSource(" }");
- ctxt.generateJavaSource("}");
+ ctxt.generateJavaSource("}");
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Param.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Param.java
index 8cccd30..a7abc08 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Param.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Param.java
@@ -22,35 +22,35 @@
import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
public class Param implements TagPlugin {
-
+
public void doTag(TagPluginContext ctxt) {
-
+
//don't support the body content
-
+
//define names of all the temp variables
String nameName = ctxt.getTemporaryVariableName();
String valueName = ctxt.getTemporaryVariableName();
String urlName = ctxt.getTemporaryVariableName();
String encName = ctxt.getTemporaryVariableName();
String index = ctxt.getTemporaryVariableName();
-
+
//if the param tag has no parents, throw a exception
TagPluginContext parent = ctxt.getParentContext();
- if(parent == null){
+ if (parent == null) {
ctxt.generateJavaSource(" throw new JspTagExcption" +
- "(\"<param> outside <import> or <urlEncode>\");");
+ "(\"<param> outside <import> or <urlEncode>\");");
return;
}
-
+
//get the url string before adding this param
ctxt.generateJavaSource("String " + urlName + " = " +
- "(String)pageContext.getAttribute(\"url_without_param\");");
-
+ "(String)pageContext.getAttribute(\"url_without_param\");");
+
//get the value of "name"
ctxt.generateJavaSource("String " + nameName + " = ");
ctxt.generateAttribute("name");
ctxt.generateJavaSource(";");
-
+
//if the "name" is null then do nothing.
//else add such string "name=value" to the url.
//and the url should be encoded
@@ -72,6 +72,6 @@
ctxt.generateJavaSource(" " + urlName + " = " + urlName + " + \"&\" + " + nameName + " + \"=\" + " + valueName + ";");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" pageContext.setAttribute(\"url_without_param\"," + urlName + ");");
- ctxt.generateJavaSource("}");
+ ctxt.generateJavaSource("}");
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Redirect.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Redirect.java
index c9f9c30..24084c4 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Redirect.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Redirect.java
@@ -22,56 +22,56 @@
import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
public class Redirect implements TagPlugin {
-
+
public void doTag(TagPluginContext ctxt) {
-
+
//flag for the existence of the "context"
boolean hasContext = ctxt.isAttributeSpecified("context");
-
+
//names of the temp variables
String urlName = ctxt.getTemporaryVariableName();
String contextName = ctxt.getTemporaryVariableName();
String baseUrlName = ctxt.getTemporaryVariableName();
String resultName = ctxt.getTemporaryVariableName();
String responseName = ctxt.getTemporaryVariableName();
-
+
//get context
ctxt.generateJavaSource("String " + contextName + " = null;");
- if(hasContext){
+ if (hasContext) {
ctxt.generateJavaSource(contextName + " = ");
ctxt.generateAttribute("context");
ctxt.generateJavaSource(";");
}
-
+
//get the url
ctxt.generateJavaSource("String " + urlName + " = ");
ctxt.generateAttribute("url");
ctxt.generateJavaSource(";");
-
+
//get the raw url according to "url" and "context"
ctxt.generateJavaSource("String " + baseUrlName + " = " +
"org.apache.struts2.jasper.tagplugins.jstl.Util.resolveUrl(" + urlName + ", " + contextName + ", pageContext);");
ctxt.generateJavaSource("pageContext.setAttribute" +
"(\"url_without_param\", " + baseUrlName + ");");
-
+
//add params
ctxt.generateBody();
-
+
ctxt.generateJavaSource("String " + resultName + " = " +
- "(String)pageContext.getAttribute(\"url_without_param\");");
+ "(String)pageContext.getAttribute(\"url_without_param\");");
ctxt.generateJavaSource("pageContext.removeAttribute" +
- "(\"url_without_param\");");
-
+ "(\"url_without_param\");");
+
//get the response object
ctxt.generateJavaSource("HttpServletResponse " + responseName + " = " +
- "((HttpServletResponse) pageContext.getResponse());");
-
+ "((HttpServletResponse) pageContext.getResponse());");
+
//if the url is relative, encode it
ctxt.generateJavaSource("if(!org.apache.struts2.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + resultName + ")){");
ctxt.generateJavaSource(" " + resultName + " = "
+ responseName + ".encodeRedirectURL(" + resultName + ");");
ctxt.generateJavaSource("}");
-
+
//do redirect
ctxt.generateJavaSource("try{");
ctxt.generateJavaSource(" " + responseName + ".sendRedirect(" + resultName + ");");
@@ -79,5 +79,5 @@
ctxt.generateJavaSource(" throw new JspTagException(ex.toString(), ex);");
ctxt.generateJavaSource("}");
}
-
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Remove.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Remove.java
index d40a0a7..f0cdec1 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Remove.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Remove.java
@@ -23,23 +23,23 @@
import org.apache.struts2.jasper.tagplugins.jstl.Util;
public class Remove implements TagPlugin {
-
+
public void doTag(TagPluginContext ctxt) {
-
+
//scope flag
boolean hasScope = ctxt.isAttributeSpecified("scope");
-
+
//the value of the "var"
String strVar = ctxt.getConstantAttribute("var");
-
+
//remove attribute from certain scope.
//default scope is "page".
- if(hasScope){
+ if (hasScope) {
int iScope = Util.getScope(ctxt.getConstantAttribute("scope"));
ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\"," + iScope + ");");
- }else{
+ } else {
ctxt.generateJavaSource("pageContext.removeAttribute(\"" + strVar + "\");");
}
}
-
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Set.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Set.java
index 980692f..2fe756b 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Set.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Set.java
@@ -23,72 +23,72 @@
import org.apache.struts2.jasper.tagplugins.jstl.Util;
public class Set implements TagPlugin {
-
+
public void doTag(TagPluginContext ctxt) {
-
+
//the flags to indicate whether the attributes have been specified
- boolean hasValue = false, hasVar = false, hasScope = false,
- hasTarget = false;
-
+ boolean hasValue = false, hasVar = false, hasScope = false,
+ hasTarget = false;
+
//the scope name
String strScope;
//the id of the scope
int iScope;
-
+
//initialize the flags
hasValue = ctxt.isAttributeSpecified("value");
hasVar = ctxt.isAttributeSpecified("var");
hasScope = ctxt.isAttributeSpecified("scope");
hasTarget = ctxt.isAttributeSpecified("target");
-
+
//the temp variables name
String resultName = ctxt.getTemporaryVariableName();
String targetName = ctxt.getTemporaryVariableName();
String propertyName = ctxt.getTemporaryVariableName();
-
+
//initialize the "result" which will be assigned to the var or target.property
ctxt.generateJavaSource("Object " + resultName + " = null;");
- if(hasValue){
+ if (hasValue) {
ctxt.generateJavaSource(resultName + " = ");
ctxt.generateAttribute("value");
ctxt.generateJavaSource(";");
- }else{
+ } else {
ctxt.dontUseTagPlugin();
return;
}
-
+
//initialize the strScope
- if(hasScope){
+ if (hasScope) {
strScope = ctxt.getConstantAttribute("scope");
- }else{
+ } else {
strScope = "page";
}
-
+
//get the iScope according to the strScope
iScope = Util.getScope(strScope);
-
+
//if the attribute var has been specified then assign the result to the var;
- if(hasVar){
+ if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
ctxt.generateJavaSource("if(null != " + resultName + "){");
ctxt.generateJavaSource(" pageContext.setAttribute(\"" + strVar + "\"," + resultName + "," + iScope + ");");
ctxt.generateJavaSource("} else {");
- if(hasScope){
+ if (hasScope) {
ctxt.generateJavaSource(" pageContext.removeAttribute(\"" + strVar + "\"," + iScope + ");");
- }else{
+ } else {
ctxt.generateJavaSource(" pageContext.removeAttribute(\"" + strVar + "\");");
}
ctxt.generateJavaSource("}");
-
+
//else assign the result to the target.property
- }else if(hasTarget){
-
+ } else if (hasTarget) {
+
//generate the temp variable name
String pdName = ctxt.getTemporaryVariableName();
String successFlagName = ctxt.getTemporaryVariableName();
String index = ctxt.getTemporaryVariableName();
String methodName = ctxt.getTemporaryVariableName();
-
+
//initialize the property
ctxt.generateJavaSource("String " + propertyName + " = null;");
ctxt.generateJavaSource("if(");
@@ -98,15 +98,15 @@
ctxt.generateAttribute("property");
ctxt.generateJavaSource(").toString();");
ctxt.generateJavaSource("}");
-
+
//initialize the target
ctxt.generateJavaSource("Object " + targetName + " = ");
ctxt.generateAttribute("target");
ctxt.generateJavaSource(";");
-
+
//the target is ok
ctxt.generateJavaSource("if(" + targetName + " != null){");
-
+
//if the target is a map, then put the result into the map with the key property
ctxt.generateJavaSource(" if(" + targetName + " instanceof java.util.Map){");
ctxt.generateJavaSource(" if(null != " + resultName + "){");
@@ -114,27 +114,27 @@
ctxt.generateJavaSource(" }else{");
ctxt.generateJavaSource(" ((java.util.Map) " + targetName + ").remove(" + propertyName + ");");
ctxt.generateJavaSource(" }");
-
+
//else assign the result to the target.property
ctxt.generateJavaSource(" }else{");
ctxt.generateJavaSource(" try{");
-
+
//get all the property of the target
ctxt.generateJavaSource(" java.beans.PropertyDescriptor " + pdName + "[] = java.beans.Introspector.getBeanInfo(" + targetName + ".getClass()).getPropertyDescriptors();");
-
+
//the success flag is to imply whether the assign is successful
ctxt.generateJavaSource(" boolean " + successFlagName + " = false;");
-
+
//find the right property
ctxt.generateJavaSource(" for(int " + index + "=0;" + index + "<" + pdName + ".length;" + index + "++){");
ctxt.generateJavaSource(" if(" + pdName + "[" + index + "].getName().equals(" + propertyName + ")){");
-
+
//get the "set" method;
ctxt.generateJavaSource(" java.lang.reflect.Method " + methodName + " = " + pdName + "[" + index + "].getWriteMethod();");
ctxt.generateJavaSource(" if(null == " + methodName + "){");
ctxt.generateJavaSource(" throw new JspException(\"No setter method in <set> for property \"+" + propertyName + ");");
ctxt.generateJavaSource(" }");
-
+
//invoke the method through the reflection
ctxt.generateJavaSource(" if(" + resultName + " != null){");
ctxt.generateJavaSource(" " + methodName + ".invoke(" + targetName + ", new Object[]{(" + methodName + ".getParameterTypes()[0]).cast(" + resultName + ")});");
@@ -148,7 +148,7 @@
ctxt.generateJavaSource(" throw new JspException(\"Invalid property in <set>:\"+" + propertyName + ");");
ctxt.generateJavaSource(" }");
ctxt.generateJavaSource(" }");
-
+
//catch the el exception and throw it as a JspException
ctxt.generateJavaSource(" catch (IllegalAccessException ex) {");
ctxt.generateJavaSource(" throw new JspException(ex);");
@@ -163,5 +163,5 @@
ctxt.generateJavaSource("}");
}
}
-
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Url.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Url.java
index f50fa49..5bc5efa 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Url.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/Url.java
@@ -23,73 +23,73 @@
import org.apache.struts2.jasper.tagplugins.jstl.Util;
public class Url implements TagPlugin {
-
+
public void doTag(TagPluginContext ctxt) {
-
+
//flags
boolean hasVar, hasContext, hasScope;
-
+
//init flags
hasVar = ctxt.isAttributeSpecified("var");
hasContext = ctxt.isAttributeSpecified("context");
hasScope = ctxt.isAttributeSpecified("scope");
-
+
//define name of the temp variables
String valueName = ctxt.getTemporaryVariableName();
String contextName = ctxt.getTemporaryVariableName();
String baseUrlName = ctxt.getTemporaryVariableName();
String resultName = ctxt.getTemporaryVariableName();
String responseName = ctxt.getTemporaryVariableName();
-
+
//get the scope
String strScope = "page";
- if(hasScope){
+ if (hasScope) {
strScope = ctxt.getConstantAttribute("scope");
}
int iScope = Util.getScope(strScope);
-
+
//get the value
ctxt.generateJavaSource("String " + valueName + " = ");
ctxt.generateAttribute("value");
ctxt.generateJavaSource(";");
-
+
//get the context
ctxt.generateJavaSource("String " + contextName + " = null;");
- if(hasContext){
+ if (hasContext) {
ctxt.generateJavaSource(contextName + " = ");
ctxt.generateAttribute("context");
ctxt.generateJavaSource(";");
}
-
+
//get the raw url
ctxt.generateJavaSource("String " + baseUrlName + " = " +
"org.apache.struts2.jasper.tagplugins.jstl.Util.resolveUrl(" + valueName + ", " + contextName + ", pageContext);");
ctxt.generateJavaSource("pageContext.setAttribute" +
"(\"url_without_param\", " + baseUrlName + ");");
-
+
//add params
ctxt.generateBody();
-
+
ctxt.generateJavaSource("String " + resultName + " = " +
- "(String)pageContext.getAttribute(\"url_without_param\");");
+ "(String)pageContext.getAttribute(\"url_without_param\");");
ctxt.generateJavaSource("pageContext.removeAttribute(\"url_without_param\");");
-
+
//if the url is relative, encode it
ctxt.generateJavaSource("if(!org.apache.struts2.jasper.tagplugins.jstl.Util.isAbsoluteUrl(" + resultName + ")){");
ctxt.generateJavaSource(" HttpServletResponse " + responseName + " = " +
- "((HttpServletResponse) pageContext.getResponse());");
+ "((HttpServletResponse) pageContext.getResponse());");
ctxt.generateJavaSource(" " + resultName + " = "
+ responseName + ".encodeURL(" + resultName + ");");
ctxt.generateJavaSource("}");
-
+
//if "var" is specified, the url string store in the attribute var defines
- if(hasVar){
+ if (hasVar) {
String strVar = ctxt.getConstantAttribute("var");
ctxt.generateJavaSource("pageContext.setAttribute" +
"(\"" + strVar + "\", " + resultName + ", " + iScope + ");");
-
+
//if var is not specified, just print out the url string
- }else{
+ } else {
ctxt.generateJavaSource("try{");
ctxt.generateJavaSource(" pageContext.getOut().print(" + resultName + ");");
ctxt.generateJavaSource("}catch(java.io.IOException ex){");
@@ -97,5 +97,5 @@
ctxt.generateJavaSource("}");
}
}
-
+
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/When.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/When.java
index d53703d..da60425 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/When.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/core/When.java
@@ -22,7 +22,7 @@
import org.apache.struts2.jasper.compiler.tagplugin.TagPluginContext;
public final class When implements TagPlugin {
-
+
public void doTag(TagPluginContext ctxt) {
// Get the parent context to determine if this is the first <c:when>
TagPluginContext parentContext = ctxt.getParentContext();
@@ -30,19 +30,18 @@
ctxt.dontUseTagPlugin();
return;
}
-
+
if ("true".equals(parentContext.getPluginAttribute("hasBeenHere"))) {
ctxt.generateJavaSource("} else if(");
// See comment below for the reason we generate the extra "}" here.
- }
- else {
+ } else {
ctxt.generateJavaSource("if(");
parentContext.setPluginAttribute("hasBeenHere", "true");
}
ctxt.generateAttribute("test");
ctxt.generateJavaSource("){");
ctxt.generateBody();
-
+
// We don't generate the closing "}" for the "if" here because there
// may be whitespaces in between <c:when>'s. Instead we delay
// generating it until the next <c:when> or <c:otherwise> or
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/tagPlugins.xml b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/tagPlugins.xml
index 0651aed..8729c47 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/tagPlugins.xml
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/tagplugins/jstl/tagPlugins.xml
@@ -16,48 +16,48 @@
limitations under the License.
-->
<tag-plugins>
- <tag-plugin>
- <tag-class>org.apache.taglibs.standard.tag.rt.core.IfTag</tag-class>
- <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.If</plugin-class>
- </tag-plugin>
- <tag-plugin>
- <tag-class>org.apache.taglibs.standard.tag.common.core.ChooseTag</tag-class>
- <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Choose</plugin-class>
- </tag-plugin>
- <tag-plugin>
- <tag-class>org.apache.taglibs.standard.tag.rt.core.WhenTag</tag-class>
- <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.When</plugin-class>
- </tag-plugin>
- <tag-plugin>
- <tag-class>org.apache.taglibs.standard.tag.common.core.OtherwiseTag</tag-class>
- <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Otherwise</plugin-class>
- </tag-plugin>
- <tag-plugin>
- <tag-class>org.apache.taglibs.standard.tag.rt.core.ForEachTag</tag-class>
- <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.ForEach</plugin-class>
- </tag-plugin>
- <tag-plugin>
- <tag-class>org.apache.taglibs.standard.tag.rt.core.OutTag</tag-class>
- <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Out</plugin-class>
- </tag-plugin>
- <tag-plugin>
- <tag-class>org.apache.taglibs.standard.tag.rt.core.SetTag</tag-class>
- <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Set</plugin-class>
- </tag-plugin>
- <tag-plugin>
- <tag-class>org.apache.taglibs.standard.tag.common.core.RemoveTag</tag-class>
- <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Remove</plugin-class>
- </tag-plugin>
- <tag-plugin>
- <tag-class>org.apache.taglibs.standard.tag.common.core.CatchTag</tag-class>
- <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Catch</plugin-class>
- </tag-plugin>
- <tag-plugin>
- <tag-class>org.apache.taglibs.standard.tag.rt.core.ForTokensTag</tag-class>
- <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.ForTokens</plugin-class>
- </tag-plugin>
- <tag-plugin>
- <tag-class>org.apache.taglibs.standard.tag.rt.core.ImportTag</tag-class>
- <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Import</plugin-class>
- </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.IfTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.If</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.common.core.ChooseTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Choose</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.WhenTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.When</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.common.core.OtherwiseTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Otherwise</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.ForEachTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.ForEach</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.OutTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Out</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.SetTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Set</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.common.core.RemoveTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Remove</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.common.core.CatchTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Catch</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.ForTokensTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.ForTokens</plugin-class>
+ </tag-plugin>
+ <tag-plugin>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.ImportTag</tag-class>
+ <plugin-class>org.apache.struts2.jasper.tagplugins.jstl.core.Import</plugin-class>
+ </tag-plugin>
</tag-plugins>
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/FastDateFormat.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/FastDateFormat.java
index 27b9c4b..7398470 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/FastDateFormat.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/FastDateFormat.java
@@ -39,13 +39,13 @@
private long lastSec = -1;
private StringBuffer sb = new StringBuffer();
private FieldPosition fp = new FieldPosition(DateFormat.MILLISECOND_FIELD);
-
+
public FastDateFormat(DateFormat df) {
this.df = df;
}
public Date parse(String text, ParsePosition pos) {
- return df.parse(text, pos);
+ return df.parse(text, pos);
}
/**
@@ -54,7 +54,7 @@
* instead if you want a msec field.
*/
public StringBuffer format(Date date, StringBuffer toAppendTo,
- FieldPosition fieldPosition) {
+ FieldPosition fieldPosition) {
long dt = date.getTime();
long ds = dt / 1000;
if (ds != lastSec) {
@@ -62,52 +62,52 @@
df.format(date, sb, fp);
lastSec = ds;
} else {
- // munge current msec into existing string
- int ms = (int)(dt % 1000);
+ // munge current msec into existing string
+ int ms = (int) (dt % 1000);
int pos = fp.getEndIndex();
- int begin = fp.getBeginIndex();
- if (pos > 0) {
- if (pos > begin)
- sb.setCharAt(--pos, Character.forDigit(ms % 10, 10));
- ms /= 10;
- if (pos > begin)
- sb.setCharAt(--pos, Character.forDigit(ms % 10, 10));
- ms /= 10;
- if (pos > begin)
- sb.setCharAt(--pos, Character.forDigit(ms % 10, 10));
- }
+ int begin = fp.getBeginIndex();
+ if (pos > 0) {
+ if (pos > begin)
+ sb.setCharAt(--pos, Character.forDigit(ms % 10, 10));
+ ms /= 10;
+ if (pos > begin)
+ sb.setCharAt(--pos, Character.forDigit(ms % 10, 10));
+ ms /= 10;
+ if (pos > begin)
+ sb.setCharAt(--pos, Character.forDigit(ms % 10, 10));
+ }
}
- toAppendTo.append(sb.toString());
- return toAppendTo;
+ toAppendTo.append(sb.toString());
+ return toAppendTo;
}
public static void main(String[] args) {
- String format = "yyyy-MM-dd HH:mm:ss.SSS";
- if (args.length > 0)
- format = args[0];
+ String format = "yyyy-MM-dd HH:mm:ss.SSS";
+ if (args.length > 0)
+ format = args[0];
SimpleDateFormat sdf = new SimpleDateFormat(format);
FastDateFormat fdf = new FastDateFormat(sdf);
Date d = new Date();
- d.setTime(1);
- System.out.println(fdf.format(d) + "\t" + sdf.format(d));
- d.setTime(20);
- System.out.println(fdf.format(d) + "\t" + sdf.format(d));
- d.setTime(500);
- System.out.println(fdf.format(d) + "\t" + sdf.format(d));
- d.setTime(543);
- System.out.println(fdf.format(d) + "\t" + sdf.format(d));
- d.setTime(999);
- System.out.println(fdf.format(d) + "\t" + sdf.format(d));
- d.setTime(1050);
- System.out.println(fdf.format(d) + "\t" + sdf.format(d));
- d.setTime(2543);
- System.out.println(fdf.format(d) + "\t" + sdf.format(d));
- d.setTime(12345);
- System.out.println(fdf.format(d) + "\t" + sdf.format(d));
- d.setTime(12340);
- System.out.println(fdf.format(d) + "\t" + sdf.format(d));
-
+ d.setTime(1);
+ System.out.println(fdf.format(d) + "\t" + sdf.format(d));
+ d.setTime(20);
+ System.out.println(fdf.format(d) + "\t" + sdf.format(d));
+ d.setTime(500);
+ System.out.println(fdf.format(d) + "\t" + sdf.format(d));
+ d.setTime(543);
+ System.out.println(fdf.format(d) + "\t" + sdf.format(d));
+ d.setTime(999);
+ System.out.println(fdf.format(d) + "\t" + sdf.format(d));
+ d.setTime(1050);
+ System.out.println(fdf.format(d) + "\t" + sdf.format(d));
+ d.setTime(2543);
+ System.out.println(fdf.format(d) + "\t" + sdf.format(d));
+ d.setTime(12345);
+ System.out.println(fdf.format(d) + "\t" + sdf.format(d));
+ d.setTime(12340);
+ System.out.println(fdf.format(d) + "\t" + sdf.format(d));
+
final int reps = 100000;
{
long start = System.currentTimeMillis();
@@ -117,7 +117,7 @@
}
long elap = System.currentTimeMillis() - start;
System.out.println("fast: " + elap + " elapsed");
- System.out.println(fdf.format(d));
+ System.out.println(fdf.format(d));
}
{
long start = System.currentTimeMillis();
@@ -125,9 +125,9 @@
d.setTime(System.currentTimeMillis());
sdf.format(d);
}
- long elap = System.currentTimeMillis() - start;
+ long elap = System.currentTimeMillis() - start;
System.out.println("slow: " + elap + " elapsed");
- System.out.println(sdf.format(d));
+ System.out.println(sdf.format(d));
}
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/Queue.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/Queue.java
index bcc3852..9c40597 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/Queue.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/Queue.java
@@ -29,61 +29,61 @@
public class Queue {
private Vector vector = new Vector();
- /**
+ /**
* Put the object into the queue.
- *
- * @param object the object to be appended to the
- * queue.
+ *
+ * @param object the object to be appended to the
+ * queue.
*/
public synchronized void put(Object object) {
- vector.addElement(object);
- notify();
+ vector.addElement(object);
+ notify();
}
-
+
/**
* Pull the first object out of the queue. Wait if the queue is
* empty.
*/
public synchronized Object pull() {
- while (isEmpty())
- try {
- wait();
- } catch (InterruptedException ex) {
- }
- return get();
+ while (isEmpty())
+ try {
+ wait();
+ } catch (InterruptedException ex) {
+ }
+ return get();
}
/**
* Get the first object out of the queue. Return null if the queue
- * is empty.
+ * is empty.
*/
public synchronized Object get() {
- Object object = peek();
- if (object != null)
- vector.removeElementAt(0);
- return object;
+ Object object = peek();
+ if (object != null)
+ vector.removeElementAt(0);
+ return object;
}
/**
* Peek to see if something is available.
*/
public Object peek() {
- if (isEmpty())
- return null;
- return vector.elementAt(0);
+ if (isEmpty())
+ return null;
+ return vector.elementAt(0);
}
-
+
/**
* Is the queue empty?
*/
public boolean isEmpty() {
- return vector.isEmpty();
+ return vector.isEmpty();
}
/**
* How many elements are there in this queue?
*/
public int size() {
- return vector.size();
+ return vector.size();
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/SimplePool.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/SimplePool.java
index d0df772..3050287 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/SimplePool.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/SimplePool.java
@@ -19,15 +19,15 @@
/**
* Simple object pool. Based on ThreadPool and few other classes
- *
+ * <p/>
* The pool will ignore overflow and return null if empty.
*
* @author Gal Shachor
* @author Costin
*/
-public final class SimplePool {
+public final class SimplePool {
- private static final int DEFAULT_SIZE=16;
+ private static final int DEFAULT_SIZE = 16;
/*
* Where the threads are held.
@@ -35,52 +35,52 @@
private Object pool[];
private int max;
- private int current=-1;
+ private int current = -1;
private Object lock;
-
+
public SimplePool() {
- this.max=DEFAULT_SIZE;
- this.pool=new Object[max];
- this.lock=new Object();
+ this.max = DEFAULT_SIZE;
+ this.pool = new Object[max];
+ this.lock = new Object();
}
-
+
public SimplePool(int max) {
- this.max=max;
- this.pool=new Object[max];
- this.lock=new Object();
+ this.max = max;
+ this.pool = new Object[max];
+ this.lock = new Object();
}
/**
* Adds the given object to the pool, and does nothing if the pool is full
*/
public void put(Object o) {
- synchronized( lock ) {
- if( current < (max-1) ) {
- current += 1;
- pool[current] = o;
+ synchronized (lock) {
+ if (current < (max - 1)) {
+ current += 1;
+ pool[current] = o;
}
- }
+ }
}
/**
* Get an object from the pool, null if the pool is empty.
*/
public Object get() {
- Object item = null;
- synchronized( lock ) {
- if( current >= 0 ) {
- item = pool[current];
- current -= 1;
- }
- }
- return item;
+ Object item = null;
+ synchronized (lock) {
+ if (current >= 0) {
+ item = pool[current];
+ current -= 1;
+ }
+ }
+ return item;
}
/**
* Return the size of the pool
*/
public int getMax() {
- return max;
+ return max;
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/SystemLogHandler.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/SystemLogHandler.java
index 670cbdf..d84846d 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/SystemLogHandler.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/util/SystemLogHandler.java
@@ -23,9 +23,9 @@
/**
- * This helper class may be used to do sophisticated redirection of
+ * This helper class may be used to do sophisticated redirection of
* System.out and System.err.
- *
+ *
* @author Remy Maucherat
*/
public class SystemLogHandler extends PrintStream {
@@ -68,7 +68,7 @@
public PrintStream getWrapped() {
- return wrapped;
+ return wrapped;
}
/**
@@ -85,8 +85,8 @@
* Stop capturing thread's output and return captured data as a String.
*/
public static String unsetThread() {
- ByteArrayOutputStream baos =
- (ByteArrayOutputStream) data.get();
+ ByteArrayOutputStream baos =
+ (ByteArrayOutputStream) data.get();
if (baos == null) {
return null;
}
@@ -135,7 +135,7 @@
}
public void write(byte[] b)
- throws IOException {
+ throws IOException {
findStream().write(b);
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/ASCIIReader.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/ASCIIReader.java
index b7ffa06..3d2597f 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/ASCIIReader.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/ASCIIReader.java
@@ -28,35 +28,40 @@
* byte streams that only contain 7-bit ASCII characters.
*
* @author Andy Clark, IBM
- *
* @version $Id: ASCIIReader.java 466606 2006-10-21 23:07:12Z markt $
*/
public class ASCIIReader
- extends Reader {
+ extends Reader {
//
// Constants
//
- /** Default byte buffer size (2048). */
+ /**
+ * Default byte buffer size (2048).
+ */
public static final int DEFAULT_BUFFER_SIZE = 2048;
//
// Data
//
- /** Input stream. */
+ /**
+ * Input stream.
+ */
protected InputStream fInputStream;
- /** Byte buffer. */
+ /**
+ * Byte buffer.
+ */
protected byte[] fBuffer;
//
// Constructors
//
- /**
- * Constructs an ASCII reader from the specified input stream
+ /**
+ * Constructs an ASCII reader from the specified input stream
* and buffer size.
*
* @param inputStream The input stream.
@@ -74,21 +79,20 @@
/**
* Read a single character. This method will block until a character is
* available, an I/O error occurs, or the end of the stream is reached.
- *
+ * <p/>
* <p> Subclasses that intend to support efficient single-character input
* should override this method.
*
- * @return The character read, as an integer in the range 0 to 127
- * (<tt>0x00-0x7f</tt>), or -1 if the end of the stream has
- * been reached
- *
- * @exception IOException If an I/O error occurs
+ * @return The character read, as an integer in the range 0 to 127
+ * (<tt>0x00-0x7f</tt>), or -1 if the end of the stream has
+ * been reached
+ * @throws IOException If an I/O error occurs
*/
public int read() throws IOException {
int b0 = fInputStream.read();
if (b0 > 0x80) {
throw new IOException(Localizer.getMessage("jsp.error.xml.invalidASCII",
- Integer.toString(b0)));
+ Integer.toString(b0)));
}
return b0;
} // read():int
@@ -98,14 +102,12 @@
* until some input is available, an I/O error occurs, or the end of the
* stream is reached.
*
- * @param ch Destination buffer
- * @param offset Offset at which to start storing characters
- * @param length Maximum number of characters to read
- *
- * @return The number of characters read, or -1 if the end of the
- * stream has been reached
- *
- * @exception IOException If an I/O error occurs
+ * @param ch Destination buffer
+ * @param offset Offset at which to start storing characters
+ * @param length Maximum number of characters to read
+ * @return The number of characters read, or -1 if the end of the
+ * stream has been reached
+ * @throws IOException If an I/O error occurs
*/
public int read(char ch[], int offset, int length) throws IOException {
if (length > fBuffer.length) {
@@ -116,9 +118,9 @@
int b0 = fBuffer[i];
if (b0 > 0x80) {
throw new IOException(Localizer.getMessage("jsp.error.xml.invalidASCII",
- Integer.toString(b0)));
+ Integer.toString(b0)));
}
- ch[offset + i] = (char)b0;
+ ch[offset + i] = (char) b0;
}
return count;
} // read(char[],int,int)
@@ -127,11 +129,9 @@
* Skip characters. This method will block until some characters are
* available, an I/O error occurs, or the end of the stream is reached.
*
- * @param n The number of characters to skip
- *
- * @return The number of characters actually skipped
- *
- * @exception IOException If an I/O error occurs
+ * @param n The number of characters to skip
+ * @return The number of characters actually skipped
+ * @throws IOException If an I/O error occurs
*/
public long skip(long n) throws IOException {
return fInputStream.skip(n);
@@ -141,20 +141,19 @@
* Tell whether this stream is ready to be read.
*
* @return True if the next read() is guaranteed not to block for input,
- * false otherwise. Note that returning false does not guarantee that the
- * next read will block.
- *
- * @exception IOException If an I/O error occurs
+ * false otherwise. Note that returning false does not guarantee that the
+ * next read will block.
+ * @throws IOException If an I/O error occurs
*/
public boolean ready() throws IOException {
- return false;
+ return false;
} // ready()
/**
* Tell whether this stream supports the mark() operation.
*/
public boolean markSupported() {
- return fInputStream.markSupported();
+ return fInputStream.markSupported();
} // markSupported()
/**
@@ -162,16 +161,15 @@
* will attempt to reposition the stream to this point. Not all
* character-input streams support the mark() operation.
*
- * @param readAheadLimit Limit on the number of characters that may be
- * read while still preserving the mark. After
- * reading this many characters, attempting to
- * reset the stream may fail.
- *
- * @exception IOException If the stream does not support mark(),
- * or if some other I/O error occurs
+ * @param readAheadLimit Limit on the number of characters that may be
+ * read while still preserving the mark. After
+ * reading this many characters, attempting to
+ * reset the stream may fail.
+ * @throws IOException If the stream does not support mark(),
+ * or if some other I/O error occurs
*/
public void mark(int readAheadLimit) throws IOException {
- fInputStream.mark(readAheadLimit);
+ fInputStream.mark(readAheadLimit);
} // mark(int)
/**
@@ -182,10 +180,10 @@
* character-input streams support the reset() operation, and some support
* reset() without supporting mark().
*
- * @exception IOException If the stream has not been marked,
- * or if the mark has been invalidated,
- * or if the stream does not support reset(),
- * or if some other I/O error occurs
+ * @throws IOException If the stream has not been marked,
+ * or if the mark has been invalidated,
+ * or if the stream does not support reset(),
+ * or if some other I/O error occurs
*/
public void reset() throws IOException {
fInputStream.reset();
@@ -196,10 +194,10 @@
* ready(), mark(), or reset() invocations will throw an IOException.
* Closing a previously-closed stream, however, has no effect.
*
- * @exception IOException If an I/O error occurs
+ * @throws IOException If an I/O error occurs
*/
- public void close() throws IOException {
- fInputStream.close();
- } // close()
+ public void close() throws IOException {
+ fInputStream.close();
+ } // close()
} // class ASCIIReader
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/EncodingMap.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/EncodingMap.java
index f603386..6a68f52 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/EncodingMap.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/EncodingMap.java
@@ -28,452 +28,451 @@
import java.util.Hashtable;
/**
- * EncodingMap is a convenience class which handles conversions between
+ * EncodingMap is a convenience class which handles conversions between
* IANA encoding names and Java encoding names, and vice versa. The
* encoding names used in XML instance documents <strong>must</strong>
* be the IANA encoding names specified or one of the aliases for those names
* which IANA defines.
- * <p>
+ * <p/>
* <TABLE BORDER="0" WIDTH="100%">
- * <TR>
- * <TD WIDTH="33%">
- * <P ALIGN="CENTER"><B>Common Name</B>
- * </TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER"><B>Use this name in XML files</B>
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER"><B>Name Type</B>
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER"><B>Xerces converts to this Java Encoder Name</B>
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">8 bit Unicode</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">UTF-8
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">UTF8
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">ISO Latin 1</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ISO-8859-1
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">ISO-8859-1
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">ISO Latin 2</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ISO-8859-2
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">ISO-8859-2
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">ISO Latin 3</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ISO-8859-3
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">ISO-8859-3
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">ISO Latin 4</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ISO-8859-4
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">ISO-8859-4
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">ISO Latin Cyrillic</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ISO-8859-5
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">ISO-8859-5
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">ISO Latin Arabic</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ISO-8859-6
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">ISO-8859-6
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">ISO Latin Greek</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ISO-8859-7
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">ISO-8859-7
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">ISO Latin Hebrew</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ISO-8859-8
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">ISO-8859-8
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">ISO Latin 5</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ISO-8859-9
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">ISO-8859-9
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: US</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-us
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp037
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Canada</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-ca
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp037
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Netherlands</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-nl
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp037
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Denmark</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-dk
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp277
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Norway</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-no
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp277
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Finland</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-fi
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp278
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Sweden</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-se
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp278
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Italy</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-it
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp280
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Spain, Latin America</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-es
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp284
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Great Britain</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-gb
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp285
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: France</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-fr
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp297
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Arabic</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-ar1
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp420
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Hebrew</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-he
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp424
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Switzerland</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-ch
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp500
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Roece</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-roece
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp870
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Yugoslavia</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-yu
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp870
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Iceland</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-is
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp871
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">EBCDIC: Urdu</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">ebcdic-cp-ar2
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">IANA
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">cp918
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">Chinese for PRC, mixed 1/2 byte</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">gb2312
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">GB2312
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">Extended Unix Code, packed for Japanese</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">euc-jp
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">eucjis
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">Japanese: iso-2022-jp</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">iso-2020-jp
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">JIS
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">Japanese: Shift JIS</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">Shift_JIS
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">SJIS
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">Chinese: Big5</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">Big5
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">Big5
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">Extended Unix Code, packed for Korean</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">euc-kr
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">iso2022kr
- * </TD>
- * </TR>
- * <TR>
- * <TD WIDTH="33%">Cyrillic</TD>
- * <TD WIDTH="15%">
- * <P ALIGN="CENTER">koi8-r
- * </TD>
- * <TD WIDTH="12%">
- * <P ALIGN="CENTER">MIME
- * </TD>
- * <TD WIDTH="31%">
- * <P ALIGN="CENTER">koi8-r
- * </TD>
- * </TR>
+ * <TR>
+ * <TD WIDTH="33%">
+ * <P ALIGN="CENTER"><B>Common Name</B>
+ * </TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER"><B>Use this name in XML files</B>
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER"><B>Name Type</B>
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER"><B>Xerces converts to this Java Encoder Name</B>
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">8 bit Unicode</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">UTF-8
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">UTF8
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin 1</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-1
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-1
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin 2</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-2
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-2
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin 3</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-3
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-3
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin 4</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-4
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-4
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin Cyrillic</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-5
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-5
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin Arabic</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-6
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-6
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin Greek</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-7
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-7
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin Hebrew</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-8
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-8
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin 5</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-9
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-9
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: US</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-us
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp037
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Canada</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-ca
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp037
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Netherlands</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-nl
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp037
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Denmark</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-dk
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp277
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Norway</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-no
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp277
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Finland</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-fi
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp278
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Sweden</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-se
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp278
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Italy</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-it
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp280
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Spain, Latin America</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-es
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp284
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Great Britain</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-gb
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp285
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: France</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-fr
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp297
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Arabic</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-ar1
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp420
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Hebrew</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-he
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp424
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Switzerland</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-ch
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp500
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Roece</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-roece
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp870
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Yugoslavia</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-yu
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp870
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Iceland</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-is
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp871
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Urdu</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-ar2
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp918
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Chinese for PRC, mixed 1/2 byte</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">gb2312
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">GB2312
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Extended Unix Code, packed for Japanese</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">euc-jp
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">eucjis
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Japanese: iso-2022-jp</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">iso-2020-jp
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">JIS
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Japanese: Shift JIS</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">Shift_JIS
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">SJIS
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Chinese: Big5</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">Big5
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">Big5
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Extended Unix Code, packed for Korean</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">euc-kr
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">iso2022kr
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Cyrillic</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">koi8-r
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">koi8-r
+ * </TD>
+ * </TR>
* </TABLE>
- *
+ *
* @author TAMURA Kent, IBM
* @author Andy Clark, IBM
- *
* @version $Id: EncodingMap.java 466606 2006-10-21 23:07:12Z markt $
*/
public class EncodingMap {
@@ -482,10 +481,14 @@
// Data
//
- /** fIANA2JavaMap */
+ /**
+ * fIANA2JavaMap
+ */
protected final static Hashtable fIANA2JavaMap = new Hashtable();
- /** fJava2IANAMap */
+ /**
+ * fJava2IANAMap
+ */
protected final static Hashtable fJava2IANAMap = new Hashtable();
//
@@ -495,456 +498,456 @@
static {
// add IANA to Java encoding mappings.
- fIANA2JavaMap.put("BIG5", "Big5");
- fIANA2JavaMap.put("CSBIG5", "Big5");
- fIANA2JavaMap.put("CP037", "CP037");
- fIANA2JavaMap.put("IBM037", "CP037");
- fIANA2JavaMap.put("CSIBM037", "CP037");
- fIANA2JavaMap.put("EBCDIC-CP-US", "CP037");
- fIANA2JavaMap.put("EBCDIC-CP-CA", "CP037");
- fIANA2JavaMap.put("EBCDIC-CP-NL", "CP037");
- fIANA2JavaMap.put("EBCDIC-CP-WT", "CP037");
- fIANA2JavaMap.put("IBM273", "CP273");
- fIANA2JavaMap.put("CP273", "CP273");
- fIANA2JavaMap.put("CSIBM273", "CP273");
- fIANA2JavaMap.put("IBM277", "CP277");
- fIANA2JavaMap.put("CP277", "CP277");
- fIANA2JavaMap.put("CSIBM277", "CP277");
- fIANA2JavaMap.put("EBCDIC-CP-DK", "CP277");
- fIANA2JavaMap.put("EBCDIC-CP-NO", "CP277");
- fIANA2JavaMap.put("IBM278", "CP278");
- fIANA2JavaMap.put("CP278", "CP278");
- fIANA2JavaMap.put("CSIBM278", "CP278");
- fIANA2JavaMap.put("EBCDIC-CP-FI", "CP278");
- fIANA2JavaMap.put("EBCDIC-CP-SE", "CP278");
- fIANA2JavaMap.put("IBM280", "CP280");
- fIANA2JavaMap.put("CP280", "CP280");
- fIANA2JavaMap.put("CSIBM280", "CP280");
- fIANA2JavaMap.put("EBCDIC-CP-IT", "CP280");
- fIANA2JavaMap.put("IBM284", "CP284");
- fIANA2JavaMap.put("CP284", "CP284");
- fIANA2JavaMap.put("CSIBM284", "CP284");
- fIANA2JavaMap.put("EBCDIC-CP-ES", "CP284");
- fIANA2JavaMap.put("EBCDIC-CP-GB", "CP285");
- fIANA2JavaMap.put("IBM285", "CP285");
- fIANA2JavaMap.put("CP285", "CP285");
- fIANA2JavaMap.put("CSIBM285", "CP285");
- fIANA2JavaMap.put("EBCDIC-JP-KANA", "CP290");
- fIANA2JavaMap.put("IBM290", "CP290");
- fIANA2JavaMap.put("CP290", "CP290");
- fIANA2JavaMap.put("CSIBM290", "CP290");
- fIANA2JavaMap.put("EBCDIC-CP-FR", "CP297");
- fIANA2JavaMap.put("IBM297", "CP297");
- fIANA2JavaMap.put("CP297", "CP297");
- fIANA2JavaMap.put("CSIBM297", "CP297");
- fIANA2JavaMap.put("EBCDIC-CP-AR1", "CP420");
- fIANA2JavaMap.put("IBM420", "CP420");
- fIANA2JavaMap.put("CP420", "CP420");
- fIANA2JavaMap.put("CSIBM420", "CP420");
- fIANA2JavaMap.put("EBCDIC-CP-HE", "CP424");
- fIANA2JavaMap.put("IBM424", "CP424");
- fIANA2JavaMap.put("CP424", "CP424");
- fIANA2JavaMap.put("CSIBM424", "CP424");
- fIANA2JavaMap.put("IBM437", "CP437");
- fIANA2JavaMap.put("437", "CP437");
- fIANA2JavaMap.put("CP437", "CP437");
- fIANA2JavaMap.put("CSPC8CODEPAGE437", "CP437");
- fIANA2JavaMap.put("EBCDIC-CP-CH", "CP500");
- fIANA2JavaMap.put("IBM500", "CP500");
- fIANA2JavaMap.put("CP500", "CP500");
- fIANA2JavaMap.put("CSIBM500", "CP500");
- fIANA2JavaMap.put("EBCDIC-CP-CH", "CP500");
- fIANA2JavaMap.put("EBCDIC-CP-BE", "CP500");
- fIANA2JavaMap.put("IBM775", "CP775");
- fIANA2JavaMap.put("CP775", "CP775");
- fIANA2JavaMap.put("CSPC775BALTIC", "CP775");
- fIANA2JavaMap.put("IBM850", "CP850");
- fIANA2JavaMap.put("850", "CP850");
- fIANA2JavaMap.put("CP850", "CP850");
- fIANA2JavaMap.put("CSPC850MULTILINGUAL", "CP850");
- fIANA2JavaMap.put("IBM852", "CP852");
- fIANA2JavaMap.put("852", "CP852");
- fIANA2JavaMap.put("CP852", "CP852");
- fIANA2JavaMap.put("CSPCP852", "CP852");
- fIANA2JavaMap.put("IBM855", "CP855");
- fIANA2JavaMap.put("855", "CP855");
- fIANA2JavaMap.put("CP855", "CP855");
- fIANA2JavaMap.put("CSIBM855", "CP855");
- fIANA2JavaMap.put("IBM857", "CP857");
- fIANA2JavaMap.put("857", "CP857");
- fIANA2JavaMap.put("CP857", "CP857");
- fIANA2JavaMap.put("CSIBM857", "CP857");
- fIANA2JavaMap.put("IBM00858", "CP858");
- fIANA2JavaMap.put("CP00858", "CP858");
- fIANA2JavaMap.put("CCSID00858", "CP858");
- fIANA2JavaMap.put("IBM860", "CP860");
- fIANA2JavaMap.put("860", "CP860");
- fIANA2JavaMap.put("CP860", "CP860");
- fIANA2JavaMap.put("CSIBM860", "CP860");
- fIANA2JavaMap.put("IBM861", "CP861");
- fIANA2JavaMap.put("861", "CP861");
- fIANA2JavaMap.put("CP861", "CP861");
- fIANA2JavaMap.put("CP-IS", "CP861");
- fIANA2JavaMap.put("CSIBM861", "CP861");
- fIANA2JavaMap.put("IBM862", "CP862");
- fIANA2JavaMap.put("862", "CP862");
- fIANA2JavaMap.put("CP862", "CP862");
- fIANA2JavaMap.put("CSPC862LATINHEBREW", "CP862");
- fIANA2JavaMap.put("IBM863", "CP863");
- fIANA2JavaMap.put("863", "CP863");
- fIANA2JavaMap.put("CP863", "CP863");
- fIANA2JavaMap.put("CSIBM863", "CP863");
- fIANA2JavaMap.put("IBM864", "CP864");
- fIANA2JavaMap.put("CP864", "CP864");
- fIANA2JavaMap.put("CSIBM864", "CP864");
- fIANA2JavaMap.put("IBM865", "CP865");
- fIANA2JavaMap.put("865", "CP865");
- fIANA2JavaMap.put("CP865", "CP865");
- fIANA2JavaMap.put("CSIBM865", "CP865");
- fIANA2JavaMap.put("IBM866", "CP866");
- fIANA2JavaMap.put("866", "CP866");
- fIANA2JavaMap.put("CP866", "CP866");
- fIANA2JavaMap.put("CSIBM866", "CP866");
- fIANA2JavaMap.put("IBM868", "CP868");
- fIANA2JavaMap.put("CP868", "CP868");
- fIANA2JavaMap.put("CSIBM868", "CP868");
- fIANA2JavaMap.put("CP-AR", "CP868");
- fIANA2JavaMap.put("IBM869", "CP869");
- fIANA2JavaMap.put("CP869", "CP869");
- fIANA2JavaMap.put("CSIBM869", "CP869");
- fIANA2JavaMap.put("CP-GR", "CP869");
- fIANA2JavaMap.put("IBM870", "CP870");
- fIANA2JavaMap.put("CP870", "CP870");
- fIANA2JavaMap.put("CSIBM870", "CP870");
+ fIANA2JavaMap.put("BIG5", "Big5");
+ fIANA2JavaMap.put("CSBIG5", "Big5");
+ fIANA2JavaMap.put("CP037", "CP037");
+ fIANA2JavaMap.put("IBM037", "CP037");
+ fIANA2JavaMap.put("CSIBM037", "CP037");
+ fIANA2JavaMap.put("EBCDIC-CP-US", "CP037");
+ fIANA2JavaMap.put("EBCDIC-CP-CA", "CP037");
+ fIANA2JavaMap.put("EBCDIC-CP-NL", "CP037");
+ fIANA2JavaMap.put("EBCDIC-CP-WT", "CP037");
+ fIANA2JavaMap.put("IBM273", "CP273");
+ fIANA2JavaMap.put("CP273", "CP273");
+ fIANA2JavaMap.put("CSIBM273", "CP273");
+ fIANA2JavaMap.put("IBM277", "CP277");
+ fIANA2JavaMap.put("CP277", "CP277");
+ fIANA2JavaMap.put("CSIBM277", "CP277");
+ fIANA2JavaMap.put("EBCDIC-CP-DK", "CP277");
+ fIANA2JavaMap.put("EBCDIC-CP-NO", "CP277");
+ fIANA2JavaMap.put("IBM278", "CP278");
+ fIANA2JavaMap.put("CP278", "CP278");
+ fIANA2JavaMap.put("CSIBM278", "CP278");
+ fIANA2JavaMap.put("EBCDIC-CP-FI", "CP278");
+ fIANA2JavaMap.put("EBCDIC-CP-SE", "CP278");
+ fIANA2JavaMap.put("IBM280", "CP280");
+ fIANA2JavaMap.put("CP280", "CP280");
+ fIANA2JavaMap.put("CSIBM280", "CP280");
+ fIANA2JavaMap.put("EBCDIC-CP-IT", "CP280");
+ fIANA2JavaMap.put("IBM284", "CP284");
+ fIANA2JavaMap.put("CP284", "CP284");
+ fIANA2JavaMap.put("CSIBM284", "CP284");
+ fIANA2JavaMap.put("EBCDIC-CP-ES", "CP284");
+ fIANA2JavaMap.put("EBCDIC-CP-GB", "CP285");
+ fIANA2JavaMap.put("IBM285", "CP285");
+ fIANA2JavaMap.put("CP285", "CP285");
+ fIANA2JavaMap.put("CSIBM285", "CP285");
+ fIANA2JavaMap.put("EBCDIC-JP-KANA", "CP290");
+ fIANA2JavaMap.put("IBM290", "CP290");
+ fIANA2JavaMap.put("CP290", "CP290");
+ fIANA2JavaMap.put("CSIBM290", "CP290");
+ fIANA2JavaMap.put("EBCDIC-CP-FR", "CP297");
+ fIANA2JavaMap.put("IBM297", "CP297");
+ fIANA2JavaMap.put("CP297", "CP297");
+ fIANA2JavaMap.put("CSIBM297", "CP297");
+ fIANA2JavaMap.put("EBCDIC-CP-AR1", "CP420");
+ fIANA2JavaMap.put("IBM420", "CP420");
+ fIANA2JavaMap.put("CP420", "CP420");
+ fIANA2JavaMap.put("CSIBM420", "CP420");
+ fIANA2JavaMap.put("EBCDIC-CP-HE", "CP424");
+ fIANA2JavaMap.put("IBM424", "CP424");
+ fIANA2JavaMap.put("CP424", "CP424");
+ fIANA2JavaMap.put("CSIBM424", "CP424");
+ fIANA2JavaMap.put("IBM437", "CP437");
+ fIANA2JavaMap.put("437", "CP437");
+ fIANA2JavaMap.put("CP437", "CP437");
+ fIANA2JavaMap.put("CSPC8CODEPAGE437", "CP437");
+ fIANA2JavaMap.put("EBCDIC-CP-CH", "CP500");
+ fIANA2JavaMap.put("IBM500", "CP500");
+ fIANA2JavaMap.put("CP500", "CP500");
+ fIANA2JavaMap.put("CSIBM500", "CP500");
+ fIANA2JavaMap.put("EBCDIC-CP-CH", "CP500");
+ fIANA2JavaMap.put("EBCDIC-CP-BE", "CP500");
+ fIANA2JavaMap.put("IBM775", "CP775");
+ fIANA2JavaMap.put("CP775", "CP775");
+ fIANA2JavaMap.put("CSPC775BALTIC", "CP775");
+ fIANA2JavaMap.put("IBM850", "CP850");
+ fIANA2JavaMap.put("850", "CP850");
+ fIANA2JavaMap.put("CP850", "CP850");
+ fIANA2JavaMap.put("CSPC850MULTILINGUAL", "CP850");
+ fIANA2JavaMap.put("IBM852", "CP852");
+ fIANA2JavaMap.put("852", "CP852");
+ fIANA2JavaMap.put("CP852", "CP852");
+ fIANA2JavaMap.put("CSPCP852", "CP852");
+ fIANA2JavaMap.put("IBM855", "CP855");
+ fIANA2JavaMap.put("855", "CP855");
+ fIANA2JavaMap.put("CP855", "CP855");
+ fIANA2JavaMap.put("CSIBM855", "CP855");
+ fIANA2JavaMap.put("IBM857", "CP857");
+ fIANA2JavaMap.put("857", "CP857");
+ fIANA2JavaMap.put("CP857", "CP857");
+ fIANA2JavaMap.put("CSIBM857", "CP857");
+ fIANA2JavaMap.put("IBM00858", "CP858");
+ fIANA2JavaMap.put("CP00858", "CP858");
+ fIANA2JavaMap.put("CCSID00858", "CP858");
+ fIANA2JavaMap.put("IBM860", "CP860");
+ fIANA2JavaMap.put("860", "CP860");
+ fIANA2JavaMap.put("CP860", "CP860");
+ fIANA2JavaMap.put("CSIBM860", "CP860");
+ fIANA2JavaMap.put("IBM861", "CP861");
+ fIANA2JavaMap.put("861", "CP861");
+ fIANA2JavaMap.put("CP861", "CP861");
+ fIANA2JavaMap.put("CP-IS", "CP861");
+ fIANA2JavaMap.put("CSIBM861", "CP861");
+ fIANA2JavaMap.put("IBM862", "CP862");
+ fIANA2JavaMap.put("862", "CP862");
+ fIANA2JavaMap.put("CP862", "CP862");
+ fIANA2JavaMap.put("CSPC862LATINHEBREW", "CP862");
+ fIANA2JavaMap.put("IBM863", "CP863");
+ fIANA2JavaMap.put("863", "CP863");
+ fIANA2JavaMap.put("CP863", "CP863");
+ fIANA2JavaMap.put("CSIBM863", "CP863");
+ fIANA2JavaMap.put("IBM864", "CP864");
+ fIANA2JavaMap.put("CP864", "CP864");
+ fIANA2JavaMap.put("CSIBM864", "CP864");
+ fIANA2JavaMap.put("IBM865", "CP865");
+ fIANA2JavaMap.put("865", "CP865");
+ fIANA2JavaMap.put("CP865", "CP865");
+ fIANA2JavaMap.put("CSIBM865", "CP865");
+ fIANA2JavaMap.put("IBM866", "CP866");
+ fIANA2JavaMap.put("866", "CP866");
+ fIANA2JavaMap.put("CP866", "CP866");
+ fIANA2JavaMap.put("CSIBM866", "CP866");
+ fIANA2JavaMap.put("IBM868", "CP868");
+ fIANA2JavaMap.put("CP868", "CP868");
+ fIANA2JavaMap.put("CSIBM868", "CP868");
+ fIANA2JavaMap.put("CP-AR", "CP868");
+ fIANA2JavaMap.put("IBM869", "CP869");
+ fIANA2JavaMap.put("CP869", "CP869");
+ fIANA2JavaMap.put("CSIBM869", "CP869");
+ fIANA2JavaMap.put("CP-GR", "CP869");
+ fIANA2JavaMap.put("IBM870", "CP870");
+ fIANA2JavaMap.put("CP870", "CP870");
+ fIANA2JavaMap.put("CSIBM870", "CP870");
fIANA2JavaMap.put("EBCDIC-CP-ROECE", "CP870");
- fIANA2JavaMap.put("EBCDIC-CP-YU", "CP870");
- fIANA2JavaMap.put("IBM871", "CP871");
- fIANA2JavaMap.put("CP871", "CP871");
- fIANA2JavaMap.put("CSIBM871", "CP871");
- fIANA2JavaMap.put("EBCDIC-CP-IS", "CP871");
- fIANA2JavaMap.put("IBM918", "CP918");
- fIANA2JavaMap.put("CP918", "CP918");
- fIANA2JavaMap.put("CSIBM918", "CP918");
- fIANA2JavaMap.put("EBCDIC-CP-AR2", "CP918");
- fIANA2JavaMap.put("IBM00924", "CP924");
- fIANA2JavaMap.put("CP00924", "CP924");
- fIANA2JavaMap.put("CCSID00924", "CP924");
+ fIANA2JavaMap.put("EBCDIC-CP-YU", "CP870");
+ fIANA2JavaMap.put("IBM871", "CP871");
+ fIANA2JavaMap.put("CP871", "CP871");
+ fIANA2JavaMap.put("CSIBM871", "CP871");
+ fIANA2JavaMap.put("EBCDIC-CP-IS", "CP871");
+ fIANA2JavaMap.put("IBM918", "CP918");
+ fIANA2JavaMap.put("CP918", "CP918");
+ fIANA2JavaMap.put("CSIBM918", "CP918");
+ fIANA2JavaMap.put("EBCDIC-CP-AR2", "CP918");
+ fIANA2JavaMap.put("IBM00924", "CP924");
+ fIANA2JavaMap.put("CP00924", "CP924");
+ fIANA2JavaMap.put("CCSID00924", "CP924");
// is this an error???
- fIANA2JavaMap.put("EBCDIC-LATIN9--EURO", "CP924");
- fIANA2JavaMap.put("IBM1026", "CP1026");
- fIANA2JavaMap.put("CP1026", "CP1026");
- fIANA2JavaMap.put("CSIBM1026", "CP1026");
- fIANA2JavaMap.put("IBM01140", "Cp1140");
- fIANA2JavaMap.put("CP01140", "Cp1140");
- fIANA2JavaMap.put("CCSID01140", "Cp1140");
- fIANA2JavaMap.put("IBM01141", "Cp1141");
- fIANA2JavaMap.put("CP01141", "Cp1141");
- fIANA2JavaMap.put("CCSID01141", "Cp1141");
- fIANA2JavaMap.put("IBM01142", "Cp1142");
- fIANA2JavaMap.put("CP01142", "Cp1142");
- fIANA2JavaMap.put("CCSID01142", "Cp1142");
- fIANA2JavaMap.put("IBM01143", "Cp1143");
- fIANA2JavaMap.put("CP01143", "Cp1143");
- fIANA2JavaMap.put("CCSID01143", "Cp1143");
- fIANA2JavaMap.put("IBM01144", "Cp1144");
- fIANA2JavaMap.put("CP01144", "Cp1144");
- fIANA2JavaMap.put("CCSID01144", "Cp1144");
- fIANA2JavaMap.put("IBM01145", "Cp1145");
- fIANA2JavaMap.put("CP01145", "Cp1145");
- fIANA2JavaMap.put("CCSID01145", "Cp1145");
- fIANA2JavaMap.put("IBM01146", "Cp1146");
- fIANA2JavaMap.put("CP01146", "Cp1146");
- fIANA2JavaMap.put("CCSID01146", "Cp1146");
- fIANA2JavaMap.put("IBM01147", "Cp1147");
- fIANA2JavaMap.put("CP01147", "Cp1147");
- fIANA2JavaMap.put("CCSID01147", "Cp1147");
- fIANA2JavaMap.put("IBM01148", "Cp1148");
- fIANA2JavaMap.put("CP01148", "Cp1148");
- fIANA2JavaMap.put("CCSID01148", "Cp1148");
- fIANA2JavaMap.put("IBM01149", "Cp1149");
- fIANA2JavaMap.put("CP01149", "Cp1149");
- fIANA2JavaMap.put("CCSID01149", "Cp1149");
- fIANA2JavaMap.put("EUC-JP", "EUCJIS");
- fIANA2JavaMap.put("CSEUCPKDFMTJAPANESE", "EUCJIS");
- fIANA2JavaMap.put("EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", "EUCJIS");
- fIANA2JavaMap.put("EUC-KR", "KSC5601");
- fIANA2JavaMap.put("CSEUCKR", "KSC5601");
- fIANA2JavaMap.put("KS_C_5601-1987", "KS_C_5601-1987");
- fIANA2JavaMap.put("ISO-IR-149", "KS_C_5601-1987");
- fIANA2JavaMap.put("KS_C_5601-1989", "KS_C_5601-1987");
- fIANA2JavaMap.put("KSC_5601", "KS_C_5601-1987");
- fIANA2JavaMap.put("KOREAN", "KS_C_5601-1987");
- fIANA2JavaMap.put("CSKSC56011987", "KS_C_5601-1987");
- fIANA2JavaMap.put("GB2312", "GB2312");
- fIANA2JavaMap.put("CSGB2312", "GB2312");
- fIANA2JavaMap.put("ISO-2022-JP", "JIS");
- fIANA2JavaMap.put("CSISO2022JP", "JIS");
- fIANA2JavaMap.put("ISO-2022-KR", "ISO2022KR");
- fIANA2JavaMap.put("CSISO2022KR", "ISO2022KR");
- fIANA2JavaMap.put("ISO-2022-CN", "ISO2022CN");
+ fIANA2JavaMap.put("EBCDIC-LATIN9--EURO", "CP924");
+ fIANA2JavaMap.put("IBM1026", "CP1026");
+ fIANA2JavaMap.put("CP1026", "CP1026");
+ fIANA2JavaMap.put("CSIBM1026", "CP1026");
+ fIANA2JavaMap.put("IBM01140", "Cp1140");
+ fIANA2JavaMap.put("CP01140", "Cp1140");
+ fIANA2JavaMap.put("CCSID01140", "Cp1140");
+ fIANA2JavaMap.put("IBM01141", "Cp1141");
+ fIANA2JavaMap.put("CP01141", "Cp1141");
+ fIANA2JavaMap.put("CCSID01141", "Cp1141");
+ fIANA2JavaMap.put("IBM01142", "Cp1142");
+ fIANA2JavaMap.put("CP01142", "Cp1142");
+ fIANA2JavaMap.put("CCSID01142", "Cp1142");
+ fIANA2JavaMap.put("IBM01143", "Cp1143");
+ fIANA2JavaMap.put("CP01143", "Cp1143");
+ fIANA2JavaMap.put("CCSID01143", "Cp1143");
+ fIANA2JavaMap.put("IBM01144", "Cp1144");
+ fIANA2JavaMap.put("CP01144", "Cp1144");
+ fIANA2JavaMap.put("CCSID01144", "Cp1144");
+ fIANA2JavaMap.put("IBM01145", "Cp1145");
+ fIANA2JavaMap.put("CP01145", "Cp1145");
+ fIANA2JavaMap.put("CCSID01145", "Cp1145");
+ fIANA2JavaMap.put("IBM01146", "Cp1146");
+ fIANA2JavaMap.put("CP01146", "Cp1146");
+ fIANA2JavaMap.put("CCSID01146", "Cp1146");
+ fIANA2JavaMap.put("IBM01147", "Cp1147");
+ fIANA2JavaMap.put("CP01147", "Cp1147");
+ fIANA2JavaMap.put("CCSID01147", "Cp1147");
+ fIANA2JavaMap.put("IBM01148", "Cp1148");
+ fIANA2JavaMap.put("CP01148", "Cp1148");
+ fIANA2JavaMap.put("CCSID01148", "Cp1148");
+ fIANA2JavaMap.put("IBM01149", "Cp1149");
+ fIANA2JavaMap.put("CP01149", "Cp1149");
+ fIANA2JavaMap.put("CCSID01149", "Cp1149");
+ fIANA2JavaMap.put("EUC-JP", "EUCJIS");
+ fIANA2JavaMap.put("CSEUCPKDFMTJAPANESE", "EUCJIS");
+ fIANA2JavaMap.put("EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", "EUCJIS");
+ fIANA2JavaMap.put("EUC-KR", "KSC5601");
+ fIANA2JavaMap.put("CSEUCKR", "KSC5601");
+ fIANA2JavaMap.put("KS_C_5601-1987", "KS_C_5601-1987");
+ fIANA2JavaMap.put("ISO-IR-149", "KS_C_5601-1987");
+ fIANA2JavaMap.put("KS_C_5601-1989", "KS_C_5601-1987");
+ fIANA2JavaMap.put("KSC_5601", "KS_C_5601-1987");
+ fIANA2JavaMap.put("KOREAN", "KS_C_5601-1987");
+ fIANA2JavaMap.put("CSKSC56011987", "KS_C_5601-1987");
+ fIANA2JavaMap.put("GB2312", "GB2312");
+ fIANA2JavaMap.put("CSGB2312", "GB2312");
+ fIANA2JavaMap.put("ISO-2022-JP", "JIS");
+ fIANA2JavaMap.put("CSISO2022JP", "JIS");
+ fIANA2JavaMap.put("ISO-2022-KR", "ISO2022KR");
+ fIANA2JavaMap.put("CSISO2022KR", "ISO2022KR");
+ fIANA2JavaMap.put("ISO-2022-CN", "ISO2022CN");
- fIANA2JavaMap.put("X0201", "JIS0201");
+ fIANA2JavaMap.put("X0201", "JIS0201");
fIANA2JavaMap.put("CSISO13JISC6220JP", "JIS0201");
- fIANA2JavaMap.put("X0208", "JIS0208");
- fIANA2JavaMap.put("ISO-IR-87", "JIS0208");
- fIANA2JavaMap.put("X0208dbiJIS_X0208-1983", "JIS0208");
- fIANA2JavaMap.put("CSISO87JISX0208", "JIS0208");
- fIANA2JavaMap.put("X0212", "JIS0212");
- fIANA2JavaMap.put("ISO-IR-159", "JIS0212");
- fIANA2JavaMap.put("CSISO159JISX02121990", "JIS0212");
- fIANA2JavaMap.put("GB18030", "GB18030");
- fIANA2JavaMap.put("GBK", "GBK");
- fIANA2JavaMap.put("CP936", "GBK");
- fIANA2JavaMap.put("MS936", "GBK");
- fIANA2JavaMap.put("WINDOWS-936", "GBK");
- fIANA2JavaMap.put("SHIFT_JIS", "SJIS");
- fIANA2JavaMap.put("CSSHIFTJIS", "SJIS");
- fIANA2JavaMap.put("MS_KANJI", "SJIS");
- fIANA2JavaMap.put("WINDOWS-31J", "MS932");
- fIANA2JavaMap.put("CSWINDOWS31J", "MS932");
+ fIANA2JavaMap.put("X0208", "JIS0208");
+ fIANA2JavaMap.put("ISO-IR-87", "JIS0208");
+ fIANA2JavaMap.put("X0208dbiJIS_X0208-1983", "JIS0208");
+ fIANA2JavaMap.put("CSISO87JISX0208", "JIS0208");
+ fIANA2JavaMap.put("X0212", "JIS0212");
+ fIANA2JavaMap.put("ISO-IR-159", "JIS0212");
+ fIANA2JavaMap.put("CSISO159JISX02121990", "JIS0212");
+ fIANA2JavaMap.put("GB18030", "GB18030");
+ fIANA2JavaMap.put("GBK", "GBK");
+ fIANA2JavaMap.put("CP936", "GBK");
+ fIANA2JavaMap.put("MS936", "GBK");
+ fIANA2JavaMap.put("WINDOWS-936", "GBK");
+ fIANA2JavaMap.put("SHIFT_JIS", "SJIS");
+ fIANA2JavaMap.put("CSSHIFTJIS", "SJIS");
+ fIANA2JavaMap.put("MS_KANJI", "SJIS");
+ fIANA2JavaMap.put("WINDOWS-31J", "MS932");
+ fIANA2JavaMap.put("CSWINDOWS31J", "MS932");
- // Add support for Cp1252 and its friends
- fIANA2JavaMap.put("WINDOWS-1250", "Cp1250");
- fIANA2JavaMap.put("WINDOWS-1251", "Cp1251");
- fIANA2JavaMap.put("WINDOWS-1252", "Cp1252");
- fIANA2JavaMap.put("WINDOWS-1253", "Cp1253");
- fIANA2JavaMap.put("WINDOWS-1254", "Cp1254");
- fIANA2JavaMap.put("WINDOWS-1255", "Cp1255");
- fIANA2JavaMap.put("WINDOWS-1256", "Cp1256");
- fIANA2JavaMap.put("WINDOWS-1257", "Cp1257");
- fIANA2JavaMap.put("WINDOWS-1258", "Cp1258");
- fIANA2JavaMap.put("TIS-620", "TIS620");
+ // Add support for Cp1252 and its friends
+ fIANA2JavaMap.put("WINDOWS-1250", "Cp1250");
+ fIANA2JavaMap.put("WINDOWS-1251", "Cp1251");
+ fIANA2JavaMap.put("WINDOWS-1252", "Cp1252");
+ fIANA2JavaMap.put("WINDOWS-1253", "Cp1253");
+ fIANA2JavaMap.put("WINDOWS-1254", "Cp1254");
+ fIANA2JavaMap.put("WINDOWS-1255", "Cp1255");
+ fIANA2JavaMap.put("WINDOWS-1256", "Cp1256");
+ fIANA2JavaMap.put("WINDOWS-1257", "Cp1257");
+ fIANA2JavaMap.put("WINDOWS-1258", "Cp1258");
+ fIANA2JavaMap.put("TIS-620", "TIS620");
- fIANA2JavaMap.put("ISO-8859-1", "ISO8859_1");
- fIANA2JavaMap.put("ISO-IR-100", "ISO8859_1");
- fIANA2JavaMap.put("ISO_8859-1", "ISO8859_1");
- fIANA2JavaMap.put("LATIN1", "ISO8859_1");
- fIANA2JavaMap.put("CSISOLATIN1", "ISO8859_1");
- fIANA2JavaMap.put("L1", "ISO8859_1");
- fIANA2JavaMap.put("IBM819", "ISO8859_1");
- fIANA2JavaMap.put("CP819", "ISO8859_1");
+ fIANA2JavaMap.put("ISO-8859-1", "ISO8859_1");
+ fIANA2JavaMap.put("ISO-IR-100", "ISO8859_1");
+ fIANA2JavaMap.put("ISO_8859-1", "ISO8859_1");
+ fIANA2JavaMap.put("LATIN1", "ISO8859_1");
+ fIANA2JavaMap.put("CSISOLATIN1", "ISO8859_1");
+ fIANA2JavaMap.put("L1", "ISO8859_1");
+ fIANA2JavaMap.put("IBM819", "ISO8859_1");
+ fIANA2JavaMap.put("CP819", "ISO8859_1");
- fIANA2JavaMap.put("ISO-8859-2", "ISO8859_2");
- fIANA2JavaMap.put("ISO-IR-101", "ISO8859_2");
- fIANA2JavaMap.put("ISO_8859-2", "ISO8859_2");
- fIANA2JavaMap.put("LATIN2", "ISO8859_2");
- fIANA2JavaMap.put("CSISOLATIN2", "ISO8859_2");
- fIANA2JavaMap.put("L2", "ISO8859_2");
+ fIANA2JavaMap.put("ISO-8859-2", "ISO8859_2");
+ fIANA2JavaMap.put("ISO-IR-101", "ISO8859_2");
+ fIANA2JavaMap.put("ISO_8859-2", "ISO8859_2");
+ fIANA2JavaMap.put("LATIN2", "ISO8859_2");
+ fIANA2JavaMap.put("CSISOLATIN2", "ISO8859_2");
+ fIANA2JavaMap.put("L2", "ISO8859_2");
- fIANA2JavaMap.put("ISO-8859-3", "ISO8859_3");
- fIANA2JavaMap.put("ISO-IR-109", "ISO8859_3");
- fIANA2JavaMap.put("ISO_8859-3", "ISO8859_3");
- fIANA2JavaMap.put("LATIN3", "ISO8859_3");
- fIANA2JavaMap.put("CSISOLATIN3", "ISO8859_3");
- fIANA2JavaMap.put("L3", "ISO8859_3");
+ fIANA2JavaMap.put("ISO-8859-3", "ISO8859_3");
+ fIANA2JavaMap.put("ISO-IR-109", "ISO8859_3");
+ fIANA2JavaMap.put("ISO_8859-3", "ISO8859_3");
+ fIANA2JavaMap.put("LATIN3", "ISO8859_3");
+ fIANA2JavaMap.put("CSISOLATIN3", "ISO8859_3");
+ fIANA2JavaMap.put("L3", "ISO8859_3");
- fIANA2JavaMap.put("ISO-8859-4", "ISO8859_4");
- fIANA2JavaMap.put("ISO-IR-110", "ISO8859_4");
- fIANA2JavaMap.put("ISO_8859-4", "ISO8859_4");
- fIANA2JavaMap.put("LATIN4", "ISO8859_4");
- fIANA2JavaMap.put("CSISOLATIN4", "ISO8859_4");
- fIANA2JavaMap.put("L4", "ISO8859_4");
+ fIANA2JavaMap.put("ISO-8859-4", "ISO8859_4");
+ fIANA2JavaMap.put("ISO-IR-110", "ISO8859_4");
+ fIANA2JavaMap.put("ISO_8859-4", "ISO8859_4");
+ fIANA2JavaMap.put("LATIN4", "ISO8859_4");
+ fIANA2JavaMap.put("CSISOLATIN4", "ISO8859_4");
+ fIANA2JavaMap.put("L4", "ISO8859_4");
- fIANA2JavaMap.put("ISO-8859-5", "ISO8859_5");
- fIANA2JavaMap.put("ISO-IR-144", "ISO8859_5");
- fIANA2JavaMap.put("ISO_8859-5", "ISO8859_5");
- fIANA2JavaMap.put("CYRILLIC", "ISO8859_5");
- fIANA2JavaMap.put("CSISOLATINCYRILLIC", "ISO8859_5");
+ fIANA2JavaMap.put("ISO-8859-5", "ISO8859_5");
+ fIANA2JavaMap.put("ISO-IR-144", "ISO8859_5");
+ fIANA2JavaMap.put("ISO_8859-5", "ISO8859_5");
+ fIANA2JavaMap.put("CYRILLIC", "ISO8859_5");
+ fIANA2JavaMap.put("CSISOLATINCYRILLIC", "ISO8859_5");
- fIANA2JavaMap.put("ISO-8859-6", "ISO8859_6");
- fIANA2JavaMap.put("ISO-IR-127", "ISO8859_6");
- fIANA2JavaMap.put("ISO_8859-6", "ISO8859_6");
- fIANA2JavaMap.put("ECMA-114", "ISO8859_6");
- fIANA2JavaMap.put("ASMO-708", "ISO8859_6");
- fIANA2JavaMap.put("ARABIC", "ISO8859_6");
- fIANA2JavaMap.put("CSISOLATINARABIC", "ISO8859_6");
+ fIANA2JavaMap.put("ISO-8859-6", "ISO8859_6");
+ fIANA2JavaMap.put("ISO-IR-127", "ISO8859_6");
+ fIANA2JavaMap.put("ISO_8859-6", "ISO8859_6");
+ fIANA2JavaMap.put("ECMA-114", "ISO8859_6");
+ fIANA2JavaMap.put("ASMO-708", "ISO8859_6");
+ fIANA2JavaMap.put("ARABIC", "ISO8859_6");
+ fIANA2JavaMap.put("CSISOLATINARABIC", "ISO8859_6");
- fIANA2JavaMap.put("ISO-8859-7", "ISO8859_7");
- fIANA2JavaMap.put("ISO-IR-126", "ISO8859_7");
- fIANA2JavaMap.put("ISO_8859-7", "ISO8859_7");
- fIANA2JavaMap.put("ELOT_928", "ISO8859_7");
- fIANA2JavaMap.put("ECMA-118", "ISO8859_7");
- fIANA2JavaMap.put("GREEK", "ISO8859_7");
- fIANA2JavaMap.put("CSISOLATINGREEK", "ISO8859_7");
- fIANA2JavaMap.put("GREEK8", "ISO8859_7");
+ fIANA2JavaMap.put("ISO-8859-7", "ISO8859_7");
+ fIANA2JavaMap.put("ISO-IR-126", "ISO8859_7");
+ fIANA2JavaMap.put("ISO_8859-7", "ISO8859_7");
+ fIANA2JavaMap.put("ELOT_928", "ISO8859_7");
+ fIANA2JavaMap.put("ECMA-118", "ISO8859_7");
+ fIANA2JavaMap.put("GREEK", "ISO8859_7");
+ fIANA2JavaMap.put("CSISOLATINGREEK", "ISO8859_7");
+ fIANA2JavaMap.put("GREEK8", "ISO8859_7");
- fIANA2JavaMap.put("ISO-8859-8", "ISO8859_8");
- fIANA2JavaMap.put("ISO-8859-8-I", "ISO8859_8"); // added since this encoding only differs w.r.t. presentation
- fIANA2JavaMap.put("ISO-IR-138", "ISO8859_8");
- fIANA2JavaMap.put("ISO_8859-8", "ISO8859_8");
- fIANA2JavaMap.put("HEBREW", "ISO8859_8");
- fIANA2JavaMap.put("CSISOLATINHEBREW", "ISO8859_8");
+ fIANA2JavaMap.put("ISO-8859-8", "ISO8859_8");
+ fIANA2JavaMap.put("ISO-8859-8-I", "ISO8859_8"); // added since this encoding only differs w.r.t. presentation
+ fIANA2JavaMap.put("ISO-IR-138", "ISO8859_8");
+ fIANA2JavaMap.put("ISO_8859-8", "ISO8859_8");
+ fIANA2JavaMap.put("HEBREW", "ISO8859_8");
+ fIANA2JavaMap.put("CSISOLATINHEBREW", "ISO8859_8");
- fIANA2JavaMap.put("ISO-8859-9", "ISO8859_9");
- fIANA2JavaMap.put("ISO-IR-148", "ISO8859_9");
- fIANA2JavaMap.put("ISO_8859-9", "ISO8859_9");
- fIANA2JavaMap.put("LATIN5", "ISO8859_9");
- fIANA2JavaMap.put("CSISOLATIN5", "ISO8859_9");
- fIANA2JavaMap.put("L5", "ISO8859_9");
+ fIANA2JavaMap.put("ISO-8859-9", "ISO8859_9");
+ fIANA2JavaMap.put("ISO-IR-148", "ISO8859_9");
+ fIANA2JavaMap.put("ISO_8859-9", "ISO8859_9");
+ fIANA2JavaMap.put("LATIN5", "ISO8859_9");
+ fIANA2JavaMap.put("CSISOLATIN5", "ISO8859_9");
+ fIANA2JavaMap.put("L5", "ISO8859_9");
- fIANA2JavaMap.put("ISO-8859-13", "ISO8859_13");
-
- fIANA2JavaMap.put("ISO-8859-15", "ISO8859_15_FDIS");
- fIANA2JavaMap.put("ISO_8859-15", "ISO8859_15_FDIS");
- fIANA2JavaMap.put("LATIN-9", "ISO8859_15_FDIS");
+ fIANA2JavaMap.put("ISO-8859-13", "ISO8859_13");
- fIANA2JavaMap.put("KOI8-R", "KOI8_R");
- fIANA2JavaMap.put("CSKOI8R", "KOI8_R");
- fIANA2JavaMap.put("US-ASCII", "ASCII");
- fIANA2JavaMap.put("ISO-IR-6", "ASCII");
- fIANA2JavaMap.put("ANSI_X3.4-1968", "ASCII");
- fIANA2JavaMap.put("ANSI_X3.4-1986", "ASCII");
- fIANA2JavaMap.put("ISO_646.IRV:1991", "ASCII");
- fIANA2JavaMap.put("ASCII", "ASCII");
- fIANA2JavaMap.put("CSASCII", "ASCII");
- fIANA2JavaMap.put("ISO646-US", "ASCII");
- fIANA2JavaMap.put("US", "ASCII");
- fIANA2JavaMap.put("IBM367", "ASCII");
- fIANA2JavaMap.put("CP367", "ASCII");
- fIANA2JavaMap.put("UTF-8", "UTF8");
- fIANA2JavaMap.put("UTF-16", "UTF-16");
- fIANA2JavaMap.put("UTF-16BE", "UnicodeBig");
- fIANA2JavaMap.put("UTF-16LE", "UnicodeLittle");
+ fIANA2JavaMap.put("ISO-8859-15", "ISO8859_15_FDIS");
+ fIANA2JavaMap.put("ISO_8859-15", "ISO8859_15_FDIS");
+ fIANA2JavaMap.put("LATIN-9", "ISO8859_15_FDIS");
+
+ fIANA2JavaMap.put("KOI8-R", "KOI8_R");
+ fIANA2JavaMap.put("CSKOI8R", "KOI8_R");
+ fIANA2JavaMap.put("US-ASCII", "ASCII");
+ fIANA2JavaMap.put("ISO-IR-6", "ASCII");
+ fIANA2JavaMap.put("ANSI_X3.4-1968", "ASCII");
+ fIANA2JavaMap.put("ANSI_X3.4-1986", "ASCII");
+ fIANA2JavaMap.put("ISO_646.IRV:1991", "ASCII");
+ fIANA2JavaMap.put("ASCII", "ASCII");
+ fIANA2JavaMap.put("CSASCII", "ASCII");
+ fIANA2JavaMap.put("ISO646-US", "ASCII");
+ fIANA2JavaMap.put("US", "ASCII");
+ fIANA2JavaMap.put("IBM367", "ASCII");
+ fIANA2JavaMap.put("CP367", "ASCII");
+ fIANA2JavaMap.put("UTF-8", "UTF8");
+ fIANA2JavaMap.put("UTF-16", "UTF-16");
+ fIANA2JavaMap.put("UTF-16BE", "UnicodeBig");
+ fIANA2JavaMap.put("UTF-16LE", "UnicodeLittle");
// support for 1047, as proposed to be added to the
// IANA registry in
// http://lists.w3.org/Archives/Public/ietf-charset/2002JulSep/0049.html
- fIANA2JavaMap.put("IBM-1047", "Cp1047");
- fIANA2JavaMap.put("IBM1047", "Cp1047");
- fIANA2JavaMap.put("CP1047", "Cp1047");
+ fIANA2JavaMap.put("IBM-1047", "Cp1047");
+ fIANA2JavaMap.put("IBM1047", "Cp1047");
+ fIANA2JavaMap.put("CP1047", "Cp1047");
// Adding new aliases as proposed in
// http://lists.w3.org/Archives/Public/ietf-charset/2002JulSep/0058.html
- fIANA2JavaMap.put("IBM-37", "CP037");
- fIANA2JavaMap.put("IBM-273", "CP273");
- fIANA2JavaMap.put("IBM-277", "CP277");
- fIANA2JavaMap.put("IBM-278", "CP278");
- fIANA2JavaMap.put("IBM-280", "CP280");
- fIANA2JavaMap.put("IBM-284", "CP284");
- fIANA2JavaMap.put("IBM-285", "CP285");
- fIANA2JavaMap.put("IBM-290", "CP290");
- fIANA2JavaMap.put("IBM-297", "CP297");
- fIANA2JavaMap.put("IBM-420", "CP420");
- fIANA2JavaMap.put("IBM-424", "CP424");
- fIANA2JavaMap.put("IBM-437", "CP437");
- fIANA2JavaMap.put("IBM-500", "CP500");
- fIANA2JavaMap.put("IBM-775", "CP775");
- fIANA2JavaMap.put("IBM-850", "CP850");
- fIANA2JavaMap.put("IBM-852", "CP852");
- fIANA2JavaMap.put("IBM-855", "CP855");
- fIANA2JavaMap.put("IBM-857", "CP857");
- fIANA2JavaMap.put("IBM-858", "CP858");
- fIANA2JavaMap.put("IBM-860", "CP860");
- fIANA2JavaMap.put("IBM-861", "CP861");
- fIANA2JavaMap.put("IBM-862", "CP862");
- fIANA2JavaMap.put("IBM-863", "CP863");
- fIANA2JavaMap.put("IBM-864", "CP864");
- fIANA2JavaMap.put("IBM-865", "CP865");
- fIANA2JavaMap.put("IBM-866", "CP866");
- fIANA2JavaMap.put("IBM-868", "CP868");
- fIANA2JavaMap.put("IBM-869", "CP869");
- fIANA2JavaMap.put("IBM-870", "CP870");
- fIANA2JavaMap.put("IBM-871", "CP871");
- fIANA2JavaMap.put("IBM-918", "CP918");
- fIANA2JavaMap.put("IBM-924", "CP924");
- fIANA2JavaMap.put("IBM-1026", "CP1026");
- fIANA2JavaMap.put("IBM-1140", "Cp1140");
- fIANA2JavaMap.put("IBM-1141", "Cp1141");
- fIANA2JavaMap.put("IBM-1142", "Cp1142");
- fIANA2JavaMap.put("IBM-1143", "Cp1143");
- fIANA2JavaMap.put("IBM-1144", "Cp1144");
- fIANA2JavaMap.put("IBM-1145", "Cp1145");
- fIANA2JavaMap.put("IBM-1146", "Cp1146");
- fIANA2JavaMap.put("IBM-1147", "Cp1147");
- fIANA2JavaMap.put("IBM-1148", "Cp1148");
- fIANA2JavaMap.put("IBM-1149", "Cp1149");
- fIANA2JavaMap.put("IBM-819", "ISO8859_1");
- fIANA2JavaMap.put("IBM-367", "ASCII");
+ fIANA2JavaMap.put("IBM-37", "CP037");
+ fIANA2JavaMap.put("IBM-273", "CP273");
+ fIANA2JavaMap.put("IBM-277", "CP277");
+ fIANA2JavaMap.put("IBM-278", "CP278");
+ fIANA2JavaMap.put("IBM-280", "CP280");
+ fIANA2JavaMap.put("IBM-284", "CP284");
+ fIANA2JavaMap.put("IBM-285", "CP285");
+ fIANA2JavaMap.put("IBM-290", "CP290");
+ fIANA2JavaMap.put("IBM-297", "CP297");
+ fIANA2JavaMap.put("IBM-420", "CP420");
+ fIANA2JavaMap.put("IBM-424", "CP424");
+ fIANA2JavaMap.put("IBM-437", "CP437");
+ fIANA2JavaMap.put("IBM-500", "CP500");
+ fIANA2JavaMap.put("IBM-775", "CP775");
+ fIANA2JavaMap.put("IBM-850", "CP850");
+ fIANA2JavaMap.put("IBM-852", "CP852");
+ fIANA2JavaMap.put("IBM-855", "CP855");
+ fIANA2JavaMap.put("IBM-857", "CP857");
+ fIANA2JavaMap.put("IBM-858", "CP858");
+ fIANA2JavaMap.put("IBM-860", "CP860");
+ fIANA2JavaMap.put("IBM-861", "CP861");
+ fIANA2JavaMap.put("IBM-862", "CP862");
+ fIANA2JavaMap.put("IBM-863", "CP863");
+ fIANA2JavaMap.put("IBM-864", "CP864");
+ fIANA2JavaMap.put("IBM-865", "CP865");
+ fIANA2JavaMap.put("IBM-866", "CP866");
+ fIANA2JavaMap.put("IBM-868", "CP868");
+ fIANA2JavaMap.put("IBM-869", "CP869");
+ fIANA2JavaMap.put("IBM-870", "CP870");
+ fIANA2JavaMap.put("IBM-871", "CP871");
+ fIANA2JavaMap.put("IBM-918", "CP918");
+ fIANA2JavaMap.put("IBM-924", "CP924");
+ fIANA2JavaMap.put("IBM-1026", "CP1026");
+ fIANA2JavaMap.put("IBM-1140", "Cp1140");
+ fIANA2JavaMap.put("IBM-1141", "Cp1141");
+ fIANA2JavaMap.put("IBM-1142", "Cp1142");
+ fIANA2JavaMap.put("IBM-1143", "Cp1143");
+ fIANA2JavaMap.put("IBM-1144", "Cp1144");
+ fIANA2JavaMap.put("IBM-1145", "Cp1145");
+ fIANA2JavaMap.put("IBM-1146", "Cp1146");
+ fIANA2JavaMap.put("IBM-1147", "Cp1147");
+ fIANA2JavaMap.put("IBM-1148", "Cp1148");
+ fIANA2JavaMap.put("IBM-1149", "Cp1149");
+ fIANA2JavaMap.put("IBM-819", "ISO8859_1");
+ fIANA2JavaMap.put("IBM-367", "ASCII");
// REVISIT:
// j:CNS11643 -> EUC-TW?
// ISO-2022-CN? ISO-2022-CN-EXT?
-
+
// add Java to IANA encoding mappings
//fJava2IANAMap.put("8859_1", "US-ASCII"); // ?
- fJava2IANAMap.put("ISO8859_1", "ISO-8859-1");
- fJava2IANAMap.put("ISO8859_2", "ISO-8859-2");
- fJava2IANAMap.put("ISO8859_3", "ISO-8859-3");
- fJava2IANAMap.put("ISO8859_4", "ISO-8859-4");
- fJava2IANAMap.put("ISO8859_5", "ISO-8859-5");
- fJava2IANAMap.put("ISO8859_6", "ISO-8859-6");
- fJava2IANAMap.put("ISO8859_7", "ISO-8859-7");
- fJava2IANAMap.put("ISO8859_8", "ISO-8859-8");
- fJava2IANAMap.put("ISO8859_9", "ISO-8859-9");
- fJava2IANAMap.put("ISO8859_13", "ISO-8859-13");
- fJava2IANAMap.put("ISO8859_15", "ISO-8859-15");
- fJava2IANAMap.put("ISO8859_15_FDIS", "ISO-8859-15");
- fJava2IANAMap.put("Big5", "BIG5");
- fJava2IANAMap.put("CP037", "EBCDIC-CP-US");
- fJava2IANAMap.put("CP273", "IBM273");
- fJava2IANAMap.put("CP277", "EBCDIC-CP-DK");
- fJava2IANAMap.put("CP278", "EBCDIC-CP-FI");
- fJava2IANAMap.put("CP280", "EBCDIC-CP-IT");
- fJava2IANAMap.put("CP284", "EBCDIC-CP-ES");
- fJava2IANAMap.put("CP285", "EBCDIC-CP-GB");
- fJava2IANAMap.put("CP290", "EBCDIC-JP-KANA");
- fJava2IANAMap.put("CP297", "EBCDIC-CP-FR");
- fJava2IANAMap.put("CP420", "EBCDIC-CP-AR1");
- fJava2IANAMap.put("CP424", "EBCDIC-CP-HE");
- fJava2IANAMap.put("CP437", "IBM437");
- fJava2IANAMap.put("CP500", "EBCDIC-CP-CH");
- fJava2IANAMap.put("CP775", "IBM775");
- fJava2IANAMap.put("CP850", "IBM850");
- fJava2IANAMap.put("CP852", "IBM852");
- fJava2IANAMap.put("CP855", "IBM855");
- fJava2IANAMap.put("CP857", "IBM857");
- fJava2IANAMap.put("CP858", "IBM00858");
- fJava2IANAMap.put("CP860", "IBM860");
- fJava2IANAMap.put("CP861", "IBM861");
- fJava2IANAMap.put("CP862", "IBM862");
- fJava2IANAMap.put("CP863", "IBM863");
- fJava2IANAMap.put("CP864", "IBM864");
- fJava2IANAMap.put("CP865", "IBM865");
- fJava2IANAMap.put("CP866", "IBM866");
- fJava2IANAMap.put("CP868", "IBM868");
- fJava2IANAMap.put("CP869", "IBM869");
- fJava2IANAMap.put("CP870", "EBCDIC-CP-ROECE");
- fJava2IANAMap.put("CP871", "EBCDIC-CP-IS");
- fJava2IANAMap.put("CP918", "EBCDIC-CP-AR2");
- fJava2IANAMap.put("CP924", "IBM00924");
- fJava2IANAMap.put("CP1026", "IBM1026");
- fJava2IANAMap.put("Cp01140", "IBM01140");
- fJava2IANAMap.put("Cp01141", "IBM01141");
- fJava2IANAMap.put("Cp01142", "IBM01142");
- fJava2IANAMap.put("Cp01143", "IBM01143");
- fJava2IANAMap.put("Cp01144", "IBM01144");
- fJava2IANAMap.put("Cp01145", "IBM01145");
- fJava2IANAMap.put("Cp01146", "IBM01146");
- fJava2IANAMap.put("Cp01147", "IBM01147");
- fJava2IANAMap.put("Cp01148", "IBM01148");
- fJava2IANAMap.put("Cp01149", "IBM01149");
- fJava2IANAMap.put("EUCJIS", "EUC-JP");
- fJava2IANAMap.put("KS_C_5601-1987", "KS_C_5601-1987");
- fJava2IANAMap.put("GB2312", "GB2312");
+ fJava2IANAMap.put("ISO8859_1", "ISO-8859-1");
+ fJava2IANAMap.put("ISO8859_2", "ISO-8859-2");
+ fJava2IANAMap.put("ISO8859_3", "ISO-8859-3");
+ fJava2IANAMap.put("ISO8859_4", "ISO-8859-4");
+ fJava2IANAMap.put("ISO8859_5", "ISO-8859-5");
+ fJava2IANAMap.put("ISO8859_6", "ISO-8859-6");
+ fJava2IANAMap.put("ISO8859_7", "ISO-8859-7");
+ fJava2IANAMap.put("ISO8859_8", "ISO-8859-8");
+ fJava2IANAMap.put("ISO8859_9", "ISO-8859-9");
+ fJava2IANAMap.put("ISO8859_13", "ISO-8859-13");
+ fJava2IANAMap.put("ISO8859_15", "ISO-8859-15");
+ fJava2IANAMap.put("ISO8859_15_FDIS", "ISO-8859-15");
+ fJava2IANAMap.put("Big5", "BIG5");
+ fJava2IANAMap.put("CP037", "EBCDIC-CP-US");
+ fJava2IANAMap.put("CP273", "IBM273");
+ fJava2IANAMap.put("CP277", "EBCDIC-CP-DK");
+ fJava2IANAMap.put("CP278", "EBCDIC-CP-FI");
+ fJava2IANAMap.put("CP280", "EBCDIC-CP-IT");
+ fJava2IANAMap.put("CP284", "EBCDIC-CP-ES");
+ fJava2IANAMap.put("CP285", "EBCDIC-CP-GB");
+ fJava2IANAMap.put("CP290", "EBCDIC-JP-KANA");
+ fJava2IANAMap.put("CP297", "EBCDIC-CP-FR");
+ fJava2IANAMap.put("CP420", "EBCDIC-CP-AR1");
+ fJava2IANAMap.put("CP424", "EBCDIC-CP-HE");
+ fJava2IANAMap.put("CP437", "IBM437");
+ fJava2IANAMap.put("CP500", "EBCDIC-CP-CH");
+ fJava2IANAMap.put("CP775", "IBM775");
+ fJava2IANAMap.put("CP850", "IBM850");
+ fJava2IANAMap.put("CP852", "IBM852");
+ fJava2IANAMap.put("CP855", "IBM855");
+ fJava2IANAMap.put("CP857", "IBM857");
+ fJava2IANAMap.put("CP858", "IBM00858");
+ fJava2IANAMap.put("CP860", "IBM860");
+ fJava2IANAMap.put("CP861", "IBM861");
+ fJava2IANAMap.put("CP862", "IBM862");
+ fJava2IANAMap.put("CP863", "IBM863");
+ fJava2IANAMap.put("CP864", "IBM864");
+ fJava2IANAMap.put("CP865", "IBM865");
+ fJava2IANAMap.put("CP866", "IBM866");
+ fJava2IANAMap.put("CP868", "IBM868");
+ fJava2IANAMap.put("CP869", "IBM869");
+ fJava2IANAMap.put("CP870", "EBCDIC-CP-ROECE");
+ fJava2IANAMap.put("CP871", "EBCDIC-CP-IS");
+ fJava2IANAMap.put("CP918", "EBCDIC-CP-AR2");
+ fJava2IANAMap.put("CP924", "IBM00924");
+ fJava2IANAMap.put("CP1026", "IBM1026");
+ fJava2IANAMap.put("Cp01140", "IBM01140");
+ fJava2IANAMap.put("Cp01141", "IBM01141");
+ fJava2IANAMap.put("Cp01142", "IBM01142");
+ fJava2IANAMap.put("Cp01143", "IBM01143");
+ fJava2IANAMap.put("Cp01144", "IBM01144");
+ fJava2IANAMap.put("Cp01145", "IBM01145");
+ fJava2IANAMap.put("Cp01146", "IBM01146");
+ fJava2IANAMap.put("Cp01147", "IBM01147");
+ fJava2IANAMap.put("Cp01148", "IBM01148");
+ fJava2IANAMap.put("Cp01149", "IBM01149");
+ fJava2IANAMap.put("EUCJIS", "EUC-JP");
+ fJava2IANAMap.put("KS_C_5601-1987", "KS_C_5601-1987");
+ fJava2IANAMap.put("GB2312", "GB2312");
fJava2IANAMap.put("ISO2022KR", "ISO-2022-KR");
fJava2IANAMap.put("ISO2022CN", "ISO-2022-CN");
- fJava2IANAMap.put("JIS", "ISO-2022-JP");
- fJava2IANAMap.put("KOI8_R", "KOI8-R");
- fJava2IANAMap.put("KSC5601", "EUC-KR");
- fJava2IANAMap.put("GB18030", "GB18030");
- fJava2IANAMap.put("GBK", "GBK");
- fJava2IANAMap.put("SJIS", "SHIFT_JIS");
- fJava2IANAMap.put("MS932", "WINDOWS-31J");
- fJava2IANAMap.put("UTF8", "UTF-8");
- fJava2IANAMap.put("Unicode", "UTF-16");
- fJava2IANAMap.put("UnicodeBig", "UTF-16BE");
- fJava2IANAMap.put("UnicodeLittle", "UTF-16LE");
- fJava2IANAMap.put("JIS0201", "X0201");
- fJava2IANAMap.put("JIS0208", "X0208");
- fJava2IANAMap.put("JIS0212", "ISO-IR-159");
+ fJava2IANAMap.put("JIS", "ISO-2022-JP");
+ fJava2IANAMap.put("KOI8_R", "KOI8-R");
+ fJava2IANAMap.put("KSC5601", "EUC-KR");
+ fJava2IANAMap.put("GB18030", "GB18030");
+ fJava2IANAMap.put("GBK", "GBK");
+ fJava2IANAMap.put("SJIS", "SHIFT_JIS");
+ fJava2IANAMap.put("MS932", "WINDOWS-31J");
+ fJava2IANAMap.put("UTF8", "UTF-8");
+ fJava2IANAMap.put("Unicode", "UTF-16");
+ fJava2IANAMap.put("UnicodeBig", "UTF-16BE");
+ fJava2IANAMap.put("UnicodeLittle", "UTF-16LE");
+ fJava2IANAMap.put("JIS0201", "X0201");
+ fJava2IANAMap.put("JIS0208", "X0208");
+ fJava2IANAMap.put("JIS0212", "ISO-IR-159");
// proposed addition (see above for details):
- fJava2IANAMap.put("CP1047", "IBM1047");
+ fJava2IANAMap.put("CP1047", "IBM1047");
} // <clinit>()
@@ -952,8 +955,11 @@
// Constructors
//
- /** Default constructor. */
- public EncodingMap() {}
+ /**
+ * Default constructor.
+ */
+ public EncodingMap() {
+ }
//
// Public static methods
@@ -961,60 +967,60 @@
/**
* Adds an IANA to Java encoding name mapping.
- *
+ *
* @param ianaEncoding The IANA encoding name.
* @param javaEncoding The Java encoding name.
*/
- public static void putIANA2JavaMapping(String ianaEncoding,
+ public static void putIANA2JavaMapping(String ianaEncoding,
String javaEncoding) {
fIANA2JavaMap.put(ianaEncoding, javaEncoding);
} // putIANA2JavaMapping(String,String)
/**
* Returns the Java encoding name for the specified IANA encoding name.
- *
+ *
* @param ianaEncoding The IANA encoding name.
*/
public static String getIANA2JavaMapping(String ianaEncoding) {
- return (String)fIANA2JavaMap.get(ianaEncoding);
+ return (String) fIANA2JavaMap.get(ianaEncoding);
} // getIANA2JavaMapping(String):String
/**
* Removes an IANA to Java encoding name mapping.
- *
+ *
* @param ianaEncoding The IANA encoding name.
*/
public static String removeIANA2JavaMapping(String ianaEncoding) {
- return (String)fIANA2JavaMap.remove(ianaEncoding);
+ return (String) fIANA2JavaMap.remove(ianaEncoding);
} // removeIANA2JavaMapping(String):String
/**
* Adds a Java to IANA encoding name mapping.
- *
+ *
* @param javaEncoding The Java encoding name.
* @param ianaEncoding The IANA encoding name.
*/
- public static void putJava2IANAMapping(String javaEncoding,
+ public static void putJava2IANAMapping(String javaEncoding,
String ianaEncoding) {
fJava2IANAMap.put(javaEncoding, ianaEncoding);
} // putJava2IANAMapping(String,String)
/**
* Returns the IANA encoding name for the specified Java encoding name.
- *
+ *
* @param javaEncoding The Java encoding name.
*/
public static String getJava2IANAMapping(String javaEncoding) {
- return (String)fJava2IANAMap.get(javaEncoding);
+ return (String) fJava2IANAMap.get(javaEncoding);
} // getJava2IANAMapping(String):String
/**
* Removes a Java to IANA encoding name mapping.
- *
+ *
* @param javaEncoding The Java encoding name.
*/
public static String removeJava2IANAMapping(String javaEncoding) {
- return (String)fJava2IANAMap.remove(javaEncoding);
+ return (String) fJava2IANAMap.remove(javaEncoding);
} // removeJava2IANAMapping
} // class EncodingMap
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/ParserUtils.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/ParserUtils.java
index 81ac42f..e60e814 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/ParserUtils.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/ParserUtils.java
@@ -17,8 +17,7 @@
package org.apache.struts2.jasper.xmlparser;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.Constants;
import org.apache.struts2.jasper.JasperException;
import org.apache.struts2.jasper.compiler.Localizer;
@@ -64,43 +63,42 @@
* that corresponds to the root node of the document tree.
*
* @param uri URI of the XML document being parsed
- * @param is Input source containing the deployment descriptor
- *
- * @exception JasperException if an input/output error occurs
- * @exception JasperException if a parsing error occurs
+ * @param is Input source containing the deployment descriptor
+ * @throws JasperException if an input/output error occurs
+ * @throws JasperException if a parsing error occurs
*/
public TreeNode parseXMLDocument(String uri, InputSource is)
- throws JasperException {
+ throws JasperException {
Document document = null;
// Perform an XML parse of this document, via JAXP
try {
DocumentBuilderFactory factory =
- DocumentBuilderFactory.newInstance();
+ DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(validating);
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setEntityResolver(entityResolver);
builder.setErrorHandler(errorHandler);
document = builder.parse(is);
- } catch (ParserConfigurationException ex) {
+ } catch (ParserConfigurationException ex) {
throw new JasperException
- (Localizer.getMessage("jsp.error.parse.xml", uri), ex);
- } catch (SAXParseException ex) {
+ (Localizer.getMessage("jsp.error.parse.xml", uri), ex);
+ } catch (SAXParseException ex) {
throw new JasperException
- (Localizer.getMessage("jsp.error.parse.xml.line",
- uri,
- Integer.toString(ex.getLineNumber()),
- Integer.toString(ex.getColumnNumber())),
- ex);
- } catch (SAXException sx) {
+ (Localizer.getMessage("jsp.error.parse.xml.line",
+ uri,
+ Integer.toString(ex.getLineNumber()),
+ Integer.toString(ex.getColumnNumber())),
+ ex);
+ } catch (SAXException sx) {
throw new JasperException
- (Localizer.getMessage("jsp.error.parse.xml", uri), sx);
+ (Localizer.getMessage("jsp.error.parse.xml", uri), sx);
} catch (IOException io) {
throw new JasperException
- (Localizer.getMessage("jsp.error.parse.xml", uri), io);
- }
+ (Localizer.getMessage("jsp.error.parse.xml", uri), io);
+ }
// Convert the resulting document to a graph of TreeNodes
return (convert(null, document.getDocumentElement()));
@@ -112,10 +110,9 @@
* that corresponds to the root node of the document tree.
*
* @param uri URI of the XML document being parsed
- * @param is Input stream containing the deployment descriptor
- *
- * @exception JasperException if an input/output error occurs
- * @exception JasperException if a parsing error occurs
+ * @param is Input stream containing the deployment descriptor
+ * @throws JasperException if an input/output error occurs
+ * @throws JasperException if a parsing error occurs
*/
public TreeNode parseXMLDocument(String uri, InputStream is)
throws JasperException {
@@ -132,7 +129,7 @@
* including processing all of the attributes and children nodes.
*
* @param parent The parent TreeNode (if any) for the new TreeNode
- * @param node The XML document Node to be converted
+ * @param node The XML document Node to be converted
*/
protected TreeNode convert(TreeNode parent, Node node) {
@@ -146,7 +143,7 @@
for (int i = 0; i < n; i++) {
Node attribute = attributes.item(i);
treeNode.addAttribute(attribute.getNodeName(),
- attribute.getNodeValue());
+ attribute.getNodeValue());
}
}
@@ -170,7 +167,7 @@
}
}
}
-
+
// Return the completed TreeNode graph
return (treeNode);
}
@@ -197,7 +194,7 @@
return isrc;
}
}
- Log log = LogFactory.getLog(MyEntityResolver.class);
+ com.opensymphony.xwork2.util.logging.Logger log = LoggerFactory.getLogger(MyEntityResolver.class);
if (log.isDebugEnabled())
log.debug("Resolve entity failed" + publicId + " " + systemId);
log.error(Localizer.getMessage("jsp.error.parse.xml.invalidPublicId",
@@ -209,7 +206,7 @@
class MyErrorHandler implements ErrorHandler {
public void warning(SAXParseException ex) throws SAXException {
- Log log = LogFactory.getLog(MyErrorHandler.class);
+ com.opensymphony.xwork2.util.logging.Logger log = LoggerFactory.getLogger(MyErrorHandler.class);
if (log.isDebugEnabled())
log.debug("ParserUtils: warning ", ex);
// We ignore warnings
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/SymbolTable.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/SymbolTable.java
index 8a8cd2f..920d9f5 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/SymbolTable.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/SymbolTable.java
@@ -30,22 +30,22 @@
* strings used as identifiers are unique references. Multiple calls
* to <code>addSymbol</code> will always return the same string
* reference.
- * <p>
+ * <p/>
* The symbol table performs the same task as <code>String.intern()</code>
* with the following differences:
* <ul>
- * <li>
- * A new string object does not need to be created in order to
- * retrieve a unique reference. Symbols can be added by using
- * a series of characters in a character array.
- * </li>
- * <li>
- * Users of the symbol table can provide their own symbol hashing
- * implementation. For example, a simple string hashing algorithm
- * may fail to produce a balanced set of hashcodes for symbols
- * that are <em>mostly</em> unique. Strings with similar leading
- * characters are especially prone to this poor hashing behavior.
- * </li>
+ * <li>
+ * A new string object does not need to be created in order to
+ * retrieve a unique reference. Symbols can be added by using
+ * a series of characters in a character array.
+ * </li>
+ * <li>
+ * Users of the symbol table can provide their own symbol hashing
+ * implementation. For example, a simple string hashing algorithm
+ * may fail to produce a balanced set of hashcodes for symbols
+ * that are <em>mostly</em> unique. Strings with similar leading
+ * characters are especially prone to this poor hashing behavior.
+ * </li>
* </ul>
*
* @author Andy Clark
@@ -57,14 +57,18 @@
// Constants
//
- /** Default table size. */
+ /**
+ * Default table size.
+ */
protected static final int TABLE_SIZE = 101;
//
// Data
//
- /** Buckets. */
+ /**
+ * Buckets.
+ */
protected Entry[] fBuckets = null;
// actual table size
@@ -74,12 +78,16 @@
// Constructors
//
- /** Constructs a symbol table with a default number of buckets. */
+ /**
+ * Constructs a symbol table with a default number of buckets.
+ */
public SymbolTable() {
this(TABLE_SIZE);
}
- /** Constructs a symbol table with a specified number of buckets. */
+ /**
+ * Constructs a symbol table with a specified number of buckets.
+ */
public SymbolTable(int tableSize) {
fTableSize = tableSize;
fBuckets = new Entry[fTableSize];
@@ -102,7 +110,8 @@
// search for identical symbol
int bucket = hash(symbol) % fTableSize;
int length = symbol.length();
- OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
+ OUTER:
+ for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length) {
for (int i = 0; i < length; i++) {
if (symbol.charAt(i) != entry.characters[i]) {
@@ -134,7 +143,8 @@
// search for identical symbol
int bucket = hash(buffer, offset, length) % fTableSize;
- OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
+ OUTER:
+ for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length) {
for (int i = 0; i < length; i++) {
if (buffer[offset + i] != entry.characters[i]) {
@@ -203,7 +213,8 @@
// search for identical symbol
int bucket = hash(symbol) % fTableSize;
int length = symbol.length();
- OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
+ OUTER:
+ for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length) {
for (int i = 0; i < length; i++) {
if (symbol.charAt(i) != entry.characters[i]) {
@@ -230,7 +241,8 @@
// search for identical symbol
int bucket = hash(buffer, offset, length) % fTableSize;
- OUTER: for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
+ OUTER:
+ for (Entry entry = fBuckets[bucket]; entry != null; entry = entry.next) {
if (length == entry.characters.length) {
for (int i = 0; i < length; i++) {
if (buffer[offset + i] != entry.characters[i]) {
@@ -259,7 +271,9 @@
// Data
//
- /** Symbol. */
+ /**
+ * Symbol.
+ */
public String symbol;
/**
@@ -268,7 +282,9 @@
*/
public char[] characters;
- /** The next entry. */
+ /**
+ * The next entry.
+ */
public Entry next;
//
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/TreeNode.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/TreeNode.java
index 72262ab..6e82536 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/TreeNode.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/TreeNode.java
@@ -28,7 +28,7 @@
* parse of an XML document. This class is used to represent a DOM tree
* so that the XML parser's implementation of <code>org.w3c.dom</code> need
* not be visible to the remainder of Jasper.
- * <p>
+ * <p/>
* <strong>WARNING</strong> - Construction of a new tree, or modifications
* to an existing one, are not thread-safe and such accesses must be
* synchronized.
@@ -58,7 +58,7 @@
/**
* Construct a new node with the specified parent.
*
- * @param name The name of this node
+ * @param name The name of this node
* @param parent The node that is the parent of this node
*/
public TreeNode(String name, TreeNode parent) {
@@ -113,7 +113,7 @@
* Add an attribute to this node, replacing any existing attribute
* with the same name.
*
- * @param name The attribute name to add
+ * @param name The attribute name to add
* @param value The new attribute value
*/
public void addAttribute(String name, String value) {
@@ -305,9 +305,9 @@
* Append to the specified StringBuffer a character representation of
* this node, with the specified amount of indentation.
*
- * @param sb The StringBuffer to append to
+ * @param sb The StringBuffer to append to
* @param indent Number of characters of indentation
- * @param node The TreeNode to be printed
+ * @param node The TreeNode to be printed
*/
protected void toString(StringBuffer sb, int indent,
TreeNode node) {
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UCSReader.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UCSReader.java
index 5f8408d..058efbd 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UCSReader.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UCSReader.java
@@ -17,30 +17,32 @@
package org.apache.struts2.jasper.xmlparser;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
-/**
+/**
* Reader for UCS-2 and UCS-4 encodings.
* (i.e., encodings from ISO-10646-UCS-(2|4)).
*
* @author Neil Graham, IBM
- *
* @version $Id: UCSReader.java 466606 2006-10-21 23:07:12Z markt $
*/
public class UCSReader extends Reader {
- private org.apache.commons.logging.Log log=
- org.apache.commons.logging.LogFactory.getLog( UCSReader.class );
-
+ private Logger log = LoggerFactory.getLogger(UCSReader.class);
+
//
// Constants
//
- /** Default byte buffer size (8192, larger than that of ASCIIReader
+ /**
+ * Default byte buffer size (8192, larger than that of ASCIIReader
* since it's reasonable to surmise that the average UCS-4-encoded
- * file should be 4 times as large as the average ASCII-encoded file).
+ * file should be 4 times as large as the average ASCII-encoded file).
*/
public static final int DEFAULT_BUFFER_SIZE = 8192;
@@ -53,10 +55,14 @@
// Data
//
- /** Input stream. */
+ /**
+ * Input stream.
+ */
protected InputStream fInputStream;
- /** Byte buffer. */
+ /**
+ * Byte buffer.
+ */
protected byte[] fBuffer;
// what kind of data we're dealing with
@@ -66,26 +72,26 @@
// Constructors
//
- /**
- * Constructs an ASCII reader from the specified input stream
+ /**
+ * Constructs an ASCII reader from the specified input stream
* using the default buffer size. The Endian-ness and whether this is
* UCS-2 or UCS-4 needs also to be known in advance.
*
* @param inputStream The input stream.
- * @param encoding One of UCS2LE, UCS2BE, UCS4LE or UCS4BE.
+ * @param encoding One of UCS2LE, UCS2BE, UCS4LE or UCS4BE.
*/
public UCSReader(InputStream inputStream, short encoding) {
this(inputStream, DEFAULT_BUFFER_SIZE, encoding);
} // <init>(InputStream, short)
- /**
- * Constructs an ASCII reader from the specified input stream
+ /**
+ * Constructs an ASCII reader from the specified input stream
* and buffer size. The Endian-ness and whether this is
* UCS-2 or UCS-4 needs also to be known in advance.
*
* @param inputStream The input stream.
* @param size The initial buffer size.
- * @param encoding One of UCS2LE, UCS2BE, UCS4LE or UCS4BE.
+ * @param encoding One of UCS2LE, UCS2BE, UCS4LE or UCS4BE.
*/
public UCSReader(InputStream inputStream, int size, short encoding) {
fInputStream = inputStream;
@@ -100,24 +106,23 @@
/**
* Read a single character. This method will block until a character is
* available, an I/O error occurs, or the end of the stream is reached.
- *
+ * <p/>
* <p> Subclasses that intend to support efficient single-character input
* should override this method.
*
- * @return The character read, as an integer in the range 0 to 127
- * (<tt>0x00-0x7f</tt>), or -1 if the end of the stream has
- * been reached
- *
- * @exception IOException If an I/O error occurs
+ * @return The character read, as an integer in the range 0 to 127
+ * (<tt>0x00-0x7f</tt>), or -1 if the end of the stream has
+ * been reached
+ * @throws IOException If an I/O error occurs
*/
- public int read() throws IOException {
+ public int read() throws IOException {
int b0 = fInputStream.read() & 0xff;
if (b0 == 0xff)
return -1;
int b1 = fInputStream.read() & 0xff;
if (b1 == 0xff)
return -1;
- if(fEncoding >=4) {
+ if (fEncoding >= 4) {
int b2 = fInputStream.read() & 0xff;
if (b2 == 0xff)
return -1;
@@ -127,14 +132,14 @@
if (log.isDebugEnabled())
log.debug("b0 is " + (b0 & 0xff) + " b1 " + (b1 & 0xff) + " b2 " + (b2 & 0xff) + " b3 " + (b3 & 0xff));
if (fEncoding == UCS4BE)
- return (b0<<24)+(b1<<16)+(b2<<8)+b3;
+ return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
else
- return (b3<<24)+(b2<<16)+(b1<<8)+b0;
+ return (b3 << 24) + (b2 << 16) + (b1 << 8) + b0;
} else { // UCS-2
if (fEncoding == UCS2BE)
- return (b0<<8)+b1;
+ return (b0 << 8) + b1;
else
- return (b1<<8)+b0;
+ return (b1 << 8) + b0;
}
} // read():int
@@ -143,68 +148,66 @@
* until some input is available, an I/O error occurs, or the end of the
* stream is reached.
*
- * @param ch Destination buffer
- * @param offset Offset at which to start storing characters
- * @param length Maximum number of characters to read
- *
- * @return The number of characters read, or -1 if the end of the
- * stream has been reached
- *
- * @exception IOException If an I/O error occurs
+ * @param ch Destination buffer
+ * @param offset Offset at which to start storing characters
+ * @param length Maximum number of characters to read
+ * @return The number of characters read, or -1 if the end of the
+ * stream has been reached
+ * @throws IOException If an I/O error occurs
*/
public int read(char ch[], int offset, int length) throws IOException {
- int byteLength = length << ((fEncoding >= 4)?2:1);
+ int byteLength = length << ((fEncoding >= 4) ? 2 : 1);
if (byteLength > fBuffer.length) {
byteLength = fBuffer.length;
}
int count = fInputStream.read(fBuffer, 0, byteLength);
- if(count == -1) return -1;
+ if (count == -1) return -1;
// try and make count be a multiple of the number of bytes we're looking for
- if(fEncoding >= 4) { // BigEndian
+ if (fEncoding >= 4) { // BigEndian
// this looks ugly, but it avoids an if at any rate...
int numToRead = (4 - (count & 3) & 3);
- for(int i=0; i<numToRead; i++) {
+ for (int i = 0; i < numToRead; i++) {
int charRead = fInputStream.read();
- if(charRead == -1) { // end of input; something likely went wrong!A Pad buffer with nulls.
- for (int j = i;j<numToRead; j++)
- fBuffer[count+j] = 0;
+ if (charRead == -1) { // end of input; something likely went wrong!A Pad buffer with nulls.
+ for (int j = i; j < numToRead; j++)
+ fBuffer[count + j] = 0;
break;
} else {
- fBuffer[count+i] = (byte)charRead;
+ fBuffer[count + i] = (byte) charRead;
}
}
count += numToRead;
} else {
int numToRead = count & 1;
- if(numToRead != 0) {
+ if (numToRead != 0) {
count++;
int charRead = fInputStream.read();
- if(charRead == -1) { // end of input; something likely went wrong!A Pad buffer with nulls.
+ if (charRead == -1) { // end of input; something likely went wrong!A Pad buffer with nulls.
fBuffer[count] = 0;
} else {
- fBuffer[count] = (byte)charRead;
+ fBuffer[count] = (byte) charRead;
}
}
}
// now count is a multiple of the right number of bytes
- int numChars = count >> ((fEncoding >= 4)?2:1);
+ int numChars = count >> ((fEncoding >= 4) ? 2 : 1);
int curPos = 0;
for (int i = 0; i < numChars; i++) {
int b0 = fBuffer[curPos++] & 0xff;
int b1 = fBuffer[curPos++] & 0xff;
- if(fEncoding >=4) {
+ if (fEncoding >= 4) {
int b2 = fBuffer[curPos++] & 0xff;
int b3 = fBuffer[curPos++] & 0xff;
if (fEncoding == UCS4BE)
- ch[offset+i] = (char)((b0<<24)+(b1<<16)+(b2<<8)+b3);
+ ch[offset + i] = (char) ((b0 << 24) + (b1 << 16) + (b2 << 8) + b3);
else
- ch[offset+i] = (char)((b3<<24)+(b2<<16)+(b1<<8)+b0);
+ ch[offset + i] = (char) ((b3 << 24) + (b2 << 16) + (b1 << 8) + b0);
} else { // UCS-2
if (fEncoding == UCS2BE)
- ch[offset+i] = (char)((b0<<8)+b1);
+ ch[offset + i] = (char) ((b0 << 8) + b1);
else
- ch[offset+i] = (char)((b1<<8)+b0);
+ ch[offset + i] = (char) ((b1 << 8) + b0);
}
}
return numChars;
@@ -214,11 +217,9 @@
* Skip characters. This method will block until some characters are
* available, an I/O error occurs, or the end of the stream is reached.
*
- * @param n The number of characters to skip
- *
- * @return The number of characters actually skipped
- *
- * @exception IOException If an I/O error occurs
+ * @param n The number of characters to skip
+ * @return The number of characters actually skipped
+ * @throws IOException If an I/O error occurs
*/
public long skip(long n) throws IOException {
// charWidth will represent the number of bits to move
@@ -227,9 +228,9 @@
// The trick with &'ing, as with elsewhere in this dcode, is
// intended to avoid an expensive use of / that might not be optimized
// away.
- int charWidth = (fEncoding >=4)?2:1;
- long bytesSkipped = fInputStream.skip(n<<charWidth);
- if((bytesSkipped & (charWidth | 1)) == 0) return bytesSkipped >> charWidth;
+ int charWidth = (fEncoding >= 4) ? 2 : 1;
+ long bytesSkipped = fInputStream.skip(n << charWidth);
+ if ((bytesSkipped & (charWidth | 1)) == 0) return bytesSkipped >> charWidth;
return (bytesSkipped >> charWidth) + 1;
} // skip(long):long
@@ -237,20 +238,19 @@
* Tell whether this stream is ready to be read.
*
* @return True if the next read() is guaranteed not to block for input,
- * false otherwise. Note that returning false does not guarantee that the
- * next read will block.
- *
- * @exception IOException If an I/O error occurs
+ * false otherwise. Note that returning false does not guarantee that the
+ * next read will block.
+ * @throws IOException If an I/O error occurs
*/
public boolean ready() throws IOException {
- return false;
+ return false;
} // ready()
/**
* Tell whether this stream supports the mark() operation.
*/
public boolean markSupported() {
- return fInputStream.markSupported();
+ return fInputStream.markSupported();
} // markSupported()
/**
@@ -258,16 +258,15 @@
* will attempt to reposition the stream to this point. Not all
* character-input streams support the mark() operation.
*
- * @param readAheadLimit Limit on the number of characters that may be
- * read while still preserving the mark. After
- * reading this many characters, attempting to
- * reset the stream may fail.
- *
- * @exception IOException If the stream does not support mark(),
- * or if some other I/O error occurs
+ * @param readAheadLimit Limit on the number of characters that may be
+ * read while still preserving the mark. After
+ * reading this many characters, attempting to
+ * reset the stream may fail.
+ * @throws IOException If the stream does not support mark(),
+ * or if some other I/O error occurs
*/
public void mark(int readAheadLimit) throws IOException {
- fInputStream.mark(readAheadLimit);
+ fInputStream.mark(readAheadLimit);
} // mark(int)
/**
@@ -278,10 +277,10 @@
* character-input streams support the reset() operation, and some support
* reset() without supporting mark().
*
- * @exception IOException If the stream has not been marked,
- * or if the mark has been invalidated,
- * or if the stream does not support reset(),
- * or if some other I/O error occurs
+ * @throws IOException If the stream has not been marked,
+ * or if the mark has been invalidated,
+ * or if the stream does not support reset(),
+ * or if some other I/O error occurs
*/
public void reset() throws IOException {
fInputStream.reset();
@@ -292,10 +291,10 @@
* ready(), mark(), or reset() invocations will throw an IOException.
* Closing a previously-closed stream, however, has no effect.
*
- * @exception IOException If an I/O error occurs
+ * @throws IOException If an I/O error occurs
*/
- public void close() throws IOException {
- fInputStream.close();
- } // close()
+ public void close() throws IOException {
+ fInputStream.close();
+ } // close()
} // class UCSReader
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UTF8Reader.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UTF8Reader.java
index 361e99a..78ab1b8 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UTF8Reader.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/UTF8Reader.java
@@ -17,6 +17,8 @@
package org.apache.struts2.jasper.xmlparser;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
import org.apache.struts2.jasper.compiler.Localizer;
import java.io.IOException;
@@ -26,49 +28,59 @@
/**
* @author Andy Clark, IBM
- *
* @version $Id: UTF8Reader.java 466606 2006-10-21 23:07:12Z markt $
*/
public class UTF8Reader
- extends Reader {
+ extends Reader {
- private org.apache.commons.logging.Log log=
- org.apache.commons.logging.LogFactory.getLog( UTF8Reader.class );
-
+ private Logger log = LoggerFactory.getLogger(UTF8Reader.class);
+
//
// Constants
//
- /** Default byte buffer size (2048). */
+ /**
+ * Default byte buffer size (2048).
+ */
public static final int DEFAULT_BUFFER_SIZE = 2048;
// debugging
- /** Debug read. */
+ /**
+ * Debug read.
+ */
private static final boolean DEBUG_READ = false;
//
// Data
//
- /** Input stream. */
+ /**
+ * Input stream.
+ */
protected InputStream fInputStream;
- /** Byte buffer. */
+ /**
+ * Byte buffer.
+ */
protected byte[] fBuffer;
- /** Offset into buffer. */
+ /**
+ * Offset into buffer.
+ */
protected int fOffset;
- /** Surrogate character. */
+ /**
+ * Surrogate character.
+ */
private int fSurrogate = -1;
//
// Constructors
//
- /**
- * Constructs a UTF-8 reader from the specified input stream,
+ /**
+ * Constructs a UTF-8 reader from the specified input stream,
* buffer size and MessageFormatter.
*
* @param inputStream The input stream.
@@ -86,15 +98,14 @@
/**
* Read a single character. This method will block until a character is
* available, an I/O error occurs, or the end of the stream is reached.
- *
+ * <p/>
* <p> Subclasses that intend to support efficient single-character input
* should override this method.
*
- * @return The character read, as an integer in the range 0 to 16383
- * (<tt>0x00-0xffff</tt>), or -1 if the end of the stream has
- * been reached
- *
- * @exception IOException If an I/O error occurs
+ * @return The character read, as an integer in the range 0 to 16383
+ * (<tt>0x00-0xffff</tt>), or -1 if the end of the stream has
+ * been reached
+ * @throws IOException If an I/O error occurs
*/
public int read() throws IOException {
@@ -106,8 +117,8 @@
int index = 0;
// get first byte
- int b0 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ int b0 = index == fOffset
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b0 == -1) {
return -1;
}
@@ -115,14 +126,14 @@
// UTF-8: [0xxx xxxx]
// Unicode: [0000 0000] [0xxx xxxx]
if (b0 < 0x80) {
- c = (char)b0;
+ c = (char) b0;
}
// UTF-8: [110y yyyy] [10xx xxxx]
// Unicode: [0000 0yyy] [yyxx xxxx]
else if ((b0 & 0xE0) == 0xC0) {
- int b1 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ int b1 = index == fOffset
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b1 == -1) {
expectedByte(2, 2);
}
@@ -136,15 +147,15 @@
// Unicode: [zzzz yyyy] [yyxx xxxx]
else if ((b0 & 0xF0) == 0xE0) {
int b1 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b1 == -1) {
expectedByte(2, 3);
}
if ((b1 & 0xC0) != 0x80) {
invalidByte(2, 3, b1);
}
- int b2 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ int b2 = index == fOffset
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b2 == -1) {
expectedByte(3, 3);
}
@@ -152,7 +163,7 @@
invalidByte(3, 3, b2);
}
c = ((b0 << 12) & 0xF000) | ((b1 << 6) & 0x0FC0) |
- (b2 & 0x003F);
+ (b2 & 0x003F);
}
// UTF-8: [1111 0uuu] [10uu zzzz] [10yy yyyy] [10xx xxxx]*
@@ -160,24 +171,24 @@
// [1101 11yy] [yyxx xxxx] (low surrogate)
// * uuuuu = wwww + 1
else if ((b0 & 0xF8) == 0xF0) {
- int b1 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ int b1 = index == fOffset
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b1 == -1) {
expectedByte(2, 4);
}
if ((b1 & 0xC0) != 0x80) {
invalidByte(2, 3, b1);
}
- int b2 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ int b2 = index == fOffset
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b2 == -1) {
expectedByte(3, 4);
}
if ((b2 & 0xC0) != 0x80) {
invalidByte(3, 3, b2);
}
- int b3 = index == fOffset
- ? fInputStream.read() : fBuffer[index++] & 0x00FF;
+ int b3 = index == fOffset
+ ? fInputStream.read() : fBuffer[index++] & 0x00FF;
if (b3 == -1) {
expectedByte(4, 4);
}
@@ -189,9 +200,9 @@
invalidSurrogate(uuuuu);
}
int wwww = uuuuu - 1;
- int hs = 0xD800 |
- ((wwww << 6) & 0x03C0) | ((b1 << 2) & 0x003C) |
- ((b2 >> 4) & 0x0003);
+ int hs = 0xD800 |
+ ((wwww << 6) & 0x03C0) | ((b1 << 2) & 0x003C) |
+ ((b2 >> 4) & 0x0003);
int ls = 0xDC00 | ((b2 << 6) & 0x03C0) | (b3 & 0x003F);
c = hs;
fSurrogate = ls;
@@ -211,7 +222,7 @@
// return character
if (DEBUG_READ) {
if (log.isDebugEnabled())
- log.debug("read(): 0x"+Integer.toHexString(c));
+ log.debug("read(): 0x" + Integer.toHexString(c));
}
return c;
@@ -222,21 +233,19 @@
* until some input is available, an I/O error occurs, or the end of the
* stream is reached.
*
- * @param ch Destination buffer
- * @param offset Offset at which to start storing characters
- * @param length Maximum number of characters to read
- *
- * @return The number of characters read, or -1 if the end of the
- * stream has been reached
- *
- * @exception IOException If an I/O error occurs
+ * @param ch Destination buffer
+ * @param offset Offset at which to start storing characters
+ * @param length Maximum number of characters to read
+ * @return The number of characters read, or -1 if the end of the
+ * stream has been reached
+ * @throws IOException If an I/O error occurs
*/
public int read(char ch[], int offset, int length) throws IOException {
// handle surrogate
int out = offset;
if (fSurrogate != -1) {
- ch[offset + 1] = (char)fSurrogate;
+ ch[offset + 1] = (char) fSurrogate;
fSurrogate = -1;
length--;
out++;
@@ -278,7 +287,7 @@
// UTF-8: [0xxx xxxx]
// Unicode: [0000 0000] [0xxx xxxx]
if (b0 < 0x80) {
- ch[out++] = (char)b0;
+ ch[out++] = (char) b0;
continue;
}
@@ -286,14 +295,13 @@
// Unicode: [0000 0yyy] [yyxx xxxx]
if ((b0 & 0xE0) == 0xC0) {
int b1 = -1;
- if (++in < total) {
- b1 = fBuffer[in] & 0x00FF;
- }
- else {
+ if (++in < total) {
+ b1 = fBuffer[in] & 0x00FF;
+ } else {
b1 = fInputStream.read();
if (b1 == -1) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
+ fBuffer[0] = (byte) b0;
fOffset = 1;
return out - offset;
}
@@ -303,15 +311,15 @@
}
if ((b1 & 0xC0) != 0x80) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
fOffset = 2;
return out - offset;
}
invalidByte(2, 2, b1);
}
int c = ((b0 << 6) & 0x07C0) | (b1 & 0x003F);
- ch[out++] = (char)c;
+ ch[out++] = (char) c;
count -= 1;
continue;
}
@@ -320,14 +328,13 @@
// Unicode: [zzzz yyyy] [yyxx xxxx]
if ((b0 & 0xF0) == 0xE0) {
int b1 = -1;
- if (++in < total) {
- b1 = fBuffer[in] & 0x00FF;
- }
- else {
+ if (++in < total) {
+ b1 = fBuffer[in] & 0x00FF;
+ } else {
b1 = fInputStream.read();
if (b1 == -1) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
+ fBuffer[0] = (byte) b0;
fOffset = 1;
return out - offset;
}
@@ -337,23 +344,22 @@
}
if ((b1 & 0xC0) != 0x80) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
fOffset = 2;
return out - offset;
}
invalidByte(2, 3, b1);
}
int b2 = -1;
- if (++in < total) {
- b2 = fBuffer[in] & 0x00FF;
- }
- else {
+ if (++in < total) {
+ b2 = fBuffer[in] & 0x00FF;
+ } else {
b2 = fInputStream.read();
if (b2 == -1) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
fOffset = 2;
return out - offset;
}
@@ -363,9 +369,9 @@
}
if ((b2 & 0xC0) != 0x80) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
- fBuffer[2] = (byte)b2;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
+ fBuffer[2] = (byte) b2;
fOffset = 3;
return out - offset;
}
@@ -373,7 +379,7 @@
}
int c = ((b0 << 12) & 0xF000) | ((b1 << 6) & 0x0FC0) |
(b2 & 0x003F);
- ch[out++] = (char)c;
+ ch[out++] = (char) c;
count -= 2;
continue;
}
@@ -384,14 +390,13 @@
// * uuuuu = wwww + 1
if ((b0 & 0xF8) == 0xF0) {
int b1 = -1;
- if (++in < total) {
- b1 = fBuffer[in] & 0x00FF;
- }
- else {
+ if (++in < total) {
+ b1 = fBuffer[in] & 0x00FF;
+ } else {
b1 = fInputStream.read();
if (b1 == -1) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
+ fBuffer[0] = (byte) b0;
fOffset = 1;
return out - offset;
}
@@ -401,23 +406,22 @@
}
if ((b1 & 0xC0) != 0x80) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
fOffset = 2;
return out - offset;
}
invalidByte(2, 4, b1);
}
int b2 = -1;
- if (++in < total) {
- b2 = fBuffer[in] & 0x00FF;
- }
- else {
+ if (++in < total) {
+ b2 = fBuffer[in] & 0x00FF;
+ } else {
b2 = fInputStream.read();
if (b2 == -1) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
fOffset = 2;
return out - offset;
}
@@ -427,25 +431,24 @@
}
if ((b2 & 0xC0) != 0x80) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
- fBuffer[2] = (byte)b2;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
+ fBuffer[2] = (byte) b2;
fOffset = 3;
return out - offset;
}
invalidByte(3, 4, b2);
}
int b3 = -1;
- if (++in < total) {
- b3 = fBuffer[in] & 0x00FF;
- }
- else {
+ if (++in < total) {
+ b3 = fBuffer[in] & 0x00FF;
+ } else {
b3 = fInputStream.read();
if (b3 == -1) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
- fBuffer[2] = (byte)b2;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
+ fBuffer[2] = (byte) b2;
fOffset = 3;
return out - offset;
}
@@ -455,10 +458,10 @@
}
if ((b3 & 0xC0) != 0x80) {
if (out > offset) {
- fBuffer[0] = (byte)b0;
- fBuffer[1] = (byte)b1;
- fBuffer[2] = (byte)b2;
- fBuffer[3] = (byte)b3;
+ fBuffer[0] = (byte) b0;
+ fBuffer[1] = (byte) b1;
+ fBuffer[2] = (byte) b2;
+ fBuffer[3] = (byte) b3;
fOffset = 4;
return out - offset;
}
@@ -478,15 +481,15 @@
int ls = 0xDC00 | ((yyyyyy << 6) & 0x03C0) | xxxxxx;
// set characters
- ch[out++] = (char)hs;
- ch[out++] = (char)ls;
+ ch[out++] = (char) hs;
+ ch[out++] = (char) ls;
count -= 2;
continue;
}
// error
if (out > offset) {
- fBuffer[0] = (byte)b0;
+ fBuffer[0] = (byte) b0;
fOffset = 1;
return out - offset;
}
@@ -496,7 +499,7 @@
// return number of characters converted
if (DEBUG_READ) {
if (log.isDebugEnabled())
- log.debug("read(char[],"+offset+','+length+"): count="+count);
+ log.debug("read(char[]," + offset + ',' + length + "): count=" + count);
}
return count;
@@ -506,23 +509,20 @@
* Skip characters. This method will block until some characters are
* available, an I/O error occurs, or the end of the stream is reached.
*
- * @param n The number of characters to skip
- *
- * @return The number of characters actually skipped
- *
- * @exception IOException If an I/O error occurs
+ * @param n The number of characters to skip
+ * @return The number of characters actually skipped
+ * @throws IOException If an I/O error occurs
*/
public long skip(long n) throws IOException {
long remaining = n;
final char[] ch = new char[fBuffer.length];
do {
- int length = ch.length < remaining ? ch.length : (int)remaining;
+ int length = ch.length < remaining ? ch.length : (int) remaining;
int count = read(ch, 0, length);
if (count > 0) {
remaining -= count;
- }
- else {
+ } else {
break;
}
} while (remaining > 0);
@@ -536,20 +536,19 @@
* Tell whether this stream is ready to be read.
*
* @return True if the next read() is guaranteed not to block for input,
- * false otherwise. Note that returning false does not guarantee that the
- * next read will block.
- *
- * @exception IOException If an I/O error occurs
+ * false otherwise. Note that returning false does not guarantee that the
+ * next read will block.
+ * @throws IOException If an I/O error occurs
*/
public boolean ready() throws IOException {
- return false;
+ return false;
} // ready()
/**
* Tell whether this stream supports the mark() operation.
*/
public boolean markSupported() {
- return false;
+ return false;
} // markSupported()
/**
@@ -557,18 +556,17 @@
* will attempt to reposition the stream to this point. Not all
* character-input streams support the mark() operation.
*
- * @param readAheadLimit Limit on the number of characters that may be
- * read while still preserving the mark. After
- * reading this many characters, attempting to
- * reset the stream may fail.
- *
- * @exception IOException If the stream does not support mark(),
- * or if some other I/O error occurs
+ * @param readAheadLimit Limit on the number of characters that may be
+ * read while still preserving the mark. After
+ * reading this many characters, attempting to
+ * reset the stream may fail.
+ * @throws IOException If the stream does not support mark(),
+ * or if some other I/O error occurs
*/
public void mark(int readAheadLimit) throws IOException {
- throw new IOException(
+ throw new IOException(
Localizer.getMessage("jsp.error.xml.operationNotSupported",
- "mark()", "UTF-8"));
+ "mark()", "UTF-8"));
}
/**
@@ -579,10 +577,10 @@
* character-input streams support the reset() operation, and some support
* reset() without supporting mark().
*
- * @exception IOException If the stream has not been marked,
- * or if the mark has been invalidated,
- * or if the stream does not support reset(),
- * or if some other I/O error occurs
+ * @throws IOException If the stream has not been marked,
+ * or if the mark has been invalidated,
+ * or if the stream does not support reset(),
+ * or if some other I/O error occurs
*/
public void reset() throws IOException {
fOffset = 0;
@@ -594,7 +592,7 @@
* ready(), mark(), or reset() invocations will throw an IOException.
* Closing a previously-closed stream, however, has no effect.
*
- * @exception IOException If an I/O error occurs
+ * @throws IOException If an I/O error occurs
*/
public void close() throws IOException {
fInputStream.close();
@@ -604,33 +602,39 @@
// Private methods
//
- /** Throws an exception for expected byte. */
+ /**
+ * Throws an exception for expected byte.
+ */
private void expectedByte(int position, int count)
- throws UTFDataFormatException {
+ throws UTFDataFormatException {
throw new UTFDataFormatException(
Localizer.getMessage("jsp.error.xml.expectedByte",
- Integer.toString(position),
- Integer.toString(count)));
+ Integer.toString(position),
+ Integer.toString(count)));
} // expectedByte(int,int,int)
- /** Throws an exception for invalid byte. */
- private void invalidByte(int position, int count, int c)
- throws UTFDataFormatException {
+ /**
+ * Throws an exception for invalid byte.
+ */
+ private void invalidByte(int position, int count, int c)
+ throws UTFDataFormatException {
throw new UTFDataFormatException(
Localizer.getMessage("jsp.error.xml.invalidByte",
- Integer.toString(position),
- Integer.toString(count)));
+ Integer.toString(position),
+ Integer.toString(count)));
} // invalidByte(int,int,int,int)
- /** Throws an exception for invalid surrogate bits. */
+ /**
+ * Throws an exception for invalid surrogate bits.
+ */
private void invalidSurrogate(int uuuuu) throws UTFDataFormatException {
-
+
throw new UTFDataFormatException(
Localizer.getMessage("jsp.error.xml.invalidHighSurrogate",
- Integer.toHexString(uuuuu)));
+ Integer.toHexString(uuuuu)));
} // invalidSurrogate(int)
} // class UTF8Reader
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLChar.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLChar.java
index 19cdc70..266cca6 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLChar.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLChar.java
@@ -32,7 +32,7 @@
* in this class can be used to verify that a character is a valid
* XML character or if the character is a space, name start, or name
* character.
- * <p>
+ * <p/>
* A series of convenience methods are supplied to ease the burden
* of the developer. Because inlining the checks can improve per
* character performance, the tables of character properties are
@@ -48,7 +48,6 @@
* @author Arnaud Le Hors, IBM
* @author Michael Glavassevich, IBM
* @author Rahul Srivastava, Sun Microsystems Inc.
- *
* @version $Id: XMLChar.java 466606 2006-10-21 23:07:12Z markt $
*/
public class XMLChar {
@@ -57,38 +56,54 @@
// Constants
//
- /** Character flags. */
+ /**
+ * Character flags.
+ */
private static final byte[] CHARS = new byte[1 << 16];
- /** Valid character mask. */
+ /**
+ * Valid character mask.
+ */
public static final int MASK_VALID = 0x01;
- /** Space character mask. */
+ /**
+ * Space character mask.
+ */
public static final int MASK_SPACE = 0x02;
- /** Name start character mask. */
+ /**
+ * Name start character mask.
+ */
public static final int MASK_NAME_START = 0x04;
- /** Name character mask. */
+ /**
+ * Name character mask.
+ */
public static final int MASK_NAME = 0x08;
- /** Pubid character mask. */
+ /**
+ * Pubid character mask.
+ */
public static final int MASK_PUBID = 0x10;
-
- /**
+
+ /**
* Content character mask. Special characters are those that can
- * be considered the start of markup, such as '<' and '&'.
+ * be considered the start of markup, such as '<' and '&'.
* The various newline characters are considered special as well.
* All other valid XML characters can be considered content.
- * <p>
+ * <p/>
* This is an optimization for the inner loop of character scanning.
*/
public static final int MASK_CONTENT = 0x20;
- /** NCName start character mask. */
+ /**
+ * NCName start character mask.
+ */
public static final int MASK_NCNAME_START = 0x40;
- /** NCName character mask. */
+ /**
+ * NCName character mask.
+ */
public static final int MASK_NCNAME = 0x80;
//
@@ -96,80 +111,80 @@
//
static {
-
+
// Initializing the Character Flag Array
// Code generated by: XMLCharGenerator.
-
+
CHARS[9] = 35;
CHARS[10] = 19;
CHARS[13] = 19;
CHARS[32] = 51;
CHARS[33] = 49;
CHARS[34] = 33;
- Arrays.fill(CHARS, 35, 38, (byte) 49 ); // Fill 3 of value (byte) 49
+ Arrays.fill(CHARS, 35, 38, (byte) 49); // Fill 3 of value (byte) 49
CHARS[38] = 1;
- Arrays.fill(CHARS, 39, 45, (byte) 49 ); // Fill 6 of value (byte) 49
- Arrays.fill(CHARS, 45, 47, (byte) -71 ); // Fill 2 of value (byte) -71
+ Arrays.fill(CHARS, 39, 45, (byte) 49); // Fill 6 of value (byte) 49
+ Arrays.fill(CHARS, 45, 47, (byte) -71); // Fill 2 of value (byte) -71
CHARS[47] = 49;
- Arrays.fill(CHARS, 48, 58, (byte) -71 ); // Fill 10 of value (byte) -71
+ Arrays.fill(CHARS, 48, 58, (byte) -71); // Fill 10 of value (byte) -71
CHARS[58] = 61;
CHARS[59] = 49;
CHARS[60] = 1;
CHARS[61] = 49;
CHARS[62] = 33;
- Arrays.fill(CHARS, 63, 65, (byte) 49 ); // Fill 2 of value (byte) 49
- Arrays.fill(CHARS, 65, 91, (byte) -3 ); // Fill 26 of value (byte) -3
- Arrays.fill(CHARS, 91, 93, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 63, 65, (byte) 49); // Fill 2 of value (byte) 49
+ Arrays.fill(CHARS, 65, 91, (byte) -3); // Fill 26 of value (byte) -3
+ Arrays.fill(CHARS, 91, 93, (byte) 33); // Fill 2 of value (byte) 33
CHARS[93] = 1;
CHARS[94] = 33;
CHARS[95] = -3;
CHARS[96] = 33;
- Arrays.fill(CHARS, 97, 123, (byte) -3 ); // Fill 26 of value (byte) -3
- Arrays.fill(CHARS, 123, 183, (byte) 33 ); // Fill 60 of value (byte) 33
+ Arrays.fill(CHARS, 97, 123, (byte) -3); // Fill 26 of value (byte) -3
+ Arrays.fill(CHARS, 123, 183, (byte) 33); // Fill 60 of value (byte) 33
CHARS[183] = -87;
- Arrays.fill(CHARS, 184, 192, (byte) 33 ); // Fill 8 of value (byte) 33
- Arrays.fill(CHARS, 192, 215, (byte) -19 ); // Fill 23 of value (byte) -19
+ Arrays.fill(CHARS, 184, 192, (byte) 33); // Fill 8 of value (byte) 33
+ Arrays.fill(CHARS, 192, 215, (byte) -19); // Fill 23 of value (byte) -19
CHARS[215] = 33;
- Arrays.fill(CHARS, 216, 247, (byte) -19 ); // Fill 31 of value (byte) -19
+ Arrays.fill(CHARS, 216, 247, (byte) -19); // Fill 31 of value (byte) -19
CHARS[247] = 33;
- Arrays.fill(CHARS, 248, 306, (byte) -19 ); // Fill 58 of value (byte) -19
- Arrays.fill(CHARS, 306, 308, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 308, 319, (byte) -19 ); // Fill 11 of value (byte) -19
- Arrays.fill(CHARS, 319, 321, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 321, 329, (byte) -19 ); // Fill 8 of value (byte) -19
+ Arrays.fill(CHARS, 248, 306, (byte) -19); // Fill 58 of value (byte) -19
+ Arrays.fill(CHARS, 306, 308, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 308, 319, (byte) -19); // Fill 11 of value (byte) -19
+ Arrays.fill(CHARS, 319, 321, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 321, 329, (byte) -19); // Fill 8 of value (byte) -19
CHARS[329] = 33;
- Arrays.fill(CHARS, 330, 383, (byte) -19 ); // Fill 53 of value (byte) -19
+ Arrays.fill(CHARS, 330, 383, (byte) -19); // Fill 53 of value (byte) -19
CHARS[383] = 33;
- Arrays.fill(CHARS, 384, 452, (byte) -19 ); // Fill 68 of value (byte) -19
- Arrays.fill(CHARS, 452, 461, (byte) 33 ); // Fill 9 of value (byte) 33
- Arrays.fill(CHARS, 461, 497, (byte) -19 ); // Fill 36 of value (byte) -19
- Arrays.fill(CHARS, 497, 500, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 500, 502, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 502, 506, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 506, 536, (byte) -19 ); // Fill 30 of value (byte) -19
- Arrays.fill(CHARS, 536, 592, (byte) 33 ); // Fill 56 of value (byte) 33
- Arrays.fill(CHARS, 592, 681, (byte) -19 ); // Fill 89 of value (byte) -19
- Arrays.fill(CHARS, 681, 699, (byte) 33 ); // Fill 18 of value (byte) 33
- Arrays.fill(CHARS, 699, 706, (byte) -19 ); // Fill 7 of value (byte) -19
- Arrays.fill(CHARS, 706, 720, (byte) 33 ); // Fill 14 of value (byte) 33
- Arrays.fill(CHARS, 720, 722, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 722, 768, (byte) 33 ); // Fill 46 of value (byte) 33
- Arrays.fill(CHARS, 768, 838, (byte) -87 ); // Fill 70 of value (byte) -87
- Arrays.fill(CHARS, 838, 864, (byte) 33 ); // Fill 26 of value (byte) 33
- Arrays.fill(CHARS, 864, 866, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 866, 902, (byte) 33 ); // Fill 36 of value (byte) 33
+ Arrays.fill(CHARS, 384, 452, (byte) -19); // Fill 68 of value (byte) -19
+ Arrays.fill(CHARS, 452, 461, (byte) 33); // Fill 9 of value (byte) 33
+ Arrays.fill(CHARS, 461, 497, (byte) -19); // Fill 36 of value (byte) -19
+ Arrays.fill(CHARS, 497, 500, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 500, 502, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 502, 506, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 506, 536, (byte) -19); // Fill 30 of value (byte) -19
+ Arrays.fill(CHARS, 536, 592, (byte) 33); // Fill 56 of value (byte) 33
+ Arrays.fill(CHARS, 592, 681, (byte) -19); // Fill 89 of value (byte) -19
+ Arrays.fill(CHARS, 681, 699, (byte) 33); // Fill 18 of value (byte) 33
+ Arrays.fill(CHARS, 699, 706, (byte) -19); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 706, 720, (byte) 33); // Fill 14 of value (byte) 33
+ Arrays.fill(CHARS, 720, 722, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 722, 768, (byte) 33); // Fill 46 of value (byte) 33
+ Arrays.fill(CHARS, 768, 838, (byte) -87); // Fill 70 of value (byte) -87
+ Arrays.fill(CHARS, 838, 864, (byte) 33); // Fill 26 of value (byte) 33
+ Arrays.fill(CHARS, 864, 866, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 866, 902, (byte) 33); // Fill 36 of value (byte) 33
CHARS[902] = -19;
CHARS[903] = -87;
- Arrays.fill(CHARS, 904, 907, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 904, 907, (byte) -19); // Fill 3 of value (byte) -19
CHARS[907] = 33;
CHARS[908] = -19;
CHARS[909] = 33;
- Arrays.fill(CHARS, 910, 930, (byte) -19 ); // Fill 20 of value (byte) -19
+ Arrays.fill(CHARS, 910, 930, (byte) -19); // Fill 20 of value (byte) -19
CHARS[930] = 33;
- Arrays.fill(CHARS, 931, 975, (byte) -19 ); // Fill 44 of value (byte) -19
+ Arrays.fill(CHARS, 931, 975, (byte) -19); // Fill 44 of value (byte) -19
CHARS[975] = 33;
- Arrays.fill(CHARS, 976, 983, (byte) -19 ); // Fill 7 of value (byte) -19
- Arrays.fill(CHARS, 983, 986, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 976, 983, (byte) -19); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 983, 986, (byte) 33); // Fill 3 of value (byte) 33
CHARS[986] = -19;
CHARS[987] = 33;
CHARS[988] = -19;
@@ -178,432 +193,432 @@
CHARS[991] = 33;
CHARS[992] = -19;
CHARS[993] = 33;
- Arrays.fill(CHARS, 994, 1012, (byte) -19 ); // Fill 18 of value (byte) -19
- Arrays.fill(CHARS, 1012, 1025, (byte) 33 ); // Fill 13 of value (byte) 33
- Arrays.fill(CHARS, 1025, 1037, (byte) -19 ); // Fill 12 of value (byte) -19
+ Arrays.fill(CHARS, 994, 1012, (byte) -19); // Fill 18 of value (byte) -19
+ Arrays.fill(CHARS, 1012, 1025, (byte) 33); // Fill 13 of value (byte) 33
+ Arrays.fill(CHARS, 1025, 1037, (byte) -19); // Fill 12 of value (byte) -19
CHARS[1037] = 33;
- Arrays.fill(CHARS, 1038, 1104, (byte) -19 ); // Fill 66 of value (byte) -19
+ Arrays.fill(CHARS, 1038, 1104, (byte) -19); // Fill 66 of value (byte) -19
CHARS[1104] = 33;
- Arrays.fill(CHARS, 1105, 1117, (byte) -19 ); // Fill 12 of value (byte) -19
+ Arrays.fill(CHARS, 1105, 1117, (byte) -19); // Fill 12 of value (byte) -19
CHARS[1117] = 33;
- Arrays.fill(CHARS, 1118, 1154, (byte) -19 ); // Fill 36 of value (byte) -19
+ Arrays.fill(CHARS, 1118, 1154, (byte) -19); // Fill 36 of value (byte) -19
CHARS[1154] = 33;
- Arrays.fill(CHARS, 1155, 1159, (byte) -87 ); // Fill 4 of value (byte) -87
- Arrays.fill(CHARS, 1159, 1168, (byte) 33 ); // Fill 9 of value (byte) 33
- Arrays.fill(CHARS, 1168, 1221, (byte) -19 ); // Fill 53 of value (byte) -19
- Arrays.fill(CHARS, 1221, 1223, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 1223, 1225, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 1225, 1227, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 1227, 1229, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 1229, 1232, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 1232, 1260, (byte) -19 ); // Fill 28 of value (byte) -19
- Arrays.fill(CHARS, 1260, 1262, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 1262, 1270, (byte) -19 ); // Fill 8 of value (byte) -19
- Arrays.fill(CHARS, 1270, 1272, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 1272, 1274, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 1274, 1329, (byte) 33 ); // Fill 55 of value (byte) 33
- Arrays.fill(CHARS, 1329, 1367, (byte) -19 ); // Fill 38 of value (byte) -19
- Arrays.fill(CHARS, 1367, 1369, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 1155, 1159, (byte) -87); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 1159, 1168, (byte) 33); // Fill 9 of value (byte) 33
+ Arrays.fill(CHARS, 1168, 1221, (byte) -19); // Fill 53 of value (byte) -19
+ Arrays.fill(CHARS, 1221, 1223, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 1223, 1225, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 1225, 1227, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 1227, 1229, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 1229, 1232, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 1232, 1260, (byte) -19); // Fill 28 of value (byte) -19
+ Arrays.fill(CHARS, 1260, 1262, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 1262, 1270, (byte) -19); // Fill 8 of value (byte) -19
+ Arrays.fill(CHARS, 1270, 1272, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 1272, 1274, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 1274, 1329, (byte) 33); // Fill 55 of value (byte) 33
+ Arrays.fill(CHARS, 1329, 1367, (byte) -19); // Fill 38 of value (byte) -19
+ Arrays.fill(CHARS, 1367, 1369, (byte) 33); // Fill 2 of value (byte) 33
CHARS[1369] = -19;
- Arrays.fill(CHARS, 1370, 1377, (byte) 33 ); // Fill 7 of value (byte) 33
- Arrays.fill(CHARS, 1377, 1415, (byte) -19 ); // Fill 38 of value (byte) -19
- Arrays.fill(CHARS, 1415, 1425, (byte) 33 ); // Fill 10 of value (byte) 33
- Arrays.fill(CHARS, 1425, 1442, (byte) -87 ); // Fill 17 of value (byte) -87
+ Arrays.fill(CHARS, 1370, 1377, (byte) 33); // Fill 7 of value (byte) 33
+ Arrays.fill(CHARS, 1377, 1415, (byte) -19); // Fill 38 of value (byte) -19
+ Arrays.fill(CHARS, 1415, 1425, (byte) 33); // Fill 10 of value (byte) 33
+ Arrays.fill(CHARS, 1425, 1442, (byte) -87); // Fill 17 of value (byte) -87
CHARS[1442] = 33;
- Arrays.fill(CHARS, 1443, 1466, (byte) -87 ); // Fill 23 of value (byte) -87
+ Arrays.fill(CHARS, 1443, 1466, (byte) -87); // Fill 23 of value (byte) -87
CHARS[1466] = 33;
- Arrays.fill(CHARS, 1467, 1470, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 1467, 1470, (byte) -87); // Fill 3 of value (byte) -87
CHARS[1470] = 33;
CHARS[1471] = -87;
CHARS[1472] = 33;
- Arrays.fill(CHARS, 1473, 1475, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 1473, 1475, (byte) -87); // Fill 2 of value (byte) -87
CHARS[1475] = 33;
CHARS[1476] = -87;
- Arrays.fill(CHARS, 1477, 1488, (byte) 33 ); // Fill 11 of value (byte) 33
- Arrays.fill(CHARS, 1488, 1515, (byte) -19 ); // Fill 27 of value (byte) -19
- Arrays.fill(CHARS, 1515, 1520, (byte) 33 ); // Fill 5 of value (byte) 33
- Arrays.fill(CHARS, 1520, 1523, (byte) -19 ); // Fill 3 of value (byte) -19
- Arrays.fill(CHARS, 1523, 1569, (byte) 33 ); // Fill 46 of value (byte) 33
- Arrays.fill(CHARS, 1569, 1595, (byte) -19 ); // Fill 26 of value (byte) -19
- Arrays.fill(CHARS, 1595, 1600, (byte) 33 ); // Fill 5 of value (byte) 33
+ Arrays.fill(CHARS, 1477, 1488, (byte) 33); // Fill 11 of value (byte) 33
+ Arrays.fill(CHARS, 1488, 1515, (byte) -19); // Fill 27 of value (byte) -19
+ Arrays.fill(CHARS, 1515, 1520, (byte) 33); // Fill 5 of value (byte) 33
+ Arrays.fill(CHARS, 1520, 1523, (byte) -19); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 1523, 1569, (byte) 33); // Fill 46 of value (byte) 33
+ Arrays.fill(CHARS, 1569, 1595, (byte) -19); // Fill 26 of value (byte) -19
+ Arrays.fill(CHARS, 1595, 1600, (byte) 33); // Fill 5 of value (byte) 33
CHARS[1600] = -87;
- Arrays.fill(CHARS, 1601, 1611, (byte) -19 ); // Fill 10 of value (byte) -19
- Arrays.fill(CHARS, 1611, 1619, (byte) -87 ); // Fill 8 of value (byte) -87
- Arrays.fill(CHARS, 1619, 1632, (byte) 33 ); // Fill 13 of value (byte) 33
- Arrays.fill(CHARS, 1632, 1642, (byte) -87 ); // Fill 10 of value (byte) -87
- Arrays.fill(CHARS, 1642, 1648, (byte) 33 ); // Fill 6 of value (byte) 33
+ Arrays.fill(CHARS, 1601, 1611, (byte) -19); // Fill 10 of value (byte) -19
+ Arrays.fill(CHARS, 1611, 1619, (byte) -87); // Fill 8 of value (byte) -87
+ Arrays.fill(CHARS, 1619, 1632, (byte) 33); // Fill 13 of value (byte) 33
+ Arrays.fill(CHARS, 1632, 1642, (byte) -87); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 1642, 1648, (byte) 33); // Fill 6 of value (byte) 33
CHARS[1648] = -87;
- Arrays.fill(CHARS, 1649, 1720, (byte) -19 ); // Fill 71 of value (byte) -19
- Arrays.fill(CHARS, 1720, 1722, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 1722, 1727, (byte) -19 ); // Fill 5 of value (byte) -19
+ Arrays.fill(CHARS, 1649, 1720, (byte) -19); // Fill 71 of value (byte) -19
+ Arrays.fill(CHARS, 1720, 1722, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 1722, 1727, (byte) -19); // Fill 5 of value (byte) -19
CHARS[1727] = 33;
- Arrays.fill(CHARS, 1728, 1743, (byte) -19 ); // Fill 15 of value (byte) -19
+ Arrays.fill(CHARS, 1728, 1743, (byte) -19); // Fill 15 of value (byte) -19
CHARS[1743] = 33;
- Arrays.fill(CHARS, 1744, 1748, (byte) -19 ); // Fill 4 of value (byte) -19
+ Arrays.fill(CHARS, 1744, 1748, (byte) -19); // Fill 4 of value (byte) -19
CHARS[1748] = 33;
CHARS[1749] = -19;
- Arrays.fill(CHARS, 1750, 1765, (byte) -87 ); // Fill 15 of value (byte) -87
- Arrays.fill(CHARS, 1765, 1767, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 1767, 1769, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 1750, 1765, (byte) -87); // Fill 15 of value (byte) -87
+ Arrays.fill(CHARS, 1765, 1767, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 1767, 1769, (byte) -87); // Fill 2 of value (byte) -87
CHARS[1769] = 33;
- Arrays.fill(CHARS, 1770, 1774, (byte) -87 ); // Fill 4 of value (byte) -87
- Arrays.fill(CHARS, 1774, 1776, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 1776, 1786, (byte) -87 ); // Fill 10 of value (byte) -87
- Arrays.fill(CHARS, 1786, 2305, (byte) 33 ); // Fill 519 of value (byte) 33
- Arrays.fill(CHARS, 2305, 2308, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 1770, 1774, (byte) -87); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 1774, 1776, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 1776, 1786, (byte) -87); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 1786, 2305, (byte) 33); // Fill 519 of value (byte) 33
+ Arrays.fill(CHARS, 2305, 2308, (byte) -87); // Fill 3 of value (byte) -87
CHARS[2308] = 33;
- Arrays.fill(CHARS, 2309, 2362, (byte) -19 ); // Fill 53 of value (byte) -19
- Arrays.fill(CHARS, 2362, 2364, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2309, 2362, (byte) -19); // Fill 53 of value (byte) -19
+ Arrays.fill(CHARS, 2362, 2364, (byte) 33); // Fill 2 of value (byte) 33
CHARS[2364] = -87;
CHARS[2365] = -19;
- Arrays.fill(CHARS, 2366, 2382, (byte) -87 ); // Fill 16 of value (byte) -87
- Arrays.fill(CHARS, 2382, 2385, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 2385, 2389, (byte) -87 ); // Fill 4 of value (byte) -87
- Arrays.fill(CHARS, 2389, 2392, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 2392, 2402, (byte) -19 ); // Fill 10 of value (byte) -19
- Arrays.fill(CHARS, 2402, 2404, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 2404, 2406, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 2406, 2416, (byte) -87 ); // Fill 10 of value (byte) -87
- Arrays.fill(CHARS, 2416, 2433, (byte) 33 ); // Fill 17 of value (byte) 33
- Arrays.fill(CHARS, 2433, 2436, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 2366, 2382, (byte) -87); // Fill 16 of value (byte) -87
+ Arrays.fill(CHARS, 2382, 2385, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2385, 2389, (byte) -87); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 2389, 2392, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2392, 2402, (byte) -19); // Fill 10 of value (byte) -19
+ Arrays.fill(CHARS, 2402, 2404, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 2404, 2406, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2406, 2416, (byte) -87); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 2416, 2433, (byte) 33); // Fill 17 of value (byte) 33
+ Arrays.fill(CHARS, 2433, 2436, (byte) -87); // Fill 3 of value (byte) -87
CHARS[2436] = 33;
- Arrays.fill(CHARS, 2437, 2445, (byte) -19 ); // Fill 8 of value (byte) -19
- Arrays.fill(CHARS, 2445, 2447, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 2447, 2449, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 2449, 2451, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 2451, 2473, (byte) -19 ); // Fill 22 of value (byte) -19
+ Arrays.fill(CHARS, 2437, 2445, (byte) -19); // Fill 8 of value (byte) -19
+ Arrays.fill(CHARS, 2445, 2447, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2447, 2449, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2449, 2451, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2451, 2473, (byte) -19); // Fill 22 of value (byte) -19
CHARS[2473] = 33;
- Arrays.fill(CHARS, 2474, 2481, (byte) -19 ); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 2474, 2481, (byte) -19); // Fill 7 of value (byte) -19
CHARS[2481] = 33;
CHARS[2482] = -19;
- Arrays.fill(CHARS, 2483, 2486, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 2486, 2490, (byte) -19 ); // Fill 4 of value (byte) -19
- Arrays.fill(CHARS, 2490, 2492, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2483, 2486, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2486, 2490, (byte) -19); // Fill 4 of value (byte) -19
+ Arrays.fill(CHARS, 2490, 2492, (byte) 33); // Fill 2 of value (byte) 33
CHARS[2492] = -87;
CHARS[2493] = 33;
- Arrays.fill(CHARS, 2494, 2501, (byte) -87 ); // Fill 7 of value (byte) -87
- Arrays.fill(CHARS, 2501, 2503, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 2503, 2505, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 2505, 2507, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 2507, 2510, (byte) -87 ); // Fill 3 of value (byte) -87
- Arrays.fill(CHARS, 2510, 2519, (byte) 33 ); // Fill 9 of value (byte) 33
+ Arrays.fill(CHARS, 2494, 2501, (byte) -87); // Fill 7 of value (byte) -87
+ Arrays.fill(CHARS, 2501, 2503, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2503, 2505, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 2505, 2507, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2507, 2510, (byte) -87); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 2510, 2519, (byte) 33); // Fill 9 of value (byte) 33
CHARS[2519] = -87;
- Arrays.fill(CHARS, 2520, 2524, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 2524, 2526, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2520, 2524, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 2524, 2526, (byte) -19); // Fill 2 of value (byte) -19
CHARS[2526] = 33;
- Arrays.fill(CHARS, 2527, 2530, (byte) -19 ); // Fill 3 of value (byte) -19
- Arrays.fill(CHARS, 2530, 2532, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 2532, 2534, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 2534, 2544, (byte) -87 ); // Fill 10 of value (byte) -87
- Arrays.fill(CHARS, 2544, 2546, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 2546, 2562, (byte) 33 ); // Fill 16 of value (byte) 33
+ Arrays.fill(CHARS, 2527, 2530, (byte) -19); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 2530, 2532, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 2532, 2534, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2534, 2544, (byte) -87); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 2544, 2546, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2546, 2562, (byte) 33); // Fill 16 of value (byte) 33
CHARS[2562] = -87;
- Arrays.fill(CHARS, 2563, 2565, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 2565, 2571, (byte) -19 ); // Fill 6 of value (byte) -19
- Arrays.fill(CHARS, 2571, 2575, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 2575, 2577, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 2577, 2579, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 2579, 2601, (byte) -19 ); // Fill 22 of value (byte) -19
+ Arrays.fill(CHARS, 2563, 2565, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2565, 2571, (byte) -19); // Fill 6 of value (byte) -19
+ Arrays.fill(CHARS, 2571, 2575, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 2575, 2577, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2577, 2579, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2579, 2601, (byte) -19); // Fill 22 of value (byte) -19
CHARS[2601] = 33;
- Arrays.fill(CHARS, 2602, 2609, (byte) -19 ); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 2602, 2609, (byte) -19); // Fill 7 of value (byte) -19
CHARS[2609] = 33;
- Arrays.fill(CHARS, 2610, 2612, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2610, 2612, (byte) -19); // Fill 2 of value (byte) -19
CHARS[2612] = 33;
- Arrays.fill(CHARS, 2613, 2615, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2613, 2615, (byte) -19); // Fill 2 of value (byte) -19
CHARS[2615] = 33;
- Arrays.fill(CHARS, 2616, 2618, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 2618, 2620, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2616, 2618, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2618, 2620, (byte) 33); // Fill 2 of value (byte) 33
CHARS[2620] = -87;
CHARS[2621] = 33;
- Arrays.fill(CHARS, 2622, 2627, (byte) -87 ); // Fill 5 of value (byte) -87
- Arrays.fill(CHARS, 2627, 2631, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 2631, 2633, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 2633, 2635, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 2635, 2638, (byte) -87 ); // Fill 3 of value (byte) -87
- Arrays.fill(CHARS, 2638, 2649, (byte) 33 ); // Fill 11 of value (byte) 33
- Arrays.fill(CHARS, 2649, 2653, (byte) -19 ); // Fill 4 of value (byte) -19
+ Arrays.fill(CHARS, 2622, 2627, (byte) -87); // Fill 5 of value (byte) -87
+ Arrays.fill(CHARS, 2627, 2631, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 2631, 2633, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 2633, 2635, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2635, 2638, (byte) -87); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 2638, 2649, (byte) 33); // Fill 11 of value (byte) 33
+ Arrays.fill(CHARS, 2649, 2653, (byte) -19); // Fill 4 of value (byte) -19
CHARS[2653] = 33;
CHARS[2654] = -19;
- Arrays.fill(CHARS, 2655, 2662, (byte) 33 ); // Fill 7 of value (byte) 33
- Arrays.fill(CHARS, 2662, 2674, (byte) -87 ); // Fill 12 of value (byte) -87
- Arrays.fill(CHARS, 2674, 2677, (byte) -19 ); // Fill 3 of value (byte) -19
- Arrays.fill(CHARS, 2677, 2689, (byte) 33 ); // Fill 12 of value (byte) 33
- Arrays.fill(CHARS, 2689, 2692, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 2655, 2662, (byte) 33); // Fill 7 of value (byte) 33
+ Arrays.fill(CHARS, 2662, 2674, (byte) -87); // Fill 12 of value (byte) -87
+ Arrays.fill(CHARS, 2674, 2677, (byte) -19); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 2677, 2689, (byte) 33); // Fill 12 of value (byte) 33
+ Arrays.fill(CHARS, 2689, 2692, (byte) -87); // Fill 3 of value (byte) -87
CHARS[2692] = 33;
- Arrays.fill(CHARS, 2693, 2700, (byte) -19 ); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 2693, 2700, (byte) -19); // Fill 7 of value (byte) -19
CHARS[2700] = 33;
CHARS[2701] = -19;
CHARS[2702] = 33;
- Arrays.fill(CHARS, 2703, 2706, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 2703, 2706, (byte) -19); // Fill 3 of value (byte) -19
CHARS[2706] = 33;
- Arrays.fill(CHARS, 2707, 2729, (byte) -19 ); // Fill 22 of value (byte) -19
+ Arrays.fill(CHARS, 2707, 2729, (byte) -19); // Fill 22 of value (byte) -19
CHARS[2729] = 33;
- Arrays.fill(CHARS, 2730, 2737, (byte) -19 ); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 2730, 2737, (byte) -19); // Fill 7 of value (byte) -19
CHARS[2737] = 33;
- Arrays.fill(CHARS, 2738, 2740, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2738, 2740, (byte) -19); // Fill 2 of value (byte) -19
CHARS[2740] = 33;
- Arrays.fill(CHARS, 2741, 2746, (byte) -19 ); // Fill 5 of value (byte) -19
- Arrays.fill(CHARS, 2746, 2748, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2741, 2746, (byte) -19); // Fill 5 of value (byte) -19
+ Arrays.fill(CHARS, 2746, 2748, (byte) 33); // Fill 2 of value (byte) 33
CHARS[2748] = -87;
CHARS[2749] = -19;
- Arrays.fill(CHARS, 2750, 2758, (byte) -87 ); // Fill 8 of value (byte) -87
+ Arrays.fill(CHARS, 2750, 2758, (byte) -87); // Fill 8 of value (byte) -87
CHARS[2758] = 33;
- Arrays.fill(CHARS, 2759, 2762, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 2759, 2762, (byte) -87); // Fill 3 of value (byte) -87
CHARS[2762] = 33;
- Arrays.fill(CHARS, 2763, 2766, (byte) -87 ); // Fill 3 of value (byte) -87
- Arrays.fill(CHARS, 2766, 2784, (byte) 33 ); // Fill 18 of value (byte) 33
+ Arrays.fill(CHARS, 2763, 2766, (byte) -87); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 2766, 2784, (byte) 33); // Fill 18 of value (byte) 33
CHARS[2784] = -19;
- Arrays.fill(CHARS, 2785, 2790, (byte) 33 ); // Fill 5 of value (byte) 33
- Arrays.fill(CHARS, 2790, 2800, (byte) -87 ); // Fill 10 of value (byte) -87
- Arrays.fill(CHARS, 2800, 2817, (byte) 33 ); // Fill 17 of value (byte) 33
- Arrays.fill(CHARS, 2817, 2820, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 2785, 2790, (byte) 33); // Fill 5 of value (byte) 33
+ Arrays.fill(CHARS, 2790, 2800, (byte) -87); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 2800, 2817, (byte) 33); // Fill 17 of value (byte) 33
+ Arrays.fill(CHARS, 2817, 2820, (byte) -87); // Fill 3 of value (byte) -87
CHARS[2820] = 33;
- Arrays.fill(CHARS, 2821, 2829, (byte) -19 ); // Fill 8 of value (byte) -19
- Arrays.fill(CHARS, 2829, 2831, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 2831, 2833, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 2833, 2835, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 2835, 2857, (byte) -19 ); // Fill 22 of value (byte) -19
+ Arrays.fill(CHARS, 2821, 2829, (byte) -19); // Fill 8 of value (byte) -19
+ Arrays.fill(CHARS, 2829, 2831, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2831, 2833, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2833, 2835, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2835, 2857, (byte) -19); // Fill 22 of value (byte) -19
CHARS[2857] = 33;
- Arrays.fill(CHARS, 2858, 2865, (byte) -19 ); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 2858, 2865, (byte) -19); // Fill 7 of value (byte) -19
CHARS[2865] = 33;
- Arrays.fill(CHARS, 2866, 2868, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 2868, 2870, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 2870, 2874, (byte) -19 ); // Fill 4 of value (byte) -19
- Arrays.fill(CHARS, 2874, 2876, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2866, 2868, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2868, 2870, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2870, 2874, (byte) -19); // Fill 4 of value (byte) -19
+ Arrays.fill(CHARS, 2874, 2876, (byte) 33); // Fill 2 of value (byte) 33
CHARS[2876] = -87;
CHARS[2877] = -19;
- Arrays.fill(CHARS, 2878, 2884, (byte) -87 ); // Fill 6 of value (byte) -87
- Arrays.fill(CHARS, 2884, 2887, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 2887, 2889, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 2889, 2891, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 2891, 2894, (byte) -87 ); // Fill 3 of value (byte) -87
- Arrays.fill(CHARS, 2894, 2902, (byte) 33 ); // Fill 8 of value (byte) 33
- Arrays.fill(CHARS, 2902, 2904, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 2904, 2908, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 2908, 2910, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2878, 2884, (byte) -87); // Fill 6 of value (byte) -87
+ Arrays.fill(CHARS, 2884, 2887, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2887, 2889, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 2889, 2891, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2891, 2894, (byte) -87); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 2894, 2902, (byte) 33); // Fill 8 of value (byte) 33
+ Arrays.fill(CHARS, 2902, 2904, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 2904, 2908, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 2908, 2910, (byte) -19); // Fill 2 of value (byte) -19
CHARS[2910] = 33;
- Arrays.fill(CHARS, 2911, 2914, (byte) -19 ); // Fill 3 of value (byte) -19
- Arrays.fill(CHARS, 2914, 2918, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 2918, 2928, (byte) -87 ); // Fill 10 of value (byte) -87
- Arrays.fill(CHARS, 2928, 2946, (byte) 33 ); // Fill 18 of value (byte) 33
- Arrays.fill(CHARS, 2946, 2948, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 2911, 2914, (byte) -19); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 2914, 2918, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 2918, 2928, (byte) -87); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 2928, 2946, (byte) 33); // Fill 18 of value (byte) 33
+ Arrays.fill(CHARS, 2946, 2948, (byte) -87); // Fill 2 of value (byte) -87
CHARS[2948] = 33;
- Arrays.fill(CHARS, 2949, 2955, (byte) -19 ); // Fill 6 of value (byte) -19
- Arrays.fill(CHARS, 2955, 2958, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 2958, 2961, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 2949, 2955, (byte) -19); // Fill 6 of value (byte) -19
+ Arrays.fill(CHARS, 2955, 2958, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2958, 2961, (byte) -19); // Fill 3 of value (byte) -19
CHARS[2961] = 33;
- Arrays.fill(CHARS, 2962, 2966, (byte) -19 ); // Fill 4 of value (byte) -19
- Arrays.fill(CHARS, 2966, 2969, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 2969, 2971, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2962, 2966, (byte) -19); // Fill 4 of value (byte) -19
+ Arrays.fill(CHARS, 2966, 2969, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2969, 2971, (byte) -19); // Fill 2 of value (byte) -19
CHARS[2971] = 33;
CHARS[2972] = -19;
CHARS[2973] = 33;
- Arrays.fill(CHARS, 2974, 2976, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 2976, 2979, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 2979, 2981, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 2981, 2984, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 2984, 2987, (byte) -19 ); // Fill 3 of value (byte) -19
- Arrays.fill(CHARS, 2987, 2990, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 2990, 2998, (byte) -19 ); // Fill 8 of value (byte) -19
+ Arrays.fill(CHARS, 2974, 2976, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2976, 2979, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2979, 2981, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2981, 2984, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2984, 2987, (byte) -19); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 2987, 2990, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2990, 2998, (byte) -19); // Fill 8 of value (byte) -19
CHARS[2998] = 33;
- Arrays.fill(CHARS, 2999, 3002, (byte) -19 ); // Fill 3 of value (byte) -19
- Arrays.fill(CHARS, 3002, 3006, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 3006, 3011, (byte) -87 ); // Fill 5 of value (byte) -87
- Arrays.fill(CHARS, 3011, 3014, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 3014, 3017, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 2999, 3002, (byte) -19); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 3002, 3006, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3006, 3011, (byte) -87); // Fill 5 of value (byte) -87
+ Arrays.fill(CHARS, 3011, 3014, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 3014, 3017, (byte) -87); // Fill 3 of value (byte) -87
CHARS[3017] = 33;
- Arrays.fill(CHARS, 3018, 3022, (byte) -87 ); // Fill 4 of value (byte) -87
- Arrays.fill(CHARS, 3022, 3031, (byte) 33 ); // Fill 9 of value (byte) 33
+ Arrays.fill(CHARS, 3018, 3022, (byte) -87); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 3022, 3031, (byte) 33); // Fill 9 of value (byte) 33
CHARS[3031] = -87;
- Arrays.fill(CHARS, 3032, 3047, (byte) 33 ); // Fill 15 of value (byte) 33
- Arrays.fill(CHARS, 3047, 3056, (byte) -87 ); // Fill 9 of value (byte) -87
- Arrays.fill(CHARS, 3056, 3073, (byte) 33 ); // Fill 17 of value (byte) 33
- Arrays.fill(CHARS, 3073, 3076, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 3032, 3047, (byte) 33); // Fill 15 of value (byte) 33
+ Arrays.fill(CHARS, 3047, 3056, (byte) -87); // Fill 9 of value (byte) -87
+ Arrays.fill(CHARS, 3056, 3073, (byte) 33); // Fill 17 of value (byte) 33
+ Arrays.fill(CHARS, 3073, 3076, (byte) -87); // Fill 3 of value (byte) -87
CHARS[3076] = 33;
- Arrays.fill(CHARS, 3077, 3085, (byte) -19 ); // Fill 8 of value (byte) -19
+ Arrays.fill(CHARS, 3077, 3085, (byte) -19); // Fill 8 of value (byte) -19
CHARS[3085] = 33;
- Arrays.fill(CHARS, 3086, 3089, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 3086, 3089, (byte) -19); // Fill 3 of value (byte) -19
CHARS[3089] = 33;
- Arrays.fill(CHARS, 3090, 3113, (byte) -19 ); // Fill 23 of value (byte) -19
+ Arrays.fill(CHARS, 3090, 3113, (byte) -19); // Fill 23 of value (byte) -19
CHARS[3113] = 33;
- Arrays.fill(CHARS, 3114, 3124, (byte) -19 ); // Fill 10 of value (byte) -19
+ Arrays.fill(CHARS, 3114, 3124, (byte) -19); // Fill 10 of value (byte) -19
CHARS[3124] = 33;
- Arrays.fill(CHARS, 3125, 3130, (byte) -19 ); // Fill 5 of value (byte) -19
- Arrays.fill(CHARS, 3130, 3134, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 3134, 3141, (byte) -87 ); // Fill 7 of value (byte) -87
+ Arrays.fill(CHARS, 3125, 3130, (byte) -19); // Fill 5 of value (byte) -19
+ Arrays.fill(CHARS, 3130, 3134, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3134, 3141, (byte) -87); // Fill 7 of value (byte) -87
CHARS[3141] = 33;
- Arrays.fill(CHARS, 3142, 3145, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 3142, 3145, (byte) -87); // Fill 3 of value (byte) -87
CHARS[3145] = 33;
- Arrays.fill(CHARS, 3146, 3150, (byte) -87 ); // Fill 4 of value (byte) -87
- Arrays.fill(CHARS, 3150, 3157, (byte) 33 ); // Fill 7 of value (byte) 33
- Arrays.fill(CHARS, 3157, 3159, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 3159, 3168, (byte) 33 ); // Fill 9 of value (byte) 33
- Arrays.fill(CHARS, 3168, 3170, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 3170, 3174, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 3174, 3184, (byte) -87 ); // Fill 10 of value (byte) -87
- Arrays.fill(CHARS, 3184, 3202, (byte) 33 ); // Fill 18 of value (byte) 33
- Arrays.fill(CHARS, 3202, 3204, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 3146, 3150, (byte) -87); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 3150, 3157, (byte) 33); // Fill 7 of value (byte) 33
+ Arrays.fill(CHARS, 3157, 3159, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 3159, 3168, (byte) 33); // Fill 9 of value (byte) 33
+ Arrays.fill(CHARS, 3168, 3170, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3170, 3174, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3174, 3184, (byte) -87); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 3184, 3202, (byte) 33); // Fill 18 of value (byte) 33
+ Arrays.fill(CHARS, 3202, 3204, (byte) -87); // Fill 2 of value (byte) -87
CHARS[3204] = 33;
- Arrays.fill(CHARS, 3205, 3213, (byte) -19 ); // Fill 8 of value (byte) -19
+ Arrays.fill(CHARS, 3205, 3213, (byte) -19); // Fill 8 of value (byte) -19
CHARS[3213] = 33;
- Arrays.fill(CHARS, 3214, 3217, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 3214, 3217, (byte) -19); // Fill 3 of value (byte) -19
CHARS[3217] = 33;
- Arrays.fill(CHARS, 3218, 3241, (byte) -19 ); // Fill 23 of value (byte) -19
+ Arrays.fill(CHARS, 3218, 3241, (byte) -19); // Fill 23 of value (byte) -19
CHARS[3241] = 33;
- Arrays.fill(CHARS, 3242, 3252, (byte) -19 ); // Fill 10 of value (byte) -19
+ Arrays.fill(CHARS, 3242, 3252, (byte) -19); // Fill 10 of value (byte) -19
CHARS[3252] = 33;
- Arrays.fill(CHARS, 3253, 3258, (byte) -19 ); // Fill 5 of value (byte) -19
- Arrays.fill(CHARS, 3258, 3262, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 3262, 3269, (byte) -87 ); // Fill 7 of value (byte) -87
+ Arrays.fill(CHARS, 3253, 3258, (byte) -19); // Fill 5 of value (byte) -19
+ Arrays.fill(CHARS, 3258, 3262, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3262, 3269, (byte) -87); // Fill 7 of value (byte) -87
CHARS[3269] = 33;
- Arrays.fill(CHARS, 3270, 3273, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 3270, 3273, (byte) -87); // Fill 3 of value (byte) -87
CHARS[3273] = 33;
- Arrays.fill(CHARS, 3274, 3278, (byte) -87 ); // Fill 4 of value (byte) -87
- Arrays.fill(CHARS, 3278, 3285, (byte) 33 ); // Fill 7 of value (byte) 33
- Arrays.fill(CHARS, 3285, 3287, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 3287, 3294, (byte) 33 ); // Fill 7 of value (byte) 33
+ Arrays.fill(CHARS, 3274, 3278, (byte) -87); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 3278, 3285, (byte) 33); // Fill 7 of value (byte) 33
+ Arrays.fill(CHARS, 3285, 3287, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 3287, 3294, (byte) 33); // Fill 7 of value (byte) 33
CHARS[3294] = -19;
CHARS[3295] = 33;
- Arrays.fill(CHARS, 3296, 3298, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 3298, 3302, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 3302, 3312, (byte) -87 ); // Fill 10 of value (byte) -87
- Arrays.fill(CHARS, 3312, 3330, (byte) 33 ); // Fill 18 of value (byte) 33
- Arrays.fill(CHARS, 3330, 3332, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 3296, 3298, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3298, 3302, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3302, 3312, (byte) -87); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 3312, 3330, (byte) 33); // Fill 18 of value (byte) 33
+ Arrays.fill(CHARS, 3330, 3332, (byte) -87); // Fill 2 of value (byte) -87
CHARS[3332] = 33;
- Arrays.fill(CHARS, 3333, 3341, (byte) -19 ); // Fill 8 of value (byte) -19
+ Arrays.fill(CHARS, 3333, 3341, (byte) -19); // Fill 8 of value (byte) -19
CHARS[3341] = 33;
- Arrays.fill(CHARS, 3342, 3345, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 3342, 3345, (byte) -19); // Fill 3 of value (byte) -19
CHARS[3345] = 33;
- Arrays.fill(CHARS, 3346, 3369, (byte) -19 ); // Fill 23 of value (byte) -19
+ Arrays.fill(CHARS, 3346, 3369, (byte) -19); // Fill 23 of value (byte) -19
CHARS[3369] = 33;
- Arrays.fill(CHARS, 3370, 3386, (byte) -19 ); // Fill 16 of value (byte) -19
- Arrays.fill(CHARS, 3386, 3390, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 3390, 3396, (byte) -87 ); // Fill 6 of value (byte) -87
- Arrays.fill(CHARS, 3396, 3398, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 3398, 3401, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 3370, 3386, (byte) -19); // Fill 16 of value (byte) -19
+ Arrays.fill(CHARS, 3386, 3390, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3390, 3396, (byte) -87); // Fill 6 of value (byte) -87
+ Arrays.fill(CHARS, 3396, 3398, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 3398, 3401, (byte) -87); // Fill 3 of value (byte) -87
CHARS[3401] = 33;
- Arrays.fill(CHARS, 3402, 3406, (byte) -87 ); // Fill 4 of value (byte) -87
- Arrays.fill(CHARS, 3406, 3415, (byte) 33 ); // Fill 9 of value (byte) 33
+ Arrays.fill(CHARS, 3402, 3406, (byte) -87); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 3406, 3415, (byte) 33); // Fill 9 of value (byte) 33
CHARS[3415] = -87;
- Arrays.fill(CHARS, 3416, 3424, (byte) 33 ); // Fill 8 of value (byte) 33
- Arrays.fill(CHARS, 3424, 3426, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 3426, 3430, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 3430, 3440, (byte) -87 ); // Fill 10 of value (byte) -87
- Arrays.fill(CHARS, 3440, 3585, (byte) 33 ); // Fill 145 of value (byte) 33
- Arrays.fill(CHARS, 3585, 3631, (byte) -19 ); // Fill 46 of value (byte) -19
+ Arrays.fill(CHARS, 3416, 3424, (byte) 33); // Fill 8 of value (byte) 33
+ Arrays.fill(CHARS, 3424, 3426, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3426, 3430, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3430, 3440, (byte) -87); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 3440, 3585, (byte) 33); // Fill 145 of value (byte) 33
+ Arrays.fill(CHARS, 3585, 3631, (byte) -19); // Fill 46 of value (byte) -19
CHARS[3631] = 33;
CHARS[3632] = -19;
CHARS[3633] = -87;
- Arrays.fill(CHARS, 3634, 3636, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 3636, 3643, (byte) -87 ); // Fill 7 of value (byte) -87
- Arrays.fill(CHARS, 3643, 3648, (byte) 33 ); // Fill 5 of value (byte) 33
- Arrays.fill(CHARS, 3648, 3654, (byte) -19 ); // Fill 6 of value (byte) -19
- Arrays.fill(CHARS, 3654, 3663, (byte) -87 ); // Fill 9 of value (byte) -87
+ Arrays.fill(CHARS, 3634, 3636, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3636, 3643, (byte) -87); // Fill 7 of value (byte) -87
+ Arrays.fill(CHARS, 3643, 3648, (byte) 33); // Fill 5 of value (byte) 33
+ Arrays.fill(CHARS, 3648, 3654, (byte) -19); // Fill 6 of value (byte) -19
+ Arrays.fill(CHARS, 3654, 3663, (byte) -87); // Fill 9 of value (byte) -87
CHARS[3663] = 33;
- Arrays.fill(CHARS, 3664, 3674, (byte) -87 ); // Fill 10 of value (byte) -87
- Arrays.fill(CHARS, 3674, 3713, (byte) 33 ); // Fill 39 of value (byte) 33
- Arrays.fill(CHARS, 3713, 3715, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3664, 3674, (byte) -87); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 3674, 3713, (byte) 33); // Fill 39 of value (byte) 33
+ Arrays.fill(CHARS, 3713, 3715, (byte) -19); // Fill 2 of value (byte) -19
CHARS[3715] = 33;
CHARS[3716] = -19;
- Arrays.fill(CHARS, 3717, 3719, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 3719, 3721, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3717, 3719, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 3719, 3721, (byte) -19); // Fill 2 of value (byte) -19
CHARS[3721] = 33;
CHARS[3722] = -19;
- Arrays.fill(CHARS, 3723, 3725, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 3723, 3725, (byte) 33); // Fill 2 of value (byte) 33
CHARS[3725] = -19;
- Arrays.fill(CHARS, 3726, 3732, (byte) 33 ); // Fill 6 of value (byte) 33
- Arrays.fill(CHARS, 3732, 3736, (byte) -19 ); // Fill 4 of value (byte) -19
+ Arrays.fill(CHARS, 3726, 3732, (byte) 33); // Fill 6 of value (byte) 33
+ Arrays.fill(CHARS, 3732, 3736, (byte) -19); // Fill 4 of value (byte) -19
CHARS[3736] = 33;
- Arrays.fill(CHARS, 3737, 3744, (byte) -19 ); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 3737, 3744, (byte) -19); // Fill 7 of value (byte) -19
CHARS[3744] = 33;
- Arrays.fill(CHARS, 3745, 3748, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 3745, 3748, (byte) -19); // Fill 3 of value (byte) -19
CHARS[3748] = 33;
CHARS[3749] = -19;
CHARS[3750] = 33;
CHARS[3751] = -19;
- Arrays.fill(CHARS, 3752, 3754, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 3754, 3756, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3752, 3754, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 3754, 3756, (byte) -19); // Fill 2 of value (byte) -19
CHARS[3756] = 33;
- Arrays.fill(CHARS, 3757, 3759, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3757, 3759, (byte) -19); // Fill 2 of value (byte) -19
CHARS[3759] = 33;
CHARS[3760] = -19;
CHARS[3761] = -87;
- Arrays.fill(CHARS, 3762, 3764, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 3764, 3770, (byte) -87 ); // Fill 6 of value (byte) -87
+ Arrays.fill(CHARS, 3762, 3764, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3764, 3770, (byte) -87); // Fill 6 of value (byte) -87
CHARS[3770] = 33;
- Arrays.fill(CHARS, 3771, 3773, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 3771, 3773, (byte) -87); // Fill 2 of value (byte) -87
CHARS[3773] = -19;
- Arrays.fill(CHARS, 3774, 3776, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 3776, 3781, (byte) -19 ); // Fill 5 of value (byte) -19
+ Arrays.fill(CHARS, 3774, 3776, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 3776, 3781, (byte) -19); // Fill 5 of value (byte) -19
CHARS[3781] = 33;
CHARS[3782] = -87;
CHARS[3783] = 33;
- Arrays.fill(CHARS, 3784, 3790, (byte) -87 ); // Fill 6 of value (byte) -87
- Arrays.fill(CHARS, 3790, 3792, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 3792, 3802, (byte) -87 ); // Fill 10 of value (byte) -87
- Arrays.fill(CHARS, 3802, 3864, (byte) 33 ); // Fill 62 of value (byte) 33
- Arrays.fill(CHARS, 3864, 3866, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 3866, 3872, (byte) 33 ); // Fill 6 of value (byte) 33
- Arrays.fill(CHARS, 3872, 3882, (byte) -87 ); // Fill 10 of value (byte) -87
- Arrays.fill(CHARS, 3882, 3893, (byte) 33 ); // Fill 11 of value (byte) 33
+ Arrays.fill(CHARS, 3784, 3790, (byte) -87); // Fill 6 of value (byte) -87
+ Arrays.fill(CHARS, 3790, 3792, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 3792, 3802, (byte) -87); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 3802, 3864, (byte) 33); // Fill 62 of value (byte) 33
+ Arrays.fill(CHARS, 3864, 3866, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 3866, 3872, (byte) 33); // Fill 6 of value (byte) 33
+ Arrays.fill(CHARS, 3872, 3882, (byte) -87); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 3882, 3893, (byte) 33); // Fill 11 of value (byte) 33
CHARS[3893] = -87;
CHARS[3894] = 33;
CHARS[3895] = -87;
CHARS[3896] = 33;
CHARS[3897] = -87;
- Arrays.fill(CHARS, 3898, 3902, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 3902, 3904, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 3904, 3912, (byte) -19 ); // Fill 8 of value (byte) -19
+ Arrays.fill(CHARS, 3898, 3902, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3902, 3904, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 3904, 3912, (byte) -19); // Fill 8 of value (byte) -19
CHARS[3912] = 33;
- Arrays.fill(CHARS, 3913, 3946, (byte) -19 ); // Fill 33 of value (byte) -19
- Arrays.fill(CHARS, 3946, 3953, (byte) 33 ); // Fill 7 of value (byte) 33
- Arrays.fill(CHARS, 3953, 3973, (byte) -87 ); // Fill 20 of value (byte) -87
+ Arrays.fill(CHARS, 3913, 3946, (byte) -19); // Fill 33 of value (byte) -19
+ Arrays.fill(CHARS, 3946, 3953, (byte) 33); // Fill 7 of value (byte) 33
+ Arrays.fill(CHARS, 3953, 3973, (byte) -87); // Fill 20 of value (byte) -87
CHARS[3973] = 33;
- Arrays.fill(CHARS, 3974, 3980, (byte) -87 ); // Fill 6 of value (byte) -87
- Arrays.fill(CHARS, 3980, 3984, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 3984, 3990, (byte) -87 ); // Fill 6 of value (byte) -87
+ Arrays.fill(CHARS, 3974, 3980, (byte) -87); // Fill 6 of value (byte) -87
+ Arrays.fill(CHARS, 3980, 3984, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3984, 3990, (byte) -87); // Fill 6 of value (byte) -87
CHARS[3990] = 33;
CHARS[3991] = -87;
CHARS[3992] = 33;
- Arrays.fill(CHARS, 3993, 4014, (byte) -87 ); // Fill 21 of value (byte) -87
- Arrays.fill(CHARS, 4014, 4017, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 4017, 4024, (byte) -87 ); // Fill 7 of value (byte) -87
+ Arrays.fill(CHARS, 3993, 4014, (byte) -87); // Fill 21 of value (byte) -87
+ Arrays.fill(CHARS, 4014, 4017, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 4017, 4024, (byte) -87); // Fill 7 of value (byte) -87
CHARS[4024] = 33;
CHARS[4025] = -87;
- Arrays.fill(CHARS, 4026, 4256, (byte) 33 ); // Fill 230 of value (byte) 33
- Arrays.fill(CHARS, 4256, 4294, (byte) -19 ); // Fill 38 of value (byte) -19
- Arrays.fill(CHARS, 4294, 4304, (byte) 33 ); // Fill 10 of value (byte) 33
- Arrays.fill(CHARS, 4304, 4343, (byte) -19 ); // Fill 39 of value (byte) -19
- Arrays.fill(CHARS, 4343, 4352, (byte) 33 ); // Fill 9 of value (byte) 33
+ Arrays.fill(CHARS, 4026, 4256, (byte) 33); // Fill 230 of value (byte) 33
+ Arrays.fill(CHARS, 4256, 4294, (byte) -19); // Fill 38 of value (byte) -19
+ Arrays.fill(CHARS, 4294, 4304, (byte) 33); // Fill 10 of value (byte) 33
+ Arrays.fill(CHARS, 4304, 4343, (byte) -19); // Fill 39 of value (byte) -19
+ Arrays.fill(CHARS, 4343, 4352, (byte) 33); // Fill 9 of value (byte) 33
CHARS[4352] = -19;
CHARS[4353] = 33;
- Arrays.fill(CHARS, 4354, 4356, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 4354, 4356, (byte) -19); // Fill 2 of value (byte) -19
CHARS[4356] = 33;
- Arrays.fill(CHARS, 4357, 4360, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 4357, 4360, (byte) -19); // Fill 3 of value (byte) -19
CHARS[4360] = 33;
CHARS[4361] = -19;
CHARS[4362] = 33;
- Arrays.fill(CHARS, 4363, 4365, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 4363, 4365, (byte) -19); // Fill 2 of value (byte) -19
CHARS[4365] = 33;
- Arrays.fill(CHARS, 4366, 4371, (byte) -19 ); // Fill 5 of value (byte) -19
- Arrays.fill(CHARS, 4371, 4412, (byte) 33 ); // Fill 41 of value (byte) 33
+ Arrays.fill(CHARS, 4366, 4371, (byte) -19); // Fill 5 of value (byte) -19
+ Arrays.fill(CHARS, 4371, 4412, (byte) 33); // Fill 41 of value (byte) 33
CHARS[4412] = -19;
CHARS[4413] = 33;
CHARS[4414] = -19;
CHARS[4415] = 33;
CHARS[4416] = -19;
- Arrays.fill(CHARS, 4417, 4428, (byte) 33 ); // Fill 11 of value (byte) 33
+ Arrays.fill(CHARS, 4417, 4428, (byte) 33); // Fill 11 of value (byte) 33
CHARS[4428] = -19;
CHARS[4429] = 33;
CHARS[4430] = -19;
CHARS[4431] = 33;
CHARS[4432] = -19;
- Arrays.fill(CHARS, 4433, 4436, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 4436, 4438, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 4438, 4441, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 4433, 4436, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 4436, 4438, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 4438, 4441, (byte) 33); // Fill 3 of value (byte) 33
CHARS[4441] = -19;
- Arrays.fill(CHARS, 4442, 4447, (byte) 33 ); // Fill 5 of value (byte) 33
- Arrays.fill(CHARS, 4447, 4450, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 4442, 4447, (byte) 33); // Fill 5 of value (byte) 33
+ Arrays.fill(CHARS, 4447, 4450, (byte) -19); // Fill 3 of value (byte) -19
CHARS[4450] = 33;
CHARS[4451] = -19;
CHARS[4452] = 33;
@@ -612,46 +627,46 @@
CHARS[4455] = -19;
CHARS[4456] = 33;
CHARS[4457] = -19;
- Arrays.fill(CHARS, 4458, 4461, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 4461, 4463, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 4463, 4466, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 4466, 4468, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 4458, 4461, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 4461, 4463, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 4463, 4466, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 4466, 4468, (byte) -19); // Fill 2 of value (byte) -19
CHARS[4468] = 33;
CHARS[4469] = -19;
- Arrays.fill(CHARS, 4470, 4510, (byte) 33 ); // Fill 40 of value (byte) 33
+ Arrays.fill(CHARS, 4470, 4510, (byte) 33); // Fill 40 of value (byte) 33
CHARS[4510] = -19;
- Arrays.fill(CHARS, 4511, 4520, (byte) 33 ); // Fill 9 of value (byte) 33
+ Arrays.fill(CHARS, 4511, 4520, (byte) 33); // Fill 9 of value (byte) 33
CHARS[4520] = -19;
- Arrays.fill(CHARS, 4521, 4523, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 4521, 4523, (byte) 33); // Fill 2 of value (byte) 33
CHARS[4523] = -19;
- Arrays.fill(CHARS, 4524, 4526, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 4526, 4528, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 4528, 4535, (byte) 33 ); // Fill 7 of value (byte) 33
- Arrays.fill(CHARS, 4535, 4537, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 4524, 4526, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 4526, 4528, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 4528, 4535, (byte) 33); // Fill 7 of value (byte) 33
+ Arrays.fill(CHARS, 4535, 4537, (byte) -19); // Fill 2 of value (byte) -19
CHARS[4537] = 33;
CHARS[4538] = -19;
CHARS[4539] = 33;
- Arrays.fill(CHARS, 4540, 4547, (byte) -19 ); // Fill 7 of value (byte) -19
- Arrays.fill(CHARS, 4547, 4587, (byte) 33 ); // Fill 40 of value (byte) 33
+ Arrays.fill(CHARS, 4540, 4547, (byte) -19); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 4547, 4587, (byte) 33); // Fill 40 of value (byte) 33
CHARS[4587] = -19;
- Arrays.fill(CHARS, 4588, 4592, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 4588, 4592, (byte) 33); // Fill 4 of value (byte) 33
CHARS[4592] = -19;
- Arrays.fill(CHARS, 4593, 4601, (byte) 33 ); // Fill 8 of value (byte) 33
+ Arrays.fill(CHARS, 4593, 4601, (byte) 33); // Fill 8 of value (byte) 33
CHARS[4601] = -19;
- Arrays.fill(CHARS, 4602, 7680, (byte) 33 ); // Fill 3078 of value (byte) 33
- Arrays.fill(CHARS, 7680, 7836, (byte) -19 ); // Fill 156 of value (byte) -19
- Arrays.fill(CHARS, 7836, 7840, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 7840, 7930, (byte) -19 ); // Fill 90 of value (byte) -19
- Arrays.fill(CHARS, 7930, 7936, (byte) 33 ); // Fill 6 of value (byte) 33
- Arrays.fill(CHARS, 7936, 7958, (byte) -19 ); // Fill 22 of value (byte) -19
- Arrays.fill(CHARS, 7958, 7960, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 7960, 7966, (byte) -19 ); // Fill 6 of value (byte) -19
- Arrays.fill(CHARS, 7966, 7968, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 7968, 8006, (byte) -19 ); // Fill 38 of value (byte) -19
- Arrays.fill(CHARS, 8006, 8008, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 8008, 8014, (byte) -19 ); // Fill 6 of value (byte) -19
- Arrays.fill(CHARS, 8014, 8016, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 8016, 8024, (byte) -19 ); // Fill 8 of value (byte) -19
+ Arrays.fill(CHARS, 4602, 7680, (byte) 33); // Fill 3078 of value (byte) 33
+ Arrays.fill(CHARS, 7680, 7836, (byte) -19); // Fill 156 of value (byte) -19
+ Arrays.fill(CHARS, 7836, 7840, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 7840, 7930, (byte) -19); // Fill 90 of value (byte) -19
+ Arrays.fill(CHARS, 7930, 7936, (byte) 33); // Fill 6 of value (byte) 33
+ Arrays.fill(CHARS, 7936, 7958, (byte) -19); // Fill 22 of value (byte) -19
+ Arrays.fill(CHARS, 7958, 7960, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 7960, 7966, (byte) -19); // Fill 6 of value (byte) -19
+ Arrays.fill(CHARS, 7966, 7968, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 7968, 8006, (byte) -19); // Fill 38 of value (byte) -19
+ Arrays.fill(CHARS, 8006, 8008, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 8008, 8014, (byte) -19); // Fill 6 of value (byte) -19
+ Arrays.fill(CHARS, 8014, 8016, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 8016, 8024, (byte) -19); // Fill 8 of value (byte) -19
CHARS[8024] = 33;
CHARS[8025] = -19;
CHARS[8026] = 33;
@@ -659,66 +674,66 @@
CHARS[8028] = 33;
CHARS[8029] = -19;
CHARS[8030] = 33;
- Arrays.fill(CHARS, 8031, 8062, (byte) -19 ); // Fill 31 of value (byte) -19
- Arrays.fill(CHARS, 8062, 8064, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 8064, 8117, (byte) -19 ); // Fill 53 of value (byte) -19
+ Arrays.fill(CHARS, 8031, 8062, (byte) -19); // Fill 31 of value (byte) -19
+ Arrays.fill(CHARS, 8062, 8064, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 8064, 8117, (byte) -19); // Fill 53 of value (byte) -19
CHARS[8117] = 33;
- Arrays.fill(CHARS, 8118, 8125, (byte) -19 ); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 8118, 8125, (byte) -19); // Fill 7 of value (byte) -19
CHARS[8125] = 33;
CHARS[8126] = -19;
- Arrays.fill(CHARS, 8127, 8130, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 8130, 8133, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 8127, 8130, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 8130, 8133, (byte) -19); // Fill 3 of value (byte) -19
CHARS[8133] = 33;
- Arrays.fill(CHARS, 8134, 8141, (byte) -19 ); // Fill 7 of value (byte) -19
- Arrays.fill(CHARS, 8141, 8144, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 8144, 8148, (byte) -19 ); // Fill 4 of value (byte) -19
- Arrays.fill(CHARS, 8148, 8150, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 8150, 8156, (byte) -19 ); // Fill 6 of value (byte) -19
- Arrays.fill(CHARS, 8156, 8160, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 8160, 8173, (byte) -19 ); // Fill 13 of value (byte) -19
- Arrays.fill(CHARS, 8173, 8178, (byte) 33 ); // Fill 5 of value (byte) 33
- Arrays.fill(CHARS, 8178, 8181, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 8134, 8141, (byte) -19); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 8141, 8144, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 8144, 8148, (byte) -19); // Fill 4 of value (byte) -19
+ Arrays.fill(CHARS, 8148, 8150, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 8150, 8156, (byte) -19); // Fill 6 of value (byte) -19
+ Arrays.fill(CHARS, 8156, 8160, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 8160, 8173, (byte) -19); // Fill 13 of value (byte) -19
+ Arrays.fill(CHARS, 8173, 8178, (byte) 33); // Fill 5 of value (byte) 33
+ Arrays.fill(CHARS, 8178, 8181, (byte) -19); // Fill 3 of value (byte) -19
CHARS[8181] = 33;
- Arrays.fill(CHARS, 8182, 8189, (byte) -19 ); // Fill 7 of value (byte) -19
- Arrays.fill(CHARS, 8189, 8400, (byte) 33 ); // Fill 211 of value (byte) 33
- Arrays.fill(CHARS, 8400, 8413, (byte) -87 ); // Fill 13 of value (byte) -87
- Arrays.fill(CHARS, 8413, 8417, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 8182, 8189, (byte) -19); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 8189, 8400, (byte) 33); // Fill 211 of value (byte) 33
+ Arrays.fill(CHARS, 8400, 8413, (byte) -87); // Fill 13 of value (byte) -87
+ Arrays.fill(CHARS, 8413, 8417, (byte) 33); // Fill 4 of value (byte) 33
CHARS[8417] = -87;
- Arrays.fill(CHARS, 8418, 8486, (byte) 33 ); // Fill 68 of value (byte) 33
+ Arrays.fill(CHARS, 8418, 8486, (byte) 33); // Fill 68 of value (byte) 33
CHARS[8486] = -19;
- Arrays.fill(CHARS, 8487, 8490, (byte) 33 ); // Fill 3 of value (byte) 33
- Arrays.fill(CHARS, 8490, 8492, (byte) -19 ); // Fill 2 of value (byte) -19
- Arrays.fill(CHARS, 8492, 8494, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 8487, 8490, (byte) 33); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 8490, 8492, (byte) -19); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 8492, 8494, (byte) 33); // Fill 2 of value (byte) 33
CHARS[8494] = -19;
- Arrays.fill(CHARS, 8495, 8576, (byte) 33 ); // Fill 81 of value (byte) 33
- Arrays.fill(CHARS, 8576, 8579, (byte) -19 ); // Fill 3 of value (byte) -19
- Arrays.fill(CHARS, 8579, 12293, (byte) 33 ); // Fill 3714 of value (byte) 33
+ Arrays.fill(CHARS, 8495, 8576, (byte) 33); // Fill 81 of value (byte) 33
+ Arrays.fill(CHARS, 8576, 8579, (byte) -19); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 8579, 12293, (byte) 33); // Fill 3714 of value (byte) 33
CHARS[12293] = -87;
CHARS[12294] = 33;
CHARS[12295] = -19;
- Arrays.fill(CHARS, 12296, 12321, (byte) 33 ); // Fill 25 of value (byte) 33
- Arrays.fill(CHARS, 12321, 12330, (byte) -19 ); // Fill 9 of value (byte) -19
- Arrays.fill(CHARS, 12330, 12336, (byte) -87 ); // Fill 6 of value (byte) -87
+ Arrays.fill(CHARS, 12296, 12321, (byte) 33); // Fill 25 of value (byte) 33
+ Arrays.fill(CHARS, 12321, 12330, (byte) -19); // Fill 9 of value (byte) -19
+ Arrays.fill(CHARS, 12330, 12336, (byte) -87); // Fill 6 of value (byte) -87
CHARS[12336] = 33;
- Arrays.fill(CHARS, 12337, 12342, (byte) -87 ); // Fill 5 of value (byte) -87
- Arrays.fill(CHARS, 12342, 12353, (byte) 33 ); // Fill 11 of value (byte) 33
- Arrays.fill(CHARS, 12353, 12437, (byte) -19 ); // Fill 84 of value (byte) -19
- Arrays.fill(CHARS, 12437, 12441, (byte) 33 ); // Fill 4 of value (byte) 33
- Arrays.fill(CHARS, 12441, 12443, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 12443, 12445, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 12445, 12447, (byte) -87 ); // Fill 2 of value (byte) -87
- Arrays.fill(CHARS, 12447, 12449, (byte) 33 ); // Fill 2 of value (byte) 33
- Arrays.fill(CHARS, 12449, 12539, (byte) -19 ); // Fill 90 of value (byte) -19
+ Arrays.fill(CHARS, 12337, 12342, (byte) -87); // Fill 5 of value (byte) -87
+ Arrays.fill(CHARS, 12342, 12353, (byte) 33); // Fill 11 of value (byte) 33
+ Arrays.fill(CHARS, 12353, 12437, (byte) -19); // Fill 84 of value (byte) -19
+ Arrays.fill(CHARS, 12437, 12441, (byte) 33); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 12441, 12443, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 12443, 12445, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 12445, 12447, (byte) -87); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 12447, 12449, (byte) 33); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 12449, 12539, (byte) -19); // Fill 90 of value (byte) -19
CHARS[12539] = 33;
- Arrays.fill(CHARS, 12540, 12543, (byte) -87 ); // Fill 3 of value (byte) -87
- Arrays.fill(CHARS, 12543, 12549, (byte) 33 ); // Fill 6 of value (byte) 33
- Arrays.fill(CHARS, 12549, 12589, (byte) -19 ); // Fill 40 of value (byte) -19
- Arrays.fill(CHARS, 12589, 19968, (byte) 33 ); // Fill 7379 of value (byte) 33
- Arrays.fill(CHARS, 19968, 40870, (byte) -19 ); // Fill 20902 of value (byte) -19
- Arrays.fill(CHARS, 40870, 44032, (byte) 33 ); // Fill 3162 of value (byte) 33
- Arrays.fill(CHARS, 44032, 55204, (byte) -19 ); // Fill 11172 of value (byte) -19
- Arrays.fill(CHARS, 55204, 55296, (byte) 33 ); // Fill 92 of value (byte) 33
- Arrays.fill(CHARS, 57344, 65534, (byte) 33 ); // Fill 8190 of value (byte) 33
+ Arrays.fill(CHARS, 12540, 12543, (byte) -87); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 12543, 12549, (byte) 33); // Fill 6 of value (byte) 33
+ Arrays.fill(CHARS, 12549, 12589, (byte) -19); // Fill 40 of value (byte) -19
+ Arrays.fill(CHARS, 12589, 19968, (byte) 33); // Fill 7379 of value (byte) 33
+ Arrays.fill(CHARS, 19968, 40870, (byte) -19); // Fill 20902 of value (byte) -19
+ Arrays.fill(CHARS, 40870, 44032, (byte) 33); // Fill 3162 of value (byte) 33
+ Arrays.fill(CHARS, 44032, 55204, (byte) -19); // Fill 11172 of value (byte) -19
+ Arrays.fill(CHARS, 55204, 55296, (byte) 33); // Fill 92 of value (byte) 33
+ Arrays.fill(CHARS, 57344, 65534, (byte) 33); // Fill 8190 of value (byte) 33
} // <clinit>()
@@ -786,7 +801,7 @@
/**
* Returns true if the specified character is valid. This method
* also checks the surrogate character range from 0x10000 to 0x10FFFF.
- * <p>
+ * <p/>
* If the program chooses to apply the mask directly to the
* <code>CHARS</code> array, then they are responsible for checking
* the surrogate character range.
@@ -795,7 +810,7 @@
*/
public static boolean isValid(int c) {
return (c < 0x10000 && (CHARS[c] & MASK_VALID) != 0) ||
- (0x10000 <= c && c <= 0x10FFFF);
+ (0x10000 <= c && c <= 0x10FFFF);
} // isValid(int):boolean
/**
@@ -814,7 +829,7 @@
*/
public static boolean isContent(int c) {
return (c < 0x10000 && (CHARS[c] & MASK_CONTENT) != 0) ||
- (0x10000 <= c && c <= 0x10FFFF);
+ (0x10000 <= c && c <= 0x10FFFF);
} // isContent(int):boolean
/**
@@ -906,22 +921,22 @@
if (name.length() == 0)
return false;
char ch = name.charAt(0);
- if( isNameStart(ch) == false)
- return false;
- for (int i = 1; i < name.length(); i++ ) {
- ch = name.charAt(i);
- if( isName( ch ) == false ){
- return false;
- }
+ if (isNameStart(ch) == false)
+ return false;
+ for (int i = 1; i < name.length(); i++) {
+ ch = name.charAt(i);
+ if (isName(ch) == false) {
+ return false;
+ }
}
return true;
} // isValidName(String):boolean
-
+
/*
- * from the namespace rec
- * [4] NCName ::= (Letter | '_') (NCNameChar)*
- */
+ * from the namespace rec
+ * [4] NCName ::= (Letter | '_') (NCNameChar)*
+ */
/**
* Check to see if a string is a valid NCName according to [4]
* from the XML Namespaces 1.0 Recommendation
@@ -933,13 +948,13 @@
if (ncName.length() == 0)
return false;
char ch = ncName.charAt(0);
- if( isNCNameStart(ch) == false)
- return false;
- for (int i = 1; i < ncName.length(); i++ ) {
- ch = ncName.charAt(i);
- if( isNCName( ch ) == false ){
- return false;
- }
+ if (isNCNameStart(ch) == false)
+ return false;
+ for (int i = 1; i < ncName.length(); i++) {
+ ch = ncName.charAt(i);
+ if (isNCName(ch) == false) {
+ return false;
+ }
}
return true;
} // isValidNCName(String):boolean
@@ -952,24 +967,21 @@
* in the XML 1.0 Recommendation
*
* @param nmtoken string to check
- * @return true if nmtoken is a valid Nmtoken
+ * @return true if nmtoken is a valid Nmtoken
*/
public static boolean isValidNmtoken(String nmtoken) {
if (nmtoken.length() == 0)
return false;
- for (int i = 0; i < nmtoken.length(); i++ ) {
- char ch = nmtoken.charAt(i);
- if( ! isName( ch ) ){
- return false;
- }
+ for (int i = 0; i < nmtoken.length(); i++) {
+ char ch = nmtoken.charAt(i);
+ if (!isName(ch)) {
+ return false;
+ }
}
return true;
} // isValidName(String):boolean
-
-
-
// encodings
/**
@@ -989,8 +1001,8 @@
for (int i = 1; i < length; i++) {
c = ianaEncoding.charAt(i);
if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') &&
- (c < '0' || c > '9') && c != '.' && c != '_' &&
- c != '-') {
+ (c < '0' || c > '9') && c != '.' && c != '_' &&
+ c != '-') {
return false;
}
}
@@ -1016,8 +1028,8 @@
for (int i = 1; i < length; i++) {
char c = javaEncoding.charAt(i);
if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') &&
- (c < '0' || c > '9') && c != '.' && c != '_' &&
- c != '-') {
+ (c < '0' || c > '9') && c != '.' && c != '_' &&
+ c != '-') {
return false;
}
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLEncodingDetector.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLEncodingDetector.java
index 8e09df2..c5a0653 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLEncodingDetector.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLEncodingDetector.java
@@ -35,13 +35,13 @@
import java.util.jar.JarFile;
public class XMLEncodingDetector {
-
+
private InputStream stream;
private String encoding;
private boolean isEncodingSetInProlog;
private Boolean isBigEndian;
private Reader reader;
-
+
// org.apache.xerces.impl.XMLEntityManager fields
public static final int DEFAULT_BUFFER_SIZE = 2048;
public static final int DEFAULT_XMLDECL_BUFFER_SIZE = 64;
@@ -49,7 +49,7 @@
private SymbolTable fSymbolTable;
private XMLEncodingDetector fCurrentEntity;
private int fBufferSize = DEFAULT_BUFFER_SIZE;
-
+
// org.apache.xerces.impl.XMLEntityManager.ScannedEntity fields
private int lineNumber = 1;
private int columnNumber = 1;
@@ -58,15 +58,15 @@
private int position;
private int count;
private boolean mayReadChunks = false;
-
+
// org.apache.xerces.impl.XMLScanner fields
- private XMLString fString = new XMLString();
+ private XMLString fString = new XMLString();
private XMLStringBuffer fStringBuffer = new XMLStringBuffer();
private XMLStringBuffer fStringBuffer2 = new XMLStringBuffer();
private final static String fVersionSymbol = "version";
private final static String fEncodingSymbol = "encoding";
private final static String fStandaloneSymbol = "standalone";
-
+
// org.apache.xerces.impl.XMLDocumentFragmentScannerImpl fields
private int fMarkupDepth = 0;
private String[] fStrings = new String[3];
@@ -84,23 +84,22 @@
/**
* Autodetects the encoding of the XML document supplied by the given
* input stream.
- *
+ * <p/>
* Encoding autodetection is done according to the XML 1.0 specification,
* Appendix F.1: Detection Without External Encoding Information.
*
* @return Two-element array, where the first element (of type
- * java.lang.String) contains the name of the (auto)detected encoding, and
- * the second element (of type java.lang.Boolean) specifies whether the
- * encoding was specified using the 'encoding' attribute of an XML prolog
- * (TRUE) or autodetected (FALSE).
+ * java.lang.String) contains the name of the (auto)detected encoding, and
+ * the second element (of type java.lang.Boolean) specifies whether the
+ * encoding was specified using the 'encoding' attribute of an XML prolog
+ * (TRUE) or autodetected (FALSE).
*/
public static Object[] getEncoding(String fname, JarFile jarFile,
JspCompilationContext ctxt,
ErrorDispatcher err)
- throws IOException, JasperException
- {
+ throws IOException, JasperException {
InputStream inStream = JspUtil.getInputStream(fname, jarFile, ctxt,
- err);
+ err);
XMLEncodingDetector detector = new XMLEncodingDetector();
Object[] ret = detector.getEncoding(inStream, err);
inStream.close();
@@ -109,59 +108,58 @@
}
private Object[] getEncoding(InputStream in, ErrorDispatcher err)
- throws IOException, JasperException
- {
+ throws IOException, JasperException {
this.stream = in;
- this.err=err;
+ this.err = err;
createInitialReader();
scanXMLDecl();
-
- return new Object[] { this.encoding,
- new Boolean(this.isEncodingSetInProlog) };
+
+ return new Object[]{this.encoding,
+ new Boolean(this.isEncodingSetInProlog)};
}
-
+
// stub method
void endEntity() {
}
-
+
// Adapted from:
// org.apache.xerces.impl.XMLEntityManager.startEntity()
private void createInitialReader() throws IOException, JasperException {
- // wrap this stream in RewindableInputStream
- stream = new RewindableInputStream(stream);
+ // wrap this stream in RewindableInputStream
+ stream = new RewindableInputStream(stream);
- // perform auto-detect of encoding if necessary
- if (encoding == null) {
- // read first four bytes and determine encoding
- final byte[] b4 = new byte[4];
- int count = 0;
- for (; count<4; count++ ) {
- b4[count] = (byte)stream.read();
- }
- if (count == 4) {
- Object [] encodingDesc = getEncodingName(b4, count);
- encoding = (String)(encodingDesc[0]);
- isBigEndian = (Boolean)(encodingDesc[1]);
+ // perform auto-detect of encoding if necessary
+ if (encoding == null) {
+ // read first four bytes and determine encoding
+ final byte[] b4 = new byte[4];
+ int count = 0;
+ for (; count < 4; count++) {
+ b4[count] = (byte) stream.read();
+ }
+ if (count == 4) {
+ Object[] encodingDesc = getEncodingName(b4, count);
+ encoding = (String) (encodingDesc[0]);
+ isBigEndian = (Boolean) (encodingDesc[1]);
- stream.reset();
- // Special case UTF-8 files with BOM created by Microsoft
- // tools. It's more efficient to consume the BOM than make
- // the reader perform extra checks. -Ac
- if (count > 2 && encoding.equals("UTF-8")) {
- int b0 = b4[0] & 0xFF;
- int b1 = b4[1] & 0xFF;
- int b2 = b4[2] & 0xFF;
- if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) {
- // ignore first three bytes...
- stream.skip(3);
- }
- }
- reader = createReader(stream, encoding, isBigEndian);
- } else {
- reader = createReader(stream, encoding, isBigEndian);
- }
- }
+ stream.reset();
+ // Special case UTF-8 files with BOM created by Microsoft
+ // tools. It's more efficient to consume the BOM than make
+ // the reader perform extra checks. -Ac
+ if (count > 2 && encoding.equals("UTF-8")) {
+ int b0 = b4[0] & 0xFF;
+ int b1 = b4[1] & 0xFF;
+ int b2 = b4[2] & 0xFF;
+ if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) {
+ // ignore first three bytes...
+ stream.skip(3);
+ }
+ }
+ reader = createReader(stream, encoding, isBigEndian);
+ } else {
+ reader = createReader(stream, encoding, isBigEndian);
+ }
+ }
}
// Adapted from:
@@ -170,21 +168,20 @@
* Creates a reader capable of reading the given input stream in
* the specified encoding.
*
- * @param inputStream The input stream.
- * @param encoding The encoding name that the input stream is
- * encoded using. If the user has specified that
- * Java encoding names are allowed, then the
- * encoding name may be a Java encoding name;
- * otherwise, it is an ianaEncoding name.
- * @param isBigEndian For encodings (like uCS-4), whose names cannot
- * specify a byte order, this tells whether the order
- * is bigEndian. null means unknown or not relevant.
- *
+ * @param inputStream The input stream.
+ * @param encoding The encoding name that the input stream is
+ * encoded using. If the user has specified that
+ * Java encoding names are allowed, then the
+ * encoding name may be a Java encoding name;
+ * otherwise, it is an ianaEncoding name.
+ * @param isBigEndian For encodings (like uCS-4), whose names cannot
+ * specify a byte order, this tells whether the order
+ * is bigEndian. null means unknown or not relevant.
* @return Returns a reader.
*/
private Reader createReader(InputStream inputStream, String encoding,
- Boolean isBigEndian)
- throws IOException, JasperException {
+ Boolean isBigEndian)
+ throws IOException, JasperException {
// normalize encoding name
if (encoding == null) {
@@ -209,7 +206,7 @@
}
} else {
err.jspError("jsp.error.xml.encodingByteOrderUnsupported",
- encoding);
+ encoding);
}
}
if (ENCODING.equals("ISO-10646-UCS-2")) {
@@ -222,7 +219,7 @@
}
} else {
err.jspError("jsp.error.xml.encodingByteOrderUnsupported",
- encoding);
+ encoding);
}
}
@@ -246,7 +243,7 @@
String javaEncoding = EncodingMap.getIANA2JavaMapping(ENCODING);
if (javaEncoding == null) {
if (fAllowJavaEncodings) {
- javaEncoding = encoding;
+ javaEncoding = encoding;
} else {
err.jspError("jsp.error.xml.encodingDeclInvalid", encoding);
// see comment above.
@@ -267,9 +264,9 @@
* @param b4 The first four bytes of the input.
* @param count The number of bytes actually read.
* @return a 2-element array: the first element, an IANA-encoding string,
- * the second element a Boolean which is true iff the document is big
- * endian, false if it's little-endian, and null if the distinction isn't
- * relevant.
+ * the second element a Boolean which is true iff the document is big
+ * endian, false if it's little-endian, and null if the distinction isn't
+ * relevant.
*/
private Object[] getEncodingName(byte[] b4, int count) {
@@ -282,115 +279,116 @@
int b1 = b4[1] & 0xFF;
if (b0 == 0xFE && b1 == 0xFF) {
// UTF-16, big-endian
- return new Object [] {"UTF-16BE", new Boolean(true)};
+ return new Object[]{"UTF-16BE", new Boolean(true)};
}
if (b0 == 0xFF && b1 == 0xFE) {
// UTF-16, little-endian
- return new Object [] {"UTF-16LE", new Boolean(false)};
+ return new Object[]{"UTF-16LE", new Boolean(false)};
}
// default to UTF-8 if we don't have enough bytes to make a
// good determination of the encoding
if (count < 3) {
- return new Object [] {"UTF-8", null};
+ return new Object[]{"UTF-8", null};
}
// UTF-8 with a BOM
int b2 = b4[2] & 0xFF;
if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) {
- return new Object [] {"UTF-8", null};
+ return new Object[]{"UTF-8", null};
}
// default to UTF-8 if we don't have enough bytes to make a
// good determination of the encoding
if (count < 4) {
- return new Object [] {"UTF-8", null};
+ return new Object[]{"UTF-8", null};
}
// other encodings
int b3 = b4[3] & 0xFF;
if (b0 == 0x00 && b1 == 0x00 && b2 == 0x00 && b3 == 0x3C) {
// UCS-4, big endian (1234)
- return new Object [] {"ISO-10646-UCS-4", new Boolean(true)};
+ return new Object[]{"ISO-10646-UCS-4", new Boolean(true)};
}
if (b0 == 0x3C && b1 == 0x00 && b2 == 0x00 && b3 == 0x00) {
// UCS-4, little endian (4321)
- return new Object [] {"ISO-10646-UCS-4", new Boolean(false)};
+ return new Object[]{"ISO-10646-UCS-4", new Boolean(false)};
}
if (b0 == 0x00 && b1 == 0x00 && b2 == 0x3C && b3 == 0x00) {
// UCS-4, unusual octet order (2143)
// REVISIT: What should this be?
- return new Object [] {"ISO-10646-UCS-4", null};
+ return new Object[]{"ISO-10646-UCS-4", null};
}
if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x00) {
// UCS-4, unusual octect order (3412)
// REVISIT: What should this be?
- return new Object [] {"ISO-10646-UCS-4", null};
+ return new Object[]{"ISO-10646-UCS-4", null};
}
if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x3F) {
// UTF-16, big-endian, no BOM
// (or could turn out to be UCS-2...
// REVISIT: What should this be?
- return new Object [] {"UTF-16BE", new Boolean(true)};
+ return new Object[]{"UTF-16BE", new Boolean(true)};
}
if (b0 == 0x3C && b1 == 0x00 && b2 == 0x3F && b3 == 0x00) {
// UTF-16, little-endian, no BOM
// (or could turn out to be UCS-2...
- return new Object [] {"UTF-16LE", new Boolean(false)};
+ return new Object[]{"UTF-16LE", new Boolean(false)};
}
if (b0 == 0x4C && b1 == 0x6F && b2 == 0xA7 && b3 == 0x94) {
// EBCDIC
// a la xerces1, return CP037 instead of EBCDIC here
- return new Object [] {"CP037", null};
+ return new Object[]{"CP037", null};
}
// default encoding
- return new Object [] {"UTF-8", null};
+ return new Object[]{"UTF-8", null};
}
// Adapted from:
// org.apache.xerces.impl.XMLEntityManager.EntityScanner.isExternal
- /** Returns true if the current entity being scanned is external. */
+ /**
+ * Returns true if the current entity being scanned is external.
+ */
public boolean isExternal() {
- return true;
+ return true;
}
// Adapted from:
// org.apache.xerces.impl.XMLEntityManager.EntityScanner.peekChar
/**
* Returns the next character on the input.
- * <p>
+ * <p/>
* <strong>Note:</strong> The character is <em>not</em> consumed.
*
* @throws IOException Thrown if i/o error occurs.
* @throws EOFException Thrown on end of file.
*/
public int peekChar() throws IOException {
-
- // load more characters, if needed
- if (fCurrentEntity.position == fCurrentEntity.count) {
- load(0, true);
- }
-
- // peek at character
- int c = fCurrentEntity.ch[fCurrentEntity.position];
- // return peeked character
- if (fCurrentEntity.isExternal()) {
- return c != '\r' ? c : '\n';
- }
- else {
- return c;
- }
-
+ // load more characters, if needed
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ load(0, true);
+ }
+
+ // peek at character
+ int c = fCurrentEntity.ch[fCurrentEntity.position];
+
+ // return peeked character
+ if (fCurrentEntity.isExternal()) {
+ return c != '\r' ? c : '\n';
+ } else {
+ return c;
+ }
+
} // peekChar():int
-
+
// Adapted from:
// org.apache.xerces.impl.XMLEntityManager.EntityScanner.scanChar
/**
* Returns the next character on the input.
- * <p>
+ * <p/>
* <strong>Note:</strong> The character is consumed.
*
* @throws IOException Thrown if i/o error occurs.
@@ -398,34 +396,34 @@
*/
public int scanChar() throws IOException {
- // load more characters, if needed
- if (fCurrentEntity.position == fCurrentEntity.count) {
- load(0, true);
- }
+ // load more characters, if needed
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ load(0, true);
+ }
- // scan character
- int c = fCurrentEntity.ch[fCurrentEntity.position++];
- boolean external = false;
- if (c == '\n' ||
- (c == '\r' && (external = fCurrentEntity.isExternal()))) {
- fCurrentEntity.lineNumber++;
- fCurrentEntity.columnNumber = 1;
- if (fCurrentEntity.position == fCurrentEntity.count) {
- fCurrentEntity.ch[0] = (char)c;
- load(1, false);
- }
- if (c == '\r' && external) {
- if (fCurrentEntity.ch[fCurrentEntity.position++] != '\n') {
- fCurrentEntity.position--;
- }
- c = '\n';
- }
- }
+ // scan character
+ int c = fCurrentEntity.ch[fCurrentEntity.position++];
+ boolean external = false;
+ if (c == '\n' ||
+ (c == '\r' && (external = fCurrentEntity.isExternal()))) {
+ fCurrentEntity.lineNumber++;
+ fCurrentEntity.columnNumber = 1;
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ fCurrentEntity.ch[0] = (char) c;
+ load(1, false);
+ }
+ if (c == '\r' && external) {
+ if (fCurrentEntity.ch[fCurrentEntity.position++] != '\n') {
+ fCurrentEntity.position--;
+ }
+ c = '\n';
+ }
+ }
- // return character that was scanned
- fCurrentEntity.columnNumber++;
- return c;
-
+ // return character that was scanned
+ fCurrentEntity.columnNumber++;
+ return c;
+
}
// Adapted from:
@@ -433,70 +431,69 @@
/**
* Returns a string matching the Name production appearing immediately
* on the input as a symbol, or null if no Name string is present.
- * <p>
+ * <p/>
* <strong>Note:</strong> The Name characters are consumed.
- * <p>
+ * <p/>
* <strong>Note:</strong> The string returned must be a symbol. The
* SymbolTable can be used for this purpose.
*
* @throws IOException Thrown if i/o error occurs.
* @throws EOFException Thrown on end of file.
- *
* @see SymbolTable
* @see XMLChar#isName
* @see XMLChar#isNameStart
*/
public String scanName() throws IOException {
-
- // load more characters, if needed
- if (fCurrentEntity.position == fCurrentEntity.count) {
- load(0, true);
- }
-
- // scan name
- int offset = fCurrentEntity.position;
- if (XMLChar.isNameStart(fCurrentEntity.ch[offset])) {
- if (++fCurrentEntity.position == fCurrentEntity.count) {
- fCurrentEntity.ch[0] = fCurrentEntity.ch[offset];
- offset = 0;
- if (load(1, false)) {
- fCurrentEntity.columnNumber++;
- String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch,
- 0, 1);
- return symbol;
- }
- }
- while (XMLChar.isName(fCurrentEntity.ch[fCurrentEntity.position])) {
- if (++fCurrentEntity.position == fCurrentEntity.count) {
- int length = fCurrentEntity.position - offset;
- if (length == fBufferSize) {
- // bad luck we have to resize our buffer
- char[] tmp = new char[fBufferSize * 2];
- System.arraycopy(fCurrentEntity.ch, offset,
- tmp, 0, length);
- fCurrentEntity.ch = tmp;
- fBufferSize *= 2;
- } else {
- System.arraycopy(fCurrentEntity.ch, offset,
- fCurrentEntity.ch, 0, length);
- }
- offset = 0;
- if (load(length, false)) {
- break;
- }
- }
- }
- }
- int length = fCurrentEntity.position - offset;
- fCurrentEntity.columnNumber += length;
- // return name
- String symbol = null;
- if (length > 0) {
- symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, offset, length);
- }
- return symbol;
-
+ // load more characters, if needed
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ load(0, true);
+ }
+
+ // scan name
+ int offset = fCurrentEntity.position;
+ if (XMLChar.isNameStart(fCurrentEntity.ch[offset])) {
+ if (++fCurrentEntity.position == fCurrentEntity.count) {
+ fCurrentEntity.ch[0] = fCurrentEntity.ch[offset];
+ offset = 0;
+ if (load(1, false)) {
+ fCurrentEntity.columnNumber++;
+ String symbol = fSymbolTable.addSymbol(fCurrentEntity.ch,
+ 0, 1);
+ return symbol;
+ }
+ }
+ while (XMLChar.isName(fCurrentEntity.ch[fCurrentEntity.position])) {
+ if (++fCurrentEntity.position == fCurrentEntity.count) {
+ int length = fCurrentEntity.position - offset;
+ if (length == fBufferSize) {
+ // bad luck we have to resize our buffer
+ char[] tmp = new char[fBufferSize * 2];
+ System.arraycopy(fCurrentEntity.ch, offset,
+ tmp, 0, length);
+ fCurrentEntity.ch = tmp;
+ fBufferSize *= 2;
+ } else {
+ System.arraycopy(fCurrentEntity.ch, offset,
+ fCurrentEntity.ch, 0, length);
+ }
+ offset = 0;
+ if (load(length, false)) {
+ break;
+ }
+ }
+ }
+ }
+ int length = fCurrentEntity.position - offset;
+ fCurrentEntity.columnNumber += length;
+
+ // return name
+ String symbol = null;
+ if (length > 0) {
+ symbol = fSymbolTable.addSymbol(fCurrentEntity.ch, offset, length);
+ }
+ return symbol;
+
}
// Adapted from:
@@ -504,14 +501,14 @@
/**
* Scans a range of attribute value data, setting the fields of the
* XMLString structure, appropriately.
- * <p>
+ * <p/>
* <strong>Note:</strong> The characters are consumed.
- * <p>
+ * <p/>
* <strong>Note:</strong> This method does not guarantee to return
* the longest run of attribute value data. This method may return
* before the quote character due to reaching the end of the input
* buffer or any other reason.
- * <p>
+ * <p/>
* <strong>Note:</strong> The fields contained in the XMLString
* structure are not guaranteed to remain valid upon subsequent calls
* to the entity scanner. Therefore, the caller is responsible for
@@ -521,135 +518,130 @@
* @param quote The quote character that signifies the end of the
* attribute value data.
* @param content The content structure to fill.
- *
* @return Returns the next character on the input, if known. This
* value may be -1 but this does <em>note</em> designate
* end of file.
- *
* @throws IOException Thrown if i/o error occurs.
* @throws EOFException Thrown on end of file.
*/
public int scanLiteral(int quote, XMLString content)
- throws IOException {
+ throws IOException {
- // load more characters, if needed
- if (fCurrentEntity.position == fCurrentEntity.count) {
- load(0, true);
- } else if (fCurrentEntity.position == fCurrentEntity.count - 1) {
- fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1];
- load(1, false);
- fCurrentEntity.position = 0;
- }
+ // load more characters, if needed
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ load(0, true);
+ } else if (fCurrentEntity.position == fCurrentEntity.count - 1) {
+ fCurrentEntity.ch[0] = fCurrentEntity.ch[fCurrentEntity.count - 1];
+ load(1, false);
+ fCurrentEntity.position = 0;
+ }
- // normalize newlines
- int offset = fCurrentEntity.position;
- int c = fCurrentEntity.ch[offset];
- int newlines = 0;
- boolean external = fCurrentEntity.isExternal();
- if (c == '\n' || (c == '\r' && external)) {
- do {
- c = fCurrentEntity.ch[fCurrentEntity.position++];
- if (c == '\r' && external) {
- newlines++;
- fCurrentEntity.lineNumber++;
- fCurrentEntity.columnNumber = 1;
- if (fCurrentEntity.position == fCurrentEntity.count) {
- offset = 0;
- fCurrentEntity.position = newlines;
- if (load(newlines, false)) {
- break;
- }
- }
- if (fCurrentEntity.ch[fCurrentEntity.position] == '\n') {
- fCurrentEntity.position++;
- offset++;
- }
- /*** NEWLINE NORMALIZATION ***/
- else {
- newlines++;
- }
- /***/
- }
- else if (c == '\n') {
- newlines++;
- fCurrentEntity.lineNumber++;
- fCurrentEntity.columnNumber = 1;
- if (fCurrentEntity.position == fCurrentEntity.count) {
- offset = 0;
- fCurrentEntity.position = newlines;
- if (load(newlines, false)) {
- break;
- }
- }
- /*** NEWLINE NORMALIZATION ***
- if (fCurrentEntity.ch[fCurrentEntity.position] == '\r'
- && external) {
- fCurrentEntity.position++;
- offset++;
- }
- /***/
- }
- else {
- fCurrentEntity.position--;
- break;
- }
- } while (fCurrentEntity.position < fCurrentEntity.count - 1);
- for (int i = offset; i < fCurrentEntity.position; i++) {
- fCurrentEntity.ch[i] = '\n';
- }
- int length = fCurrentEntity.position - offset;
- if (fCurrentEntity.position == fCurrentEntity.count - 1) {
- content.setValues(fCurrentEntity.ch, offset, length);
- return -1;
- }
- }
+ // normalize newlines
+ int offset = fCurrentEntity.position;
+ int c = fCurrentEntity.ch[offset];
+ int newlines = 0;
+ boolean external = fCurrentEntity.isExternal();
+ if (c == '\n' || (c == '\r' && external)) {
+ do {
+ c = fCurrentEntity.ch[fCurrentEntity.position++];
+ if (c == '\r' && external) {
+ newlines++;
+ fCurrentEntity.lineNumber++;
+ fCurrentEntity.columnNumber = 1;
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ offset = 0;
+ fCurrentEntity.position = newlines;
+ if (load(newlines, false)) {
+ break;
+ }
+ }
+ if (fCurrentEntity.ch[fCurrentEntity.position] == '\n') {
+ fCurrentEntity.position++;
+ offset++;
+ }
+ /*** NEWLINE NORMALIZATION ***/
+ else {
+ newlines++;
+ }
+ /***/
+ } else if (c == '\n') {
+ newlines++;
+ fCurrentEntity.lineNumber++;
+ fCurrentEntity.columnNumber = 1;
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ offset = 0;
+ fCurrentEntity.position = newlines;
+ if (load(newlines, false)) {
+ break;
+ }
+ }
+ /*** NEWLINE NORMALIZATION ***
+ if (fCurrentEntity.ch[fCurrentEntity.position] == '\r'
+ && external) {
+ fCurrentEntity.position++;
+ offset++;
+ }
+ /***/
+ } else {
+ fCurrentEntity.position--;
+ break;
+ }
+ } while (fCurrentEntity.position < fCurrentEntity.count - 1);
+ for (int i = offset; i < fCurrentEntity.position; i++) {
+ fCurrentEntity.ch[i] = '\n';
+ }
+ int length = fCurrentEntity.position - offset;
+ if (fCurrentEntity.position == fCurrentEntity.count - 1) {
+ content.setValues(fCurrentEntity.ch, offset, length);
+ return -1;
+ }
+ }
- // scan literal value
- while (fCurrentEntity.position < fCurrentEntity.count) {
- c = fCurrentEntity.ch[fCurrentEntity.position++];
- if ((c == quote &&
- (!fCurrentEntity.literal || external))
- || c == '%' || !XMLChar.isContent(c)) {
- fCurrentEntity.position--;
- break;
- }
- }
- int length = fCurrentEntity.position - offset;
- fCurrentEntity.columnNumber += length - newlines;
- content.setValues(fCurrentEntity.ch, offset, length);
+ // scan literal value
+ while (fCurrentEntity.position < fCurrentEntity.count) {
+ c = fCurrentEntity.ch[fCurrentEntity.position++];
+ if ((c == quote &&
+ (!fCurrentEntity.literal || external))
+ || c == '%' || !XMLChar.isContent(c)) {
+ fCurrentEntity.position--;
+ break;
+ }
+ }
+ int length = fCurrentEntity.position - offset;
+ fCurrentEntity.columnNumber += length - newlines;
+ content.setValues(fCurrentEntity.ch, offset, length);
- // return next character
- if (fCurrentEntity.position != fCurrentEntity.count) {
- c = fCurrentEntity.ch[fCurrentEntity.position];
- // NOTE: We don't want to accidentally signal the
- // end of the literal if we're expanding an
- // entity appearing in the literal. -Ac
- if (c == quote && fCurrentEntity.literal) {
- c = -1;
- }
- }
- else {
- c = -1;
- }
- return c;
+ // return next character
+ if (fCurrentEntity.position != fCurrentEntity.count) {
+ c = fCurrentEntity.ch[fCurrentEntity.position];
+ // NOTE: We don't want to accidentally signal the
+ // end of the literal if we're expanding an
+ // entity appearing in the literal. -Ac
+ if (c == quote && fCurrentEntity.literal) {
+ c = -1;
+ }
+ } else {
+ c = -1;
+ }
+ return c;
}
/**
* Scans a range of character data up to the specified delimiter,
* setting the fields of the XMLString structure, appropriately.
- * <p>
+ * <p/>
* <strong>Note:</strong> The characters are consumed.
- * <p>
+ * <p/>
* <strong>Note:</strong> This assumes that the internal buffer is
* at least the same size, or bigger, than the length of the delimiter
* and that the delimiter contains at least one character.
- * <p>
+ * <p/>
* <strong>Note:</strong> This method does not guarantee to return
* the longest run of character data. This method may return before
* the delimiter due to reaching the end of the input buffer or any
* other reason.
- * <p>
+ * <p/>
* <strong>Note:</strong> The fields contained in the XMLString
* structure are not guaranteed to remain valid upon subsequent calls
* to the entity scanner. Therefore, the caller is responsible for
@@ -659,143 +651,137 @@
* @param delimiter The string that signifies the end of the character
* data to be scanned.
* @param buffer The data structure to fill.
- *
* @return Returns true if there is more data to scan, false otherwise.
- *
* @throws IOException Thrown if i/o error occurs.
* @throws EOFException Thrown on end of file.
*/
public boolean scanData(String delimiter, XMLStringBuffer buffer)
- throws IOException {
+ throws IOException {
- boolean done = false;
- int delimLen = delimiter.length();
- char charAt0 = delimiter.charAt(0);
- boolean external = fCurrentEntity.isExternal();
- do {
-
- // load more characters, if needed
-
- if (fCurrentEntity.position == fCurrentEntity.count) {
- load(0, true);
- }
- else if (fCurrentEntity.position >= fCurrentEntity.count - delimLen) {
- System.arraycopy(fCurrentEntity.ch, fCurrentEntity.position,
- fCurrentEntity.ch, 0, fCurrentEntity.count - fCurrentEntity.position);
- load(fCurrentEntity.count - fCurrentEntity.position, false);
- fCurrentEntity.position = 0;
- }
- if (fCurrentEntity.position >= fCurrentEntity.count - delimLen) {
- // something must be wrong with the input: e.g., file ends an
- // unterminated comment
- int length = fCurrentEntity.count - fCurrentEntity.position;
- buffer.append (fCurrentEntity.ch, fCurrentEntity.position,
- length);
- fCurrentEntity.columnNumber += fCurrentEntity.count;
- fCurrentEntity.position = fCurrentEntity.count;
- load(0,true);
- return false;
- }
-
- // normalize newlines
- int offset = fCurrentEntity.position;
- int c = fCurrentEntity.ch[offset];
- int newlines = 0;
- if (c == '\n' || (c == '\r' && external)) {
- do {
- c = fCurrentEntity.ch[fCurrentEntity.position++];
- if (c == '\r' && external) {
- newlines++;
- fCurrentEntity.lineNumber++;
- fCurrentEntity.columnNumber = 1;
- if (fCurrentEntity.position == fCurrentEntity.count) {
- offset = 0;
- fCurrentEntity.position = newlines;
- if (load(newlines, false)) {
- break;
- }
- }
- if (fCurrentEntity.ch[fCurrentEntity.position] == '\n') {
- fCurrentEntity.position++;
- offset++;
- }
- /*** NEWLINE NORMALIZATION ***/
- else {
- newlines++;
- }
- }
- else if (c == '\n') {
- newlines++;
- fCurrentEntity.lineNumber++;
- fCurrentEntity.columnNumber = 1;
- if (fCurrentEntity.position == fCurrentEntity.count) {
- offset = 0;
- fCurrentEntity.position = newlines;
- fCurrentEntity.count = newlines;
- if (load(newlines, false)) {
- break;
- }
- }
- }
- else {
- fCurrentEntity.position--;
- break;
- }
- } while (fCurrentEntity.position < fCurrentEntity.count - 1);
- for (int i = offset; i < fCurrentEntity.position; i++) {
- fCurrentEntity.ch[i] = '\n';
- }
- int length = fCurrentEntity.position - offset;
- if (fCurrentEntity.position == fCurrentEntity.count - 1) {
- buffer.append(fCurrentEntity.ch, offset, length);
- return true;
- }
- }
-
- // iterate over buffer looking for delimiter
- OUTER: while (fCurrentEntity.position < fCurrentEntity.count) {
- c = fCurrentEntity.ch[fCurrentEntity.position++];
- if (c == charAt0) {
- // looks like we just hit the delimiter
- int delimOffset = fCurrentEntity.position - 1;
- for (int i = 1; i < delimLen; i++) {
- if (fCurrentEntity.position == fCurrentEntity.count) {
- fCurrentEntity.position -= i;
- break OUTER;
- }
- c = fCurrentEntity.ch[fCurrentEntity.position++];
- if (delimiter.charAt(i) != c) {
- fCurrentEntity.position--;
- break;
- }
- }
- if (fCurrentEntity.position == delimOffset + delimLen) {
- done = true;
- break;
- }
- }
- else if (c == '\n' || (external && c == '\r')) {
- fCurrentEntity.position--;
- break;
- }
- else if (XMLChar.isInvalid(c)) {
- fCurrentEntity.position--;
- int length = fCurrentEntity.position - offset;
- fCurrentEntity.columnNumber += length - newlines;
- buffer.append(fCurrentEntity.ch, offset, length);
- return true;
- }
- }
- int length = fCurrentEntity.position - offset;
- fCurrentEntity.columnNumber += length - newlines;
- if (done) {
- length -= delimLen;
- }
- buffer.append (fCurrentEntity.ch, offset, length);
-
- // return true if string was skipped
- } while (!done);
- return !done;
+ boolean done = false;
+ int delimLen = delimiter.length();
+ char charAt0 = delimiter.charAt(0);
+ boolean external = fCurrentEntity.isExternal();
+ do {
+
+ // load more characters, if needed
+
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ load(0, true);
+ } else if (fCurrentEntity.position >= fCurrentEntity.count - delimLen) {
+ System.arraycopy(fCurrentEntity.ch, fCurrentEntity.position,
+ fCurrentEntity.ch, 0, fCurrentEntity.count - fCurrentEntity.position);
+ load(fCurrentEntity.count - fCurrentEntity.position, false);
+ fCurrentEntity.position = 0;
+ }
+ if (fCurrentEntity.position >= fCurrentEntity.count - delimLen) {
+ // something must be wrong with the input: e.g., file ends an
+ // unterminated comment
+ int length = fCurrentEntity.count - fCurrentEntity.position;
+ buffer.append(fCurrentEntity.ch, fCurrentEntity.position,
+ length);
+ fCurrentEntity.columnNumber += fCurrentEntity.count;
+ fCurrentEntity.position = fCurrentEntity.count;
+ load(0, true);
+ return false;
+ }
+
+ // normalize newlines
+ int offset = fCurrentEntity.position;
+ int c = fCurrentEntity.ch[offset];
+ int newlines = 0;
+ if (c == '\n' || (c == '\r' && external)) {
+ do {
+ c = fCurrentEntity.ch[fCurrentEntity.position++];
+ if (c == '\r' && external) {
+ newlines++;
+ fCurrentEntity.lineNumber++;
+ fCurrentEntity.columnNumber = 1;
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ offset = 0;
+ fCurrentEntity.position = newlines;
+ if (load(newlines, false)) {
+ break;
+ }
+ }
+ if (fCurrentEntity.ch[fCurrentEntity.position] == '\n') {
+ fCurrentEntity.position++;
+ offset++;
+ }
+ /*** NEWLINE NORMALIZATION ***/
+ else {
+ newlines++;
+ }
+ } else if (c == '\n') {
+ newlines++;
+ fCurrentEntity.lineNumber++;
+ fCurrentEntity.columnNumber = 1;
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ offset = 0;
+ fCurrentEntity.position = newlines;
+ fCurrentEntity.count = newlines;
+ if (load(newlines, false)) {
+ break;
+ }
+ }
+ } else {
+ fCurrentEntity.position--;
+ break;
+ }
+ } while (fCurrentEntity.position < fCurrentEntity.count - 1);
+ for (int i = offset; i < fCurrentEntity.position; i++) {
+ fCurrentEntity.ch[i] = '\n';
+ }
+ int length = fCurrentEntity.position - offset;
+ if (fCurrentEntity.position == fCurrentEntity.count - 1) {
+ buffer.append(fCurrentEntity.ch, offset, length);
+ return true;
+ }
+ }
+
+ // iterate over buffer looking for delimiter
+ OUTER:
+ while (fCurrentEntity.position < fCurrentEntity.count) {
+ c = fCurrentEntity.ch[fCurrentEntity.position++];
+ if (c == charAt0) {
+ // looks like we just hit the delimiter
+ int delimOffset = fCurrentEntity.position - 1;
+ for (int i = 1; i < delimLen; i++) {
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ fCurrentEntity.position -= i;
+ break OUTER;
+ }
+ c = fCurrentEntity.ch[fCurrentEntity.position++];
+ if (delimiter.charAt(i) != c) {
+ fCurrentEntity.position--;
+ break;
+ }
+ }
+ if (fCurrentEntity.position == delimOffset + delimLen) {
+ done = true;
+ break;
+ }
+ } else if (c == '\n' || (external && c == '\r')) {
+ fCurrentEntity.position--;
+ break;
+ } else if (XMLChar.isInvalid(c)) {
+ fCurrentEntity.position--;
+ int length = fCurrentEntity.position - offset;
+ fCurrentEntity.columnNumber += length - newlines;
+ buffer.append(fCurrentEntity.ch, offset, length);
+ return true;
+ }
+ }
+ int length = fCurrentEntity.position - offset;
+ fCurrentEntity.columnNumber += length - newlines;
+ if (done) {
+ length -= delimLen;
+ }
+ buffer.append(fCurrentEntity.ch, offset, length);
+
+ // return true if string was skipped
+ } while (!done);
+ return !done;
}
@@ -803,53 +789,50 @@
// org.apache.xerces.impl.XMLEntityManager.EntityScanner.skipChar
/**
* Skips a character appearing immediately on the input.
- * <p>
+ * <p/>
* <strong>Note:</strong> The character is consumed only if it matches
* the specified character.
*
* @param c The character to skip.
- *
* @return Returns true if the character was skipped.
- *
* @throws IOException Thrown if i/o error occurs.
* @throws EOFException Thrown on end of file.
*/
public boolean skipChar(int c) throws IOException {
- // load more characters, if needed
- if (fCurrentEntity.position == fCurrentEntity.count) {
- load(0, true);
- }
+ // load more characters, if needed
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ load(0, true);
+ }
- // skip character
- int cc = fCurrentEntity.ch[fCurrentEntity.position];
- if (cc == c) {
- fCurrentEntity.position++;
- if (c == '\n') {
- fCurrentEntity.lineNumber++;
- fCurrentEntity.columnNumber = 1;
- }
- else {
- fCurrentEntity.columnNumber++;
- }
- return true;
- } else if (c == '\n' && cc == '\r' && fCurrentEntity.isExternal()) {
- // handle newlines
- if (fCurrentEntity.position == fCurrentEntity.count) {
- fCurrentEntity.ch[0] = (char)cc;
- load(1, false);
- }
- fCurrentEntity.position++;
- if (fCurrentEntity.ch[fCurrentEntity.position] == '\n') {
- fCurrentEntity.position++;
- }
- fCurrentEntity.lineNumber++;
- fCurrentEntity.columnNumber = 1;
- return true;
- }
+ // skip character
+ int cc = fCurrentEntity.ch[fCurrentEntity.position];
+ if (cc == c) {
+ fCurrentEntity.position++;
+ if (c == '\n') {
+ fCurrentEntity.lineNumber++;
+ fCurrentEntity.columnNumber = 1;
+ } else {
+ fCurrentEntity.columnNumber++;
+ }
+ return true;
+ } else if (c == '\n' && cc == '\r' && fCurrentEntity.isExternal()) {
+ // handle newlines
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ fCurrentEntity.ch[0] = (char) cc;
+ load(1, false);
+ }
+ fCurrentEntity.position++;
+ if (fCurrentEntity.ch[fCurrentEntity.position] == '\n') {
+ fCurrentEntity.position++;
+ }
+ fCurrentEntity.lineNumber++;
+ fCurrentEntity.columnNumber = 1;
+ return true;
+ }
- // character was not skipped
- return false;
+ // character was not skipped
+ return false;
}
@@ -857,116 +840,111 @@
// org.apache.xerces.impl.XMLEntityManager.EntityScanner.skipSpaces
/**
* Skips space characters appearing immediately on the input.
- * <p>
+ * <p/>
* <strong>Note:</strong> The characters are consumed only if they are
* space characters.
*
* @return Returns true if at least one space character was skipped.
- *
* @throws IOException Thrown if i/o error occurs.
* @throws EOFException Thrown on end of file.
- *
* @see XMLChar#isSpace
*/
public boolean skipSpaces() throws IOException {
- // load more characters, if needed
- if (fCurrentEntity.position == fCurrentEntity.count) {
- load(0, true);
- }
+ // load more characters, if needed
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ load(0, true);
+ }
- // skip spaces
- int c = fCurrentEntity.ch[fCurrentEntity.position];
- if (XMLChar.isSpace(c)) {
- boolean external = fCurrentEntity.isExternal();
- do {
- boolean entityChanged = false;
- // handle newlines
- if (c == '\n' || (external && c == '\r')) {
- fCurrentEntity.lineNumber++;
- fCurrentEntity.columnNumber = 1;
- if (fCurrentEntity.position == fCurrentEntity.count - 1) {
- fCurrentEntity.ch[0] = (char)c;
- entityChanged = load(1, true);
- if (!entityChanged)
- // the load change the position to be 1,
- // need to restore it when entity not changed
- fCurrentEntity.position = 0;
- }
- if (c == '\r' && external) {
- // REVISIT: Does this need to be updated to fix the
- // #x0D ^#x0A newline normalization problem? -Ac
- if (fCurrentEntity.ch[++fCurrentEntity.position] != '\n') {
- fCurrentEntity.position--;
- }
- }
- /*** NEWLINE NORMALIZATION ***
- else {
- if (fCurrentEntity.ch[fCurrentEntity.position + 1] == '\r'
- && external) {
- fCurrentEntity.position++;
- }
- }
- /***/
- }
- else {
- fCurrentEntity.columnNumber++;
- }
- // load more characters, if needed
- if (!entityChanged)
- fCurrentEntity.position++;
- if (fCurrentEntity.position == fCurrentEntity.count) {
- load(0, true);
- }
- } while (XMLChar.isSpace(c = fCurrentEntity.ch[fCurrentEntity.position]));
- return true;
- }
+ // skip spaces
+ int c = fCurrentEntity.ch[fCurrentEntity.position];
+ if (XMLChar.isSpace(c)) {
+ boolean external = fCurrentEntity.isExternal();
+ do {
+ boolean entityChanged = false;
+ // handle newlines
+ if (c == '\n' || (external && c == '\r')) {
+ fCurrentEntity.lineNumber++;
+ fCurrentEntity.columnNumber = 1;
+ if (fCurrentEntity.position == fCurrentEntity.count - 1) {
+ fCurrentEntity.ch[0] = (char) c;
+ entityChanged = load(1, true);
+ if (!entityChanged)
+ // the load change the position to be 1,
+ // need to restore it when entity not changed
+ fCurrentEntity.position = 0;
+ }
+ if (c == '\r' && external) {
+ // REVISIT: Does this need to be updated to fix the
+ // #x0D ^#x0A newline normalization problem? -Ac
+ if (fCurrentEntity.ch[++fCurrentEntity.position] != '\n') {
+ fCurrentEntity.position--;
+ }
+ }
+ /*** NEWLINE NORMALIZATION ***
+ else {
+ if (fCurrentEntity.ch[fCurrentEntity.position + 1] == '\r'
+ && external) {
+ fCurrentEntity.position++;
+ }
+ }
+ /***/
+ } else {
+ fCurrentEntity.columnNumber++;
+ }
+ // load more characters, if needed
+ if (!entityChanged)
+ fCurrentEntity.position++;
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ load(0, true);
+ }
+ } while (XMLChar.isSpace(c = fCurrentEntity.ch[fCurrentEntity.position]));
+ return true;
+ }
- // no spaces were found
- return false;
+ // no spaces were found
+ return false;
}
/**
* Skips the specified string appearing immediately on the input.
- * <p>
+ * <p/>
* <strong>Note:</strong> The characters are consumed only if they are
* space characters.
*
* @param s The string to skip.
- *
* @return Returns true if the string was skipped.
- *
* @throws IOException Thrown if i/o error occurs.
* @throws EOFException Thrown on end of file.
*/
public boolean skipString(String s) throws IOException {
- // load more characters, if needed
- if (fCurrentEntity.position == fCurrentEntity.count) {
- load(0, true);
- }
+ // load more characters, if needed
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ load(0, true);
+ }
- // skip string
- final int length = s.length();
- for (int i = 0; i < length; i++) {
- char c = fCurrentEntity.ch[fCurrentEntity.position++];
- if (c != s.charAt(i)) {
- fCurrentEntity.position -= i + 1;
- return false;
- }
- if (i < length - 1 && fCurrentEntity.position == fCurrentEntity.count) {
- System.arraycopy(fCurrentEntity.ch, fCurrentEntity.count - i - 1, fCurrentEntity.ch, 0, i + 1);
- // REVISIT: Can a string to be skipped cross an
- // entity boundary? -Ac
- if (load(i + 1, false)) {
- fCurrentEntity.position -= i + 1;
- return false;
- }
- }
- }
- fCurrentEntity.columnNumber += length;
- return true;
+ // skip string
+ final int length = s.length();
+ for (int i = 0; i < length; i++) {
+ char c = fCurrentEntity.ch[fCurrentEntity.position++];
+ if (c != s.charAt(i)) {
+ fCurrentEntity.position -= i + 1;
+ return false;
+ }
+ if (i < length - 1 && fCurrentEntity.position == fCurrentEntity.count) {
+ System.arraycopy(fCurrentEntity.ch, fCurrentEntity.count - i - 1, fCurrentEntity.ch, 0, i + 1);
+ // REVISIT: Can a string to be skipped cross an
+ // entity boundary? -Ac
+ if (load(i + 1, false)) {
+ fCurrentEntity.position -= i + 1;
+ return false;
+ }
+ }
+ }
+ fCurrentEntity.columnNumber += length;
+ return true;
}
@@ -982,47 +960,46 @@
* the current entity in place and the entity
* boundary will be signaled by the return
* value.
- *
* @returns Returns true if the entity changed as a result of this
- * load operation.
+ * load operation.
*/
final boolean load(int offset, boolean changeEntity)
- throws IOException {
+ throws IOException {
- // read characters
- int length = fCurrentEntity.mayReadChunks?
- (fCurrentEntity.ch.length - offset):
- (DEFAULT_XMLDECL_BUFFER_SIZE);
- int count = fCurrentEntity.reader.read(fCurrentEntity.ch, offset,
- length);
+ // read characters
+ int length = fCurrentEntity.mayReadChunks ?
+ (fCurrentEntity.ch.length - offset) :
+ (DEFAULT_XMLDECL_BUFFER_SIZE);
+ int count = fCurrentEntity.reader.read(fCurrentEntity.ch, offset,
+ length);
- // reset count and position
- boolean entityChanged = false;
- if (count != -1) {
- if (count != 0) {
- fCurrentEntity.count = count + offset;
- fCurrentEntity.position = offset;
- }
- }
+ // reset count and position
+ boolean entityChanged = false;
+ if (count != -1) {
+ if (count != 0) {
+ fCurrentEntity.count = count + offset;
+ fCurrentEntity.position = offset;
+ }
+ }
- // end of this entity
- else {
- fCurrentEntity.count = offset;
- fCurrentEntity.position = offset;
- entityChanged = true;
- if (changeEntity) {
- endEntity();
- if (fCurrentEntity == null) {
- throw new EOFException();
- }
- // handle the trailing edges
- if (fCurrentEntity.position == fCurrentEntity.count) {
- load(0, false);
- }
- }
- }
+ // end of this entity
+ else {
+ fCurrentEntity.count = offset;
+ fCurrentEntity.position = offset;
+ entityChanged = true;
+ if (changeEntity) {
+ endEntity();
+ if (fCurrentEntity == null) {
+ throw new EOFException();
+ }
+ // handle the trailing edges
+ if (fCurrentEntity.position == fCurrentEntity.count) {
+ load(0, false);
+ }
+ }
+ }
- return entityChanged;
+ return entityChanged;
}
@@ -1037,7 +1014,7 @@
* encoding of a document, we can neither backtrack to read the
* whole doc again nor start reading where we are with a new
* reader.
- *
+ * <p/>
* This class allows rewinding an inputStream by allowing a mark
* to be set, and the stream reset to that position. <strong>The
* class assumes that it needs to read one character per
@@ -1094,7 +1071,7 @@
fEndOffset = fOffset;
return -1;
}
- fData[fLength++] = (byte)b;
+ fData[fLength++] = (byte) b;
fOffset++;
return b & 0xff;
}
@@ -1114,15 +1091,14 @@
fEndOffset = fOffset;
return -1;
}
- b[off] = (byte)returnedVal;
+ b[off] = (byte) returnedVal;
return 1;
}
if (len < bytesLeft) {
if (len <= 0) {
return 0;
}
- }
- else {
+ } else {
len = bytesLeft;
}
if (b != null) {
@@ -1133,8 +1109,7 @@
}
public long skip(long n)
- throws IOException
- {
+ throws IOException {
int bytesLeft;
if (n <= 0) {
return 0;
@@ -1155,14 +1130,14 @@
return bytesLeft;
}
n -= bytesLeft;
- /*
- * In a manner of speaking, when this class isn't permitting more
- * than one byte at a time to be read, it is "blocking". The
- * available() method should indicate how much can be read without
- * blocking, so while we're in this mode, it should only indicate
- * that bytes in its buffer are available; otherwise, the result of
- * available() on the underlying InputStream is appropriate.
- */
+ /*
+ * In a manner of speaking, when this class isn't permitting more
+ * than one byte at a time to be read, it is "blocking". The
+ * available() method should indicate how much can be read without
+ * blocking, so while we're in this mode, it should only indicate
+ * that bytes in its buffer are available; otherwise, the result of
+ * available() on the underlying InputStream is appropriate.
+ */
return fInputStream.skip(n) + bytesLeft;
}
@@ -1173,7 +1148,7 @@
return -1;
}
return fCurrentEntity.mayReadChunks ? fInputStream.available()
- : 0;
+ : 0;
}
return bytesLeft;
}
@@ -1202,34 +1177,34 @@
// org.apache.xerces.impl.XMLDocumentScannerImpl.dispatch
private void scanXMLDecl() throws IOException, JasperException {
- if (skipString("<?xml")) {
- fMarkupDepth++;
- // NOTE: special case where document starts with a PI
- // whose name starts with "xml" (e.g. "xmlfoo")
- if (XMLChar.isName(peekChar())) {
- fStringBuffer.clear();
- fStringBuffer.append("xml");
- while (XMLChar.isName(peekChar())) {
- fStringBuffer.append((char)scanChar());
- }
- String target = fSymbolTable.addSymbol(fStringBuffer.ch,
- fStringBuffer.offset,
- fStringBuffer.length);
- scanPIData(target, fString);
- }
+ if (skipString("<?xml")) {
+ fMarkupDepth++;
+ // NOTE: special case where document starts with a PI
+ // whose name starts with "xml" (e.g. "xmlfoo")
+ if (XMLChar.isName(peekChar())) {
+ fStringBuffer.clear();
+ fStringBuffer.append("xml");
+ while (XMLChar.isName(peekChar())) {
+ fStringBuffer.append((char) scanChar());
+ }
+ String target = fSymbolTable.addSymbol(fStringBuffer.ch,
+ fStringBuffer.offset,
+ fStringBuffer.length);
+ scanPIData(target, fString);
+ }
- // standard XML declaration
- else {
- scanXMLDeclOrTextDecl(false);
- }
- }
+ // standard XML declaration
+ else {
+ scanXMLDeclOrTextDecl(false);
+ }
+ }
}
-
+
// Adapted from:
// org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanXMLDeclOrTextDecl
/**
* Scans an XML or text declaration.
- * <p>
+ * <p/>
* <pre>
* [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
* [24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ")
@@ -1237,7 +1212,7 @@
* [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
* [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'")
* | ('"' ('yes' | 'no') '"'))
- *
+ * <p/>
* [77] TextDecl ::= '<?xml' VersionInfo? EncodingDecl S? '?>'
* </pre>
*
@@ -1245,8 +1220,8 @@
* be scanned instead of an XML
* declaration.
*/
- private void scanXMLDeclOrTextDecl(boolean scanningTextDecl)
- throws IOException, JasperException {
+ private void scanXMLDeclOrTextDecl(boolean scanningTextDecl)
+ throws IOException, JasperException {
// scan decl
scanXMLDeclOrTextDecl(scanningTextDecl, fStrings);
@@ -1258,7 +1233,7 @@
// set encoding on reader
if (encodingPseudoAttr != null) {
isEncodingSetInProlog = true;
- encoding = encodingPseudoAttr;
+ encoding = encodingPseudoAttr;
}
}
@@ -1266,7 +1241,7 @@
// org.apache.xerces.impl.XMLScanner.scanXMLDeclOrTextDecl
/**
* Scans an XML or text declaration.
- * <p>
+ * <p/>
* <pre>
* [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
* [24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ")
@@ -1274,23 +1249,23 @@
* [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
* [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'")
* | ('"' ('yes' | 'no') '"'))
- *
+ * <p/>
* [77] TextDecl ::= '<?xml' VersionInfo? EncodingDecl S? '?>'
* </pre>
*
- * @param scanningTextDecl True if a text declaration is to
- * be scanned instead of an XML
- * declaration.
+ * @param scanningTextDecl True if a text declaration is to
+ * be scanned instead of an XML
+ * declaration.
* @param pseudoAttributeValues An array of size 3 to return the version,
- * encoding and standalone pseudo attribute values
- * (in that order).
- *
- * <strong>Note:</strong> This method uses fString, anything in it
- * at the time of calling is lost.
+ * encoding and standalone pseudo attribute values
+ * (in that order).
+ * <p/>
+ * <strong>Note:</strong> This method uses fString, anything in it
+ * at the time of calling is lost.
*/
private void scanXMLDeclOrTextDecl(boolean scanningTextDecl,
- String[] pseudoAttributeValues)
- throws IOException, JasperException {
+ String[] pseudoAttributeValues)
+ throws IOException, JasperException {
// pseudo-attribute values
String version = null;
@@ -1314,18 +1289,18 @@
if (name == fVersionSymbol) {
if (!sawSpace) {
reportFatalError(scanningTextDecl
- ? "jsp.error.xml.spaceRequiredBeforeVersionInTextDecl"
- : "jsp.error.xml.spaceRequiredBeforeVersionInXMLDecl",
- null);
+ ? "jsp.error.xml.spaceRequiredBeforeVersionInTextDecl"
+ : "jsp.error.xml.spaceRequiredBeforeVersionInXMLDecl",
+ null);
}
version = fString.toString();
state = STATE_ENCODING;
if (!version.equals("1.0")) {
// REVISIT: XML REC says we should throw an error
- // in such cases.
+ // in such cases.
// some may object the throwing of fatalError.
err.jspError("jsp.error.xml.versionNotSupported",
- version);
+ version);
}
} else if (name == fEncodingSymbol) {
if (!scanningTextDecl) {
@@ -1333,17 +1308,16 @@
}
if (!sawSpace) {
reportFatalError(scanningTextDecl
- ? "jsp.error.xml.spaceRequiredBeforeEncodingInTextDecl"
- : "jsp.error.xml.spaceRequiredBeforeEncodingInXMLDecl",
- null);
+ ? "jsp.error.xml.spaceRequiredBeforeEncodingInTextDecl"
+ : "jsp.error.xml.spaceRequiredBeforeEncodingInXMLDecl",
+ null);
}
encoding = fString.toString();
state = scanningTextDecl ? STATE_DONE : STATE_STANDALONE;
} else {
if (scanningTextDecl) {
err.jspError("jsp.error.xml.encodingDeclRequired");
- }
- else {
+ } else {
err.jspError("jsp.error.xml.versionInfoRequired");
}
}
@@ -1353,9 +1327,9 @@
if (name == fEncodingSymbol) {
if (!sawSpace) {
reportFatalError(scanningTextDecl
- ? "jsp.error.xml.spaceRequiredBeforeEncodingInTextDecl"
- : "jsp.error.xml.spaceRequiredBeforeEncodingInXMLDecl",
- null);
+ ? "jsp.error.xml.spaceRequiredBeforeEncodingInTextDecl"
+ : "jsp.error.xml.spaceRequiredBeforeEncodingInXMLDecl",
+ null);
}
encoding = fString.toString();
state = scanningTextDecl ? STATE_DONE : STATE_STANDALONE;
@@ -1386,7 +1360,7 @@
err.jspError("jsp.error.xml.sdDeclInvalid");
}
} else {
- err.jspError("jsp.error.xml.encodingDeclRequired");
+ err.jspError("jsp.error.xml.encodingDeclRequired");
}
break;
}
@@ -1400,9 +1374,9 @@
if (scanningTextDecl && state != STATE_DONE) {
err.jspError("jsp.error.xml.morePseudoAttributes");
}
-
+
// If there is no data in the xml or text decl then we fail to report
- // error for version or encoding info above.
+ // error for version or encoding info above.
if (scanningTextDecl) {
if (!dataFoundForTarget && encoding == null) {
err.jspError("jsp.error.xml.encodingDeclRequired");
@@ -1421,7 +1395,7 @@
err.jspError("jsp.error.xml.xmlDeclUnterminated");
}
-
+
// fill in return array
pseudoAttributeValues[0] = version;
pseudoAttributeValues[1] = encoding;
@@ -1434,20 +1408,19 @@
* Scans a pseudo attribute.
*
* @param scanningTextDecl True if scanning this pseudo-attribute for a
- * TextDecl; false if scanning XMLDecl. This
+ * TextDecl; false if scanning XMLDecl. This
* flag is needed to report the correct type of
* error.
- * @param value The string to fill in with the attribute
+ * @param value The string to fill in with the attribute
* value.
- *
* @return The name of the attribute
- *
- * <strong>Note:</strong> This method uses fStringBuffer2, anything in it
- * at the time of calling is lost.
+ * <p/>
+ * <strong>Note:</strong> This method uses fStringBuffer2, anything in it
+ * at the time of calling is lost.
*/
- public String scanPseudoAttribute(boolean scanningTextDecl,
- XMLString value)
- throws IOException, JasperException {
+ public String scanPseudoAttribute(boolean scanningTextDecl,
+ XMLString value)
+ throws IOException, JasperException {
String name = scanName();
if (name == null) {
@@ -1456,17 +1429,17 @@
skipSpaces();
if (!skipChar('=')) {
reportFatalError(scanningTextDecl ?
- "jsp.error.xml.eqRequiredInTextDecl"
- : "jsp.error.xml.eqRequiredInXMLDecl",
- name);
+ "jsp.error.xml.eqRequiredInTextDecl"
+ : "jsp.error.xml.eqRequiredInXMLDecl",
+ name);
}
skipSpaces();
int quote = peekChar();
if (quote != '\'' && quote != '"') {
reportFatalError(scanningTextDecl ?
- "jsp.error.xml.quoteRequiredInTextDecl"
- : "jsp.error.xml.quoteRequiredInXMLDecl" ,
- name);
+ "jsp.error.xml.quoteRequiredInTextDecl"
+ : "jsp.error.xml.quoteRequiredInXMLDecl",
+ name);
}
scanChar();
int c = scanLiteral(quote, value);
@@ -1476,15 +1449,13 @@
fStringBuffer2.append(value);
if (c != -1) {
if (c == '&' || c == '%' || c == '<' || c == ']') {
- fStringBuffer2.append((char)scanChar());
- }
- else if (XMLChar.isHighSurrogate(c)) {
+ fStringBuffer2.append((char) scanChar());
+ } else if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer2);
- }
- else if (XMLChar.isInvalid(c)) {
+ } else if (XMLChar.isInvalid(c)) {
String key = scanningTextDecl
- ? "jsp.error.xml.invalidCharInTextDecl"
- : "jsp.error.xml.invalidCharInXMLDecl";
+ ? "jsp.error.xml.invalidCharInTextDecl"
+ : "jsp.error.xml.invalidCharInXMLDecl";
reportFatalError(key, Integer.toString(c, 16));
scanChar();
}
@@ -1496,31 +1467,31 @@
}
if (!skipChar(quote)) {
reportFatalError(scanningTextDecl ?
- "jsp.error.xml.closeQuoteMissingInTextDecl"
- : "jsp.error.xml.closeQuoteMissingInXMLDecl",
- name);
+ "jsp.error.xml.closeQuoteMissingInTextDecl"
+ : "jsp.error.xml.closeQuoteMissingInXMLDecl",
+ name);
}
// return
return name;
}
-
+
// Adapted from:
// org.apache.xerces.impl.XMLScanner.scanPIData
/**
* Scans a processing data. This is needed to handle the situation
- * where a document starts with a processing instruction whose
+ * where a document starts with a processing instruction whose
* target name <em>starts with</em> "xml". (e.g. xmlfoo)
- *
+ * <p/>
* <strong>Note:</strong> This method uses fStringBuffer, anything in it
* at the time of calling is lost.
*
* @param target The PI target
- * @param data The string to fill in with the data
+ * @param data The string to fill in with the data
*/
- private void scanPIData(String target, XMLString data)
- throws IOException, JasperException {
+ private void scanPIData(String target, XMLString data)
+ throws IOException, JasperException {
// check target
if (target.length() == 3) {
@@ -1538,8 +1509,7 @@
// we found the end, there is no data
data.clear();
return;
- }
- else {
+ } else {
// if there is data there should be some space
err.jspError("jsp.error.xml.spaceRequiredInPI");
}
@@ -1555,7 +1525,7 @@
scanSurrogates(fStringBuffer);
} else if (XMLChar.isInvalid(c)) {
err.jspError("jsp.error.xml.invalidCharInPI",
- Integer.toHexString(c));
+ Integer.toHexString(c));
scanChar();
}
}
@@ -1569,7 +1539,7 @@
// org.apache.xerces.impl.XMLScanner.scanSurrogates
/**
* Scans surrogates and append them to the specified buffer.
- * <p>
+ * <p/>
* <strong>Note:</strong> This assumes the current char has already been
* identified as a high surrogate.
*
@@ -1577,30 +1547,30 @@
* @returns True if it succeeded.
*/
private boolean scanSurrogates(XMLStringBuffer buf)
- throws IOException, JasperException {
+ throws IOException, JasperException {
int high = scanChar();
int low = peekChar();
if (!XMLChar.isLowSurrogate(low)) {
err.jspError("jsp.error.xml.invalidCharInContent",
- Integer.toString(high, 16));
+ Integer.toString(high, 16));
return false;
}
scanChar();
// convert surrogates to supplemental character
- int c = XMLChar.supplemental((char)high, (char)low);
+ int c = XMLChar.supplemental((char) high, (char) low);
// supplemental character must be a valid XML character
if (!XMLChar.isValid(c)) {
err.jspError("jsp.error.xml.invalidCharInContent",
- Integer.toString(c, 16));
+ Integer.toString(c, 16));
return false;
}
// fill in the buffer
- buf.append((char)high);
- buf.append((char)low);
+ buf.append((char) high);
+ buf.append((char) low);
return true;
@@ -1612,7 +1582,7 @@
* Convenience function used in all XML scanners.
*/
private void reportFatalError(String msgId, String arg)
- throws JasperException {
+ throws JasperException {
err.jspError(msgId, arg);
}
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLString.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLString.java
index 58a0ab3..1e8220e 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLString.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLString.java
@@ -29,16 +29,16 @@
* This class is used as a structure to pass text contained in the underlying
* character buffer of the scanner. The offset and length fields allow the
* buffer to be re-used without creating new character arrays.
- * <p>
+ * <p/>
* <strong>Note:</strong> Methods that are passed an XMLString structure
* should consider the contents read-only and not make any modifications
* to the contents of the buffer. The method receiving this structure
* should also not modify the offset and length if this structure (or
* the values of this structure) are passed to another method.
- * <p>
+ * <p/>
* <strong>Note:</strong> Methods that are passed an XMLString structure
* are required to copy the information out of the buffer if it is to be
- * saved for use beyond the scope of the method. The contents of the
+ * saved for use beyond the scope of the method. The contents of the
* structure are volatile and the contents of the character buffer cannot
* be assured once the method that is passed this structure returns.
* Therefore, methods passed this structure should not save any reference
@@ -46,7 +46,6 @@
*
* @author Eric Ye, IBM
* @author Andy Clark, IBM
- *
* @version $Id: XMLString.java 466606 2006-10-21 23:07:12Z markt $
*/
public class XMLString {
@@ -55,27 +54,35 @@
// Data
//
- /** The character array. */
+ /**
+ * The character array.
+ */
public char[] ch;
- /** The offset into the character array. */
+ /**
+ * The offset into the character array.
+ */
public int offset;
- /** The length of characters from the offset. */
+ /**
+ * The length of characters from the offset.
+ */
public int length;
//
// Constructors
//
- /** Default constructor. */
+ /**
+ * Default constructor.
+ */
public XMLString() {
} // <init>()
/**
* Constructs an XMLString structure preset with the specified
* values.
- *
+ *
* @param ch The character array.
* @param offset The offset into the character array.
* @param length The length of characters from the offset.
@@ -87,7 +94,7 @@
/**
* Constructs an XMLString structure with copies of the values in
* the given structure.
- * <p>
+ * <p/>
* <strong>Note:</strong> This does not copy the character array;
* only the reference to the array is copied.
*
@@ -104,7 +111,7 @@
/**
* Initializes the contents of the XMLString structure with the
* specified values.
- *
+ *
* @param ch The character array.
* @param offset The offset into the character array.
* @param length The length of characters from the offset.
@@ -118,17 +125,19 @@
/**
* Initializes the contents of the XMLString structure with copies
* of the given string structure.
- * <p>
+ * <p/>
* <strong>Note:</strong> This does not copy the character array;
* only the reference to the array is copied.
- *
+ *
* @param s
*/
public void setValues(XMLString s) {
setValues(s.ch, s.offset, s.length);
} // setValues(XMLString)
- /** Resets all of the values to their defaults. */
+ /**
+ * Resets all of the values to their defaults.
+ */
public void clear() {
this.ch = null;
this.offset = 0;
@@ -138,7 +147,7 @@
/**
* Returns true if the contents of this XMLString structure and
* the specified array are equal.
- *
+ *
* @param ch The character array.
* @param offset The offset into the character array.
* @param length The length of characters from the offset.
@@ -151,8 +160,8 @@
return false;
}
- for (int i=0; i<length; i++) {
- if (this.ch[this.offset+i] != ch[offset+i] ) {
+ for (int i = 0; i < length; i++) {
+ if (this.ch[this.offset + i] != ch[offset + i]) {
return false;
}
}
@@ -162,22 +171,22 @@
/**
* Returns true if the contents of this XMLString structure and
* the specified string are equal.
- *
+ *
* @param s The string to compare.
*/
public boolean equals(String s) {
if (s == null) {
return false;
}
- if ( length != s.length() ) {
+ if (length != s.length()) {
return false;
}
// is this faster than call s.toCharArray first and compare the
// two arrays directly, which will possibly involve creating a
// new char array object.
- for (int i=0; i<length; i++) {
- if (ch[offset+i] != s.charAt(i)) {
+ for (int i = 0; i < length; i++) {
+ if (ch[offset + i] != s.charAt(i)) {
return false;
}
}
@@ -189,7 +198,9 @@
// Object methods
//
- /** Returns a string representation of this object. */
+ /**
+ * Returns a string representation of this object.
+ */
public String toString() {
return length > 0 ? new String(ch, offset, length) : "";
} // toString():String
diff --git a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLStringBuffer.java b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLStringBuffer.java
index 14a471e..d97dbde 100644
--- a/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLStringBuffer.java
+++ b/struts2-jsp-plugin/src/main/java/org/apache/struts2/jasper/xmlparser/XMLStringBuffer.java
@@ -32,28 +32,29 @@
* expecting an XMLString object. This is a safe operation because
* it is assumed that any callee will <strong>not</strong> modify
* the contents of the XMLString structure.
- * <p>
+ * <p/>
* The contents of the string are managed by the string buffer. As
* characters are appended, the string buffer will grow as needed.
- * <p>
- * <strong>Note:</strong> Never set the <code>ch</code>,
+ * <p/>
+ * <strong>Note:</strong> Never set the <code>ch</code>,
* <code>offset</code>, and <code>length</code> fields directly.
* These fields are managed by the string buffer. In order to reset
* the buffer, call <code>clear()</code>.
- *
+ *
* @author Andy Clark, IBM
* @author Eric Ye, IBM
- *
* @version $Id: XMLStringBuffer.java 466606 2006-10-21 23:07:12Z markt $
*/
public class XMLStringBuffer
- extends XMLString {
+ extends XMLString {
//
// Constants
//
- /** Default buffer size (32). */
+ /**
+ * Default buffer size (32).
+ */
public static final int DEFAULT_SIZE = 32;
//
@@ -61,40 +62,46 @@
//
/**
- *
+ *
*/
public XMLStringBuffer() {
this(DEFAULT_SIZE);
} // <init>()
/**
- *
- *
- * @param size
+ * @param size
*/
public XMLStringBuffer(int size) {
ch = new char[size];
} // <init>(int)
- /** Constructs a string buffer from a char. */
+ /**
+ * Constructs a string buffer from a char.
+ */
public XMLStringBuffer(char c) {
this(1);
append(c);
} // <init>(char)
- /** Constructs a string buffer from a String. */
+ /**
+ * Constructs a string buffer from a String.
+ */
public XMLStringBuffer(String s) {
this(s.length());
append(s);
} // <init>(String)
- /** Constructs a string buffer from the specified character array. */
+ /**
+ * Constructs a string buffer from the specified character array.
+ */
public XMLStringBuffer(char[] ch, int offset, int length) {
this(length);
append(ch, offset, length);
} // <init>(char[],int,int)
- /** Constructs a string buffer from the specified XMLString. */
+ /**
+ * Constructs a string buffer from the specified XMLString.
+ */
public XMLStringBuffer(XMLString s) {
this(s.length);
append(s);
@@ -104,7 +111,9 @@
// Public methods
//
- /** Clears the string buffer. */
+ /**
+ * Clears the string buffer.
+ */
public void clear() {
offset = 0;
length = 0;
@@ -112,17 +121,17 @@
/**
* append
- *
- * @param c
+ *
+ * @param c
*/
public void append(char c) {
if (this.length + 1 > this.ch.length) {
- int newLength = this.ch.length*2;
- if (newLength < this.ch.length + DEFAULT_SIZE)
- newLength = this.ch.length + DEFAULT_SIZE;
- char[] newch = new char[newLength];
- System.arraycopy(this.ch, 0, newch, 0, this.length);
- this.ch = newch;
+ int newLength = this.ch.length * 2;
+ if (newLength < this.ch.length + DEFAULT_SIZE)
+ newLength = this.ch.length + DEFAULT_SIZE;
+ char[] newch = new char[newLength];
+ System.arraycopy(this.ch, 0, newch, 0, this.length);
+ this.ch = newch;
}
this.ch[this.length] = c;
this.length++;
@@ -130,16 +139,16 @@
/**
* append
- *
- * @param s
+ *
+ * @param s
*/
public void append(String s) {
int length = s.length();
if (this.length + length > this.ch.length) {
- int newLength = this.ch.length*2;
+ int newLength = this.ch.length * 2;
if (newLength < this.length + length + DEFAULT_SIZE)
newLength = this.ch.length + length + DEFAULT_SIZE;
- char[] newch = new char[newLength];
+ char[] newch = new char[newLength];
System.arraycopy(this.ch, 0, newch, 0, this.length);
this.ch = newch;
}
@@ -149,10 +158,10 @@
/**
* append
- *
- * @param ch
- * @param offset
- * @param length
+ *
+ * @param ch
+ * @param offset
+ * @param length
*/
public void append(char[] ch, int offset, int length) {
if (this.length + length > this.ch.length) {
@@ -166,8 +175,8 @@
/**
* append
- *
- * @param s
+ *
+ * @param s
*/
public void append(XMLString s) {
append(s.ch, s.offset, s.length);
diff --git a/struts2-jsp-plugin/src/main/resources/struts-plugin.xml b/struts2-jsp-plugin/src/main/resources/struts-plugin.xml
index 35a15a0..8f30dc0 100644
--- a/struts2-jsp-plugin/src/main/resources/struts-plugin.xml
+++ b/struts2-jsp-plugin/src/main/resources/struts-plugin.xml
@@ -22,15 +22,15 @@
*/
-->
<!DOCTYPE struts PUBLIC
- "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
- "http://struts.apache.org/dtds/struts-2.0.dtd">
+ "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+ "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="jsp-default" extends="struts-default">
- <result-types>
- <result-type name="embeddedJsp" class="org.apache.struts2.EmbeddedJSPResult"/>
- </result-types>
+ <result-types>
+ <result-type name="embeddedJsp" class="org.apache.struts2.EmbeddedJSPResult"/>
+ </result-types>
</package>
</struts>
diff --git a/struts2-jsp-plugin/src/test/java/org/apache/struts2/EmbeddedJSPResultTest.java b/struts2-jsp-plugin/src/test/java/org/apache/struts2/EmbeddedJSPResultTest.java
index 3784f80..9314b93 100644
--- a/struts2-jsp-plugin/src/test/java/org/apache/struts2/EmbeddedJSPResultTest.java
+++ b/struts2-jsp-plugin/src/test/java/org/apache/struts2/EmbeddedJSPResultTest.java
@@ -25,22 +25,21 @@
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.util.ValueStack;
import junit.framework.TestCase;
-import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.xwork.StringUtils;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;
+import javax.servlet.Servlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
-import javax.servlet.Servlet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.List;
import java.util.ArrayList;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.CyclicBarrier;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
public class EmbeddedJSPResultTest extends TestCase {
private HttpServletRequest request;
@@ -48,6 +47,22 @@
private MockServletContext context;
private EmbeddedJSPResult result;
+ public void testEmbedded() throws Exception {
+ //the jsp is inside jsps.jar
+ result.setLocation("dir/all.jsp");
+ result.execute(null);
+
+ assertEquals("helloJGWhoamI?XXXXXXXXXXXYThissessionisnotsecure.", StringUtils.deleteWhitespace(response.getContentAsString()));
+ }
+
+ public void testEmbeddedAbsolutePath() throws Exception {
+ //the jsp is inside jsps.jar
+ result.setLocation("/dir/all.jsp");
+ result.execute(null);
+
+ assertEquals("helloJGWhoamI?XXXXXXXXXXXYThissessionisnotsecure.", StringUtils.deleteWhitespace(response.getContentAsString()));
+ }
+
public void testSimple() throws Exception {
result.setLocation("org/apache/struts2/simple0.jsp");
result.execute(null);
@@ -66,35 +81,35 @@
result.setLocation("org/apache/struts2/tag0.jsp");
result.execute(null);
- assertEquals("Thissessionisnotsecure.OtherText", cleanup(response.getContentAsString()));
+ assertEquals("Thissessionisnotsecure.OtherText", StringUtils.deleteWhitespace(response.getContentAsString()));
}
public void testIncludeSimple() throws Exception {
result.setLocation("org/apache/struts2/includes0.jsp");
result.execute(null);
- assertEquals("helloTest", cleanup(response.getContentAsString()));
+ assertEquals("helloTest", StringUtils.deleteWhitespace(response.getContentAsString()));
}
public void testIncludeSimpleWithDirective() throws Exception {
result.setLocation("org/apache/struts2/includes3.jsp");
result.execute(null);
- assertEquals("helloTest", cleanup(response.getContentAsString()));
+ assertEquals("helloTest", StringUtils.deleteWhitespace(response.getContentAsString()));
}
public void testIncludeWithSubdir() throws Exception {
result.setLocation("org/apache/struts2/includes1.jsp");
result.execute(null);
- assertEquals("subTest", cleanup(response.getContentAsString()));
+ assertEquals("subTest", StringUtils.deleteWhitespace(response.getContentAsString()));
}
public void testIncludeWithParam() throws Exception {
result.setLocation("org/apache/struts2/includes2.jsp");
result.execute(null);
- assertEquals("JGTest", cleanup(response.getContentAsString()));
+ assertEquals("JGTest", StringUtils.deleteWhitespace(response.getContentAsString()));
}
public void testBroken0() throws Exception {
@@ -111,7 +126,7 @@
result.setLocation("org/apache/struts2/jstl.jsp");
result.execute(null);
- assertEquals("XXXXXXXXXXXY", cleanup(response.getContentAsString()));
+ assertEquals("XXXXXXXXXXXY", StringUtils.deleteWhitespace(response.getContentAsString()));
}
@@ -154,18 +169,13 @@
}
}
- public void testBeans() throws Exception {
+ public void testBeans() throws Exception {
result.setLocation("org/apache/struts2/beans.jsp");
result.execute(null);
- assertEquals("WhoamI?", cleanup(response.getContentAsString()));
+ assertEquals("WhoamI?", StringUtils.deleteWhitespace(response.getContentAsString()));
}
- private String cleanup(String str) {
- return str.replaceAll("\\s", "");
- }
-
-
@Override
protected void setUp() throws Exception {
super.setUp();
diff --git a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/beans.jsp b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/beans.jsp
index 0f18aef..6d5222d 100644
--- a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/beans.jsp
+++ b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/beans.jsp
@@ -1,2 +1,2 @@
-<jsp:useBean id="mybean" class="org.apache.struts2.SoyBean" scope="page" />
-<jsp:getProperty name="mybean" property="message" />
+<jsp:useBean id="mybean" class="org.apache.struts2.SoyBean" scope="page"/>
+<jsp:getProperty name="mybean" property="message"/>
diff --git a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/broken0.jsp b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/broken0.jsp
index cd8160b..b4bf816 100644
--- a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/broken0.jsp
+++ b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/broken0.jsp
@@ -1,2 +1,2 @@
-<jsp:include page="org/apache/struts2/printParam.jsp" >
+<jsp:include page="org/apache/struts2/printParam.jsp">
\ No newline at end of file
diff --git a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/includes0.jsp b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/includes0.jsp
index a13faf2..d660643 100644
--- a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/includes0.jsp
+++ b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/includes0.jsp
@@ -1,2 +1,2 @@
-<jsp:include page="org/apache/struts2/simple0.jsp" />
+<jsp:include page="org/apache/struts2/simple0.jsp"/>
Test
\ No newline at end of file
diff --git a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/includes1.jsp b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/includes1.jsp
index f1a3deb..b08963f 100644
--- a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/includes1.jsp
+++ b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/includes1.jsp
@@ -1,2 +1,2 @@
-<jsp:include page="org/apache/struts2/sub/simple0.jsp" />
+<jsp:include page="org/apache/struts2/sub/simple0.jsp"/>
Test
\ No newline at end of file
diff --git a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/includes2.jsp b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/includes2.jsp
index 9ebdf99..442f5b3 100644
--- a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/includes2.jsp
+++ b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/includes2.jsp
@@ -1,4 +1,4 @@
-<jsp:include page="org/apache/struts2/printParam.jsp" >
- <jsp:param name="username" value="JG" />
+<jsp:include page="org/apache/struts2/printParam.jsp">
+ <jsp:param name="username" value="JG"/>
</jsp:include>
Test
\ No newline at end of file
diff --git a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/jstl.jsp b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/jstl.jsp
index f31dd21..82c7e61 100644
--- a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/jstl.jsp
+++ b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/jstl.jsp
@@ -2,8 +2,8 @@
<c:set var="number" value="10"/>
<c:forEach begin="0" end="${number}">
-X
+ X
</c:forEach>
<c:if test="${number < 15}">
-Y
+ Y
</c:if>
\ No newline at end of file
diff --git a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/tag0.jsp b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/tag0.jsp
index 7bdc194..55e2b05 100644
--- a/struts2-jsp-plugin/src/test/resources/org/apache/struts2/tag0.jsp
+++ b/struts2-jsp-plugin/src/test/resources/org/apache/struts2/tag0.jsp
@@ -1,5 +1,5 @@
<%@ taglib prefix="r" uri="http://jakarta.apache.org/taglibs/request-1.0" %>
<r:isSecure value="false">
- This session is not secure.
+ This session is not secure.
</r:isSecure>
OtherText
\ No newline at end of file