public abstract class POIDocument
extends java.lang.Object
implements java.io.Closeable
Modifier | Constructor and Description |
---|---|
protected |
POIDocument(DirectoryNode dir)
Constructs a POIDocument with the given directory node.
(用给定的目录节点构造一个 POIDocument。)
|
protected |
POIDocument(POIFSFileSystem fs)
Constructs from the default POIFS
(从默认 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.
(关闭从中读取文档的基础 POIFSFileSystem(如果有)。)
|
void |
createInformationProperties()
Will create whichever of SummaryInformation and DocumentSummaryInformation (HPSF) properties are not already part of your document.
(将创建尚未包含在文档中的 SummaryInformation 和 DocumentSummaryInformation (HPSF) 属性。)
|
DirectoryNode |
getDirectory() |
DocumentSummaryInformation |
getDocumentSummaryInformation()
Fetch the Document Summary Information of the document
(获取文档的文档摘要信息)
|
protected java.lang.String |
getEncryptedPropertyStreamName() |
EncryptionInfo |
getEncryptionInfo() |
protected PropertySet |
getPropertySet(java.lang.String setName)
For a given named property entry, either return it or null if if it wasn't found
(对于给定的命名属性条目,如果未找到,则返回它或 null)
|
protected PropertySet |
getPropertySet(java.lang.String setName, EncryptionInfo encryptionInfo)
For a given named property entry, either return it or null if if it wasn't found
(对于给定的命名属性条目,如果未找到,则返回它或 null)
|
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
(检查我们是否由 POIFS 创建,否则创建一个新的虚拟 POIFS 用于存储包数据)
|
void |
readProperties()
Find, and create objects for, the standard Document Information Properties (HPSF).
(查找标准文档信息属性 (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.
(在 write() 期间调用,以确保以与就地写入兼容的方式打开文档(和相关的 POIFSFileSystem)。)
|
abstract void |
write()
Writes the document out to the currently open
File , via the writeable
POIFSFileSystem it was opened from.
(通过打开它的可写 POIFSFileSystem 将文档写入当前打开的文件。)
|
abstract void |
write(java.io.File newFile)
Writes the document out to the specified new
File .
(将文档写入指定的新文件。)
|
abstract void |
write(java.io.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
(将更新的标准文档信息属性 (HPSF) 写入当前打开的 POIFSFileSystem)
|
void |
writeProperties(POIFSFileSystem outFS)
Writes out the standard Document Information Properties (HPSF)
(写出标准文档信息属性 (HPSF))
|
protected void |
writeProperties(POIFSFileSystem outFS, java.util.List<java.lang.String> writtenEntries)
Writes out the standard Document Information Properties (HPSF)
(写出标准文档信息属性 (HPSF))
|
protected POIDocument(DirectoryNode dir)
dir
- The
DirectoryNode
where information is read from.
(dir - 从中读取信息的 DirectoryNode。)
protected POIDocument(POIFSFileSystem fs)
fs
- the filesystem the document is read from
(fs - 从中读取文档的文件系统)
public DocumentSummaryInformation getDocumentSummaryInformation()
public SummaryInformation getSummaryInformation()
public void createInformationProperties()
@Internal public void readProperties()
protected PropertySet getPropertySet(java.lang.String setName) throws java.io.IOException
setName
- The property to read
(setName - 要读取的属性)
java.io.IOException
- If retrieving properties fails
(java.io.IOException - 如果检索属性失败)
protected PropertySet getPropertySet(java.lang.String setName, EncryptionInfo encryptionInfo) throws java.io.IOException
setName
- The property to read
(setName - 要读取的属性)
encryptionInfo
- the encryption descriptor in case of cryptoAPI encryption
(encryptionInfo - cryptoAPI 加密情况下的加密描述符)
java.io.IOException
- If retrieving properties fails
(java.io.IOException - 如果检索属性失败)
protected void writeProperties() throws java.io.IOException
java.io.IOException
- if an error when writing to the open
POIFSFileSystem
occurs
(java.io.IOException - 如果写入打开的 POIFSFileSystem 时发生错误)
@Internal public void writeProperties(POIFSFileSystem outFS) throws java.io.IOException
outFS
- the POIFSFileSystem to write the properties into
(outFS - 将属性写入的 POIFSFileSystem)
java.io.IOException
- if an error when writing to the
POIFSFileSystem
occurs
(java.io.IOException - 如果写入 POIFSFileSystem 时发生错误)
protected void writeProperties(POIFSFileSystem outFS, java.util.List<java.lang.String> writtenEntries) throws java.io.IOException
outFS
- the
POIFSFileSystem
to write the properties into
(outFS - 将属性写入的 POIFSFileSystem)
writtenEntries
- a list of POIFS entries to add the property names too
(writtenEntries - 一个 POIFS 条目列表,也可以添加属性名称)
java.io.IOException
- if an error when writing to the
POIFSFileSystem
occurs
(java.io.IOException - 如果写入 POIFSFileSystem 时发生错误)
protected void validateInPlaceWritePossible() throws java.lang.IllegalStateException
write()
to ensure that the Document (and associated
POIFSFileSystem
) was opened in a way compatible with an in-place write.
(在 write() 期间调用,以确保以与就地写入兼容的方式打开文档(和相关的 POIFSFileSystem)。)
java.lang.IllegalStateException
- if the document was opened suitably
(java.lang.IllegalStateException - 如果文档打开得当)
public abstract void write() throws java.io.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.
java.io.IOException
- thrown on errors writing to the file
(java.io.IOException - 写入文件出错时抛出)
java.lang.IllegalStateException
- if this isn't from a writable File
(java.lang.IllegalStateException - 如果这不是来自可写文件)
public abstract void write(java.io.File newFile) throws java.io.IOException
File
. If the file exists, it will be replaced, otherwise a new one will be created
(将文档写入指定的新文件。如果文件存在,则将其替换,否则将创建一个新文件)
newFile
- The new File to write to.
(newFile - 要写入的新文件。)
java.io.IOException
- thrown on errors writing to the file
(java.io.IOException - 写入文件出错时抛出)
public abstract void write(java.io.OutputStream out) throws java.io.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.
(将文档写入指定的输出流。作为此操作的一部分,流不会关闭。注意 - 如果 Document 是从 File 而不是 InputStream 打开的,则必须使用 write() 或写入不同的 File。无法通过 OutputStream 覆盖当前打开的文件。如果流是网络驱动器上的 FileOutputStream 或与每个写入字节相关的成本/延迟较高,请考虑将 OutputStream 包装在 BufferedOutputStream 中以提高写入性能,或尽可能使用 write() / write(File)。)
out
- The stream to write to.
(out - 要写入的流。)
java.io.IOException
- thrown on errors writing to the stream
(java.io.IOException - 写入流时抛出错误)
public void close() throws java.io.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
java.io.Closeable
(在接口 java.io.Closeable 中关闭)
close
in interface
java.lang.AutoCloseable
(在接口 java.lang.AutoCloseable 中关闭)
java.io.IOException
(java.io.IOException)
@Internal public DirectoryNode getDirectory()
@Internal protected void clearDirectory()
@Internal protected boolean initDirectory()
true
if dummy directory was created,
false
otherwise
(如果创建了虚拟目录,则为 true,否则为 false)
@Internal protected void replaceDirectory(DirectoryNode newDirectory) throws java.io.IOException
newDirectory
- the new directory
(newDirectory - 新目录)
java.io.IOException
(java.io.IOException)
protected java.lang.String getEncryptedPropertyStreamName()
public EncryptionInfo getEncryptionInfo() throws java.io.IOException
null
(如果文档已加密,则为加密信息,否则为 null)
java.io.IOException
- If retrieving the encryption information fails
(java.io.IOException - 如果检索加密信息失败)
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.