Package org.custommonkey.xmlunit
Class NodeInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.custommonkey.xmlunit.NodeInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class NodeInputStream extends java.io.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 Summary
Fields Modifier and Type Field Description private int
atPos
private java.io.ByteArrayOutputStream
nodeContentBytes
private java.util.Properties
outputProperties
private org.w3c.dom.Node
rootNode
-
Constructor Summary
Constructors Constructor Description NodeInputStream(org.w3c.dom.Node rootNode)
Simple constructorNodeInputStream(org.w3c.dom.Node rootNode, java.util.Properties outputProperties)
Simple constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
InputStream methodvoid
close()
InputStream method Note that calling close allows a repeated read of the contentprivate void
ensureContentAvailable()
Do the actual work of serializing the node to bytesint
read()
InputStream methodprivate int
reallyAvailable()
-
-
-
Constructor Detail
-
NodeInputStream
public NodeInputStream(org.w3c.dom.Node rootNode)
Simple constructor- Parameters:
rootNode
- the node to be presented as an input stream
-
NodeInputStream
public NodeInputStream(org.w3c.dom.Node rootNode, java.util.Properties outputProperties)
Simple constructor- Parameters:
rootNode
- the node to be presented as an input stream
-
-
Method Detail
-
ensureContentAvailable
private void ensureContentAvailable() throws java.io.IOException
Do the actual work of serializing the node to bytes- Throws:
java.io.IOException
- if serialization goes awry
-
read
public int read() throws java.io.IOException
InputStream method- Specified by:
read
in classjava.io.InputStream
- Returns:
- byte as read
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
InputStream method Note that calling close allows a repeated read of the content- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException
InputStream method- Overrides:
available
in classjava.io.InputStream
- Returns:
- number of bytes available
- Throws:
java.io.IOException
-
reallyAvailable
private int reallyAvailable()
- Returns:
- really available
-
-