| 1 | package fr.sii.ogham.core.charset; | |
| 2 | ||
| 3 | import java.io.InputStream; | |
| 4 | import java.nio.charset.Charset; | |
| 5 | import java.nio.charset.StandardCharsets; | |
| 6 | import java.util.Arrays; | |
| 7 | import java.util.List; | |
| 8 | ||
| 9 | /** | |
| 10 | * Detector that always gives the same charset. The charset is provided at | |
| 11 | * construction. If no charset is specified then UTF-8 is used. | |
| 12 | * | |
| 13 | * @author Aurélien Baudet | |
| 14 | * | |
| 15 | */ | |
| 16 | public class FixedCharsetDetector implements CharsetDetector { | |
| 17 | ||
| 18 | /** | |
| 19 | * The charset to use | |
| 20 | */ | |
| 21 | private final Charset charset; | |
| 22 | ||
| 23 | /** | |
| 24 | * Initialize the provider with the default charset (UTF-8) | |
| 25 | */ | |
| 26 | public FixedCharsetDetector() { | |
| 27 | this(StandardCharsets.UTF_8); | |
| 28 | } | |
| 29 | ||
| 30 | /** | |
| 31 | * Initialize the provider with the given charset. | |
| 32 | * | |
| 33 | * @param charset | |
| 34 | * the charset to use | |
| 35 | */ | |
| 36 | public FixedCharsetDetector(Charset charset) { | |
| 37 | super(); | |
| 38 | this.charset = charset; | |
| 39 | } | |
| 40 | ||
| 41 | @Override | |
| 42 | public Charset detect(String str) { | |
| 43 |
4
1. detect : replaced return value with null for fr/sii/ogham/core/charset/FixedCharsetDetector::detect → SURVIVED 2. detect : replaced return value with null for fr/sii/ogham/core/charset/FixedCharsetDetector::detect → NO_COVERAGE 3. detect : replaced return value with null for fr/sii/ogham/core/charset/FixedCharsetDetector::detect → TIMED_OUT 4. detect : replaced return value with null for fr/sii/ogham/core/charset/FixedCharsetDetector::detect → KILLED |
return charset; |
| 44 | } | |
| 45 | ||
| 46 | @Override | |
| 47 | public Charset detect(byte[] bytes) { | |
| 48 |
1
1. detect : replaced return value with null for fr/sii/ogham/core/charset/FixedCharsetDetector::detect → NO_COVERAGE |
return charset; |
| 49 | } | |
| 50 | ||
| 51 | @Override | |
| 52 | public Charset detect(InputStream stream) { | |
| 53 |
1
1. detect : replaced return value with null for fr/sii/ogham/core/charset/FixedCharsetDetector::detect → NO_COVERAGE |
return charset; |
| 54 | } | |
| 55 | ||
| 56 | @Override | |
| 57 | public List<CharsetMatch> detectAll(String str) { | |
| 58 |
1
1. detectAll : replaced return value with Collections.emptyList for fr/sii/ogham/core/charset/FixedCharsetDetector::detectAll → NO_COVERAGE |
return Arrays.<CharsetMatch>asList(new SimpleCharsetMatch(charset, 0)); |
| 59 | } | |
| 60 | ||
| 61 | @Override | |
| 62 | public List<CharsetMatch> detectAll(byte[] bytes) { | |
| 63 |
1
1. detectAll : replaced return value with Collections.emptyList for fr/sii/ogham/core/charset/FixedCharsetDetector::detectAll → NO_COVERAGE |
return Arrays.<CharsetMatch>asList(new SimpleCharsetMatch(charset, 0)); |
| 64 | } | |
| 65 | ||
| 66 | @Override | |
| 67 | public List<CharsetMatch> detectAll(InputStream stream) { | |
| 68 |
1
1. detectAll : replaced return value with Collections.emptyList for fr/sii/ogham/core/charset/FixedCharsetDetector::detectAll → NO_COVERAGE |
return Arrays.<CharsetMatch>asList(new SimpleCharsetMatch(charset, 0)); |
| 69 | } | |
| 70 | } | |
Mutations | ||
| 43 |
1.1 2.2 3.3 4.4 |
|
| 48 |
1.1 |
|
| 53 |
1.1 |
|
| 58 |
1.1 |
|
| 63 |
1.1 |
|
| 68 |
1.1 |