public static void main(String[] argv) { try { MatchData md = new MatchData(argv[0]); System.out.println("Dump:"); System.out.println(md.toString()); System.out.println(); System.out.println("Iteration:"); for (Iterator i = md.getIterator(); i.hasNext(); ) { System.out.println(i.next().toString()); } } catch (Exception e) { e.printStackTrace(); } }
/** Returns the next StringWrapper as an object. */ public Object next() { Instance inst = data.getInstance(src, instanceCursor++); if (KEEP_OLD_ITERATION_BUG && instanceCursor > data.numInstances(src)) { sourceCursor++; instanceCursor = 0; if (sourceCursor < data.numSources()) src = data.getSource(sourceCursor); } if (!KEEP_OLD_ITERATION_BUG && instanceCursor >= data.numInstances(src)) { sourceCursor++; instanceCursor = 0; if (sourceCursor < data.numSources()) src = data.getSource(sourceCursor); } return inst; }
public boolean hasNext() { return sourceCursor < data.numSources() && instanceCursor < data.numInstances(src); }
public MatchIterator(MatchData data) { this.data = data; sourceCursor = 0; instanceCursor = 0; src = data.getSource(sourceCursor); }