/** * Get the current location */ public int[] getCurrentLocation() { return iterator.getCurrentLocation(); }
/** * Delegates to contained LockStepIterator */ public boolean hasNext() { return iterator.hasNext(); }
/** * 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(); }
/** * Delegates to contained LockStepIterator */ public void reset() { iterator.reset(); }
/** * Delegates to contained LockStepIterator */ public int size() { return iterator.size(); }
/** * Return a Map of named objects derived from any iterator nodes attached to * this one as children, the iteration strategy is derived from the * underlying LockStepIterator which performs a cross product of all * available sub-iterators */ public Object next() { // Result will be an array of Map objects, convert to a Map i.e. // convert [{foo->bar}],[{urgle->wibble}] to {foo->bar,urgle->wibble} // and return Object[] o = (Object[]) iterator.next(); Map[] map = new Map[o.length]; for (int i = 0; i < o.length; i++) { map[i] = (Map) o[i]; } Map result = new HashMap(); for (int j = 0; j < map.length; j++) { for (Iterator i = map[j].keySet().iterator(); i.hasNext();) { String name = (String) i.next(); Object value = map[j].get(name); result.put(name, value); } } return result; }
/** * 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(); }