| 1 | package fr.sii.ogham.sms.builder.cloudhopper; | |
| 2 | ||
| 3 | import static com.cloudhopper.commons.charset.CharsetUtil.NAME_GSM; | |
| 4 | import static com.cloudhopper.commons.charset.CharsetUtil.NAME_GSM7; | |
| 5 | import static com.cloudhopper.commons.charset.CharsetUtil.NAME_ISO_8859_1; | |
| 6 | import static com.cloudhopper.commons.charset.CharsetUtil.NAME_UCS_2; | |
| 7 | ||
| 8 | import fr.sii.ogham.core.builder.context.BuildContext; | |
| 9 | import fr.sii.ogham.sms.encoder.Encoder; | |
| 10 | import fr.sii.ogham.sms.splitter.MessageSplitter; | |
| 11 | ||
| 12 | /** | |
| 13 | * Encoding configuration is shared between {@link CloudhopperBuilder} and | |
| 14 | * {@link MessageSplitterBuilder}. {@link CloudhopperBuilder} directly uses the | |
| 15 | * result of {@link EncoderBuilder#build()}. However, | |
| 16 | * {@link MessageSplitterBuilder} can't use result of | |
| 17 | * {@link EncoderBuilder#build()} directly but only the registered properties | |
| 18 | * and values to create an {@link Encoder} dedicated to a | |
| 19 | * {@link MessageSplitter}. | |
| 20 | * | |
| 21 | * {@link EncoderBuilder} is the part that is "visible" by the developer and | |
| 22 | * developer should not access methods used to get values (internal methods), | |
| 23 | * just methods to configure like with other builders in order to have a simple | |
| 24 | * contract. | |
| 25 | * | |
| 26 | * This class uses package protected visibility to access configured values. | |
| 27 | * | |
| 28 | * @author Aurélien Baudet | |
| 29 | * | |
| 30 | */ | |
| 31 | public class ReadableEncoderBuilder { | |
| 32 | private final BuildContext buildContext; | |
| 33 | private EncoderBuilder delegate; | |
| 34 | ||
| 35 | /** | |
| 36 | * Initialize with the build context | |
| 37 | * | |
| 38 | * @param buildContext | |
| 39 | * for registering instances and property evaluation | |
| 40 | */ | |
| 41 | public ReadableEncoderBuilder(BuildContext buildContext) { | |
| 42 | super(); | |
| 43 | this.buildContext = buildContext; | |
| 44 | } | |
| 45 | ||
| 46 | /** | |
| 47 | * Set the encoder builder that is configured by the developer. | |
| 48 | * | |
| 49 | * @param encoderBuilder | |
| 50 | * the encoder builder | |
| 51 | */ | |
| 52 | public void update(EncoderBuilder encoderBuilder) { | |
| 53 | this.delegate = encoderBuilder; | |
| 54 | } | |
| 55 | ||
| 56 | /** | |
| 57 | * @return the registered properties/values for GSM 7-bit encoding | |
| 58 | */ | |
| 59 | public StandardEncodingHelper getGsm7Priorities() { | |
| 60 |
1
1. getGsm7Priorities : negated conditional → RUN_ERROR |
if (delegate == null) { |
| 61 |
1
1. getGsm7Priorities : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/ReadableEncoderBuilder::getGsm7Priorities → NO_COVERAGE |
return new StandardEncodingHelper(delegate, NAME_GSM7, buildContext); |
| 62 | } | |
| 63 |
1
1. getGsm7Priorities : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/ReadableEncoderBuilder::getGsm7Priorities → RUN_ERROR |
return delegate.gsm7PackedValueBuilder; |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * @return the registered properties/values for GSM 8-bit encoding | |
| 68 | */ | |
| 69 | public StandardEncodingHelper getGsm8Priorities() { | |
| 70 |
1
1. getGsm8Priorities : negated conditional → RUN_ERROR |
if (delegate == null) { |
| 71 |
1
1. getGsm8Priorities : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/ReadableEncoderBuilder::getGsm8Priorities → NO_COVERAGE |
return new StandardEncodingHelper(delegate, NAME_GSM, buildContext); |
| 72 | } | |
| 73 |
1
1. getGsm8Priorities : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/ReadableEncoderBuilder::getGsm8Priorities → RUN_ERROR |
return delegate.gsm8ValueBuilder; |
| 74 | } | |
| 75 | ||
| 76 | /** | |
| 77 | * @return the registered properties/values for UCS-2 encoding | |
| 78 | */ | |
| 79 | public StandardEncodingHelper getUcs2Priorities() { | |
| 80 |
1
1. getUcs2Priorities : negated conditional → RUN_ERROR |
if (delegate == null) { |
| 81 |
1
1. getUcs2Priorities : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/ReadableEncoderBuilder::getUcs2Priorities → NO_COVERAGE |
return new StandardEncodingHelper(delegate, NAME_UCS_2, buildContext); |
| 82 | } | |
| 83 |
1
1. getUcs2Priorities : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/ReadableEncoderBuilder::getUcs2Priorities → RUN_ERROR |
return delegate.ucs2ValueBuilder; |
| 84 | } | |
| 85 | ||
| 86 | /** | |
| 87 | * @return the registered properties/values for Latin 1 encoding | |
| 88 | */ | |
| 89 | public StandardEncodingHelper getLatin1Priorities() { | |
| 90 |
1
1. getLatin1Priorities : negated conditional → RUN_ERROR |
if (delegate == null) { |
| 91 |
1
1. getLatin1Priorities : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/ReadableEncoderBuilder::getLatin1Priorities → NO_COVERAGE |
return new StandardEncodingHelper(delegate, NAME_ISO_8859_1, buildContext); |
| 92 | } | |
| 93 |
1
1. getLatin1Priorities : replaced return value with null for fr/sii/ogham/sms/builder/cloudhopper/ReadableEncoderBuilder::getLatin1Priorities → RUN_ERROR |
return delegate.latin1ValueBuilder; |
| 94 | } | |
| 95 | ||
| 96 | /** | |
| 97 | * @return true if automatic guessing has been enabled | |
| 98 | */ | |
| 99 | public boolean autoGuessEnabled() { | |
| 100 |
1
1. autoGuessEnabled : negated conditional → RUN_ERROR |
if (delegate == null) { |
| 101 |
1
1. autoGuessEnabled : replaced boolean return with true for fr/sii/ogham/sms/builder/cloudhopper/ReadableEncoderBuilder::autoGuessEnabled → NO_COVERAGE |
return false; |
| 102 | } | |
| 103 |
2
1. autoGuessEnabled : replaced boolean return with false for fr/sii/ogham/sms/builder/cloudhopper/ReadableEncoderBuilder::autoGuessEnabled → RUN_ERROR 2. autoGuessEnabled : replaced boolean return with true for fr/sii/ogham/sms/builder/cloudhopper/ReadableEncoderBuilder::autoGuessEnabled → RUN_ERROR |
return delegate.autoGuessEnabled(); |
| 104 | } | |
| 105 | } | |
Mutations | ||
| 60 |
1.1 |
|
| 61 |
1.1 |
|
| 63 |
1.1 |
|
| 70 |
1.1 |
|
| 71 |
1.1 |
|
| 73 |
1.1 |
|
| 80 |
1.1 |
|
| 81 |
1.1 |
|
| 83 |
1.1 |
|
| 90 |
1.1 |
|
| 91 |
1.1 |
|
| 93 |
1.1 |
|
| 100 |
1.1 |
|
| 101 |
1.1 |
|
| 103 |
1.1 2.2 |