Package org.openstreetmap.josm.io
Class InvalidXmlCharacterFilter
- java.lang.Object
-
- java.io.Reader
-
- org.openstreetmap.josm.io.InvalidXmlCharacterFilter
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
public class InvalidXmlCharacterFilter extends Reader
FilterInputStream that gets rid of characters that are invalid in an XML 1.0 document. Although these characters are forbidden, in the real wold they still appear in XML files. Java's SAX parser throws an exception, so we have to filter at a lower level. Only handles control characters (<0x20). Invalid characters are replaced by space (0x20).
-
-
Field Summary
Fields Modifier and Type Field Description private static boolean
firstWarning
private static boolean[]
INVALID_CHARS
private Reader
reader
-
Constructor Summary
Constructors Constructor Description InvalidXmlCharacterFilter(Reader reader)
Constructs a newInvalidXmlCharacterFilter
for the given Reader.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
private static char
filter(char in)
int
read(char[] b, int off, int len)
-
Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, read, ready, reset, skip, transferTo
-
-
-
-
Field Detail
-
firstWarning
private static boolean firstWarning
-
INVALID_CHARS
private static final boolean[] INVALID_CHARS
-
-
Constructor Detail
-
InvalidXmlCharacterFilter
public InvalidXmlCharacterFilter(Reader reader)
Constructs a newInvalidXmlCharacterFilter
for the given Reader.- Parameters:
reader
- The reader to filter
-
-
Method Detail
-
read
public int read(char[] b, int off, int len) throws IOException
- Specified by:
read
in classReader
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
-
filter
private static char filter(char in)
-
-