if (!value.hasMoreItems()) {
break;
}
final Object itemKey = value.get(null, context);
if (!value.hasMoreItems()) {
throw new ConversionException("Encoded Map entry has missing value");
}
final Object itemValue = value.get(null, context);
map.put(itemKey, itemValue);
}
} else
throw new ConversionException("Cannot convert a " + clazz.getName() + " to a Map");
} else if (target instanceof Collection) {
if (Collection.class.isAssignableFrom(clazz)) {
final Collection collection = (Collection) target;
for (;;) {
if (!value.hasMoreItems()) {
break;
}
final Object itemValue = value.get(null, context);
collection.add(itemValue);
}
} else
throw new ConversionException("Cannot convert " + clazz.getName() + " to a Collection");
} else
throw new ConversionException("CollectionValueCoder cannot render to an object of class "
+ target.getClass().getName());
}