I have this StreamTokenizer Iterator Adapter that is suppose to create a Tokenizer Iterator Index Builder then build the index from a STIA wrapped around a StreamTokenizer. I am having trouble implementing the hasNext and Next for my STIA, can anyone help me, here is my class:
public class StreamTokenizerIteratorAdapter implements Iterator<Token> {
DefaultIndexImpl index;
StreamTokenizer source;
public StreamTokenizerIteratorAdapter(final StreamTokenizer source) {
if (source == null)
throw new IllegalArgumentException("source == null");
}
@Override
public boolean hasNext() {
return !index.isEmpty();
}
public Token next() {
if(!index.isEmpty())
return next();
else
return null;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
}
Should I be using the source element in the hasNext() and next()?