Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

Re: [jdom-interest] ClassCastException on Element.getContent

Jason Hunter

2006-02-11

Replies:

It's not designed to allow that to happen. I'd be curious what type is
being returned.

-jh-

Martin Berg wrote:

> Hi
>
> According to the javadoc, org.jdom.Element.getContent() returns a list of
> objects of types that all extend org.jdom.Content. My code looks something
> like this:
> ...
> for (Iterator it = xhtmlElement.getContent().iterator(); it.hasNext(); ) {
>
> Content content = (Content) it.next();
>
> ...
>
> where xhtmlElement is of type org.jdom.Element. This works nicely in the
> test environment, but in the production environment the second line
> (Contents contents = ...) causes a ClassCastException. Both environments
> run sun jdk 1.4. Under what circumstances could the returned list from
> getContents() contain anything that is not castable to Content?
>
> /Martin
>
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
>
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.