Package org.apache.poi.openxml4j.opc
Class ZipPackage
java.lang.Object
org.apache.poi.openxml4j.opc.OPCPackage
org.apache.poi.openxml4j.opc.ZipPackage
- All Implemented Interfaces:
Closeable,AutoCloseable,RelationshipSource
Physical zip package.
-
Field Summary
Fields inherited from class org.apache.poi.openxml4j.opc.OPCPackage
contentTypeManager, defaultPackageAccess, defaultPartMarshaller, isDirty, originalPackagePath, output, packageProperties, partMarshallers, partUnmarshallers, relationships -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidClose and save the package.protected PackagePartcreatePartImpl(PackagePartName partName, String contentType, boolean loadRelationships) Create a new MemoryPackagePart from the specified URI and content typestatic booleanprotected voidFlush the package.protected PackagePartCollectionRetrieves the parts from this package.Get the zip archivebooleanisClosed()Has close been called already?protected voidClose the package without saving the document.voidsaveImpl(OutputStream outputStream) Save this package into the specified streamstatic voidsetEncryptTempFilePackageParts(boolean encryptTempFiles) static voidsetUseTempFilePackageParts(boolean tempFilePackageParts) static booleanMethods inherited from class org.apache.poi.openxml4j.opc.OPCPackage
addExternalRelationship, addExternalRelationship, addMarshaller, addPackagePart, addRelationship, addRelationship, addThumbnail, addThumbnail, addUnmarshaller, clearRelationships, close, closeParts, containPart, create, create, create, createPart, createPart, deletePart, deletePartRecursive, ensureRelationships, flush, getPackageAccess, getPackageProperties, getPart, getPart, getParts, getPartsByContentType, getPartsByName, getPartsByRelationshipType, getRelationship, getRelationships, getRelationshipsByType, getUnusedPartIndex, hasPackagePart, hasRelationships, isRelationshipExists, isStrictOoxmlFormat, open, open, open, open, open, open, open, open, open, open, open, open, open, open, openOrCreate, registerPartAndContentType, removeMarshaller, removePart, removePart, removePartImpl, removePartRecursive, removeRelationship, removeUnmarshaller, replaceContentType, revert, save, save, toString, unregisterPartAndContentType, validatePackage
-
Constructor Details
-
ZipPackage
public ZipPackage()Constructor. Creates a new, empty ZipPackage. -
ZipPackage
Constructor. Creates a new, empty ZipPackage.- Parameters:
opcComplianceFlags- The level of OPC compliance to enforce when reading the package- Since:
- 5.4.1
-
-
Method Details
-
setUseTempFilePackageParts
public static void setUseTempFilePackageParts(boolean tempFilePackageParts) - Parameters:
tempFilePackageParts- whether to save package part data in temp files to save memory
-
setEncryptTempFilePackageParts
public static void setEncryptTempFilePackageParts(boolean encryptTempFiles) - Parameters:
encryptTempFiles- whether to encrypt package part temp files
-
useTempFilePackageParts
public static boolean useTempFilePackageParts()- Returns:
- whether package part data is stored in temp files to save memory
-
encryptTempFilePackageParts
public static boolean encryptTempFilePackageParts()- Returns:
- whether package part temp files are encrypted
-
getPartsImpl
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:
getPartsImplin classOPCPackage- 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- Specified by:
createPartImplin classOPCPackage- Parameters:
partName- The part name.contentType- The part content type.loadRelationships- whether to load relationships.- Returns:
- The newly created zip package part, else null.
- Throws:
IllegalArgumentException- if partName or contentType is null
-
flushImpl
protected void flushImpl()Flush the package. Do nothing.- Specified by:
flushImplin classOPCPackage
-
closeImpl
Close and save the package.- Specified by:
closeImplin classOPCPackage- 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:
revertImplin classOPCPackage
-
saveImpl
Save this package into the specified stream- Specified by:
saveImplin classOPCPackage- Parameters:
outputStream- The stream use to save this package.- Throws:
OpenXML4JRuntimeException- if there is an error while saving the package.- See Also:
-
getZipArchive
Get the zip archive- Returns:
- The zip archive.
-
isClosed
public boolean isClosed()Description copied from class:OPCPackageHas close been called already?- Specified by:
isClosedin classOPCPackage
-