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;
return false;
}
- public Map getCache() {
+ public Map<String, TagLibraryInfo> getCache() {
return null;
}
// Ignore
}
- Enumeration enumeration=config.getInitParameterNames();
+ Enumeration<String> enumeration=config.getInitParameterNames();
while( enumeration.hasMoreElements() ) {
- String k=(String)enumeration.nextElement();
+ String k=enumeration.nextElement();
String v=config.getInitParameter( k );
setProperty( k, v);
}
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;
protected boolean smapSuppressed = true;
protected boolean smapDumped = false;
protected boolean caching = true;
- protected Map cache = new HashMap();
+ protected Map<String, TagLibraryInfo> cache =
+ new HashMap<String, TagLibraryInfo>();
protected String compiler = null;
* The file extensions to be handled as JSP files.
* Default list is .jsp and .jspx.
*/
- protected List extensions;
+ protected List<String> extensions;
/**
* The pages.
*/
- protected List pages = new Vector();
+ protected List<String> pages = new Vector<String>();
/**
* Needs better documentation, this data member does.
/**
* @see Options#getCache()
*/
- public Map getCache() {
+ public Map<String, TagLibraryInfo> getCache() {
return cache;
}
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;
}
*
* @return The list of extensions
*/
- public List getExtensions() {
+ public List<String> getExtensions() {
return extensions;
}
protected void addExtension(final String extension) {
if(extension != null) {
if(extensions == null) {
- extensions = new Vector();
+ extensions = new Vector<String>();
}
extensions.add(extension);
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(
initWebXml();
- Iterator iter = pages.iterator();
+ Iterator<String> iter = pages.iterator();
while (iter.hasNext()) {
String nextjsp = iter.next().toString();
File fjsp = new File(nextjsp);
protected URLClassLoader jspLoader;
protected URL baseUrl;
- protected Class servletClass;
+ protected Class<?> servletClass;
protected boolean isTagFile;
protected boolean protoTypeMode;
}
- public Set getResourcePaths(String path) {
+ public Set<String> getResourcePaths(String path) {
return context.getResourcePaths(canonicalURI(path));
}
// ==================== Manipulating the class ====================
- public Class load()
+ public Class<?> load()
throws JasperException, FileNotFoundException
{
try {
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;
*
* @return the Map(String uri, TreeNode tld) instance.
*/
- public Map getCache();
+ public Map<String, TagLibraryInfo> getCache();
}
/**
* Thread <-> PrintStream associations.
*/
- protected static ThreadLocal streams = new ThreadLocal();
+ protected static ThreadLocal<PrintStream> streams =
+ new ThreadLocal<PrintStream>();
/**
* Thread <-> ByteArrayOutputStream associations.
*/
- protected static ThreadLocal data = new ThreadLocal();
+ protected static ThreadLocal<ByteArrayOutputStream> data =
+ new ThreadLocal<ByteArrayOutputStream>();
// --------------------------------------------------------- Public Methods
* 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;
}
* 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;
}
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) {
return false;
}
- List depends = jsw.getDependants();
+ List<String> depends = jsw.getDependants();
if (depends == null) {
return false;
}
- Iterator it = depends.iterator();
+ Iterator<String> it = depends.iterator();
while (it.hasNext()) {
- String include = (String) it.next();
+ String include = it.next();
try {
URL includeUrl = ctxt.getResource(include);
if (includeUrl == null) {
// First locate all unique functions in this EL
Fvisitor fv = new Fvisitor();
el.visit(fv);
- ArrayList functions = fv.funcs;
+ ArrayList<ELNode.Function> functions = fv.funcs;
if (functions.size() == 0) {
return;
// 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 + "\", " +
* @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<ELNode.Function> 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;
}
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;
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");
private ServletWriter out;
- private ArrayList methodsBuffered;
+ private ArrayList<GenBuffer> methodsBuffered;
private FragmentHelperClass fragmentHelperClass;
class TagHandlerPoolVisitor extends Node.Visitor {
- private Vector names;
+ private Vector<String> names;
/*
* Constructor
*
* @param v Vector of tag handler pool names to populate
*/
- TagHandlerPoolVisitor(Vector v) {
+ TagHandlerPoolVisitor(Vector<String> v) {
names = v;
}
class ScriptingVarVisitor extends Node.Visitor {
- private Vector vars;
+ private Vector<String> vars;
ScriptingVarVisitor() {
- vars = new Vector();
+ vars = new Vector<String>();
}
public void visit(Node.CustomTag n) throws JasperException {
if (isPoolingEnabled) {
for (int i = 0; i < tagHandlerPoolNames.size(); i++) {
- out.printin((String) tagHandlerPoolNames.elementAt(i));
+ out.printin(tagHandlerPoolNames.elementAt(i));
out.println(".release();");
}
}
* generation)
*/
private void genPreambleImports() throws JasperException {
- Iterator iter = pageInfo.getImports().iterator();
+ Iterator<String> iter = pageInfo.getImports().iterator();
while (iter.hasNext()) {
out.printin("import ");
- out.print((String) iter.next());
+ out.print(iter.next());
out.println(";");
}
// Static data for getDependants()
out.printil("private static java.util.List _jspx_dependants;");
out.println();
- List dependants = pageInfo.getDependants();
- Iterator iter = dependants.iterator();
+ List<String> dependants = pageInfo.getDependants();
+ Iterator<String> iter = dependants.iterator();
if (!dependants.isEmpty()) {
out.printil("static {");
out.pushIndent();
out.println(");");
while (iter.hasNext()) {
out.printin("_jspx_dependants.add(\"");
- out.print((String) iter.next());
+ out.print(iter.next());
out.println("\");");
}
out.popIndent();
* handlers: <key>: tag short name <value>: introspection info of tag
* handler for <prefix:shortName> tag
*/
- private Hashtable handlerInfos;
+ private Hashtable<String,Hashtable<String,TagHandlerInfo>> handlerInfos;
- private Hashtable tagVarNumbers;
+ private Hashtable<String,Integer> tagVarNumbers;
private String parent;
private ServletWriter out;
- private ArrayList methodsBuffered;
+ private ArrayList<GenBuffer> methodsBuffered;
private FragmentHelperClass fragmentHelperClass;
private int charArrayCount;
- private HashMap textMap;
+ private HashMap<String,String> textMap;
/**
* Constructor.
*/
public GenerateVisitor(boolean isTagFile, ServletWriter out,
- ArrayList methodsBuffered,
+ ArrayList<GenBuffer> methodsBuffered,
FragmentHelperClass fragmentHelperClass, ClassLoader loader,
TagInfo tagInfo) {
this.loader = loader;
this.tagInfo = tagInfo;
methodNesting = 0;
- handlerInfos = new Hashtable();
- tagVarNumbers = new Hashtable();
- textMap = new HashMap();
+ handlerInfos =
+ new Hashtable<String,Hashtable<String,TagHandlerInfo>>();
+ tagVarNumbers = new Hashtable<String,Integer>();
+ textMap = new HashMap<String,String>();
}
/**
* 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 "";
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);
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);
// Compute attribute value string for XML-style and named
// attributes
- Hashtable map = new Hashtable();
+ Hashtable<String,String> map = new Hashtable<String,String>();
Node.JspAttribute[] attrs = n.getJspAttributes();
for (int i = 0; attrs != null && i < attrs.length; i++) {
String attrStr = null;
out.print(" + " + elemName);
// Write remaining attributes
- Enumeration enumeration = map.keys();
+ Enumeration<String> 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 <jsp:element> have nested tags other than
charArrayBuffer = new GenBuffer();
caOut = charArrayBuffer.getOut();
caOut.pushIndent();
- textMap = new HashMap();
+ textMap = new HashMap<String,String>();
} 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);
private TagHandlerInfo getTagHandlerInfo(Node.CustomTag n)
throws JasperException {
- Hashtable handlerInfosByShortName = (Hashtable) handlerInfos.get(n
- .getPrefix());
+ Hashtable<String,TagHandlerInfo> handlerInfosByShortName =
+ handlerInfos.get(n.getPrefix());
if (handlerInfosByShortName == null) {
- handlerInfosByShortName = new Hashtable();
+ handlerInfosByShortName =
+ new Hashtable<String,TagHandlerInfo>();
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);
String tagEvalVar, String tagPushBodyCountVar)
throws JasperException {
- Class tagHandlerClass = handlerInfo.getTagHandlerClass();
+ Class<?> tagHandlerClass =
+ handlerInfo.getTagHandlerClass();
out.printin("// ");
out.println(n.getQName());
TagHandlerInfo handlerInfo, String tagHandlerVar)
throws JasperException {
- Class tagHandlerClass = handlerInfo.getTagHandlerClass();
+ Class<?> tagHandlerClass =
+ handlerInfo.getTagHandlerClass();
n.setBeginJavaLine(out.getJavaLine());
out.printin("// ");
private void declareScriptingVars(Node.CustomTag n, int scope) {
- Vector vec = n.getScriptingVars(scope);
+ Vector<Object> vec = n.getScriptingVars(scope);
if (vec != null) {
for (int i = 0; i < vec.size(); i++) {
Object elem = vec.elementAt(i);
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 {
String localName = attr.getLocalName();
Method m = null;
- Class[] c = null;
+ Class<?>[] c = null;
if (attr.isDynamic()) {
c = OBJECT_CLASS;
} else {
* 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;
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());
}
*/
Generator(ServletWriter out, Compiler compiler) {
this.out = out;
- methodsBuffered = new ArrayList();
+ methodsBuffered = new ArrayList<GenBuffer>();
charArrayBuffer = null;
err = compiler.getErrorDispatcher();
ctxt = compiler.getCompilationContext();
beanInfo = pageInfo.getBeanRepository();
breakAtLF = ctxt.getOptions().getMappedFile();
if (isPoolingEnabled) {
- tagHandlerPoolNames = new Vector();
+ tagHandlerPoolNames = new Vector<String>();
}
}
*/
private static class TagHandlerInfo {
- private Hashtable methodMaps;
+ private Hashtable<String, Method> methodMaps;
- private Hashtable propertyEditorMaps;
+ private Hashtable<String, Class<?>> propertyEditorMaps;
- private Class tagHandlerClass;
+ private Class<?> tagHandlerClass;
/**
* Constructor.
* @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<String, Method>();
+ this.propertyEditorMaps = new Hashtable<String, Class<?>>();
try {
BeanInfo tagClassInfo = Introspector
* 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;
}
}
// True if the helper class should be generated.
private boolean used = false;
- private ArrayList fragments = new ArrayList();
+ private ArrayList<Fragment> fragments = new ArrayList<Fragment>();
private String className;
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());
}
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);
}
}
private static final String IMPLICIT_TLD = "implicit.tld";
// Maps tag names to tag file paths
- private Hashtable tagFileMap;
+ private Hashtable<String,String> tagFileMap;
private ParserController pc;
private PageInfo pi;
- private Vector vec;
+ private Vector<TagFileInfo> vec;
/**
* Constructor.
super(prefix, null);
this.pc = pc;
this.pi = pi;
- this.tagFileMap = new Hashtable();
- this.vec = new Vector();
+ this.tagFileMap = new Hashtable<String,String>();
+ this.vec = new Vector<TagFileInfo>();
// Implicit tag libraries have no functions:
this.functions = new FunctionInfo[0];
}
// Populate mapping of tag names to tag file paths
- Set dirList = ctxt.getResourcePaths(tagdir);
+ Set<String> dirList = ctxt.getResourcePaths(tagdir);
if (dirList != null) {
- Iterator it = dirList.iterator();
+ Iterator<String> 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)) {
/*
}
// Process each child element of our <taglib> element
- Iterator list = tld.findChildren();
+ Iterator<TreeNode> 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
TagFileInfo tagFile = super.getTagFile(shortName);
if (tagFile == null) {
- String path = (String) tagFileMap.get(shortName);
+ String path = tagFileMap.get(shortName);
if (path == null) {
return null;
}
}
public TagLibraryInfo[] getTagLibraryInfos() {
- Collection coll = pi.getTaglibs();
- return (TagLibraryInfo[]) coll.toArray(new TagLibraryInfo[0]);
+ Collection<TagLibraryInfo> coll = pi.getTaglibs();
+ return coll.toArray(new TagLibraryInfo[0]);
}
}
final ClassLoader classLoader = ctxt.getJspLoader();
String[] fileNames = new String[] {sourceFile};
String[] classNames = new String[] {targetClassName};
- final ArrayList problemList = new ArrayList();
+ final ArrayList<JavacErrorDetail> problemList =
+ new ArrayList<JavacErrorDetail>();
class CompilationUnit implements ICompilationUnit {
final IErrorHandlingPolicy policy =
DefaultErrorHandlingPolicies.proceedWithAllProblems();
- final Map settings = new HashMap();
+ final Map<String,String> settings = new HashMap<String,String>();
settings.put(CompilerOptions.OPTION_LineNumberAttribute,
CompilerOptions.GENERATE);
settings.put(CompilerOptions.OPTION_SourceFileAttribute,
if (!problemList.isEmpty()) {
JavacErrorDetail[] jeds =
- (JavacErrorDetail[]) problemList.toArray(new JavacErrorDetail[0]);
+ problemList.toArray(new JavacErrorDetail[0]);
errDispatcher.javacError(jeds);
}
*/
private String[] readFile(InputStream s) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(s));
- List lines = new ArrayList();
+ List<String> lines = new ArrayList<String>();
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()] );
}
}
// Logger
private Log log = LogFactory.getLog(JspConfig.class);
- private Vector jspProperties = null;
+ private Vector<JspPropertyGroup> jspProperties = null;
private ServletContext ctxt;
private boolean initialized = false;
return;
}
- jspProperties = new Vector();
- Iterator jspPropertyList = jspConfig.findChildren("jsp-property-group");
+ jspProperties = new Vector<JspPropertyGroup>();
+ Iterator<TreeNode> jspPropertyList =
+ jspConfig.findChildren("jsp-property-group");
while (jspPropertyList.hasNext()) {
- TreeNode element = (TreeNode) jspPropertyList.next();
- Iterator list = element.findChildren();
+ TreeNode element = jspPropertyList.next();
+ Iterator<TreeNode> list = element.findChildren();
- Vector urlPatterns = new Vector();
+ Vector<String> urlPatterns = new Vector<String>();
String pageEncoding = null;
String scriptingInvalid = null;
String elIgnored = null;
String isXml = null;
- Vector includePrelude = new Vector();
- Vector includeCoda = new Vector();
+ Vector<String> includePrelude = new Vector<String>();
+ Vector<String> includeCoda = new Vector<String>();
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))
// 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;
uriExtension = uri.substring(index+1);
}
- Vector includePreludes = new Vector();
- Vector includeCodas = new Vector();
+ Vector<String> includePreludes = new Vector<String>();
+ Vector<String> includeCodas = new Vector<String>();
JspPropertyGroup isXmlMatch = null;
JspPropertyGroup elIgnoredMatch = null;
JspPropertyGroup deferedSyntaxAllowedAsLiteralMatch = null;
JspPropertyGroup trimDirectiveWhitespacesMatch = null;
- Iterator iter = jspProperties.iterator();
+ Iterator<JspPropertyGroup> 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)
uriExtension = uri.substring(index+1);
}
- Iterator iter = jspProperties.iterator();
+ Iterator<JspPropertyGroup> iter = jspProperties.iterator();
while (iter.hasNext()) {
- JspPropertyGroup jpg = (JspPropertyGroup) iter.next();
+ JspPropertyGroup jpg = iter.next();
JspProperty jp = jpg.getJspProperty();
String extension = jpg.getExtension();
private String elIgnored;
private String scriptingInvalid;
private String pageEncoding;
- private Vector includePrelude;
- private Vector includeCoda;
+ private Vector<String> includePrelude;
+ private Vector<String> includeCoda;
private String deferedSyntaxAllowedAsLiteral;
private String trimDirectiveWhitespaces;
public JspProperty(String isXml, String elIgnored,
String scriptingInvalid, String pageEncoding,
- Vector includePrelude, Vector includeCoda,
+ Vector<String> includePrelude, Vector<String> includeCoda,
String deferedSyntaxAllowedAsLiteral,
String trimDirectiveWhitespaces) {
return pageEncoding;
}
- public Vector getIncludePrelude() {
+ public Vector<String> getIncludePrelude() {
return includePrelude;
}
- public Vector getIncludeCoda() {
+ public Vector<String> getIncludeCoda() {
return includeCoda;
}
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;
* 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<String> files) throws SAXException {
if (files != null) {
- Iterator iter = files.iterator();
+ Iterator<String> 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);
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 {
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) {
/*
/**
* The list of source files.
*/
- private List sourceFiles;
+ private List<String> sourceFiles;
/**
* The current file ID (-1 indicates an error or no file).
this.context = ctxt;
this.err = err;
- sourceFiles = new Vector();
+ sourceFiles = new Vector<String>();
currFileId = 0;
size = 0;
singleFile = false;
* @return The file at that position, if found, null otherwise
*/
String getFile(final int fileid) {
- return (String) sourceFiles.get(fileid);
+ return sourceFiles.get(fileid);
}
/**
* Process a "destory" event for this web application context.
*/
public void destroy() {
- Iterator servlets = jsps.values().iterator();
+ Iterator<JspServletWrapper> servlets = jsps.values().iterator();
while (servlets.hasNext()) {
- ((JspServletWrapper) servlets.next()).destroy();
+ servlets.next().destroy();
}
}
// 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);
}
}
* stack of stream and stream state of streams that have included
* current stream
*/
- private Stack includeStack = null;
+ private Stack<IncludeState> includeStack = null;
// encoding of current file
private String encoding = null;
this.fileName = name;
this.baseDir = inBaseDir;
this.encoding = inEncoding;
- this.includeStack = new Stack();
+ this.includeStack = new Stack<IncludeState>();
}
this.encoding = other.encoding;
// clone includeStack without cloning contents
- includeStack = new Stack();
+ includeStack = new Stack<IncludeState>();
for ( int i=0; i < other.includeStack.size(); i++ ) {
includeStack.addElement( other.includeStack.elementAt(i) );
}
}
// get previous state in stack
- IncludeState state = (IncludeState) includeStack.pop( );
+ IncludeState state = includeStack.pop( );
// set new variables
cursor = state.cursor;
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;
*/
public static class PageDirective extends Node {
- private Vector imports;
+ private Vector<String> imports;
public PageDirective(Attributes attrs, Mark start, Node parent) {
this(JSP_PAGE_DIRECTIVE_ACTION, attrs, null, null, start, parent);
Mark start, Node parent) {
super(qName, PAGE_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs,
taglibAttrs, start, parent);
- imports = new Vector();
+ imports = new Vector<String>();
}
public void accept(Visitor v) throws JasperException {
}
}
- public List getImports() {
+ public List<String> getImports() {
return imports;
}
}
* Represents a tag directive
*/
public static class TagDirective extends Node {
- private Vector imports;
+ private Vector<String> imports;
public TagDirective(Attributes attrs, Mark start, Node parent) {
this(JSP_TAG_DIRECTIVE_ACTION, attrs, null, null, start, parent);
Mark start, Node parent) {
super(qName, TAG_DIRECTIVE_ACTION, attrs, nonTaglibXmlnsAttrs,
taglibAttrs, start, parent);
- imports = new Vector();
+ imports = new Vector<String>();
}
public void accept(Visitor v) throws JasperException {
}
}
- public List getImports() {
+ public List<String> getImports() {
return imports;
}
}
private TagFileInfo tagFileInfo;
- private Class tagHandlerClass;
+ private Class<?> tagHandlerClass;
private VariableInfo[] varInfos;
private boolean implementsDynamicAttributes;
- private Vector atBeginScriptingVars;
+ private Vector<Object> atBeginScriptingVars;
- private Vector atEndScriptingVars;
+ private Vector<Object> atEndScriptingVars;
- private Vector nestedScriptingVars;
+ private Vector<Object> nestedScriptingVars;
private Node.CustomTag customTagParent;
*/
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);
}
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);
return tagFileInfo != null;
}
- public Class getTagHandlerClass() {
+ public Class<?> getTagHandlerClass() {
return tagHandlerClass;
}
- public void setTagHandlerClass(Class hc) {
+ public void setTagHandlerClass(Class<?> hc) {
tagHandlerClass = hc;
}
return this.numCount;
}
- public void setScriptingVars(Vector vec, int scope) {
+ public void setScriptingVars(Vector<Object> vec, int scope) {
switch (scope) {
case VariableInfo.AT_BEGIN:
this.atBeginScriptingVars = vec;
* Gets the scripting variables for the given scope that need to be
* declared.
*/
- public Vector getScriptingVars(int scope) {
- Vector vec = null;
+ public Vector<Object> getScriptingVars(int scope) {
+ Vector<Object> vec = null;
switch (scope) {
case VariableInfo.AT_BEGIN:
*/
public static class TemplateText extends Node {
- private ArrayList extraSmap = null;
+ private ArrayList<Integer> extraSmap = null;
public TemplateText(String text, Mark start, Node parent) {
super(null, null, text, start, parent);
*/
public void addSmap(int srcLine) {
if (extraSmap == null) {
- extraSmap = new ArrayList();
+ extraSmap = new ArrayList<Integer>();
}
extraSmap.add(new Integer(srcLine));
}
- public ArrayList getExtraSmap() {
+ public ArrayList<Integer> getExtraSmap() {
return extraSmap;
}
}
*/
public static class Nodes {
- private List list;
+ private List<Node> list;
private Node.Root root; // null if this is not a page
private boolean generatedInBuffer;
public Nodes() {
- list = new Vector();
+ list = new Vector<Node>();
}
public Nodes(Node.Root root) {
this.root = root;
- list = new Vector();
+ list = new Vector<Node>();
list.add(root);
}
* The visitor used
*/
public void visit(Visitor v) throws JasperException {
- Iterator iter = list.iterator();
+ Iterator<Node> iter = list.iterator();
while (iter.hasNext()) {
- Node n = (Node) iter.next();
+ Node n = iter.next();
n.accept(v);
}
}
public Node getNode(int index) {
Node n = null;
try {
- n = (Node) list.get(index);
+ n = list.get(index);
} catch (ArrayIndexOutOfBoundsException e) {
}
return n;
if (n.getImports().size() > 0) {
// Concatenate names of imported classes/packages
boolean first = true;
- ListIterator iter = n.getImports().listIterator();
+ ListIterator<String> iter = n.getImports().listIterator();
while (iter.hasNext()) {
if (first) {
first = false;
} else {
buf.append(",");
}
- buf.append(JspUtil.getExprInXml((String) iter.next()));
+ buf.append(JspUtil.getExprInXml(iter.next()));
}
buf.append("\"\n");
}
class PageInfo {
- private Vector imports;
- private Vector dependants;
+ private Vector<String> imports;
+ private Vector<String> dependants;
private BeanRepository beanRepository;
- private HashMap taglibsMap;
- private HashMap jspPrefixMapper;
- private HashMap xmlPrefixMapper;
- private HashMap nonCustomTagPrefixMap;
+ private HashMap<String,TagLibraryInfo> taglibsMap;
+ private HashMap<String, String> jspPrefixMapper;
+ private HashMap<String, LinkedList<String>> xmlPrefixMapper;
+ private HashMap<String, Mark> nonCustomTagPrefixMap;
private String jspFile;
private String defaultLanguage = "java";
private String language;
private boolean isJspPrefixHijacked;
// Set of all element and attribute prefixes used in this translation unit
- private HashSet prefixes;
+ private HashSet<String> prefixes;
private boolean hasJspRoot = false;
- private Vector includePrelude;
- private Vector includeCoda;
- private Vector pluginDcls; // Id's for tagplugin declarations
+ private Vector<String> includePrelude;
+ private Vector<String> includeCoda;
+ private Vector<String> 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<String, TagLibraryInfo>();
+ this.jspPrefixMapper = new HashMap<String, String>();
+ this.xmlPrefixMapper = new HashMap<String, LinkedList<String>>();
+ this.nonCustomTagPrefixMap = new HashMap<String, Mark>();
+ this.imports = new Vector<String>();
+ this.dependants = new Vector<String>();
+ this.includePrelude = new Vector<String>();
+ this.includeCoda = new Vector<String>();
+ this.pluginDcls = new Vector<String>();
+ this.prefixes = new HashSet<String>();
// Enter standard imports
for(int i = 0; i < Constants.STANDARD_IMPORTS.length; i++)
return false;
}
- public void addImports(List imports) {
+ public void addImports(List<String> imports) {
this.imports.addAll(imports);
}
this.imports.add(imp);
}
- public List getImports() {
+ public List<String> getImports() {
return imports;
}
dependants.add(d);
}
- public List getDependants() {
+ public List<String> getDependants() {
return dependants;
}
return scriptingInvalid;
}
- public List getIncludePrelude() {
+ public List<String> getIncludePrelude() {
return includePrelude;
}
- public void setIncludePrelude(Vector prelude) {
+ public void setIncludePrelude(Vector<String> prelude) {
includePrelude = prelude;
}
- public List getIncludeCoda() {
+ public List<String> getIncludeCoda() {
return includeCoda;
}
- public void setIncludeCoda(Vector coda) {
+ public void setIncludeCoda(Vector<String> coda) {
includeCoda = coda;
}
* @return Tag library corresponding to the given URI
*/
public TagLibraryInfo getTaglib(String uri) {
- return (TagLibraryInfo) taglibsMap.get(uri);
+ return taglibsMap.get(uri);
}
/*
*
* @return Collection of tag libraries that are associated with a URI
*/
- public Collection getTaglibs() {
+ public Collection<TagLibraryInfo> getTaglibs() {
return taglibsMap.values();
}
* @param uri The URI to be pushed onto the stack
*/
public void pushPrefixMapping(String prefix, String uri) {
- LinkedList stack = (LinkedList) xmlPrefixMapper.get(prefix);
+ LinkedList<String> stack = xmlPrefixMapper.get(prefix);
if (stack == null) {
- stack = new LinkedList();
+ stack = new LinkedList<String>();
xmlPrefixMapper.put(prefix, stack);
}
stack.addFirst(uri);
* @param prefix The prefix whose stack of URIs is to be popped
*/
public void popPrefixMapping(String prefix) {
- LinkedList stack = (LinkedList) xmlPrefixMapper.get(prefix);
+ LinkedList<String> stack = xmlPrefixMapper.get(prefix);
if (stack == null || stack.size() == 0) {
// XXX throw new Exception("XXX");
}
String uri = null;
- LinkedList stack = (LinkedList) xmlPrefixMapper.get(prefix);
+ LinkedList<String> 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;
}
public Mark getNonCustomTagPrefix(String prefix) {
- return (Mark) nonCustomTagPrefixMap.get(prefix);
+ return nonCustomTagPrefixMap.get(prefix);
}
public String getDeferredSyntaxAllowedAsLiteral() {
* 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<String> files) throws JasperException {
if (files != null) {
- Iterator iter = files.iterator();
+ Iterator<String> 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);
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
* 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<String> baseDirStack = new Stack<String>();
private boolean isEncodingSpecifiedInProlog;
private boolean isBomPresent;
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);
static class ScriptingVariableVisitor extends Node.Visitor {
private ErrorDispatcher err;
- private Hashtable scriptVars;
+ private Hashtable<String,Integer> scriptVars;
public ScriptingVariableVisitor(ErrorDispatcher err) {
this.err = err;
- scriptVars = new Hashtable();
+ scriptVars = new Hashtable<String,Integer>();
}
public void visit(Node.CustomTag n) throws JasperException {
return;
}
- Vector vec = new Vector();
+ Vector<Object> vec = new Vector<Object>();
Integer ownRange = null;
if (scope == VariableInfo.AT_BEGIN
}
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);
}
}
- Integer currentRange = (Integer) scriptVars.get(varName);
+ Integer currentRange = scriptVars.get(varName);
if (currentRange == null
|| ownRange.compareTo(currentRange) > 0) {
scriptVars.put(varName, ownRange);
private String outputFileName;
private String defaultStratum = "Java";
- private List strata = new ArrayList();
- private List embedded = new ArrayList();
+ private List<SmapStratum> strata = new ArrayList<SmapStratum>();
+ private List<String> embedded = new ArrayList<String>();
private boolean doEmbedded = true;
//*********************************************************************
// 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());
}
// Private state
private String stratumName;
- private List fileNameList;
- private List filePathList;
- private List lineData;
+ private List<String> fileNameList;
+ private List<String> filePathList;
+ private List<LineInfo> lineData;
private int lastFileID;
//*********************************************************************
*/
public SmapStratum(String stratumName) {
this.stratumName = stratumName;
- fileNameList = new ArrayList();
- filePathList = new ArrayList();
- lineData = new ArrayList();
+ fileNameList = new ArrayList<String>();
+ filePathList = new ArrayList<String>();
+ lineData = new ArrayList<LineInfo>();
lastFileID = 0;
}
//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
//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
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);
}
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());
}
pageNodes.visit(psVisitor);
} catch (JasperException ex) {
}
- HashMap map = psVisitor.getMap();
+ HashMap<String, SmapStratum> map = psVisitor.getMap();
// set up our SMAP generator
SmapGenerator g = new SmapGenerator();
smapInfo[1] = g.getString();
int count = 2;
- Iterator iter = map.entrySet().iterator();
+ Iterator<Map.Entry<String,SmapStratum>> 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<String,SmapStratum> entry = iter.next();
+ String innerClass = entry.getKey();
+ s = entry.getValue();
s.optimizeLineSection();
g = new SmapGenerator();
g.setOutputFileName(unqualify(ctxt.getServletJavaFileName()));
}
int readU1() {
- return ((int)orig[origPos++]) & 0xFF;
+ return orig[origPos++] & 0xFF;
}
int readU2() {
public static void evaluateNodes(
Node.Nodes nodes,
SmapStratum s,
- HashMap innerClassMap,
+ HashMap<String, SmapStratum> innerClassMap,
boolean breakAtLF) {
try {
nodes.visit(new SmapGenVisitor(s, breakAtLF, innerClassMap));
private SmapStratum smap;
private boolean breakAtLF;
- private HashMap innerClassMap;
+ private HashMap<String, SmapStratum> innerClassMap;
- SmapGenVisitor(SmapStratum s, boolean breakAtLF, HashMap map) {
+ SmapGenVisitor(SmapStratum s, boolean breakAtLF, HashMap<String, SmapStratum> map) {
this.smap = s;
this.breakAtLF = breakAtLF;
this.innerClassMap = map;
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;
iOutputLineIncrement);
// Output additional mappings in the text
- java.util.ArrayList extraSmap = n.getExtraSmap();
+ java.util.ArrayList<Integer> 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,
private static class PreScanVisitor extends Node.Visitor {
- HashMap map = new HashMap();
+ HashMap<String, SmapStratum> map = new HashMap<String, SmapStratum>();
public void doVisit(Node n) {
String inner = n.getInnerClassName();
}
}
- HashMap getMap() {
+ HashMap<String, SmapStratum> getMap() {
return map;
}
}
import java.io.IOException;
import java.net.URLClassLoader;
import java.util.Iterator;
-import java.util.List;
import java.util.Vector;
import java.util.HashMap;
class TagFileProcessor {
- private Vector tempVector;
+ private Vector<Compiler> tempVector;
/**
* A visitor the tag file
private String example = null;
- private Vector attributeVector;
+ private Vector<TagAttributeInfo> attributeVector;
- private Vector variableVector;
+ private Vector<TagVariableInfo> variableVector;
private static final String ATTR_NAME = "the name attribute of the attribute directive";
private static final String TAG_DYNAMIC = "the dynamic-attributes attribute of the tag directive";
- private HashMap nameTable = new HashMap();
+ private HashMap<String,NameEntry> nameTable =
+ new HashMap<String,NameEntry>();
- private HashMap nameFromTable = new HashMap();
+ private HashMap<String,NameEntry> nameFromTable =
+ new HashMap<String,NameEntry>();
public TagFileDirectiveVisitor(Compiler compiler,
TagLibraryInfo tagLibInfo, String name, String path) {
this.tagLibInfo = tagLibInfo;
this.name = name;
this.path = path;
- attributeVector = new Vector();
- variableVector = new Vector();
+ attributeVector = new Vector<TagAttributeInfo>();
+ variableVector = new Vector<TagVariableInfo>();
}
public void visit(Node.TagDirective n) throws JasperException {
* Returns the vector of attributes corresponding to attribute
* directives.
*/
- public Vector getAttributesVector() {
+ public Vector<TagAttributeInfo> getAttributesVector() {
return attributeVector;
}
/*
* Returns the vector of variables corresponding to variable directives.
*/
- public Vector getVariablesVector() {
+ public Vector<TagVariableInfo> getVariablesVector() {
return variableVector;
}
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<String, NameEntry> 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();
*/
void postCheck() throws JasperException {
// Check that var.name-from-attributes has valid values.
- Iterator iter = nameFromTable.keySet().iterator();
+ Iterator<String> 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,
/**
* 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) {
wrapper.getJspEngineContext().setTagInfo(tagInfo);
}
- Class tagClazz;
+ Class<?> tagClazz;
int tripCount = wrapper.incTripCount();
try {
if (tripCount > 0) {
try {
Object tagIns = tagClazz.newInstance();
if (tagIns instanceof JspSourceDependent) {
- Iterator iter = ((List) ((JspSourceDependent) tagIns)
- .getDependants()).iterator();
+ Iterator<String> iter = ((JspSourceDependent) tagIns)
+ .getDependants().iterator();
while (iter.hasNext()) {
- parentPageInfo.addDependant((String) iter.next());
+ parentPageInfo.addDependant(iter.next());
}
}
} catch (Exception e) {
} else {
pageInfo.addDependant(tagFilePath);
}
- Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(),
+ Class<?> c = loadTagFile(compiler, tagFilePath, n.getTagInfo(),
pageInfo);
n.setTagHandlerClass(c);
}
public void loadTagFiles(Compiler compiler, Node.Nodes page)
throws JasperException {
- tempVector = new Vector();
+ tempVector = new Vector<Compiler>();
page.visit(new TagFileLoaderVisitor(compiler));
}
* If non-null, remove only the class file with with this name.
*/
public void removeProtoTypeFiles(String classFileName) {
- Iterator iter = tempVector.iterator();
+ Iterator<Compiler> 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()
}
public TagLibraryInfo[] getTagLibraryInfos() {
- Collection coll = pi.getTaglibs();
- return (TagLibraryInfo[]) coll.toArray(new TagLibraryInfo[0]);
+ Collection<TagLibraryInfo> coll = pi.getTaglibs();
+ return coll.toArray(new TagLibraryInfo[0]);
}
/*
*/
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<TagInfo> tagVector = new Vector<TagInfo>();
+ Vector<TagFileInfo> tagFileVector = new Vector<TagFileInfo>();
+ Hashtable<String, FunctionInfo> functionTable = new Hashtable<String, FunctionInfo>();
// Create an iterator over the child elements of our <taglib> element
ParserUtils pu = new ParserUtils();
this.jspversion = tld.findAttribute("version");
// Process each child element of our <taglib> element
- Iterator list = tld.findChildren();
+ Iterator<TreeNode> 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
this.functions = new FunctionInfo[functionTable.size()];
int i = 0;
- Enumeration enumeration = functionTable.elements();
+ Enumeration<FunctionInfo> enumeration = functionTable.elements();
while (enumeration.hasMoreElements()) {
- this.functions[i++] = (FunctionInfo) enumeration.nextElement();
+ this.functions[i++] = enumeration.nextElement();
}
}
String largeIcon = null;
boolean dynamicAttributes = false;
- Vector attributeVector = new Vector();
- Vector variableVector = new Vector();
- Iterator list = elem.findChildren();
+ Vector<TagAttributeInfo> attributeVector = new Vector<TagAttributeInfo>();
+ Vector<TagVariableInfo> variableVector = new Vector<TagVariableInfo>();
+ Iterator<TreeNode> list = elem.findChildren();
while (list.hasNext()) {
- TreeNode element = (TreeNode) list.next();
+ TreeNode element = list.next();
String tname = element.getName();
if ("name".equals(tname)) {
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,
String name = null;
String path = null;
- Iterator list = elem.findChildren();
+ Iterator<TreeNode> 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();
String methodSignature = null;
boolean required = false, rtexprvalue = false, reqTime = false, isFragment = false, deferredValue = false, deferredMethod = false;
- Iterator list = elem.findChildren();
+ Iterator<TreeNode> list = elem.findChildren();
while (list.hasNext()) {
- TreeNode element = (TreeNode) list.next();
+ TreeNode element = list.next();
String tname = element.getName();
if ("name".equals(tname)) {
boolean declare = true;
int scope = VariableInfo.NESTED;
- Iterator list = elem.findChildren();
+ Iterator<TreeNode> 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();
throws JasperException {
String validatorClass = null;
- Map initParams = new Hashtable();
+ Map<String,Object> initParams = new Hashtable<String,Object>();
- Iterator list = elem.findChildren();
+ Iterator<TreeNode> 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();
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) {
String[] createInitParam(TreeNode elem) {
String[] initParam = new String[2];
- Iterator list = elem.findChildren();
+ Iterator<TreeNode> 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();
String klass = null;
String signature = null;
- Iterator list = elem.findChildren();
+ Iterator<TreeNode> list = elem.findChildren();
while (list.hasNext()) {
- TreeNode element = (TreeNode) list.next();
+ TreeNode element = list.next();
String tname = element.getName();
if ("name".equals(tname)) {
private static final String TAG_PLUGINS_ROOT_ELEM = "tag-plugins";
private boolean initialized = false;
- private HashMap tagPlugins = null;
+ private HashMap<String, TagPlugin> tagPlugins = null;
private ServletContext ctxt;
private PageInfo pageInfo;
TAG_PLUGINS_ROOT_ELEM);
}
- tagPlugins = new HashMap();
- Iterator pluginList = root.findChildren("tag-plugin");
+ tagPlugins = new HashMap<String, TagPlugin>();
+ Iterator<TreeNode> 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
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);
* 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;
}
private Node.CustomTag node;
private Node.Nodes curNodes;
private PageInfo pageInfo;
- private HashMap pluginAttributes;
+ private HashMap<String, Object> pluginAttributes;
TagPluginContextImpl(Node.CustomTag n, PageInfo pageInfo) {
this.node = n;
curNodes = new Node.Nodes();
n.setAtSTag(curNodes);
n.setUseTagPlugin(true);
- pluginAttributes = new HashMap();
+ pluginAttributes = new HashMap<String, Object>();
}
public TagPluginContext getParentContext() {
* [0] The location
* [1] If the location is a jar file, this is the location of the tld.
*/
- private Hashtable mappings;
+ private Hashtable<String, String[]> mappings;
private boolean initialized;
private ServletContext ctxt;
public TldLocationsCache(ServletContext ctxt, boolean redeployMode) {
this.ctxt = ctxt;
this.redeployMode = redeployMode;
- mappings = new Hashtable();
+ mappings = new Hashtable<String, String[]>();
initialized = false;
}
if (!initialized) {
init();
}
- return (String[]) mappings.get(uri);
+ return mappings.get(uri);
}
/**
if (jspConfig != null) {
webtld = jspConfig;
}
- Iterator taglibs = webtld.findChildren("taglib");
+ Iterator<TreeNode> taglibs = webtld.findChildren("taglib");
while (taglibs.hasNext()) {
// Parse the next <taglib> element
- TreeNode taglib = (TreeNode) taglibs.next();
+ TreeNode taglib = taglibs.next();
String tagUri = null;
String tagLoc = null;
TreeNode child = taglib.findChild("taglib-uri");
conn.setUseCaches(false);
}
jarFile = conn.getJarFile();
- Enumeration entries = jarFile.entries();
+ Enumeration<JarEntry> 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;
private void processTldsInFileSystem(String startPath)
throws Exception {
- Set dirList = ctxt.getResourcePaths(startPath);
+ Set<String> dirList = ctxt.getResourcePaths(startPath);
if (dirList != null) {
- Iterator it = dirList.iterator();
+ Iterator<String> it = dirList.iterator();
while (it.hasNext()) {
- String path = (String) it.next();
+ String path = it.next();
if (path.endsWith("/")) {
processTldsInFileSystem(path);
}
StringBuffer errMsg = null;
ErrorDispatcher errDisp = compiler.getErrorDispatcher();
- for (Iterator iter = compiler.getPageInfo().getTaglibs().iterator(); iter
- .hasNext();) {
+ for (Iterator<TagLibraryInfo> iter =
+ compiler.getPageInfo().getTaglibs().iterator(); iter.hasNext();) {
Object o = iter.next();
if (!(o instanceof TagLibraryInfoImpl))
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
* 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<String> getDependants();
}
/**
* Get a list of files that the current page has source dependency on.
*/
- public java.util.List getDependants() {
+ public java.util.List<String> getDependants() {
try {
Object target;
if (isTagFile) {
/**
* The children of this node, instantiated only if required.
*/
- protected ArrayList children = null;
+ protected ArrayList<TreeNode> children = null;
/**
public void addChild(TreeNode node) {
if (children == null)
- children = new ArrayList();
+ children = new ArrayList<TreeNode>();
children.add(node);
}
* Return an Iterator of all children of this node. If there are no
* children, an empty Iterator is returned.
*/
- public Iterator findChildren() {
+ public Iterator<TreeNode> findChildren() {
if (children == null)
return (Collections.EMPTY_LIST.iterator());
*
* @param name Name used to select children
*/
- public Iterator findChildren(String name) {
+ public Iterator<TreeNode> findChildren(String name) {
if (children == null)
return (Collections.EMPTY_LIST.iterator());
- ArrayList results = new ArrayList();
- Iterator items = children.iterator();
+ ArrayList<TreeNode> results = new ArrayList<TreeNode>();
+ Iterator<TreeNode> items = children.iterator();
while (items.hasNext()) {
- TreeNode item = (TreeNode) items.next();
+ TreeNode item = items.next();
if (name.equals(item.getName()))
results.add(item);
}