- Add two lost Jasper patches (which were applied to the old Jasper/TC6 repository).
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 18 Aug 2006 14:32:34 +0000 (14:32 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 18 Aug 2006 14:32:34 +0000 (14:32 +0000)
- 38676
- 39803 (not sure if the fix is complete)

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@432604 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/el/lang/ELSupport.java
java/org/apache/jasper/servlet/JspServletWrapper.java

index 0393c9f..3dda6d1 100644 (file)
@@ -107,6 +107,10 @@ public class ELSupport {
             return false;
         } else if (obj0 instanceof Boolean || obj1 instanceof Boolean) {
             return coerceToBoolean(obj0).equals(coerceToBoolean(obj1));
+        } else if (obj0.getClass().isEnum()) {
+            return obj0.equals(coerceToEnum(obj1, obj0.getClass()));
+        } else if (obj1.getClass().isEnum()) {
+            return obj1.equals(coerceToEnum(obj0, obj1.getClass()));
         }
         if (isBigDecimalOp(obj0, obj1)) {
             BigDecimal bd0 = (BigDecimal) coerceToNumber(obj0, BigDecimal.class);
@@ -131,6 +135,21 @@ public class ELSupport {
             return obj0.equals(obj1);
         }
     }
+    
+    /**
+     * @param obj
+     * @param type
+     * @return
+     */
+    public final static Enum coerceToEnum(final Object obj, Class type) {
+        if (obj == null || "".equals(obj)) {
+            return null;
+        }
+        if (obj.getClass().isEnum()) {
+            return (Enum) obj;
+        }
+        return Enum.valueOf(type, obj.toString());
+    }
 
     /**
      * @param obj
@@ -286,6 +305,8 @@ public class ELSupport {
             return "";
         } else if (obj instanceof String) {
             return (String) obj;
+        } else if (obj instanceof Enum) {
+            return ((Enum) obj).name();
         } else {
             return obj.toString();
         }
@@ -311,6 +332,9 @@ public class ELSupport {
         if (obj != null && type.isAssignableFrom(obj.getClass())) {
             return obj;
         }
+        if (type.isEnum()) {
+            return coerceToEnum(obj, type);
+        }
 
         // new to spec
         if (obj == null)
index 45187b7..942e854 100644 (file)
@@ -217,6 +217,7 @@ public class JspServletWrapper {
 
             if (reload) {
                 tagHandlerClass = ctxt.load();
+                reload = false;
             }
         } catch (FileNotFoundException ex) {
             throw new JasperException(ex);
@@ -245,22 +246,23 @@ public class JspServletWrapper {
      * Get a list of files that the current page has source dependency on.
      */
     public java.util.List getDependants() {
-       try {
-           Object target;
-           if (isTagFile) {
+        try {
+            Object target;
+            if (isTagFile) {
                 if (reload) {
                     tagHandlerClass = ctxt.load();
+                    reload = false;
                 }
-               target = tagHandlerClass.newInstance();
-           } else {
-               target = getServlet();
-           }
-           if (target != null && target instanceof JspSourceDependent) {
-            return ((java.util.List) ((JspSourceDependent) target).getDependants());
-           }
-       } catch (Throwable ex) {
-       }
-       return null;
+                target = tagHandlerClass.newInstance();
+            } else {
+                target = getServlet();
+            }
+            if (target != null && target instanceof JspSourceDependent) {
+                return ((java.util.List) ((JspSourceDependent) target).getDependants());
+            }
+        } catch (Throwable ex) {
+        }
+        return null;
     }
 
     public boolean isTagFile() {