From 33fd46ea81ab5009a93ff7cf577f0915e407743a Mon Sep 17 00:00:00 2001 From: Mark Thomas Date: Fri, 7 Feb 2025 15:31:22 +0000 Subject: [PATCH] Code clean-up - formatting. No functional change. --- .../org/apache/jasper/compiler/JspReader.java | 320 +++++---- .../jasper/compiler/JspRuntimeContext.java | 139 ++-- java/org/apache/jasper/compiler/JspUtil.java | 328 +++++---- .../org/apache/jasper/compiler/Localizer.java | 18 +- java/org/apache/jasper/compiler/Mark.java | 8 +- .../NewlineReductionServletWriter.java | 11 +- java/org/apache/jasper/compiler/Node.java | 622 +++++++----------- 7 files changed, 609 insertions(+), 837 deletions(-) diff --git a/java/org/apache/jasper/compiler/JspReader.java b/java/org/apache/jasper/compiler/JspReader.java index df3ee8a0f497..7681a9b44631 100644 --- a/java/org/apache/jasper/compiler/JspReader.java +++ b/java/org/apache/jasper/compiler/JspReader.java @@ -29,9 +29,8 @@ import org.apache.tomcat.Jar; /** - * JspReader is an input buffer for the JSP parser. It should allow - * unlimited lookahead and pushback. It also has a bunch of parsing - * utility methods for understanding htmlesque thingies. + * JspReader is an input buffer for the JSP parser. It should allow unlimited lookahead and pushback. It also has a + * bunch of parsing utility methods for understanding htmlesque thingies. * * @author Anil K. Vijendran * @author Anselm Baird-Smith @@ -69,41 +68,33 @@ class JspReader { /** * 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 jar ? - * @param err The error dispatcher - * @throws JasperException If a Jasper-internal error occurs + * @param jar ? + * @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 */ - JspReader(JspCompilationContext ctxt, - String fname, - String encoding, - Jar jar, - ErrorDispatcher err) + JspReader(JspCompilationContext ctxt, String fname, String encoding, Jar jar, ErrorDispatcher err) throws JasperException, FileNotFoundException, IOException { - this(ctxt, fname, JspUtil.getReader(fname, encoding, jar, ctxt, err), - err); + this(ctxt, fname, JspUtil.getReader(fname, encoding, jar, ctxt, err), err); } /** - * Constructor: same as above constructor but with initialized reader - * to the file given. + * Constructor: same as above constructor but with initialized reader to the file given. * * @param ctxt The compilation context * @param fname The file name * @param reader A reader for the JSP source file - * @param err The error dispatcher + * @param err The error dispatcher * * @throws JasperException If an error occurs parsing the JSP file */ - JspReader(JspCompilationContext ctxt, - String fname, - InputStreamReader reader, - ErrorDispatcher err) + JspReader(JspCompilationContext ctxt, String fname, InputStreamReader reader, ErrorDispatcher err) throws JasperException { this.context = ctxt; @@ -112,7 +103,7 @@ class JspReader { 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(); @@ -126,7 +117,7 @@ class JspReader { try { reader.close(); } catch (Exception any) { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(Localizer.getMessage("jsp.error.file.close"), any); } } @@ -136,8 +127,7 @@ class JspReader { /** - * @return JSP compilation context with which this JspReader is - * associated + * @return JSP compilation context with which this JspReader is associated */ JspCompilationContext getJspCompilationContext() { return context; @@ -171,9 +161,8 @@ int nextChar() { } /** - * A faster approach than calling {@link #mark()} & {@link #nextChar()}. - * However, this approach is only safe if the mark is only used within the - * JspReader. + * A faster approach than calling {@link #mark()} & {@link #nextChar()}. However, this approach is only safe if the + * mark is only used within the JspReader. */ private int nextChar(Mark mark) { if (!hasMoreInput()) { @@ -196,8 +185,7 @@ private int nextChar(Mark mark) { } /** - * Search the given character, If it was found, then mark the current cursor - * and the cursor point to next character. + * Search the given character, If it was found, then mark the current cursor and the cursor point to next character. */ private Boolean indexOf(char c, Mark mark) { if (!hasMoreInput()) { @@ -209,30 +197,30 @@ private Boolean indexOf(char c, Mark mark) { int line = current.line; int col = current.col; int i = current.cursor; - for(; i < end; i ++) { - ch = current.stream[i]; + for (; i < end; i++) { + ch = current.stream[i]; - if (ch == c) { - mark.update(i, line, col); - } - if (ch == '\n') { + if (ch == c) { + mark.update(i, line, col); + } + if (ch == '\n') { line++; col = 0; } else { col++; } - if (ch == c) { - current.update(i+1, line, col); - return Boolean.TRUE; - } + if (ch == c) { + current.update(i + 1, line, col); + return Boolean.TRUE; + } } current.update(i, line, col); return Boolean.FALSE; } /** - * Back up the current cursor by one char, assumes current.cursor > 0, - * and that the char to be pushed back is not '\n'. + * Back up the current cursor by one char, assumes current.cursor > 0, and that the char to be pushed back is not + * '\n'. */ void pushChar() { current.cursor--; @@ -263,11 +251,9 @@ int peekChar() { /** * Read ahead the given number of characters without moving the cursor. * - * @param readAhead The number of characters to read ahead. NOTE: This is - * zero based. + * @param readAhead The number of characters to read ahead. NOTE: This is zero based. * - * @return The requested character or -1 if the end of the input is reached - * first + * @return The requested character or -1 if the end of the input is reached first */ int peekChar(int readAhead) { int target = current.cursor + readAhead; @@ -286,7 +272,7 @@ Mark mark() { * This method avoids a call to {@link #mark()} when doing comparison. */ private boolean markEquals(Mark another) { - return another.equals(current); + return another.equals(current); } void reset(Mark mark) { @@ -294,55 +280,56 @@ void reset(Mark mark) { } /** - * Similar to {@link #reset(Mark)} but no new Mark will be created. - * Therefore, the parameter mark must NOT be used in other places. + * Similar to {@link #reset(Mark)} but no new Mark will be created. Therefore, the parameter mark must NOT be used + * in other places. */ private void setCurrent(Mark mark) { - current = mark; + current = mark; } /** * search the stream for a match to a string + * * @param string The string to match - * @return true is one is found, the current position - * in stream is positioned after the search string, - * false otherwise, position in stream unchanged. + * + * @return true is one is found, the current position in stream is positioned after the search + * string, false otherwise, position in stream unchanged. */ boolean matches(String string) { - int len = string.length(); - int cursor = current.cursor; - int streamSize = current.stream.length; - if (cursor + len < streamSize) { //Try to scan in memory - int line = current.line; - int col = current.col; - int ch; - int i = 0; - for(; i < len; i ++) { - ch = current.stream[i+cursor]; - if (string.charAt(i) != ch) { - return false; - } - if (ch == '\n') { - line ++; - col = 0; - } else { - col++; - } - } - current.update(i+cursor, line, col); - } else { - Mark mark = mark(); - int ch = 0; - int i = 0; - do { - ch = nextChar(); - if (((char) ch) != string.charAt(i++)) { - setCurrent(mark); - return false; - } - } while (i < len); - } - return true; + int len = string.length(); + int cursor = current.cursor; + int streamSize = current.stream.length; + if (cursor + len < streamSize) { // Try to scan in memory + int line = current.line; + int col = current.col; + int ch; + int i = 0; + for (; i < len; i++) { + ch = current.stream[i + cursor]; + if (string.charAt(i) != ch) { + return false; + } + if (ch == '\n') { + line++; + col = 0; + } else { + col++; + } + } + current.update(i + cursor, line, col); + } else { + Mark mark = mark(); + int ch = 0; + int i = 0; + do { + ch = nextChar(); + if (((char) ch) != string.charAt(i++)) { + setCurrent(mark); + return false; + } + } while (i < len); + } + return true; } boolean matchesETag(String tagName) { @@ -361,33 +348,32 @@ boolean matchesETag(String tagName) { } boolean matchesETagWithoutLessThan(String tagName) { - Mark mark = mark(); + Mark mark = mark(); - if (!matches("/" + tagName)) { - return false; - } - skipSpaces(); - if (nextChar() == '>') { - return true; - } + if (!matches("/" + tagName)) { + return false; + } + skipSpaces(); + if (nextChar() == '>') { + return true; + } - setCurrent(mark); - return false; + setCurrent(mark); + return false; } /** - * Looks ahead to see if there are optional spaces followed by - * the given String. If so, true is returned and those spaces and - * characters are skipped. If not, false is returned and the - * position is restored to where we were before. + * Looks ahead to see if there are optional spaces followed by the given String. If so, true is returned and those + * spaces and characters are skipped. If not, false is returned and the position is restored to where we were + * before. */ boolean matchesOptionalSpacesFollowedBy(String s) { Mark mark = mark(); skipSpaces(); - boolean result = matches( s ); - if( !result ) { + boolean result = matches(s); + if (!result) { setCurrent(mark); } @@ -404,13 +390,13 @@ int skipSpaces() { } /** - * Skip until the given string is matched in the stream. - * When returned, the context is positioned past the end of the match. + * Skip until the given string is matched in the stream. When returned, the context is positioned past the end of + * the match. * * @param limit The String to match. - * @return A non-null Mark instance (positioned immediately - * before the search string) if found, null - * otherwise. + * + * @return A non-null Mark instance (positioned immediately before the search string) if found, + * null otherwise. */ Mark skipUntil(String limit) { Mark ret = mark(); @@ -419,58 +405,54 @@ Mark skipUntil(String limit) { Boolean result = null; Mark restart = null; - skip: - while((result = indexOf(firstChar, ret)) != null) { - if (result.booleanValue()) { - if (restart != null) { - restart.init(current, true); - } else { - restart = mark(); - } - for (int i = 1 ; i < limlen ; i++) { - if (peekChar() == limit.charAt(i)) { - nextChar(); - } else { - current.init(restart, true); - continue skip; - } - } - return ret; + skip: while ((result = indexOf(firstChar, ret)) != null) { + if (result.booleanValue()) { + if (restart != null) { + restart.init(current, true); + } else { + restart = mark(); + } + for (int i = 1; i < limlen; i++) { + if (peekChar() == limit.charAt(i)) { + nextChar(); + } else { + current.init(restart, true); + continue skip; + } + } + return ret; } } return null; } /** - * Skip until the given string is matched in the stream, but ignoring - * chars initially escaped by a '\' and any EL expressions. - * When returned, the context is positioned past the end of the match. + * Skip until the given string is matched in the stream, but ignoring chars initially escaped by a '\' and any EL + * expressions. When returned, the context is positioned past the end of the match. * * @param limit The String to match. - * @param ignoreEL true if something that looks like EL should - * not be treated as EL. - * @return A non-null Mark instance (positioned immediately - * before the search string) if found, null - * otherwise. + * @param ignoreEL true if something that looks like EL should not be treated as EL. + * + * @return A non-null Mark instance (positioned immediately before the search string) if found, + * null otherwise. */ Mark skipUntilIgnoreEsc(String limit, boolean ignoreEL) { Mark ret = mark(); int limlen = limit.length(); int ch; - int prev = 'x'; // Doesn't matter + int prev = 'x'; // Doesn't matter char firstChar = limit.charAt(0); - skip: - for (ch = nextChar(ret) ; ch != -1 ; prev = ch, ch = nextChar(ret)) { + skip: for (ch = nextChar(ret); ch != -1; prev = ch, ch = nextChar(ret)) { if (ch == '\\' && prev == '\\') { - ch = 0; // Double \ is not an escape char anymore + ch = 0; // Double \ is not an escape char anymore } else if (prev == '\\') { continue; - } else if (!ignoreEL && (ch == '$' || ch == '#') && peekChar() == '{' ) { + } else if (!ignoreEL && (ch == '$' || ch == '#') && peekChar() == '{') { // Move beyond the '{' nextChar(); skipELExpression(); } else if (ch == firstChar) { - for (int i = 1 ; i < limlen ; i++) { + for (int i = 1; i < limlen; i++) { if (peekChar() == limit.charAt(i)) { nextChar(); } else { @@ -484,12 +466,13 @@ Mark skipUntilIgnoreEsc(String limit, boolean ignoreEL) { } /** - * Skip until the given end tag is matched in the stream. - * When returned, the context is positioned past the end of the tag. + * 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 Mark instance (positioned immediately - * before the ETag) if found, null otherwise. + * + * @return A non-null Mark instance (positioned immediately before the ETag) if found, + * null otherwise. */ Mark skipUntilETag(String tag) { Mark ret = skipUntil(" - * In case of success, this method returns Mark for the last - * character before the terminating '}' and reader is positioned just after - * the '}' character. If no terminating '}' is encountered, this method - * returns null. + * In case of success, this method returns Mark for the last character before the terminating '}' and + * reader is positioned just after the '}' character. If no terminating '}' is encountered, this method returns + * null. *

* Starting with EL 3.0, nested paired {}s are supported. * @@ -517,8 +499,8 @@ Mark skipUntilETag(String tag) { */ Mark skipELExpression() { // ELExpressionBody. - // Starts with "#{" or "${". Ends with "}". - // May contain quoted "{", "}", '{', or '}' and nested "{...}" + // Starts with "#{" or "${". Ends with "}". + // May contain quoted "{", "}", '{', or '}' and nested "{...}" Mark last = mark(); boolean singleQuoted = false; boolean doubleQuoted = false; @@ -542,11 +524,11 @@ Mark skipELExpression() { singleQuoted = !singleQuoted; } else if (currentChar == '{' && !doubleQuoted && !singleQuoted) { nesting++; - } else if (currentChar =='}' && !doubleQuoted && !singleQuoted) { + } else if (currentChar == '}' && !doubleQuoted && !singleQuoted) { // Note: This also matches the terminating '}' at which point - // nesting will be set to -1 - hence the test for - // while (currentChar != '}' || nesting > -1 ||...) below - // to continue the loop until the final '}' is detected + // nesting will be set to -1 - hence the test for + // while (currentChar != '}' || nesting > -1 ||...) below + // to continue the loop until the final '}' is detected nesting--; } } while (currentChar != '}' || singleQuoted || doubleQuoted || nesting > -1); @@ -560,9 +542,8 @@ final boolean isSpace() { } /** - * Parse a space delimited token. - * If quoted the token will consume all characters up to a matching quote, - * otherwise, it consumes up to the first delimiter character. + * Parse a space delimited token. If quoted the token will consume all characters up to a matching quote, otherwise, + * it consumes up to the first delimiter character. * * @param quoted If true accept quoted strings. */ @@ -583,8 +564,7 @@ String parseToken(boolean quoted) throws JasperException { char endQuote = ch == '"' ? '"' : '\''; // Consume the open quote: ch = nextChar(); - for (ch = nextChar(); ch != -1 && ch != endQuote; - ch = nextChar()) { + for (ch = nextChar(); ch != -1 && ch != endQuote; ch = nextChar()) { if (ch == '\\') { ch = nextChar(); } @@ -604,8 +584,7 @@ String parseToken(boolean quoted) throws JasperException { ch = nextChar(); // Take care of the quoting here. if (ch == '\\') { - if (peekChar() == '"' || peekChar() == '\'' || - peekChar() == '>' || peekChar() == '%') { + if (peekChar() == '"' || peekChar() == '\'' || peekChar() == '>' || peekChar() == '%') { ch = nextChar(); } } @@ -619,25 +598,22 @@ String parseToken(boolean quoted) throws JasperException { /** - * Parse utils - Is current character a token delimiter ? - * Delimiters are currently defined to be =, >, <, ", and ' or any - * any space character as defined by isSpace. + * Parse utils - Is current character a token delimiter ? Delimiters are currently defined to be =, >, <, ", + * and ' or any any space character as defined by isSpace. * * @return A boolean. */ private boolean isDelimiter() { - if (! isSpace()) { + if (!isSpace()) { int ch = peekChar(); // Look for a single-char work delimiter: - if (ch == '=' || ch == '>' || ch == '"' || ch == '\'' - || ch == '/') { + if (ch == '=' || ch == '>' || ch == '"' || ch == '\'' || ch == '/') { return true; } // Look for an end-of-comment or end-of-tag: if (ch == '-') { Mark mark = mark(); - if (((ch = nextChar()) == '>') - || ((ch == '-') && (nextChar() == '>'))) { + if (((ch = nextChar()) == '>') || ((ch == '-') && (nextChar() == '>'))) { setCurrent(mark); return true; } else { diff --git a/java/org/apache/jasper/compiler/JspRuntimeContext.java b/java/org/apache/jasper/compiler/JspRuntimeContext.java index 12f53c434a4f..5a0760c1e8a0 100644 --- a/java/org/apache/jasper/compiler/JspRuntimeContext.java +++ b/java/org/apache/jasper/compiler/JspRuntimeContext.java @@ -47,14 +47,9 @@ /** - * Class for tracking JSP compile time file dependencies when the - * >%@include file="..."%< directive is used. - * - * A background thread periodically checks the files a JSP page - * is dependent upon. If a dependent file changes the JSP page - * which included it is recompiled. - * - * Only used if a web application context is a directory. + * Class for tracking JSP compile time file dependencies when the >%@include file="..."%< directive is used. A + * background thread periodically checks the files a JSP page is dependent upon. If a dependent file changes the JSP + * page which included it is recompiled. Only used if a web application context is a directory. * * @author Glenn L. Nielsen */ @@ -78,9 +73,8 @@ public final class JspRuntimeContext { // ----------------------------------------------------------- Constructors /** - * Create a JspRuntimeContext for a web application context. - * - * Loads in any previously generated dependencies from file. + * Create a JspRuntimeContext for a web application context. Loads in any previously generated dependencies from + * file. * * @param context ServletContext for web application * @param options The main Jasper options @@ -98,15 +92,13 @@ public JspRuntimeContext(ServletContext context, Options options) { if (log.isTraceEnabled()) { if (loader != null) { - log.trace(Localizer.getMessage("jsp.message.parent_class_loader_is", - loader.toString())); + log.trace(Localizer.getMessage("jsp.message.parent_class_loader_is", loader.toString())); } else { - log.trace(Localizer.getMessage("jsp.message.parent_class_loader_is", - "")); + log.trace(Localizer.getMessage("jsp.message.parent_class_loader_is", "")); } } - parentClassLoader = loader; + parentClassLoader = loader; classpath = initClassPath(); if (context instanceof org.apache.jasper.servlet.JspCServletContext) { @@ -127,17 +119,15 @@ public JspRuntimeContext(ServletContext context, Options options) { // If this web application context is running from a // directory, start the background compilation thread String appBase = context.getRealPath("/"); - if (!options.getDevelopment() - && appBase != null - && options.getCheckInterval() > 0) { + if (!options.getDevelopment() && appBase != null && options.getCheckInterval() > 0) { lastCompileCheck = System.currentTimeMillis(); } if (options.getMaxLoadedJsps() > 0) { jspQueue = new FastRemovalDequeue<>(options.getMaxLoadedJsps()); if (log.isTraceEnabled()) { - log.trace(Localizer.getMessage("jsp.message.jsp_queue_created", - "" + options.getMaxLoadedJsps(), context.getContextPath())); + log.trace(Localizer.getMessage("jsp.message.jsp_queue_created", "" + options.getMaxLoadedJsps(), + context.getContextPath())); } } @@ -164,7 +154,7 @@ public JspRuntimeContext(ServletContext context, Options options) { /** * Maps JSP pages to their JspServletWrapper's */ - private final Map jsps = new ConcurrentHashMap<>(); + private final Map jsps = new ConcurrentHashMap<>(); /** * Keeps JSP pages ordered by last access. @@ -172,9 +162,8 @@ public JspRuntimeContext(ServletContext context, Options options) { private FastRemovalDequeue jspQueue = null; /** - * Map of class name to associated source map. This is maintained here as - * multiple JSPs can depend on the same file (included JSP, tag file, etc.) - * so a web application scoped Map is required. + * Map of class name to associated source map. This is maintained here as multiple JSPs can depend on the same file + * (included JSP, tag file, etc.) so a web application scoped Map is required. */ private final Map smaps = new ConcurrentHashMap<>(); @@ -190,7 +179,7 @@ public JspRuntimeContext(ServletContext context, Options options) { * 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.put(jspUri, jsw); @@ -200,6 +189,7 @@ public void addWrapper(String jspUri, JspServletWrapper jsw) { * Get an already existing JspServletWrapper. * * @param jspUri JSP URI + * * @return JspServletWrapper for JSP */ public JspServletWrapper getWrapper(String jspUri) { @@ -207,7 +197,7 @@ public JspServletWrapper getWrapper(String jspUri) { } /** - * Remove a JspServletWrapper. + * Remove a JspServletWrapper. * * @param jspUri JSP URI of JspServletWrapper to remove */ @@ -216,23 +206,23 @@ public void removeWrapper(String jspUri) { } /** - * Push a newly compiled JspServletWrapper into the queue at first - * execution of jsp. Destroy any JSP that has been replaced in the queue. + * Push a newly compiled JspServletWrapper into the queue at first execution of jsp. Destroy any JSP that has been + * replaced in the queue. * * @param jsw Servlet wrapper for jsp. + * * @return an unloadHandle that can be pushed to front of queue at later execution times. - * */ + */ public FastRemovalDequeue.Entry push(JspServletWrapper jsw) { if (log.isTraceEnabled()) { - log.trace(Localizer.getMessage("jsp.message.jsp_added", - jsw.getJspUri(), context.getContextPath())); + log.trace(Localizer.getMessage("jsp.message.jsp_added", jsw.getJspUri(), context.getContextPath())); } FastRemovalDequeue.Entry entry = jspQueue.push(jsw); JspServletWrapper replaced = entry.getReplaced(); if (replaced != null) { if (log.isTraceEnabled()) { - log.trace(Localizer.getMessage("jsp.message.jsp_removed_excess", - replaced.getJspUri(), context.getContextPath())); + log.trace(Localizer.getMessage("jsp.message.jsp_removed_excess", replaced.getJspUri(), + context.getContextPath())); } unloadJspServletWrapper(replaced); entry.clearReplaced(); @@ -244,19 +234,18 @@ public FastRemovalDequeue.Entry push(JspServletWrapper jsw) { * Push unloadHandle for JspServletWrapper to front of the queue. * * @param unloadHandle the unloadHandle for the jsp. - * */ + */ public void makeYoungest(FastRemovalDequeue.Entry unloadHandle) { if (log.isTraceEnabled()) { JspServletWrapper jsw = unloadHandle.getContent(); - log.trace(Localizer.getMessage("jsp.message.jsp_queue_update", - jsw.getJspUri(), context.getContextPath())); + log.trace(Localizer.getMessage("jsp.message.jsp_queue_update", jsw.getJspUri(), context.getContextPath())); } jspQueue.moveFirst(unloadHandle); } /** - * Returns the number of JSPs for which JspServletWrappers exist, i.e., - * the number of JSPs that have been loaded into the webapp. + * Returns the number of JSPs for which JspServletWrappers exist, i.e., the number of JSPs that have been loaded + * into the webapp. * * @return The number of JSPs that have been loaded into the webapp */ @@ -265,8 +254,7 @@ public int getJspCount() { } /** - * Get the SecurityManager Policy CodeSource for this web - * application context. + * Get the SecurityManager Policy CodeSource for this web application context. * * @return CodeSource for JSP */ @@ -284,8 +272,7 @@ public ClassLoader getParentClassLoader() { } /** - * Get the SecurityManager PermissionCollection for this - * web application context. + * Get the SecurityManager PermissionCollection for this web application context. * * @return PermissionCollection permissions */ @@ -330,8 +317,8 @@ public int getJspReloadCount() { /** * Gets the number of JSPs that are in the JSP limiter queue * - * @return The number of JSPs (in the webapp with which this JspServlet is - * associated) that are in the JSP limiter queue + * @return The number of JSPs (in the webapp with which this JspServlet is associated) that are in the JSP limiter + * queue */ public int getJspQueueLength() { if (jspQueue != null) { @@ -343,8 +330,7 @@ public int getJspQueueLength() { /** * Gets the number of JSPs that have been unloaded. * - * @return The number of JSPs (in the webapp with which this JspServlet is - * associated) that have been unloaded + * @return The number of JSPs (in the webapp with which this JspServlet is associated) that have been unloaded */ public int getJspUnloadCount() { return jspUnloadCount.intValue(); @@ -352,8 +338,7 @@ public int getJspUnloadCount() { /** - * Method used by background thread to check the JSP dependencies - * registered with this class for JSP's. + * Method used by background thread to check the JSP dependencies registered with this class for JSP's. */ public void checkCompile() { @@ -373,7 +358,7 @@ public void checkCompile() { // check is in progress. See BZ 62603. compileCheckInProgress = true; - Object [] wrappers = jsps.values().toArray(); + Object[] wrappers = jsps.values().toArray(); for (Object wrapper : wrappers) { JspServletWrapper jsw = (JspServletWrapper) wrapper; JspCompilationContext ctxt = jsw.getJspEngineContext(); @@ -444,6 +429,7 @@ public Map getSmaps() { /** * Method used to initialize classpath for compiles. + * * @return the compilation classpath */ private String initClassPath() { @@ -451,7 +437,7 @@ private String initClassPath() { StringBuilder cpath = new StringBuilder(); if (parentClassLoader instanceof URLClassLoader) { - URL [] urls = ((URLClassLoader)parentClassLoader).getURLs(); + URL[] urls = ((URLClassLoader) parentClassLoader).getURLs(); for (URL url : urls) { // Tomcat can use URLs other than file URLs. However, a protocol @@ -480,7 +466,7 @@ private String initClassPath() { String path = cpath.toString() + cp; - if(log.isTraceEnabled()) { + if (log.isTraceEnabled()) { log.trace("Compilation classpath initialized: " + path); } return path; @@ -489,14 +475,16 @@ private String initClassPath() { /** * Helper class to allow initSecurity() to return two items */ - private static class SecurityHolder{ + private static class SecurityHolder { private final CodeSource cs; private final PermissionCollection pc; - private SecurityHolder(CodeSource cs, PermissionCollection pc){ + + private SecurityHolder(CodeSource cs, PermissionCollection pc) { this.cs = cs; this.pc = pc; } } + /** * Method used to initialize SecurityManager data. */ @@ -509,52 +497,46 @@ private SecurityHolder initSecurity() { Policy policy = Policy.getPolicy(); CodeSource source = null; PermissionCollection permissions = null; - if( policy != null ) { + if (policy != null) { try { // Get the permissions for the web app context String docBase = context.getRealPath("/"); - if( docBase == null ) { + if (docBase == null) { docBase = options.getScratchDir().toString(); } String codeBase = docBase; - if (!codeBase.endsWith(File.separator)){ + if (!codeBase.endsWith(File.separator)) { codeBase = codeBase + File.separator; } File contextDir = new File(codeBase); URL url = contextDir.getCanonicalFile().toURI().toURL(); - source = new CodeSource(url,(Certificate[])null); + source = new CodeSource(url, (Certificate[]) null); permissions = policy.getPermissions(source); // Create a file read permission for web app context directory - if (!docBase.endsWith(File.separator)){ - permissions.add - (new FilePermission(docBase,"read")); + if (!docBase.endsWith(File.separator)) { + permissions.add(new FilePermission(docBase, "read")); docBase = docBase + File.separator; } else { - permissions.add - (new FilePermission - (docBase.substring(0,docBase.length() - 1),"read")); + permissions.add(new FilePermission(docBase.substring(0, docBase.length() - 1), "read")); } docBase = docBase + "-"; - permissions.add(new FilePermission(docBase,"read")); + permissions.add(new FilePermission(docBase, "read")); // Spec says apps should have read/write for their temp // directory. This is fine, as no security sensitive files, at // least any that the app doesn't have full control of anyway, // will be written here. String workDir = options.getScratchDir().toString(); - if (!workDir.endsWith(File.separator)){ - permissions.add - (new FilePermission(workDir,"read,write")); + if (!workDir.endsWith(File.separator)) { + permissions.add(new FilePermission(workDir, "read,write")); workDir = workDir + File.separator; } workDir = workDir + "-"; - permissions.add(new FilePermission( - workDir,"read,write,delete")); + permissions.add(new FilePermission(workDir, "read,write,delete")); // Allow the JSP to access org.apache.jasper.runtime.HttpJspBase - permissions.add( new RuntimePermission( - "accessClassInPackage.org.apache.jasper.runtime") ); + permissions.add(new RuntimePermission("accessClassInPackage.org.apache.jasper.runtime")); } catch (RuntimeException | IOException e) { context.log(Localizer.getMessage("jsp.error.security"), e); } @@ -564,7 +546,7 @@ private SecurityHolder initSecurity() { private void unloadJspServletWrapper(JspServletWrapper jsw) { removeWrapper(jsw.getJspUri()); - synchronized(jsw) { + synchronized (jsw) { jsw.destroy(); } jspUnloadCount.incrementAndGet(); @@ -581,21 +563,20 @@ public void checkUnload() { if (jspQueue != null) { queueLength = jspQueue.getSize(); } - log.trace(Localizer.getMessage("jsp.message.jsp_unload_check", - context.getContextPath(), "" + jsps.size(), "" + queueLength)); + log.trace(Localizer.getMessage("jsp.message.jsp_unload_check", context.getContextPath(), "" + jsps.size(), + "" + queueLength)); } long now = System.currentTimeMillis(); if (jspIdleTimeout > 0) { long unloadBefore = now - jspIdleTimeout; - Object [] wrappers = jsps.values().toArray(); + Object[] wrappers = jsps.values().toArray(); for (Object wrapper : wrappers) { JspServletWrapper jsw = (JspServletWrapper) wrapper; synchronized (jsw) { if (jsw.getLastUsageTime() < unloadBefore) { if (log.isTraceEnabled()) { - log.trace(Localizer.getMessage("jsp.message.jsp_removed_idle", - jsw.getJspUri(), context.getContextPath(), - "" + (now - jsw.getLastUsageTime()))); + log.trace(Localizer.getMessage("jsp.message.jsp_removed_idle", jsw.getJspUri(), + context.getContextPath(), "" + (now - jsw.getLastUsageTime()))); } if (jspQueue != null) { jspQueue.remove(jsw.getUnloadHandle()); diff --git a/java/org/apache/jasper/compiler/JspUtil.java b/java/org/apache/jasper/compiler/JspUtil.java index 08eff04645c9..74fccf97727e 100644 --- a/java/org/apache/jasper/compiler/JspUtil.java +++ b/java/org/apache/jasper/compiler/JspUtil.java @@ -33,8 +33,7 @@ import org.xml.sax.InputSource; /** - * This class has all the utility method(s). Ideally should move all the bean - * containers here. + * This class has all the utility method(s). Ideally should move all the bean containers here. * * @author Mandar Raje. * @author Rajiv Mordani. @@ -52,15 +51,12 @@ public class JspUtil { private static final String OPEN_EXPR = "<%="; private static final String CLOSE_EXPR = "%>"; - 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", "throw", "throws", "transient", "try", - "void", "volatile", "while" }; + 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", "throw", "throws", "transient", "try", "void", "volatile", "while" }; static final int JSP_INPUT_STREAM_BUFFER_SIZE = 1024; @@ -68,15 +64,16 @@ public class JspUtil { /** * Takes a potential expression and converts it into XML form. + * * @param expression The expression to convert + * * @return XML view */ public static String getExprInXml(String expression) { String returnString; int length = expression.length(); - if (expression.startsWith(OPEN_EXPR) && - expression.endsWith(CLOSE_EXPR)) { + if (expression.startsWith(OPEN_EXPR) && expression.endsWith(CLOSE_EXPR)) { returnString = expression.substring(1, length - 1); } else { returnString = expression; @@ -88,40 +85,32 @@ public static String getExprInXml(String expression) { /** * 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 - * - * @throws JasperException - * if scope is not null and different from "page", - * "request", "session", and - * "application" + * @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 + * + * @throws JasperException if scope is not null and different from "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")) { + 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); } } /** - * 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. - * @param typeOfTag The tag type - * @param n The corresponding node + * 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. + * + * @param typeOfTag The tag type + * @param n The corresponding node * @param validAttributes The array with the valid attributes - * @param err Dispatcher for errors + * @param err Dispatcher for errors + * * @throws JasperException An error occurred */ - public static void checkAttributes(String typeOfTag, Node n, - ValidAttribute[] validAttributes, ErrorDispatcher err) + public static void checkAttributes(String typeOfTag, Node n, ValidAttribute[] validAttributes, ErrorDispatcher err) throws JasperException { Attributes attrs = n.getAttributes(); Mark start = n.getStart(); @@ -131,7 +120,7 @@ public static void checkAttributes(String typeOfTag, Node n, int tempLength = (attrs == null) ? 0 : attrs.getLength(); ArrayList temp = new ArrayList<>(tempLength); for (int i = 0; i < tempLength; i++) { - @SuppressWarnings("null") // If attrs==null, tempLength == 0 + @SuppressWarnings("null") // If attrs==null, tempLength == 0 String qName = attrs.getQName(i); if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:"))) { temp.add(qName); @@ -149,9 +138,7 @@ public static void checkAttributes(String typeOfTag, Node n, temp.add(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); + err.jspError(n, "jsp.error.duplicate.name.jspattribute", attrName); } } else { // Nothing can come before jsp:attribute, and only @@ -162,9 +149,8 @@ public static void checkAttributes(String typeOfTag, Node n, } /* - * 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. + * 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; @@ -185,8 +171,7 @@ public static void checkAttributes(String typeOfTag, Node n, // If mandatory attribute is missing then the exception is thrown if (!valid) { - err.jspError(start, "jsp.error.mandatory.attribute", typeOfTag, - missingAttribute); + err.jspError(start, "jsp.error.mandatory.attribute", typeOfTag, missingAttribute); } // Check to see if there are any more attributes for the specified tag. @@ -196,7 +181,7 @@ public static void checkAttributes(String typeOfTag, Node n, } // Now check to see if the rest of the attributes are valid too. - for(String attribute : temp) { + for (String attribute : temp) { valid = false; for (ValidAttribute validAttribute : validAttributes) { if (attribute.equals(validAttribute.name)) { @@ -205,8 +190,7 @@ public static void checkAttributes(String typeOfTag, Node n, } } if (!valid) { - err.jspError(start, "jsp.error.invalid.attribute", typeOfTag, - attribute); + err.jspError(start, "jsp.error.invalid.attribute", typeOfTag, attribute); } } // XXX *could* move EL-syntax validation here... (sb) @@ -228,12 +212,11 @@ public ValidAttribute(String name) { } /** - * Convert a String value to 'boolean'. Besides the standard conversions - * done by Boolean.parseBoolean(s), the value "yes" (ignore case) - * is also converted to 'true'. If 's' is null, then 'false' is returned. + * Convert a String value to 'boolean'. Besides the standard conversions done by Boolean.parseBoolean(s), the value + * "yes" (ignore case) is also converted to 'true'. If 's' is null, then 'false' is returned. + * + * @param s the string to be converted * - * @param s - * the string to be converted * @return the boolean value associated with the string s */ public static boolean booleanValue(String s) { @@ -249,22 +232,20 @@ public static boolean booleanValue(String s) { } /** - * Returns the Class object associated with the class or - * interface with the given string name. - * + * Returns the Class object associated with the class or interface with the given string name. *

- * The Class object is determined by passing the given string - * name to the Class.forName() method, unless the given string - * name represents a primitive type, in which case it is converted to a - * Class object by appending ".class" to it (e.g., - * "int.class"). - * @param type The class name, array or primitive type + * The Class object is determined by passing the given string name to the Class.forName() + * method, unless the given string name represents a primitive type, in which case it is converted to a + * Class object by appending ".class" to it (e.g., "int.class"). + * + * @param type The class name, array or primitive type * @param loader The class loader + * * @return the loaded class + * * @throws ClassNotFoundException Loading class failed */ - public static Class toClass(String type, ClassLoader loader) - throws ClassNotFoundException { + public static Class toClass(String type, ClassLoader loader) throws ClassNotFoundException { Class c = null; int i0 = type.indexOf('['); @@ -316,18 +297,14 @@ public static Class toClass(String type, ClassLoader loader) /** * Produces a String representing a call to the EL interpreter. * - * @param isTagFile true if the file is a tag file - * rather than a JSP - * @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 isTagFile true if the file is a tag file rather than a JSP + * @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. + * * @return a String representing a call to the EL interpreter. */ - public static String interpreterCall(boolean isTagFile, String expression, - Class expectedType, String fnmapvar) { + public static String interpreterCall(boolean isTagFile, String expression, Class expectedType, String fnmapvar) { /* * Determine which context object to use. */ @@ -339,8 +316,8 @@ public static String interpreterCall(boolean isTagFile, String expression, } /* - * Determine whether to use the expected type's textual name or, if it's - * a primitive, the name of its correspondent boxed type. + * Determine whether to use the expected type's textual name or, if it's a primitive, the name of its + * correspondent boxed type. */ String returnType = expectedType.getCanonicalName(); String targetType = returnType; @@ -388,14 +365,9 @@ public static String interpreterCall(boolean isTagFile, String expression, // the generated Servlet/SimpleTag implements FunctionMapper, so // that machinery is already in place (mroth). targetType = toJavaSourceType(targetType); - StringBuilder call = new StringBuilder( - "(" - + returnType - + ") " - + "org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate" - + "(" + Generator.quote(expression) + ", " + targetType - + ".class, " + "(javax.servlet.jsp.PageContext)" + jspCtxt + ", " - + fnmapvar + ")"); + StringBuilder call = new StringBuilder("(" + returnType + ") " + + "org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate" + "(" + Generator.quote(expression) + + ", " + targetType + ".class, " + "(javax.servlet.jsp.PageContext)" + jspCtxt + ", " + fnmapvar + ")"); /* * Add the primitive converter method if we need to. @@ -408,11 +380,9 @@ public static String interpreterCall(boolean isTagFile, String expression, return call.toString(); } - public static String coerceToPrimitiveBoolean(String s, - boolean isNamedAttribute) { + public static String coerceToPrimitiveBoolean(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToBoolean(" - + s + ")"; + return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToBoolean(" + s + ")"; } else { if (s == null || s.length() == 0) { return "false"; @@ -424,8 +394,8 @@ public static String coerceToPrimitiveBoolean(String s, public static String coerceToBoolean(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "(java.lang.Boolean) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" - + s + ", java.lang.Boolean.class)"; + return "(java.lang.Boolean) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" + s + + ", java.lang.Boolean.class)"; } else { if (s == null || s.length() == 0) { return "java.lang.Boolean.FALSE"; @@ -436,11 +406,9 @@ public static String coerceToBoolean(String s, boolean isNamedAttribute) { } } - public static String coerceToPrimitiveByte(String s, - boolean isNamedAttribute) { + public static String coerceToPrimitiveByte(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToByte(" - + s + ")"; + return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToByte(" + s + ")"; } else { if (s == null || s.length() == 0) { return "(byte) 0"; @@ -452,8 +420,8 @@ public static String coerceToPrimitiveByte(String s, public static String coerceToByte(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "(java.lang.Byte) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" - + s + ", java.lang.Byte.class)"; + return "(java.lang.Byte) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" + s + + ", java.lang.Byte.class)"; } else { if (s == null || s.length() == 0) { return "java.lang.Byte.valueOf((byte) 0)"; @@ -466,8 +434,7 @@ public static String coerceToByte(String s, boolean isNamedAttribute) { public static String coerceToChar(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToChar(" - + s + ")"; + return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToChar(" + s + ")"; } else { if (s == null || s.length() == 0) { return "(char) 0"; @@ -481,8 +448,8 @@ public static String coerceToChar(String s, boolean isNamedAttribute) { public static String coerceToCharacter(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "(java.lang.Character) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" - + s + ", java.lang.Character.class)"; + return "(java.lang.Character) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" + s + + ", java.lang.Character.class)"; } else { if (s == null || s.length() == 0) { return "java.lang.Character.valueOf((char) 0)"; @@ -494,11 +461,9 @@ public static String coerceToCharacter(String s, boolean isNamedAttribute) { } } - public static String coerceToPrimitiveDouble(String s, - boolean isNamedAttribute) { + public static String coerceToPrimitiveDouble(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToDouble(" - + s + ")"; + return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToDouble(" + s + ")"; } else { if (s == null || s.length() == 0) { return "(double) 0"; @@ -510,8 +475,7 @@ public static String coerceToPrimitiveDouble(String s, public static String coerceToDouble(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "(java.lang.Double) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" - + s + ", Double.class)"; + return "(java.lang.Double) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" + s + ", Double.class)"; } else { if (s == null || s.length() == 0) { return "java.lang.Double.valueOf(0)"; @@ -522,11 +486,9 @@ public static String coerceToDouble(String s, boolean isNamedAttribute) { } } - public static String coerceToPrimitiveFloat(String s, - boolean isNamedAttribute) { + public static String coerceToPrimitiveFloat(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToFloat(" - + s + ")"; + return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToFloat(" + s + ")"; } else { if (s == null || s.length() == 0) { return "(float) 0"; @@ -538,8 +500,8 @@ public static String coerceToPrimitiveFloat(String s, public static String coerceToFloat(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "(java.lang.Float) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" - + s + ", java.lang.Float.class)"; + return "(java.lang.Float) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" + s + + ", java.lang.Float.class)"; } else { if (s == null || s.length() == 0) { return "java.lang.Float.valueOf(0)"; @@ -552,8 +514,7 @@ public static String coerceToFloat(String s, boolean isNamedAttribute) { public static String coerceToInt(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToInt(" - + s + ")"; + return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToInt(" + s + ")"; } else { if (s == null || s.length() == 0) { return "0"; @@ -565,8 +526,8 @@ public static String coerceToInt(String s, boolean isNamedAttribute) { public static String coerceToInteger(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "(java.lang.Integer) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" - + s + ", java.lang.Integer.class)"; + return "(java.lang.Integer) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" + s + + ", java.lang.Integer.class)"; } else { if (s == null || s.length() == 0) { return "java.lang.Integer.valueOf(0)"; @@ -577,11 +538,9 @@ public static String coerceToInteger(String s, boolean isNamedAttribute) { } } - public static String coerceToPrimitiveShort(String s, - boolean isNamedAttribute) { + public static String coerceToPrimitiveShort(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToShort(" - + s + ")"; + return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToShort(" + s + ")"; } else { if (s == null || s.length() == 0) { return "(short) 0"; @@ -593,8 +552,8 @@ public static String coerceToPrimitiveShort(String s, public static String coerceToShort(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "(java.lang.Short) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" - + s + ", java.lang.Short.class)"; + return "(java.lang.Short) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" + s + + ", java.lang.Short.class)"; } else { if (s == null || s.length() == 0) { return "java.lang.Short.valueOf((short) 0)"; @@ -605,11 +564,9 @@ public static String coerceToShort(String s, boolean isNamedAttribute) { } } - public static String coerceToPrimitiveLong(String s, - boolean isNamedAttribute) { + public static String coerceToPrimitiveLong(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToLong(" - + s + ")"; + return "org.apache.jasper.runtime.JspRuntimeLibrary.coerceToLong(" + s + ")"; } else { if (s == null || s.length() == 0) { return "(long) 0"; @@ -621,8 +578,8 @@ public static String coerceToPrimitiveLong(String s, public static String coerceToLong(String s, boolean isNamedAttribute) { if (isNamedAttribute) { - return "(java.lang.Long) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" - + s + ", java.lang.Long.class)"; + return "(java.lang.Long) org.apache.jasper.runtime.JspRuntimeLibrary.coerce(" + s + + ", java.lang.Long.class)"; } else { if (s == null || s.length() == 0) { return "java.lang.Long.valueOf(0)"; @@ -633,8 +590,8 @@ public static String coerceToLong(String s, boolean isNamedAttribute) { } } - public static BufferedInputStream getInputStream(String fname, Jar jar, - JspCompilationContext ctxt) throws IOException { + public static BufferedInputStream getInputStream(String fname, Jar jar, JspCompilationContext ctxt) + throws IOException { InputStream in = null; @@ -646,15 +603,13 @@ public static BufferedInputStream getInputStream(String fname, Jar jar, } if (in == null) { - throw new FileNotFoundException(Localizer.getMessage( - "jsp.error.file.not.found", fname)); + throw new FileNotFoundException(Localizer.getMessage("jsp.error.file.not.found", fname)); } return new BufferedInputStream(in, JSP_INPUT_STREAM_BUFFER_SIZE); } - public static InputSource getInputSource(String fname, Jar jar, JspCompilationContext ctxt) - throws IOException { + public static InputSource getInputSource(String fname, Jar jar, JspCompilationContext ctxt) throws IOException { InputSource source; if (jar != null) { String jarEntryName = fname.substring(1); @@ -668,19 +623,17 @@ public static InputSource getInputSource(String fname, Jar jar, JspCompilationCo } /** - * Gets the fully-qualified class name of the tag handler corresponding to - * the given tag file path. + * Gets the fully-qualified class name of the tag handler corresponding to the given tag file path. * * @param path Tag file path - * @param urn The tag identifier - * @param err Error dispatcher + * @param urn The tag identifier + * @param err Error dispatcher + * + * @return Fully-qualified class name of the tag handler corresponding to the given tag file path * - * @return Fully-qualified class name of the tag handler corresponding to - * the given tag file path * @throws JasperException Failed to generate a class name for the tag */ - public static String getTagHandlerClassName(String path, String urn, - ErrorDispatcher err) throws JasperException { + public static String getTagHandlerClassName(String path, String urn, ErrorDispatcher err) throws JasperException { String className = null; @@ -722,8 +675,7 @@ public static String getTagHandlerClassName(String path, String urn, } private static String getClassNameBase(String urn) { - StringBuilder base = - new StringBuilder(Constants.TAG_FILE_PACKAGE_NAME + ".meta."); + StringBuilder base = new StringBuilder(Constants.TAG_FILE_PACKAGE_NAME + ".meta."); if (urn != null) { base.append(makeJavaPackage(urn)); base.append('.'); @@ -734,8 +686,7 @@ private static String getClassNameBase(String urn) { /** * Converts the given path to a Java package or fully-qualified class name * - * @param path - * Path to convert + * @param path Path to convert * * @return Java package corresponding to the given path */ @@ -756,8 +707,7 @@ public static final String makeJavaPackage(String path) { /** * Converts the given identifier to a legal Java identifier * - * @param identifier - * Identifier to convert + * @param identifier Identifier to convert * * @return Legal Java identifier corresponding to the given identifier */ @@ -766,11 +716,9 @@ public static final String makeJavaIdentifier(String identifier) { } /** - * Converts the given identifier to a legal Java identifier - * to be used for JSP Tag file attribute names. + * Converts the given identifier to a legal Java identifier to be used for JSP Tag file attribute names. * - * @param identifier - * Identifier to convert + * @param identifier Identifier to convert * * @return Legal Java identifier corresponding to the given identifier */ @@ -781,21 +729,18 @@ public static final String makeJavaIdentifierForAttribute(String identifier) { /** * Converts the given identifier to a legal Java identifier. * - * @param identifier - * Identifier to convert + * @param identifier Identifier to convert * * @return Legal Java identifier corresponding to the given identifier */ - private static String makeJavaIdentifier(String identifier, - boolean periodToUnderscore) { + private static String makeJavaIdentifier(String identifier, boolean periodToUnderscore) { StringBuilder modifiedIdentifier = new StringBuilder(identifier.length()); if (!Character.isJavaIdentifierStart(identifier.charAt(0))) { modifiedIdentifier.append('_'); } for (int i = 0; i < identifier.length(); i++) { char ch = identifier.charAt(i); - if (Character.isJavaIdentifierPart(ch) && - (ch != '_' || !periodToUnderscore)) { + if (Character.isJavaIdentifierPart(ch) && (ch != '_' || !periodToUnderscore)) { modifiedIdentifier.append(ch); } else if (ch == '.' && periodToUnderscore) { modifiedIdentifier.append('_'); @@ -811,7 +756,9 @@ private static String makeJavaIdentifier(String identifier, /** * Mangle the specified character to create a legal Java class name. + * * @param ch The character + * * @return the replacement character as a string */ public static final String mangleChar(char ch) { @@ -826,7 +773,9 @@ public static final String mangleChar(char ch) { /** * Test whether the argument is a Java keyword. + * * @param key The name + * * @return true if the name is a java identifier */ public static boolean isJavaKeyword(String key) { @@ -847,16 +796,14 @@ public static boolean isJavaKeyword(String key) { return false; } - static InputStreamReader getReader(String fname, String encoding, - Jar jar, JspCompilationContext ctxt, ErrorDispatcher err) - throws JasperException, IOException { + static InputStreamReader getReader(String fname, String encoding, Jar jar, JspCompilationContext ctxt, + ErrorDispatcher err) throws JasperException, IOException { return getReader(fname, encoding, jar, ctxt, err, 0); } - static InputStreamReader getReader(String fname, String encoding, - Jar jar, JspCompilationContext ctxt, ErrorDispatcher err, int skip) - throws JasperException, IOException { + static InputStreamReader getReader(String fname, String encoding, Jar jar, JspCompilationContext ctxt, + ErrorDispatcher err, int skip) throws JasperException, IOException { InputStreamReader reader = null; InputStream in = getInputStream(fname, jar, ctxt); @@ -882,11 +829,11 @@ static InputStreamReader getReader(String fname, String encoding, } /** - * Handles taking input from TLDs 'java.lang.Object' -> - * 'java.lang.Object.class' 'int' -> 'int.class' 'void' -> 'Void.TYPE' - * 'int[]' -> 'int[].class' + * Handles taking input from TLDs 'java.lang.Object' -> 'java.lang.Object.class' 'int' -> 'int.class' 'void' + * -> 'Void.TYPE' 'int[]' -> 'int[].class' * * @param type The type from the TLD + * * @return the Java type */ public static String toJavaSourceTypeFromTld(String type) { @@ -897,10 +844,11 @@ public static String toJavaSourceTypeFromTld(String type) { } /** - * Class.getName() return arrays in the form "[[[<et>", where et, the - * element type can be one of ZBCDFIJS or L<classname>;. It is - * converted into forms that can be understood by javac. + * Class.getName() return arrays in the form "[[[<et>", where et, the element type can be one of ZBCDFIJS or + * L<classname>;. It is converted into forms that can be understood by javac. + * * @param type the type to convert + * * @return the equivalent type in Java sources */ public static String toJavaSourceType(String type) { @@ -916,15 +864,33 @@ public static String toJavaSourceType(String type) { 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; + 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; } diff --git a/java/org/apache/jasper/compiler/Localizer.java b/java/org/apache/jasper/compiler/Localizer.java index e22803a64d31..d0645338dfbe 100644 --- a/java/org/apache/jasper/compiler/Localizer.java +++ b/java/org/apache/jasper/compiler/Localizer.java @@ -23,8 +23,7 @@ import org.apache.jasper.runtime.ExceptionUtils; /** - * Class responsible for converting error codes to corresponding localized - * error messages. + * Class responsible for converting error codes to corresponding localized error messages. * * @author Jan Luehe */ @@ -41,11 +40,10 @@ public class Localizer { } /* - * Returns the localized error message corresponding to the given error - * code. + * 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. + * 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 * @@ -63,13 +61,13 @@ public static String getMessage(String errCode) { } /* - * Returns the localized error message corresponding to the given error - * code. + * 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. + * 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 args Arguments for parametric replacement * * @return Localized error message diff --git a/java/org/apache/jasper/compiler/Mark.java b/java/org/apache/jasper/compiler/Mark.java index a677087c74cb..a53cd7bb03e8 100644 --- a/java/org/apache/jasper/compiler/Mark.java +++ b/java/org/apache/jasper/compiler/Mark.java @@ -42,9 +42,9 @@ final class Mark { /** * Constructor * - * @param reader JspReader this mark belongs to + * @param reader JspReader this mark belongs to * @param inStream current stream for this mark - * @param name JSP file name + * @param name JSP file name */ Mark(JspReader reader, char[] inStream, String name) { this.ctxt = reader.getJspCompilationContext(); @@ -60,7 +60,7 @@ final class Mark { * Constructor */ Mark(Mark other) { - init(other, false); + init(other, false); } void update(int cursor, int line, int col) { @@ -105,7 +105,7 @@ public int getColumnNumber() { @Override public String toString() { - return getFile()+"("+line+","+col+")"; + return getFile() + "(" + line + "," + col + ")"; } public String getFile() { diff --git a/java/org/apache/jasper/compiler/NewlineReductionServletWriter.java b/java/org/apache/jasper/compiler/NewlineReductionServletWriter.java index ed6fbfe44b19..72fe3f1c5e03 100644 --- a/java/org/apache/jasper/compiler/NewlineReductionServletWriter.java +++ b/java/org/apache/jasper/compiler/NewlineReductionServletWriter.java @@ -19,13 +19,10 @@ import java.io.PrintWriter; /** - * This class filters duplicate newlines instructions from the compiler output, - * and therefore from the runtime JSP. The duplicates typically happen because - * the compiler has multiple branches that write them, but they operate - * independently and don't realize that the previous output was identical. - * - * Removing these lines makes the JSP more efficient by executing fewer - * operations during runtime. + * This class filters duplicate newlines instructions from the compiler output, and therefore from the runtime JSP. The + * duplicates typically happen because the compiler has multiple branches that write them, but they operate + * independently and don't realize that the previous output was identical. Removing these lines makes the JSP more + * efficient by executing fewer operations during runtime. */ public class NewlineReductionServletWriter extends ServletWriter { diff --git a/java/org/apache/jasper/compiler/Node.java b/java/org/apache/jasper/compiler/Node.java index 0306b16fccf4..e10247605a8a 100644 --- a/java/org/apache/jasper/compiler/Node.java +++ b/java/org/apache/jasper/compiler/Node.java @@ -41,8 +41,8 @@ import org.xml.sax.Attributes; /** - * An internal data representation of a JSP page or a JSP document (XML). Also - * included here is a visitor class for traversing nodes. + * An internal data representation of a JSP page or a JSP document (XML). Also included here is a visitor class for + * traversing nodes. * * @author Kin-man Chung * @author Jan Luehe @@ -83,10 +83,9 @@ abstract class Node implements TagConstants { protected String localName; /* - * The name of the inner class to which the codes for this node and its body - * are generated. For instance, for in foo.jsp, this is - * "foo_jspHelper". This is primarily used for communicating such info from - * Generator to Smap generator. + * The name of the inner class to which the codes for this node and its body are generated. For instance, for + * in foo.jsp, this is "foo_jspHelper". This is primarily used for communicating such info from Generator + * to Smap generator. */ protected String innerClassName; @@ -100,10 +99,8 @@ abstract class Node implements TagConstants { /** * Constructor. * - * @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 */ Node(Mark start, Node parent) { this.startMark = start; @@ -113,19 +110,13 @@ abstract class Node implements TagConstants { /** * Constructor for Nodes parsed from standard syntax. * - * @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 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 */ - Node(String qName, String localName, Attributes attrs, Mark start, - Node parent) { + Node(String qName, String localName, Attributes attrs, Mark start, Node parent) { this.qName = qName; this.localName = localName; this.attrs = attrs; @@ -136,25 +127,16 @@ abstract class Node implements TagConstants { /** * 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 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 + * @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 */ - Node(String qName, String localName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, - Node parent) { + Node(String qName, String localName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, + Mark start, Node parent) { this.qName = qName; this.localName = localName; this.attrs = attrs; @@ -167,12 +149,10 @@ abstract class Node implements TagConstants { /* * Constructor. * - * @param qName The action's qualified name @param localName The action's - * local name @param text The text associated with this node @param start - * The location of the jsp page @param parent The enclosing node + * @param qName The action's qualified name @param localName The action's local name @param text The text associated + * with this node @param start The location of the jsp page @param parent The enclosing node */ - Node(String qName, String localName, String text, Mark start, - Node parent) { + Node(String qName, String localName, String text, Mark start, Node parent) { this.qName = qName; this.localName = localName; this.text = text; @@ -191,27 +171,25 @@ public String getLocalName() { /* * Gets this Node's attributes. * - * In the case of a Node parsed from standard syntax, this method returns - * all the Node's attributes. + * In the case of a Node parsed from standard syntax, this method returns all the Node's attributes. * - * In the case of a Node parsed from XML syntax, this method returns only - * those attributes whose name does not start with xmlns. + * In the case of a Node parsed from XML syntax, this method returns only those attributes whose name does not start + * with xmlns. */ public Attributes getAttributes() { return this.attrs; } /* - * Gets this Node's xmlns attributes that represent tag libraries (only - * meaningful for Nodes parsed from XML syntax) + * Gets this Node's xmlns attributes that represent tag libraries (only meaningful for Nodes parsed from XML syntax) */ public Attributes getTaglibAttributes() { return this.taglibAttrs; } /* - * Gets this Node's xmlns attributes that do not represent tag libraries - * (only meaningful for Nodes parsed from XML syntax) + * Gets this Node's xmlns attributes that do not represent tag libraries (only meaningful for Nodes parsed from XML + * syntax) */ public Attributes getNonTaglibXmlnsAttributes() { return this.nonTaglibXmlnsAttrs; @@ -226,8 +204,8 @@ public String getAttributeValue(String name) { } /** - * Get the attribute that is non request time expression, either from the - * attribute of the node, or from a jsp:attribute + * Get the attribute that is non request time expression, either from the attribute of the node, or from a + * jsp:attribute * * @param name The name of the attribute * @@ -249,15 +227,13 @@ public String getTextAttribute(String name) { } /** - * Searches all sub-nodes of this node for jsp:attribute standard actions - * with the given name. + * Searches all sub-nodes of this node for jsp:attribute standard actions with the given name. *

- * This should always be called and only be called for nodes that accept - * dynamic runtime attribute expressions. + * This should always be called and only be called for nodes that accept dynamic runtime attribute expressions. * * @param name The name of the attribute - * @return the NamedAttribute node of the matching named attribute, nor null - * if no such node is found. + * + * @return the NamedAttribute node of the matching named attribute, nor null if no such node is found. */ public NamedAttribute getNamedAttributeNode(String name) { NamedAttribute result = null; @@ -285,11 +261,10 @@ public NamedAttribute getNamedAttributeNode(String name) { } /** - * Searches all subnodes of this node for jsp:attribute standard actions, - * and returns that set of nodes as a Node.Nodes object. + * Searches all subnodes of this node for jsp:attribute standard 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 + * @return Possibly empty Node.Nodes object containing any jsp:attribute subnodes of this Node */ public Node.Nodes getNamedAttributeNodes() { @@ -372,11 +347,10 @@ public void setInnerClassName(String icn) { } /** - * 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. + * 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 + * @param v The visitor class */ abstract void accept(Visitor v) throws JasperException; @@ -415,28 +389,23 @@ public static class Root extends Node { private String jspConfigPageEnc; /* - * Flag indicating if the default page encoding is being used (only - * applicable with standard syntax). + * Flag indicating if the default page encoding is being used (only applicable with standard syntax). * - * True if the page does not provide a page directive with a - * 'contentType' attribute (or the 'contentType' attribute doesn't have - * a CHARSET value), the page does not provide a page directive with a - * 'pageEncoding' attribute, and there is no JSP configuration element - * page-encoding whose URL pattern matches the page. + * True if the page does not provide a page directive with a 'contentType' attribute (or the 'contentType' + * attribute doesn't have a CHARSET value), the page does not provide a page directive with a 'pageEncoding' + * attribute, and there is no JSP configuration element page-encoding whose URL pattern matches the page. */ private boolean isDefaultPageEncoding; /* - * Indicates whether an encoding has been explicitly specified in the - * page's XML prolog (only used for pages in XML syntax). This - * information is used to decide whether a translation error must be - * reported for encoding conflicts. + * Indicates whether an encoding has been explicitly specified in the page's XML prolog (only used for pages in + * XML syntax). This information is used to decide whether a translation error must be reported for encoding + * conflicts. */ private boolean isEncodingSpecifiedInProlog; /* - * Indicates whether an encoding has been explicitly specified in the - * page's dom. + * Indicates whether an encoding has been explicitly specified in the page's dom. */ private boolean isBomPresent; @@ -472,16 +441,16 @@ public boolean isXmlSyntax() { } /* - * Sets the encoding specified in the JSP config element whose URL - * pattern matches the page containing this Root. + * Sets the encoding specified in the JSP config element whose URL pattern matches the page containing this + * Root. */ public void setJspConfigPageEncoding(String enc) { jspConfigPageEnc = enc; } /* - * Gets the encoding specified in the JSP config element whose URL - * pattern matches the page containing this Root. + * Gets the encoding specified in the JSP config element whose URL pattern matches the page containing this + * Root. */ public String getJspConfigPageEncoding() { return jspConfigPageEnc; @@ -539,11 +508,9 @@ public String nextTemporaryVariableName() { */ public static class JspRoot extends Node { - JspRoot(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, - Mark start, Node parent) { - super(qName, ROOT_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, - start, parent); + JspRoot(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, + Node parent) { + super(qName, ROOT_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -563,11 +530,9 @@ public static class PageDirective extends Node { this(JSP_PAGE_DIRECTIVE_ACTION, attrs, null, null, start, parent); } - PageDirective(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, + PageDirective(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { - super(qName, PAGE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + super(qName, PAGE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); imports = new ArrayList<>(); } @@ -577,12 +542,10 @@ public void accept(Visitor v) throws JasperException { } /** - * 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. + * 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. + * @param value A comma-separated string of imports. */ public void addImport(String value) { int start = 0; @@ -604,16 +567,14 @@ public List getImports() { } /** - * Just need enough validation to make sure nothing strange is going on. - * The compiler will validate this thoroughly when it tries to compile - * the resulting .java file. + * Just need enough validation to make sure nothing strange is going on. The compiler will validate this + * thoroughly when it tries to compile the resulting .java file. */ private String validateImport(String importEntry) { // This should either be a fully-qualified class name or a package // name with a wildcard if (importEntry.indexOf(';') > -1) { - throw new IllegalArgumentException( - Localizer.getMessage("jsp.error.page.invalid.import")); + throw new IllegalArgumentException(Localizer.getMessage("jsp.error.page.invalid.import")); } return importEntry.trim(); } @@ -628,11 +589,9 @@ public static class IncludeDirective extends Node { this(JSP_INCLUDE_DIRECTIVE_ACTION, attrs, null, null, start, parent); } - IncludeDirective(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, + IncludeDirective(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { - super(qName, INCLUDE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + super(qName, INCLUDE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -647,8 +606,7 @@ public void accept(Visitor v) throws JasperException { public static class TaglibDirective extends Node { TaglibDirective(Attributes attrs, Mark start, Node parent) { - super(JSP_TAGLIB_DIRECTIVE_ACTION, TAGLIB_DIRECTIVE_ACTION, attrs, - start, parent); + super(JSP_TAGLIB_DIRECTIVE_ACTION, TAGLIB_DIRECTIVE_ACTION, attrs, start, parent); } @Override @@ -667,11 +625,9 @@ public static class TagDirective extends Node { this(JSP_TAG_DIRECTIVE_ACTION, attrs, null, null, start, parent); } - TagDirective(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, - Mark start, Node parent) { - super(qName, TAG_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + TagDirective(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, + Node parent) { + super(qName, TAG_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); imports = new ArrayList<>(); } @@ -681,12 +637,10 @@ public void accept(Visitor v) throws JasperException { } /** - * 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. + * 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. + * @param value A comma-separated string of imports. */ public void addImport(String value) { int start = 0; @@ -714,15 +668,12 @@ public List getImports() { public static class AttributeDirective extends Node { AttributeDirective(Attributes attrs, Mark start, Node parent) { - this(JSP_ATTRIBUTE_DIRECTIVE_ACTION, attrs, null, null, start, - parent); + this(JSP_ATTRIBUTE_DIRECTIVE_ACTION, attrs, null, null, start, parent); } - AttributeDirective(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, + AttributeDirective(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { - super(qName, ATTRIBUTE_DIRECTIVE_ACTION, attrs, - nonTaglibXmlnsAttrs, taglibAttrs, start, parent); + super(qName, ATTRIBUTE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -737,15 +688,12 @@ public void accept(Visitor v) throws JasperException { public static class VariableDirective extends Node { VariableDirective(Attributes attrs, Mark start, Node parent) { - this(JSP_VARIABLE_DIRECTIVE_ACTION, attrs, null, null, start, - parent); + this(JSP_VARIABLE_DIRECTIVE_ACTION, attrs, null, null, start, parent); } - VariableDirective(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, + VariableDirective(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { - super(qName, VARIABLE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + super(qName, VARIABLE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -763,11 +711,9 @@ public static class InvokeAction extends Node { this(JSP_INVOKE_ACTION, attrs, null, null, start, parent); } - InvokeAction(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, - Mark start, Node parent) { - super(qName, INVOKE_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + InvokeAction(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, + Node parent) { + super(qName, INVOKE_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -785,11 +731,9 @@ public static class DoBodyAction extends Node { this(JSP_DOBODY_ACTION, attrs, null, null, start, parent); } - DoBodyAction(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, - Mark start, Node parent) { - super(qName, DOBODY_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + DoBodyAction(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, + Node parent) { + super(qName, DOBODY_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -818,22 +762,18 @@ public void accept(Visitor v) throws JasperException { */ public abstract static class ScriptingElement extends Node { - ScriptingElement(String qName, String localName, String text, - Mark start, Node parent) { + ScriptingElement(String qName, String localName, String text, Mark start, Node parent) { super(qName, localName, text, start, parent); } - ScriptingElement(String qName, String localName, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, + ScriptingElement(String qName, String localName, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { - super(qName, localName, null, nonTaglibXmlnsAttrs, taglibAttrs, - start, parent); + super(qName, localName, null, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } /** - * When this node was created from a JSP page in JSP syntax, its text - * 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 + * When this node was created from a JSP page in JSP syntax, its text 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 @@ -857,8 +797,7 @@ public String getText() { } /** - * For the same reason as above, the source line information in the - * contained TemplateText node should be used. + * For the same reason as above, the source line information in the contained TemplateText node should be used. */ @Override public Mark getStart() { @@ -876,14 +815,11 @@ public Mark getStart() { public static class Declaration extends ScriptingElement { Declaration(String text, Mark start, Node parent) { - super(JSP_DECLARATION_ACTION, DECLARATION_ACTION, text, start, - parent); + super(JSP_DECLARATION_ACTION, DECLARATION_ACTION, text, start, parent); } - Declaration(String qName, Attributes nonTaglibXmlnsAttrs, - Attributes taglibAttrs, Mark start, Node parent) { - super(qName, DECLARATION_ACTION, nonTaglibXmlnsAttrs, taglibAttrs, - start, parent); + Declaration(String qName, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { + super(qName, DECLARATION_ACTION, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -893,8 +829,7 @@ public void accept(Visitor v) throws JasperException { } /** - * Represents an expression. Expressions in attributes are embedded in the - * attribute string and not here. + * Represents an expression. Expressions in attributes are embedded in the attribute string and not here. */ public static class Expression extends ScriptingElement { @@ -902,10 +837,8 @@ public static class Expression extends ScriptingElement { super(JSP_EXPRESSION_ACTION, EXPRESSION_ACTION, text, start, parent); } - Expression(String qName, Attributes nonTaglibXmlnsAttrs, - Attributes taglibAttrs, Mark start, Node parent) { - super(qName, EXPRESSION_ACTION, nonTaglibXmlnsAttrs, taglibAttrs, - start, parent); + Expression(String qName, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { + super(qName, EXPRESSION_ACTION, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -923,10 +856,8 @@ public static class Scriptlet extends ScriptingElement { super(JSP_SCRIPTLET_ACTION, SCRIPTLET_ACTION, text, start, parent); } - Scriptlet(String qName, Attributes nonTaglibXmlnsAttrs, - Attributes taglibAttrs, Mark start, Node parent) { - super(qName, SCRIPTLET_ACTION, nonTaglibXmlnsAttrs, taglibAttrs, - start, parent); + Scriptlet(String qName, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { + super(qName, SCRIPTLET_ACTION, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -936,8 +867,7 @@ public void accept(Visitor v) throws JasperException { } /** - * Represents an EL expression. Expressions in attributes are embedded in - * the attribute string and not here. + * Represents an EL expression. Expressions in attributes are embedded in the attribute string and not here. */ public static class ELExpression extends Node { @@ -979,11 +909,9 @@ public static class ParamAction extends Node { this(JSP_PARAM_ACTION, attrs, null, null, start, parent); } - ParamAction(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, - Mark start, Node parent) { - super(qName, PARAM_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, - start, parent); + ParamAction(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, + Node parent) { + super(qName, PARAM_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -1009,10 +937,8 @@ public static class ParamsAction extends Node { this(JSP_PARAMS_ACTION, null, null, start, parent); } - ParamsAction(String qName, Attributes nonTaglibXmlnsAttrs, - Attributes taglibAttrs, Mark start, Node parent) { - super(qName, PARAMS_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs, - start, parent); + ParamsAction(String qName, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { + super(qName, PARAMS_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -1030,10 +956,8 @@ public static class FallBackAction extends Node { this(JSP_FALLBACK_ACTION, null, null, start, parent); } - FallBackAction(String qName, Attributes nonTaglibXmlnsAttrs, - Attributes taglibAttrs, Mark start, Node parent) { - super(qName, FALLBACK_ACTION, null, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + FallBackAction(String qName, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { + super(qName, FALLBACK_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -1053,11 +977,9 @@ public static class IncludeAction extends Node { this(JSP_INCLUDE_ACTION, attrs, null, null, start, parent); } - IncludeAction(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, + IncludeAction(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { - super(qName, INCLUDE_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + super(qName, INCLUDE_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -1085,11 +1007,9 @@ public static class ForwardAction extends Node { this(JSP_FORWARD_ACTION, attrs, null, null, start, parent); } - ForwardAction(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, + ForwardAction(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { - super(qName, FORWARD_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + super(qName, FORWARD_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -1115,11 +1035,9 @@ public static class GetProperty extends Node { this(JSP_GET_PROPERTY_ACTION, attrs, null, null, start, parent); } - GetProperty(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, - Mark start, Node parent) { - super(qName, GET_PROPERTY_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + GetProperty(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, + Node parent) { + super(qName, GET_PROPERTY_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -1139,11 +1057,9 @@ public static class SetProperty extends Node { this(JSP_SET_PROPERTY_ACTION, attrs, null, null, start, parent); } - SetProperty(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, - Mark start, Node parent) { - super(qName, SET_PROPERTY_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + SetProperty(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, + Node parent) { + super(qName, SET_PROPERTY_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -1171,11 +1087,9 @@ public static class UseBean extends Node { this(JSP_USE_BEAN_ACTION, attrs, null, null, start, parent); } - UseBean(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, - Mark start, Node parent) { - super(qName, USE_BEAN_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + UseBean(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, + Node parent) { + super(qName, USE_BEAN_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -1205,11 +1119,9 @@ public static class PlugIn extends Node { this(JSP_PLUGIN_ACTION, attrs, null, null, start, parent); } - PlugIn(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, - Mark start, Node parent) { - super(qName, PLUGIN_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + PlugIn(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, + Node parent) { + super(qName, PLUGIN_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -1241,11 +1153,9 @@ public static class UninterpretedTag extends Node { private JspAttribute[] jspAttrs; - UninterpretedTag(String qName, String localName, - Attributes attrs, Attributes nonTaglibXmlnsAttrs, + UninterpretedTag(String qName, String localName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { - super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, - start, parent); + super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -1275,11 +1185,9 @@ public static class JspElement extends Node { this(JSP_ELEMENT_ACTION, attrs, null, null, start, parent); } - JspElement(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, - Mark start, Node parent) { - super(qName, ELEMENT_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + JspElement(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, + Node parent) { + super(qName, ELEMENT_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -1315,11 +1223,9 @@ public JspAttribute getNameAttribute() { */ public static class JspOutput extends Node { - JspOutput(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, - Mark start, Node parent) { - super(qName, OUTPUT_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + JspOutput(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, + Node parent) { + super(qName, OUTPUT_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -1329,8 +1235,8 @@ public void accept(Visitor v) throws JasperException { } /** - * Collected information about child elements. Used by nodes like CustomTag, - * JspBody, and NamedAttribute. The information is set in the Collector. + * Collected information about child elements. Used by nodes like 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 @@ -1400,9 +1306,8 @@ public abstract static class ChildInfoBase extends Node { private final ChildInfo childInfo = new ChildInfo(); - ChildInfoBase(String qName, String localName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, - Node parent) { + ChildInfoBase(String qName, String localName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, + Attributes taglibAttrs, Mark start, Node parent) { super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @@ -1464,10 +1369,9 @@ public static class CustomTag extends ChildInfoBase { private TagPluginContext tagPluginContext; /** - * The following two fields are used for holding the Java scriptlets - * that the tag plugins may generate. Meaningful only if useTagPlugin is - * true; Could move them into TagPluginContextImpl, but we'll need to - * cast tagPluginContext to TagPluginContextImpl all the time... + * The following two fields are used for holding the Java scriptlets that the tag plugins may generate. + * Meaningful only if useTagPlugin is true; Could move them into TagPluginContextImpl, but we'll need to cast + * tagPluginContext to TagPluginContextImpl all the time... */ private Nodes atSTag; @@ -1476,22 +1380,18 @@ public static class CustomTag extends ChildInfoBase { /* * Constructor for custom action implemented by tag handler. */ - CustomTag(String qName, String prefix, String localName, - String uri, Attributes attrs, Mark start, Node parent, + CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, Mark start, Node parent, TagInfo tagInfo, Class tagHandlerClass) { - this(qName, prefix, localName, uri, attrs, null, null, start, - parent, tagInfo, tagHandlerClass); + this(qName, prefix, localName, uri, attrs, null, null, start, parent, tagInfo, tagHandlerClass); } /* * Constructor for custom action implemented by tag handler. */ - CustomTag(String qName, String prefix, String localName, - String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, - Attributes taglibAttrs, Mark start, Node parent, - TagInfo tagInfo, Class tagHandlerClass) { - super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, - start, parent); + CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, + Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent, TagInfo tagInfo, + Class tagHandlerClass) { + super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); this.uri = uri; this.prefix = prefix; @@ -1500,40 +1400,30 @@ public static class CustomTag extends ChildInfoBase { this.tagHandlerClass = tagHandlerClass; this.customNestingLevel = makeCustomNestingLevel(); - 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); - this.implementsJspIdConsumer = JspIdConsumer.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); + this.implementsJspIdConsumer = JspIdConsumer.class.isAssignableFrom(tagHandlerClass); } /* * Constructor for custom action implemented by tag file. */ - CustomTag(String qName, String prefix, String localName, - String uri, Attributes attrs, Mark start, Node parent, + CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, Mark start, Node parent, TagFileInfo tagFileInfo) { - this(qName, prefix, localName, uri, attrs, null, null, start, - parent, tagFileInfo); + this(qName, prefix, localName, uri, attrs, null, null, start, parent, tagFileInfo); } /* * Constructor for custom action implemented by tag file. */ - CustomTag(String qName, String prefix, String localName, - String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, - Attributes taglibAttrs, Mark start, Node parent, + CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, + Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent, TagFileInfo tagFileInfo) { - super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, - start, parent); + super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); this.uri = uri; this.prefix = prefix; @@ -1605,8 +1495,7 @@ public TagFileInfo getTagFileInfo() { } /* - * @return true if this custom action is supported by a tag file, false - * otherwise + * @return true if this custom action is supported by a tag file, false otherwise */ public boolean isTagFile() { return tagFileInfo != null; @@ -1670,57 +1559,55 @@ public Integer getNumCount() { public void setScriptingVars(List 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; - default: - throw new IllegalArgumentException( - Localizer.getMessage("jsp.error.page.invalid.varscope", Integer.valueOf(scope))); + case VariableInfo.AT_BEGIN: + this.atBeginScriptingVars = vec; + break; + case VariableInfo.AT_END: + this.atEndScriptingVars = vec; + break; + case VariableInfo.NESTED: + this.nestedScriptingVars = vec; + break; + default: + throw new IllegalArgumentException( + Localizer.getMessage("jsp.error.page.invalid.varscope", Integer.valueOf(scope))); } } /* - * Gets the scripting variables for the given scope that need to be - * declared. + * Gets the scripting variables for the given scope that need to be declared. */ public List getScriptingVars(int scope) { List 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; - default: - throw new IllegalArgumentException( - Localizer.getMessage("jsp.error.page.invalid.varscope", Integer.valueOf(scope))); + case VariableInfo.AT_BEGIN: + vec = this.atBeginScriptingVars; + break; + case VariableInfo.AT_END: + vec = this.atEndScriptingVars; + break; + case VariableInfo.NESTED: + vec = this.nestedScriptingVars; + break; + default: + throw new IllegalArgumentException( + Localizer.getMessage("jsp.error.page.invalid.varscope", Integer.valueOf(scope))); } return vec; } /* - * Gets this custom tag's custom nesting level, which is given as the - * number of times this custom tag is nested inside itself. + * Gets this custom tag's custom nesting level, which is given as the number of times this custom tag is nested + * inside itself. */ public int getCustomNestingLevel() { return customNestingLevel; } /** - * Checks to see if the attribute of the given name is of type - * JspFragment. + * Checks to see if the attribute of the given name is of type JspFragment. * * @param name The attribute to check * @@ -1731,8 +1618,7 @@ public boolean checkIfAttributeIsJspFragment(String name) { TagAttributeInfo[] attributes = tagInfo.getAttributes(); for (TagAttributeInfo attribute : attributes) { - if (attribute.getName().equals(name) - && attribute.isFragment()) { + if (attribute.getName().equals(name) && attribute.isFragment()) { result = true; break; } @@ -1774,14 +1660,13 @@ public Nodes getAtETag() { } /* - * Computes this custom tag's custom nesting level, which corresponds to - * the number of times this custom tag is nested inside itself. + * Computes this custom tag's custom nesting level, which corresponds to the number of times this custom tag is + * nested inside itself. * * Example: * - * -- nesting level 0 -- nesting level 1 - * -- nesting level 2 -- nesting level 1 - * + * -- nesting level 0 -- nesting level 1 -- nesting level 2 + * -- nesting level 1 * * @return Custom tag's nesting level */ @@ -1789,8 +1674,7 @@ private int makeCustomNestingLevel() { int n = 0; Node p = parent; while (p != null) { - if ((p instanceof Node.CustomTag) - && qName.equals(((Node.CustomTag) p).qName)) { + if ((p instanceof Node.CustomTag) && qName.equals(((Node.CustomTag) p).qName)) { n++; } p = p.parent; @@ -1799,12 +1683,10 @@ private int makeCustomNestingLevel() { } /** - * 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. + * 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. * - * @return {@code true} if this custom action has an empty body, and - * {@code false} otherwise. + * @return {@code true} if this custom action has an empty body, and {@code false} otherwise. */ public boolean hasEmptyBody() { boolean hasEmptyBody = true; @@ -1829,8 +1711,8 @@ public boolean hasEmptyBody() { } /** - * Used as a placeholder for the evaluation code of a custom action - * attribute (used by the tag plugin machinery only). + * Used as a placeholder for the evaluation code of a custom action attribute (used by the tag plugin machinery + * only). */ public static class AttributeGenerator extends Node { private String name; // name of the attribute @@ -1862,10 +1744,8 @@ public CustomTag getTag() { */ public static class JspText extends Node { - JspText(String qName, Attributes nonTaglibXmlnsAttrs, - Attributes taglibAttrs, Mark start, Node parent) { - super(qName, TEXT_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs, - start, parent); + JspText(String qName, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { + super(qName, TEXT_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -1899,12 +1779,10 @@ public static class NamedAttribute extends ChildInfoBase { this(JSP_ATTRIBUTE_ACTION, attrs, null, null, start, parent); } - NamedAttribute(String qName, Attributes attrs, - Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, + NamedAttribute(String qName, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { - super(qName, ATTRIBUTE_ACTION, attrs, nonTaglibXmlnsAttrs, - taglibAttrs, start, parent); + super(qName, ATTRIBUTE_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); if ("false".equals(this.getAttributeValue("trim"))) { // (if null or true, leave default of true) trim = false; @@ -1952,8 +1830,8 @@ public JspAttribute getOmit() { } /** - * @return A unique temporary variable name to store the result in. - * (this probably could go elsewhere, but it's convenient here) + * @return A unique temporary variable name to store the result in. (this probably could go elsewhere, but it's + * convenient here) */ public String getTemporaryVariableName() { if (temporaryVariableName == null) { @@ -1963,9 +1841,8 @@ public String getTemporaryVariableName() { } /* - * Get the attribute value from this named attribute (). - * Since this method is only for attributes that are not rtexpr, we can - * assume the body of the jsp:attribute is a template text. + * Get the attribute value from this named attribute (). Since this method is only for attributes + * that are not rtexpr, we can assume the body of the jsp:attribute is a template text. */ @Override public String getText() { @@ -2009,10 +1886,8 @@ public static class JspBody extends ChildInfoBase { this(JSP_BODY_ACTION, null, null, start, parent); } - JspBody(String qName, Attributes nonTaglibXmlnsAttrs, - Attributes taglibAttrs, Mark start, Node parent) { - super(qName, BODY_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs, - start, parent); + JspBody(String qName, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent) { + super(qName, BODY_ACTION, null, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); } @Override @@ -2080,10 +1955,8 @@ public boolean isAllSpace() { /** * Add a source to Java line mapping * - * @param srcLine - * The position 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. + * @param srcLine The position 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. */ public void addSmap(int srcLine) { if (extraSmap == null) { @@ -2098,11 +1971,9 @@ public ArrayList getExtraSmap() { } /** - * Represents attributes that can be request time expressions. - * - * 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). + * Represents attributes that can be request time expressions. 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). */ public static class JspAttribute { @@ -2129,9 +2000,8 @@ public static class JspAttribute { // The node in the parse tree for the NamedAttribute private final NamedAttribute namedAttributeNode; - JspAttribute(TagAttributeInfo tai, String qName, String uri, - String localName, String value, boolean expr, ELNode.Nodes el, - boolean dyn) { + JspAttribute(TagAttributeInfo tai, String qName, String uri, String localName, String value, boolean expr, + ELNode.Nodes el, boolean dyn) { this.qName = qName; this.uri = uri; this.localName = localName; @@ -2147,13 +2017,12 @@ public static class JspAttribute { /** * Allow node to validate itself. * - * @param ef The expression factory to use to evaluate any EL + * @param ef The expression factory to use to evaluate any EL * @param ctx The context to use to evaluate any EL * * @throws ELException If validation fails */ - public void validateEL(ExpressionFactory ef, ELContext ctx) - throws ELException { + public void validateEL(ExpressionFactory ef, ELContext ctx) throws ELException { if (this.el != null) { // determine exact type ef.createValueExpression(ctx, this.value, String.class); @@ -2161,9 +2030,8 @@ public void validateEL(ExpressionFactory ef, ELContext ctx) } /** - * Use this constructor if the JspAttribute represents a named - * attribute. In this case, we have to store the nodes of the body of - * the attribute. + * Use this constructor if the JspAttribute represents a named attribute. In this case, we have to store the + * nodes of the body of the attribute. */ JspAttribute(NamedAttribute na, TagAttributeInfo tai, boolean dyn) { this.qName = na.getName(); @@ -2193,8 +2061,7 @@ public String getLocalName() { } /** - * @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; @@ -2205,16 +2072,14 @@ public TagAttributeInfo getTagAttributeInfo() { } /** - * @return return true if there's TagAttributeInfo meaning we need to - * assign a ValueExpression + * @return return true if there's TagAttributeInfo meaning we need to assign a ValueExpression */ public boolean isDeferredInput() { return (this.tai != null) ? this.tai.isDeferredValue() : false; } /** - * @return return true if there's TagAttributeInfo meaning we need to - * assign a MethodExpression + * @return return true if there's TagAttributeInfo meaning we need to assign a MethodExpression */ public boolean isDeferredMethodInput() { return (this.tai != null) ? this.tai.isDeferredMethod() : false; @@ -2261,9 +2126,8 @@ public String[] getParameterTypeNames() { /** * Only makes sense if namedAttribute is false. * - * @return the value for the attribute, or the expression string - * (stripped of "<%=", "%>", "%=", or "%" but containing "${" - * and "}" for EL expressions) + * @return the value for the attribute, or the expression string (stripped of "<%=", "%>", "%=", or "%" but + * containing "${" and "}" for EL expressions) */ public String getValue() { return value; @@ -2293,28 +2157,23 @@ public boolean isNamedAttribute() { } /** - * @return true if the value represents an expression that should be fed - * to the expression interpreter - * false for string literals or rtexprvalues that should not be - * interpreted or reevaluated + * @return true if the value represents an expression that should be fed to the expression interpreter false for + * string literals or rtexprvalues that should not be interpreted or reevaluated */ public boolean isELInterpreterInput() { - return el != null || this.isDeferredInput() - || this.isDeferredMethodInput(); + return el != null || this.isDeferredInput() || this.isDeferredMethodInput(); } /** - * @return true if the value is a string literal known at translation - * time. + * @return true if the value is a string literal known at translation time. */ public boolean isLiteral() { return !expression && (el == null) && !namedAttribute; } /** - * @return {@code true} if the attribute is a "dynamic" attribute of a - * custom tag that implements DynamicAttributes interface. That is, - * a random extra attribute that is not declared by the tag. + * @return {@code true} if the attribute is a "dynamic" attribute of a custom tag that implements + * DynamicAttributes interface. That is, a random extra attribute that is not declared by the tag. */ public boolean isDynamic() { return dynamic; @@ -2326,8 +2185,7 @@ public ELNode.Nodes getEL() { } /** - * An ordered list of Node, used to represent the body of an element, or a - * jsp page of jsp document. + * An ordered list of Node, used to represent the body of an element, or a jsp page of jsp document. */ public static class Nodes { @@ -2350,8 +2208,7 @@ public static class Nodes { /** * Appends a node to the list * - * @param n - * The node to add + * @param n The node to add */ public void add(Node n) { list.add(n); @@ -2361,8 +2218,7 @@ public void add(Node n) { /** * Removes the given node from the list. * - * @param n - * The node to be removed + * @param n The node to be removed */ public void remove(Node n) { list.remove(n); @@ -2371,8 +2227,7 @@ public void remove(Node n) { /** * Visit the nodes in the list with the supplied visitor * - * @param v - * The visitor used + * @param v The visitor used * * @throws JasperException if an error occurs while visiting a node */ @@ -2409,16 +2264,15 @@ public void setGeneratedInBuffer(boolean g) { } /** - * A visitor class for visiting the node. This class also provides the - * default action (i.e. nop) for each of the child class of the Node. An - * actual visitor should extend this class and supply the visit method for - * the nodes that it cares. + * A visitor class for visiting the node. This class also provides the default action (i.e. nop) for each of the + * child class of the Node. An actual visitor should extend this class and supply the visit method for the nodes + * that it cares. */ public static class Visitor { /** - * This method provides a place to put actions that are common to all - * nodes. Override this in the child visitor class if need to. + * This method provides a place to put actions that are common to all nodes. Override this in the child visitor + * class if need to. * * @param n The node to visit */