001    package railo.commons.io;
002    
003    import java.io.IOException;
004    import java.io.Reader;
005    import java.nio.CharBuffer;
006    
007    public final class CountingReader extends Reader {
008            
009            private final Reader reader;
010        private int count=0;
011    
012        public CountingReader(Reader reader) {
013            this.reader=reader;
014        }
015            /**
016             * @see java.io.Reader#mark(int)
017             */
018            public void mark(int readAheadLimit) throws IOException {
019                    reader.mark(readAheadLimit);
020            }
021    
022            /**
023             * @see java.io.Reader#markSupported()
024             */
025            public boolean markSupported() {
026                    return reader.markSupported();
027            }
028    
029            /**
030             *
031             * @see java.io.Reader#read()
032             */
033            public int read() throws IOException {
034                    count++;
035                    return reader.read();
036            }
037    
038            /**
039             *
040             * @see java.io.Reader#read(char[])
041             */
042            public int read(char[] cbuf) throws IOException {
043                    
044                    return reader.read(cbuf);
045            }
046    
047            /**
048             *
049             * @see java.io.Reader#read(java.nio.CharBuffer)
050             */
051            public int read(CharBuffer arg0) throws IOException {
052                    return super.read(arg0.array());
053            }
054    
055            /**
056             *
057             * @see java.io.Reader#ready()
058             */
059            public boolean ready() throws IOException {
060                    // TODO Auto-generated method stub
061                    return super.ready();
062            }
063    
064            /**
065             *
066             * @see java.io.Reader#reset()
067             */
068            public void reset() throws IOException {
069                    // TODO Auto-generated method stub
070                    super.reset();
071            }
072    
073            /**
074             *
075             * @see java.io.Reader#skip(long)
076             */
077            public long skip(long n) throws IOException {
078                    // TODO Auto-generated method stub
079                    return super.skip(n);
080            }
081    
082            public void close() throws IOException {
083                    // TODO Auto-generated method stub
084    
085            }
086    
087            public int read(char[] cbuf, int off, int len) throws IOException {
088                    // TODO Auto-generated method stub
089                    return 0;
090            }
091    
092    }