Hi Paul,
Currently Castor has no way of handling constructors which require
arguments, whether they are typical constructors or factory methods.
This is on my to-do list and I've already begun planning how to modify
Castor to add this support.
I'll probably release it in two phases. The first will be attribute
based constructor arguments ( or Factory method arguments) and the
second will be element based arguments. Since attributes are passed in
with the startElement it will be the easiest and therefore come first.
I envision the mapping file to look like:
<field name="arg" set-method="%1" get-method="getArg"/>
Where "%" will indicate a constructor argument and the following integer
will specify it's index within the argument array.
I hate to give estimates as it really depends on how much time I can
spend per day which changes from day to day, but I imagine I'll have a
first cut available sometime in the next one to two weeks. I need to
clean up a few other items first.
--Keith
Paul Christmann wrote:
>
> [Apologies if this turns out to be a repost; I attempted to post via
> gmane newsgroup and got two email responses - one indicating success and
> one indicating failure. So I don't know if that post went through or not.]
>
> I'm interested in serializing a bunch of existing java objects that all
> follow the same idiom:
>
> class Foo {
> final int arg;
> private Foo (int arg) {
> this.arg = arg;
> }
>
> public static Foo newFoo (int arg) {
> return new Foo(arg);
> }
>
> public int getArg () {
> return arg;
> }
> }
>
> Is it possible to define a mapping file that can work with this class?
> It doesn't have a public constructor, so I immediately ran into that
> MappingException. I read (and reread and reread) the tips-and-tricks
> paragraphs on use of the "create-method" in the mapping, but couldn't
> figure out how to make it apply -- its not a property of my Foo that I
> need created, but the Foo itself. I found posts in the archives dealing
> with use of FieldHandlers to provide flexibility for constructing
> objects; but again -- those seem to apply to creating objects on a
> class. In some of my cases, the Foo will be the root element in the
> mapping.
>
> Is this possible? If so, any pointers to where I can learn how? If
> not, is there a particular reason why not (meaning, would developers be
> open to support of this if it was possible to define a mapping that
> described it and I could provide such a patch (which is not to say I
> have such a patch yet, but I would be willing to dig into it))?
>
> Thanks,
>
> Paul Christmann
>
> [EMAIL PROTECTED]
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev