Class ZipHelper


  • @Internal
    public final class ZipHelper
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ZipArchiveEntry getCorePropertiesZipEntry​(ZipPackage pkg)
      Retrieve the zip entry of the core properties part.
      static java.lang.String getOPCNameFromZipItemName​(java.lang.String zipItemName)
      Convert a zip name into an OPC name by adding a leading forward slash to the specified item name.
      static java.lang.String getZipItemNameFromOPCName​(java.lang.String opcItemName)
      Convert an OPC item name into a zip item name by removing any leading forward slash if it exist.
      static java.net.URI getZipURIFromOPCName​(java.lang.String opcItemName)
      Convert an OPC item name into a zip URI by removing any leading forward slash if it exist.
      static ZipSecureFile openZipFile​(java.io.File file)
      Opens the specified file as a secure zip, or returns null if no such file exists
      static ZipSecureFile openZipFile​(java.lang.String path)
      Retrieve and open as a secure zip file with the specified path.
      static ZipArchiveThresholdInputStream openZipStream​(java.io.InputStream stream)
      Opens the specified stream as a secure zip
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getCorePropertiesZipEntry

        public static ZipArchiveEntry getCorePropertiesZipEntry​(ZipPackage pkg)
        Retrieve the zip entry of the core properties part.
        Throws:
        java.lang.IllegalArgumentException - If the relationship for core properties cannot be read or an invalid name is specified in the properties.
      • getOPCNameFromZipItemName

        public static java.lang.String getOPCNameFromZipItemName​(java.lang.String zipItemName)
        Convert a zip name into an OPC name by adding a leading forward slash to the specified item name.
        Parameters:
        zipItemName - Zip item name to convert.
        Returns:
        An OPC compliant name.
      • getZipItemNameFromOPCName

        public static java.lang.String getZipItemNameFromOPCName​(java.lang.String opcItemName)
        Convert an OPC item name into a zip item name by removing any leading forward slash if it exist.
        Parameters:
        opcItemName - The OPC item name to convert.
        Returns:
        A zip item name without any leading slashes.
      • getZipURIFromOPCName

        public static java.net.URI getZipURIFromOPCName​(java.lang.String opcItemName)
        Convert an OPC item name into a zip URI by removing any leading forward slash if it exist.
        Parameters:
        opcItemName - The OPC item name to convert.
        Returns:
        A zip URI without any leading slashes.
      • openZipStream

        public static ZipArchiveThresholdInputStream openZipStream​(java.io.InputStream stream)
                                                            throws java.io.IOException
        Opens the specified stream as a secure zip
        Parameters:
        stream - The stream to open.
        Returns:
        The zip stream freshly open.
        Throws:
        java.io.IOException
      • openZipFile

        public static ZipSecureFile openZipFile​(java.io.File file)
                                         throws java.io.IOException,
                                                NotOfficeXmlFileException
        Opens the specified file as a secure zip, or returns null if no such file exists
        Parameters:
        file - The file to open.
        Returns:
        The zip archive freshly open.
        Throws:
        java.io.IOException - if the zip file cannot be opened or closed to read the header signature
        NotOfficeXmlFileException - if stream does not start with zip header signature
      • openZipFile

        public static ZipSecureFile openZipFile​(java.lang.String path)
                                         throws java.io.IOException
        Retrieve and open as a secure zip file with the specified path.
        Parameters:
        path - The file path.
        Returns:
        The zip archive freshly open.
        Throws:
        java.io.IOException