org.apache.poi.openxml4j.opc
Class ZipPackage

java.lang.Object
  extended by org.apache.poi.openxml4j.opc.OPCPackage
      extended by org.apache.poi.openxml4j.opc.Package
          extended by org.apache.poi.openxml4j.opc.ZipPackage
All Implemented Interfaces:
java.io.Closeable, RelationshipSource

public final class ZipPackage
extends Package

Physical zip package.

Author:
Julien Chable

Field Summary
 
Fields inherited from class org.apache.poi.openxml4j.opc.OPCPackage
contentTypeManager, defaultPackageAccess, defaultPartMarshaller, isDirty, originalPackagePath, output, packageProperties, partList, partMarshallers, partUnmarshallers, relationships
 
Constructor Summary
ZipPackage()
          Constructor.
 
Method Summary
protected  void closeImpl()
          Close and save the package.
protected  PackagePart createPartImpl(PackagePartName partName, java.lang.String contentType, boolean loadRelationships)
          Create a new MemoryPackagePart from the specified URI and content type aram partName The part URI.
protected  void flushImpl()
          Flush the package.
protected  PackagePart getPartImpl(PackagePartName partName)
          Implement the getPart() method to retrieve a part from its URI in the current package
protected  PackagePart[] getPartsImpl()
          Retrieves the parts from this package.
 ZipEntrySource getZipArchive()
          Get the zip archive
protected  void removePartImpl(PackagePartName partName)
          Delete a part from the package
protected  void revertImpl()
          Close the package without saving the document.
 void saveImpl(java.io.OutputStream outputStream)
          Save this package into the specified stream
 
Methods inherited from class org.apache.poi.openxml4j.opc.Package
create, create, create, open, open, open, openOrCreate
 
Methods inherited from class org.apache.poi.openxml4j.opc.OPCPackage
addExternalRelationship, addExternalRelationship, addMarshaller, addPackagePart, addRelationship, addRelationship, addThumbnail, addUnmarshaller, clearRelationships, close, containPart, createPart, createPart, deletePart, deletePartRecursive, ensureRelationships, flush, getPackageAccess, getPackageProperties, getPart, getPart, getParts, getPartsByContentType, getPartsByName, getPartsByRelationshipType, getRelationship, getRelationships, getRelationshipsByType, hasRelationships, isRelationshipExists, removeMarshaller, removePart, removePart, removePartRecursive, removeRelationship, removeUnmarshaller, replaceContentType, revert, save, save, validatePackage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipPackage

public ZipPackage()
Constructor. Creates a new ZipPackage.

Method Detail

getPartsImpl

protected PackagePart[] 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. If the package part list is not empty, it will be emptied.

Specified by:
getPartsImpl in class OPCPackage
Returns:
All parts contain in this package.
Throws:
InvalidFormatException - Throws if the package is not valid.

createPartImpl

protected PackagePart createPartImpl(PackagePartName partName,
                                     java.lang.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:
contentType - The part content type.
partName - URI of the part to create.
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:
java.lang.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 java.io.IOException
Close and save the package.

Specified by:
closeImpl in class OPCPackage
Throws:
java.io.IOException
See Also:
OPCPackage.close()

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

getPartImpl

protected PackagePart getPartImpl(PackagePartName partName)
Implement the getPart() method to retrieve a part from its URI in the current package

Specified by:
getPartImpl in class OPCPackage
Parameters:
partName - The URI of the part to retrieve.
Returns:
The package part located by the specified URI, else null.
See Also:
OPCPackage.getPart(PackageRelationship)

saveImpl

public void saveImpl(java.io.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:
OPCPackage.save(OutputStream)

getZipArchive

public ZipEntrySource getZipArchive()
Get the zip archive

Returns:
The zip archive.


Copyright 2012 The Apache Software Foundation or its licensors, as applicable.