public void setText(String value) { try { XmlText text = null; if (StringUtil.isNotEmpty(value)) { final XmlText[] texts = getTextElements(); if (texts.length == 0) { text = (XmlText) myTag.add( XmlElementFactory.getInstance(myTag.getProject()).createDisplayText("x")); } else { text = texts[0]; } text.setValue(value); } if (myElements.length > 0) { for (final XmlTagChild child : myElements) { if (child != text) { child.delete(); } } } } catch (IncorrectOperationException e) { LOG.error(e); } }
@NotNull public String getText() { String text = myText; if (text != null) return text; final StringBuilder consolidatedText = new StringBuilder(); for (final XmlTagChild element : myElements) { consolidatedText.append(element.getText()); } return myText = consolidatedText.toString(); }