Class OFDDir
java.lang.Object
org.ofdrw.pkg.container.VirtualContainer
org.ofdrw.pkg.container.OFDDir
- All Implemented Interfaces:
Closeable, AutoCloseable
OFD文档对象
请显示的调用Close或clean方法清除工作过程中的文件和目录
- Since:
- 2020-01-18 13:00:45
- Author:
- 权观宇
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetDocByIndex(int index) 通过文档索引获取文档容器获取 解密入口文件getFileAbs(String absPath) 获取OFD虚拟容器中的文件获取OFD文档中最新的文档目录getOfd()获取voidjar(OutputStream outStream) 打包成OFD并输出到流void打包成OFDnewDoc()新建一个文档容器static OFDDirnewOFD()新建一个OFD文档obtainDoc(int index) 获取指定Index的文档获取第一个文档容器作为默认获取 解密入口文件putFileAbs(String absPath, Path path) 将文件写入OFD虚拟容器,若路径不存在则创建setEncryptions(Encryptions encryptions) 设置 解密入口文件设置 文档主入口文件对象voidwalk(OFDPackageFileIterator iterator) 遍历OFD文件包内的所有文件Methods inherited from class VirtualContainer
addRaw, clean, close, deleteFile, exist, exit, flush, flushContainerByName, flushFileByName, getAbsLoc, getContainer, getContainerName, getContainerPath, getFile, getFile, getObj, getObj, getParent, getSysAbsPath, obtainContainer, putFile, putFile, putFile, putFileWithPath, putObj, setContainerPath, setParent, syncCacheWithFileSystemModifier and TypeMethodDescriptionaddRaw(String fileName, InputStream in) 向虚拟容器中直接加入流类型资源voidclean()删除整个虚拟容器voidclose()voiddeleteFile(String fileName) 删除文件boolean判断文件或对象是否存在booleanDeprecated.voidflush()将缓存中的对象写入到文件系统中flushContainerByName(String name) 从缓存中刷新指定容器到文件系统中flushFileByName(String name) 从缓存将指定对象写入到文件系统中获取在容器中的绝对路径<R extends VirtualContainer>
RgetContainer(String name, Function<Path, R> mapper) 获取虚拟容器获取虚拟容器的名称获取虚拟容器所处的文件系统路径获取容器中的文件对象通过路径获取文件org.dom4j.Element通过文件名获取元素对象org.dom4j.Element通过路径获取元素获取该容器所属容器获取当前容器完整路径<R extends VirtualContainer>
RobtainContainer(String name, Function<Path, R> mapper) 获取一个虚拟容器对象void向虚拟容器中加入文件voidputFile(String fileName, InputStream in) 向虚拟容器中加入文件向虚拟容器中加入文件putFileWithPath(Path file) 向虚拟容器中加入文件,并获取文件在容器中的绝对路径向虚拟容器加入对象setContainerPath(String actualFullPath) 修正容器的文件系统路径与名称protected VirtualContainersetParent(VirtualContainer parent) 设置所属容器使目录与文件缓存与当前文件系统保持一致(仅用于读取方向)
-
Field Details
-
OFDFileName
-
EncryptionsFileName
-
OFDEntriesFileName
-
-
Constructor Details
-
OFDDir
指定路径创建或读取OFD文档容器如果容器文档已经存在,那么读取
如果文档不存在那么创建一个文档
- Parameters:
fullDir- 完整路径- Throws:
IllegalArgumentException- 路径参数异常
-
-
Method Details
-
newOFD
-
getOfd
获取- Returns:
- 文档主入口文件对象
- Throws:
FileNotFoundException- 文档主入口文件不存在org.dom4j.DocumentException- 文档主入口文件解析异常
-
setOfd
-
obtainEncryptions
-
getEncryptions
获取 解密入口文件- Returns:
- 解密入口文件 或 null(不存在)
- Throws:
org.dom4j.DocumentException- 解密入口文件无法解析
-
setEncryptions
设置 解密入口文件- Parameters:
encryptions- 解密入口文件- Returns:
- this
-
newDoc
-
obtainDoc
-
getLatestDir
-
getDocByIndex
通过文档索引获取文档容器- Parameters:
index- 文档索引- Returns:
- 文档容器
- Throws:
FileNotFoundException- 指定索引的文档容器不存在
-
getDocDir
- Throws:
FileNotFoundException
-
obtainDocDefault
-
putFileAbs
将文件写入OFD虚拟容器,若路径不存在则创建- Parameters:
absPath- 文件绝对路径,例如:"/Doc_0/Document.xml"path- 文件路径- Returns:
- 文件在OFD虚拟容器中的路径
- Throws:
IOException- IO异常
-
getFileAbs
获取OFD虚拟容器中的文件- Parameters:
absPath- 文件绝对路径,例如:"/Doc_0/Document.xml"- Returns:
- 文件路径
- Throws:
InvalidPathException- 文件不存在
-
jar
打包成OFD并输出到流1. 创建文件夹复制文件 2. 打包 3. 删除临时文件
使用操作系统临时文件夹作为输出流数据
- Parameters:
outStream- 输出流- Throws:
IOException- IO异常
-
jar
打包成OFD1. 创建文件夹复制文件 2. 打包 3. 删除临时文件
使用操作系统临时文件夹作为生成OFD文件的临时路径
- Parameters:
filePath- OFD文件名称路径(含后缀名)- Throws:
IOException- IO异常
-
walk
遍历OFD文件包内的所有文件- Parameters:
iterator- OFD包内文件迭代器- Throws:
IOException- 文件读写异常
-
VirtualContainer.exist(String)