[jdom-interest] patch for skipLeadingWhite

Philip Nelson panmanphil at yahoo.com
Wed Apr 17 21:02:21 PDT 2002


OK, since my cvs is still somewhat challenged, I'll just send the method. 
Notice the change:  there is an early exit in the case where the content has
data but the first node is not whitespace.  All my tests pass after this change
but there are not extensive tests of whitespace handling anywhere.

private int skipLeadingWhite( List content, int start) {
        if (start <= 0) {
            start = 0;
        }

        int index = start;
        int size = content.size();
        
        //check if the first node of the content list is not whitespace 
        //and return the index 
        if ( size > 0 && !isAllWhitespace( content.get(0))) 
            return 0;
        
        if (currentFormat.trimAllWhite
                || currentFormat.textNormalize
                || currentFormat.textTrim
                || currentFormat.newlines) {
            while( index < size) {
                if ( !isAllWhitespace( content.get(index))) {
                    return index;
                }
                index++;
            }
        }
        return size;
    }

__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/



More information about the jdom-interest mailing list