private static void setProperty ( Object obj , PropertyDescriptor pd , String value , boolean doTraceValue ) throws Exception { Object param = null ; String propName = pd . getName ( ) ; if ( tc . isDebugEnabled ( ) ) { if ( "URL" . equals ( propName ) || "url" . equals ( propName ) ) { Tr . debug ( tc , "set " + propName + " = " + PropertyService . filterURL ( value ) ) ; } else { Tr . debug ( tc , "set " + propName + " = " + ( doTraceValue ? value : "******" ) ) ; } } java . lang . reflect . Method setter = pd . getWriteMethod ( ) ; if ( setter == null ) throw new NoSuchMethodException ( AdapterUtil . getNLSMessage ( "NO_SETTER_METHOD" , propName ) ) ; Class < ? > paramType = setter . getParameterTypes ( ) [ 0 ] ; if ( ! paramType . isPrimitive ( ) ) { if ( paramType . equals ( String . class ) ) // the most common case: String param = value ; else if ( paramType . equals ( Properties . class ) ) // special case: Properties param = AdapterUtil . toProperties ( value ) ; else if ( paramType . equals ( Character . class ) ) // special case: Character param = Character . valueOf ( value . charAt ( 0 ) ) ; else // the generic case: any object with a single parameter String constructor param = paramType . getConstructor ( String . class ) . newInstance ( value ) ; } else if ( paramType . equals ( int . class ) ) param = Integer . valueOf ( value ) ; else if ( paramType . equals ( long . class ) ) param = Long . valueOf ( value ) ; else if ( paramType . equals ( boolean . class ) ) param = Boolean . valueOf ( value ) ; else if ( paramType . equals ( double . class ) ) param = Double . valueOf ( value ) ; else if ( paramType . equals ( float . class ) ) param = Float . valueOf ( value ) ; else if ( paramType . equals ( short . class ) ) param = Short . valueOf ( value ) ; else if ( paramType . equals ( byte . class ) ) param = Byte . valueOf ( value ) ; else if ( paramType . equals ( char . class ) ) param = Character . valueOf ( value . charAt ( 0 ) ) ; setter . invoke ( obj , new Object [ ] { param } ) ; }
Handles the setting of any property for which a public single - parameter setter exists on the DataSource and for which the property data type is either a primitive or has a single - parameter String constructor .