Element (@NotNull Set<String> keywords, @NotNull String tagName, @NotNull Element highlightingElement) { if (keywords.isEmpty() && !ELEMENT_KEYWORDS.equals(tagName)) return null; Element keywordsElement = new Element(tagName); String[] strings = ArrayUtilRt.toStringArray(keywords); Arrays.sort(strings); StringBuilder keywordsAttribute = new StringBuilder(); for (final String keyword : strings) { if (!keyword.contains(SEMICOLON)) { if (keywordsAttribute.length() != 0) keywordsAttribute.append(SEMICOLON); keywordsAttribute.append(keyword); } else { Element e = new Element(ELEMENT_KEYWORD); e.setAttribute(ATTRIBUTE_NAME, keyword); keywordsElement.addContent(e); } } if (keywordsAttribute.length() != 0) { keywordsElement.setAttribute(ELEMENT_KEYWORDS, keywordsAttribute.toString()); } highlightingElement.addContent(keywordsElement); return keywordsElement; }