Class OFDDir

All Implemented Interfaces:
Closeable, AutoCloseable

public class OFDDir extends VirtualContainer
OFD文档对象

请显示的调用Close或clean方法清除工作过程中的文件和目录

Since:
2020-01-18 13:00:45
Author:
权观宇
  • Field Details

  • Constructor Details

    • OFDDir

      public OFDDir(Path fullDir) throws IllegalArgumentException
      指定路径创建或读取OFD文档容器

      如果容器文档已经存在,那么读取

      如果文档不存在那么创建一个文档

      Parameters:
      fullDir - 完整路径
      Throws:
      IllegalArgumentException - 路径参数异常
  • Method Details

    • newOFD

      public static OFDDir newOFD()
      新建一个OFD文档
      Returns:
      OFD文档
    • getOfd

      public OFD getOfd() throws FileNotFoundException, org.dom4j.DocumentException
      获取
      Returns:
      文档主入口文件对象
      Throws:
      FileNotFoundException - 文档主入口文件不存在
      org.dom4j.DocumentException - 文档主入口文件解析异常
    • setOfd

      public OFDDir setOfd(OFD ofd)
      设置 文档主入口文件对象
      Parameters:
      ofd - 文档主入口文件对象
      Returns:
      this
    • obtainEncryptions

      public Encryptions obtainEncryptions()
      获取 解密入口文件

      如果文件不存在那么创建新的文件

      Returns:
      解密入口文件
    • getEncryptions

      public Encryptions getEncryptions() throws org.dom4j.DocumentException
      获取 解密入口文件
      Returns:
      解密入口文件 或 null(不存在)
      Throws:
      org.dom4j.DocumentException - 解密入口文件无法解析
    • setEncryptions

      public OFDDir setEncryptions(Encryptions encryptions)
      设置 解密入口文件
      Parameters:
      encryptions - 解密入口文件
      Returns:
      this
    • newDoc

      public DocDir newDoc()
      新建一个文档容器
      Returns:
      新建的文档容器
    • obtainDoc

      public DocDir obtainDoc(int index)
      获取指定Index的文档

      如果文档不存在那么创建

      Parameters:
      index - index
      Returns:
      文档容器
    • getLatestDir

      public DocDir getLatestDir()
      获取OFD文档中最新的文档目录

      一般来说序号最大的最新 Doc_N

      Returns:
      文档目录
    • getDocByIndex

      public DocDir getDocByIndex(int index) throws FileNotFoundException
      通过文档索引获取文档容器
      Parameters:
      index - 文档索引
      Returns:
      文档容器
      Throws:
      FileNotFoundException - 指定索引的文档容器不存在
    • getDocDir

      public DocDir getDocDir(String name) throws FileNotFoundException
      Throws:
      FileNotFoundException
    • obtainDocDefault

      public DocDir obtainDocDefault()
      获取第一个文档容器作为默认
      Returns:
      第一个文档容器
    • putFileAbs

      public ST_Loc putFileAbs(String absPath, Path path) throws IOException
      将文件写入OFD虚拟容器,若路径不存在则创建
      Parameters:
      absPath - 文件绝对路径,例如:"/Doc_0/Document.xml"
      path - 文件路径
      Returns:
      文件在OFD虚拟容器中的路径
      Throws:
      IOException - IO异常
    • getFileAbs

      public Path getFileAbs(String absPath)
      获取OFD虚拟容器中的文件
      Parameters:
      absPath - 文件绝对路径,例如:"/Doc_0/Document.xml"
      Returns:
      文件路径
      Throws:
      InvalidPathException - 文件不存在
    • jar

      public void jar(OutputStream outStream) throws IOException
      打包成OFD并输出到流

      1. 创建文件夹复制文件 2. 打包 3. 删除临时文件

      使用操作系统临时文件夹作为输出流数据

      Parameters:
      outStream - 输出流
      Throws:
      IOException - IO异常
    • jar

      public void jar(Path filePath) throws IOException
      打包成OFD

      1. 创建文件夹复制文件 2. 打包 3. 删除临时文件

      使用操作系统临时文件夹作为生成OFD文件的临时路径

      Parameters:
      filePath - OFD文件名称路径(含后缀名)
      Throws:
      IOException - IO异常
    • walk

      public void walk(OFDPackageFileIterator iterator) throws IOException
      遍历OFD文件包内的所有文件
      Parameters:
      iterator - OFD包内文件迭代器
      Throws:
      IOException - 文件读写异常