From 97e7d44a47299e7f8133de4537732aae9fb7ea59 Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 5 Oct 2020 00:37:00 +0200 Subject: [PATCH] Extracted convertReservedXmlCharacters() and convertDiacritics() --- .../implementierte/sepa/ISepaMessageCreator.kt | 16 +++++++++------- .../implementierte/sepa/SepaMessageCreator.kt | 7 +++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/ISepaMessageCreator.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/ISepaMessageCreator.kt index 353a2402..e570b47b 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/ISepaMessageCreator.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/ISepaMessageCreator.kt @@ -5,14 +5,16 @@ interface ISepaMessageCreator { fun createXmlFile(messageTemplate: PaymentInformationMessages, replacementStrings: Map): String - fun convertDiacriticsAndReservedXmlCharactersAndCheckIfContainsOnlyAllowedCharacters(stringToTest: String): Boolean { - val convertedString = convertDiacriticsAndReservedXmlCharacters(stringToTest) - - return containsOnlyAllowedCharacters(convertedString) - } - fun containsOnlyAllowedCharacters(stringToTest: String): Boolean - fun convertDiacriticsAndReservedXmlCharacters(input: String): String + fun convertDiacriticsAndReservedXmlCharacters(input: String): String { + var converted = convertDiacritics(input) + + return convertReservedXmlCharacters(converted) + } + + fun convertReservedXmlCharacters(input: String): String + + fun convertDiacritics(input: String): String } \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreator.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreator.kt index 6fafd3c8..5a7c6a1a 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreator.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/messages/segmente/implementierte/sepa/SepaMessageCreator.kt @@ -37,7 +37,7 @@ open class SepaMessageCreator : ISepaMessageCreator { && convertDiacriticsAndReservedXmlCharacters(stringToTest) == stringToTest } - override fun convertDiacriticsAndReservedXmlCharacters(input: String): String { + override fun convertReservedXmlCharacters(input: String): String { // TODO: add other replacement strings return input .replace("\"", """) @@ -45,8 +45,11 @@ open class SepaMessageCreator : ISepaMessageCreator { .replace("&", "&") .replace("<", "<") .replace(">", ">") + } + + override fun convertDiacritics(input: String): String { + return input - // convert diacritics .replace("á", "a", true) .replace("à", "a", true) .replace("â", "a", true)