I just wrote this to Marc directly, but realized now that it was
might be generally interesting. I was actually wrong, too, your
original sorted arrays also, i just didn't notice where it hooked in:
"I've had to rethink the approach a little ... Andrus wasn't keen on
the patch, and he had some good reasonings behind it. For the
record, his claims about Lists is something he is totally right about
and a bug that I actually introduced into your original code when I
was trying to be Mr. Clever. Here is the bug report:
http://issues.apache.org/cayenne/browse/CAY-600
So basically the disagreements he had were related to the code being
a little too specialized, which is kind of true -- it was obviously
designed with EOModel plists in mind. It also was discussed whether
sorting when writing was correct, or whether it should just preserve
whatever order the model presents it with. As a result, I switched
things around and redesigned how the plists are READ. So now I read
the plist OUT into sorted data structures by modifying his Parser to
take a factory that I can return TreeMap instead of HashMap, for
instance. This also means that the PropertyListComparator moves into
EOModeler and out of Cayenne, so it's OK then that it is a little
more specialized. I did end up adding support for comparing
incompatible types, though, because UserInfo can actually have a mix
of String and Number keys (as an example). So the basic change is
that the plist when loaded out of the is actually sorted according to
your rules, and when I write it, it just writes in the natural order
of the Map it's given (which happens now to be sorted).
Long story short, though, yes, you could remove your dependency on
javawebobjects.jar and instead depend now on EOModeler plugin and
Cayenne plugin and load models using the new API that I'm using in
EOModeler (see EOModelParserDataStructureFactory). Or you could JUST
depend on cayenne (though I would steal the cayenne jar from WOLips,
or wait until he's merged it into the mainline) and then just steal
that little bit of code from EOModeler plugin to do the same thing.
phew ... a lot more words than you probably wanted to read about that
subject :)
ms
On Jul 18, 2006, at 6:59 AM, mar..iffy-berlin.in-berlin.de wrote:
>
> On 17. Jul. 2006, at 23:47, Watkins, Garry wrote:
>
>> ...Since you have been sorting things from dictionaries today,
>> would you automatically sort by the keys of the user info
>> dictionary in the properties inspector?
>
> I assume Mike is using my code, so yes, the keys of the user
> dictionary are sorted. But as dictionaries don't have an order
> anyway, it doesn't matter.
>
> There is a possible problem with arrays though. I assumed that
> there are no arrays whose element order matters, so I simply sort
> all the arrays I find. Otherwise the whole thing wouldn't make
> sense, as for example the list of entities (which EOModeler
> constantly scrambles around) is an array. I am not aware of any
> arrays where the order of their elements matters, except maybe
> arrays that have been put in the user info doctionary.
>
> Maybe the code should be changed to not sort arrays which are below
> an entry named 'userInfo'. Sounds like a hack, though :)
>
> Marc
>
This archive was generated by hypermail 2.0.0 : Tue Jul 18 2006 - 08:06:28 EDT