Details
-
Type: New Feature
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.3.1
-
Fix Version/s: 1.4
-
Component/s: Converters
-
Labels:None
-
JDK version and platform:1.6 apple 32bits
Description
All my enums have a localized toString() so they are used in comboboxes without change.
in the xstream file they are saved with their toString, wich is good so my file doesn't speak too much the developer language (engrish), but more the user one (german).
But the system is unable to unmarshall the enums because it is trying to use Enum.valeOf(type, string).
This is sensible, but in my case, I want to use :
try
catch (IllegalArgumentException e) {
final Object[] enumConstants = type.getEnumConstants();
for (final Object constant : enumConstants)
throw e;
}
If I naively try to register a converter with XStream.registerConverter(SingleValueConverter) it is not taken into account because the internal EnumMapper takes precedence. And I don't want to register one converter by enum, they are all based on the same template in this part of my application.
I have to reopen this, because the SingleValueEnumConverter really uses toString() and not name(). This is plain wrong. EnumConverter itself does it right.