}
}
public String getElementText() throws XMLStreamException {
if (super.getEventType() != START_ELEMENT) {
throw new XMLStreamException("The current event is not a START_ELEMENT event");
}
int event = super.next();
// Note that an xop:Include must be the first child of the element
if (event == START_ELEMENT
&& super.getLocalName().equals(XOPConstants.INCLUDE)
&& super.getNamespaceURI().equals(XOPConstants.NAMESPACE_URI)) {
String contentID = processXopInclude();
try {
return toBase64(mimePartProvider.getDataHandler(contentID));
} catch (IOException ex) {
throw new XMLStreamException("Failed to load MIME part '" + contentID + "'", ex);
}
} else {
String text = null;
StringBuffer buffer = null;
while (event != END_ELEMENT) {
switch (event) {
case CHARACTERS:
case CDATA:
case SPACE:
case ENTITY_REFERENCE:
if (text == null && buffer == null) {
text = super.getText();
} else {
String thisText = super.getText();
if (buffer == null) {
buffer = new StringBuffer(text.length() + thisText.length());
buffer.append(text);
}
buffer.append(thisText);
}
break;
case PROCESSING_INSTRUCTION:
case COMMENT:
// Skip this event
break;
default:
throw new XMLStreamException("Unexpected event " +
XMLEventUtils.getEventTypeString(event) +
" while reading element text");
}
event = super.next();
}