public String readText() throws XMLStreamException {
        if (isInsideResponseHeader()) {
            return getHeader(currentHeader);
        }
        if (currentEvent.isAttribute()) {
            Attribute attribute = (Attribute)currentEvent;
            return attribute.getValue();
        }

        StringBuilder sb = new StringBuilder();
        while (true) {
            XMLEvent event = eventReader.peek();
            if (event.getEventType() == XMLStreamConstants.CHARACTERS) {
                eventReader.nextEvent();
                sb.append(event.asCharacters().getData());
            } else if (event.getEventType() == XMLStreamConstants.END_ELEMENT) {
                return sb.toString();
            } else {
                throw new RuntimeException("Encountered unexpected event: " + event.toString());
            }
        }
    }
Returns the text contents of the current element being parsed.

@return The text contents of the current element being parsed.
@throws XMLStreamException
aws-java-sdk-core/src/main/java/com/amazonaws/transform/StaxUnmarshallerContext.java