Index: org/exolab/castor/mapping/loader/FieldHandlerImpl.java =================================================================== RCS file: /scm/castor/castor/src/main/org/exolab/castor/mapping/loader/FieldHandlerImpl.java,v retrieving revision 1.4 diff -u -r1.4 FieldHandlerImpl.java --- org/exolab/castor/mapping/loader/FieldHandlerImpl.java 5 Mar 2005 13:41:52 -0000 1.4 +++ org/exolab/castor/mapping/loader/FieldHandlerImpl.java 5 Mar 2005 18:17:49 -0000 @@ -47,6 +47,7 @@ package org.exolab.castor.mapping.loader; +import java.util.Vector; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -77,8 +78,6 @@ public final class FieldHandlerImpl extends AbstractFieldHandler { - - /** * The prefix for an "add" method **/ @@ -94,62 +93,62 @@ /** * The Java field described and accessed through this descriptor. */ - private final Field _field; + private final Field _field; /** * The sequence of methods used to obtain the nested field. May be null. */ - private Method[] _getSequence; + private Method[] _getSequence; /** * The sequence of methods used to create the nested object. May be null. */ - private Method[] _setSequence; + private Method[] _setSequence; /** * The method used to "incrementally" set the value of this field. * This is only used if the field is a collection */ - private Method _addMethod; + private Vector _addMethods; /** * The method used to obtain the value of this field. May be null. */ - private Method _getMethod; + private Method _getMethod; /** - * The method used to set the value of this field. May be null. + * The available methods to be used to set the value of this field. May be null. */ - private Method _setMethod; + private Vector _setMethods; /** * The method used to check if the value of this field exists. May be null. */ - private Method _hasMethod; + private Method _hasMethod; /** * The method used to delete the value of this field. May be null. */ - private Method _deleteMethod; + private Method _deleteMethod; /** * The method used to create a new instance of the field. */ - private Method _createMethod; + private Method _createMethod; /** * The Java field name. */ - private final String _fieldName; + private final String _fieldName; /** @@ -280,14 +279,14 @@ * must accept no parameters and have a return type castable to * the field type * @param setMethod The method used to set the field value, must - * accept a single paramater that is castable to the field type + * accept a single parameter that is castable to the field type * @param typeInfo Type information * @throws MappingException If the get or set method are not public, * are static, or do not specify the proper types * */ public FieldHandlerImpl( String fieldName, Method[] getSequence, Method[] setSequence, - Method getMethod, Method setMethod, TypeInfo typeInfo ) + Method getMethod, Vector setMethods, TypeInfo typeInfo ) throws MappingException { _handler = null; @@ -302,18 +301,29 @@ _getSequence = getSequence; _setSequence = setSequence; - if ( setMethod != null ) { - //-- might be an "add" method - if ( setMethod.getName().startsWith(ADD_PREFIX) ) { - Class pType = setMethod.getParameterTypes()[0]; - if (pType != typeInfo.getFieldType() ) - setAddMethod (setMethod); - else - setWriteMethod(setMethod); + if (setMethods!=null && !setMethods.isEmpty()) { + //-- There might be "add" methods. + Vector addMethods = new Vector(); + + for(int i=0; i