CssImageInlinerConstants.java

1
package fr.sii.ogham.html.inliner.impl.regexp;
2
3
/**
4
 * Common constants for inlining of images included through CSS properties (such
5
 * as background, list-style, ...).
6
 * 
7
 * 
8
 * @author Aurélien Baudet
9
 *
10
 */
11
public final class CssImageInlinerConstants {
12
	/**
13
	 * <p>
14
	 * The CSS property name to indicate which strategy for inlining to apply if
15
	 * the default one is not appropriated.
16
	 * </p>
17
	 * 
18
	 * For example:
19
	 * 
20
	 * <pre>
21
	 * <code>
22
	 * 	background: url(...);
23
	 * 	--inline-image: base64;
24
	 * </code>
25
	 * </pre>
26
	 * 
27
	 * It forces to use <code>base64</code> inlining for this image.
28
	 * 
29
	 * 
30
	 * <p>
31
	 * You can also skip inlining by using "skip" value:
32
	 * 
33
	 * <pre>
34
	 * <code>
35
	 * 	background: url(...);
36
	 * 	--inline-image: skip;
37
	 * </code>
38
	 * </pre>
39
	 * 
40
	 * <p>
41
	 * It is possible to have several images to inline for the same CSS rule.
42
	 * Therefore, you can indicate an inline mode per image:
43
	 * 
44
	 * <pre>
45
	 * <code>
46
	 * .rule {
47
	 * 		background: url('path/to/top.png'), url('path/to/bottom.gif');
48
	 * 		list-style-image: url('path/to/list.gif');
49
	 * 		cursor: url('path/to/cursor.png');
50
	 * 		--inline-image: top=attach bottom=base64 list=skip;
51
	 * }
52
	 * </code>
53
	 * </pre>
54
	 * 
55
	 * {@code --inline-image} indicates that:
56
	 * <ul>
57
	 * <li>Image 'path/to/top.png' should be inlined using {@code attach}
58
	 * mode</li>
59
	 * <li>Image 'path/to/bottom.gif' should be inlined using {@code base64}
60
	 * mode</li>
61
	 * <li>Image 'path/to/list.gif' should not be inlined</li>
62
	 * <li></li>
63
	 * </ul>
64
	 * 
65
	 * As nothing is specified for 'path/to/cursor.png', the default inline mode
66
	 * is used.
67
	 * 
68
	 * <strong>NOTE:</strong> Only the name is provided but you can also target
69
	 * an image by providing any matching path
70
	 * ({@code --inline-image: to/top.png=attach} also targets 'top' image).
71
	 * This can be useful if you have several images with the same name but in
72
	 * different folders.
73
	 * 
74
	 * @see InlineModes
75
	 */
76
	public static final String INLINE_MODE_PROPERTY = "--inline-image";
77
78
	/**
79
	 * Property to mark an image as already inlined in order to not process it
80
	 * again
81
	 */
82
	public static final String INLINED_URL_FUNC = "--image-inlined-url";
83
84
	/**
85
	 * Interface for defining an inline mode
86
	 * 
87
	 * @author Aurélien Baudet
88
	 *
89
	 */
90
	public interface InlineMode {
91
		/**
92
		 * The inline mode value
93
		 * 
94
		 * @return inline mode value
95
		 */
96
		String mode();
97
98
		/**
99
		 * Indicates if the mode is the same as the current mode.
100
		 * 
101
		 * @param mode
102
		 *            the mode to check if same
103
		 * @return true if same value, false otherwise
104
		 */
105
		boolean is(String mode);
106
	}
107
108
	/**
109
	 * Provide predefined inline modes
110
	 * 
111
	 * @author Aurélien Baudet
112
	 *
113
	 */
114
	public enum InlineModes implements InlineMode {
115
		/**
116
		 * Attach the image to the email and references it in the HTML using a
117
		 * Content-ID (CID).
118
		 */
119
		ATTACH("attach"),
120
		/**
121
		 * Encode the image content to a base64 string that is directly used by
122
		 * image {@code src} attribute
123
		 */
124
		BASE64("base64"),
125
		/**
126
		 * Do not inline the image
127
		 */
128
		SKIP("skip");
129
130
		private final String mode;
131
132
		InlineModes(String mode) {
133
			this.mode = mode;
134
		}
135
136
		@Override
137
		public String mode() {
138 1 1. mode : replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::mode → NO_COVERAGE
			return mode;
139
		}
140
141
		@Override
142
		public boolean is(String mode) {
143 6 1. is : replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::is → NO_COVERAGE
2. is : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::is → NO_COVERAGE
3. is : replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::is → KILLED
4. is : replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::is → KILLED
5. is : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::is → KILLED
6. is : replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::is → KILLED
			return this.mode.equals(mode);
144
		}
145
	}
146
147
	private CssImageInlinerConstants() {
148
		super();
149
	}
150
}

Mutations

138

1.1
Location : mode
Killed by : none
replaced return value with "" for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::mode → NO_COVERAGE

143

1.1
Location : is
Killed by : oghamcore.it.html.translator.InlineImageTranslatorTest.backgroudImagesShouldBeInlined(oghamcore.it.html.translator.InlineImageTranslatorTest)
replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::is → KILLED

2.2
Location : is
Killed by : oghamall.it.email.EmailResourceInliningTest.inlineResources(oghamall.it.email.EmailResourceInliningTest)
replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::is → KILLED

3.3
Location : is
Killed by : none
replaced boolean return with false for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::is → NO_COVERAGE

4.4
Location : is
Killed by : oghamcore.it.html.translator.InlineImageTranslatorTest.backgroudImagesShouldBeInlined(oghamcore.it.html.translator.InlineImageTranslatorTest)
replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::is → KILLED

5.5
Location : is
Killed by : none
replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::is → NO_COVERAGE

6.6
Location : is
Killed by : oghamall.it.email.EmailResourceInliningTest.inlineResources(oghamall.it.email.EmailResourceInliningTest)
replaced boolean return with true for fr/sii/ogham/html/inliner/impl/regexp/CssImageInlinerConstants$InlineModes::is → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM