Class ZipHelper
- java.lang.Object
-
- org.apache.poi.openxml4j.opc.internal.ZipHelper
-
-
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 String
getOPCNameFromZipItemName(String zipItemName)
Convert a zip name into an OPC name by adding a leading forward slash to the specified item name.static String
getZipItemNameFromOPCName(String opcItemName)
Convert an OPC item name into a zip item name by removing any leading forward slash if it exist.static URI
getZipURIFromOPCName(String opcItemName)
Convert an OPC item name into a zip URI by removing any leading forward slash if it exist.static ZipSecureFile
openZipFile(File file)
Opens the specified file as a secure zip, or returns null if no such file existsstatic ZipSecureFile
openZipFile(String path)
Retrieve and open as a secure zip file with the specified path.static ZipArchiveThresholdInputStream
openZipStream(InputStream stream)
Opens the specified stream as a secure zip
-
-
-
Method Detail
-
getCorePropertiesZipEntry
public static ZipArchiveEntry getCorePropertiesZipEntry(ZipPackage pkg)
Retrieve the zip entry of the core properties part.- Throws:
IllegalArgumentException
- If the relationship for core properties cannot be read or an invalid name is specified in the properties.
-
getOPCNameFromZipItemName
public static String getOPCNameFromZipItemName(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 String getZipItemNameFromOPCName(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 URI getZipURIFromOPCName(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(InputStream stream) throws IOException
Opens the specified stream as a secure zip- Parameters:
stream
- The stream to open.- Returns:
- The zip stream freshly open.
- Throws:
IOException
-
openZipFile
public static ZipSecureFile openZipFile(File file) throws 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:
IOException
- if the zip file cannot be opened or closed to read the header signatureNotOfficeXmlFileException
- if stream does not start with zip header signature
-
openZipFile
public static ZipSecureFile openZipFile(String path) throws 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:
IOException
-
-