users@jaxb.java.net

Re: order of constructor args when using the value-constructor plugin

From: Kenny MacLeod <kennym_at_kizoom.com>
Date: Sat, 07 Oct 2006 15:22:56 +0100

The plugin is given the fields as a map of field names to field
definitions, so it appears that the original attribute ordering is lost.

I may be wrong, but the plugin framework doesn't given the plugins
access to the original schema. Instead, it gives them access to the
generated code model, which the plugin can then modify.

If someone could point me to a way for the plugin to obtain information
on the ordering, I'd be happy to try and modify the plugin to
incorporate it.


Lowell Kirsh wrote:
> I am using the value-constructor plugin
> (https://jaxb2-commons.dev.java.net/value-constructor/) to generate
> constructors. The order of the params is not what I have specified in my
> xsd. In my xsd I have:
>
> <xs:element name="localization">
> <xs:complexType>
> <xs:attribute name="locale"/>
> <xs:attribute name="label"/>
> ...
>
> And when I use the value-constructor plugin, it gives me the following
> constructor
>
> public Localization(String label, String locale) { ...}
>
> I'm not sure how the plugin determines the order of arguments. Looking
> at the java file that Jaxb creates without the plugin, label appears
> before locale (not that this neccessarily means anything).
>
> Basically what I want to accomplish is to control the order of the
> constructor arguments. But since these are xml attributes, their order
> in an xml file does not matter, so perhaps it's outside of the jaxb spec
> to have any control over their ordering in the generated java code.
>
> My questions are: does the value-constructor plugin control this order,
> or does it get it from the jaxb impl? And if it gets it from the jaxb
> impl, can the jaxb impl control the order?
>
> Thanks
> Lowell
>


Lowell Kirsh wrote:
> I am using the value-constructor plugin
> (https://jaxb2-commons.dev.java.net/value-constructor/) to generate
> constructors. The order of the params is not what I have specified in my
> xsd. In my xsd I have:
>
> <xs:element name="localization">
> <xs:complexType>
> <xs:attribute name="locale"/>
> <xs:attribute name="label"/>
> ...
>
> And when I use the value-constructor plugin, it gives me the following
> constructor
>
> public Localization(String label, String locale) { ...}
>
> I'm not sure how the plugin determines the order of arguments. Looking
> at the java file that Jaxb creates without the plugin, label appears
> before locale (not that this neccessarily means anything).
>
> Basically what I want to accomplish is to control the order of the
> constructor arguments. But since these are xml attributes, their order
> in an xml file does not matter, so perhaps it's outside of the jaxb spec
> to have any control over their ordering in the generated java code.
>
> My questions are: does the value-constructor plugin control this order,
> or does it get it from the jaxb impl? And if it gets it from the jaxb
> impl, can the jaxb impl control the order?
>
> Thanks
> Lowell
>