prop.setXmlPath(xpath);
prop.setSchemaName(new QName(pname));
// figure out the type based on transformer method return type
JavaClass jType = null;
JavaClass jClass = null;
JavaMethod jMethod = null;
String methodName;
if (writeTransformer.isSetTransformerClass()) {
// handle transformer class
try {
jClass = helper.getJavaClass(writeTransformer.getTransformerClass());
} catch (JAXBException x) {
throw JAXBException.transformerClassNotFound(writeTransformer.getTransformerClass());
}
methodName = BUILD_FIELD_VALUE_METHOD;
jMethod = jClass.getDeclaredMethod(methodName, new JavaClass[] { helper.getJavaClass(Object.class), helper.getJavaClass(String.class), helper.getJavaClass(Session.class) });
if (jMethod == null) {
throw JAXBException.noSuchWriteTransformationMethod(methodName);
}
jType = jMethod.getReturnType();
} else {
// handle method
// here it is assumed that the JavaModel is aware of the TypeInfo's class, hence jClass cannot be null
jClass = helper.getJavaClass(typeInfo.getJavaClassName());
methodName = writeTransformer.getMethod();
// the method can have 0 args or 1 arg (either AbstractSession or Session)
// first check 0 arg
jMethod = jClass.getDeclaredMethod(methodName, new JavaClass[] {});
if (jMethod == null) {
// try AbstractSession
jMethod = jClass.getDeclaredMethod(methodName, new JavaClass[] { helper.getJavaClass(AbstractSession.class) });
if (jMethod == null) {
// try Session
jMethod = jClass.getDeclaredMethod(methodName, new JavaClass[] { helper.getJavaClass(Session.class) });
if (jMethod == null) {
throw JAXBException.noSuchWriteTransformationMethod(methodName);
}
}
}
jType = jMethod.getReturnType();
}
prop.setType(jType);
props.add(prop);
}
addToSchemaType(typeInfo, props, compositor, type, schema);