package org.openecomp.sdc.common.util;
+import org.apache.commons.lang3.StringEscapeUtils;
+
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTML.Tag;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.swing.text.html.HTML;
-import javax.swing.text.html.HTML.Tag;
-
-import org.apache.commons.lang3.StringEscapeUtils;
-
public class HtmlCleaner {
private static Set<String> htmlTags = new HashSet<>();
public static String stripHtml(String input, boolean toEscape) {
- if (input == null || true == input.isEmpty()) {
+ if (input == null || input.isEmpty()) {
return input;
}
if (groupCount > 0) {
String tag = matcher.group(1);
if (tag != null && htmlTags.contains(tag.toLowerCase())) {
- if (false == tagsToRemove.contains(matchTag)) {
+ if (!tagsToRemove.contains(matchTag)) {
tagsToRemove.add(matchTag);
}
}
String stripHtmlStr = removeTagsFromString(tagsToRemove, input);
if (stripHtmlStr != null) {
- if (true == toEscape) {
+ if (toEscape) {
stripHtmlStr = StringEscapeUtils.escapeHtml4(stripHtmlStr);
}
}
private static String removeTagsFromString(Set<String> tagsToRemove, String input) {
String stripStr = input;
- if (input == null || true == tagsToRemove.isEmpty()) {
+ if (input == null || tagsToRemove.isEmpty()) {
return input;
}