Package org.openstreetmap.josm.io
Class InvalidXmlCharacterFilter
- java.lang.Object
-
- java.io.Reader
-
- org.openstreetmap.josm.io.InvalidXmlCharacterFilter
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Readable
public class InvalidXmlCharacterFilter extends java.io.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 java.io.Reader
reader
-
Constructor Summary
Constructors Constructor Description InvalidXmlCharacterFilter(java.io.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)
-
-
-
Field Detail
-
reader
private final java.io.Reader reader
-
firstWarning
private static boolean firstWarning
-
INVALID_CHARS
private static final boolean[] INVALID_CHARS
-
-
Constructor Detail
-
InvalidXmlCharacterFilter
public InvalidXmlCharacterFilter(java.io.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 java.io.IOException
- Specified by:
read
in classjava.io.Reader
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Reader
- Throws:
java.io.IOException
-
filter
private static char filter(char in)
-
-