Index: org/exolab/castor/xml/UnmarshalHandler.java =================================================================== --- org/exolab/castor/xml/UnmarshalHandler.java (Revision 6999) +++ org/exolab/castor/xml/UnmarshalHandler.java (Arbeitskopie) @@ -3676,7 +3676,29 @@ primitive = java.math.BigInteger.valueOf(0); else primitive = new java.math.BigInteger(value); } - + else if (type.getSuperclass().getName().equals("java.lang.Enum")) { + if (isNull) { + primitive = null; + } else { + try { + Method valueOfMethod = type.getMethod("valueOf", new Class[]{ String.class }); + primitive = valueOfMethod.invoke(null, new Object[]{ value }); + } + catch (IllegalAccessException e) { + throw new IllegalStateException(e.toString()); + } + catch (InvocationTargetException e) { + if (e.getTargetException() instanceof RuntimeException); + throw (RuntimeException)e.getTargetException(); + } + catch (NoSuchMethodException e) { + String err = type.getName() + + " does not contain the required method: public static " + + type.getName() + " valueOf(String);"; + throw new IllegalArgumentException(err); + } + } + } return primitive; } //-- toPrimitiveObject Index: org/exolab/castor/xml/Introspector.java =================================================================== --- org/exolab/castor/xml/Introspector.java (Revision 7001) +++ org/exolab/castor/xml/Introspector.java (Arbeitskopie) @@ -1238,12 +1238,24 @@ **/ private static boolean isPrimitive(Class type) { - if (type.isPrimitive()) return true; + if (type.isPrimitive()) { + return true; + } - if ((type == Boolean.class) || (type == Character.class)) + if ((type == Boolean.class) || (type == Character.class)) { return true; + } - return (type.getSuperclass() == Number.class); + Class superClass = type.getSuperclass(); + if (superClass == Number.class) { + return true; + } + + if (superClass != null) { + return superClass.getName().equals("java.lang.Enum"); + } else { + return false; + } } //-- isPrimitive Index: org/exolab/castor/xml/MarshalFramework.java =================================================================== --- org/exolab/castor/xml/MarshalFramework.java (Revision 7001) +++ org/exolab/castor/xml/MarshalFramework.java (Arbeitskopie) @@ -200,10 +200,21 @@ if (type == String.class) return true; //-- primtive wrapper classes - if ((type == Boolean.class) || (type == Character.class)) + if ((type == Boolean.class) || (type == Character.class)) { return true; + } - return (type.getSuperclass() == Number.class); + Class superClass = type.getSuperclass(); + if (superClass == Number.class) { + return true; + } + + if (superClass != null) { + return superClass.getName().equals("java.lang.Enum"); + } + + return false; + } //-- isPrimitive /**