Methods Summary |
---|
public static Getter | createGetter(java.lang.Class theClass, java.lang.String propertyName)
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 Setter | createSetter(java.lang.Class theClass, java.lang.String propertyName)
BasicSetter result = getSetterOrNull(theClass, propertyName);
if (result==null) {
throw new PropertyNotFoundException(
"Could not find a setter for property " +
propertyName +
" in class " +
theClass.getName()
);
}
return result;
|
public Getter | getGetter(java.lang.Class theClass, java.lang.String propertyName)
return createGetter(theClass, propertyName);
|
private static org.hibernate.property.BasicPropertyAccessor$BasicGetter | getGetterOrNull(java.lang.Class theClass, java.lang.String propertyName)
if (theClass==Object.class || theClass==null) return null;
Method method = getterMethod(theClass, propertyName);
if (method!=null) {
if ( !ReflectHelper.isPublic(theClass, method) ) method.setAccessible(true);
return new BasicGetter(theClass, method, propertyName);
}
else {
BasicGetter getter = getGetterOrNull( theClass.getSuperclass(), propertyName );
if (getter==null) {
Class[] interfaces = theClass.getInterfaces();
for ( int i=0; getter==null && i<interfaces.length; i++ ) {
getter=getGetterOrNull( interfaces[i], propertyName );
}
}
return getter;
}
|
public Setter | getSetter(java.lang.Class theClass, java.lang.String propertyName)
return createSetter(theClass, propertyName);
|
private static org.hibernate.property.BasicPropertyAccessor$BasicSetter | getSetterOrNull(java.lang.Class theClass, java.lang.String propertyName)
if (theClass==Object.class || theClass==null) return null;
Method method = setterMethod(theClass, propertyName);
if (method!=null) {
if ( !ReflectHelper.isPublic(theClass, method) ) method.setAccessible(true);
return new BasicSetter(theClass, method, propertyName);
}
else {
BasicSetter setter = getSetterOrNull( theClass.getSuperclass(), propertyName );
if (setter==null) {
Class[] interfaces = theClass.getInterfaces();
for ( int i=0; setter==null && i<interfaces.length; i++ ) {
setter=getSetterOrNull( interfaces[i], propertyName );
}
}
return setter;
}
|
private static java.lang.reflect.Method | getterMethod(java.lang.Class theClass, java.lang.String propertyName)
Method[] methods = theClass.getDeclaredMethods();
for (int i=0; i<methods.length; i++) {
// only carry on if the method has no parameters
if ( methods[i].getParameterTypes().length==0 ) {
String methodName = methods[i].getName();
// try "get"
if ( methodName.startsWith("get") ) {
String testStdMethod = Introspector.decapitalize( methodName.substring(3) );
String testOldMethod = methodName.substring(3);
if ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) {
return methods[i];
}
}
// if not "get" then try "is"
/*boolean isBoolean = methods[i].getReturnType().equals(Boolean.class) ||
methods[i].getReturnType().equals(boolean.class);*/
if ( methodName.startsWith("is") ) {
String testStdMethod = Introspector.decapitalize( methodName.substring(2) );
String testOldMethod = methodName.substring(2);
if ( testStdMethod.equals(propertyName) || testOldMethod.equals(propertyName) ) {
return methods[i];
}
}
}
}
return null;
|
private static java.lang.reflect.Method | setterMethod(java.lang.Class theClass, java.lang.String propertyName)
BasicGetter getter = getGetterOrNull(theClass, propertyName);
Class returnType = (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;
|