Package org.docx4j.model.images
Class AbstractConversionImageHandler
java.lang.Object
org.docx4j.model.images.AbstractConversionImageHandler
- All Implemented Interfaces:
ConversionImageHandler
- Direct Known Subclasses:
FileConversionImageHandler
public abstract class AbstractConversionImageHandler
extends Object
implements ConversionImageHandler
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractConversionImageHandler(String imageDirPath, boolean includeUUID) Creates an AbstractConversionImageHandler -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()If the instance is reused, it should be cleared firstprotected StringcreateEncodedImage(BinaryPart binaryPart, byte[] bytes) protected StringcreateKey(Relationship relationship, BinaryPart part) protected abstract StringcreateStoredImage(BinaryPart binaryPart, byte[] bytes) protected StringdoHandleImage(AbstractWordXmlPicture picture, Relationship relationship, BinaryPart part) protected byte[]getImageData(BinaryPart binaryPart) Get the image data of the bufferprotected StringgetImageName(BinaryPart binaryPart) Get the image base nameprotected StringhandleExternalImage(AbstractWordXmlPicture picture, Relationship relationship, BinaryPart part) handleImage(AbstractWordXmlPicture picture, Relationship relationship, BinaryPart part) protected StringhandleInternalImage(AbstractWordXmlPicture picture, Relationship relationship, BinaryPart binaryPart) protected booleanisInternalImage(AbstractWordXmlPicture picture, Relationship relationship, BinaryPart part) protected StringsetupImageName(BinaryPart binaryPart)
-
Field Details
-
log
protected static org.slf4j.Logger log -
uuid
-
handledImagesMap
-
imageDirPath
-
includeUUID
protected boolean includeUUID
-
-
Constructor Details
-
AbstractConversionImageHandler
Creates an AbstractConversionImageHandler- Parameters:
imageDirPath- , the path, where the images will be storedincludeUUID- , should the image names be prefixed with an UUID to differentiate different runs
-
-
Method Details
-
handleImage
public String handleImage(AbstractWordXmlPicture picture, Relationship relationship, BinaryPart part) throws Docx4JException - Specified by:
handleImagein interfaceConversionImageHandlerrelationship- of the imagepart- of the image, if it is an internal image, otherwise null- Returns:
- uri for the image we've saved, or null
- Throws:
Docx4JException- this exception will be logged, but not propagated
-
createKey
-
doHandleImage
protected String doHandleImage(AbstractWordXmlPicture picture, Relationship relationship, BinaryPart part) throws Docx4JException - Throws:
Docx4JException
-
isInternalImage
protected boolean isInternalImage(AbstractWordXmlPicture picture, Relationship relationship, BinaryPart part) throws Docx4JException - Throws:
Docx4JException
-
handleInternalImage
protected String handleInternalImage(AbstractWordXmlPicture picture, Relationship relationship, BinaryPart binaryPart) throws Docx4JException - Parameters:
picture-relationship-binaryPart-- Returns:
- uri for the image we've saved, or null
- Throws:
Docx4JException
-
createStoredImage
protected abstract String createStoredImage(BinaryPart binaryPart, byte[] bytes) throws Docx4JException - Throws:
Docx4JException
-
createEncodedImage
- Throws:
Docx4JException
-
setupImageName
-
getImageName
Get the image base name- Parameters:
binaryPart-- Returns:
-
getImageData
Get the image data of the buffer- Parameters:
binaryPart-- Returns:
-
handleExternalImage
protected String handleExternalImage(AbstractWordXmlPicture picture, Relationship relationship, BinaryPart part) - Parameters:
picture-relationship-part- (is always null)- Returns:
- uri for the image we've saved, or null
-
clear
public void clear()If the instance is reused, it should be cleared first
-