/** * Skips to the next segment. Now {@link #currentStartMarker()} and {@link #currentStopMarker()} can be used. */ public void nextSegment() { if ( ! hasMoreSegments() ) throw new NoSuchElementException(); currSegment++; }
/** Adds a new block defined by its array of segment delimiters. * * <p>The block has length defined by the difference between the last and first * delimiter. * * <p>This method performs the initial call to {@link #nextBlock()} when the first marker * is put in. * * @param delimiter a list of segment delimiters. * @throws IllegalArgumentException if the elements of <code>delimiter</code> are negative or not increasing. */ public void addBlock( final long... delimiter ) throws IllegalArgumentException, IOException { ensureNotClosed(); blocks.add( new SegmentBlock( delimiter ) ); if ( DEBUG ) LOGGER.debug( "Adding a new block with delimiters " + Arrays.toString( delimiter ) ); if ( currentBlock == -1 ) nextBlock(); }
/** Skips the underlying input stream to the next segment. */ private void nextSegment() throws IOException { ensureNotClosed(); final SegmentBlock block = blocks.get(currentBlock); if (! block.hasMoreSegments()) return; block.nextSegment(); long absPos = currentStartMarker + relativePos; currentStartMarker = block.currentStartMarker(); currentStopMarker = block.currentStopMarker(); if (currentStartMarker - absPos > 0) { long diff = in.skip(currentStartMarker - absPos); if (diff != currentStartMarker - absPos) throw new IllegalStateException("Should have skipped " + (currentStartMarker - absPos) + " bytes, got " + diff); } relativePos = 0; segmentLen = (int)(currentStopMarker - currentStartMarker); if (DEBUG) LOGGER.debug("New segment for block # " + currentBlock); }
/** Adds a new block defined by its array of segment delimiters. * * <p>The block has length defined by the difference between the last and first * delimiter. * * <p>This method performs the initial call to {@link #nextBlock()} when the first marker * is put in. * * @param delimiter a list of segment delimiters. * @throws IllegalArgumentException if the elements of <code>delimiter</code> are negative or not increasing. */ public void addBlock(final long... delimiter) throws IllegalArgumentException, IOException { ensureNotClosed(); blocks.add(new SegmentBlock(delimiter)); if (DEBUG) LOGGER.debug("Adding a new block with delimiters " + Arrays.toString(delimiter)); if (currentBlock == -1) nextBlock(); }
/** Skips the underlying input stream to the next segment. */ private void nextSegment() throws IOException { ensureNotClosed(); final SegmentBlock block = blocks.get( currentBlock ); if ( ! block.hasMoreSegments() ) return; block.nextSegment(); long absPos = currentStartMarker + relativePos; currentStartMarker = block.currentStartMarker(); currentStopMarker = block.currentStopMarker(); if ( currentStartMarker - absPos > 0 ) { long diff = in.skip( currentStartMarker - absPos ); if ( diff != currentStartMarker - absPos ) throw new IllegalStateException( "Should have skipped " + ( currentStartMarker - absPos ) + " bytes, got " + diff ); } relativePos = 0; segmentLen = (int)( currentStopMarker - currentStartMarker ); if ( DEBUG ) LOGGER.debug( "New segment for block # " + currentBlock ); }
/** Adds a new block defined by its array of segment delimiters. * * <p>The block has length defined by the difference between the last and first * delimiter. * * <p>This method performs the initial call to {@link #nextBlock()} when the first marker * is put in. * * @param delimiter a list of segment delimiters. * @throws IllegalArgumentException if the elements of <code>delimiter</code> are negative or not increasing. */ public void addBlock( final long... delimiter ) throws IllegalArgumentException, IOException { ensureNotClosed(); blocks.add( new SegmentBlock( delimiter ) ); if ( DEBUG ) LOGGER.debug( "Adding a new block with delimiters " + Arrays.toString( delimiter ) ); if ( currentBlock == -1 ) nextBlock(); }
/** Skips the underlying input stream to the next segment. */ private void nextSegment() throws IOException { ensureNotClosed(); final SegmentBlock block = blocks.get( currentBlock ); if ( ! block.hasMoreSegments() ) return; block.nextSegment(); long absPos = currentStartMarker + relativePos; currentStartMarker = block.currentStartMarker(); currentStopMarker = block.currentStopMarker(); if ( currentStartMarker - absPos > 0 ) { long diff = in.skip( currentStartMarker - absPos ); if ( diff != currentStartMarker - absPos ) throw new IllegalStateException( "Should have skipped " + ( currentStartMarker - absPos ) + " bytes, got " + diff ); } relativePos = 0; segmentLen = (int)( currentStopMarker - currentStartMarker ); if ( DEBUG ) LOGGER.debug( "New segment for block # " + currentBlock ); }
/** * Skips to the next segment. Now {@link #currentStartMarker()} and {@link #currentStopMarker()} can be used. */ public void nextSegment() { if (! hasMoreSegments()) throw new NoSuchElementException(); currSegment++; }
/** * Skips to the next segment. Now {@link #currentStartMarker()} and {@link #currentStopMarker()} can be used. */ public void nextSegment() { if ( ! hasMoreSegments() ) throw new NoSuchElementException(); currSegment++; }