org.apache.poi.openxml4j.opc
Class ZipPackagePart

java.lang.Object
  extended by org.apache.poi.openxml4j.opc.PackagePart
      extended by org.apache.poi.openxml4j.opc.ZipPackagePart
All Implemented Interfaces:
java.lang.Comparable<PackagePart>, RelationshipSource

public class ZipPackagePart
extends PackagePart

Zip implementation of a PackagePart.

See Also:
PackagePart

Field Summary
 
Fields inherited from class org.apache.poi.openxml4j.opc.PackagePart
_container, _contentType, _partName
 
Constructor Summary
ZipPackagePart(OPCPackage container, PackagePartName partName, java.lang.String contentType)
          Constructor.
ZipPackagePart(OPCPackage container, java.util.zip.ZipEntry zipEntry, PackagePartName partName, java.lang.String contentType)
          Constructor.
 
Method Summary
 void close()
          Close this part : flush this part, close the input stream and output stream.
 void flush()
          Flush the content of this part.
protected  java.io.InputStream getInputStreamImpl()
          Implementation of the getInputStream() which return the inputStream of this part zip entry.
protected  java.io.OutputStream getOutputStreamImpl()
          Implementation of the getOutputStream().
 long getSize()
           
 java.util.zip.ZipEntry getZipArchive()
          Get the zip entry of this part.
 boolean load(java.io.InputStream ios)
          Load the content of this part.
 boolean save(java.io.OutputStream os)
          Save the content of this part and the associated relationships part (if this part own at least one relationship) into the specified output stream.
 
Methods inherited from class org.apache.poi.openxml4j.opc.PackagePart
addExternalRelationship, addExternalRelationship, addRelationship, addRelationship, addRelationship, addRelationship, clear, clearRelationships, compareTo, findExistingRelation, getContentType, getContentTypeDetails, getInputStream, getOutputStream, getPackage, getPartName, getRelatedPart, getRelationship, getRelationships, getRelationshipsByType, hasRelationships, isDeleted, isRelationshipExists, isRelationshipPart, removeRelationship, setContentType, setDeleted, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZipPackagePart

public ZipPackagePart(OPCPackage container,
                      PackagePartName partName,
                      java.lang.String contentType)
               throws InvalidFormatException
Constructor.

Parameters:
container - The container package.
partName - Part name.
contentType - Content type.
Throws:
InvalidFormatException - Throws if the content of this part invalid.

ZipPackagePart

public ZipPackagePart(OPCPackage container,
                      java.util.zip.ZipEntry zipEntry,
                      PackagePartName partName,
                      java.lang.String contentType)
               throws InvalidFormatException
Constructor.

Parameters:
container - The container package.
zipEntry - The zip entry corresponding to this part.
partName - The part name.
contentType - Content type.
Throws:
InvalidFormatException - Throws if the content of this part is invalid.
Method Detail

getZipArchive

public java.util.zip.ZipEntry getZipArchive()
Get the zip entry of this part.

Returns:
The zip entry in the zip structure coresponding to this part.

getInputStreamImpl

protected java.io.InputStream getInputStreamImpl()
                                          throws java.io.IOException
Implementation of the getInputStream() which return the inputStream of this part zip entry.

Specified by:
getInputStreamImpl in class PackagePart
Returns:
Input stream of this part zip entry.
Throws:
java.io.IOException - Throws if an IO Exception occur in the implementation method.

getOutputStreamImpl

protected java.io.OutputStream getOutputStreamImpl()
Implementation of the getOutputStream(). Return null. Normally will never be called since the MemoryPackage is use instead.

Specified by:
getOutputStreamImpl in class PackagePart
Returns:
null

getSize

public long getSize()
Overrides:
getSize in class PackagePart
Returns:
The length of the part in bytes, or -1 if not known

save

public boolean save(java.io.OutputStream os)
             throws OpenXML4JException
Description copied from class: PackagePart
Save the content of this part and the associated relationships part (if this part own at least one relationship) into the specified output stream.

Specified by:
save in class PackagePart
Parameters:
os - Output stream to save this part.
Throws:
OpenXML4JException - If any exception occur.

load

@NotImplemented
public boolean load(java.io.InputStream ios)
Description copied from class: PackagePart
Load the content of this part.

Specified by:
load in class PackagePart
Parameters:
ios - The input stream of the content to load.
Returns:
true if the content has been successfully loaded, else false.

close

@NotImplemented
public void close()
Description copied from class: PackagePart
Close this part : flush this part, close the input stream and output stream. After this method call, the part must be available for packaging.

Specified by:
close in class PackagePart

flush

@NotImplemented
public void flush()
Description copied from class: PackagePart
Flush the content of this part. If the input stream and/or output stream as in a waiting state to read or write, the must to empty their respective buffer.

Specified by:
flush in class PackagePart