_mappings.put( cls, classMap );
fields = xmlClass.getFields();
for ( int i = 0 ; i < fields.length ; ++i ) {
FieldDescriptor fdesc = fields[ i ];
String fieldName = fdesc.getFieldName();
boolean isContainer = false;
//-- check for collection wrapper
if (introspected && fieldName.startsWith("##container")) {
fdesc = fdesc.getClassDescriptor().getFields()[0];
fieldName = fdesc.getFieldName();
isContainer = true;
}
Class fieldType = fdesc.getFieldType();
//-- check to make sure we can find the accessors...
//-- if we used introspection we don't need to
//-- enter this block...only when descriptors
//-- were generated using the source code generator
//-- or by hand.
if ((!introspected) && fieldName.startsWith(UNDERSCORE)) {
//-- check to see if we need to remove underscore
if (!_mappingLoader.canFindAccessors(cls, fieldName, fieldType))
fieldName = fieldName.substring(1);
//-- check to see if we need to remove "List" prefix
//-- used by generated source code
if (!_mappingLoader.canFindAccessors(cls, fieldName, fieldType))
{
if (fieldName.endsWith("List")) {
int len = fieldName.length()-4;
String tmpName = fieldName.substring(0, len);
if (_mappingLoader.canFindAccessors(cls, tmpName, fieldType))
fieldName = tmpName;
}
}
}
fieldMap = new FieldMapping();
fieldMap.setName( fieldName );
//-- unwrap arrays of objects
boolean isArray = fieldType.isArray();
while (fieldType.isArray())
fieldType = fieldType.getComponentType();
//-- To prevent outputing of optional fields...check
//-- for value first before setting
if (fdesc.isRequired()) fieldMap.setRequired( true );
if (fdesc.isTransient()) fieldMap.setTransient( true );
if ( fdesc.isMultivalued() ) {
//-- special case for collections
if (isContainer) {
//-- backwards than what you'd expect, but
//-- if the collection had a "container" wrapper