| 1 | package fr.sii.ogham.sms.encoder; | |
| 2 | ||
| 3 | /** | |
| 4 | * The encoded message into a byte array also contains a header. | |
| 5 | * | |
| 6 | * <p> | |
| 7 | * This happens for example when a message is split into several segments. The | |
| 8 | * header is used to indicate how the message was split (see | |
| 9 | * <a href="https://en.wikipedia.org/wiki/User_Data_Header">User Data | |
| 10 | * Header</a>). | |
| 11 | * | |
| 12 | * <p> | |
| 13 | * {@link #getBytes()} returns the whole message (header + payload). | |
| 14 | * | |
| 15 | * | |
| 16 | * @author Aurélien Baudet | |
| 17 | * | |
| 18 | */ | |
| 19 | public class EncodedWithHeader implements Encoded { | |
| 20 | private final byte[] header; | |
| 21 | private final Encoded payload; | |
| 22 | private final byte[] wholeSegment; | |
| 23 | ||
| 24 | /** | |
| 25 | * Initializes with the header byte array and the encoded message (byte | |
| 26 | * array and charset unsed to encode it). | |
| 27 | * | |
| 28 | * <p> | |
| 29 | * The whole segment byte array is generated by creating a new array of | |
| 30 | * bytes, appending header bytes and appending {@link Encoded#getBytes()}. | |
| 31 | * | |
| 32 | * @param header | |
| 33 | * the header bytes | |
| 34 | * @param payload | |
| 35 | * the encoded message without the header. | |
| 36 | */ | |
| 37 | public EncodedWithHeader(byte[] header, Encoded payload) { | |
| 38 | super(); | |
| 39 | this.header = header; | |
| 40 | this.payload = payload; | |
| 41 |
4
1. <init> : Replaced integer addition with subtraction → NO_COVERAGE 2. <init> : Replaced integer addition with subtraction → KILLED 3. <init> : Replaced integer addition with subtraction → KILLED 4. <init> : Replaced integer addition with subtraction → KILLED |
wholeSegment = new byte[header.length + payload.getBytes().length]; |
| 42 |
4
1. <init> : removed call to java/lang/System::arraycopy → NO_COVERAGE 2. <init> : removed call to java/lang/System::arraycopy → KILLED 3. <init> : removed call to java/lang/System::arraycopy → KILLED 4. <init> : removed call to java/lang/System::arraycopy → KILLED |
System.arraycopy(header, 0, wholeSegment, 0, header.length); |
| 43 |
4
1. <init> : removed call to java/lang/System::arraycopy → NO_COVERAGE 2. <init> : removed call to java/lang/System::arraycopy → KILLED 3. <init> : removed call to java/lang/System::arraycopy → KILLED 4. <init> : removed call to java/lang/System::arraycopy → KILLED |
System.arraycopy(payload.getBytes(), 0, wholeSegment, header.length, payload.getBytes().length); |
| 44 | } | |
| 45 | ||
| 46 | @Override | |
| 47 | public byte[] getBytes() { | |
| 48 |
4
1. getBytes : replaced return value with null for fr/sii/ogham/sms/encoder/EncodedWithHeader::getBytes → NO_COVERAGE 2. getBytes : replaced return value with null for fr/sii/ogham/sms/encoder/EncodedWithHeader::getBytes → KILLED 3. getBytes : replaced return value with null for fr/sii/ogham/sms/encoder/EncodedWithHeader::getBytes → KILLED 4. getBytes : replaced return value with null for fr/sii/ogham/sms/encoder/EncodedWithHeader::getBytes → KILLED |
return wholeSegment; |
| 49 | } | |
| 50 | ||
| 51 | @Override | |
| 52 | public String getCharsetName() { | |
| 53 |
3
1. getCharsetName : replaced return value with "" for fr/sii/ogham/sms/encoder/EncodedWithHeader::getCharsetName → NO_COVERAGE 2. getCharsetName : replaced return value with "" for fr/sii/ogham/sms/encoder/EncodedWithHeader::getCharsetName → KILLED 3. getCharsetName : replaced return value with "" for fr/sii/ogham/sms/encoder/EncodedWithHeader::getCharsetName → KILLED |
return payload.getCharsetName(); |
| 54 | } | |
| 55 | ||
| 56 | /** | |
| 57 | * The encoded message may contain a header. This happens for example when a | |
| 58 | * message is split into several segments. The header is used to indicate | |
| 59 | * how the message was split (see | |
| 60 | * <a href="https://en.wikipedia.org/wiki/User_Data_Header">User Data | |
| 61 | * Header</a>). | |
| 62 | * | |
| 63 | * @return the header bytes | |
| 64 | */ | |
| 65 | public byte[] getHeader() { | |
| 66 |
1
1. getHeader : replaced return value with null for fr/sii/ogham/sms/encoder/EncodedWithHeader::getHeader → NO_COVERAGE |
return header; |
| 67 | } | |
| 68 | ||
| 69 | /** | |
| 70 | * The encoded message may contain a header. This happens for example when a | |
| 71 | * message is split into several segments. The header is used to indicate | |
| 72 | * how the message was split (see | |
| 73 | * <a href="https://en.wikipedia.org/wiki/User_Data_Header">User Data | |
| 74 | * Header</a>). This method gives access to the real message (named | |
| 75 | * payload). | |
| 76 | * | |
| 77 | * @return the payload (real message without header) bytes | |
| 78 | */ | |
| 79 | public Encoded getPayload() { | |
| 80 |
1
1. getPayload : replaced return value with null for fr/sii/ogham/sms/encoder/EncodedWithHeader::getPayload → NO_COVERAGE |
return payload; |
| 81 | } | |
| 82 | ||
| 83 | } | |
Mutations | ||
| 41 |
1.1 2.2 3.3 4.4 |
|
| 42 |
1.1 2.2 3.3 4.4 |
|
| 43 |
1.1 2.2 3.3 4.4 |
|
| 48 |
1.1 2.2 3.3 4.4 |
|
| 53 |
1.1 2.2 3.3 |
|
| 66 |
1.1 |
|
| 80 |
1.1 |