/** * Returns an iterator that'll supply one {@link ByteBuffer} * per block in the stream. */ public Iterator<ByteBuffer> iterator() { return getBlockIterator(); }
/** * Returns an iterator that'll supply one {@link ByteBuffer} * per block in the stream. */ public Iterator<ByteBuffer> iterator() { return getBlockIterator(); }
Iterator<ByteBuffer> getBlockIterator() { if(getSize() > 0) { return _stream.getBlockIterator(); } else { List<ByteBuffer> empty = Collections.emptyList(); return empty.iterator(); } }
Iterator<ByteBuffer> getBlockIterator() { if(getSize() > 0) { return _stream.getBlockIterator(); } else { List<ByteBuffer> empty = Collections.emptyList(); return empty.iterator(); } }
/** * Load the block at the given offset. */ protected ByteBuffer getBlockAt(final int offset) throws IOException { // Which big block is this? int byteOffset = offset * POIFSConstants.SMALL_BLOCK_SIZE; int bigBlockNumber = byteOffset / _filesystem.getBigBlockSize(); int bigBlockOffset = byteOffset % _filesystem.getBigBlockSize(); // Now locate the data block for it Iterator<ByteBuffer> it = _mini_stream.getBlockIterator(); for(int i=0; i<bigBlockNumber; i++) { it.next(); } ByteBuffer dataBlock = it.next(); if(dataBlock == null) { throw new IndexOutOfBoundsException("Big block " + bigBlockNumber + " outside stream"); } // Position ourselves, and take a slice dataBlock.position( dataBlock.position() + bigBlockOffset ); ByteBuffer miniBuffer = dataBlock.slice(); miniBuffer.limit(POIFSConstants.SMALL_BLOCK_SIZE); return miniBuffer; }
/** * Load the block at the given offset. */ protected ByteBuffer getBlockAt(final int offset) throws IOException { // Which big block is this? int byteOffset = offset * POIFSConstants.SMALL_BLOCK_SIZE; int bigBlockNumber = byteOffset / _filesystem.getBigBlockSize(); int bigBlockOffset = byteOffset % _filesystem.getBigBlockSize(); // Now locate the data block for it Iterator<ByteBuffer> it = _mini_stream.getBlockIterator(); for(int i=0; i<bigBlockNumber; i++) { it.next(); } ByteBuffer dataBlock = it.next(); if(dataBlock == null) { throw new IndexOutOfBoundsException("Big block " + bigBlockNumber + " outside stream"); } // Position ourselves, and take a slice dataBlock.position( dataBlock.position() + bigBlockOffset ); ByteBuffer miniBuffer = dataBlock.slice(); miniBuffer.limit(POIFSConstants.SMALL_BLOCK_SIZE); return miniBuffer; }