Class NodeInputStream

java.lang.Object
java.io.InputStream
org.custommonkey.xmlunit.NodeInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class NodeInputStream extends InputStream
Adapter class to present the content of a DOM Node (e.g. a Document) as an InputStream using a DOM to Stream transformation.
  • Field Details

    • rootNode

      private final Node rootNode
    • nodeContentBytes

      private final ByteArrayOutputStream nodeContentBytes
    • outputProperties

      private final Properties outputProperties
    • atPos

      private int atPos
  • Constructor Details

    • NodeInputStream

      public NodeInputStream(Node rootNode)
      Simple constructor
      Parameters:
      rootNode - the node to be presented as an input stream
    • NodeInputStream

      public NodeInputStream(Node rootNode, Properties outputProperties)
      Simple constructor
      Parameters:
      rootNode - the node to be presented as an input stream
  • Method Details

    • ensureContentAvailable

      private void ensureContentAvailable() throws IOException
      Do the actual work of serializing the node to bytes
      Throws:
      IOException - if serialization goes awry
    • read

      public int read() throws IOException
      InputStream method
      Specified by:
      read in class InputStream
      Returns:
      byte as read
      Throws:
      IOException
    • close

      public void close() throws IOException
      InputStream method Note that calling close allows a repeated read of the content
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException
    • available

      public int available() throws IOException
      InputStream method
      Overrides:
      available in class InputStream
      Returns:
      number of bytes available
      Throws:
      IOException
    • reallyAvailable

      private int reallyAvailable()
      Returns:
      really available