Class ZipPackage

java.lang.Object
org.apache.poi.openxml4j.opc.OPCPackage
org.apache.poi.openxml4j.opc.ZipPackage
All Implemented Interfaces:
Closeable, AutoCloseable, RelationshipSource

public final class ZipPackage extends OPCPackage
Physical zip package.
  • Constructor Details

    • ZipPackage

      public ZipPackage()
      Constructor. Creates a new, empty ZipPackage.
  • Method Details

    • getPartsImpl

      protected PackagePartCollection getPartsImpl() throws InvalidFormatException
      Retrieves the parts from this package. We assume that the package has not been yet inspect to retrieve all the parts, this method will open the archive and look for all parts contain inside it.
      Specified by:
      getPartsImpl in class OPCPackage
      Returns:
      All parts contain in this package.
      Throws:
      InvalidFormatException - if the package is not valid.
    • createPartImpl

      protected PackagePart createPartImpl(PackagePartName partName, String contentType, boolean loadRelationships)
      Create a new MemoryPackagePart from the specified URI and content type aram partName The part URI.
      Specified by:
      createPartImpl in class OPCPackage
      Parameters:
      partName - URI of the part to create.
      contentType - The part content type.
      Returns:
      The newly created zip package part, else null.
    • removePartImpl

      protected void removePartImpl(PackagePartName partName)
      Delete a part from the package
      Specified by:
      removePartImpl in class OPCPackage
      Parameters:
      partName - The URI of the part to delete.
      Throws:
      IllegalArgumentException - Throws if the part URI is nulll or invalid.
    • flushImpl

      protected void flushImpl()
      Flush the package. Do nothing.
      Specified by:
      flushImpl in class OPCPackage
    • closeImpl

      protected void closeImpl() throws IOException
      Close and save the package.
      Specified by:
      closeImpl in class OPCPackage
      Throws:
      IOException
      See Also:
    • revertImpl

      protected void revertImpl()
      Close the package without saving the document. Discard all the changes made to this package.
      Specified by:
      revertImpl in class OPCPackage
    • saveImpl

      public void saveImpl(OutputStream outputStream)
      Save this package into the specified stream
      Specified by:
      saveImpl in class OPCPackage
      Parameters:
      outputStream - The stream use to save this package.
      See Also:
    • getZipArchive

      public ZipEntrySource getZipArchive()
      Get the zip archive
      Returns:
      The zip archive.