public abstract class POIDocument extends Object implements Closeable
| Modifier | Constructor and Description |
|---|---|
protected |
POIDocument(DirectoryNode dir)
Constructs a POIDocument with the given directory node.
|
protected |
POIDocument(POIFSFileSystem fs)
Constructs from the default POIFS
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
clearDirectory()
Clear/unlink the attached directory entry
|
void |
close()
Closes the underlying
POIFSFileSystem from which
the document was read, if any. |
void |
createInformationProperties()
Will create whichever of SummaryInformation
and DocumentSummaryInformation (HPSF) properties
are not already part of your document.
|
DirectoryNode |
getDirectory() |
DocumentSummaryInformation |
getDocumentSummaryInformation()
Fetch the Document Summary Information of the document
|
protected String |
getEncryptedPropertyStreamName() |
EncryptionInfo |
getEncryptionInfo() |
protected PropertySet |
getPropertySet(String setName)
For a given named property entry, either return it or null if
if it wasn't found
|
protected PropertySet |
getPropertySet(String setName,
EncryptionInfo encryptionInfo)
For a given named property entry, either return it or null if
if it wasn't found
|
SummaryInformation |
getSummaryInformation()
Fetch the Summary Information of the document
|
protected boolean |
initDirectory()
check if we were created by POIFS otherwise create a new dummy POIFS
for storing the package data
|
void |
readProperties()
Find, and create objects for, the standard
Document Information Properties (HPSF).
|
void |
readProperties(boolean warnIfNull)
Find, and create objects for, the standard Document Information Properties (HPSF).
|
protected void |
replaceDirectory(DirectoryNode newDirectory)
Replaces the attached directory, e.g.
|
protected void |
validateInPlaceWritePossible()
Called during a
write() to ensure that the Document (and
associated POIFSFileSystem) was opened in a way compatible
with an in-place write. |
abstract void |
write()
Writes the document out to the currently open
File, via the
writeable POIFSFileSystem it was opened from. |
abstract void |
write(File newFile)
Writes the document out to the specified new
File. |
abstract void |
write(OutputStream out)
Writes the document out to the specified output stream.
|
protected void |
writeProperties()
Writes out the updated standard Document Information Properties (HPSF)
into the currently open POIFSFileSystem
|
void |
writeProperties(POIFSFileSystem outFS)
Writes out the standard Document Information Properties (HPSF)
|
protected void |
writeProperties(POIFSFileSystem outFS,
List<String> writtenEntries)
Writes out the standard Document Information Properties (HPSF)
|
protected POIDocument(DirectoryNode dir)
dir - The DirectoryNode where information is read from.protected POIDocument(POIFSFileSystem fs)
fs - the filesystem the document is read frompublic DocumentSummaryInformation getDocumentSummaryInformation()
public SummaryInformation getSummaryInformation()
public void createInformationProperties()
@Internal public void readProperties()
@Internal public void readProperties(boolean warnIfNull)
warnIfNull - log a warning if any of the property sets come back as null.
The directory is null when creating a new document from scratchprotected PropertySet getPropertySet(String setName) throws IOException
setName - The property to readIOException - If retrieving properties failsprotected PropertySet getPropertySet(String setName, EncryptionInfo encryptionInfo) throws IOException
setName - The property to readencryptionInfo - the encryption descriptor in case of cryptoAPI encryptionIOException - If retrieving properties failsprotected void writeProperties()
throws IOException
IOException - if an error when writing to the open
POIFSFileSystem occurs@Internal public void writeProperties(POIFSFileSystem outFS) throws IOException
outFS - the POIFSFileSystem to write the properties intoIOException - if an error when writing to the
POIFSFileSystem occursprotected void writeProperties(POIFSFileSystem outFS, List<String> writtenEntries) throws IOException
outFS - the POIFSFileSystem to write the properties intowrittenEntries - a list of POIFS entries to add the property names tooIOException - if an error when writing to the
POIFSFileSystem occursprotected void validateInPlaceWritePossible()
throws IllegalStateException
write() to ensure that the Document (and
associated POIFSFileSystem) was opened in a way compatible
with an in-place write.IllegalStateException - if the document was opened suitablypublic abstract void write()
throws IOException
File, via the
writeable POIFSFileSystem it was opened from.
This will fail (with an IllegalStateException if the
document was opened read-only, opened from an InputStream
instead of a File, or if this is not the root document. For those cases,
you must use write(OutputStream) or write(File) to
write to a brand new document.
IOException - thrown on errors writing to the fileIllegalStateException - if this isn't from a writable Filepublic abstract void write(File newFile) throws IOException
File. If the file
exists, it will be replaced, otherwise a new one will be creatednewFile - The new File to write to.IOException - thrown on errors writing to the filepublic abstract void write(OutputStream out) throws IOException
File rather
than an InputStream, you must write out using
write() or to a different File. Overwriting the currently
open file via an OutputStream isn't possible.
If stream is a FileOutputStream on a networked drive
or has a high cost/latency associated with each written byte,
consider wrapping the OutputStream in a BufferedOutputStream
to improve write performance, or use write() / write(File)
if possible.out - The stream to write to.IOException - thrown on errors writing to the streampublic void close()
throws IOException
POIFSFileSystem from which
the document was read, if any. Has no effect on documents
opened from an InputStream, or newly created ones.
Once close() has been called, no further operations
should be called on the document.
close in interface Closeableclose in interface AutoCloseableIOException@Internal public DirectoryNode getDirectory()
@Internal protected void clearDirectory()
@Internal protected boolean initDirectory()
true if dummy directory was created, false otherwise@Internal protected void replaceDirectory(DirectoryNode newDirectory) throws IOException
newDirectory - the new directoryIOExceptionprotected String getEncryptedPropertyStreamName()
public EncryptionInfo getEncryptionInfo() throws IOException
nullIOException - If retrieving the encryption information fails