Package org.custommonkey.xmlunit
Class DoctypeReader
java.lang.Object
java.io.Reader
org.custommonkey.xmlunit.DoctypeReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
Adapts the marked-up content in a source Reader to specify that it
conforms to a different DTD.
Combines Reader semantics with the ability to specify a target doctype
for a character stream containing XML markup.
Used by Validator class to wrap a Reader when performing validation of a
document against a DTD.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BufferedReader
private final StringBuilder
private final DoctypeSupport
-
Constructor Summary
ConstructorsConstructorDescriptionDoctypeReader
(Reader originalSource, String doctypeName, String systemID) Create a Reader whose XML content is provided by the originalSource with the exception of the DOCTYPE which is provided by the doctypeName and systemID. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected String
private StringBuilder
getContent
(BufferedReader originalSource) int
read()
Read DOCTYPE-replaced content from the wrapped Readerint
read
(char[] cbuf, int off, int len) Read DOCTYPE-replaced content from the wrapped ReaderMethods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, ready, reset, skip, transferTo
-
Field Details
-
originalReader
-
sourceBuilder
-
support
-
-
Constructor Details
-
DoctypeReader
Create a Reader whose XML content is provided by the originalSource with the exception of the DOCTYPE which is provided by the doctypeName and systemID.- Parameters:
originalSource
-doctypeName
-systemID
-
-
-
Method Details
-
getContent
- Returns:
- the content of the original source, without amendments or substitutions. Safe to call multiple times.
- Throws:
IOException
- if thrown while reading from the original source
-
getContent
- Parameters:
originalSource
-- Returns:
- the contents of the originalSource within a StringBuffer
- Throws:
IOException
- if thrown while reading from the original source
-
read
Read DOCTYPE-replaced content from the wrapped Reader- Specified by:
read
in classReader
- Parameters:
cbuf
-off
-len
-- Returns:
- The number of characters read, or -1 if the end of the stream has been reached
- Throws:
IOException
-
read
Read DOCTYPE-replaced content from the wrapped Reader- Overrides:
read
in classReader
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
-