Log Message
EnumConverter is more lenient while parsing constants (XSTR-721).
Modified Paths
- trunk/xstream/src/java/com/thoughtworks/xstream/converters/enums/EnumConverter.java
- trunk/xstream-distribution/src/content/changes.html
- trunk/xstream-distribution/src/content/team.html
Diff
Modified: trunk/xstream/src/java/com/thoughtworks/xstream/converters/enums/EnumConverter.java (2032 => 2033)
--- trunk/xstream/src/java/com/thoughtworks/xstream/converters/enums/EnumConverter.java 2013-03-02 19:14:35 UTC (rev 2032)
+++ trunk/xstream/src/java/com/thoughtworks/xstream/converters/enums/EnumConverter.java 2013-03-02 19:29:21 UTC (rev 2033)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2005 Joe Walnes.
- * Copyright (C) 2006, 2007, 2009 XStream Committers.
+ * Copyright (C) 2006, 2007, 2009, 2013 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
@@ -44,7 +44,17 @@
if (type.getSuperclass() != Enum.class) {
type = type.getSuperclass(); // polymorphic enums
}
- return Enum.valueOf(type, reader.getValue());
+ String name = reader.getValue();
+ try {
+ return Enum.valueOf(type, name);
+ } catch (IllegalArgumentException e) {
+ // failed to find it, do a case insensitive match
+ for (Enum c : (Enum[])type.getEnumConstants())
+ if (c.name().equalsIgnoreCase(name))
+ return c;
+ // all else failed
+ throw e;
+ }
}
}
Modified: trunk/xstream-distribution/src/content/changes.html (2032 => 2033)
--- trunk/xstream-distribution/src/content/changes.html 2013-03-02 19:14:35 UTC (rev 2032)
+++ trunk/xstream-distribution/src/content/changes.html 2013-03-02 19:29:21 UTC (rev 2033)
@@ -55,6 +55,7 @@
<ul>
<li>JIRA:XSTR-719: Support replacement of default converter in any case.</li>
<li>JIRA:XSTR-725: processAnnotation performance improvement in concurrent situation.</li>
+ <li>JIRA:XSTR-721: EnumConverter is more lenient while parsing constants.</li>
<li>Current IBM JDK for Java 1.4.2 no longer has a reverse field ordering.</li>
</ul>
Modified: trunk/xstream-distribution/src/content/team.html (2032 => 2033)
--- trunk/xstream-distribution/src/content/team.html 2013-03-02 19:14:35 UTC (rev 2032)
+++ trunk/xstream-distribution/src/content/team.html 2013-03-02 19:29:21 UTC (rev 2033)
@@ -1,7 +1,7 @@
<html>
<!--
Copyright (C) 2005, 2006 Joe Walnes.
- Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 XStream committers.
+ Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2013 XStream committers.
All rights reserved.
The software in this package is published under the terms of the BSD
@@ -114,6 +114,7 @@
<li>Jaime Metcher</li>
<li>Michael Schnell</li>
<li>Nikita Levyankov</li>
+ <li>Kohsuke Kawaguchi</li>
</ul>
<p>Please direct all correspondence about XStream to the <a href="" mailing lists</a>
To unsubscribe from this list please visit:
