Re: XMLEncoder behavior

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Dec 15 2005 - 04:15:22 EST

  • Next message: Andrus Adamchik: "Re: XML data service"

    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 - 04:15:28 EST