/** * Writes the properties out into the given low-level stream */ public void write(POIFSStream stream) throws IOException { OutputStream os = stream.getOutputStream(); for(Property property : _properties) { if(property != null) { property.writeData(os); } } os.close(); // Update the start position if needed if(getStartBlock() != stream.getStartBlock()) { setStartBlock(stream.getStartBlock()); } }
public void close() throws IOException { // Do we have a pending buffer for the mini stream? if (_buffer != null) { // It's not much data, so ask POIFSDocument to do it for us _document.replaceContents(new ByteArrayInputStream(_buffer.toByteArray())); } else { // We've been writing to the stream as we've gone along // Update the details on the property now _stream_output.close(); _property.updateSize(_document_size); _property.setStartBlock(_stream.getStartBlock()); } // No more! _closed = true; }
public void replaceContents(InputStream stream) throws IOException { free(); int size = store(stream); _property.setStartBlock(_stream.getStartBlock()); _property.updateSize(size); }
/** * Constructor for a new Document * * @param name the name of the POIFSDocument * @param stream the InputStream we read data from */ public POIFSDocument(String name, POIFSFileSystem filesystem, InputStream stream) throws IOException { this._filesystem = filesystem; // Store it int length = store(stream); // Build the property for it this._property = new DocumentProperty(name, length); _property.setStartBlock(_stream.getStartBlock()); _property.setDocument(this); }
if (_mini_stream.getStartBlock() == POIFSConstants.END_OF_CHAIN) { firstInStore = true; int block = _mini_stream.getStartBlock(); while(true) { loopDetector.claim(block);
public POIFSDocument(String name, final int size, POIFSFileSystem filesystem, POIFSWriterListener writer) throws IOException { this._filesystem = filesystem; if (size < POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE) { _stream = new POIFSStream(filesystem.getMiniStore()); _block_size = _filesystem.getMiniStore().getBlockStoreBlockSize(); } else { _stream = new POIFSStream(filesystem); _block_size = _filesystem.getBlockStoreBlockSize(); } this._property = new DocumentProperty(name, size); _property.setStartBlock(_stream.getStartBlock()); _property.setDocument(this); try (DocumentOutputStream os = new DocumentOutputStream(this, size)) { POIFSDocumentPath path = new POIFSDocumentPath(name.split("\\\\")); String docName = path.getComponent(path.length() - 1); POIFSWriterEvent event = new POIFSWriterEvent(os, path, docName, size); writer.processPOIFSWriterEvent(event); } }
public void close() throws IOException { // Do we have a pending buffer for the mini stream? if (_buffer != null) { // It's not much data, so ask POIFSDocument to do it for us _document.replaceContents(new ByteArrayInputStream(_buffer.toByteArray())); } else { // We've been writing to the stream as we've gone along // Update the details on the property now _stream_output.close(); _property.updateSize(_document_size); _property.setStartBlock(_stream.getStartBlock()); } // No more! _closed = true; }
/** * Writes the properties out into the given low-level stream */ public void write(POIFSStream stream) throws IOException { OutputStream os = stream.getOutputStream(); for(Property property : _properties) { if(property != null) { property.writeData(os); } } os.close(); // Update the start position if needed if(getStartBlock() != stream.getStartBlock()) { setStartBlock(stream.getStartBlock()); } }
public void replaceContents(InputStream stream) throws IOException { free(); int size = store(stream); _property.setStartBlock(_stream.getStartBlock()); _property.updateSize(size); }
/** * Constructor for a new Document * * @param name the name of the POIFSDocument * @param stream the InputStream we read data from */ public POIFSDocument(String name, POIFSFileSystem filesystem, InputStream stream) throws IOException { this._filesystem = filesystem; // Store it int length = store(stream); // Build the property for it this._property = new DocumentProperty(name, length); _property.setStartBlock(_stream.getStartBlock()); _property.setDocument(this); }
if (_mini_stream.getStartBlock() == POIFSConstants.END_OF_CHAIN) { firstInStore = true; int block = _mini_stream.getStartBlock(); while(true) { loopDetector.claim(block);
public POIFSDocument(String name, final int size, POIFSFileSystem filesystem, POIFSWriterListener writer) throws IOException { this._filesystem = filesystem; if (size < POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE) { _stream = new POIFSStream(filesystem.getMiniStore()); _block_size = _filesystem.getMiniStore().getBlockStoreBlockSize(); } else { _stream = new POIFSStream(filesystem); _block_size = _filesystem.getBlockStoreBlockSize(); } this._property = new DocumentProperty(name, size); _property.setStartBlock(_stream.getStartBlock()); _property.setDocument(this); try (DocumentOutputStream os = new DocumentOutputStream(this, size)) { POIFSDocumentPath path = new POIFSDocumentPath(name.split("\\\\")); String docName = path.getComponent(path.length() - 1); POIFSWriterEvent event = new POIFSWriterEvent(os, path, docName, size); writer.processPOIFSWriterEvent(event); } }