Class ZipPartStore
java.lang.Object
org.docx4j.openpackaging.io3.stores.ZipPartStore
- All Implemented Interfaces:
PartStore
Load a zipped up package from a file or input stream;
save it to some output stream.
- Since:
- 3.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static org.slf4j.Logger(package private) long(package private) HashMap<String,ZipPartStore.ByteArray> private PartStoreprivate org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()voidAnything necessary to perfect the save operation.getByteArray(String partName) This method is to facilitate updating the part without JAXB unmarshalling then marshalling.private byte[]getBytesFromInputStream(InputStream is, long size) longgetPartSize(String partName) The size of this part in bytes.private voidReturns null if the part does not exist.booleanpartExists(String partName) private voidpolicePartSize(File f, long length, String entryName) voidRename a part in the part store.voidsaveBinaryPart(Part part) voidvoidvoidsaveJaxbXmlPart(JaxbXmlPart part) voidsaveXmlPart(XmlPart part) voidvoidsetSourcePartStore(PartStore partStore) Set this if its different to the target part store (ie this object)private static booleanshouldCompress(Part part)
-
Field Details
-
log
private static org.slf4j.Logger log -
partByteArrays
HashMap<String,ZipPartStore.ByteArray> partByteArrays -
MAX_BYTES_Unzip_Error
long MAX_BYTES_Unzip_Error -
sourcePartStore
-
zos
private org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream zos
-
-
Constructor Details
-
ZipPartStore
public ZipPartStore() -
ZipPartStore
- Throws:
Docx4JException
-
ZipPartStore
- Throws:
Docx4JException
-
-
Method Details
-
initMaxBytes
private void initMaxBytes() -
policePartSize
- Throws:
PartTooLargeException
-
setSourcePartStore
Set this if its different to the target part store (ie this object)- Specified by:
setSourcePartStorein interfacePartStore
-
partExists
-
getBytesFromInputStream
- Throws:
Exception
-
loadPart
Description copied from interface:PartStoreReturns null if the part does not exist. This will happen when calling code optimistically tries to fetch a rels part (which may or may not exist). Note: JaxbXmlPart and JaxbXmlPartXPathAware both unmarshal lazily (ie can invoke this sometime after the docx is loaded). Caller (generally docx4j itself) should close the resulting InputStream after use.- Specified by:
loadPartin interfacePartStore- Returns:
- Throws:
Docx4JException
-
getPartSize
Description copied from interface:PartStoreThe size of this part in bytes. Return -1 if the part does not exist.- Specified by:
getPartSizein interfacePartStore- Returns:
- Throws:
Docx4JException
-
getByteArray
This method is to facilitate updating the part without JAXB unmarshalling then marshalling. Not intended for direct use by user code.- Parameters:
partName-- Returns:
- Throws:
Docx4JException- Since:
- 3.3.2
-
rename
Description copied from interface:PartStoreRename a part in the part store. Useful where a part is being renamed, but its content has not been loaded. (The existing approach is to manually force the content to be loaded) -
setOutputStream
- Specified by:
setOutputStreamin interfacePartStore- Parameters:
zipOutputStream- the zipOutputStream to set
-
saveContentTypes
- Specified by:
saveContentTypesin interfacePartStore- Throws:
Docx4JException
-
saveJaxbXmlPart
- Specified by:
saveJaxbXmlPartin interfacePartStore- Throws:
Docx4JException
-
saveCustomXmlDataStoragePart
- Specified by:
saveCustomXmlDataStoragePartin interfacePartStore- Throws:
Docx4JException
-
saveXmlPart
- Specified by:
saveXmlPartin interfacePartStore- Throws:
Docx4JException
-
saveBinaryPart
- Specified by:
saveBinaryPartin interfacePartStore- Throws:
Docx4JException
-
shouldCompress
-
finishSave
Description copied from interface:PartStoreAnything necessary to perfect the save operation. For example,- Specified by:
finishSavein interfacePartStore- Throws:
Docx4JException
-
dispose
public void dispose()
-