| 1 | |
package org.paneris.bibliomania.metasearch.util; |
| 2 | |
|
| 3 | |
import java.util.Enumeration; |
| 4 | |
import java.util.NoSuchElementException; |
| 5 | |
|
| 6 | |
import org.paneris.bibliomania.metasearch.BookStockingFactory; |
| 7 | |
|
| 8 | |
public abstract class SearchResultsBase |
| 9 | |
extends HackParser implements Enumeration { |
| 10 | |
|
| 11 | |
protected BookStockingFactory stockings; |
| 12 | |
|
| 13 | |
public SearchResultsBase(byte[] text, |
| 14 | |
BookStockingFactory stockings) { |
| 15 | 0 | super(text); |
| 16 | 0 | this.stockings = stockings; |
| 17 | 0 | } |
| 18 | |
|
| 19 | |
protected abstract Object more(); |
| 20 | |
|
| 21 | 0 | private Object next = null; |
| 22 | |
|
| 23 | |
public synchronized boolean hasMoreElements() { |
| 24 | 0 | return next != null || (next = more()) != null; |
| 25 | |
} |
| 26 | |
|
| 27 | |
public synchronized Object nextElement() { |
| 28 | 0 | if (!hasMoreElements()) |
| 29 | 0 | throw new NoSuchElementException(); |
| 30 | 0 | Object it = next; |
| 31 | 0 | next = null; |
| 32 | 0 | return it; |
| 33 | |
} |
| 34 | |
} |