### Question:
CharacterNGramTokenizer implements TextTokenizer { @Override public Iterator<Token> iterateTokens(String text) { Validate.notNull(text, "text must not be null"); final String textForTokenization = padding ? createPadding(text) : text; return new AbstractIterator2<Token>() { private int offset = 0; private int length = minLength; @Override protected Token getNext() { for (;;) { if (offset + minLength > textForTokenization.length()) { return finished(); } String nGram = textForTokenization.substring(offset, offset + length); if (offset + length == textForTokenization.length() || length == maxLength) { offset++; length = minLength; } else { length++; } if (nGram.replace(PADDING_CHARACTER, "").length() == 0) { continue; } return new ImmutableToken(offset, nGram); } } }; } CharacterNGramTokenizer(int minLength, int maxLength);  CharacterNGramTokenizer(int minLength, int maxLength, boolean padding); @Override Iterator<Token> iterateTokens(String text); @Override String toString();  }### Answer:
@Test public void testCharacterNGramIterator() { Iterator<Token> nGrams; nGrams = new CharacterNGramTokenizer(3, 3).iterateTokens(STRING); assertEquals(7, CollectionHelper.count(nGrams)); nGrams = new CharacterNGramTokenizer(15, 15).iterateTokens(STRING); assertEquals(0, CollectionHelper.count(nGrams)); nGrams = new CharacterNGramTokenizer(9, 9).iterateTokens(STRING); assertEquals(1, CollectionHelper.count(nGrams)); nGrams = new CharacterNGramTokenizer(3, 8).iterateTokens(STRING); assertEquals(27, CollectionHelper.count(nGrams)); nGrams = new CharacterNGramTokenizer(3, 3, true).iterateTokens(STRING); assertEquals(11, CollectionHelper.count(nGrams)); }