[jdom-interest] Optimizing Method Element.getText()

georg.plank at gerling.de georg.plank at gerling.de
Mon Aug 13 02:38:39 PDT 2001

I suggest an optimization in method Element.getText():
Instead of
        // If we hold only a String, return it directly
        if ((content.size() == 1) && (content.get(0) instanceof String)) {
            return (String)content.get(0);
you may extend it to CDATA as
        // If we hold only a String or CDATA, return it directly
        if ( content.size() == 1 ) {
            Object obj = content.get(0);
            if ( obj instanceof String))
                return (String)obj;
            else if ( obj instanceof CDATA )
                return ((CDATA)obj).getText();
                return "";

I am not involved in the development process of JDOM. Maybe someone else
puts it into source?

- Georg

This message is intended for the addressee or its representative only. Any
form of unauthorized use, publication, reproduction, copying or disclosure
of the content of this e-mail is not permitted. If you are not the intended
recipient of this e-mail message and its contents, please notify the sender
immediately and delete this message and all its attachments subsequently.

More information about the jdom-interest mailing list