@Test public void failsIfAttemptsToGoBeyondEnd() throws Exception { final Iterator<String> sut = createSut("block1"); assertThat(sut.next(),equalTo("block1")); try { sut.next(); fail("Should fail when going beyond end"); } catch (final NoSuchElementException e) { } }
@Override public String next() { if(!hasNext()) { throw new NoSuchElementException(ERROR_NO_MORE_BLOCKS_AVAILABLE); } this.partStart=this.traversal.currentOffset(); this.partEnd=findTokenEnd(); this.part=this.header.substring(this.partStart,this.partEnd); this.traversal=continueTraversal(); return this.part; }
HeaderPartIterator implements Iterator<String> { @Override public String next() { if(!hasNext()) { throw new NoSuchElementException(ERROR_NO_MORE_BLOCKS_AVAILABLE); } this.partStart=this.traversal.currentOffset(); this.partEnd=findTokenEnd(); this.part=this.header.substring(this.partStart,this.partEnd); this.traversal=continueTraversal(); return this.part; } }
HeaderPartIterator implements Iterator<String> { @Override public String next() { if(!hasNext()) { throw new NoSuchElementException(ERROR_NO_MORE_BLOCKS_AVAILABLE); } this.partStart=this.traversal.currentOffset(); this.partEnd=findTokenEnd(); this.part=this.header.substring(this.partStart,this.partEnd); this.traversal=continueTraversal(); return this.part; } private  HeaderPartIterator(final String str); }
HeaderPartIterator implements Iterator<String> { @Override public String next() { if(!hasNext()) { throw new NoSuchElementException(ERROR_NO_MORE_BLOCKS_AVAILABLE); } this.partStart=this.traversal.currentOffset(); this.partEnd=findTokenEnd(); this.part=this.header.substring(this.partStart,this.partEnd); this.traversal=continueTraversal(); return this.part; } private  HeaderPartIterator(final String str); @Override boolean hasNext(); @Override String next(); @Override void remove(); }
HeaderPartIterator implements Iterator<String> { @Override public String next() { if(!hasNext()) { throw new NoSuchElementException(ERROR_NO_MORE_BLOCKS_AVAILABLE); } this.partStart=this.traversal.currentOffset(); this.partEnd=findTokenEnd(); this.part=this.header.substring(this.partStart,this.partEnd); this.traversal=continueTraversal(); return this.part; } private  HeaderPartIterator(final String str); @Override boolean hasNext(); @Override String next(); @Override void remove();  }