Code clean-up. Remove unused code, parameters, etc.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 13 May 2008 21:19:07 +0000 (21:19 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 13 May 2008 21:19:07 +0000 (21:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@656018 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/compiler/Validator.java

index da81d47..3b63046 100644 (file)
@@ -27,7 +27,6 @@ import javax.el.ELException;
 import javax.el.ExpressionFactory;
 import javax.el.FunctionMapper;
 import javax.servlet.jsp.tagext.FunctionInfo;
-import javax.servlet.jsp.tagext.JspFragment;
 import javax.servlet.jsp.tagext.PageData;
 import javax.servlet.jsp.tagext.TagAttributeInfo;
 import javax.servlet.jsp.tagext.TagData;
@@ -543,8 +542,7 @@ class Validator {
             // request-time expression
             throwErrorIfExpression(n, "name", "jsp:param");
             n.setValue(getJspAttribute(null, "value", null, null, n
-                    .getAttributeValue("value"), java.lang.String.class, n,
-                    false));
+                    .getAttributeValue("value"), n, false));
             visitBody(n);
         }
 
@@ -561,16 +559,14 @@ class Validator {
             JspUtil.checkAttributes("Include action", n, includeActionAttrs,
                     err);
             n.setPage(getJspAttribute(null, "page", null, null, n
-                    .getAttributeValue("page"), java.lang.String.class, n,
-                    false));
+                    .getAttributeValue("page"), n, false));
             visitBody(n);
-        };
+        }
 
         public void visit(Node.ForwardAction n) throws JasperException {
             JspUtil.checkAttributes("Forward", n, forwardActionAttrs, err);
             n.setPage(getJspAttribute(null, "page", null, null, n
-                    .getAttributeValue("page"), java.lang.String.class, n,
-                    false));
+                    .getAttributeValue("page"), n, false));
             visitBody(n);
         }
 
@@ -585,7 +581,7 @@ class Validator {
             String value = n.getAttributeValue("value");
 
             n.setValue(getJspAttribute(null, "value", null, null, value,
-                    java.lang.Object.class, n, false));
+                    n, false));
 
             boolean valueSpecified = n.getValue() != null;
 
@@ -620,8 +616,7 @@ class Validator {
                 err.jspError(n, "jsp.error.usebean.noSession");
 
             Node.JspAttribute jattr = getJspAttribute(null, "beanName", null,
-                    null, n.getAttributeValue("beanName"),
-                    java.lang.String.class, n, false);
+                    null, n.getAttributeValue("beanName"), n, false);
             n.setBeanName(jattr);
             if (className != null && jattr != null)
                 err.jspError(n, "jsp.error.usebean.notBoth");
@@ -658,13 +653,11 @@ class Validator {
                 err.jspError(n, "jsp.error.plugin.nocode");
 
             Node.JspAttribute width = getJspAttribute(null, "width", null,
-                    null, n.getAttributeValue("width"), java.lang.String.class,
-                    n, false);
+                    null, n.getAttributeValue("width"), n, false);
             n.setWidth(width);
 
             Node.JspAttribute height = getJspAttribute(null, "height", null,
-                    null, n.getAttributeValue("height"),
-                    java.lang.String.class, n, false);
+                    null, n.getAttributeValue("height"), n, false);
             n.setHeight(height);
 
             visitBody(n);
@@ -739,8 +732,7 @@ class Validator {
                 for (int i = 0; i < attrSize; i++) {
                     jspAttrs[i] = getJspAttribute(null, attrs.getQName(i),
                             attrs.getURI(i), attrs.getLocalName(i), attrs
-                                    .getValue(i), java.lang.Object.class, n,
-                            false);
+                                    .getValue(i), n, false);
                 }
                 n.setJspAttributes(jspAttrs);
             }
@@ -860,14 +852,12 @@ class Validator {
                 if ("name".equals(attrs.getLocalName(i))) {
                     n.setNameAttribute(getJspAttribute(null, attrs.getQName(i),
                             attrs.getURI(i), attrs.getLocalName(i), attrs
-                                    .getValue(i), java.lang.String.class, n,
-                            false));
+                                    .getValue(i), n, false));
                 } else {
                     if (jspAttrIndex < jspAttrSize) {
                         jspAttrs[jspAttrIndex++] = getJspAttribute(null, attrs
                                 .getQName(i), attrs.getURI(i), attrs
-                                .getLocalName(i), attrs.getValue(i),
-                                java.lang.Object.class, n, false);
+                                .getLocalName(i), attrs.getValue(i), n, false);
                     }
                 }
             }
@@ -1090,7 +1080,7 @@ class Validator {
                                     expectedType = tldAttrs[j].getExpectedTypeName();
                                 }
                                 if (expectedType != null) {
-                                    Class expectedClass = String.class;
+                                    Class<?> expectedClass = String.class;
                                     try {
                                         expectedClass = JspUtil.toClass(expectedType, loader);
                                     } catch (ClassNotFoundException e) {
@@ -1125,43 +1115,28 @@ class Validator {
                                             tldAttrs[j].getName());
                                 }
                                 
-                                Class expectedType = String.class;
-                                try {
-                                    String typeStr = tldAttrs[j].getTypeName();
-                                    if (tldAttrs[j].isFragment()) {
-                                        expectedType = JspFragment.class;
-                                    } else if (typeStr != null) {
-                                        expectedType = JspUtil.toClass(typeStr,
-                                                loader);
-                                    }
-                                    if (elExpression) {
-                                        // El expression
-                                        validateFunctions(el, n);
-                                        jspAttrs[i] = new Node.JspAttribute(tldAttrs[j],
-                                                attrs.getQName(i), attrs.getURI(i), 
-                                                attrs.getLocalName(i),
-                                                attrs.getValue(i), false, el, false);
-                                        ELContextImpl ctx = new ELContextImpl();
-                                        ctx.setFunctionMapper(getFunctionMapper(el));
-                                        try {
-                                            jspAttrs[i].validateEL(this.pageInfo.getExpressionFactory(), ctx);
-                                        } catch (ELException e) {
-                                            this.err.jspError(n.getStart(),
-                                                    "jsp.error.invalid.expression", 
-                                                    attrs.getValue(i), e.toString());
-                                        }
-                                    } else {
-                                        // Runtime expression
-                                        jspAttrs[i] = getJspAttribute(tldAttrs[j],
-                                                attrs.getQName(i), attrs.getURI(i),
-                                                attrs.getLocalName(i), attrs
-                                                .getValue(i), expectedType, n,
-                                                false);
+                                if (elExpression) {
+                                    // El expression
+                                    validateFunctions(el, n);
+                                    jspAttrs[i] = new Node.JspAttribute(tldAttrs[j],
+                                            attrs.getQName(i), attrs.getURI(i), 
+                                            attrs.getLocalName(i),
+                                            attrs.getValue(i), false, el, false);
+                                    ELContextImpl ctx = new ELContextImpl();
+                                    ctx.setFunctionMapper(getFunctionMapper(el));
+                                    try {
+                                        jspAttrs[i].validateEL(this.pageInfo.getExpressionFactory(), ctx);
+                                    } catch (ELException e) {
+                                        this.err.jspError(n.getStart(),
+                                                "jsp.error.invalid.expression", 
+                                                attrs.getValue(i), e.toString());
                                     }
-                                } catch (ClassNotFoundException e) {
-                                    err.jspError
-                                        (n, "jsp.error.unknown_attribute_type",
-                                         tldAttrs[j].getName(), tldAttrs[j].getTypeName());
+                                } else {
+                                    // Runtime expression
+                                    jspAttrs[i] = getJspAttribute(tldAttrs[j],
+                                            attrs.getQName(i), attrs.getURI(i),
+                                            attrs.getLocalName(i), attrs
+                                            .getValue(i), n, false);
                                 }
                             }
                             
@@ -1192,8 +1167,7 @@ class Validator {
                     if (tagInfo.hasDynamicAttributes()) {
                         jspAttrs[i] = getJspAttribute(null, attrs.getQName(i),
                                 attrs.getURI(i), attrs.getLocalName(i), attrs
-                                        .getValue(i), java.lang.Object.class,
-                                n, true);
+                                        .getValue(i), n, true);
                     } else {
                         err.jspError(n, "jsp.error.bad_attribute", attrs
                                 .getQName(i), n.getLocalName());
@@ -1274,7 +1248,7 @@ class Validator {
          */
         private Node.JspAttribute getJspAttribute(TagAttributeInfo tai,
                 String qName, String uri, String localName, String value,
-                Class expectedType, Node n, boolean dynamic)
+                Node n, boolean dynamic)
                 throws JasperException {
 
             Node.JspAttribute result = null;
@@ -1579,7 +1553,7 @@ class Validator {
                 }
                 start = p + 1;
             }
-            return (String[]) params.toArray(new String[params.size()]);
+            return params.toArray(new String[params.size()]);
         }
 
         private FunctionMapper getFunctionMapper(ELNode.Nodes el)
@@ -1607,7 +1581,7 @@ class Validator {
 
                 public void visit(ELNode.Function n) throws JasperException {
 
-                    Class c = null;
+                    Class<?> c = null;
                     Method method = null;
                     try {
                         c = loader.loadClass(n.getFunctionInfo()
@@ -1620,7 +1594,7 @@ class Validator {
                     }
                     String paramTypes[] = n.getParameters();
                     int size = paramTypes.length;
-                    Class params[] = new Class[size];
+                    Class<?> params[] = new Class[size];
                     int i = 0;
                     try {
                         for (i = 0; i < size; i++) {