com.docmosis.template.population.data
Class Base64ImageStringInterceptor
java.lang.Object
com.docmosis.template.population.data.Base64ImageStringInterceptor
- All Implemented Interfaces:
- StringInterceptor
- public class Base64ImageStringInterceptor
- extends Object
- implements StringInterceptor
This interceptor will look for images in string values. The images are identified
by the value starting with the sequence "image:base64:" and when found will be
decoded and added as an image.
Note this interceptor's process() method always returns false whether an image
was processed or not. This allows other interceptors to be applied even if this
one does it's job.
Constructor Summary |
Base64ImageStringInterceptor(String prefix,
boolean processingTerminus,
boolean addImagesAsStringsToo)
Create a new Base64 image-decoding interceptor. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FIELD_IMAGE_BASE64_ENCODED_PREFIX
public static final String FIELD_IMAGE_BASE64_ENCODED_PREFIX
FIELD_IMAGE_BASE64_PROCESSING_TERMINUS
public static final boolean FIELD_IMAGE_BASE64_PROCESSING_TERMINUS
FIELD_IMAGE_BASE64_ADD_STRINGS
public static final boolean FIELD_IMAGE_BASE64_ADD_STRINGS
Base64ImageStringInterceptor
public Base64ImageStringInterceptor(String prefix,
boolean processingTerminus,
boolean addImagesAsStringsToo)
- Create a new Base64 image-decoding interceptor.
- Parameters:
prefix
- the prefix used to at the beginning of strings to indicate this
decoder should applyprocessingTerminus
- if true, this interceptor will return true when it
successfully processes an image - which has the effect of stopping
further interceptors being applied. If false, the process() method
will always return false whether an image is found or not - which allows
subsequent interceptors to have a go.addImagesAsStringsToo
- if true, when an image is found it will also be
added to the data provider as a string. If false it will not be added.
getDefaultInstance
public static Base64ImageStringInterceptor getDefaultInstance()
process
public boolean process(String key,
String value,
MutableDataProvider dp)
throws StringInterceptorException
- Description copied from interface:
StringInterceptor
- Process the given key and value to make optional adjustments to the given
DataProvider. Typically this is to be used to intercept a value that
should be interpreted as an image or image reference (for example) which
can then be plugged into the DataProvider as an image not a string.
A return value of true indicates this interceptor means to consume the value
and so further processing should cease. If in doubt, return false to allow
other string interceptors to apply.
- Specified by:
process
in interface StringInterceptor
- Parameters:
key
- the key for the datavalue
- the value of the datadp
- the data provider this data is about to be plugged into
- Returns:
- true if no further interceptors should work with this value
- Throws:
StringInterceptorException
- if an error occurs. This error will cause
processing of the render to fail with an exception.
Copyright © 2014 Docmosis Pty Ltd. All Rights Reserved.