[jdom-interest] Ambiguity in ???MixedContent()

Laurent ROMEO romeo at agisphere.com
Thu Mar 15 02:00:28 PST 2001


Hi,

Nothing serious, but I found an ambiguity in the naming of the methods
getMixedContent() and hasMixedContent() of the Element class.

If I have an Element with only a textual content, then :
 - hasMixedContent() return false ( because only one type of content )
 - getMixedContent() return a list not empty with the expected textual
content.

So, I can't use a piece of code like this :

if ( myElement.hasMixedContent() )
{
  java.util.List mixedContentList = myElement.getMixedContent();
  ...
}

because I should miss my previous example...

This problem is not really one, because my test should be made directly
on the resulting list. But what I fear is that other people ( like I did

!!! ) will first write my wrong code !

Consequently, please let me make a suggestion :

1 ) Implementing a method hasContent() very simple :

 public boolean hasMixedContent() {
        if (content == null) {
            return false;
        }
 }

in the Element class.

2 ) adding a warning in the Javadoc to precise the use of the two
methods.


--
Laurent.
romeo at agisphere.com








More information about the jdom-interest mailing list