/** * Returns an array of items created by calling the next() method of each * contained iterator */ public synchronized Object next() throws NoSuchElementException { Object[] results = new Object[iterators().length]; for (int i = 0; i < iterators().length; i++) { results[i] = iterators()[i].next(); } return results; }
/** * If the iterator isn't empty then all the iterators contained within it * are the same length, can therefore just ask the first one */ public synchronized boolean hasNext() { return (emptyIterator()) ? false : iterators()[0].hasNext(); }
/** * All iterators are the same size */ public int size() { return (emptyIterator()) ? 0 : iterators()[0].size(); }
/** * Get the current location by finding the longest current position array * from all the child iterators and returning it. This is because otherwise * if we take the approach that the join iterator uses we end up with holes * in the resultant collection structure caused by the redundant * information. */ public int[] getCurrentLocation() { ResumableIterator[] iterators = iterators(); int longestIteratorLength = -1; int longestIteratorIndex = 0; for (int i = 0; i < iterators.length; i++) { if (iterators[i].getCurrentLocation().length > longestIteratorLength) { longestIteratorLength = iterators[i].getCurrentLocation().length; longestIteratorIndex = i; } } return iterators[longestIteratorIndex].getCurrentLocation(); }