From 71883b548b21a7aa4a9aef3839e2bc9855083a9f Mon Sep 17 00:00:00 2001 From: markt Date: Sun, 23 Nov 2008 21:29:46 +0000 Subject: [PATCH] Fix generics in o.a.jasper & o.a.jasper.compiler. Also a few knock-on changes in other jasper packages. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@720049 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/jasper/EmbeddedServletOptions.java | 7 +- java/org/apache/jasper/JspC.java | 25 +++-- java/org/apache/jasper/JspCompilationContext.java | 6 +- java/org/apache/jasper/Options.java | 4 +- java/org/apache/jasper/compiler/AntCompiler.java | 11 +- .../org/apache/jasper/compiler/BeanRepository.java | 4 +- java/org/apache/jasper/compiler/Compiler.java | 6 +- .../apache/jasper/compiler/ELFunctionMapper.java | 12 +- java/org/apache/jasper/compiler/Generator.java | 121 +++++++++++---------- .../jasper/compiler/ImplicitTagLibraryInfo.java | 24 ++-- java/org/apache/jasper/compiler/JDTCompiler.java | 7 +- .../apache/jasper/compiler/JavacErrorDetail.java | 4 +- java/org/apache/jasper/compiler/JspConfig.java | 43 ++++---- .../apache/jasper/compiler/JspDocumentParser.java | 11 +- java/org/apache/jasper/compiler/JspReader.java | 6 +- .../apache/jasper/compiler/JspRuntimeContext.java | 6 +- java/org/apache/jasper/compiler/Mark.java | 8 +- java/org/apache/jasper/compiler/Node.java | 53 ++++----- java/org/apache/jasper/compiler/PageDataImpl.java | 4 +- java/org/apache/jasper/compiler/PageInfo.java | 72 ++++++------ java/org/apache/jasper/compiler/Parser.java | 8 +- .../apache/jasper/compiler/ParserController.java | 4 +- .../apache/jasper/compiler/ScriptingVariabler.java | 10 +- java/org/apache/jasper/compiler/SmapGenerator.java | 6 +- java/org/apache/jasper/compiler/SmapStratum.java | 24 ++-- java/org/apache/jasper/compiler/SmapUtil.java | 28 ++--- .../apache/jasper/compiler/TagFileProcessor.java | 55 +++++----- .../apache/jasper/compiler/TagLibraryInfoImpl.java | 57 +++++----- .../apache/jasper/compiler/TagPluginManager.java | 17 ++- .../apache/jasper/compiler/TldLocationsCache.java | 20 ++-- java/org/apache/jasper/compiler/Validator.java | 4 +- .../apache/jasper/runtime/JspSourceDependent.java | 6 +- .../apache/jasper/servlet/JspServletWrapper.java | 2 +- java/org/apache/jasper/xmlparser/TreeNode.java | 14 +-- 34 files changed, 352 insertions(+), 337 deletions(-) diff --git a/java/org/apache/jasper/EmbeddedServletOptions.java b/java/org/apache/jasper/EmbeddedServletOptions.java index 5c1211efe..862341751 100644 --- a/java/org/apache/jasper/EmbeddedServletOptions.java +++ b/java/org/apache/jasper/EmbeddedServletOptions.java @@ -22,6 +22,7 @@ import java.util.*; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; +import javax.servlet.jsp.tagext.TagLibraryInfo; import org.apache.jasper.compiler.TldLocationsCache; import org.apache.jasper.compiler.JspConfig; @@ -357,7 +358,7 @@ public final class EmbeddedServletOptions implements Options { return false; } - public Map getCache() { + public Map getCache() { return null; } @@ -387,9 +388,9 @@ public final class EmbeddedServletOptions implements Options { // Ignore } - Enumeration enumeration=config.getInitParameterNames(); + Enumeration enumeration=config.getInitParameterNames(); while( enumeration.hasMoreElements() ) { - String k=(String)enumeration.nextElement(); + String k=enumeration.nextElement(); String v=config.getInitParameter( k ); setProperty( k, v); } diff --git a/java/org/apache/jasper/JspC.java b/java/org/apache/jasper/JspC.java index d21fbb782..a3f7d406d 100644 --- a/java/org/apache/jasper/JspC.java +++ b/java/org/apache/jasper/JspC.java @@ -40,6 +40,8 @@ import java.util.Stack; import java.util.StringTokenizer; import java.util.Vector; +import javax.servlet.jsp.tagext.TagLibraryInfo; + import org.apache.jasper.compiler.Compiler; import org.apache.jasper.compiler.JspConfig; import org.apache.jasper.compiler.JspRuntimeContext; @@ -157,7 +159,8 @@ public class JspC implements Options { protected boolean smapSuppressed = true; protected boolean smapDumped = false; protected boolean caching = true; - protected Map cache = new HashMap(); + protected Map cache = + new HashMap(); protected String compiler = null; @@ -176,12 +179,12 @@ public class JspC implements Options { * The file extensions to be handled as JSP files. * Default list is .jsp and .jspx. */ - protected List extensions; + protected List extensions; /** * The pages. */ - protected List pages = new Vector(); + protected List pages = new Vector(); /** * Needs better documentation, this data member does. @@ -440,7 +443,7 @@ public class JspC implements Options { /** * @see Options#getCache() */ - public Map getCache() { + public Map getCache() { return cache; } @@ -540,13 +543,13 @@ public class JspC implements Options { return scratchDir; } - public Class getJspCompilerPlugin() { - // we don't compile, so this is meanlingless + public Class getJspCompilerPlugin() { + // we don't compile, so this is meaningless return null; } public String getJspCompilerPath() { - // we don't compile, so this is meanlingless + // we don't compile, so this is meaningless return null; } @@ -637,7 +640,7 @@ public class JspC implements Options { * * @return The list of extensions */ - public List getExtensions() { + public List getExtensions() { return extensions; } @@ -650,7 +653,7 @@ public class JspC implements Options { protected void addExtension(final String extension) { if(extension != null) { if(extensions == null) { - extensions = new Vector(); + extensions = new Vector(); } extensions.add(extension); @@ -1094,7 +1097,7 @@ public class JspC implements Options { throw new JasperException( Localizer.getMessage("jsp.error.jspc.missingTarget")); } - String firstJsp = (String) pages.get( 0 ); + String firstJsp = pages.get( 0 ); File firstJspF = new File( firstJsp ); if (!firstJspF.exists()) { throw new JasperException( @@ -1126,7 +1129,7 @@ public class JspC implements Options { initWebXml(); - Iterator iter = pages.iterator(); + Iterator iter = pages.iterator(); while (iter.hasNext()) { String nextjsp = iter.next().toString(); File fjsp = new File(nextjsp); diff --git a/java/org/apache/jasper/JspCompilationContext.java b/java/org/apache/jasper/JspCompilationContext.java index 0037f3ab2..de766f091 100644 --- a/java/org/apache/jasper/JspCompilationContext.java +++ b/java/org/apache/jasper/JspCompilationContext.java @@ -85,7 +85,7 @@ public class JspCompilationContext { protected URLClassLoader jspLoader; protected URL baseUrl; - protected Class servletClass; + protected Class servletClass; protected boolean isTagFile; protected boolean protoTypeMode; @@ -307,7 +307,7 @@ public class JspCompilationContext { } - public Set getResourcePaths(String path) { + public Set getResourcePaths(String path) { return context.getResourcePaths(canonicalURI(path)); } @@ -606,7 +606,7 @@ public class JspCompilationContext { // ==================== Manipulating the class ==================== - public Class load() + public Class load() throws JasperException, FileNotFoundException { try { diff --git a/java/org/apache/jasper/Options.java b/java/org/apache/jasper/Options.java index cff52c855..3b3341e9e 100644 --- a/java/org/apache/jasper/Options.java +++ b/java/org/apache/jasper/Options.java @@ -20,6 +20,8 @@ package org.apache.jasper; import java.io.File; import java.util.Map; +import javax.servlet.jsp.tagext.TagLibraryInfo; + import org.apache.jasper.compiler.JspConfig; import org.apache.jasper.compiler.TagPluginManager; import org.apache.jasper.compiler.TldLocationsCache; @@ -190,6 +192,6 @@ public interface Options { * * @return the Map(String uri, TreeNode tld) instance. */ - public Map getCache(); + public Map getCache(); } diff --git a/java/org/apache/jasper/compiler/AntCompiler.java b/java/org/apache/jasper/compiler/AntCompiler.java index 351267a5b..9579fb2f6 100644 --- a/java/org/apache/jasper/compiler/AntCompiler.java +++ b/java/org/apache/jasper/compiler/AntCompiler.java @@ -324,13 +324,15 @@ public class AntCompiler extends Compiler { /** * Thread <-> PrintStream associations. */ - protected static ThreadLocal streams = new ThreadLocal(); + protected static ThreadLocal streams = + new ThreadLocal(); /** * Thread <-> ByteArrayOutputStream associations. */ - protected static ThreadLocal data = new ThreadLocal(); + protected static ThreadLocal data = + new ThreadLocal(); // --------------------------------------------------------- Public Methods @@ -354,8 +356,7 @@ public class AntCompiler extends Compiler { * Stop capturing thread's output and return captured data as a String. */ public static String unsetThread() { - ByteArrayOutputStream baos = - (ByteArrayOutputStream) data.get(); + ByteArrayOutputStream baos = data.get(); if (baos == null) { return null; } @@ -372,7 +373,7 @@ public class AntCompiler extends Compiler { * Find PrintStream to which the output must be written to. */ protected PrintStream findStream() { - PrintStream ps = (PrintStream) streams.get(); + PrintStream ps = streams.get(); if (ps == null) { ps = wrapped; } diff --git a/java/org/apache/jasper/compiler/BeanRepository.java b/java/org/apache/jasper/compiler/BeanRepository.java index cd32b7fa4..032b978cf 100644 --- a/java/org/apache/jasper/compiler/BeanRepository.java +++ b/java/org/apache/jasper/compiler/BeanRepository.java @@ -53,9 +53,9 @@ public class BeanRepository { beanTypes.put(s, type); } - public Class getBeanType(String bean) + public Class getBeanType(String bean) throws JasperException { - Class clazz = null; + Class clazz = null; try { clazz = loader.loadClass(beanTypes.get(bean)); } catch (ClassNotFoundException ex) { diff --git a/java/org/apache/jasper/compiler/Compiler.java b/java/org/apache/jasper/compiler/Compiler.java index ee4204a67..397f0c7bd 100644 --- a/java/org/apache/jasper/compiler/Compiler.java +++ b/java/org/apache/jasper/compiler/Compiler.java @@ -444,14 +444,14 @@ public abstract class Compiler { return false; } - List depends = jsw.getDependants(); + List depends = jsw.getDependants(); if (depends == null) { return false; } - Iterator it = depends.iterator(); + Iterator it = depends.iterator(); while (it.hasNext()) { - String include = (String) it.next(); + String include = it.next(); try { URL includeUrl = ctxt.getResource(include); if (includeUrl == null) { diff --git a/java/org/apache/jasper/compiler/ELFunctionMapper.java b/java/org/apache/jasper/compiler/ELFunctionMapper.java index f2df33dc0..d7a5cea80 100644 --- a/java/org/apache/jasper/compiler/ELFunctionMapper.java +++ b/java/org/apache/jasper/compiler/ELFunctionMapper.java @@ -167,7 +167,7 @@ public class ELFunctionMapper { // First locate all unique functions in this EL Fvisitor fv = new Fvisitor(); el.visit(fv); - ArrayList functions = fv.funcs; + ArrayList functions = fv.funcs; if (functions.size() == 0) { return; @@ -198,7 +198,7 @@ public class ELFunctionMapper { // Setup arguments for either getMapForFunction or mapFunction for (int i = 0; i < functions.size(); i++) { - ELNode.Function f = (ELNode.Function)functions.get(i); + ELNode.Function f = functions.get(i); FunctionInfo funcInfo = f.getFunctionInfo(); String key = f.getPrefix()+ ":" + f.getName(); ds.append(funcMethod + "(\"" + key + "\", " + @@ -250,13 +250,13 @@ public class ELFunctionMapper { * @return A previous generated function mapper name that can be used * by this EL; null if none found. */ - private String matchMap(ArrayList functions) { + private String matchMap(ArrayList functions) { String mapName = null; for (int i = 0; i < functions.size(); i++) { - ELNode.Function f = (ELNode.Function)functions.get(i); - String temName = (String) gMap.get(f.getPrefix() + ':' + - f.getName() + ':' + f.getUri()); + ELNode.Function f = functions.get(i); + String temName = gMap.get(f.getPrefix() + ':' + f.getName() + + ':' + f.getUri()); if (temName == null) { return null; } diff --git a/java/org/apache/jasper/compiler/Generator.java b/java/org/apache/jasper/compiler/Generator.java index f9a28c026..20b14817f 100644 --- a/java/org/apache/jasper/compiler/Generator.java +++ b/java/org/apache/jasper/compiler/Generator.java @@ -35,6 +35,7 @@ import java.util.Vector; import javax.el.MethodExpression; import javax.el.ValueExpression; +import javax.servlet.jsp.tagext.Tag; import javax.servlet.jsp.tagext.TagAttributeInfo; import javax.servlet.jsp.tagext.TagInfo; import javax.servlet.jsp.tagext.TagVariableInfo; @@ -69,7 +70,7 @@ import org.xml.sax.Attributes; class Generator { - private static final Class[] OBJECT_CLASS = { Object.class }; + private static final Class[] OBJECT_CLASS = { Object.class }; private static final String VAR_EXPRESSIONFACTORY = System.getProperty("org.apache.jasper.compiler.Generator.VAR_EXPRESSIONFACTORY", "_el_expressionfactory"); @@ -78,7 +79,7 @@ class Generator { private ServletWriter out; - private ArrayList methodsBuffered; + private ArrayList methodsBuffered; private FragmentHelperClass fragmentHelperClass; @@ -247,14 +248,14 @@ class Generator { class TagHandlerPoolVisitor extends Node.Visitor { - private Vector names; + private Vector names; /* * Constructor * * @param v Vector of tag handler pool names to populate */ - TagHandlerPoolVisitor(Vector v) { + TagHandlerPoolVisitor(Vector v) { names = v; } @@ -316,10 +317,10 @@ class Generator { class ScriptingVarVisitor extends Node.Visitor { - private Vector vars; + private Vector vars; ScriptingVarVisitor() { - vars = new Vector(); + vars = new Vector(); } public void visit(Node.CustomTag n) throws JasperException { @@ -438,7 +439,7 @@ class Generator { if (isPoolingEnabled) { for (int i = 0; i < tagHandlerPoolNames.size(); i++) { - out.printin((String) tagHandlerPoolNames.elementAt(i)); + out.printin(tagHandlerPoolNames.elementAt(i)); out.println(".release();"); } } @@ -464,10 +465,10 @@ class Generator { * generation) */ private void genPreambleImports() throws JasperException { - Iterator iter = pageInfo.getImports().iterator(); + Iterator iter = pageInfo.getImports().iterator(); while (iter.hasNext()) { out.printin("import "); - out.print((String) iter.next()); + out.print(iter.next()); out.println(";"); } @@ -486,8 +487,8 @@ class Generator { // Static data for getDependants() out.printil("private static java.util.List _jspx_dependants;"); out.println(); - List dependants = pageInfo.getDependants(); - Iterator iter = dependants.iterator(); + List dependants = pageInfo.getDependants(); + Iterator iter = dependants.iterator(); if (!dependants.isEmpty()) { out.printil("static {"); out.pushIndent(); @@ -496,7 +497,7 @@ class Generator { out.println(");"); while (iter.hasNext()) { out.printin("_jspx_dependants.add(\""); - out.print((String) iter.next()); + out.print(iter.next()); out.println("\");"); } out.popIndent(); @@ -723,9 +724,9 @@ class Generator { * handlers: : tag short name : introspection info of tag * handler for tag */ - private Hashtable handlerInfos; + private Hashtable> handlerInfos; - private Hashtable tagVarNumbers; + private Hashtable tagVarNumbers; private String parent; @@ -743,7 +744,7 @@ class Generator { private ServletWriter out; - private ArrayList methodsBuffered; + private ArrayList methodsBuffered; private FragmentHelperClass fragmentHelperClass; @@ -755,13 +756,13 @@ class Generator { private int charArrayCount; - private HashMap textMap; + private HashMap textMap; /** * Constructor. */ public GenerateVisitor(boolean isTagFile, ServletWriter out, - ArrayList methodsBuffered, + ArrayList methodsBuffered, FragmentHelperClass fragmentHelperClass, ClassLoader loader, TagInfo tagInfo) { @@ -772,9 +773,10 @@ class Generator { this.loader = loader; this.tagInfo = tagInfo; methodNesting = 0; - handlerInfos = new Hashtable(); - tagVarNumbers = new Hashtable(); - textMap = new HashMap(); + handlerInfos = + new Hashtable>(); + tagVarNumbers = new Hashtable(); + textMap = new HashMap(); } /** @@ -794,7 +796,7 @@ class Generator { * attributes that aren't EL expressions) */ private String attributeValue(Node.JspAttribute attr, boolean encode, - Class expectedType) { + Class expectedType) { String v = attr.getValue(); if (!attr.isNamedAttribute() && (v == null)) return ""; @@ -1100,7 +1102,7 @@ class Generator { if (beanInfo.checkVariable(name)) { // Bean is defined using useBean, introspect at compile time - Class bean = beanInfo.getBeanType(name); + Class bean = beanInfo.getBeanType(name); String beanName = JspUtil.getCanonicalName(bean); java.lang.reflect.Method meth = JspRuntimeLibrary .getReadMethod(bean, property); @@ -1232,7 +1234,7 @@ class Generator { String canonicalName = null; // Canonical name for klass if (klass != null) { try { - Class bean = ctxt.getClassLoader().loadClass(klass); + Class bean = ctxt.getClassLoader().loadClass(klass); if (klass.indexOf('$') >= 0) { // Obtain the canonical type name canonicalName = JspUtil.getCanonicalName(bean); @@ -1859,7 +1861,7 @@ class Generator { // Compute attribute value string for XML-style and named // attributes - Hashtable map = new Hashtable(); + Hashtable map = new Hashtable(); Node.JspAttribute[] attrs = n.getJspAttributes(); for (int i = 0; attrs != null && i < attrs.length; i++) { String attrStr = null; @@ -1882,10 +1884,10 @@ class Generator { out.print(" + " + elemName); // Write remaining attributes - Enumeration enumeration = map.keys(); + Enumeration enumeration = map.keys(); while (enumeration.hasMoreElements()) { - String attrName = (String) enumeration.nextElement(); - out.print((String) map.get(attrName)); + String attrName = enumeration.nextElement(); + out.print(map.get(attrName)); } // Does the have nested tags other than @@ -1954,11 +1956,11 @@ class Generator { charArrayBuffer = new GenBuffer(); caOut = charArrayBuffer.getOut(); caOut.pushIndent(); - textMap = new HashMap(); + textMap = new HashMap(); } else { caOut = charArrayBuffer.getOut(); } - String charArrayName = (String) textMap.get(text); + String charArrayName = textMap.get(text); if (charArrayName == null) { charArrayName = "_jspx_char_array_" + charArrayCount++; textMap.put(text, charArrayName); @@ -2150,14 +2152,15 @@ class Generator { private TagHandlerInfo getTagHandlerInfo(Node.CustomTag n) throws JasperException { - Hashtable handlerInfosByShortName = (Hashtable) handlerInfos.get(n - .getPrefix()); + Hashtable handlerInfosByShortName = + handlerInfos.get(n.getPrefix()); if (handlerInfosByShortName == null) { - handlerInfosByShortName = new Hashtable(); + handlerInfosByShortName = + new Hashtable(); handlerInfos.put(n.getPrefix(), handlerInfosByShortName); } - TagHandlerInfo handlerInfo = (TagHandlerInfo) handlerInfosByShortName - .get(n.getLocalName()); + TagHandlerInfo handlerInfo = + handlerInfosByShortName.get(n.getLocalName()); if (handlerInfo == null) { handlerInfo = new TagHandlerInfo(n, n.getTagHandlerClass(), err); handlerInfosByShortName.put(n.getLocalName(), handlerInfo); @@ -2180,7 +2183,8 @@ class Generator { String tagEvalVar, String tagPushBodyCountVar) throws JasperException { - Class tagHandlerClass = handlerInfo.getTagHandlerClass(); + Class tagHandlerClass = + handlerInfo.getTagHandlerClass(); out.printin("// "); out.println(n.getQName()); @@ -2447,7 +2451,8 @@ class Generator { TagHandlerInfo handlerInfo, String tagHandlerVar) throws JasperException { - Class tagHandlerClass = handlerInfo.getTagHandlerClass(); + Class tagHandlerClass = + handlerInfo.getTagHandlerClass(); n.setBeginJavaLine(out.getJavaLine()); out.printin("// "); @@ -2520,7 +2525,7 @@ class Generator { private void declareScriptingVars(Node.CustomTag n, int scope) { - Vector vec = n.getScriptingVars(scope); + Vector vec = n.getScriptingVars(scope); if (vec != null) { for (int i = 0; i < vec.size(); i++) { Object elem = vec.elementAt(i); @@ -2744,7 +2749,7 @@ class Generator { synchronized (tagVarNumbers) { varName = prefix + "_" + shortName + "_"; if (tagVarNumbers.get(fullName) != null) { - Integer i = (Integer) tagVarNumbers.get(fullName); + Integer i = tagVarNumbers.get(fullName); varName = varName + i.intValue(); tagVarNumbers.put(fullName, new Integer(i.intValue() + 1)); } else { @@ -2778,7 +2783,7 @@ class Generator { String localName = attr.getLocalName(); Method m = null; - Class[] c = null; + Class[] c = null; if (attr.isDynamic()) { c = OBJECT_CLASS; } else { @@ -3047,8 +3052,8 @@ class Generator { * attribute is a named attribute (that is, specified using the * jsp:attribute standard action), and false otherwise */ - private String convertString(Class c, String s, String attrName, - Class propEditorClass, boolean isNamedAttribute) + private String convertString(Class c, String s, String attrName, + Class propEditorClass, boolean isNamedAttribute) throws JasperException { String quoted = s; @@ -3286,7 +3291,7 @@ class Generator { private void genCommonPostamble() { // Append any methods that were generated in the buffer. for (int i = 0; i < methodsBuffered.size(); i++) { - GenBuffer methodBuffer = (GenBuffer) methodsBuffered.get(i); + GenBuffer methodBuffer = methodsBuffered.get(i); methodBuffer.adjustJavaLines(out.getJavaLine() - 1); out.printMultiLn(methodBuffer.toString()); } @@ -3350,7 +3355,7 @@ class Generator { */ Generator(ServletWriter out, Compiler compiler) { this.out = out; - methodsBuffered = new ArrayList(); + methodsBuffered = new ArrayList(); charArrayBuffer = null; err = compiler.getErrorDispatcher(); ctxt = compiler.getCompilationContext(); @@ -3374,7 +3379,7 @@ class Generator { beanInfo = pageInfo.getBeanRepository(); breakAtLF = ctxt.getOptions().getMappedFile(); if (isPoolingEnabled) { - tagHandlerPoolNames = new Vector(); + tagHandlerPoolNames = new Vector(); } } @@ -3838,11 +3843,11 @@ class Generator { */ private static class TagHandlerInfo { - private Hashtable methodMaps; + private Hashtable methodMaps; - private Hashtable propertyEditorMaps; + private Hashtable> propertyEditorMaps; - private Class tagHandlerClass; + private Class tagHandlerClass; /** * Constructor. @@ -3855,11 +3860,11 @@ class Generator { * @param err * Error dispatcher */ - TagHandlerInfo(Node n, Class tagHandlerClass, ErrorDispatcher err) - throws JasperException { + TagHandlerInfo(Node n, Class tagHandlerClass, + ErrorDispatcher err) throws JasperException { this.tagHandlerClass = tagHandlerClass; - this.methodMaps = new Hashtable(); - this.propertyEditorMaps = new Hashtable(); + this.methodMaps = new Hashtable(); + this.propertyEditorMaps = new Hashtable>(); try { BeanInfo tagClassInfo = Introspector @@ -3887,20 +3892,20 @@ class Generator { * XXX */ public Method getSetterMethod(String attrName) { - return (Method) methodMaps.get(attrName); + return methodMaps.get(attrName); } /** * XXX */ - public Class getPropertyEditorClass(String attrName) { - return (Class) propertyEditorMaps.get(attrName); + public Class getPropertyEditorClass(String attrName) { + return propertyEditorMaps.get(attrName); } /** * XXX */ - public Class getTagHandlerClass() { + public Class getTagHandlerClass() { return tagHandlerClass; } } @@ -4017,7 +4022,7 @@ class Generator { // True if the helper class should be generated. private boolean used = false; - private ArrayList fragments = new ArrayList(); + private ArrayList fragments = new ArrayList(); private String className; @@ -4113,7 +4118,7 @@ class Generator { ServletWriter out = this.classBuffer.getOut(); // Generate all fragment methods: for (int i = 0; i < fragments.size(); i++) { - Fragment fragment = (Fragment) fragments.get(i); + Fragment fragment = fragments.get(i); fragment.getGenBuffer().adjustJavaLines(out.getJavaLine() - 1); out.printMultiLn(fragment.getGenBuffer().toString()); } @@ -4182,7 +4187,7 @@ class Generator { public void adjustJavaLines(int offset) { for (int i = 0; i < fragments.size(); i++) { - Fragment fragment = (Fragment) fragments.get(i); + Fragment fragment = fragments.get(i); fragment.getGenBuffer().adjustJavaLines(offset); } } diff --git a/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java b/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java index dbe9c1ec7..318b44b01 100644 --- a/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java +++ b/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java @@ -52,11 +52,11 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo { private static final String IMPLICIT_TLD = "implicit.tld"; // Maps tag names to tag file paths - private Hashtable tagFileMap; + private Hashtable tagFileMap; private ParserController pc; private PageInfo pi; - private Vector vec; + private Vector vec; /** * Constructor. @@ -70,8 +70,8 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo { super(prefix, null); this.pc = pc; this.pi = pi; - this.tagFileMap = new Hashtable(); - this.vec = new Vector(); + this.tagFileMap = new Hashtable(); + this.vec = new Vector(); // Implicit tag libraries have no functions: this.functions = new FunctionInfo[0]; @@ -94,11 +94,11 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo { } // Populate mapping of tag names to tag file paths - Set dirList = ctxt.getResourcePaths(tagdir); + Set dirList = ctxt.getResourcePaths(tagdir); if (dirList != null) { - Iterator it = dirList.iterator(); + Iterator it = dirList.iterator(); while (it.hasNext()) { - String path = (String) it.next(); + String path = it.next(); if (path.endsWith(TAG_FILE_SUFFIX) || path.endsWith(TAGX_FILE_SUFFIX)) { /* @@ -131,10 +131,10 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo { } // Process each child element of our element - Iterator list = tld.findChildren(); + Iterator list = tld.findChildren(); while (list.hasNext()) { - TreeNode element = (TreeNode) list.next(); + TreeNode element = list.next(); String tname = element.getName(); if ("tlibversion".equals(tname) // JSP 1.1 @@ -184,7 +184,7 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo { TagFileInfo tagFile = super.getTagFile(shortName); if (tagFile == null) { - String path = (String) tagFileMap.get(shortName); + String path = tagFileMap.get(shortName); if (path == null) { return null; } @@ -210,8 +210,8 @@ class ImplicitTagLibraryInfo extends TagLibraryInfo { } public TagLibraryInfo[] getTagLibraryInfos() { - Collection coll = pi.getTaglibs(); - return (TagLibraryInfo[]) coll.toArray(new TagLibraryInfo[0]); + Collection coll = pi.getTaglibs(); + return coll.toArray(new TagLibraryInfo[0]); } } diff --git a/java/org/apache/jasper/compiler/JDTCompiler.java b/java/org/apache/jasper/compiler/JDTCompiler.java index 8d960b72d..b8ccd048d 100644 --- a/java/org/apache/jasper/compiler/JDTCompiler.java +++ b/java/org/apache/jasper/compiler/JDTCompiler.java @@ -81,7 +81,8 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler { final ClassLoader classLoader = ctxt.getJspLoader(); String[] fileNames = new String[] {sourceFile}; String[] classNames = new String[] {targetClassName}; - final ArrayList problemList = new ArrayList(); + final ArrayList problemList = + new ArrayList(); class CompilationUnit implements ICompilationUnit { @@ -266,7 +267,7 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler { final IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.proceedWithAllProblems(); - final Map settings = new HashMap(); + final Map settings = new HashMap(); settings.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE); settings.put(CompilerOptions.OPTION_SourceFileAttribute, @@ -419,7 +420,7 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler { if (!problemList.isEmpty()) { JavacErrorDetail[] jeds = - (JavacErrorDetail[]) problemList.toArray(new JavacErrorDetail[0]); + problemList.toArray(new JavacErrorDetail[0]); errDispatcher.javacError(jeds); } diff --git a/java/org/apache/jasper/compiler/JavacErrorDetail.java b/java/org/apache/jasper/compiler/JavacErrorDetail.java index cf2daffe1..8c2b56502 100644 --- a/java/org/apache/jasper/compiler/JavacErrorDetail.java +++ b/java/org/apache/jasper/compiler/JavacErrorDetail.java @@ -220,13 +220,13 @@ public class JavacErrorDetail { */ private String[] readFile(InputStream s) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(s)); - List lines = new ArrayList(); + List lines = new ArrayList(); String line; while ( (line = reader.readLine()) != null ) { lines.add(line); } - return (String[]) lines.toArray( new String[lines.size()] ); + return lines.toArray( new String[lines.size()] ); } } diff --git a/java/org/apache/jasper/compiler/JspConfig.java b/java/org/apache/jasper/compiler/JspConfig.java index 7a9542fd1..6b9d38208 100644 --- a/java/org/apache/jasper/compiler/JspConfig.java +++ b/java/org/apache/jasper/compiler/JspConfig.java @@ -46,7 +46,7 @@ public class JspConfig { // Logger private Log log = LogFactory.getLog(JspConfig.class); - private Vector jspProperties = null; + private Vector jspProperties = null; private ServletContext ctxt; private boolean initialized = false; @@ -100,26 +100,27 @@ public class JspConfig { return; } - jspProperties = new Vector(); - Iterator jspPropertyList = jspConfig.findChildren("jsp-property-group"); + jspProperties = new Vector(); + Iterator jspPropertyList = + jspConfig.findChildren("jsp-property-group"); while (jspPropertyList.hasNext()) { - TreeNode element = (TreeNode) jspPropertyList.next(); - Iterator list = element.findChildren(); + TreeNode element = jspPropertyList.next(); + Iterator list = element.findChildren(); - Vector urlPatterns = new Vector(); + Vector urlPatterns = new Vector(); String pageEncoding = null; String scriptingInvalid = null; String elIgnored = null; String isXml = null; - Vector includePrelude = new Vector(); - Vector includeCoda = new Vector(); + Vector includePrelude = new Vector(); + Vector includeCoda = new Vector(); String deferredSyntaxAllowedAsLiteral = null; String trimDirectiveWhitespaces = null; while (list.hasNext()) { - element = (TreeNode) list.next(); + element = list.next(); String tname = element.getName(); if ("url-pattern".equals(tname)) @@ -149,7 +150,7 @@ public class JspConfig { // Add one JspPropertyGroup for each URL Pattern. This makes // the matching logic easier. for( int p = 0; p < urlPatterns.size(); p++ ) { - String urlPattern = (String)urlPatterns.elementAt( p ); + String urlPattern = urlPatterns.elementAt( p ); String path = null; String extension = null; @@ -289,8 +290,8 @@ public class JspConfig { uriExtension = uri.substring(index+1); } - Vector includePreludes = new Vector(); - Vector includeCodas = new Vector(); + Vector includePreludes = new Vector(); + Vector includeCodas = new Vector(); JspPropertyGroup isXmlMatch = null; JspPropertyGroup elIgnoredMatch = null; @@ -299,10 +300,10 @@ public class JspConfig { JspPropertyGroup deferedSyntaxAllowedAsLiteralMatch = null; JspPropertyGroup trimDirectiveWhitespacesMatch = null; - Iterator iter = jspProperties.iterator(); + Iterator iter = jspProperties.iterator(); while (iter.hasNext()) { - JspPropertyGroup jpg = (JspPropertyGroup) iter.next(); + JspPropertyGroup jpg = iter.next(); JspProperty jp = jpg.getJspProperty(); // (arrays will be the same length) @@ -419,10 +420,10 @@ public class JspConfig { uriExtension = uri.substring(index+1); } - Iterator iter = jspProperties.iterator(); + Iterator iter = jspProperties.iterator(); while (iter.hasNext()) { - JspPropertyGroup jpg = (JspPropertyGroup) iter.next(); + JspPropertyGroup jpg = iter.next(); JspProperty jp = jpg.getJspProperty(); String extension = jpg.getExtension(); @@ -475,14 +476,14 @@ public class JspConfig { private String elIgnored; private String scriptingInvalid; private String pageEncoding; - private Vector includePrelude; - private Vector includeCoda; + private Vector includePrelude; + private Vector includeCoda; private String deferedSyntaxAllowedAsLiteral; private String trimDirectiveWhitespaces; public JspProperty(String isXml, String elIgnored, String scriptingInvalid, String pageEncoding, - Vector includePrelude, Vector includeCoda, + Vector includePrelude, Vector includeCoda, String deferedSyntaxAllowedAsLiteral, String trimDirectiveWhitespaces) { @@ -512,11 +513,11 @@ public class JspConfig { return pageEncoding; } - public Vector getIncludePrelude() { + public Vector getIncludePrelude() { return includePrelude; } - public Vector getIncludeCoda() { + public Vector getIncludeCoda() { return includeCoda; } diff --git a/java/org/apache/jasper/compiler/JspDocumentParser.java b/java/org/apache/jasper/compiler/JspDocumentParser.java index 3acd9d5b9..e51008556 100644 --- a/java/org/apache/jasper/compiler/JspDocumentParser.java +++ b/java/org/apache/jasper/compiler/JspDocumentParser.java @@ -25,6 +25,7 @@ import java.util.Iterator; import java.util.List; import java.util.jar.JarFile; +import javax.servlet.jsp.tagext.Tag; import javax.servlet.jsp.tagext.TagFileInfo; import javax.servlet.jsp.tagext.TagInfo; import javax.servlet.jsp.tagext.TagLibraryInfo; @@ -228,11 +229,11 @@ class JspDocumentParser * This is used to implement the include-prelude and include-coda * subelements of the jsp-config element in web.xml */ - private void addInclude(Node parent, List files) throws SAXException { + private void addInclude(Node parent, List files) throws SAXException { if (files != null) { - Iterator iter = files.iterator(); + Iterator iter = files.iterator(); while (iter.hasNext()) { - String file = (String)iter.next(); + String file = iter.next(); AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "file", "file", "CDATA", file); @@ -1166,7 +1167,7 @@ class JspDocumentParser throw new SAXException( Localizer.getMessage("jsp.error.xml.bad_tag", localName, uri)); } - Class tagHandlerClass = null; + Class tagHandlerClass = null; if (tagInfo != null) { String handlerClassName = tagInfo.getTagClassName(); try { @@ -1254,7 +1255,7 @@ class JspDocumentParser String[] location = ctxt.getTldLocation(uri); if (location != null || !isPlainUri) { if (ctxt.getOptions().isCaching()) { - result = (TagLibraryInfoImpl) ctxt.getOptions().getCache().get(uri); + result = ctxt.getOptions().getCache().get(uri); } if (result == null) { /* diff --git a/java/org/apache/jasper/compiler/JspReader.java b/java/org/apache/jasper/compiler/JspReader.java index 4df569f91..d20b6b87b 100644 --- a/java/org/apache/jasper/compiler/JspReader.java +++ b/java/org/apache/jasper/compiler/JspReader.java @@ -68,7 +68,7 @@ class JspReader { /** * The list of source files. */ - private List sourceFiles; + private List sourceFiles; /** * The current file ID (-1 indicates an error or no file). @@ -134,7 +134,7 @@ class JspReader { this.context = ctxt; this.err = err; - sourceFiles = new Vector(); + sourceFiles = new Vector(); currFileId = 0; size = 0; singleFile = false; @@ -156,7 +156,7 @@ class JspReader { * @return The file at that position, if found, null otherwise */ String getFile(final int fileid) { - return (String) sourceFiles.get(fileid); + return sourceFiles.get(fileid); } /** diff --git a/java/org/apache/jasper/compiler/JspRuntimeContext.java b/java/org/apache/jasper/compiler/JspRuntimeContext.java index 6e4fe069b..797559e6c 100644 --- a/java/org/apache/jasper/compiler/JspRuntimeContext.java +++ b/java/org/apache/jasper/compiler/JspRuntimeContext.java @@ -240,9 +240,9 @@ public final class JspRuntimeContext { * Process a "destory" event for this web application context. */ public void destroy() { - Iterator servlets = jsps.values().iterator(); + Iterator servlets = jsps.values().iterator(); while (servlets.hasNext()) { - ((JspServletWrapper) servlets.next()).destroy(); + servlets.next().destroy(); } } @@ -336,7 +336,7 @@ public final class JspRuntimeContext { // protocol URL's to the classpath. if( urls[i].getProtocol().equals("file") ) { - cpath.append((String)urls[i].getFile()+sep); + cpath.append(urls[i].getFile()+sep); } } diff --git a/java/org/apache/jasper/compiler/Mark.java b/java/org/apache/jasper/compiler/Mark.java index 85c942bfe..789e2bcd7 100644 --- a/java/org/apache/jasper/compiler/Mark.java +++ b/java/org/apache/jasper/compiler/Mark.java @@ -47,7 +47,7 @@ final class Mark { * stack of stream and stream state of streams that have included * current stream */ - private Stack includeStack = null; + private Stack includeStack = null; // encoding of current file private String encoding = null; @@ -80,7 +80,7 @@ final class Mark { this.fileName = name; this.baseDir = inBaseDir; this.encoding = inEncoding; - this.includeStack = new Stack(); + this.includeStack = new Stack(); } @@ -101,7 +101,7 @@ final class Mark { this.encoding = other.encoding; // clone includeStack without cloning contents - includeStack = new Stack(); + includeStack = new Stack(); for ( int i=0; i < other.includeStack.size(); i++ ) { includeStack.addElement( other.includeStack.elementAt(i) ); } @@ -168,7 +168,7 @@ final class Mark { } // get previous state in stack - IncludeState state = (IncludeState) includeStack.pop( ); + IncludeState state = includeStack.pop( ); // set new variables cursor = state.cursor; diff --git a/java/org/apache/jasper/compiler/Node.java b/java/org/apache/jasper/compiler/Node.java index 2aa504fdc..86df9b7f5 100644 --- a/java/org/apache/jasper/compiler/Node.java +++ b/java/org/apache/jasper/compiler/Node.java @@ -31,6 +31,7 @@ import javax.servlet.jsp.tagext.DynamicAttributes; import javax.servlet.jsp.tagext.IterationTag; import javax.servlet.jsp.tagext.JspIdConsumer; import javax.servlet.jsp.tagext.SimpleTag; +import javax.servlet.jsp.tagext.Tag; import javax.servlet.jsp.tagext.TagAttributeInfo; import javax.servlet.jsp.tagext.TagData; import javax.servlet.jsp.tagext.TagFileInfo; @@ -590,7 +591,7 @@ abstract class Node implements TagConstants { */ public static class PageDirective extends Node { - private Vector imports; + private Vector imports; public PageDirective(Attributes attrs, Mark start, Node parent) { this(JSP_PAGE_DIRECTIVE_ACTION, attrs, null, null, start, parent); @@ -601,7 +602,7 @@ abstract class Node implements TagConstants { Mark start, Node parent) { super(qName, PAGE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); - imports = new Vector(); + imports = new Vector(); } public void accept(Visitor v) throws JasperException { @@ -631,7 +632,7 @@ abstract class Node implements TagConstants { } } - public List getImports() { + public List getImports() { return imports; } } @@ -676,7 +677,7 @@ abstract class Node implements TagConstants { * Represents a tag directive */ public static class TagDirective extends Node { - private Vector imports; + private Vector imports; public TagDirective(Attributes attrs, Mark start, Node parent) { this(JSP_TAG_DIRECTIVE_ACTION, attrs, null, null, start, parent); @@ -687,7 +688,7 @@ abstract class Node implements TagConstants { Mark start, Node parent) { super(qName, TAG_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); - imports = new Vector(); + imports = new Vector(); } public void accept(Visitor v) throws JasperException { @@ -717,7 +718,7 @@ abstract class Node implements TagConstants { } } - public List getImports() { + public List getImports() { return imports; } } @@ -1405,7 +1406,7 @@ abstract class Node implements TagConstants { private TagFileInfo tagFileInfo; - private Class tagHandlerClass; + private Class tagHandlerClass; private VariableInfo[] varInfos; @@ -1425,11 +1426,11 @@ abstract class Node implements TagConstants { private boolean implementsDynamicAttributes; - private Vector atBeginScriptingVars; + private Vector atBeginScriptingVars; - private Vector atEndScriptingVars; + private Vector atEndScriptingVars; - private Vector nestedScriptingVars; + private Vector nestedScriptingVars; private Node.CustomTag customTagParent; @@ -1454,7 +1455,7 @@ abstract class Node implements TagConstants { */ public CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, Mark start, Node parent, - TagInfo tagInfo, Class tagHandlerClass) { + TagInfo tagInfo, Class tagHandlerClass) { this(qName, prefix, localName, uri, attrs, null, null, start, parent, tagInfo, tagHandlerClass); } @@ -1465,7 +1466,7 @@ abstract class Node implements TagConstants { public CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent, - TagInfo tagInfo, Class tagHandlerClass) { + TagInfo tagInfo, Class tagHandlerClass) { super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); @@ -1605,11 +1606,11 @@ abstract class Node implements TagConstants { return tagFileInfo != null; } - public Class getTagHandlerClass() { + public Class getTagHandlerClass() { return tagHandlerClass; } - public void setTagHandlerClass(Class hc) { + public void setTagHandlerClass(Class hc) { tagHandlerClass = hc; } @@ -1661,7 +1662,7 @@ abstract class Node implements TagConstants { return this.numCount; } - public void setScriptingVars(Vector vec, int scope) { + public void setScriptingVars(Vector vec, int scope) { switch (scope) { case VariableInfo.AT_BEGIN: this.atBeginScriptingVars = vec; @@ -1679,8 +1680,8 @@ abstract class Node implements TagConstants { * Gets the scripting variables for the given scope that need to be * declared. */ - public Vector getScriptingVars(int scope) { - Vector vec = null; + public Vector getScriptingVars(int scope) { + Vector vec = null; switch (scope) { case VariableInfo.AT_BEGIN: @@ -2004,7 +2005,7 @@ abstract class Node implements TagConstants { */ public static class TemplateText extends Node { - private ArrayList extraSmap = null; + private ArrayList extraSmap = null; public TemplateText(String text, Mark start, Node parent) { super(null, null, text, start, parent); @@ -2064,12 +2065,12 @@ abstract class Node implements TagConstants { */ public void addSmap(int srcLine) { if (extraSmap == null) { - extraSmap = new ArrayList(); + extraSmap = new ArrayList(); } extraSmap.add(new Integer(srcLine)); } - public ArrayList getExtraSmap() { + public ArrayList getExtraSmap() { return extraSmap; } } @@ -2311,19 +2312,19 @@ abstract class Node implements TagConstants { */ public static class Nodes { - private List list; + private List list; private Node.Root root; // null if this is not a page private boolean generatedInBuffer; public Nodes() { - list = new Vector(); + list = new Vector(); } public Nodes(Node.Root root) { this.root = root; - list = new Vector(); + list = new Vector(); list.add(root); } @@ -2355,9 +2356,9 @@ abstract class Node implements TagConstants { * The visitor used */ public void visit(Visitor v) throws JasperException { - Iterator iter = list.iterator(); + Iterator iter = list.iterator(); while (iter.hasNext()) { - Node n = (Node) iter.next(); + Node n = iter.next(); n.accept(v); } } @@ -2369,7 +2370,7 @@ abstract class Node implements TagConstants { public Node getNode(int index) { Node n = null; try { - n = (Node) list.get(index); + n = list.get(index); } catch (ArrayIndexOutOfBoundsException e) { } return n; diff --git a/java/org/apache/jasper/compiler/PageDataImpl.java b/java/org/apache/jasper/compiler/PageDataImpl.java index deb4adfe2..9022d31e3 100644 --- a/java/org/apache/jasper/compiler/PageDataImpl.java +++ b/java/org/apache/jasper/compiler/PageDataImpl.java @@ -518,7 +518,7 @@ class PageDataImpl extends PageData implements TagConstants { if (n.getImports().size() > 0) { // Concatenate names of imported classes/packages boolean first = true; - ListIterator iter = n.getImports().listIterator(); + ListIterator iter = n.getImports().listIterator(); while (iter.hasNext()) { if (first) { first = false; @@ -526,7 +526,7 @@ class PageDataImpl extends PageData implements TagConstants { } else { buf.append(","); } - buf.append(JspUtil.getExprInXml((String) iter.next())); + buf.append(JspUtil.getExprInXml(iter.next())); } buf.append("\"\n"); } diff --git a/java/org/apache/jasper/compiler/PageInfo.java b/java/org/apache/jasper/compiler/PageInfo.java index 5a016fc39..70b30d726 100644 --- a/java/org/apache/jasper/compiler/PageInfo.java +++ b/java/org/apache/jasper/compiler/PageInfo.java @@ -38,14 +38,14 @@ import javax.servlet.jsp.tagext.TagLibraryInfo; class PageInfo { - private Vector imports; - private Vector dependants; + private Vector imports; + private Vector dependants; private BeanRepository beanRepository; - private HashMap taglibsMap; - private HashMap jspPrefixMapper; - private HashMap xmlPrefixMapper; - private HashMap nonCustomTagPrefixMap; + private HashMap taglibsMap; + private HashMap jspPrefixMapper; + private HashMap> xmlPrefixMapper; + private HashMap nonCustomTagPrefixMap; private String jspFile; private String defaultLanguage = "java"; private String language; @@ -86,28 +86,28 @@ class PageInfo { private boolean isJspPrefixHijacked; // Set of all element and attribute prefixes used in this translation unit - private HashSet prefixes; + private HashSet prefixes; private boolean hasJspRoot = false; - private Vector includePrelude; - private Vector includeCoda; - private Vector pluginDcls; // Id's for tagplugin declarations + private Vector includePrelude; + private Vector includeCoda; + private Vector pluginDcls; // Id's for tagplugin declarations PageInfo(BeanRepository beanRepository, String jspFile) { this.jspFile = jspFile; this.beanRepository = beanRepository; - this.taglibsMap = new HashMap(); - this.jspPrefixMapper = new HashMap(); - this.xmlPrefixMapper = new HashMap(); - this.nonCustomTagPrefixMap = new HashMap(); - this.imports = new Vector(); - this.dependants = new Vector(); - this.includePrelude = new Vector(); - this.includeCoda = new Vector(); - this.pluginDcls = new Vector(); - this.prefixes = new HashSet(); + this.taglibsMap = new HashMap(); + this.jspPrefixMapper = new HashMap(); + this.xmlPrefixMapper = new HashMap>(); + this.nonCustomTagPrefixMap = new HashMap(); + this.imports = new Vector(); + this.dependants = new Vector(); + this.includePrelude = new Vector(); + this.includeCoda = new Vector(); + this.pluginDcls = new Vector(); + this.prefixes = new HashSet(); // Enter standard imports for(int i = 0; i < Constants.STANDARD_IMPORTS.length; i++) @@ -126,7 +126,7 @@ class PageInfo { return false; } - public void addImports(List imports) { + public void addImports(List imports) { this.imports.addAll(imports); } @@ -134,7 +134,7 @@ class PageInfo { this.imports.add(imp); } - public List getImports() { + public List getImports() { return imports; } @@ -147,7 +147,7 @@ class PageInfo { dependants.add(d); } - public List getDependants() { + public List getDependants() { return dependants; } @@ -171,19 +171,19 @@ class PageInfo { return scriptingInvalid; } - public List getIncludePrelude() { + public List getIncludePrelude() { return includePrelude; } - public void setIncludePrelude(Vector prelude) { + public void setIncludePrelude(Vector prelude) { includePrelude = prelude; } - public List getIncludeCoda() { + public List getIncludeCoda() { return includeCoda; } - public void setIncludeCoda(Vector coda) { + public void setIncludeCoda(Vector coda) { includeCoda = coda; } @@ -274,7 +274,7 @@ class PageInfo { * @return Tag library corresponding to the given URI */ public TagLibraryInfo getTaglib(String uri) { - return (TagLibraryInfo) taglibsMap.get(uri); + return taglibsMap.get(uri); } /* @@ -282,7 +282,7 @@ class PageInfo { * * @return Collection of tag libraries that are associated with a URI */ - public Collection getTaglibs() { + public Collection getTaglibs() { return taglibsMap.values(); } @@ -316,9 +316,9 @@ class PageInfo { * @param uri The URI to be pushed onto the stack */ public void pushPrefixMapping(String prefix, String uri) { - LinkedList stack = (LinkedList) xmlPrefixMapper.get(prefix); + LinkedList stack = xmlPrefixMapper.get(prefix); if (stack == null) { - stack = new LinkedList(); + stack = new LinkedList(); xmlPrefixMapper.put(prefix, stack); } stack.addFirst(uri); @@ -331,7 +331,7 @@ class PageInfo { * @param prefix The prefix whose stack of URIs is to be popped */ public void popPrefixMapping(String prefix) { - LinkedList stack = (LinkedList) xmlPrefixMapper.get(prefix); + LinkedList stack = xmlPrefixMapper.get(prefix); if (stack == null || stack.size() == 0) { // XXX throw new Exception("XXX"); } @@ -349,11 +349,11 @@ class PageInfo { String uri = null; - LinkedList stack = (LinkedList) xmlPrefixMapper.get(prefix); + LinkedList stack = xmlPrefixMapper.get(prefix); if (stack == null || stack.size() == 0) { - uri = (String) jspPrefixMapper.get(prefix); + uri = jspPrefixMapper.get(prefix); } else { - uri = (String) stack.getFirst(); + uri = stack.getFirst(); } return uri; @@ -678,7 +678,7 @@ class PageInfo { } public Mark getNonCustomTagPrefix(String prefix) { - return (Mark) nonCustomTagPrefixMap.get(prefix); + return nonCustomTagPrefixMap.get(prefix); } public String getDeferredSyntaxAllowedAsLiteral() { diff --git a/java/org/apache/jasper/compiler/Parser.java b/java/org/apache/jasper/compiler/Parser.java index 40e7d9103..5eb544ee3 100644 --- a/java/org/apache/jasper/compiler/Parser.java +++ b/java/org/apache/jasper/compiler/Parser.java @@ -382,11 +382,11 @@ class Parser implements TagConstants { * Add a list of files. This is used for implementing include-prelude and * include-coda of jsp-config element in web.xml */ - private void addInclude(Node parent, List files) throws JasperException { + private void addInclude(Node parent, List files) throws JasperException { if (files != null) { - Iterator iter = files.iterator(); + Iterator iter = files.iterator(); while (iter.hasNext()) { - String file = (String) iter.next(); + String file = iter.next(); AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "file", "file", "CDATA", file); @@ -1230,7 +1230,7 @@ class Parser implements TagConstants { if (tagInfo == null && tagFileInfo == null) { err.jspError(start, "jsp.error.bad_tag", shortTagName, prefix); } - Class tagHandlerClass = null; + Class tagHandlerClass = null; if (tagInfo != null) { // Must be a classic tag, load it here. // tag files will be loaded later, in TagFileProcessor diff --git a/java/org/apache/jasper/compiler/ParserController.java b/java/org/apache/jasper/compiler/ParserController.java index 25f3c39a7..50dc1d02b 100644 --- a/java/org/apache/jasper/compiler/ParserController.java +++ b/java/org/apache/jasper/compiler/ParserController.java @@ -58,7 +58,7 @@ class ParserController implements TagConstants { * A stack to keep track of the 'current base directory' * for include directives that refer to relative paths. */ - private Stack baseDirStack = new Stack(); + private Stack baseDirStack = new Stack(); private boolean isEncodingSpecifiedInProlog; private boolean isBomPresent; @@ -534,7 +534,7 @@ class ParserController implements TagConstants { String fileName = inFileName.replace('\\', '/'); boolean isAbsolute = fileName.startsWith("/"); fileName = isAbsolute ? fileName - : (String) baseDirStack.peek() + fileName; + : baseDirStack.peek() + fileName; String baseDir = fileName.substring(0, fileName.lastIndexOf("/") + 1); baseDirStack.push(baseDir); diff --git a/java/org/apache/jasper/compiler/ScriptingVariabler.java b/java/org/apache/jasper/compiler/ScriptingVariabler.java index 7110356c9..d4366b09d 100644 --- a/java/org/apache/jasper/compiler/ScriptingVariabler.java +++ b/java/org/apache/jasper/compiler/ScriptingVariabler.java @@ -58,11 +58,11 @@ class ScriptingVariabler { static class ScriptingVariableVisitor extends Node.Visitor { private ErrorDispatcher err; - private Hashtable scriptVars; + private Hashtable scriptVars; public ScriptingVariableVisitor(ErrorDispatcher err) { this.err = err; - scriptVars = new Hashtable(); + scriptVars = new Hashtable(); } public void visit(Node.CustomTag n) throws JasperException { @@ -81,7 +81,7 @@ class ScriptingVariabler { return; } - Vector vec = new Vector(); + Vector vec = new Vector(); Integer ownRange = null; if (scope == VariableInfo.AT_BEGIN @@ -104,7 +104,7 @@ class ScriptingVariabler { } String varName = varInfos[i].getVarName(); - Integer currentRange = (Integer) scriptVars.get(varName); + Integer currentRange = scriptVars.get(varName); if (currentRange == null || ownRange.compareTo(currentRange) > 0) { scriptVars.put(varName, ownRange); @@ -127,7 +127,7 @@ class ScriptingVariabler { } } - Integer currentRange = (Integer) scriptVars.get(varName); + Integer currentRange = scriptVars.get(varName); if (currentRange == null || ownRange.compareTo(currentRange) > 0) { scriptVars.put(varName, ownRange); diff --git a/java/org/apache/jasper/compiler/SmapGenerator.java b/java/org/apache/jasper/compiler/SmapGenerator.java index 67374478c..99a7b48cc 100644 --- a/java/org/apache/jasper/compiler/SmapGenerator.java +++ b/java/org/apache/jasper/compiler/SmapGenerator.java @@ -47,8 +47,8 @@ public class SmapGenerator { private String outputFileName; private String defaultStratum = "Java"; - private List strata = new ArrayList(); - private List embedded = new ArrayList(); + private List strata = new ArrayList(); + private List embedded = new ArrayList(); private boolean doEmbedded = true; //********************************************************************* @@ -129,7 +129,7 @@ public class SmapGenerator { // print our StratumSections, FileSections, and LineSections int nStrata = strata.size(); for (int i = 0; i < nStrata; i++) { - SmapStratum s = (SmapStratum) strata.get(i); + SmapStratum s = strata.get(i); out.append(s.getString()); } diff --git a/java/org/apache/jasper/compiler/SmapStratum.java b/java/org/apache/jasper/compiler/SmapStratum.java index d0c506e1a..aa0fbcb63 100644 --- a/java/org/apache/jasper/compiler/SmapStratum.java +++ b/java/org/apache/jasper/compiler/SmapStratum.java @@ -115,9 +115,9 @@ public class SmapStratum { // Private state private String stratumName; - private List fileNameList; - private List filePathList; - private List lineData; + private List fileNameList; + private List filePathList; + private List lineData; private int lastFileID; //********************************************************************* @@ -131,9 +131,9 @@ public class SmapStratum { */ public SmapStratum(String stratumName) { this.stratumName = stratumName; - fileNameList = new ArrayList(); - filePathList = new ArrayList(); - lineData = new ArrayList(); + fileNameList = new ArrayList(); + filePathList = new ArrayList(); + lineData = new ArrayList(); lastFileID = 0; } @@ -180,8 +180,8 @@ public class SmapStratum { //outputLineIncrement, if possible int i = 0; while (i < lineData.size() - 1) { - LineInfo li = (LineInfo)lineData.get(i); - LineInfo liNext = (LineInfo)lineData.get(i + 1); + LineInfo li = lineData.get(i); + LineInfo liNext = lineData.get(i + 1); if (!liNext.lineFileIDSet && liNext.inputStartLine == li.inputStartLine && liNext.inputLineCount == 1 @@ -203,8 +203,8 @@ public class SmapStratum { //inputLineCount, if possible i = 0; while (i < lineData.size() - 1) { - LineInfo li = (LineInfo)lineData.get(i); - LineInfo liNext = (LineInfo)lineData.get(i + 1); + LineInfo li = lineData.get(i); + LineInfo liNext = lineData.get(i + 1); if (!liNext.lineFileIDSet && liNext.inputStartLine == li.inputStartLine + li.inputLineCount && liNext.outputLineIncrement == li.outputLineIncrement @@ -308,7 +308,7 @@ public class SmapStratum { out.append("+ " + i + " " + fileNameList.get(i) + "\n"); // Source paths must be relative, not absolute, so we // remove the leading "/", if one exists. - String filePath = (String)filePathList.get(i); + String filePath = filePathList.get(i); if (filePath.startsWith("/")) { filePath = filePath.substring(1); } @@ -322,7 +322,7 @@ public class SmapStratum { out.append("*L\n"); bound = lineData.size(); for (int i = 0; i < bound; i++) { - LineInfo li = (LineInfo)lineData.get(i); + LineInfo li = lineData.get(i); out.append(li.getString()); } diff --git a/java/org/apache/jasper/compiler/SmapUtil.java b/java/org/apache/jasper/compiler/SmapUtil.java index c9e08ec08..8c3910c0b 100644 --- a/java/org/apache/jasper/compiler/SmapUtil.java +++ b/java/org/apache/jasper/compiler/SmapUtil.java @@ -74,7 +74,7 @@ public class SmapUtil { pageNodes.visit(psVisitor); } catch (JasperException ex) { } - HashMap map = psVisitor.getMap(); + HashMap map = psVisitor.getMap(); // set up our SMAP generator SmapGenerator g = new SmapGenerator(); @@ -123,11 +123,11 @@ public class SmapUtil { smapInfo[1] = g.getString(); int count = 2; - Iterator iter = map.entrySet().iterator(); + Iterator> iter = map.entrySet().iterator(); while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); - String innerClass = (String) entry.getKey(); - s = (SmapStratum) entry.getValue(); + Map.Entry entry = iter.next(); + String innerClass = entry.getKey(); + s = entry.getValue(); s.optimizeLineSection(); g = new SmapGenerator(); g.setOutputFileName(unqualify(ctxt.getServletJavaFileName())); @@ -385,7 +385,7 @@ public class SmapUtil { } int readU1() { - return ((int)orig[origPos++]) & 0xFF; + return orig[origPos++] & 0xFF; } int readU2() { @@ -495,7 +495,7 @@ public class SmapUtil { public static void evaluateNodes( Node.Nodes nodes, SmapStratum s, - HashMap innerClassMap, + HashMap innerClassMap, boolean breakAtLF) { try { nodes.visit(new SmapGenVisitor(s, breakAtLF, innerClassMap)); @@ -507,9 +507,9 @@ public class SmapUtil { private SmapStratum smap; private boolean breakAtLF; - private HashMap innerClassMap; + private HashMap innerClassMap; - SmapGenVisitor(SmapStratum s, boolean breakAtLF, HashMap map) { + SmapGenVisitor(SmapStratum s, boolean breakAtLF, HashMap map) { this.smap = s; this.breakAtLF = breakAtLF; this.innerClassMap = map; @@ -519,7 +519,7 @@ public class SmapUtil { SmapStratum smapSave = smap; String innerClass = n.getInnerClassName(); if (innerClass != null) { - this.smap = (SmapStratum) innerClassMap.get(innerClass); + this.smap = innerClassMap.get(innerClass); } super.visitBody(n); smap = smapSave; @@ -628,13 +628,13 @@ public class SmapUtil { iOutputLineIncrement); // Output additional mappings in the text - java.util.ArrayList extraSmap = n.getExtraSmap(); + java.util.ArrayList extraSmap = n.getExtraSmap(); if (extraSmap != null) { for (int i = 0; i < extraSmap.size(); i++) { iOutputStartLine += iOutputLineIncrement; smap.addLineData( - iInputStartLine+((Integer)extraSmap.get(i)).intValue(), + iInputStartLine+extraSmap.get(i).intValue(), fileName, 1, iOutputStartLine, @@ -712,7 +712,7 @@ public class SmapUtil { private static class PreScanVisitor extends Node.Visitor { - HashMap map = new HashMap(); + HashMap map = new HashMap(); public void doVisit(Node n) { String inner = n.getInnerClassName(); @@ -721,7 +721,7 @@ public class SmapUtil { } } - HashMap getMap() { + HashMap getMap() { return map; } } diff --git a/java/org/apache/jasper/compiler/TagFileProcessor.java b/java/org/apache/jasper/compiler/TagFileProcessor.java index 565f5276b..bdd3bda74 100644 --- a/java/org/apache/jasper/compiler/TagFileProcessor.java +++ b/java/org/apache/jasper/compiler/TagFileProcessor.java @@ -21,7 +21,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.net.URLClassLoader; import java.util.Iterator; -import java.util.List; import java.util.Vector; import java.util.HashMap; @@ -49,7 +48,7 @@ import org.apache.jasper.runtime.JspSourceDependent; class TagFileProcessor { - private Vector tempVector; + private Vector tempVector; /** * A visitor the tag file @@ -116,9 +115,9 @@ class TagFileProcessor { private String example = null; - private Vector attributeVector; + private Vector attributeVector; - private Vector variableVector; + private Vector variableVector; private static final String ATTR_NAME = "the name attribute of the attribute directive"; @@ -130,9 +129,11 @@ class TagFileProcessor { private static final String TAG_DYNAMIC = "the dynamic-attributes attribute of the tag directive"; - private HashMap nameTable = new HashMap(); + private HashMap nameTable = + new HashMap(); - private HashMap nameFromTable = new HashMap(); + private HashMap nameFromTable = + new HashMap(); public TagFileDirectiveVisitor(Compiler compiler, TagLibraryInfo tagLibInfo, String name, String path) { @@ -140,8 +141,8 @@ class TagFileProcessor { this.tagLibInfo = tagLibInfo; this.name = name; this.path = path; - attributeVector = new Vector(); - variableVector = new Vector(); + attributeVector = new Vector(); + variableVector = new Vector(); } public void visit(Node.TagDirective n) throws JasperException { @@ -351,14 +352,14 @@ class TagFileProcessor { * Returns the vector of attributes corresponding to attribute * directives. */ - public Vector getAttributesVector() { + public Vector getAttributesVector() { return attributeVector; } /* * Returns the vector of variables corresponding to variable directives. */ - public Vector getVariablesVector() { + public Vector getVariablesVector() { return variableVector; } @@ -443,8 +444,8 @@ class TagFileProcessor { private void checkUniqueName(String name, String type, Node n, TagAttributeInfo attr) throws JasperException { - HashMap table = (type == VAR_NAME_FROM) ? nameFromTable : nameTable; - NameEntry nameEntry = (NameEntry) table.get(name); + HashMap table = (type == VAR_NAME_FROM) ? nameFromTable : nameTable; + NameEntry nameEntry = table.get(name); if (nameEntry != null) { if (type != TAG_DYNAMIC || nameEntry.getType() != TAG_DYNAMIC) { int line = nameEntry.getNode().getStart().getLineNumber(); @@ -461,12 +462,11 @@ class TagFileProcessor { */ void postCheck() throws JasperException { // Check that var.name-from-attributes has valid values. - Iterator iter = nameFromTable.keySet().iterator(); + Iterator iter = nameFromTable.keySet().iterator(); while (iter.hasNext()) { - String nameFrom = (String) iter.next(); - NameEntry nameEntry = (NameEntry) nameTable.get(nameFrom); - NameEntry nameFromEntry = (NameEntry) nameFromTable - .get(nameFrom); + String nameFrom = iter.next(); + NameEntry nameEntry = nameTable.get(nameFrom); + NameEntry nameFromEntry = nameFromTable.get(nameFrom); Node nameFromNode = nameFromEntry.getNode(); if (nameEntry == null) { err.jspError(nameFromNode, @@ -529,13 +529,12 @@ class TagFileProcessor { /** * Compiles and loads a tagfile. */ - private Class loadTagFile(Compiler compiler, String tagFilePath, + private Class loadTagFile(Compiler compiler, String tagFilePath, TagInfo tagInfo, PageInfo parentPageInfo) throws JasperException { JspCompilationContext ctxt = compiler.getCompilationContext(); JspRuntimeContext rctxt = ctxt.getRuntimeContext(); - JspServletWrapper wrapper = (JspServletWrapper) rctxt - .getWrapper(tagFilePath); + JspServletWrapper wrapper = rctxt.getWrapper(tagFilePath); synchronized (rctxt) { if (wrapper == null) { @@ -556,7 +555,7 @@ class TagFileProcessor { wrapper.getJspEngineContext().setTagInfo(tagInfo); } - Class tagClazz; + Class tagClazz; int tripCount = wrapper.incTripCount(); try { if (tripCount > 0) { @@ -585,10 +584,10 @@ class TagFileProcessor { try { Object tagIns = tagClazz.newInstance(); if (tagIns instanceof JspSourceDependent) { - Iterator iter = ((List) ((JspSourceDependent) tagIns) - .getDependants()).iterator(); + Iterator iter = ((JspSourceDependent) tagIns) + .getDependants().iterator(); while (iter.hasNext()) { - parentPageInfo.addDependant((String) iter.next()); + parentPageInfo.addDependant(iter.next()); } } } catch (Exception e) { @@ -633,7 +632,7 @@ class TagFileProcessor { } else { pageInfo.addDependant(tagFilePath); } - Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(), + Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(), pageInfo); n.setTagHandlerClass(c); } @@ -650,7 +649,7 @@ class TagFileProcessor { public void loadTagFiles(Compiler compiler, Node.Nodes page) throws JasperException { - tempVector = new Vector(); + tempVector = new Vector(); page.visit(new TagFileLoaderVisitor(compiler)); } @@ -662,9 +661,9 @@ class TagFileProcessor { * If non-null, remove only the class file with with this name. */ public void removeProtoTypeFiles(String classFileName) { - Iterator iter = tempVector.iterator(); + Iterator iter = tempVector.iterator(); while (iter.hasNext()) { - Compiler c = (Compiler) iter.next(); + Compiler c = iter.next(); if (classFileName == null) { c.removeGeneratedClassFiles(); } else if (classFileName.equals(c.getCompilationContext() diff --git a/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java b/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java index a2782e368..3f7351a5e 100644 --- a/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java +++ b/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java @@ -201,8 +201,8 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { } public TagLibraryInfo[] getTagLibraryInfos() { - Collection coll = pi.getTaglibs(); - return (TagLibraryInfo[]) coll.toArray(new TagLibraryInfo[0]); + Collection coll = pi.getTaglibs(); + return coll.toArray(new TagLibraryInfo[0]); } /* @@ -212,9 +212,9 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { */ private void parseTLD(JspCompilationContext ctxt, String uri, InputStream in, URL jarFileUrl) throws JasperException { - Vector tagVector = new Vector(); - Vector tagFileVector = new Vector(); - Hashtable functionTable = new Hashtable(); + Vector tagVector = new Vector(); + Vector tagFileVector = new Vector(); + Hashtable functionTable = new Hashtable(); // Create an iterator over the child elements of our element ParserUtils pu = new ParserUtils(); @@ -226,10 +226,10 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { this.jspversion = tld.findAttribute("version"); // Process each child element of our element - Iterator list = tld.findChildren(); + Iterator list = tld.findChildren(); while (list.hasNext()) { - TreeNode element = (TreeNode) list.next(); + TreeNode element = list.next(); String tname = element.getName(); if ("tlibversion".equals(tname) // JSP 1.1 @@ -293,9 +293,9 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { this.functions = new FunctionInfo[functionTable.size()]; int i = 0; - Enumeration enumeration = functionTable.elements(); + Enumeration enumeration = functionTable.elements(); while (enumeration.hasMoreElements()) { - this.functions[i++] = (FunctionInfo) enumeration.nextElement(); + this.functions[i++] = enumeration.nextElement(); } } @@ -358,11 +358,11 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { String largeIcon = null; boolean dynamicAttributes = false; - Vector attributeVector = new Vector(); - Vector variableVector = new Vector(); - Iterator list = elem.findChildren(); + Vector attributeVector = new Vector(); + Vector variableVector = new Vector(); + Iterator list = elem.findChildren(); while (list.hasNext()) { - TreeNode element = (TreeNode) list.next(); + TreeNode element = list.next(); String tname = element.getName(); if ("name".equals(tname)) { @@ -413,7 +413,8 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { TagExtraInfo tei = null; if (teiClassName != null && !teiClassName.equals("")) { try { - Class teiClass = ctxt.getClassLoader().loadClass(teiClassName); + Class teiClass = + ctxt.getClassLoader().loadClass(teiClassName); tei = (TagExtraInfo) teiClass.newInstance(); } catch (Exception e) { err.jspError("jsp.error.teiclass.instantiation", teiClassName, @@ -451,9 +452,9 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { String name = null; String path = null; - Iterator list = elem.findChildren(); + Iterator list = elem.findChildren(); while (list.hasNext()) { - TreeNode child = (TreeNode) list.next(); + TreeNode child = list.next(); String tname = child.getName(); if ("name".equals(tname)) { name = child.getBody(); @@ -494,9 +495,9 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { String methodSignature = null; boolean required = false, rtexprvalue = false, reqTime = false, isFragment = false, deferredValue = false, deferredMethod = false; - Iterator list = elem.findChildren(); + Iterator list = elem.findChildren(); while (list.hasNext()) { - TreeNode element = (TreeNode) list.next(); + TreeNode element = list.next(); String tname = element.getName(); if ("name".equals(tname)) { @@ -593,9 +594,9 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { boolean declare = true; int scope = VariableInfo.NESTED; - Iterator list = elem.findChildren(); + Iterator list = elem.findChildren(); while (list.hasNext()) { - TreeNode element = (TreeNode) list.next(); + TreeNode element = list.next(); String tname = element.getName(); if ("name-given".equals(tname)) nameGiven = element.getBody(); @@ -635,11 +636,11 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { throws JasperException { String validatorClass = null; - Map initParams = new Hashtable(); + Map initParams = new Hashtable(); - Iterator list = elem.findChildren(); + Iterator list = elem.findChildren(); while (list.hasNext()) { - TreeNode element = (TreeNode) list.next(); + TreeNode element = list.next(); String tname = element.getName(); if ("validator-class".equals(tname)) validatorClass = element.getBody(); @@ -659,7 +660,7 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { TagLibraryValidator tlv = null; if (validatorClass != null && !validatorClass.equals("")) { try { - Class tlvClass = ctxt.getClassLoader() + Class tlvClass = ctxt.getClassLoader() .loadClass(validatorClass); tlv = (TagLibraryValidator) tlvClass.newInstance(); } catch (Exception e) { @@ -676,9 +677,9 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { String[] createInitParam(TreeNode elem) { String[] initParam = new String[2]; - Iterator list = elem.findChildren(); + Iterator list = elem.findChildren(); while (list.hasNext()) { - TreeNode element = (TreeNode) list.next(); + TreeNode element = list.next(); String tname = element.getName(); if ("param-name".equals(tname)) { initParam[0] = element.getBody(); @@ -702,9 +703,9 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { String klass = null; String signature = null; - Iterator list = elem.findChildren(); + Iterator list = elem.findChildren(); while (list.hasNext()) { - TreeNode element = (TreeNode) list.next(); + TreeNode element = list.next(); String tname = element.getName(); if ("name".equals(tname)) { diff --git a/java/org/apache/jasper/compiler/TagPluginManager.java b/java/org/apache/jasper/compiler/TagPluginManager.java index e95d0382c..926f3df97 100644 --- a/java/org/apache/jasper/compiler/TagPluginManager.java +++ b/java/org/apache/jasper/compiler/TagPluginManager.java @@ -38,7 +38,7 @@ public class TagPluginManager { private static final String TAG_PLUGINS_ROOT_ELEM = "tag-plugins"; private boolean initialized = false; - private HashMap tagPlugins = null; + private HashMap tagPlugins = null; private ServletContext ctxt; private PageInfo pageInfo; @@ -85,10 +85,10 @@ public class TagPluginManager { TAG_PLUGINS_ROOT_ELEM); } - tagPlugins = new HashMap(); - Iterator pluginList = root.findChildren("tag-plugin"); + tagPlugins = new HashMap(); + Iterator pluginList = root.findChildren("tag-plugin"); while (pluginList.hasNext()) { - TreeNode pluginNode = (TreeNode) pluginList.next(); + TreeNode pluginNode = pluginList.next(); TreeNode tagClassNode = pluginNode.findChild("tag-class"); if (tagClassNode == null) { // Error @@ -104,7 +104,7 @@ public class TagPluginManager { String pluginClassStr = pluginClassNode.getBody(); TagPlugin tagPlugin = null; try { - Class pluginClass = Class.forName(pluginClassStr); + Class pluginClass = Class.forName(pluginClassStr); tagPlugin = (TagPlugin) pluginClass.newInstance(); } catch (Exception e) { throw new JasperException(e); @@ -124,8 +124,7 @@ public class TagPluginManager { * The given custom tag node will be manipulated by the plugin. */ private void invokePlugin(Node.CustomTag n) { - TagPlugin tagPlugin = (TagPlugin) - tagPlugins.get(n.getTagHandlerClass().getName()); + TagPlugin tagPlugin = tagPlugins.get(n.getTagHandlerClass().getName()); if (tagPlugin == null) { return; } @@ -139,7 +138,7 @@ public class TagPluginManager { private Node.CustomTag node; private Node.Nodes curNodes; private PageInfo pageInfo; - private HashMap pluginAttributes; + private HashMap pluginAttributes; TagPluginContextImpl(Node.CustomTag n, PageInfo pageInfo) { this.node = n; @@ -149,7 +148,7 @@ public class TagPluginManager { curNodes = new Node.Nodes(); n.setAtSTag(curNodes); n.setUseTagPlugin(true); - pluginAttributes = new HashMap(); + pluginAttributes = new HashMap(); } public TagPluginContext getParentContext() { diff --git a/java/org/apache/jasper/compiler/TldLocationsCache.java b/java/org/apache/jasper/compiler/TldLocationsCache.java index 023bb0c5b..b86d23104 100644 --- a/java/org/apache/jasper/compiler/TldLocationsCache.java +++ b/java/org/apache/jasper/compiler/TldLocationsCache.java @@ -101,7 +101,7 @@ public class TldLocationsCache { * [0] The location * [1] If the location is a jar file, this is the location of the tld. */ - private Hashtable mappings; + private Hashtable mappings; private boolean initialized; private ServletContext ctxt; @@ -178,7 +178,7 @@ public class TldLocationsCache { public TldLocationsCache(ServletContext ctxt, boolean redeployMode) { this.ctxt = ctxt; this.redeployMode = redeployMode; - mappings = new Hashtable(); + mappings = new Hashtable(); initialized = false; } @@ -218,7 +218,7 @@ public class TldLocationsCache { if (!initialized) { init(); } - return (String[]) mappings.get(uri); + return mappings.get(uri); } /** @@ -302,11 +302,11 @@ public class TldLocationsCache { if (jspConfig != null) { webtld = jspConfig; } - Iterator taglibs = webtld.findChildren("taglib"); + Iterator taglibs = webtld.findChildren("taglib"); while (taglibs.hasNext()) { // Parse the next element - TreeNode taglib = (TreeNode) taglibs.next(); + TreeNode taglib = taglibs.next(); String tagUri = null; String tagLoc = null; TreeNode child = taglib.findChild("taglib-uri"); @@ -356,9 +356,9 @@ public class TldLocationsCache { conn.setUseCaches(false); } jarFile = conn.getJarFile(); - Enumeration entries = jarFile.entries(); + Enumeration entries = jarFile.entries(); while (entries.hasMoreElements()) { - JarEntry entry = (JarEntry) entries.nextElement(); + JarEntry entry = entries.nextElement(); String name = entry.getName(); if (!name.startsWith("META-INF/")) continue; if (!name.endsWith(".tld")) continue; @@ -416,11 +416,11 @@ public class TldLocationsCache { private void processTldsInFileSystem(String startPath) throws Exception { - Set dirList = ctxt.getResourcePaths(startPath); + Set dirList = ctxt.getResourcePaths(startPath); if (dirList != null) { - Iterator it = dirList.iterator(); + Iterator it = dirList.iterator(); while (it.hasNext()) { - String path = (String) it.next(); + String path = it.next(); if (path.endsWith("/")) { processTldsInFileSystem(path); } diff --git a/java/org/apache/jasper/compiler/Validator.java b/java/org/apache/jasper/compiler/Validator.java index b73ea7ced..c37a89a08 100644 --- a/java/org/apache/jasper/compiler/Validator.java +++ b/java/org/apache/jasper/compiler/Validator.java @@ -1736,8 +1736,8 @@ class Validator { StringBuffer errMsg = null; ErrorDispatcher errDisp = compiler.getErrorDispatcher(); - for (Iterator iter = compiler.getPageInfo().getTaglibs().iterator(); iter - .hasNext();) { + for (Iterator iter = + compiler.getPageInfo().getTaglibs().iterator(); iter.hasNext();) { Object o = iter.next(); if (!(o instanceof TagLibraryInfoImpl)) diff --git a/java/org/apache/jasper/runtime/JspSourceDependent.java b/java/org/apache/jasper/runtime/JspSourceDependent.java index 2ba9364a6..7217a3f2b 100644 --- a/java/org/apache/jasper/runtime/JspSourceDependent.java +++ b/java/org/apache/jasper/runtime/JspSourceDependent.java @@ -17,6 +17,8 @@ package org.apache.jasper.runtime; +import java.util.List; + /** * Interface for tracking the source files dependencies, for the purpose * of compiling out of date pages. This is used for @@ -32,8 +34,6 @@ public interface JspSourceDependent { * Returns a list of files names that the current page has a source * dependency on. */ - // FIXME: Type used is Object due to very weird behavior - // with Eclipse JDT 3.1 in Java 5 mode - public Object getDependants(); + public List getDependants(); } diff --git a/java/org/apache/jasper/servlet/JspServletWrapper.java b/java/org/apache/jasper/servlet/JspServletWrapper.java index 2582d63d9..0feef71cc 100644 --- a/java/org/apache/jasper/servlet/JspServletWrapper.java +++ b/java/org/apache/jasper/servlet/JspServletWrapper.java @@ -245,7 +245,7 @@ public class JspServletWrapper { /** * Get a list of files that the current page has source dependency on. */ - public java.util.List getDependants() { + public java.util.List getDependants() { try { Object target; if (isTagFile) { diff --git a/java/org/apache/jasper/xmlparser/TreeNode.java b/java/org/apache/jasper/xmlparser/TreeNode.java index 4ccf97b41..a765c44f2 100644 --- a/java/org/apache/jasper/xmlparser/TreeNode.java +++ b/java/org/apache/jasper/xmlparser/TreeNode.java @@ -91,7 +91,7 @@ public class TreeNode { /** * The children of this node, instantiated only if required. */ - protected ArrayList children = null; + protected ArrayList children = null; /** @@ -133,7 +133,7 @@ public class TreeNode { public void addChild(TreeNode node) { if (children == null) - children = new ArrayList(); + children = new ArrayList(); children.add(node); } @@ -194,7 +194,7 @@ public class TreeNode { * Return an Iterator of all children of this node. If there are no * children, an empty Iterator is returned. */ - public Iterator findChildren() { + public Iterator findChildren() { if (children == null) return (Collections.EMPTY_LIST.iterator()); @@ -211,15 +211,15 @@ public class TreeNode { * * @param name Name used to select children */ - public Iterator findChildren(String name) { + public Iterator findChildren(String name) { if (children == null) return (Collections.EMPTY_LIST.iterator()); - ArrayList results = new ArrayList(); - Iterator items = children.iterator(); + ArrayList results = new ArrayList(); + Iterator items = children.iterator(); while (items.hasNext()) { - TreeNode item = (TreeNode) items.next(); + TreeNode item = items.next(); if (name.equals(item.getName())) results.add(item); } -- 2.11.0