[jdom-interest] Important proposal: Element/Document changes - bug

Michael Hinchey hincheymg at yahoo.com
Fri Jul 28 01:36:02 PDT 2000

I have the latest CVS code.  This is the only problem
from the changes that I found by running my code.

Element#getTextTrim() should check for null text
first.  Otherwise StringTokenizer throws an NPE.  I
also added the same length==0 check as you have in

BTW, I'm +1 on this method normalizing internal

public String getTextTrim() {
    if (getText() == null) {
      return null;

    // Use "cached" trimmed text if available
    if (trimmedContent == null) {

        StringBuffer textContent = new StringBuffer();

        StringTokenizer tokenizer = new
        while (tokenizer.hasMoreTokens()) {
            String str = tokenizer.nextToken();
            if (tokenizer.hasMoreTokens()) {
                textContent.append(" ");  // separator

        trimmedContent = textContent.toString();

    if (trimmedContent.length() == 0) {
        return null;
    else {
        return trimmedContent;


Do You Yahoo!?
Kick off your party with Yahoo! Invites.

More information about the jdom-interest mailing list