private static POIFSDocument getDocument(DocumentEntry document) throws IOException { if (!(document instanceof DocumentNode)) { throw new IOException("Cannot open internal document storage, " + document + " not a Document Node"); } return new POIFSDocument((DocumentNode)document); }
/** * create a new DocumentEntry * * @param name the name of the new DocumentEntry * @param stream the InputStream from which to create the new * DocumentEntry * * @return the new DocumentEntry * * @exception IOException if the document can't be created */ public DocumentEntry createDocument(final String name, final InputStream stream) throws IOException { return createDocument(new POIFSDocument(name, _nfilesystem, stream)); }
/** * create a new DocumentEntry; the data will be provided later * * @param name the name of the new DocumentEntry * @param size the size of the new DocumentEntry * @param writer the writer of the new DocumentEntry * * @return the new DocumentEntry * * @exception IOException if the document can't be created */ public DocumentEntry createDocument(final String name, final int size, final POIFSWriterListener writer) throws IOException { return createDocument(new POIFSDocument(name, size, _nfilesystem, writer)); }
/** * remove an entry * * @param entry to be removed */ void remove(EntryNode entry) throws IOException { // If it's a document, free the blocks if (entry instanceof DocumentEntry) { POIFSDocument doc = new POIFSDocument((DocumentProperty)entry.getProperty(), this); doc.free(); } // Now zap it from the properties list _property_table.removeProperty(entry.getProperty()); }
/** * Create an InputStream from the specified DocumentEntry * * @param document the DocumentEntry to be read * * @exception IOException if the DocumentEntry cannot be opened (like, maybe it has * been deleted?) */ public DocumentInputStream(DocumentEntry document) throws IOException { if (!(document instanceof DocumentNode)) { throw new IOException("Cannot open internal document storage, " + document + " not a Document Node"); } _current_offset = 0; _current_block_count = 0; _marked_offset = 0; _marked_offset_count = 0; _document_size = document.getSize(); _closed = false; // can't be asserted ... see bug 61300 // assert (_document_size >= 0) : "Document size can't be < 0"; DocumentNode doc = (DocumentNode)document; DocumentProperty property = (DocumentProperty)doc.getProperty(); _document = new POIFSDocument( property, ((DirectoryNode)doc.getParent()).getNFileSystem() ); _data = _document.getBlockIterator(); }
/** * Set the contents of a document, creating if needed, * otherwise updating. Returns the created / updated DocumentEntry * * @param name the name of the new or existing DocumentEntry * @param stream the InputStream from which to populate the DocumentEntry * * @return the new or updated DocumentEntry * * @exception IOException if the document can't be created or its content be replaced */ @SuppressWarnings("WeakerAccess") public DocumentEntry createOrUpdateDocument(final String name, final InputStream stream) throws IOException { if (! hasEntry(name)) { return createDocument(name, stream); } else { DocumentNode existing = (DocumentNode)getEntry(name); POIFSDocument nDoc = new POIFSDocument(existing); nDoc.replaceContents(stream); return existing; } }
/** * Write out this workbook to the currently open {@link File} via the * writeable {@link POIFSFileSystem} it was opened as. * * <p>This will fail (with an {@link IllegalStateException} if the * Workbook was opened read-only, opened from an {@link InputStream} * instead of a File, or if this is not the root document. For those cases, * you must use {@link #write(OutputStream)} or {@link #write(File)} to * write to a brand new document. */ @Override public void write() throws IOException { validateInPlaceWritePossible(); final DirectoryNode dir = getDirectory(); // Update the Workbook stream in the file DocumentNode workbookNode = (DocumentNode)dir.getEntry( getWorkbookDirEntryName(dir)); POIFSDocument workbookDoc = new POIFSDocument(workbookNode); workbookDoc.replaceContents(new ByteArrayInputStream(getBytes())); // Update the properties streams in the file writeProperties(); // Sync with the File on disk dir.getFileSystem().writeFilesystem(); }
for (POIFSReaderListener rl : registry.getListeners(path, name)) { if (document == null) { document = new POIFSDocument((DocumentProperty)property, poifs);
private static POIFSDocument getDocument(DocumentEntry document) throws IOException { if (!(document instanceof DocumentNode)) { throw new IOException("Cannot open internal document storage, " + document + " not a Document Node"); } return new POIFSDocument((DocumentNode)document); }
/** * create a new DocumentEntry; the data will be provided later * * @param name the name of the new DocumentEntry * @param size the size of the new DocumentEntry * @param writer the writer of the new DocumentEntry * * @return the new DocumentEntry * * @exception IOException */ public DocumentEntry createDocument(final String name, final int size, final POIFSWriterListener writer) throws IOException { return createDocument(new POIFSDocument(name, size, _path, writer)); }
/** * create a new DocumentEntry; the data will be provided later * * @param name the name of the new DocumentEntry * @param size the size of the new DocumentEntry * @param writer the writer of the new DocumentEntry * * @return the new DocumentEntry * * @exception IOException */ public DocumentEntry createDocument(final String name, final int size, final POIFSWriterListener writer) throws IOException { return createDocument(new POIFSDocument(name, size, _path, writer)); }
/** * create a new DocumentEntry * * @param name the name of the new DocumentEntry * @param stream the InputStream from which to create the new * DocumentEntry * * @return the new DocumentEntry * * @exception IOException if the document can't be created */ public DocumentEntry createDocument(final String name, final InputStream stream) throws IOException { return createDocument(new POIFSDocument(name, _nfilesystem, stream)); }
/** * create a new DocumentEntry; the data will be provided later * * @param name the name of the new DocumentEntry * @param size the size of the new DocumentEntry * @param writer the writer of the new DocumentEntry * * @return the new DocumentEntry * * @exception IOException if the document can't be created */ public DocumentEntry createDocument(final String name, final int size, final POIFSWriterListener writer) throws IOException { return createDocument(new POIFSDocument(name, size, _nfilesystem, writer)); }
/** * create a new DocumentEntry * * @param name the name of the new DocumentEntry * @param stream the InputStream from which to create the new * DocumentEntry * * @return the new DocumentEntry * * @exception IOException */ public DocumentEntry createDocument(final String name, final InputStream stream) throws IOException { if(_nfilesystem != null) { return createDocument(new NPOIFSDocument(name, _nfilesystem, stream)); } else { return createDocument(new POIFSDocument(name, stream)); } }
/** * create a new DocumentEntry * * @param name the name of the new DocumentEntry * @param stream the InputStream from which to create the new * DocumentEntry * * @return the new DocumentEntry * * @exception IOException */ public DocumentEntry createDocument(final String name, final InputStream stream) throws IOException { if(_nfilesystem != null) { return createDocument(new NPOIFSDocument(name, _nfilesystem, stream)); } else { return createDocument(new POIFSDocument(name, stream)); } }
/** * remove an entry * * @param entry to be removed */ void remove(EntryNode entry) throws IOException { // If it's a document, free the blocks if (entry instanceof DocumentEntry) { POIFSDocument doc = new POIFSDocument((DocumentProperty)entry.getProperty(), this); doc.free(); } // Now zap it from the properties list _property_table.removeProperty(entry.getProperty()); }
/** * Create an InputStream from the specified DocumentEntry * * @param document the DocumentEntry to be read * * @exception IOException if the DocumentEntry cannot be opened (like, maybe it has * been deleted?) */ public DocumentInputStream(DocumentEntry document) throws IOException { if (!(document instanceof DocumentNode)) { throw new IOException("Cannot open internal document storage, " + document + " not a Document Node"); } _current_offset = 0; _current_block_count = 0; _marked_offset = 0; _marked_offset_count = 0; _document_size = document.getSize(); _closed = false; // can't be asserted ... see bug 61300 // assert (_document_size >= 0) : "Document size can't be < 0"; DocumentNode doc = (DocumentNode)document; DocumentProperty property = (DocumentProperty)doc.getProperty(); _document = new POIFSDocument( property, ((DirectoryNode)doc.getParent()).getNFileSystem() ); _data = _document.getBlockIterator(); }
/** * Set the contents of a document, creating if needed, * otherwise updating. Returns the created / updated DocumentEntry * * @param name the name of the new or existing DocumentEntry * @param stream the InputStream from which to populate the DocumentEntry * * @return the new or updated DocumentEntry * * @exception IOException if the document can't be created or its content be replaced */ @SuppressWarnings("WeakerAccess") public DocumentEntry createOrUpdateDocument(final String name, final InputStream stream) throws IOException { if (! hasEntry(name)) { return createDocument(name, stream); } else { DocumentNode existing = (DocumentNode)getEntry(name); POIFSDocument nDoc = new POIFSDocument(existing); nDoc.replaceContents(stream); return existing; } }
/** * Write out this workbook to the currently open {@link File} via the * writeable {@link POIFSFileSystem} it was opened as. * * <p>This will fail (with an {@link IllegalStateException} if the * Workbook was opened read-only, opened from an {@link InputStream} * instead of a File, or if this is not the root document. For those cases, * you must use {@link #write(OutputStream)} or {@link #write(File)} to * write to a brand new document. */ @Override public void write() throws IOException { validateInPlaceWritePossible(); final DirectoryNode dir = getDirectory(); // Update the Workbook stream in the file DocumentNode workbookNode = (DocumentNode)dir.getEntry( getWorkbookDirEntryName(dir)); POIFSDocument workbookDoc = new POIFSDocument(workbookNode); workbookDoc.replaceContents(new ByteArrayInputStream(getBytes())); // Update the properties streams in the file writeProperties(); // Sync with the File on disk dir.getFileSystem().writeFilesystem(); }
for (POIFSReaderListener rl : registry.getListeners(path, name)) { if (document == null) { document = new POIFSDocument((DocumentProperty)property, poifs);