| 1 | package fr.sii.ogham.core.util; | |
| 2 | ||
| 3 | /** | |
| 4 | * Wraps a matched CSS {@code url()} function. | |
| 5 | * | |
| 6 | * It provides the following information: | |
| 7 | * <ul> | |
| 8 | * <li>{@code "source"}: the whole match of the {@code url()} function</li> | |
| 9 | * <li>{@code "start"}: matches the {@code url(} part (without quote, spaces | |
| 10 | * are preserved)</li> | |
| 11 | * <li>{@code "end"}: matches the {@code );} part (without quote, spaces are | |
| 12 | * preserved)</li> | |
| 13 | * <li>{@code "url"}: the url (without surrounding quotes)</li> | |
| 14 | * <li>{@code "enclosingQuoteChar"}: either {@literal "} character, | |
| 15 | * {@literal '} character or empty string</li> | |
| 16 | * </ul> | |
| 17 | * | |
| 18 | * @author Aurélien Baudet | |
| 19 | * | |
| 20 | */ | |
| 21 | public class CssUrlFunction { | |
| 22 | private final String source; | |
| 23 | private final String start; | |
| 24 | private final String url; | |
| 25 | private final String end; | |
| 26 | private final String enclosingQuoteChar; | |
| 27 | ||
| 28 | /** | |
| 29 | * Store information about a CSS {@code url()} function. | |
| 30 | * | |
| 31 | * @param source | |
| 32 | * the whole match of the {@code url()} function | |
| 33 | * @param start | |
| 34 | * the {@code url(} part (without quote, spaces are | |
| 35 | * preserved) | |
| 36 | * @param url | |
| 37 | * the url (without surrounding quotes) | |
| 38 | * @param end | |
| 39 | * the {@code );} part (without quote, spaces are preserved) | |
| 40 | * @param enclosingQuoteChar | |
| 41 | * either {@literal "} character, {@literal '} character or | |
| 42 | * empty string | |
| 43 | */ | |
| 44 | public CssUrlFunction(String source, String start, String url, String end, String enclosingQuoteChar) { | |
| 45 | super(); | |
| 46 | this.source = source; | |
| 47 | this.start = start; | |
| 48 | this.url = url; | |
| 49 | this.end = end; | |
| 50 | this.enclosingQuoteChar = enclosingQuoteChar; | |
| 51 | } | |
| 52 | ||
| 53 | public String rewriteUrl(String cssPropertyValue, String newUrl) { | |
| 54 |
3
1. rewriteUrl : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::rewriteUrl → NO_COVERAGE 2. rewriteUrl : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::rewriteUrl → KILLED 3. rewriteUrl : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::rewriteUrl → KILLED |
return cssPropertyValue.replace(source, rewriteUrl(newUrl)); |
| 55 | } | |
| 56 | ||
| 57 | public String rewriteUrl(String newUrl) { | |
| 58 |
3
1. rewriteUrl : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::rewriteUrl → NO_COVERAGE 2. rewriteUrl : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::rewriteUrl → KILLED 3. rewriteUrl : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::rewriteUrl → KILLED |
return start+enclosingQuoteChar+newUrl+enclosingQuoteChar+end; |
| 59 | } | |
| 60 | | |
| 61 | public String getSource() { | |
| 62 |
2
1. getSource : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::getSource → NO_COVERAGE 2. getSource : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::getSource → TIMED_OUT |
return source; |
| 63 | } | |
| 64 | ||
| 65 | public String getStart() { | |
| 66 |
2
1. getStart : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::getStart → SURVIVED 2. getStart : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::getStart → NO_COVERAGE |
return start; |
| 67 | } | |
| 68 | ||
| 69 | public String getUrl() { | |
| 70 |
3
1. getUrl : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::getUrl → NO_COVERAGE 2. getUrl : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::getUrl → KILLED 3. getUrl : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::getUrl → KILLED |
return url; |
| 71 | } | |
| 72 | ||
| 73 | public String getEnd() { | |
| 74 |
2
1. getEnd : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::getEnd → SURVIVED 2. getEnd : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::getEnd → NO_COVERAGE |
return end; |
| 75 | } | |
| 76 | ||
| 77 | public String getEnclosingQuoteChar() { | |
| 78 |
2
1. getEnclosingQuoteChar : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::getEnclosingQuoteChar → SURVIVED 2. getEnclosingQuoteChar : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::getEnclosingQuoteChar → NO_COVERAGE |
return enclosingQuoteChar; |
| 79 | } | |
| 80 | ||
| 81 | @Override | |
| 82 | public String toString() { | |
| 83 |
1
1. toString : replaced return value with "" for fr/sii/ogham/core/util/CssUrlFunction::toString → NO_COVERAGE |
return start+enclosingQuoteChar+url+enclosingQuoteChar+end; |
| 84 | } | |
| 85 | ||
| 86 | @Override | |
| 87 | public int hashCode() { | |
| 88 |
1
1. hashCode : replaced int return with 0 for fr/sii/ogham/core/util/CssUrlFunction::hashCode → NO_COVERAGE |
return new HashCodeBuilder().append(source, start, url, end, enclosingQuoteChar).hashCode(); |
| 89 | } | |
| 90 | ||
| 91 | @Override | |
| 92 | public boolean equals(Object obj) { | |
| 93 |
4
1. equals : replaced boolean return with false for fr/sii/ogham/core/util/CssUrlFunction::equals → NO_COVERAGE 2. equals : replaced boolean return with true for fr/sii/ogham/core/util/CssUrlFunction::equals → SURVIVED 3. equals : replaced boolean return with true for fr/sii/ogham/core/util/CssUrlFunction::equals → NO_COVERAGE 4. equals : replaced boolean return with false for fr/sii/ogham/core/util/CssUrlFunction::equals → KILLED |
return new EqualsBuilder(this, obj).appendFields("source", "start", "url", "end", "enclosingQuoteChar").isEqual(); |
| 94 | } | |
| 95 | } | |
Mutations | ||
| 54 |
1.1 2.2 3.3 |
|
| 58 |
1.1 2.2 3.3 |
|
| 62 |
1.1 2.2 |
|
| 66 |
1.1 2.2 |
|
| 70 |
1.1 2.2 3.3 |
|
| 74 |
1.1 2.2 |
|
| 78 |
1.1 2.2 |
|
| 83 |
1.1 |
|
| 88 |
1.1 |
|
| 93 |
1.1 2.2 3.3 4.4 |