Class TempFilePackagePart
- java.lang.Object
-
- org.apache.poi.openxml4j.opc.PackagePart
-
- org.apache.poi.openxml4j.opc.internal.TempFilePackagePart
-
- All Implemented Interfaces:
Comparable<PackagePart>,RelationshipSource
@Beta public final class TempFilePackagePart extends PackagePart
(Experimental) Temp File version of a package part.- Since:
- POI 5.1.0
-
-
Field Summary
-
Fields inherited from class org.apache.poi.openxml4j.opc.PackagePart
_container, _contentType, _partName
-
-
Constructor Summary
Constructors Constructor Description TempFilePackagePart(OPCPackage pack, PackagePartName partName, String contentType)Constructor.TempFilePackagePart(OPCPackage pack, PackagePartName partName, String contentType, boolean loadRelationships)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Allows sub-classes to clean up before new data is added.voidclose()Close this part : flush this part, close the input stream and output stream.voidflush()Flush the content of this part.protected InputStreamgetInputStreamImpl()Method that gets the input stream for this part.protected OutputStreamgetOutputStreamImpl()Method that gets the output stream for this part.longgetSize()booleanload(InputStream is)Load the content of this part.booleansave(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
-
-
-
-
Constructor Detail
-
TempFilePackagePart
public TempFilePackagePart(OPCPackage pack, PackagePartName partName, String contentType) throws InvalidFormatException, IOException
Constructor.- Parameters:
pack- The owner package.partName- The part name.contentType- The content type.- Throws:
InvalidFormatException- If the specified URI is not OPC compliant.IOException- If temp file cannot be created.
-
TempFilePackagePart
public TempFilePackagePart(OPCPackage pack, PackagePartName partName, String contentType, boolean loadRelationships) throws InvalidFormatException, IOException
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.IOException- If temp file cannot be created.
-
-
Method Detail
-
getInputStreamImpl
protected InputStream getInputStreamImpl() throws IOException
Description copied from class:PackagePartMethod that gets the input stream for this part.- Specified by:
getInputStreamImplin classPackagePart- Returns:
- input stream for this part
- Throws:
IOException- Throws if an IO Exception occur in the implementation method.
-
getOutputStreamImpl
protected OutputStream getOutputStreamImpl() throws IOException
Description copied from class:PackagePartMethod that gets the output stream for this part.- Specified by:
getOutputStreamImplin classPackagePart- Returns:
- output stream for this part
- Throws:
IOException- Throws if an IO Exception occur in the implementation method.
-
getSize
public long getSize()
- Overrides:
getSizein classPackagePart- Returns:
- The length of the part in bytes, or -1 if not known
-
clear
public void clear()
Description copied from class:PackagePartAllows sub-classes to clean up before new data is added.- Overrides:
clearin classPackagePart
-
save
public boolean save(OutputStream os) throws OpenXML4JException
Description copied from class:PackagePartSave 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:
savein classPackagePart- Parameters:
os- Output stream to save this part.- Returns:
- true if the content has been successfully stored, false otherwise. More information about errors may be logged via Log4j 2.
- Throws:
OpenXML4JException- If any exception occur.
-
load
public boolean load(InputStream is) throws InvalidFormatException
Description copied from class:PackagePartLoad the content of this part.- Specified by:
loadin classPackagePart- Parameters:
is- The input stream of the content to load.- Returns:
- true if the content has been successfully loaded, false otherwise. More information about errors may be logged via Log4j 2.
- Throws:
InvalidFormatException- Throws if the content format is invalid.
-
close
public void close()
Description copied from class:PackagePartClose 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:
closein classPackagePart
-
flush
public void flush()
Description copied from class:PackagePartFlush 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:
flushin classPackagePart
-
-