array to object

This commit is contained in:
Keith Donald
2009-09-18 23:15:33 +00:00
parent d37c5aba94
commit fada151878
2 changed files with 21 additions and 8 deletions

View File

@@ -171,7 +171,15 @@ class CollectionGenericConverter implements GenericConverter {
}
private Object convertObjectToArray(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
throw new UnsupportedOperationException("Not yet implemented");
TypeDescriptor targetElementType = targetType.getElementTypeDescriptor();
Object array = Array.newInstance(targetType.getElementType(), 1);
if (sourceType.isAssignableTo(targetElementType)) {
Array.set(array, 0, source);
} else {
GenericConverter converter = conversionService.getConverter(sourceType, targetElementType);
Array.set(array, 0, converter.convert(source, sourceType, targetElementType));
}
return array;
}
private boolean isCollectionToObject(TypeDescriptor sourceType, TypeDescriptor targetType) {