_big_store = new BigBlockStore(bigBlockSize,bigBlocks); _property = new DocumentProperty(name, _size); _property.setDocument(this); if (_property.shouldUseSmallBlocks()) { _small_store = new SmallBlockStore(bigBlockSize,SmallDocumentBlock.convert(bigBlockSize,bigBlocks, _size)); _big_store = new BigBlockStore(bigBlockSize,new DocumentBlock[0]); } else { _small_store = new SmallBlockStore(bigBlockSize,EMPTY_SMALL_BLOCK_ARRAY);
_big_store = new BigBlockStore(bigBlockSize,bigBlocks); _property = new DocumentProperty(name, _size); _property.setDocument(this); if (_property.shouldUseSmallBlocks()) { _small_store = new SmallBlockStore(bigBlockSize,SmallDocumentBlock.convert(bigBlockSize,bigBlocks, _size)); _big_store = new BigBlockStore(bigBlockSize,new DocumentBlock[0]); } else { _small_store = new SmallBlockStore(bigBlockSize,EMPTY_SMALL_BLOCK_ARRAY);
/** * Constructor from large blocks * * @param name the name of the POIFSDocument * @param blocks the big blocks making up the POIFSDocument * @param length the actual length of the POIFSDocument */ public POIFSDocument(String name, RawDataBlock[] blocks, int length) throws IOException { _size = length; if(blocks.length == 0) { _bigBigBlockSize = POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS; } else { _bigBigBlockSize = (blocks[0].getBigBlockSize() == POIFSConstants.SMALLER_BIG_BLOCK_SIZE ? POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS : POIFSConstants.LARGER_BIG_BLOCK_SIZE_DETAILS ); } _big_store = new BigBlockStore(_bigBigBlockSize, convertRawBlocksToBigBlocks(blocks)); _property = new DocumentProperty(name, _size); _small_store = new SmallBlockStore(_bigBigBlockSize, EMPTY_SMALL_BLOCK_ARRAY); _property.setDocument(this); }
/** * Constructor * * @param name the name of the POIFSDocument * @param size the length of the POIFSDocument * @param path the path of the POIFSDocument * @param writer the writer who will eventually write the document contents */ public POIFSDocument(String name, int size, POIFSBigBlockSize bigBlockSize, POIFSDocumentPath path, POIFSWriterListener writer) { _size = size; _bigBigBlockSize = bigBlockSize; _property = new DocumentProperty(name, _size); _property.setDocument(this); if (_property.shouldUseSmallBlocks()) { _small_store = new SmallBlockStore(_bigBigBlockSize, path, name, size, writer); _big_store = new BigBlockStore(_bigBigBlockSize, EMPTY_BIG_BLOCK_ARRAY); } else { _small_store = new SmallBlockStore(_bigBigBlockSize, EMPTY_SMALL_BLOCK_ARRAY); _big_store = new BigBlockStore(_bigBigBlockSize, path, name, size, writer); } } public POIFSDocument(String name, int size, POIFSDocumentPath path, POIFSWriterListener writer) {
/** * Constructor * * @param name the name of the POIFSDocument * @param size the length of the POIFSDocument * @param path the path of the POIFSDocument * @param writer the writer who will eventually write the document contents */ public POIFSDocument(String name, int size, POIFSBigBlockSize bigBlockSize, POIFSDocumentPath path, POIFSWriterListener writer) { _size = size; _bigBigBlockSize = bigBlockSize; _property = new DocumentProperty(name, _size); _property.setDocument(this); if (_property.shouldUseSmallBlocks()) { _small_store = new SmallBlockStore(_bigBigBlockSize, path, name, size, writer); _big_store = new BigBlockStore(_bigBigBlockSize, EMPTY_BIG_BLOCK_ARRAY); } else { _small_store = new SmallBlockStore(_bigBigBlockSize, EMPTY_SMALL_BLOCK_ARRAY); _big_store = new BigBlockStore(_bigBigBlockSize, path, name, size, writer); } } public POIFSDocument(String name, int size, POIFSDocumentPath path, POIFSWriterListener writer) {
/** * Constructor from small blocks * * @param name the name of the POIFSDocument * @param blocks the small blocks making up the POIFSDocument * @param length the actual length of the POIFSDocument */ public POIFSDocument(String name, POIFSBigBlockSize bigBlockSize, ListManagedBlock[] blocks, int length) throws IOException { _size = length; _bigBigBlockSize = bigBlockSize; _property = new DocumentProperty(name, _size); _property.setDocument(this); if (Property.isSmall(_size)) { _big_store = new BigBlockStore(bigBlockSize,EMPTY_BIG_BLOCK_ARRAY); _small_store = new SmallBlockStore(bigBlockSize,convertRawBlocksToSmallBlocks(blocks)); } else { _big_store = new BigBlockStore(bigBlockSize,convertRawBlocksToBigBlocks(blocks)); _small_store = new SmallBlockStore(bigBlockSize,EMPTY_SMALL_BLOCK_ARRAY); } } public POIFSDocument(String name, ListManagedBlock[] blocks, int length) throws IOException {
/** * Constructor from small blocks * * @param name the name of the POIFSDocument * @param blocks the small blocks making up the POIFSDocument * @param length the actual length of the POIFSDocument */ public POIFSDocument(String name, POIFSBigBlockSize bigBlockSize, ListManagedBlock[] blocks, int length) throws IOException { _size = length; _bigBigBlockSize = bigBlockSize; _property = new DocumentProperty(name, _size); _property.setDocument(this); if (Property.isSmall(_size)) { _big_store = new BigBlockStore(bigBlockSize,EMPTY_BIG_BLOCK_ARRAY); _small_store = new SmallBlockStore(bigBlockSize,convertRawBlocksToSmallBlocks(blocks)); } else { _big_store = new BigBlockStore(bigBlockSize,convertRawBlocksToBigBlocks(blocks)); _small_store = new SmallBlockStore(bigBlockSize,EMPTY_SMALL_BLOCK_ARRAY); } } public POIFSDocument(String name, ListManagedBlock[] blocks, int length) throws IOException {
/** * Constructor from large blocks * * @param name the name of the POIFSDocument * @param blocks the big blocks making up the POIFSDocument * @param length the actual length of the POIFSDocument */ public POIFSDocument(String name, RawDataBlock[] blocks, int length) throws IOException { _size = length; if(blocks.length == 0) { _bigBigBlockSize = POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS; } else { _bigBigBlockSize = (blocks[0].getBigBlockSize() == POIFSConstants.SMALLER_BIG_BLOCK_SIZE ? POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS : POIFSConstants.LARGER_BIG_BLOCK_SIZE_DETAILS ); } _big_store = new BigBlockStore(_bigBigBlockSize, convertRawBlocksToBigBlocks(blocks)); _property = new DocumentProperty(name, _size); _small_store = new SmallBlockStore(_bigBigBlockSize, EMPTY_SMALL_BLOCK_ARRAY); _property.setDocument(this); }
/** * Constructor from small blocks * * @param name the name of the POIFSDocument * @param blocks the small blocks making up the POIFSDocument * @param length the actual length of the POIFSDocument */ public POIFSDocument(String name, SmallDocumentBlock[] blocks, int length) { _size = length; if(blocks.length == 0) { _bigBigBlockSize = POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS; } else { _bigBigBlockSize = blocks[0].getBigBlockSize(); } _big_store = new BigBlockStore(_bigBigBlockSize, EMPTY_BIG_BLOCK_ARRAY); _property = new DocumentProperty(name, _size); _small_store = new SmallBlockStore(_bigBigBlockSize, blocks); _property.setDocument(this); }
/** * write the blocks to a stream * * @param stream the stream to which the data is to be written */ void writeBlocks(OutputStream stream) throws IOException { if (isValid()) { if (_writer != null) { DocumentOutputStream dstream = new DocumentOutputStream(stream, _size); _writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, _path, _name, _size)); dstream.writeFiller(countBlocks() * _bigBlockSize.getBigBlockSize(), DocumentBlock.getFillByte()); } else { for (int k = 0; k < bigBlocks.length; k++) { bigBlocks[k].writeBlocks(stream); } } } }
/** * Constructor from small blocks * * @param name the name of the POIFSDocument * @param blocks the small blocks making up the POIFSDocument * @param length the actual length of the POIFSDocument */ public POIFSDocument(String name, SmallDocumentBlock[] blocks, int length) { _size = length; if(blocks.length == 0) { _bigBigBlockSize = POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS; } else { _bigBigBlockSize = blocks[0].getBigBlockSize(); } _big_store = new BigBlockStore(_bigBigBlockSize, EMPTY_BIG_BLOCK_ARRAY); _property = new DocumentProperty(name, _size); _small_store = new SmallBlockStore(_bigBigBlockSize, blocks); _property.setDocument(this); }
/** * write the blocks to a stream * * @param stream the stream to which the data is to be written */ void writeBlocks(OutputStream stream) throws IOException { if (isValid()) { if (_writer != null) { DocumentOutputStream dstream = new DocumentOutputStream(stream, _size); _writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, _path, _name, _size)); dstream.writeFiller(countBlocks() * _bigBlockSize.getBigBlockSize(), DocumentBlock.getFillByte()); } else { for (int k = 0; k < bigBlocks.length; k++) { bigBlocks[k].writeBlocks(stream); } } } }
/** * @return <code>null</code> if <tt>offset</tt> points to the end of the document stream */ DataInputBlock getDataInputBlock(int offset) { if (offset >= _size) { if (offset > _size) { throw new RuntimeException("Request for Offset " + offset + " doc size is " + _size); } return null; } if (_property.shouldUseSmallBlocks()) { return SmallDocumentBlock.getDataInputBlock(_small_store.getBlocks(), offset); } return DocumentBlock.getDataInputBlock(_big_store.getBlocks(), offset); }
/** * @return <code>null</code> if <tt>offset</tt> points to the end of the document stream */ DataInputBlock getDataInputBlock(int offset) { if (offset >= _size) { if (offset > _size) { throw new RuntimeException("Request for Offset " + offset + " doc size is " + _size); } return null; } if (_property.shouldUseSmallBlocks()) { return SmallDocumentBlock.getDataInputBlock(_small_store.getBlocks(), offset); } return DocumentBlock.getDataInputBlock(_big_store.getBlocks(), offset); }
/** * @return number of big blocks making up this document */ int countBlocks() { if (isValid()) { if (_writer == null) { return bigBlocks.length; } return (_size + _bigBlockSize.getBigBlockSize() - 1) / _bigBlockSize.getBigBlockSize(); } return 0; } } // end private class BigBlockStore
/** * @return number of big blocks making up this document */ int countBlocks() { if (isValid()) { if (_writer == null) { return bigBlocks.length; } return (_size + _bigBlockSize.getBigBlockSize() - 1) / _bigBlockSize.getBigBlockSize(); } return 0; } } // end private class BigBlockStore
/** * Return the number of BigBlock's this instance uses * * @return count of BigBlock instances */ public int countBlocks() { return _big_store.countBlocks(); }
/** * @return the DocumentBlocks */ DocumentBlock[] getBlocks() { if (isValid() && _writer != null) { ByteArrayOutputStream stream = new ByteArrayOutputStream(_size); DocumentOutputStream dstream = new DocumentOutputStream(stream, _size); _writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, _path, _name, _size)); bigBlocks = DocumentBlock.convert(_bigBlockSize, stream.toByteArray(), _size); } return bigBlocks; }