Content () { // set the 'current' if it needs changing. if (descending != null) { current = descending; descending = null; } else if (ascending != null) { current = ascending; ascending = null; } final Content ret = current.next(); // got an item to return. // sort out the next state.... if ((ret instanceof Element) && ((Element)ret).getContentSize() > 0) { // there is another descendant, and it has values. // our next will be down.... descending = ((Element)ret).getContent().iterator(); if (ssize >= stack.length) { stack = Arrays.copyOf(stack, ssize + 16); } stack[ssize++] = current; return ret; } if (current.hasNext()) { // our next will be along.... return ret; } // our next will be up. while (ssize > 0) { // if the stack was generic, this would not be needed, but, // the java.uti.* stack codes are too slow. @SuppressWarnings("unchecked") final Iterator<Content> subit = (Iterator<Content>)stack[--ssize]; ascending = subit; stack[ssize] = null; if (ascending.hasNext()) { return ret; } } ascending = null; hasnext = false; return ret; }