}
TypeInfo typeInfo = getTypeInfo( fieldType, colHandler, fieldMap );
ExtendedFieldHandler exfHandler = null;
FieldHandler handler = null;
//-- check for user supplied FieldHandler
if (fieldMap.getHandler() != null) {
Class handlerClass = null;
try {
handlerClass = resolveType( fieldMap.getHandler() );
}
catch (ClassNotFoundException except) {
throw new MappingException( "mapping.classNotFound", fieldMap.getHandler() );
}
if (!FieldHandler.class.isAssignableFrom(handlerClass)) {
String err = "The class '" + fieldMap.getHandler() +
"' must implement " + FieldHandler.class.getName();
throw new MappingException(err);
}
//-- get default constructor to invoke. We can't use the
//-- newInstance method unfortunately becaue FieldHandler
//-- overloads this method
Constructor constructor = null;
try {
constructor = handlerClass.getConstructor(new Class[0]);
handler = (FieldHandler)
constructor.newInstance(new Object[0]);
}
catch(java.lang.Exception except) {
String err = "The class '" + handlerClass.getName() +
"' must have a default public constructor.";
throw new MappingException(err);
}
//-- ExtendedFieldHandler?
if (handler instanceof ExtendedFieldHandler) {
exfHandler = (ExtendedFieldHandler) handler;
}
//-- Fix for Castor JDO from Steve Vaughan, Castor JDO
//-- requires FieldHandlerImpl or a ClassCastException
//-- will be thrown... [KV 20030131 - also make sure this new handler
//-- doesn't use it's own CollectionHandler otherwise
//-- it'll cause unwanted calls to the getValue method during
//-- unmarshalling]
colHandler = typeInfo.getCollectionHandler();
typeInfo.setCollectionHandler(null);
handler = new FieldHandlerImpl(handler, typeInfo);
typeInfo.setCollectionHandler(colHandler);
//-- End Castor JDO fix
}
boolean generalized = (exfHandler instanceof GeneralizedFieldHandler);
//-- if generalized we need to change the fieldType to whatever
//-- is specified in the GeneralizedFieldHandler so that the
//-- correct getter/setter methods can be found
FieldHandler custom = handler;
if (generalized) {
fieldType = ((GeneralizedFieldHandler)exfHandler).getFieldType();
}
if (generalized || (handler == null)) {