[jdom-interest] Bug when iterating in reverse order over
FilteredList
Vadim Strizhevsky
Vadim.Strizhevsky at morganstanley.com
Wed Jul 23 14:21:14 PDT 2003
I think I was in my interpretation of the bug reason. I was able to fix
it by changing the hasPrevious() function CREATE case not to substract 1
from thine initialCursor. it works, but I'm not sure that's a right
solution that covers all possible cases. Hopefully someone who is more
familiar with this code can comment.
Thanks,
-Vadim
Vadim Strizhevsky wrote:
>
> Hi,
>
> I've hit what looks like a bug in JDOM b9 when iterating over children
> in reverse order if there's a Text node at the end of the content list.
> So for example if you have one of the following messages:
>
> <root><e/>text</root>
>
> or
>
> <root>text</root>
>
> the following code will fail with CastException.
>
> List children = rootElement.getChildren();
> for (ListIterator iter =
> children.listIterator(children.size());iter.hasPrevious();)
> {
> Element element = (Element)iter.previous();
> }
>
> This is an extract from a larger code. Let me know if you need a fully
> working test case. I think this bug is because the initial hasPrevious()
> call does not adjust the cursor, while the constructor always adjust the
> cursor forward only. I.e. it seems like the constructor of
> ContentList.FilterListIterator assumes that iteration will always be
> forward only.
>
> Thanks,
> Vadim
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
--
NOTICE: If received in error, please destroy and notify sender. Sender
does not waive confidentiality or privilege, and use is prohibited.
More information about the jdom-interest
mailing list