You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2016/08/02 12:28:05 UTC

svn commit: r1754903 - /tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java

Author: markt
Date: Tue Aug  2 12:28:05 2016
New Revision: 1754903

URL: http://svn.apache.org/viewvc?rev=1754903&view=rev
Log:
Tab police

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java?rev=1754903&r1=1754902&r2=1754903&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java Tue Aug  2 12:28:05 2016
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,7 +43,7 @@ import org.apache.jasper.compiler.Locali
 
 /**
  * Bunch of util methods that are used by code generated for useBean,
- * getProperty and setProperty.  
+ * getProperty and setProperty.
  *
  * The __begin, __end stuff is there so that the JSP engine can
  * actually parse this file and inline them if people don't want
@@ -54,36 +54,36 @@ import org.apache.jasper.compiler.Locali
  * @author Shawn Bayern
  */
 public class JspRuntimeLibrary {
-    
+
     private static final String SERVLET_EXCEPTION
-	= "javax.servlet.error.exception";
+        = "javax.servlet.error.exception";
     private static final String JSP_EXCEPTION
-	= "javax.servlet.jsp.jspException";
+        = "javax.servlet.jsp.jspException";
 
     protected static class PrivilegedIntrospectHelper
-	implements PrivilegedExceptionAction {
+        implements PrivilegedExceptionAction {
 
-	private Object bean;
-	private String prop;
-	private String value;
-	private ServletRequest request;
-	private String param;
-	private boolean ignoreMethodNF;
+        private Object bean;
+        private String prop;
+        private String value;
+        private ServletRequest request;
+        private String param;
+        private boolean ignoreMethodNF;
 
         PrivilegedIntrospectHelper(Object bean, String prop,
                                    String value, ServletRequest request,
                                    String param, boolean ignoreMethodNF)
         {
-	    this.bean = bean;
-	    this.prop = prop;
-	    this.value = value;
+            this.bean = bean;
+            this.prop = prop;
+            this.value = value;
             this.request = request;
-	    this.param = param;
-	    this.ignoreMethodNF = ignoreMethodNF;
+            this.param = param;
+            this.ignoreMethodNF = ignoreMethodNF;
         }
-         
+
         public Object run() throws JasperException {
-	    internalIntrospecthelper(
+            internalIntrospecthelper(
                 bean,prop,value,request,param,ignoreMethodNF);
             return null;
         }
@@ -99,135 +99,135 @@ public class JspRuntimeLibrary {
      * variable is initialized.
      */
     public static Throwable getThrowable(ServletRequest request) {
-	Throwable error = (Throwable) request.getAttribute(SERVLET_EXCEPTION);
-	if (error == null) {
-	    error = (Throwable) request.getAttribute(JSP_EXCEPTION);
-	    if (error != null) {
-		/*
-		 * The only place that sets JSP_EXCEPTION is
-		 * PageContextImpl.handlePageException(). It really should set
-		 * SERVLET_EXCEPTION, but that would interfere with the 
-		 * ErrorReportValve. Therefore, if JSP_EXCEPTION is set, we
-		 * need to set SERVLET_EXCEPTION.
-		 */
-		request.setAttribute(SERVLET_EXCEPTION, error);
-	    }
-	}
+        Throwable error = (Throwable) request.getAttribute(SERVLET_EXCEPTION);
+        if (error == null) {
+            error = (Throwable) request.getAttribute(JSP_EXCEPTION);
+            if (error != null) {
+                /*
+                 * The only place that sets JSP_EXCEPTION is
+                 * PageContextImpl.handlePageException(). It really should set
+                 * SERVLET_EXCEPTION, but that would interfere with the
+                 * ErrorReportValve. Therefore, if JSP_EXCEPTION is set, we
+                 * need to set SERVLET_EXCEPTION.
+                 */
+                request.setAttribute(SERVLET_EXCEPTION, error);
+            }
+        }
 
-	return error;
+        return error;
     }
 
     public static boolean coerceToBoolean(String s) {
-	if (s == null || s.length() == 0)
-	    return false;
-	else
-	    return Boolean.valueOf(s).booleanValue();
+        if (s == null || s.length() == 0)
+            return false;
+        else
+            return Boolean.valueOf(s).booleanValue();
     }
 
     public static byte coerceToByte(String s) {
-	if (s == null || s.length() == 0)
-	    return (byte) 0;
-	else
-	    return Byte.valueOf(s).byteValue();
+        if (s == null || s.length() == 0)
+            return (byte) 0;
+        else
+            return Byte.valueOf(s).byteValue();
     }
 
     public static char coerceToChar(String s) {
-	if (s == null || s.length() == 0) {
-	    return (char) 0;
-	} else {
-	    // this trick avoids escaping issues
-	    return (char)(int) s.charAt(0);
-	}
+        if (s == null || s.length() == 0) {
+            return (char) 0;
+        } else {
+            // this trick avoids escaping issues
+            return (char)(int) s.charAt(0);
+        }
     }
 
     public static double coerceToDouble(String s) {
-	if (s == null || s.length() == 0)
-	    return (double) 0;
-	else
-	    return Double.valueOf(s).doubleValue();
+        if (s == null || s.length() == 0)
+            return (double) 0;
+        else
+            return Double.valueOf(s).doubleValue();
     }
 
     public static float coerceToFloat(String s) {
-	if (s == null || s.length() == 0)
-	    return (float) 0;
-	else
-	    return Float.valueOf(s).floatValue();
+        if (s == null || s.length() == 0)
+            return (float) 0;
+        else
+            return Float.valueOf(s).floatValue();
     }
 
     public static int coerceToInt(String s) {
-	if (s == null || s.length() == 0)
-	    return 0;
-	else
-	    return Integer.valueOf(s).intValue();
+        if (s == null || s.length() == 0)
+            return 0;
+        else
+            return Integer.valueOf(s).intValue();
     }
 
     public static short coerceToShort(String s) {
-	if (s == null || s.length() == 0)
-	    return (short) 0;
-	else
-	    return Short.valueOf(s).shortValue();
+        if (s == null || s.length() == 0)
+            return (short) 0;
+        else
+            return Short.valueOf(s).shortValue();
     }
 
     public static long coerceToLong(String s) {
-	if (s == null || s.length() == 0)
-	    return (long) 0;
-	else
-	    return Long.valueOf(s).longValue();
+        if (s == null || s.length() == 0)
+            return (long) 0;
+        else
+            return Long.valueOf(s).longValue();
     }
 
     public static Object coerce(String s, Class target) {
 
-	boolean isNullOrEmpty = (s == null || s.length() == 0);
+        boolean isNullOrEmpty = (s == null || s.length() == 0);
 
-	if (target == Boolean.class) {
-	    if (isNullOrEmpty) {
-		s = "false";
-	    }
-	    return new Boolean(s);
-	} else if (target == Byte.class) {
-	    if (isNullOrEmpty)
-		return new Byte((byte) 0);
-	    else
-		return new Byte(s);
-	} else if (target == Character.class) {
-	    if (isNullOrEmpty)
-		return new Character((char) 0);
-	    else 
-		return new Character(s.charAt(0));
-	} else if (target == Double.class) {
-	    if (isNullOrEmpty)
-		return new Double(0);
-	    else
-		return new Double(s);
-	} else if (target == Float.class) {
-	    if (isNullOrEmpty)
-		return new Float(0);
-	    else
-		return new Float(s);
-	} else if (target == Integer.class) {
-	    if (isNullOrEmpty)
-		return new Integer(0);
-	    else
-		return new Integer(s);
-	} else if (target == Short.class) {
-	    if (isNullOrEmpty)
-		return new Short((short) 0);
-	    else
-		return new Short(s);
-	} else if (target == Long.class) {
-	    if (isNullOrEmpty)
-		return new Long(0);
-	    else
-		return new Long(s);
-	} else {
-	    return null;
-	}
+        if (target == Boolean.class) {
+            if (isNullOrEmpty) {
+                s = "false";
+            }
+            return new Boolean(s);
+        } else if (target == Byte.class) {
+            if (isNullOrEmpty)
+                return new Byte((byte) 0);
+            else
+                return new Byte(s);
+        } else if (target == Character.class) {
+            if (isNullOrEmpty)
+                return new Character((char) 0);
+            else
+                return new Character(s.charAt(0));
+        } else if (target == Double.class) {
+            if (isNullOrEmpty)
+                return new Double(0);
+            else
+                return new Double(s);
+        } else if (target == Float.class) {
+            if (isNullOrEmpty)
+                return new Float(0);
+            else
+                return new Float(s);
+        } else if (target == Integer.class) {
+            if (isNullOrEmpty)
+                return new Integer(0);
+            else
+                return new Integer(s);
+        } else if (target == Short.class) {
+            if (isNullOrEmpty)
+                return new Short((short) 0);
+            else
+                return new Short(s);
+        } else if (target == Long.class) {
+            if (isNullOrEmpty)
+                return new Long(0);
+            else
+                return new Long(s);
+        } else {
+            return null;
+        }
     }
 
    // __begin convertMethod
     public static Object convert(String propertyName, String s, Class t,
-				 Class propertyEditorClass) 
-       throws JasperException 
+                                 Class propertyEditorClass)
+       throws JasperException
     {
         try {
             if (s == null) {
@@ -236,10 +236,10 @@ public class JspRuntimeLibrary {
                 else
                     return null;
             }
-	    if (propertyEditorClass != null) {
-		return getValueFromBeanInfoPropertyEditor(
-				    t, propertyName, s, propertyEditorClass);
-	    } else if ( t.equals(Boolean.class) || t.equals(Boolean.TYPE) ) {
+            if (propertyEditorClass != null) {
+                return getValueFromBeanInfoPropertyEditor(
+                                    t, propertyName, s, propertyEditorClass);
+            } else if ( t.equals(Boolean.class) || t.equals(Boolean.TYPE) ) {
                 if (s.equalsIgnoreCase("on") || s.equalsIgnoreCase("true"))
                     s = "true";
                 else
@@ -265,8 +265,8 @@ public class JspRuntimeLibrary {
                 return new java.io.File(s);
             } else if (t.getName().equals("java.lang.Object")) {
                 return new Object[] {s};
-	    } else {
-		return getValueFromPropertyEditorManager(
+            } else {
+                return getValueFromPropertyEditorManager(
                                             t, propertyName, s);
             }
         } catch (Exception ex) {
@@ -279,15 +279,15 @@ public class JspRuntimeLibrary {
     public static void introspect(Object bean, ServletRequest request)
                                   throws JasperException
     {
-	Enumeration e = request.getParameterNames();
-	while ( e.hasMoreElements() ) {
-	    String name  = (String) e.nextElement();
-	    String value = request.getParameter(name);
-	    introspecthelper(bean, name, value, request, name, true);
-	}
+        Enumeration e = request.getParameterNames();
+        while ( e.hasMoreElements() ) {
+            String name  = (String) e.nextElement();
+            String value = request.getParameter(name);
+            introspecthelper(bean, name, value, request, name, true);
+        }
     }
     // __end introspectMethod
-    
+
     // __begin introspecthelperMethod
     public static void introspecthelper(Object bean, String prop,
                                         String value, ServletRequest request,
@@ -297,8 +297,8 @@ public class JspRuntimeLibrary {
         if( Constants.IS_SECURITY_ENABLED ) {
             try {
                 PrivilegedIntrospectHelper dp =
-		    new PrivilegedIntrospectHelper(
-			bean,prop,value,request,param,ignoreMethodNF);
+                    new PrivilegedIntrospectHelper(
+                        bean,prop,value,request,param,ignoreMethodNF);
                 AccessController.doPrivileged(dp);
             } catch( PrivilegedActionException pe) {
                 Exception e = pe.getException();
@@ -306,77 +306,77 @@ public class JspRuntimeLibrary {
             }
         } else {
             internalIntrospecthelper(
-		bean,prop,value,request,param,ignoreMethodNF);
+                bean,prop,value,request,param,ignoreMethodNF);
         }
     }
 
     private static void internalIntrospecthelper(Object bean, String prop,
-					String value, ServletRequest request,
-					String param, boolean ignoreMethodNF) 
-					throws JasperException
+                                        String value, ServletRequest request,
+                                        String param, boolean ignoreMethodNF)
+                                        throws JasperException
     {
         Method method = null;
         Class type = null;
         Class propertyEditorClass = null;
-	try {
-	    java.beans.BeanInfo info
-		= java.beans.Introspector.getBeanInfo(bean.getClass());
-	    if ( info != null ) {
-		java.beans.PropertyDescriptor pd[]
-		    = info.getPropertyDescriptors();
-		for (int i = 0 ; i < pd.length ; i++) {
-		    if ( pd[i].getName().equals(prop) ) {
-			method = pd[i].getWriteMethod();
-			type   = pd[i].getPropertyType();
-			propertyEditorClass = pd[i].getPropertyEditorClass();
-			break;
-		    }
-		}
-	    }
-	    if ( method != null ) {
-		if (type.isArray()) {
+        try {
+            java.beans.BeanInfo info
+                = java.beans.Introspector.getBeanInfo(bean.getClass());
+            if ( info != null ) {
+                java.beans.PropertyDescriptor pd[]
+                    = info.getPropertyDescriptors();
+                for (int i = 0 ; i < pd.length ; i++) {
+                    if ( pd[i].getName().equals(prop) ) {
+                        method = pd[i].getWriteMethod();
+                        type   = pd[i].getPropertyType();
+                        propertyEditorClass = pd[i].getPropertyEditorClass();
+                        break;
+                    }
+                }
+            }
+            if ( method != null ) {
+                if (type.isArray()) {
                     if (request == null) {
-			throw new JasperException(
-		            Localizer.getMessage("jsp.error.beans.setproperty.noindexset"));
+                        throw new JasperException(
+                            Localizer.getMessage("jsp.error.beans.setproperty.noindexset"));
                     }
-		    Class t = type.getComponentType();
-		    String[] values = request.getParameterValues(param);
-		    //XXX Please check.
-		    if(values == null) return;
-		    if(t.equals(String.class)) {
-			method.invoke(bean, new Object[] { values });
-		    } else {
-			Object tmpval = null;
-			createTypedArray (prop, bean, method, values, t,
-					  propertyEditorClass); 
-		    }
-		} else {
-		    if(value == null || (param != null && value.equals(""))) return;
-		    Object oval = convert(prop, value, type, propertyEditorClass);
-		    if ( oval != null )
-			method.invoke(bean, new Object[] { oval });
-		}
-	    }
-	} catch (Exception ex) {
-	    throw new JasperException(ex);
-	}
+                    Class t = type.getComponentType();
+                    String[] values = request.getParameterValues(param);
+                    //XXX Please check.
+                    if(values == null) return;
+                    if(t.equals(String.class)) {
+                        method.invoke(bean, new Object[] { values });
+                    } else {
+                        Object tmpval = null;
+                        createTypedArray (prop, bean, method, values, t,
+                                          propertyEditorClass);
+                    }
+                } else {
+                    if(value == null || (param != null && value.equals(""))) return;
+                    Object oval = convert(prop, value, type, propertyEditorClass);
+                    if ( oval != null )
+                        method.invoke(bean, new Object[] { oval });
+                }
+            }
+        } catch (Exception ex) {
+            throw new JasperException(ex);
+        }
         if (!ignoreMethodNF && (method == null)) {
             if (type == null) {
-		throw new JasperException(
+                throw new JasperException(
                     Localizer.getMessage("jsp.error.beans.noproperty",
-					 prop,
-					 bean.getClass().getName()));
+                                         prop,
+                                         bean.getClass().getName()));
             } else {
-		throw new JasperException(
-	            Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
-					 prop,
-					 type.getName(),
-					 bean.getClass().getName()));
+                throw new JasperException(
+                    Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
+                                         prop,
+                                         type.getName(),
+                                         bean.getClass().getName()));
             }
         }
     }
     // __end introspecthelperMethod
-    
+
     //-------------------------------------------------------------------
     // functions to convert builtin Java data types to string.
     //-------------------------------------------------------------------
@@ -425,113 +425,113 @@ public class JspRuntimeLibrary {
      * the request and the property is indexed.
      */
     public static void createTypedArray(String propertyName,
-					Object bean,
-					Method method,
-					String[] values,
-					Class t,
-					Class propertyEditorClass)
-	        throws JasperException {
-
-	try {
-	    if (propertyEditorClass != null) {
-		Object[] tmpval = new Integer[values.length];
-		for (int i=0; i<values.length; i++) {
-		    tmpval[i] = getValueFromBeanInfoPropertyEditor(
+                                        Object bean,
+                                        Method method,
+                                        String[] values,
+                                        Class t,
+                                        Class propertyEditorClass)
+                throws JasperException {
+
+        try {
+            if (propertyEditorClass != null) {
+                Object[] tmpval = new Integer[values.length];
+                for (int i=0; i<values.length; i++) {
+                    tmpval[i] = getValueFromBeanInfoPropertyEditor(
                             t, propertyName, values[i], propertyEditorClass);
-		}
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(Integer.class)) {
-		Integer []tmpval = new Integer[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] =  new Integer (values[i]);
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(Byte.class)) {
-		Byte[] tmpval = new Byte[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = new Byte (values[i]);
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(Boolean.class)) {
-		Boolean[] tmpval = new Boolean[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = new Boolean (values[i]);
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(Short.class)) {
-		Short[] tmpval = new Short[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = new Short (values[i]);
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(Long.class)) {
-		Long[] tmpval = new Long[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = new Long (values[i]);
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(Double.class)) {
-		Double[] tmpval = new Double[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = new Double (values[i]);
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(Float.class)) {
-		Float[] tmpval = new Float[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = new Float (values[i]);
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(Character.class)) {
-		Character[] tmpval = new Character[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = new Character(values[i].charAt(0));
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(int.class)) {
-		int []tmpval = new int[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = Integer.parseInt (values[i]);
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(byte.class)) {
-		byte[] tmpval = new byte[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = Byte.parseByte (values[i]);
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(boolean.class)) {
-		boolean[] tmpval = new boolean[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = (Boolean.valueOf(values[i])).booleanValue();
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(short.class)) {
-		short[] tmpval = new short[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = Short.parseShort (values[i]);
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(long.class)) {
-		long[] tmpval = new long[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = Long.parseLong (values[i]);
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(double.class)) {
-		double[] tmpval = new double[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = Double.valueOf(values[i]).doubleValue();
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(float.class)) {
-		float[] tmpval = new float[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = Float.valueOf(values[i]).floatValue();
-		method.invoke (bean, new Object[] {tmpval});
-	    } else if (t.equals(char.class)) {
-		char[] tmpval = new char[values.length];
-		for (int i = 0 ; i < values.length; i++)
-		    tmpval[i] = values[i].charAt(0);
-		method.invoke (bean, new Object[] {tmpval});
-	    } else {
-		Object[] tmpval = new Integer[values.length];
-		for (int i=0; i<values.length; i++) {
-		    tmpval[i] =  
-			getValueFromPropertyEditorManager(
+                }
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(Integer.class)) {
+                Integer []tmpval = new Integer[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] =  new Integer (values[i]);
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(Byte.class)) {
+                Byte[] tmpval = new Byte[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = new Byte (values[i]);
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(Boolean.class)) {
+                Boolean[] tmpval = new Boolean[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = new Boolean (values[i]);
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(Short.class)) {
+                Short[] tmpval = new Short[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = new Short (values[i]);
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(Long.class)) {
+                Long[] tmpval = new Long[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = new Long (values[i]);
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(Double.class)) {
+                Double[] tmpval = new Double[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = new Double (values[i]);
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(Float.class)) {
+                Float[] tmpval = new Float[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = new Float (values[i]);
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(Character.class)) {
+                Character[] tmpval = new Character[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = new Character(values[i].charAt(0));
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(int.class)) {
+                int []tmpval = new int[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = Integer.parseInt (values[i]);
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(byte.class)) {
+                byte[] tmpval = new byte[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = Byte.parseByte (values[i]);
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(boolean.class)) {
+                boolean[] tmpval = new boolean[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = (Boolean.valueOf(values[i])).booleanValue();
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(short.class)) {
+                short[] tmpval = new short[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = Short.parseShort (values[i]);
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(long.class)) {
+                long[] tmpval = new long[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = Long.parseLong (values[i]);
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(double.class)) {
+                double[] tmpval = new double[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = Double.valueOf(values[i]).doubleValue();
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(float.class)) {
+                float[] tmpval = new float[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = Float.valueOf(values[i]).floatValue();
+                method.invoke (bean, new Object[] {tmpval});
+            } else if (t.equals(char.class)) {
+                char[] tmpval = new char[values.length];
+                for (int i = 0 ; i < values.length; i++)
+                    tmpval[i] = values[i].charAt(0);
+                method.invoke (bean, new Object[] {tmpval});
+            } else {
+                Object[] tmpval = new Integer[values.length];
+                for (int i=0; i<values.length; i++) {
+                    tmpval[i] =
+                        getValueFromPropertyEditorManager(
                                             t, propertyName, values[i]);
-		}
-		method.invoke (bean, new Object[] {tmpval});
-	    }
-	} catch (Exception ex) {
+                }
+                method.invoke (bean, new Object[] {tmpval});
+            }
+        } catch (Exception ex) {
             throw new JasperException ("error in invoking method", ex);
-	}
+        }
     }
 
     /**
@@ -543,10 +543,10 @@ public class JspRuntimeLibrary {
     public static String escapeQueryString(String unescString) {
     if ( unescString == null )
         return null;
-   
+
     String escString    = "";
     String shellSpChars = "&;`'\"|*?~<>^()[]{}$\\\n";
-   
+
     for(int index=0; index<unescString.length(); index++) {
         char nextChar = unescString.charAt(index);
 
@@ -591,7 +591,7 @@ public class JspRuntimeLibrary {
             holdbuffer[bufcount++] = (byte) cur;
             }
         }
-	// REVISIT -- remedy for Deprecated warning.
+        // REVISIT -- remedy for Deprecated warning.
     //return new String(holdbuffer,0,0,bufcount);
     return new String(holdbuffer,0,bufcount);
     }
@@ -600,15 +600,15 @@ public class JspRuntimeLibrary {
     public static Object handleGetProperty(Object o, String prop)
     throws JasperException {
         if (o == null) {
-	    throw new JasperException(
-	            Localizer.getMessage("jsp.error.beans.nullbean"));
+            throw new JasperException(
+                    Localizer.getMessage("jsp.error.beans.nullbean"));
         }
-	Object value = null;
+        Object value = null;
         try {
             Method method = getReadMethod(o.getClass(), prop);
-	    value = method.invoke(o, (Object[]) null);
+            value = method.invoke(o, (Object[]) null);
         } catch (Exception ex) {
-	    throw new JasperException (ex);
+            throw new JasperException (ex);
         }
         return value;
     }
@@ -619,26 +619,26 @@ public class JspRuntimeLibrary {
     public static void handleSetPropertyExpression(Object bean,
         String prop, String expression, PageContext pageContext,
         VariableResolver variableResolver, FunctionMapper functionMapper )
-	throws JasperException
+        throws JasperException
     {
-	try {
+        try {
             Method method = getWriteMethod(bean.getClass(), prop);
-	    method.invoke(bean, new Object[] { 
-		pageContext.getExpressionEvaluator().evaluate(
-		    expression,
-		    method.getParameterTypes()[0],
+            method.invoke(bean, new Object[] {
+                pageContext.getExpressionEvaluator().evaluate(
+                    expression,
+                    method.getParameterTypes()[0],
                     variableResolver,
                     functionMapper,
                     null )
-	    });
-	} catch (Exception ex) {
-	    throw new JasperException(ex);
-	}
+            });
+        } catch (Exception ex) {
+            throw new JasperException(ex);
+        }
     }
 **/
     public static void handleSetPropertyExpression(Object bean,
         String prop, String expression, PageContext pageContext,
-	ProtectedFunctionMapper functionMapper )
+        ProtectedFunctionMapper functionMapper )
         throws JasperException
     {
         try {
@@ -647,7 +647,7 @@ public class JspRuntimeLibrary {
                 PageContextImpl.proprietaryEvaluate(
                     expression,
                     method.getParameterTypes()[0],
-		    pageContext,
+                    pageContext,
                     functionMapper,
                     false )
             });
@@ -657,160 +657,160 @@ public class JspRuntimeLibrary {
     }
 
     public static void handleSetProperty(Object bean, String prop,
-					 Object value)
-	throws JasperException
+                                         Object value)
+        throws JasperException
     {
-	try {
+        try {
             Method method = getWriteMethod(bean.getClass(), prop);
-	    method.invoke(bean, new Object[] { value });
-	} catch (Exception ex) {
-	    throw new JasperException(ex);
-	}
+            method.invoke(bean, new Object[] { value });
+        } catch (Exception ex) {
+            throw new JasperException(ex);
+        }
     }
-    
+
     public static void handleSetProperty(Object bean, String prop,
-					 int value)
-	throws JasperException
+                                         int value)
+        throws JasperException
     {
-	try {
+        try {
             Method method = getWriteMethod(bean.getClass(), prop);
-	    method.invoke(bean, new Object[] { new Integer(value) });
-	} catch (Exception ex) {
-	    throw new JasperException(ex);
-	}	
+            method.invoke(bean, new Object[] { new Integer(value) });
+        } catch (Exception ex) {
+            throw new JasperException(ex);
+        }
     }
-    
+
     public static void handleSetProperty(Object bean, String prop,
-					 short value)
-	throws JasperException
+                                         short value)
+        throws JasperException
     {
-	try {
+        try {
             Method method = getWriteMethod(bean.getClass(), prop);
-	    method.invoke(bean, new Object[] { new Short(value) });
-	} catch (Exception ex) {
-	    throw new JasperException(ex);
-	}	
+            method.invoke(bean, new Object[] { new Short(value) });
+        } catch (Exception ex) {
+            throw new JasperException(ex);
+        }
     }
-    
+
     public static void handleSetProperty(Object bean, String prop,
-					 long value)
-	throws JasperException
+                                         long value)
+        throws JasperException
     {
-	try {
+        try {
             Method method = getWriteMethod(bean.getClass(), prop);
-	    method.invoke(bean, new Object[] { new Long(value) });
-	} catch (Exception ex) {
-	    throw new JasperException(ex);
-	}	
-    } 
-    
+            method.invoke(bean, new Object[] { new Long(value) });
+        } catch (Exception ex) {
+            throw new JasperException(ex);
+        }
+    }
+
     public static void handleSetProperty(Object bean, String prop,
-					 double value)
-	throws JasperException
+                                         double value)
+        throws JasperException
     {
-	try {
+        try {
             Method method = getWriteMethod(bean.getClass(), prop);
-	    method.invoke(bean, new Object[] { new Double(value) });
-	} catch (Exception ex) {
-	    throw new JasperException(ex);
-	}	
+            method.invoke(bean, new Object[] { new Double(value) });
+        } catch (Exception ex) {
+            throw new JasperException(ex);
+        }
     }
-    
+
     public static void handleSetProperty(Object bean, String prop,
-					 float value)
-	throws JasperException
+                                         float value)
+        throws JasperException
     {
-	try {
+        try {
             Method method = getWriteMethod(bean.getClass(), prop);
-	    method.invoke(bean, new Object[] { new Float(value) });
-	} catch (Exception ex) {
-	    throw new JasperException(ex);
-	}	
+            method.invoke(bean, new Object[] { new Float(value) });
+        } catch (Exception ex) {
+            throw new JasperException(ex);
+        }
     }
-    
+
     public static void handleSetProperty(Object bean, String prop,
-					 char value)
-	throws JasperException
+                                         char value)
+        throws JasperException
     {
-	try {
+        try {
             Method method = getWriteMethod(bean.getClass(), prop);
-	    method.invoke(bean, new Object[] { new Character(value) });
-	} catch (Exception ex) {
-	    throw new JasperException(ex);
-	}	
+            method.invoke(bean, new Object[] { new Character(value) });
+        } catch (Exception ex) {
+            throw new JasperException(ex);
+        }
     }
 
     public static void handleSetProperty(Object bean, String prop,
-					 byte value)
-	throws JasperException
+                                         byte value)
+        throws JasperException
     {
-	try {
+        try {
             Method method = getWriteMethod(bean.getClass(), prop);
-	    method.invoke(bean, new Object[] { new Byte(value) });
-	} catch (Exception ex) {
-	    throw new JasperException(ex);
-	}	
+            method.invoke(bean, new Object[] { new Byte(value) });
+        } catch (Exception ex) {
+            throw new JasperException(ex);
+        }
     }
-    
+
     public static void handleSetProperty(Object bean, String prop,
-					 boolean value)
-	throws JasperException
+                                         boolean value)
+        throws JasperException
     {
-	try {
+        try {
             Method method = getWriteMethod(bean.getClass(), prop);
-	    method.invoke(bean, new Object[] { new Boolean(value) });
-	} catch (Exception ex) {
-	    throw new JasperException(ex);
-	}	
+            method.invoke(bean, new Object[] { new Boolean(value) });
+        } catch (Exception ex) {
+            throw new JasperException(ex);
+        }
     }
-    
+
     public static Method getWriteMethod(Class beanClass, String prop)
     throws JasperException {
-	Method method = null;	
+        Method method = null;
         Class type = null;
-	try {
-	    java.beans.BeanInfo info
+        try {
+            java.beans.BeanInfo info
                 = java.beans.Introspector.getBeanInfo(beanClass);
-	    if ( info != null ) {
-		java.beans.PropertyDescriptor pd[]
-		    = info.getPropertyDescriptors();
-		for (int i = 0 ; i < pd.length ; i++) {
-		    if ( pd[i].getName().equals(prop) ) {
-			method = pd[i].getWriteMethod();
-			type   = pd[i].getPropertyType();
-			break;
-		    }
-		}
-            } else {        
+            if ( info != null ) {
+                java.beans.PropertyDescriptor pd[]
+                    = info.getPropertyDescriptors();
+                for (int i = 0 ; i < pd.length ; i++) {
+                    if ( pd[i].getName().equals(prop) ) {
+                        method = pd[i].getWriteMethod();
+                        type   = pd[i].getPropertyType();
+                        break;
+                    }
+                }
+            } else {
                 // just in case introspection silently fails.
                 throw new JasperException(
                     Localizer.getMessage("jsp.error.beans.nobeaninfo",
-					 beanClass.getName()));
+                                         beanClass.getName()));
             }
         } catch (Exception ex) {
             throw new JasperException (ex);
         }
         if (method == null) {
             if (type == null) {
-		throw new JasperException(
+                throw new JasperException(
                         Localizer.getMessage("jsp.error.beans.noproperty",
-					     prop,
-					     beanClass.getName()));
+                                             prop,
+                                             beanClass.getName()));
             } else {
-		throw new JasperException(
-		    Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
-					 prop,
-					 type.getName(),
-					 beanClass.getName()));
+                throw new JasperException(
+                    Localizer.getMessage("jsp.error.beans.nomethod.setproperty",
+                                         prop,
+                                         type.getName(),
+                                         beanClass.getName()));
             }
         }
         return method;
     }
 
     public static Method getReadMethod(Class beanClass, String prop)
-	    throws JasperException {
+            throws JasperException {
 
-        Method method = null;        
+        Method method = null;
         Class type = null;
         try {
             java.beans.BeanInfo info
@@ -825,70 +825,70 @@ public class JspRuntimeLibrary {
                         break;
                     }
                 }
-            } else {        
+            } else {
                 // just in case introspection silently fails.
-		throw new JasperException(
+                throw new JasperException(
                     Localizer.getMessage("jsp.error.beans.nobeaninfo",
-					 beanClass.getName()));
-	    }
-	} catch (Exception ex) {
-	    throw new JasperException (ex);
-	}
+                                         beanClass.getName()));
+            }
+        } catch (Exception ex) {
+            throw new JasperException (ex);
+        }
         if (method == null) {
             if (type == null) {
-		throw new JasperException(
+                throw new JasperException(
                     Localizer.getMessage("jsp.error.beans.noproperty", prop,
-					 beanClass.getName()));
+                                         beanClass.getName()));
             } else {
-		throw new JasperException(
+                throw new JasperException(
                     Localizer.getMessage("jsp.error.beans.nomethod", prop,
-					 beanClass.getName()));
+                                         beanClass.getName()));
             }
         }
 
-	return method;
+        return method;
     }
 
     //*********************************************************************
     // PropertyEditor Support
 
     public static Object getValueFromBeanInfoPropertyEditor(
-		           Class attrClass, String attrName, String attrValue,
-			   Class propertyEditorClass) 
-	throws JasperException 
+                           Class attrClass, String attrName, String attrValue,
+                           Class propertyEditorClass)
+        throws JasperException
     {
-	try {
-	    PropertyEditor pe = (PropertyEditor)propertyEditorClass.newInstance();
-	    pe.setAsText(attrValue);
-	    return pe.getValue();
-	} catch (Exception ex) {
-	    throw new JasperException(
+        try {
+            PropertyEditor pe = (PropertyEditor)propertyEditorClass.newInstance();
+            pe.setAsText(attrValue);
+            return pe.getValue();
+        } catch (Exception ex) {
+            throw new JasperException(
                 Localizer.getMessage("jsp.error.beans.property.conversion",
-				     attrValue, attrClass.getName(), attrName,
-				     ex.getMessage()));
-	}
+                                     attrValue, attrClass.getName(), attrName,
+                                     ex.getMessage()));
+        }
     }
 
     public static Object getValueFromPropertyEditorManager(
-	             Class attrClass, String attrName, String attrValue) 
-	throws JasperException 
+                     Class attrClass, String attrName, String attrValue)
+        throws JasperException
     {
-	try {
-	    PropertyEditor propEditor = 
-		PropertyEditorManager.findEditor(attrClass);
-	    if (propEditor != null) {
-		propEditor.setAsText(attrValue);
-		return propEditor.getValue();
-	    } else {
-		throw new IllegalArgumentException(
+        try {
+            PropertyEditor propEditor =
+                PropertyEditorManager.findEditor(attrClass);
+            if (propEditor != null) {
+                propEditor.setAsText(attrValue);
+                return propEditor.getValue();
+            } else {
+                throw new IllegalArgumentException(
                     Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
-	    }
-	} catch (IllegalArgumentException ex) {
-	    throw new JasperException(
+            }
+        } catch (IllegalArgumentException ex) {
+            throw new JasperException(
                 Localizer.getMessage("jsp.error.beans.property.conversion",
-				     attrValue, attrClass.getName(), attrName,
-				     ex.getMessage()));
-	}
+                                     attrValue, attrClass.getName(), attrName,
+                                     ex.getMessage()));
+        }
     }
 
 
@@ -918,13 +918,13 @@ public class JspRuntimeLibrary {
             String pathInfo = (String)
                 request.getAttribute("javax.servlet.include.path_info");
             if (pathInfo == null) {
-                if (uri.lastIndexOf('/') >= 0) 
+                if (uri.lastIndexOf('/') >= 0)
                     uri = uri.substring(0, uri.lastIndexOf('/'));
             }
         }
         else {
             uri = hrequest.getServletPath();
-            if (uri.lastIndexOf('/') >= 0) 
+            if (uri.lastIndexOf('/') >= 0)
                 uri = uri.substring(0, uri.lastIndexOf('/'));
         }
         return uri + '/' + relativePath;
@@ -976,72 +976,72 @@ public class JspRuntimeLibrary {
      * in J2SDK1.4, and should be removed if the only platform supported
      * is 1.4 or higher.
      * @param s The String to be URL encoded.
-     * @param enc The character encoding 
+     * @param enc The character encoding
      * @return The URL encoded String
      */
     public static String URLEncode(String s, String enc) {
 
-	if (s == null) {
-	    return "null";
-	}
-
-	if (enc == null) {
-	    enc = "ISO-8859-1";	// The default request encoding 
-	}
-
-	StringBuffer out = new StringBuffer(s.length());
-	ByteArrayOutputStream buf = new ByteArrayOutputStream();
-	OutputStreamWriter writer = null;
-	try {
-	    writer = new OutputStreamWriter(buf, enc);
-	} catch (java.io.UnsupportedEncodingException ex) {
-	    // Use the default encoding?
-	    writer = new OutputStreamWriter(buf);
-	}
-	
-	for (int i = 0; i < s.length(); i++) {
-	    int c = s.charAt(i);
-	    if (c == ' ') {
-		out.append('+');
-	    } else if (isSafeChar(c)) {
-		out.append((char)c);
-	    } else {
-		// convert to external encoding before hex conversion
-		try {
-		    writer.write(c);
-		    writer.flush();
-		} catch(IOException e) {
-		    buf.reset();
-		    continue;
-		}
-		byte[] ba = buf.toByteArray();
-		for (int j = 0; j < ba.length; j++) {
-		    out.append('%');
-		    // Converting each byte in the buffer
-		    out.append(Character.forDigit((ba[j]>>4) & 0xf, 16));
-		    out.append(Character.forDigit(ba[j] & 0xf, 16));
-		}
-		buf.reset();
-	    }
-	}
-	return out.toString();
+        if (s == null) {
+            return "null";
+        }
+
+        if (enc == null) {
+            enc = "ISO-8859-1";        // The default request encoding
+        }
+
+        StringBuffer out = new StringBuffer(s.length());
+        ByteArrayOutputStream buf = new ByteArrayOutputStream();
+        OutputStreamWriter writer = null;
+        try {
+            writer = new OutputStreamWriter(buf, enc);
+        } catch (java.io.UnsupportedEncodingException ex) {
+            // Use the default encoding?
+            writer = new OutputStreamWriter(buf);
+        }
+
+        for (int i = 0; i < s.length(); i++) {
+            int c = s.charAt(i);
+            if (c == ' ') {
+                out.append('+');
+            } else if (isSafeChar(c)) {
+                out.append((char)c);
+            } else {
+                // convert to external encoding before hex conversion
+                try {
+                    writer.write(c);
+                    writer.flush();
+                } catch(IOException e) {
+                    buf.reset();
+                    continue;
+                }
+                byte[] ba = buf.toByteArray();
+                for (int j = 0; j < ba.length; j++) {
+                    out.append('%');
+                    // Converting each byte in the buffer
+                    out.append(Character.forDigit((ba[j]>>4) & 0xf, 16));
+                    out.append(Character.forDigit(ba[j] & 0xf, 16));
+                }
+                buf.reset();
+            }
+        }
+        return out.toString();
     }
 
     private static boolean isSafeChar(int c) {
-	if (c >= 'a' && c <= 'z') {
-	    return true;
-	}
-	if (c >= 'A' && c <= 'Z') {
-	    return true;
-	}
-	if (c >= '0' && c <= '9') {
-	    return true;
-	}
-	if (c == '-' || c == '_' || c == '.' || c == '!' ||
-	    c == '~' || c == '*' || c == '\'' || c == '(' || c == ')') {
-	    return true;
-	}
-	return false;
+        if (c >= 'a' && c <= 'z') {
+            return true;
+        }
+        if (c >= 'A' && c <= 'Z') {
+            return true;
+        }
+        if (c >= '0' && c <= '9') {
+            return true;
+        }
+        if (c == '-' || c == '_' || c == '.' || c == '!' ||
+            c == '~' || c == '*' || c == '\'' || c == '(' || c == ')') {
+            return true;
+        }
+        return false;
     }
 
 }




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