velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Koberg <...@koberg.com>
Subject Re: SortedMap/TreeMap in a tool does not sort
Date Tue, 05 Apr 2005 14:07:58 GMT
Simon Christian wrote:
> Hi Robert,
> 
> Remember that SortedMap/TreeMap only guarantee "that the map will be in 
> ascending key order, sorted according to the natural order for the key's 
> class". This is as opposed to the put order.
> 
> Looks like you need to either supply a Comparator when creating the 
> TreeMap, or implement Comparable in your question classes.

Guess I need to learn java :)

I had assumed 'natural order' meant the order I put it in (never used 
SortedMap before...). The question's answers are correct because the 
keys are like q1, q2, q3.

Thanks and sorry for the bother,
-Rob


> 
> hth,
> 
> - simon
> 
> Robert Koberg wrote:
> 
>> Hi,
>>
>>  From what I am seeing, it seems to be the case that velocity 
>> tools/templates do not work with SortedMap/TreeMap created in the 
>> tool. That is, they do not come to the template in the order they were 
>> placed in the map. Is that to be expected?
>>
>> <my-case>I have a tool(s) that creates 'static final' question (and 
>> answer, if multichoice) objects. These question objects are added to a 
>> SortedMap. If the question object has multiple choice answers, those 
>> answers are also added to their own SortedMap. The answers come back 
>> in the put order, but the questions do not. (before anyone asks why I 
>> am creating static final question objects in a tool (quizes), the 
>> classes are generated by XSL at build time before compile)</my-case>
>>
>> best,
>> -Rob
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message