| 1 | package com.jsql.view.swing.util; | |
| 2 | ||
| 3 | import org.apache.commons.lang3.StringUtils; | |
| 4 | import org.mozilla.universalchardet.UniversalDetector; | |
| 5 | ||
| 6 | import java.nio.charset.StandardCharsets; | |
| 7 | ||
| 8 | public class UiStringUtil { | |
| 9 | ||
| 10 | private UiStringUtil() { | |
| 11 | // Utility class | |
| 12 | } | |
| 13 | | |
| 14 | public static String detectUtf8Html(String text) { | |
| 15 |
1
1. detectUtf8Html : replaced return value with "" for com/jsql/view/swing/util/UiStringUtil::detectUtf8Html → NO_COVERAGE |
return UiStringUtil.detectUtf8Html(text, false); |
| 16 | } | |
| 17 | | |
| 18 | public static String detectUtf8HtmlNoWrap(String text) { | |
| 19 |
1
1. detectUtf8HtmlNoWrap : replaced return value with "" for com/jsql/view/swing/util/UiStringUtil::detectUtf8HtmlNoWrap → NO_COVERAGE |
return UiStringUtil.detectUtf8Html(text, true); |
| 20 | } | |
| 21 | | |
| 22 | public static String detectUtf8Html(String text, boolean nowrap) { | |
| 23 | | |
| 24 | // Fix #35217: NullPointerException on getBytes() | |
| 25 |
1
1. detectUtf8Html : negated conditional → NO_COVERAGE |
if (text == null) { |
| 26 | return StringUtils.EMPTY; | |
| 27 | } | |
| 28 | | |
| 29 | var detector = new UniversalDetector(null); | |
| 30 | | |
| 31 | // Decode bytes for potentially UTF8 chars | |
| 32 | // Required by asian and hindi chars, otherwise wrong display in database tree | |
| 33 |
1
1. detectUtf8Html : removed call to org/mozilla/universalchardet/UniversalDetector::handleData → NO_COVERAGE |
detector.handleData( |
| 34 | text.getBytes(StandardCharsets.UTF_8), | |
| 35 | 0, | |
| 36 |
1
1. detectUtf8Html : Replaced integer subtraction with addition → NO_COVERAGE |
text.length() - 1 |
| 37 | ); | |
| 38 | | |
| 39 |
1
1. detectUtf8Html : removed call to org/mozilla/universalchardet/UniversalDetector::dataEnd → NO_COVERAGE |
detector.dataEnd(); |
| 40 | String result = text; | |
| 41 | ||
| 42 | // Confirm UTF8 | |
| 43 | String encoding = detector.getDetectedCharset(); | |
| 44 |
1
1. detectUtf8Html : negated conditional → NO_COVERAGE |
if (encoding != null) { |
| 45 |
1
1. detectUtf8Html : negated conditional → NO_COVERAGE |
result = I18nViewUtil.formatNonLatin(text, nowrap ? "white-space:nowrap;" : StringUtils.EMPTY); |
| 46 | } | |
| 47 | | |
| 48 |
1
1. detectUtf8Html : replaced return value with "" for com/jsql/view/swing/util/UiStringUtil::detectUtf8Html → NO_COVERAGE |
return result; |
| 49 | } | |
| 50 | } | |
Mutations | ||
| 15 |
1.1 |
|
| 19 |
1.1 |
|
| 25 |
1.1 |
|
| 33 |
1.1 |
|
| 36 |
1.1 |
|
| 39 |
1.1 |
|
| 44 |
1.1 |
|
| 45 |
1.1 |
|
| 48 |
1.1 |