Index: foundation/org.eclipse.persistence.core/resource/xsd/eclipselink_persistence_map_1.1.xsd =================================================================== --- foundation/org.eclipse.persistence.core/resource/xsd/eclipselink_persistence_map_1.1.xsd (revision 4170) +++ foundation/org.eclipse.persistence.core/resource/xsd/eclipselink_persistence_map_1.1.xsd (working copy) @@ -2091,6 +2091,22 @@ + + + List converter + + + + + + + Specifies the fully qualified class name of the list's element type. + + + + + + Typesafe Enumeration conversion @@ -3407,7 +3423,7 @@ - + Index: foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLConversionManager.java =================================================================== --- foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLConversionManager.java (revision 4170) +++ foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/oxm/XMLConversionManager.java (working copy) @@ -18,6 +18,7 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collection; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; @@ -36,6 +37,7 @@ import org.eclipse.persistence.exceptions.XMLConversionException; import org.eclipse.persistence.internal.helper.*; import org.eclipse.persistence.internal.oxm.conversion.Base64; +import org.eclipse.persistence.internal.queries.ContainerPolicy; import org.eclipse.persistence.oxm.XMLConstants; /** @@ -1687,19 +1689,39 @@ } return list; } + + /** + * Convert the given sourceObject (String) to the appropriate collection type specified by the + * containerPolicy, using the elementType to properly convert each element of the list. + * + * @param sourceObject - will always be a string if read from XML + * @param elementType - the type of the elements contained in the list + * @return - the newly converted object + */ + public Object convertStringToList(Object sourceObject, Class elementType, ContainerPolicy containerPolicy) throws ConversionException { + Collection collection = (Collection) containerPolicy.containerInstance(); + + if (sourceObject instanceof String) { + StringTokenizer tokenizer = new StringTokenizer((String) sourceObject, " "); + while (tokenizer.hasMoreElements()) { + String token = tokenizer.nextToken(); + collection.add(convertObject(token, elementType)); + } + } + + return collection; + } - protected String convertListToString(Object sourceObject) throws ConversionException { + public String convertListToString(Object sourceObject) throws ConversionException { String returnString = new String(); if (sourceObject instanceof List) { List list = (List) sourceObject; for (int i = 0; i < list.size(); i++) { Object next = list.get(i); - if (next instanceof String) { if (i > 0) { returnString += " "; } - returnString = returnString + next; - } + returnString = returnString + convertObjectToString(next); } } return returnString; Index: foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/factories/EclipseLinkObjectPersistenceRuntimeXMLProject.java =================================================================== --- foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/factories/EclipseLinkObjectPersistenceRuntimeXMLProject.java (revision 4170) +++ foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/factories/EclipseLinkObjectPersistenceRuntimeXMLProject.java (working copy) @@ -16,7 +16,6 @@ import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI; import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -// EclipseLink imports import org.eclipse.persistence.descriptors.ClassDescriptor; import org.eclipse.persistence.internal.helper.NonSynchronizedVector; import org.eclipse.persistence.mappings.converters.Converter; @@ -27,6 +26,7 @@ import org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping; import org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping; import org.eclipse.persistence.oxm.mappings.XMLDirectMapping; +import org.eclipse.persistence.oxm.mappings.converters.XMLListConverter; import org.eclipse.persistence.oxm.mappings.nullpolicy.NullPolicy; import org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference; import org.eclipse.persistence.queries.DatabaseQuery; @@ -59,8 +59,9 @@ @Override public void buildDescriptors() { super.buildDescriptors(); - - // Any new mappings go after call to super.buildDescriptors(); + // Any new mappings go after call to super.buildDescriptors(); + + addDescriptor(buildXMLListConverterDescriptor()); } @Override @@ -235,5 +236,27 @@ return descriptor; } - + + protected ClassDescriptor buildConverterDescriptor() { + ClassDescriptor descriptor = super.buildConverterDescriptor(); + descriptor.getInheritancePolicy().addClassIndicator(XMLListConverter.class, getPrimaryNamespaceXPath() + "xml-list-converter"); + return descriptor; + } + + protected ClassDescriptor buildXMLListConverterDescriptor() { + XMLDescriptor descriptor = new XMLDescriptor(); + descriptor.setJavaClass(XMLListConverter.class); + + descriptor.getInheritancePolicy().setParentClass(Converter.class); + + XMLDirectMapping fieldSubElementClassNameMapping = new XMLDirectMapping(); + fieldSubElementClassNameMapping.setAttributeName("objectClassName"); + fieldSubElementClassNameMapping.setGetMethodName("getObjectClassName"); + fieldSubElementClassNameMapping.setSetMethodName("setObjectClassName"); + fieldSubElementClassNameMapping.setXPath(getPrimaryNamespaceXPath() + "object-class-name"); + descriptor.addMapping(fieldSubElementClassNameMapping); + + return descriptor; + } + } \ No newline at end of file Index: foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/mappings/converters/XMLListConverter.java =================================================================== --- foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/mappings/converters/XMLListConverter.java (revision 0) +++ foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/oxm/mappings/converters/XMLListConverter.java (revision 0) @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 1998, 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 + * which accompanies this distribution. + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * rbarkhouse - 2009-05-05 14:32:00 - initial implementation + ******************************************************************************/ +package org.eclipse.persistence.oxm.mappings.converters; + +import java.security.AccessController; +import java.security.PrivilegedActionException; + +import org.eclipse.persistence.exceptions.ValidationException; +import org.eclipse.persistence.internal.oxm.XMLConversionManager; +import org.eclipse.persistence.internal.security.PrivilegedClassForName; +import org.eclipse.persistence.mappings.DatabaseMapping; +import org.eclipse.persistence.mappings.converters.Converter; +import org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping; +import org.eclipse.persistence.sessions.Session; + +public class XMLListConverter implements Converter { + + private XMLConversionManager conversionManager; + private XMLCompositeDirectCollectionMapping mapping; + private Class objectClass = null; + private String objectClassName = null; + + public Object convertDataValueToObjectValue(Object dataValue, Session session) { + XMLCompositeDirectCollectionMapping dcMapping = (XMLCompositeDirectCollectionMapping) this.mapping; + return this.conversionManager.convertStringToList(dataValue, getObjectClass(), dcMapping.getContainerPolicy()); + } + + public Object convertObjectValueToDataValue(Object objectValue, Session session) { + return this.conversionManager.convertListToString(objectValue); + } + + public void initialize(DatabaseMapping mapping, Session session) { + this.conversionManager = (XMLConversionManager) session.getDatasourcePlatform().getConversionManager(); + this.mapping = (XMLCompositeDirectCollectionMapping) mapping; + + try { + if (getObjectClassName() != null) { + ClassLoader loader = session.getDatasourcePlatform().getConversionManager().getLoader(); + Class aClass = (Class) AccessController.doPrivileged(new PrivilegedClassForName(getObjectClassName(), true, loader)); + setObjectClass(aClass); + } + } catch (PrivilegedActionException pae) { + throw ValidationException.classNotFoundWhileConvertingClassNames(getObjectClassName(), pae.getException()); + } + } + + public boolean isMutable() { + return false; + } + + /** + * Get the Class name of the elements of this collection's "sub-collection". + * Only applicable for DirectCollections of Lists (for example, for an + * ArrayList<ArrayList<Double>>, FieldSubElementClassName would be "java.lang.Double"). + * @return String the name of the Class of the elements of this collection's "sub-collection" + */ + public String getObjectClassName() { + return objectClassName; + } + + /** + * Set the Class name of the elements of this collection's "sub-collection". + * Only applicable for DirectCollections of Lists (for example, for an + * ArrayList<ArrayList<Double>>, FieldSubElementClassName would be "java.lang.Double"). + * @param aClassName the name of the Class of the elements of this collection's "sub-collection" + */ + public void setObjectClassName(String aClassName) { + objectClassName = aClassName; + } + + /** + * Get the Class of the elements of this collection's "sub-collection". + * Only applicable for DirectCollections of Lists (for example, for an + * ArrayList<ArrayList<Double>>, FieldSubElementClass would be java.lang.Double.class). + * @return Class the Class of the elements of this collection's "sub-collection" + */ + public Class getObjectClass() { + return objectClass; + } + + /** + * Set the Class of the elements of this collection's "sub-collection". + * Only applicable for DirectCollections of Lists (for example, for an + * ArrayList<ArrayList<Double>>, FieldSubElementClass would be java.lang.Double.class). + * @param aClass the Class of the elements of this collection's "sub-collection" + */ + public void setObjectClass(Class aClass) { + this.objectClass = aClass; + if (this.objectClassName == null) { + this.objectClassName = aClass.getName(); + } + } + +} \ No newline at end of file Index: moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml =================================================================== --- moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml (revision 0) +++ moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml (revision 0) @@ -0,0 +1,4 @@ + + 1.2 3.4 5.6 + -7.8 -9.0 -1.2 + \ No newline at end of file Index: moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml =================================================================== --- moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml (revision 0) +++ moxy/eclipselink.moxy.test/resource/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml (revision 0) @@ -0,0 +1,4 @@ + + 1.2 3.4 5.6 + -7.8 -9.0 -1.2 + \ No newline at end of file Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/DirectCollectionMappingTestSuite.java =================================================================== --- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/DirectCollectionMappingTestSuite.java (revision 4170) +++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/DirectCollectionMappingTestSuite.java (working copy) @@ -44,6 +44,7 @@ import org.eclipse.persistence.testing.oxm.mappings.directcollection.identifiedbyposition.withgroupingelement.DirectCollectionWithGroupingElementIdentifiedByPositionEmptyTestCases; import org.eclipse.persistence.testing.oxm.mappings.directcollection.identifiedbyposition.withgroupingelement.DirectCollectionWithGroupingElementIdentifiedByPositionNullTestCases; import org.eclipse.persistence.testing.oxm.mappings.directcollection.identifiedbyposition.withgroupingelement.DirectCollectionWithGroupingElementIdentifiedByPositionTestCases; +import org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists.XMLDirectCollectionOfListsTestCases; import org.eclipse.persistence.testing.oxm.mappings.directcollection.nillable.DirectCollectionIsSetNodeNullPolicyTrueTestCases; import org.eclipse.persistence.testing.oxm.mappings.directcollection.nillable.DirectCollectionNillableNodeNullPolicyTestCases; import org.eclipse.persistence.testing.oxm.mappings.directcollection.nillable.DirectCollectionOptionalNodeNullPolicyAttributeTestCases; @@ -106,13 +107,15 @@ // UC2b //suite.addTestSuite(DirectCollectionOptionalNodeNullPolicyAttributeTestCases.class);// 6 of 6 pass by default // UC3 - // see #5876860: we are turning off failing Nillable tests for collections until the feature is implemented + // see #5876860: we are turning off failing Nillable tests for collections until the feature is implemented //suite.addTestSuite(DirectCollectionNillableNodeNullPolicyTestCases.class);// 3 of 6 pass until implementation set // UC4-true - // see #5876860: we are turning off failing Nillable tests for collections until the feature is implemented + // see #5876860: we are turning off failing Nillable tests for collections until the feature is implemented //suite.addTestSuite(DirectCollectionIsSetNodeNullPolicyTrueTestCases.class);// 3 of 6 pass until implementation set // UC4-false - n/a - + + suite.addTestSuite(XMLDirectCollectionOfListsTestCases.class); + return suite; } @@ -121,4 +124,5 @@ //junit.swingui.TestRunner.main(arguments); junit.textui.TestRunner.main(arguments); } + } \ No newline at end of file Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/Root.java =================================================================== --- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/Root.java (revision 0) +++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/Root.java (revision 0) @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 1998, 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 + * which accompanies this distribution. + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * rbarkhouse - 2009-05-05 14:32:00 - initial implementation + ******************************************************************************/ +package org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +public class Root { + + public ArrayList> items = new ArrayList>(); + + public ArrayList> getItems() { + return this.items; + } + + public boolean equals(Object obj) { + if (!(obj instanceof Root)) { + return false; + } + + Root otherRoot = (Root) obj; + + if (this.items.size() != otherRoot.items.size()) { + return false; + } + + return this.items.equals(otherRoot.items); + } + +} \ No newline at end of file Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/RootProject.java =================================================================== --- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/RootProject.java (revision 0) +++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/RootProject.java (revision 0) @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 1998, 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 + * which accompanies this distribution. + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * rbarkhouse - 2009-05-05 14:32:00 - initial implementation + ******************************************************************************/ +package org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists; + +import java.util.ArrayList; + +import org.eclipse.persistence.oxm.XMLConstants; +import org.eclipse.persistence.oxm.XMLDescriptor; +import org.eclipse.persistence.oxm.XMLField; +import org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping; +import org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping; +import org.eclipse.persistence.oxm.mappings.XMLDirectMapping; +import org.eclipse.persistence.oxm.mappings.converters.XMLListConverter; +import org.eclipse.persistence.sessions.Project; + +public class RootProject extends Project { + + public RootProject() { + addDescriptor(getRootDescriptor()); + } + + private XMLDescriptor getRootDescriptor() { + XMLDescriptor descriptor = new XMLDescriptor(); + descriptor.setJavaClass(Root.class); + descriptor.setDefaultRootElement("root"); + + XMLCompositeDirectCollectionMapping itemsMapping = new XMLCompositeDirectCollectionMapping(); + itemsMapping.setAttributeName("items"); + itemsMapping.setXPath("item/text()"); + itemsMapping.setFieldElementClass(ArrayList.class); + itemsMapping.useCollectionClass(ArrayList.class); + + XMLListConverter listConverter = new XMLListConverter(); + listConverter.setObjectClass(Double.class); + itemsMapping.setValueConverter(listConverter); + + descriptor.addMapping(itemsMapping); + return descriptor; + } + +} \ No newline at end of file Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/XMLDirectCollectionOfListsTestCases.java =================================================================== --- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/XMLDirectCollectionOfListsTestCases.java (revision 0) +++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/XMLDirectCollectionOfListsTestCases.java (revision 0) @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 1998, 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 + * which accompanies this distribution. + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * rbarkhouse - 2009-05-05 14:32:00 - initial implementation + ******************************************************************************/ +package org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists; + +import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.util.ArrayList; + +import javax.lang.model.element.TypeParameterElement; + +import org.eclipse.persistence.testing.oxm.mappings.XMLMappingTestCases; + +public class XMLDirectCollectionOfListsTestCases extends XMLMappingTestCases { + + private final static String XML_RESOURCE = "org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml"; + + public XMLDirectCollectionOfListsTestCases(String name) throws Exception { + super(name); + setControlDocument(XML_RESOURCE); + setProject(new RootProject()); + } + + protected Object getControlObject() { + Root root = new Root(); + + ArrayList values1 = new ArrayList(); + values1.add(Double.valueOf(1.2)); + values1.add(Double.valueOf(3.4)); + values1.add(Double.valueOf(5.6)); + + ArrayList values2 = new ArrayList(); + values2.add(Double.valueOf(-7.8)); + values2.add(Double.valueOf(-9.0)); + values2.add(Double.valueOf(-1.2)); + + ArrayList> itemCollection = new ArrayList>(); + itemCollection.add(values1); + itemCollection.add(values2); + + root.items = itemCollection; + + return root; + } + +} \ No newline at end of file Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/Root.java =================================================================== --- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/Root.java (revision 0) +++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/Root.java (revision 0) @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 1998, 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 + * which accompanies this distribution. + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * rbarkhouse - 2009-05-05 14:32:00 - initial implementation + ******************************************************************************/ +package org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +public class Root { + + public ArrayList> items = new ArrayList>(); + + public ArrayList> getItems() { + return this.items; + } + + public boolean equals(Object obj) { + if (!(obj instanceof Root)) { + return false; + } + + Root otherRoot = (Root) obj; + + if (this.items.size() != otherRoot.items.size()) { + return false; + } + + return this.items.equals(otherRoot.items); + } + +} \ No newline at end of file Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/RootProject.java =================================================================== --- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/RootProject.java (revision 0) +++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/RootProject.java (revision 0) @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 1998, 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 + * which accompanies this distribution. + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * rbarkhouse - 2009-05-05 14:32:00 - initial implementation + ******************************************************************************/ +package org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists; + +import java.util.ArrayList; + +import org.eclipse.persistence.oxm.XMLConstants; +import org.eclipse.persistence.oxm.XMLDescriptor; +import org.eclipse.persistence.oxm.XMLField; +import org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping; +import org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping; +import org.eclipse.persistence.oxm.mappings.XMLDirectMapping; +import org.eclipse.persistence.oxm.mappings.converters.XMLListConverter; +import org.eclipse.persistence.sessions.Project; + +public class RootProject extends Project { + + public RootProject() { + addDescriptor(getRootDescriptor()); + } + + private XMLDescriptor getRootDescriptor() { + XMLDescriptor descriptor = new XMLDescriptor(); + descriptor.setJavaClass(Root.class); + descriptor.setDefaultRootElement("root"); + + XMLCompositeDirectCollectionMapping itemsMapping = new XMLCompositeDirectCollectionMapping(); + itemsMapping.setAttributeName("items"); + itemsMapping.setXPath("item/text()"); + itemsMapping.setFieldElementClass(ArrayList.class); + itemsMapping.useCollectionClass(ArrayList.class); + + XMLListConverter listConverter = new XMLListConverter(); + listConverter.setObjectClass(Double.class); + itemsMapping.setValueConverter(listConverter); + + descriptor.addMapping(itemsMapping); + return descriptor; + } + +} \ No newline at end of file Index: moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/XMLDirectCollectionOfListsTestCases.java =================================================================== --- moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/XMLDirectCollectionOfListsTestCases.java (revision 0) +++ moxy/eclipselink.moxy.test/src/org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/XMLDirectCollectionOfListsTestCases.java (revision 0) @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 1998, 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 + * which accompanies this distribution. + * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * rbarkhouse - 2009-05-05 14:32:00 - initial implementation + ******************************************************************************/ +package org.eclipse.persistence.testing.oxm.mappings.directcollection.listoflists; + +import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.util.ArrayList; + +import javax.lang.model.element.TypeParameterElement; + +import org.eclipse.persistence.testing.oxm.mappings.XMLMappingTestCases; + +public class XMLDirectCollectionOfListsTestCases extends XMLMappingTestCases { + + private final static String XML_RESOURCE = "org/eclipse/persistence/testing/oxm/mappings/directcollection/listoflists/DirectCollectionOfLists.xml"; + + public XMLDirectCollectionOfListsTestCases(String name) throws Exception { + super(name); + setControlDocument(XML_RESOURCE); + setProject(new RootProject()); + } + + protected Object getControlObject() { + Root root = new Root(); + + ArrayList values1 = new ArrayList(); + values1.add(Double.valueOf(1.2)); + values1.add(Double.valueOf(3.4)); + values1.add(Double.valueOf(5.6)); + + ArrayList values2 = new ArrayList(); + values2.add(Double.valueOf(-7.8)); + values2.add(Double.valueOf(-9.0)); + values2.add(Double.valueOf(-1.2)); + + ArrayList> itemCollection = new ArrayList>(); + itemCollection.add(values1); + itemCollection.add(values2); + + root.items = itemCollection; + + return root; + } + +} \ No newline at end of file Index: moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java =================================================================== --- moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java (revision 4170) +++ moxy/org.eclipse.persistence.moxy/src/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java (working copy) @@ -41,6 +41,7 @@ import org.eclipse.persistence.oxm.*; import org.eclipse.persistence.oxm.mappings.*; +import org.eclipse.persistence.oxm.mappings.converters.XMLListConverter; import org.eclipse.persistence.oxm.mappings.converters.XMLRootConverter; import org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy; import org.eclipse.persistence.oxm.mappings.nullpolicy.XMLNullRepresentationType; @@ -387,6 +388,11 @@ if(((DatabaseMapping)nestedMapping).isAbstractCompositeCollectionMapping()){ ((XMLCompositeCollectionMapping)nestedMapping).setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT); } + if (element.isList() && ((DatabaseMapping)nestedMapping).isAbstractCompositeDirectCollectionMapping()) { + XMLListConverter listConverter = new XMLListConverter(); + listConverter.setObjectClassName(element.getJavaType().getQualifiedName()); + ((XMLCompositeDirectCollectionMapping)nestedMapping).setValueConverter(listConverter); + } }else{ ((XMLChoiceObjectMapping)mapping).addChoiceElement(xmlField, element.getJavaTypeName()); XMLMapping nestedMapping = ((XMLChoiceObjectMapping)mapping).getChoiceElementMappings().get(xmlField);