urnType = (getter==null) ? null : getter.getReturnType();
Method[] methods = theClass.getDeclaredMethods();
Method potentialSetter = null;
for (int i=0; i<methods.length; i++) {
String methodName = methods[i].getName();
if ( methods[i].getParameterTypes().length==1 && methodName.startsWith("set") ) {
String testStdMethod = Introspector.decapitalize( methodName.substring(3) );
String testOldMethod = methodName.substring(3);
if ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) {
potentialSetter = methods[i];
if ( returnType==null || methods[i].getParameterTypes()[0].equals(returnType) ) {
return potentialSetter;
}
}
}
}
return potentialSetter;
}
public Getter getGetter(Class theClass, String propertyName)
throws PropertyNotFoundException {
return createGetter(theClass, propertyName);
}
public static Getter createGetter(Class theClass, String propertyName)
throws PropertyNotFoundException {
BasicGetter result = getGetterOrNull(theClass, propertyName);
if (result==null) {
throw new PropertyNotFoundException(
"Could not find a getter for " +
propertyName +
" in class " +
theClass.getName()
);
}
return result;
}
private static BasicGetter getGetterOrNull(Class theClass, String propertyName) {
if (theClass==Object.class || theClass==null) return null;
Method method = getterMethod(theClass, propertyName);
if (method!=nul
上一篇:
BasicPlayerListener.java
下一篇:
"夜"