Class ByteArrayXmlStreamReader

  • All Implemented Interfaces:
    java.lang.AutoCloseable, javax.xml.stream.XMLStreamConstants, javax.xml.stream.XMLStreamReader

    @Internal
    public final class ByteArrayXmlStreamReader
    extends javax.xml.stream.util.StreamReaderDelegate
    implements java.lang.AutoCloseable
    Stream reader that pairs xml stream with underlying byte array.
    Since:
    1.0.0
    • Field Summary

      • Fields inherited from interface javax.xml.stream.XMLStreamConstants

        ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ByteArrayXmlStreamReader reset()
      The xmlStream is stateful.
      • Methods inherited from class javax.xml.stream.util.StreamReaderDelegate

        close, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getElementText, getEncoding, getEventType, getLocalName, getLocation, getName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getParent, getPIData, getPITarget, getPrefix, getProperty, getText, getTextCharacters, getTextCharacters, getTextLength, getTextStart, getVersion, hasName, hasNext, hasText, isAttributeSpecified, isCharacters, isEndElement, isStandalone, isStartElement, isWhiteSpace, next, nextTag, require, setParent, standaloneSet
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.AutoCloseable

        close
    • Constructor Detail

      • ByteArrayXmlStreamReader

        public ByteArrayXmlStreamReader​(byte[] bytes)
                                 throws javax.xml.stream.XMLStreamException
        Parameters:
        bytes - raw representation of xml
        Throws:
        javax.xml.stream.XMLStreamException - if byte array represents corrupted xml
    • Method Detail

      • reset

        public ByteArrayXmlStreamReader reset()
        The xmlStream is stateful. Once we walked through the whole stream, before we can re-read its content we need to reset state. Unfortunately the stream implementation does not have an api to flush the state, so a simple solution is to create a new instance with the same underlying byte array.
        Returns:
        new instance with fresh state