[jboss-dev-forums] [Design of JBossXB] - Re: Extending EnumValueAdapter

adrian@jboss.org do-not-reply at jboss.com
Tue Mar 18 08:59:54 EDT 2008


"alesj" wrote : "adrian at jboss.org" wrote : 
  |   | It doesn't. The "1" gets used if you do this:
  |   | 
  |   | 
  |   |   | @XmlEnum(Integer.class)
  |   |   | public enum Numbers
  |   |   | {
  |   |   |    ONE(1)
  |   |   | }
  |   |   | 
  |   | 
  |   | i.e. a "1" in the xml maps to the ONE enum value.
  | So in this case it would be illegal to use @JBossXmlEnum(ignoreCase=true) or just ignored?
  | 

Yes. Obviously, you can't ignore case on an integer. ;-)

anonymous wrote : 
  | Who makes sure "1" is passed into EVA::cast as an Integer?

Its the xsd:type (or technically its parent type) of the attribute/element.

>From JBossXBNoSchemaBuilder

  |       // Determine the enum type 
  |       Class<?> xmlEnumValue = String.class;
  |       XmlEnum xmlEnum = typeInfo.getUnderlyingAnnotation(XmlEnum.class);
  |       if (xmlEnum != null)
  |          xmlEnumValue = xmlEnum.value();
  |       TypeInfo enumType = typeInfo.getTypeInfoFactory().getTypeInfo(xmlEnumValue);
  | 
  |       // Resolve the enum type as the parent (must be simple)
  |       TypeBinding parent = getSimpleType(enumType);
  | 
  |       // Create the enum type
  |       QName qName = null;
  |       TypeBinding typeBinding = null;
  |       if (root)
  |       {
  |          qName = generateXmlName(typeInfo, XmlNsForm.QUALIFIED, overrideNamespace, overrideName);
  |          typeBinding = new TypeBinding(qName, parent);
  |       }
  |       else
  |       {
  |          typeBinding = new TypeBinding(null, parent);
  |       }
  | 

Please, either read the spec, read the code, read the tests or "suck it and see".

Don't keep expecting me to explain the finest points of every implementation detail
ad infinitum in the forums (unless you want to post in the user forums
where I can ignore you :-).


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4137392#4137392

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4137392



More information about the jboss-dev-forums mailing list