tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r470584 - in /tomcat/tc6.0.x/trunk/java/org/apache/jasper: compiler/Validator.java resources/LocalStrings.properties
Date Thu, 02 Nov 2006 22:56:46 GMT
Author: remm
Date: Thu Nov  2 14:56:45 2006
New Revision: 470584

URL: http://svn.apache.org/viewvc?view=rev&rev=470584
Log:
- Add translation time type checks for String.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Validator.java
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Validator.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Validator.java?view=diff&rev=470584&r1=470583&r2=470584
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Validator.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Validator.java Thu Nov  2 14:56:45
2006
@@ -36,6 +36,7 @@
 import javax.servlet.jsp.tagext.TagLibraryInfo;
 import javax.servlet.jsp.tagext.ValidationMessage;
 
+import org.apache.el.lang.ELSupport;
 import org.apache.jasper.Constants;
 import org.apache.jasper.JasperException;
 import org.apache.jasper.JspCompilationContext;
@@ -1037,12 +1038,6 @@
                             }
                         }
                         
-                        /*System.out.println("attrs.getLocalName(i): " + attrs.getLocalName(i));
-                        System.out.println("tldAttrs[j].canBeRequestTime(): " + tldAttrs[j].canBeRequestTime());
-                        System.out.println("expression: " + expression);
-                        System.out.println("tldAttrs[j].isDeferredMethod(): " + tldAttrs[j].isDeferredMethod());
-                        System.out.println("tldAttrs[j].isDeferredValue(): " + tldAttrs[j].isDeferredValue());*/
-                        
                         if (tldAttrs[j].canBeRequestTime()
                                 || tldAttrs[j].isDeferredMethod() || tldAttrs[j].isDeferredValue())
{ // JSP 2.1
                             
@@ -1053,15 +1048,42 @@
                                             tldAttrs[j].getName());
                                 }
                                 
+                                String expectedType = null;
                                 if (tldAttrs[j].isDeferredMethod()) {
                                     // The String litteral must be castable to what is declared
as type
                                     // for the attribute
-                                    
+                                    String m = tldAttrs[j].getMethodSignature();
+                                    if (m != null) {
+                                        int rti = m.trim().indexOf(' ');
+                                        if (rti > 0) {
+                                            expectedType = m.substring(0, rti).trim();
+                                        }
+                                    } else {
+                                        expectedType = "java.lang.Object";
+                                    }
                                 }
                                 if (tldAttrs[j].isDeferredValue()) {
                                     // The String litteral must be castable to what is declared
as type
                                     // for the attribute
-                                    
+                                    expectedType = tldAttrs[j].getExpectedTypeName();
+                                }
+                                if (expectedType != null) {
+                                    Class expectedClass = String.class;
+                                    try {
+                                        expectedClass = JspUtil.toClass(expectedType, loader);
+                                    } catch (ClassNotFoundException e) {
+                                        err.jspError
+                                            (n, "jsp.error.unknown_attribute_type",
+                                             tldAttrs[j].getName(), expectedType);
+                                    }
+                                    // Check casting
+                                    try {
+                                        ELSupport.coerceToType(attrs.getValue(i), expectedClass);
+                                    } catch (Exception e) {
+                                        err.jspError
+                                            (n, "jsp.error.coerce_to_type",
+                                             tldAttrs[j].getName(), expectedType, attrs.getValue(i));
+                                    }
                                 }
 
                                 jspAttrs[i] = new Node.JspAttribute(tldAttrs[j],

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties?view=diff&rev=470584&r1=470583&r2=470584
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties Thu Nov
 2 14:56:45 2006
@@ -337,6 +337,7 @@
 jsp.error.missing_var_or_varReader=Missing \'var\' or \'varReader\' attribute
 jsp.warning.bad.urlpattern.propertygroup=Bad value {0} in the url-pattern subelement in web.xml
 jsp.error.unknown_attribute_type=Unknown attribute type ({1}) for attribute {0}.
+jsp.error.coerce_to_type=Cannot coerce value ({2}) to type ({1}) for attribute {0}.
 jsp.error.jspelement.missing.name=Mandatory XML-style \'name\' attribute missing
 jsp.error.xmlns.redefinition.notimplemented=Internal error: Attempt to redefine xmlns:{0}.
 Redefinition of namespaces is not implemented.
 jsp.error.could.not.add.taglibraries=Could not add one or more tag libraries.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message