Re: XMLEncoder behavior

From: Cris Daniluk (cris.danilu..mail.com)
Date: Thu Dec 15 2005 - 17:02:46 EST

  • Next message: Kevin Menard: "Re: XMLEncoder behavior"

    I just submitted a patch that preserves the behavior for objects, but
    behaves consistently for collections. I wasn't sure if the current
    implementation made sense for objects or not, so I didn't want to
    change it. Wish I could have finished it in time for M9 :(

    Cris

    On 12/15/05, Andrus Adamchik <andru..bjectstyle.org> wrote:
    > I agree with Cris. I think Kevin modeled this after WebObjects
    > implementation. But I don't know what the reason for that either.
    >
    > Andrus
    >
    >
    > On Dec 15, 2005, at 4:36 AM, Cris Daniluk wrote:
    > > In working on the GenericDataService, I noticed (and had to work
    > > around) some very unintuitive behavior in the XMLEncoder. When a
    > > single result is returned, the rootTag is not included in the document
    > > tree. The offending code is:
    > >
    > > // if synthetic root has a single child, use child as a root
    > > Node root = document.getDocumentElement();
    > > if (root.getChildNodes().getLength() == 1) {
    > > root = root.getFirstChild();
    > > }
    > >
    > > I can't figure out why you would want this, but if you're encoding a
    > > list, the behavior will be different if the list happens to have only
    > > one element in it, making a very difficult to debug problem. I think
    > > we should overload the encode method so that if a collection is
    > > passed, instead of an Object, this behavior is disabled.
    > >
    > > Would be happy to submit a JIRA and/or patch if necessary.
    > >
    > > Cris
    > >
    >
    >



    This archive was generated by hypermail 2.0.0 : Thu Dec 15 2005 - 17:02:48 EST