[jdom-interest] Document.getRootElement()

Jason Hunter jhunter at acm.org
Tue Jun 13 11:37:15 PDT 2000

> There is a contradiction here: Does the method return null or does it
> throw a NoSuchElementException?

The code says it thorws NSEE.  This shouldn't naturally happen because
the public Element constructor requires an Element be passed in, but I
changed the Javadocs to match behavior.

     * <p>
     * This will return the root <code>Element</code>
     *   for this <code>Document</code>, or throw a
     *   if it hasn't been properly set.
     * </p>
     * @return <code>Element</code> - the document's root element
     * @throws <code>NoSuchElementException</code> - when no root
     *                                      element exists.
    public Element getRootElement() throws NoSuchElementException {
        if (rootElement == null)  {
            throw new NoSuchElementException("No root element exists.");
        return rootElement;


More information about the jdom-interest mailing list