Class BinaryPart
java.lang.Object
org.docx4j.openpackaging.Base
org.docx4j.openpackaging.parts.Part
org.docx4j.openpackaging.parts.WordprocessingML.BinaryPart
- Direct Known Subclasses:
AbstractFontPart,AlternativeFormatInputPart,BinaryPartAbstractImage,EmbeddedPackagePart,FontDataPart,OleObjectBinaryPart,PrinterSettings,VMLBinaryPart
public class BinaryPart extends Part
A part containing binary (as opposed to XML) data.
The content of a binary parts is loaded lazily (ie only when required).
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Loggerlog -
Constructor Summary
Constructors Constructor Description BinaryPart(ExternalTarget externalTarget)BinaryPart(PartName partName) -
Method Summary
Modifier and Type Method Description java.nio.ByteBuffergetBuffer()Get the contents of this part.byte[]getBytes()ExternalTargetgetExternalTarget()booleanisContentEqual(Part other)booleanisLoaded()voidsetBinaryData(byte[] bytes)voidsetBinaryData(java.io.InputStream binaryData)voidsetBinaryData(java.nio.ByteBuffer bb)voidwriteDataToOutputStream(java.io.OutputStream out)Copy the ByteBuffer containing this part's binary data to an output stream.Methods inherited from class org.docx4j.openpackaging.parts.Part
getContentLengthAsLoaded, getOwningRelationshipPart, getPackage, getRelationshipType, getSourceRelationship, getSourceRelationships, getVersion, remove, rename, setContentLengthAsLoaded, setOwningRelationshipPart, setPackage, setPartShortcut, setRelationshipType, setSourceRelationship, setVersionMethods inherited from class org.docx4j.openpackaging.Base
addTargetPart, addTargetPart, addTargetPart, addTargetPart, getContentType, getPartName, getRelationshipsPart, getRelationshipsPart, getUserData, reset, setContentType, setPartName, setRelationships, setUserData
-
Field Details
-
log
protected static org.slf4j.Logger log
-
-
Constructor Details
-
Method Details
-
getExternalTarget
-
setBinaryData
public void setBinaryData(java.io.InputStream binaryData) -
setBinaryData
public void setBinaryData(byte[] bytes) -
setBinaryData
public void setBinaryData(java.nio.ByteBuffer bb) -
isLoaded
public boolean isLoaded()- Since:
- 3.0
-
getBuffer
public java.nio.ByteBuffer getBuffer()Get the contents of this part. NB: if you are moving this part from one pkg to another, you'll probably want to invoke this first, since otherwise the content may not be located (lazy loading).- Returns:
-
writeDataToOutputStream
public void writeDataToOutputStream(java.io.OutputStream out) throws java.io.IOExceptionCopy the ByteBuffer containing this part's binary data to an output stream.- Parameters:
out-- Throws:
java.io.IOException
-
getBytes
public byte[] getBytes() -
isContentEqual
- Specified by:
isContentEqualin classPart- Throws:
Docx4JException
-