| 1 | package fr.sii.ogham.html.inliner; | |
| 2 | ||
| 3 | /** | |
| 4 | * Common constants for image inlining. | |
| 5 | * | |
| 6 | * | |
| 7 | * @author Aurélien Baudet | |
| 8 | * | |
| 9 | */ | |
| 10 | public final class ImageInlinerConstants { | |
| 11 | /** | |
| 12 | * <p> | |
| 13 | * The attribute name to indicate which strategy for inlining to apply if | |
| 14 | * the default one is not appropriated. | |
| 15 | * </p> | |
| 16 | * | |
| 17 | * For example: | |
| 18 | * | |
| 19 | * <pre> | |
| 20 | * {@code | |
| 21 | * <img src="..." data-inline-image="base64" /> | |
| 22 | * } | |
| 23 | * </pre> | |
| 24 | * | |
| 25 | * It forces to use <code>base64</code> inlining for this image. | |
| 26 | * | |
| 27 | * | |
| 28 | * <p> | |
| 29 | * You can also skip inlining by using "skip" value: | |
| 30 | * | |
| 31 | * <pre> | |
| 32 | * {@code | |
| 33 | * <img src="..." data-inline-image="skip" /> | |
| 34 | * } | |
| 35 | * </pre> | |
| 36 | * | |
| 37 | * @see InlineModes | |
| 38 | */ | |
| 39 | public static final String INLINE_MODE_ATTR = "data-inline-image"; | |
| 40 | ||
| 41 | /** | |
| 42 | * Attribute to mark an image as already inlined in order to not process it | |
| 43 | * again | |
| 44 | */ | |
| 45 | public static final String INLINED_ATTR = "data-image-inlined"; | |
| 46 | ||
| 47 | /** | |
| 48 | * Interface for defining an inline mode | |
| 49 | * | |
| 50 | * @author Aurélien Baudet | |
| 51 | * | |
| 52 | */ | |
| 53 | public interface InlineMode { | |
| 54 | /** | |
| 55 | * The inline mode value | |
| 56 | * | |
| 57 | * @return inline mode value | |
| 58 | */ | |
| 59 | String mode(); | |
| 60 | ||
| 61 | /** | |
| 62 | * Indicates if the mode is the same as the current mode. | |
| 63 | * | |
| 64 | * @param mode | |
| 65 | * the mode to check if same | |
| 66 | * @return true if same value, false otherwise | |
| 67 | */ | |
| 68 | boolean is(String mode); | |
| 69 | } | |
| 70 | ||
| 71 | /** | |
| 72 | * Provide predefined inline modes | |
| 73 | * | |
| 74 | * @author Aurélien Baudet | |
| 75 | * | |
| 76 | */ | |
| 77 | public enum InlineModes implements InlineMode { | |
| 78 | /** | |
| 79 | * Attach the image to the email and references it in the HTML using a | |
| 80 | * Content-ID (CID). | |
| 81 | */ | |
| 82 | ATTACH("attach"), | |
| 83 | /** | |
| 84 | * Encode the image content to a base64 string that is directly used by | |
| 85 | * image {@code src} attribute | |
| 86 | */ | |
| 87 | BASE64("base64"), | |
| 88 | /** | |
| 89 | * Do not inline the image | |
| 90 | */ | |
| 91 | SKIP("skip"); | |
| 92 | ||
| 93 | private final String mode; | |
| 94 | ||
| 95 | InlineModes(String mode) { | |
| 96 | this.mode = mode; | |
| 97 | } | |
| 98 | ||
| 99 | @Override | |
| 100 | public String mode() { | |
| 101 |
1
1. mode : replaced return value with "" for fr/sii/ogham/html/inliner/ImageInlinerConstants$InlineModes::mode → NO_COVERAGE |
return mode; |
| 102 | } | |
| 103 | ||
| 104 | @Override | |
| 105 | public boolean is(String mode) { | |
| 106 |
6
1. is : replaced boolean return with false for fr/sii/ogham/html/inliner/ImageInlinerConstants$InlineModes::is → NO_COVERAGE 2. is : replaced boolean return with true for fr/sii/ogham/html/inliner/ImageInlinerConstants$InlineModes::is → NO_COVERAGE 3. is : replaced boolean return with false for fr/sii/ogham/html/inliner/ImageInlinerConstants$InlineModes::is → KILLED 4. is : replaced boolean return with false for fr/sii/ogham/html/inliner/ImageInlinerConstants$InlineModes::is → KILLED 5. is : replaced boolean return with true for fr/sii/ogham/html/inliner/ImageInlinerConstants$InlineModes::is → KILLED 6. is : replaced boolean return with true for fr/sii/ogham/html/inliner/ImageInlinerConstants$InlineModes::is → KILLED |
return this.mode.equals(mode); |
| 107 | } | |
| 108 | } | |
| 109 | ||
| 110 | private ImageInlinerConstants() { | |
| 111 | super(); | |
| 112 | } | |
| 113 | } | |
Mutations | ||
| 101 |
1.1 |
|
| 106 |
1.1 2.2 3.3 4.4 5.5 6.6 |