users@jaxb.java.net

Re: XSD Data types

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 15 Nov 2006 17:57:10 -0800

Aleksei Valikov wrote:
> Hi.
>
>>> I think I need to learn a lot of things. :-) Great...
>>> 1 more question.
>>> Can I add an import statement on the generated code? Because I inject
>>> a code to my generated Code using co.implClass.direct() API, which
>>> containing util classes such as Iterator, List, etc. And maybe would
>>> like to add few more classes. Or maybe is there any better way to
>>> inject code?
>>
>> Lexi: I generally dislike direct() code generation.
>>
>> Heru: What are the other alternatives?
>
> Well, if you have your code defined in a String, there's no alternative. I just
> prefer using normal CodeModel API instead of direct statements where it's possible.
> Say, you can direct("a=b;"), you can body.assign(a, b);

Yep.

That said, I do realize that sometimes you really have no option but to
use code-in-string. We can certainly consider allowing explicit import
statements to be added. It's ugly, but it's not hard.


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com