Index: src/main/org/exolab/castor/mapping/loader/FieldHandlerImpl.java =================================================================== RCS file: /cvs/castor/castor/src/main/org/exolab/castor/mapping/loader/FieldHandlerImpl.java,v retrieving revision 1.2 diff -u -p -d -r1.2 FieldHandlerImpl.java --- a/src/main/org/exolab/castor/mapping/loader/FieldHandlerImpl.java 16 Apr 2003 07:15:35 -0000 1.2 +++ b/src/main/org/exolab/castor/mapping/loader/FieldHandlerImpl.java 23 Oct 2004 11:36:41 -0000 @@ -49,17 +49,18 @@ package org.exolab.castor.mapping.loader import java.lang.reflect.Array; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.lang.reflect.InvocationTargetException; +import java.util.Vector; + import org.exolab.castor.mapping.AbstractFieldHandler; +import org.exolab.castor.mapping.CollectionHandler; import org.exolab.castor.mapping.ExtendedFieldHandler; import org.exolab.castor.mapping.FieldHandler; -import org.exolab.castor.mapping.TypeConvertor; -import org.exolab.castor.mapping.CollectionHandler; import org.exolab.castor.mapping.MappingException; import org.exolab.castor.mapping.MappingRuntimeException; -import org.exolab.castor.mapping.ValidityException; +import org.exolab.castor.mapping.TypeConvertor; import org.exolab.castor.util.Messages; @@ -78,8 +79,6 @@ import org.exolab.castor.util.Messages; public final class FieldHandlerImpl extends AbstractFieldHandler { - - /** * The prefix for an "add" method **/ @@ -95,62 +94,62 @@ public final class FieldHandlerImpl /** * 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; /** @@ -281,14 +280,14 @@ public final class FieldHandlerImpl * 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; @@ -303,18 +302,29 @@ public final class FieldHandlerImpl _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