📄 jspruntimelibrary.java
字号:
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}); } } catch (Exception ex) { throw new JasperException ("error in invoking method"); } } /** * Escape special shell characters. * @param unescString The string to shell-escape * @return The escaped shell string. */ 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); if( shellSpChars.indexOf(nextChar) != -1 ) escString += "\\"; escString += nextChar; } return escString; } /** * Decode an URL formatted string. * @param s The string to decode. * @return The decoded string. */ public static String decode(String encoded) { // speedily leave if we're not needed if (encoded == null) return null; if (encoded.indexOf('%') == -1 && encoded.indexOf('+') == -1) return encoded; //allocate the buffer - use byte[] to avoid calls to new. byte holdbuffer[] = new byte[encoded.length()]; char holdchar; int bufcount = 0; for (int count = 0; count < encoded.length(); count++) { char cur = encoded.charAt(count); if (cur == '%') { holdbuffer[bufcount++] = (byte)Integer.parseInt(encoded.substring(count+1,count+3),16); if (count + 2 >= encoded.length()) count = encoded.length(); else count += 2; } else if (cur == '+') { holdbuffer[bufcount++] = (byte) ' '; } else { holdbuffer[bufcount++] = (byte) cur; } } // REVISIT -- remedy for Deprecated warning. //return new String(holdbuffer,0,0,bufcount); return new String(holdbuffer,0,bufcount); } // __begin lookupReadMethodMethod public static Object handleGetProperty(Object o, String prop) throws JasperException { if (o == null) { throw new JasperException(Constants.getString( "jsp.error.beans.nullbean", new Object[] {})); } Object value = null; try { java.lang.reflect.Method method = getReadMethod(o.getClass(), prop); value = method.invoke(o, null); } catch (Exception ex) { throw new JasperException (ex); } return value; } // __end lookupReadMethodMethod public static void handleSetProperty(Object bean, String prop, Object value) throws JasperException { try { Method method = getWriteMethod(bean.getClass(), prop); 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 { try { Method method = getWriteMethod(bean.getClass(), prop); 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 { try { Method method = getWriteMethod(bean.getClass(), prop); 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 { try { Method method = getWriteMethod(bean.getClass(), prop); 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 { try { Method method = getWriteMethod(bean.getClass(), prop); 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 { try { Method method = getWriteMethod(bean.getClass(), prop); 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 { try { Method method = getWriteMethod(bean.getClass(), prop); 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 { try { Method method = getWriteMethod(bean.getClass(), prop); 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 { try { Method method = getWriteMethod(bean.getClass(), prop); method.invoke(bean, new Object[] { new Boolean(value) }); } catch (Exception ex) { throw new JasperException(ex); } } public static java.lang.reflect.Method getWriteMethod(Class beanClass, String prop) throws JasperException { java.lang.reflect.Method method = null; Class type = null; 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 { // just in case introspection silently fails. throw new JasperException(Constants.getString( "jsp.error.beans.nobeaninfo", new Object[] {beanClass.getName()})); } } catch (Exception ex) { throw new JasperException (ex); } if (method == null) { if (type == null) { throw new JasperException(Constants.getString( "jsp.error.beans.noproperty", new Object[] {prop, beanClass.getName()})); } else { throw new JasperException(Constants.getString( "jsp.error.beans.nomethod.setproperty", new Object[] {prop, beanClass.getName()})); } } return method; } public static java.lang.reflect.Method getReadMethod(Class beanClass, String prop) throws JasperException { java.lang.reflect.Method method = null; Class type = null; 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].getReadMethod(); type = pd[i].getPropertyType(); break; } } } else { // just in case introspection silently fails. throw new JasperException(Constants.getString( "jsp.error.beans.nobeaninfo", new Object[] {beanClass.getName()})); } } catch (Exception ex) { throw new JasperException (ex); } if (method == null) { if (type == null) { throw new JasperException(Constants.getString( "jsp.error.beans.noproperty", new Object[] {prop, beanClass.getName()})); } else { throw new JasperException(Constants.getString( "jsp.error.beans.nomethod", new Object[] {prop, beanClass.getName()})); } } return method; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -