class Xml10FilterReader extends FilterReader {

    /**
     * Creates filter reader which skips invalid xml characters.
     *
     * @param in original reader
     */
    public Xml10FilterReader(Reader in) {
        super(in);
    }

    /**
     * Every overload of {@link Reader#read()} method delegates to this one so
     * it is enough to override only this one.
     * <p>
     * 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.
     *
     * @return Number of read valid characters or <code>-1</code> if end of the
     * underling reader was reached.
     */
    @Override
    public int read(char[] cbuf, int off, int len) throws IOException {<FILL_FUNCTION_BODY>}
}

        int read = super.read(cbuf, off, len);
        /*
         * If read chars are -1 then we have reach the end of the reader.
         */
        if (read == -1) {
            return -1;
        }
        /*
         * pos will show the index where chars should be moved if there are gaps
         * from invalid characters.
         */
        int pos = off - 1;

        for (int readPos = off; readPos < off + read; readPos++) {
            if (XMLChar.isValid(cbuf[readPos])) {
                pos++;
            } else {
                continue;
            }
            /*
             * If there is gap(s) move current char to its position.
             */
            if (pos < readPos) {
                cbuf[pos] = cbuf[readPos];
            }
        }
        /*
         * Number of read valid characters.
         */
        return pos - off + 1;
    
<methods>public void close() throws java.io.IOException,public void mark(int) throws java.io.IOException,public boolean markSupported() ,public int read() throws java.io.IOException,public int read(char[], int, int) throws java.io.IOException,public boolean ready() throws java.io.IOException,public void reset() throws java.io.IOException,public long skip(long) throws java.io.IOException<variables>protected java.io.Reader in