Package com.avoka.core.util
Class Xml10FilterReader
- java.lang.Object
-
- java.io.Reader
-
- java.io.FilterReader
-
- com.avoka.core.util.Xml10FilterReader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
public class Xml10FilterReader extends FilterReader
Provides an XML 1.0 filter reader. See: http://info.tsachev.org/2009/05/skipping-invalid-xml-character-with.html- Since:
- 4.1.0
-
-
Field Summary
-
Fields inherited from class java.io.FilterReader
in
-
-
Constructor Summary
Constructors Constructor Description Xml10FilterReader(Reader in)
Creates filter reader which skips invalid xml characters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
read(char[] cbuf, int off, int len)
Every overload ofReader.read()
method delegates to this one so it is enough to override only this one.-
Methods inherited from class java.io.FilterReader
close, mark, markSupported, read, ready, reset, skip
-
Methods inherited from class java.io.Reader
nullReader, read, read, transferTo
-
-
-
-
Constructor Detail
-
Xml10FilterReader
public Xml10FilterReader(Reader in)
Creates filter reader which skips invalid xml characters.- Parameters:
in
- original reader
-
-
Method Detail
-
read
public int read(char[] cbuf, int off, int len) throws IOException
Every overload ofReader.read()
method delegates to this one so it is enough to override only this one.
To skip invalid characters this method shifts only valid chars to left and returns decreased value of the original read method. So after last valid character there will be some unused chars in the buffer.- Overrides:
read
in classFilterReader
- Parameters:
cbuf
- the character bufferoff
- the offsetlen
- the buffer length- Returns:
- Number of read valid characters or
-1
if end of the underling reader was reached. - Throws:
IOException
- if an error occurs
-
-