[jdom-interest] Exception: org.jdom.ContentList$FilterList
Azrael
azrael at azrael-uk.f2s.com
Thu Aug 29 11:03:20 PDT 2002
Ken Rune Helland wrote:
>>The Exception getMessage() is:
>>
>>org.jdom.ContentList$FilterList
> My guess is you are getting an ClassCastException, because
> the list returned from getChildren is not a ArrayList but a
> org.jdom.ContentList$FilterList.
>
> There is no need to cast the return value of the getChildren
> metod. It returns a reference to a List inteface and
> this interface shoud give you all the metods you need.
> So the line shoud be:
>
> List temp = currentElement.getChildren();
>
>
> KenR
You were spot on!
This results from perhaps a slight misunderstanding of java itself.
Because List is an interface.. and you can't create Objects of that
type.. I thought List temp.. etc wouldn't be allowed.
As indeed, List temp=new List(); wouldn't be allowed...
but doing the above solved my problem.. and now I assume if the return
type is a List.. you can do List temp = <thing that returns the List>
So not only have I learned some jdom, but also some java.. many thanks!!
(only been learning Java 8 months .. long enough that I should have
known this.. but...)
p.s. My project now works.. and I managed to compress a 76 byte (tags
only, no content) xml file into a 2 byte file.
And more importantly managed to decompress it back to the original data.
Thanks a lot to everyone for their help!!
--
Azrael
("\''/").___..--'''"-._
`0_ O ) `-. ( ).`-.__.`)
(_Y_.)' ._ ) `._ `. ``-..-'
_..`--'_..-_/ /--'_.' .'
((i).-'' ((i).' (((.-'
Of all God's creatures there is only one that cannot be made the slave
of the lash. That one is the cat. If man could be crossed with a cat it
would improve man, but it would deteriorate the cat.
ICQ#52944566
More information about the jdom-interest
mailing list