public Iterator<Node[]> parse(Iterator<String> iterator) { _stringIt = iterator; loadNext(); return this; }
public Node[] next(){ if(next==null) throw new NoSuchElementException(); Node[] now = next; loadNext(); return now; }
private void loadNext() { next = null; do{ if (_stringIt.hasNext()){ _line = _stringIt.next(); } else { next = null; return; } ++_lineNo; } while(_line==null || isEntirelyWhitespaceOrEmpty(_line)); //iterate until we get a non-blank line try { next = parseNodesInternal(_line); } catch (Exception e) { _log.warning("Moving on to the next line, as I couldn't parse line " + _lineNo + ": " + _line); e.printStackTrace(); //invalid: skip and try again loadNext(); } if (next == null) return; if(next.length==0)//valid but empty: skip and try again loadNext(); }