Class MemoryPackagePart
java.lang.Object
org.apache.poi.openxml4j.opc.PackagePart
org.apache.poi.openxml4j.opc.internal.MemoryPackagePart
- All Implemented Interfaces:
Comparable<PackagePart>
,RelationshipSource
Memory version of a package part. Use to
- Version:
- 1.0
- Author:
- Julien Chable
-
Field Summary
FieldsFields inherited from class org.apache.poi.openxml4j.opc.PackagePart
_container, _contentType, _partName
-
Constructor Summary
ConstructorsConstructorDescriptionMemoryPackagePart
(OPCPackage pack, PackagePartName partName, String contentType) Constructor.MemoryPackagePart
(OPCPackage pack, PackagePartName partName, String contentType, boolean loadRelationships) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Allows sub-classes to clean up before new data is added.void
close()
Close this part : flush this part, close the input stream and output stream.void
flush()
Flush the content of this part.protected InputStream
Method that gets the input stream for this part.protected OutputStream
Method that gets the output stream for this part.long
getSize()
boolean
load
(InputStream ios) Load the content of this part.boolean
save
(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, clearRelationships, compareTo, findExistingRelation, getContentType, getContentTypeDetails, getInputStream, getOutputStream, getPackage, getPartName, getRelatedPart, getRelationship, getRelationships, getRelationshipsByType, hasRelationships, isDeleted, isRelationshipExists, isRelationshipPart, removeRelationship, setContentType, setDeleted, toString
-
Field Details
-
data
protected byte[] dataStorage for the part data.
-
-
Constructor Details
-
MemoryPackagePart
public MemoryPackagePart(OPCPackage pack, PackagePartName partName, String contentType) throws InvalidFormatException Constructor.- Parameters:
pack
- The owner package.partName
- The part name.contentType
- The content type.- Throws:
InvalidFormatException
- If the specified URI is not OPC compliant.
-
MemoryPackagePart
public MemoryPackagePart(OPCPackage pack, PackagePartName partName, String contentType, boolean loadRelationships) throws InvalidFormatException Constructor.- Parameters:
pack
- The owner package.partName
- The part name.contentType
- The content type.loadRelationships
- Specify if the relationships will be loaded.- Throws:
InvalidFormatException
- If the specified URI is not OPC compliant.
-
-
Method Details
-
getInputStreamImpl
Description copied from class:PackagePart
Method that gets the input stream for this part.- Specified by:
getInputStreamImpl
in classPackagePart
- Returns:
- input stream for this part
-
getOutputStreamImpl
Description copied from class:PackagePart
Method that gets the output stream for this part.- Specified by:
getOutputStreamImpl
in classPackagePart
- Returns:
- output stream for this part
-
getSize
public long getSize()- Overrides:
getSize
in classPackagePart
- Returns:
- The length of the part in bytes, or -1 if not known
-
clear
public void clear()Description copied from class:PackagePart
Allows sub-classes to clean up before new data is added.- Overrides:
clear
in classPackagePart
-
save
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 classPackagePart
- Parameters:
os
- Output stream to save this part.- Returns:
- boolean flag that shows if the save succeeded
- Throws:
OpenXML4JException
- If any exception occur.
-
load
Description copied from class:PackagePart
Load the content of this part.- Specified by:
load
in classPackagePart
- Parameters:
ios
- The input stream of the content to load.- Returns:
- true if the content has been successfully loaded, else false.
- Throws:
InvalidFormatException
- Throws if the content format is invalid.
-
close
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 classPackagePart
-
flush
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 classPackagePart
-