/**
  * Fills {@link #inputWindow} with input stream tokens, if available, shifting to the right if the
  * window was previously full.
  *
  * <p>Resets {@link #gramSize} to its minimum value.
  *
  * @throws IOException if there's a problem getting the next token
  */
 private void shiftInputWindow() throws IOException {
   InputWindowToken firstToken = null;
   if (inputWindow.size() > 0) {
     firstToken = inputWindow.removeFirst();
   }
   while (inputWindow.size() < maxShingleSize) {
     if (null != firstToken) { // recycle the firstToken, if available
       if (null != getNextToken(firstToken)) {
         inputWindow.add(firstToken); // the firstToken becomes the last
         firstToken = null;
       } else {
         break; // end of input stream
       }
     } else {
       InputWindowToken nextToken = getNextToken(null);
       if (null != nextToken) {
         inputWindow.add(nextToken);
       } else {
         break; // end of input stream
       }
     }
   }
   if (outputUnigramsIfNoShingles
       && noShingleOutput
       && gramSize.minValue > 1
       && inputWindow.size() < minShingleSize) {
     gramSize.minValue = 1;
   }
   gramSize.reset();
   isOutputHere = false;
 }
 @Override
 public void reset() throws IOException {
   super.reset();
   gramSize.reset();
   inputWindow.clear();
   nextInputStreamToken = null;
   isNextInputStreamToken = false;
   numFillerTokensToInsert = 0;
   isOutputHere = false;
   noShingleOutput = true;
   exhausted = false;
   endState = null;
   if (outputUnigramsIfNoShingles && !outputUnigrams) {
     // Fix up gramSize if minValue was reset for outputUnigramsIfNoShingles
     gramSize.minValue = minShingleSize;
   }
 }