[jdom-interest] IOExceptions in createDocument() in adapter classes

Jason Hunter jhunter at acm.org
Fri Apr 5 11:39:06 PST 2002


Good points.  Care to submit a patch?

-jh-

Elliotte Rusty Harold wrote:
> 
> The AbstractDOMAdapter class and the DOMAdapter interface decalre
> createDocument() methods that are decalred to throw a generic Exception:
> 
> public org.w3c.dom.Document *createDocument*() throws java.lang.Exception
> 
> Wouldn't a JDOMException be more appropriate here?
> 
> In the various subclasses many of these methods throw IOException. For
> example, in  CrimsonDOMAdapter:
> 
> public org.w3c.dom.Document *createDocument*() throws java.io.IOException
> 
> This really makes no sense. Looking at the code the problems it's
> reporting are not an I/O problem of any kind. Typically the problem
> would be a ClassNotFoundException:
> 
>     public Document createDocument() throws IOException {
>         try {
>             return
>                 (Document)Class.forName(
>                     "org.apache.crimson.tree.XmlDocument")
>                     .newInstance();
> 
>         } catch (Exception e) {
>             throw new IOException(e.getClass().getName() + ": " +
>                                   e.getMessage());
>         }
>     }
> 
> JDOM is converting this to an IOException. I suspect JDOM should either
> let the original exception percolate up or convert it to a
> JDOMException. An IOException here just makes no sense. The other
> adapter classes I've looked at have the same problem.
> 
> --
> +-----------------------+------------------------+-------------------+
> | Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
> +-----------------------+------------------------+-------------------+
> |           The XML Bible, 2nd Edition (IDG Books, 2001)             |
> |             http://www.cafeconleche.org/books/bible2/              |
> |   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
> +----------------------------------+---------------------------------+
> |  Read Cafe au Lait for Java News:   http://www.cafeaulait.org/     |
> |  Read Cafe con Leche for XML News:  http://www.cafeconleche.org/   |
> +----------------------------------+---------------------------------+
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com



More information about the jdom-interest mailing list