| 1 | package fr.sii.ogham.html.inliner; | |
| 2 | ||
| 3 | /** | |
| 4 | * Common constants for CSS inlining. | |
| 5 | * | |
| 6 | * | |
| 7 | * @author Aurélien Baudet | |
| 8 | * | |
| 9 | */ | |
| 10 | public final class CssInlinerConstants { | |
| 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 | * <p> | |
| 18 | * <strong>NOTE:</strong> Currently there only one available strategy but | |
| 19 | * later, there could be several ways to inline styles. | |
| 20 | * | |
| 21 | * <p> | |
| 22 | * For example: | |
| 23 | * | |
| 24 | * CSS rules: | |
| 25 | * | |
| 26 | * <pre> | |
| 27 | * {@code | |
| 28 | * .white { | |
| 29 | * color: #fff; | |
| 30 | * } | |
| 31 | * } | |
| 32 | * </pre> | |
| 33 | * | |
| 34 | * <p> | |
| 35 | * You can skip inlining by using "skip" value: | |
| 36 | * | |
| 37 | * <pre> | |
| 38 | * {@code | |
| 39 | * <span class="white" data-inline-styles="skip"></span> | |
| 40 | * } | |
| 41 | * </pre> | |
| 42 | * | |
| 43 | * | |
| 44 | * @see InlineModes | |
| 45 | */ | |
| 46 | public static final String INLINE_MODE_ATTR = "data-inline-styles"; | |
| 47 | ||
| 48 | /** | |
| 49 | * Attribute to mark an image as already inlined in order to not process it | |
| 50 | * again | |
| 51 | */ | |
| 52 | public static final String INLINED_ATTR = "data-styles-inlined"; | |
| 53 | ||
| 54 | /** | |
| 55 | * Interface for defining an inline mode | |
| 56 | * | |
| 57 | * @author Aurélien Baudet | |
| 58 | * | |
| 59 | */ | |
| 60 | public interface InlineMode { | |
| 61 | /** | |
| 62 | * The inline mode value | |
| 63 | * | |
| 64 | * @return inline mode value | |
| 65 | */ | |
| 66 | String mode(); | |
| 67 | ||
| 68 | /** | |
| 69 | * Indicates if the mode is the same as the current mode. | |
| 70 | * | |
| 71 | * @param mode | |
| 72 | * the mode to check if same | |
| 73 | * @return true if same value, false otherwise | |
| 74 | */ | |
| 75 | boolean is(String mode); | |
| 76 | } | |
| 77 | ||
| 78 | /** | |
| 79 | * Provide predefined inline modes | |
| 80 | * | |
| 81 | * @author Aurélien Baudet | |
| 82 | * | |
| 83 | */ | |
| 84 | public enum InlineModes implements InlineMode { | |
| 85 | /** | |
| 86 | * Do not inline the image | |
| 87 | */ | |
| 88 | STYLE_ATTR("style-attribute"), | |
| 89 | /** | |
| 90 | * Do not inline the image | |
| 91 | */ | |
| 92 | SKIP("skip"); | |
| 93 | ||
| 94 | private final String mode; | |
| 95 | ||
| 96 | InlineModes(String mode) { | |
| 97 | this.mode = mode; | |
| 98 | } | |
| 99 | ||
| 100 | @Override | |
| 101 | public String mode() { | |
| 102 |
1
1. mode : replaced return value with "" for fr/sii/ogham/html/inliner/CssInlinerConstants$InlineModes::mode → NO_COVERAGE |
return mode; |
| 103 | } | |
| 104 | ||
| 105 | @Override | |
| 106 | public boolean is(String mode) { | |
| 107 |
4
1. is : replaced boolean return with false for fr/sii/ogham/html/inliner/CssInlinerConstants$InlineModes::is → NO_COVERAGE 2. is : replaced boolean return with false for fr/sii/ogham/html/inliner/CssInlinerConstants$InlineModes::is → SURVIVED 3. is : replaced boolean return with true for fr/sii/ogham/html/inliner/CssInlinerConstants$InlineModes::is → NO_COVERAGE 4. is : replaced boolean return with true for fr/sii/ogham/html/inliner/CssInlinerConstants$InlineModes::is → KILLED |
return this.mode.equals(mode); |
| 108 | } | |
| 109 | } | |
| 110 | ||
| 111 | private CssInlinerConstants() { | |
| 112 | super(); | |
| 113 | } | |
| 114 | } | |
Mutations | ||
| 102 |
1.1 |
|
| 107 |
1.1 2.2 3.3 4.4 |