in commons-transfer/commons-transfer-interactive/src/main/java/org/apache/archiva/commons/transfer/interactive/swing/ActionMapper.java [57:121]
public ActionMapper( Object commandObj )
{
log.debug( "Finding action methods for " + commandObj.getClass().getName() );
commandMap = new HashMap<String, Method>();
commandObject = commandObj;
Pattern namePat = Pattern.compile( "do[A-Z][a-z].*" );
Method methods[] = commandObject.getClass().getMethods();
for ( Method method : methods )
{
int modifiers = method.getModifiers();
String name = method.getName();
Object params[] = method.getParameterTypes();
Matcher mat = namePat.matcher( name );
if ( !mat.matches() )
{
// log.debug( "Method " + name + " not an application command."
// );
continue;
}
if ( !Modifier.isPublic( modifiers ) || Modifier.isAbstract( modifiers ) || Modifier.isNative( modifiers )
|| Modifier.isStatic( modifiers ) )
{
log.debug( "Method " + name + " is has wrong modifiers." );
continue;
}
if ( ( params == null ) || ( params.length < 1 ) || ( params.length > 1 ) )
{
log.debug( "Method " + name + " has wrong number of parameters." );
continue;
}
Object param = params[0];
if ( param instanceof ActionEvent )
{
String commandName = name.substring( 2 ).toLowerCase();
commandMap.put( commandName, method );
}
else if ( param instanceof Class )
{
Class<?> pclass = (Class<?>) param;
if ( pclass.isAssignableFrom( ActionEvent.class ) )
{
String commandName = name.substring( 2 ).toLowerCase();
commandMap.put( commandName, method );
}
else
{
log.warn( "Method " + name + " has wrong parameter type class. Expected "
+ ActionEvent.class.getName() + " but found " + pclass.getName() + " instead." );
}
}
else
{
log.warn( "Method " + name + " has wrong parameter type. Expected " + ActionEvent.class.getName()
+ " but found " + param.getClass().getName() + " instead." );
}
}
log.debug( "Done with ActionMapper()" );
}