private Object invokeStaticMethod ( Class pClass , String pMethod , Object pParam ) { Object value = null ; try { // Create param and argument arrays Class [ ] param = { pParam . getClass ( ) } ; Object [ ] arg = { pParam } ; // Get method // *** If more than one such method is found in the class, and one // of these methods has a RETURN TYPE that is more specific than // any of the others, that method is reflected; otherwise one of // the methods is chosen ARBITRARILY. // java/lang/Class.html#getMethod(java.lang.String, java.lang.Class[]) java . lang . reflect . Method method = pClass . getMethod ( pMethod , param ) ; // Invoke public static method if ( Modifier . isPublic ( method . getModifiers ( ) ) && Modifier . isStatic ( method . getModifiers ( ) ) ) { value = method . invoke ( null , arg ) ; } } catch ( Exception e ) { return null ; } return value ; }
Creates an object from any given static method given the parameter