001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.servlet;
016    
017    import java.io.IOException;
018    import java.io.InputStream;
019    
020    import javax.servlet.ServletInputStream;
021    
022    /**
023     * @author Shuyang Zhou
024     */
025    public class ServletInputStreamAdapter extends ServletInputStream {
026    
027            public ServletInputStreamAdapter(InputStream inputStream) {
028                    this.inputStream = inputStream;
029            }
030    
031            @Override
032            public int available() throws IOException {
033                    return inputStream.available();
034            }
035    
036            @Override
037            public void close() throws IOException {
038                    inputStream.close();
039            }
040    
041            @Override
042            public void mark(int readLimit) {
043                    inputStream.mark(readLimit);
044            }
045    
046            @Override
047            public boolean markSupported() {
048                    return inputStream.markSupported();
049            }
050    
051            @Override
052            public int read() throws IOException {
053                    return inputStream.read();
054            }
055    
056            @Override
057            public int read(byte[] bytes) throws IOException {
058                    return inputStream.read(bytes);
059            }
060    
061            @Override
062            public int read(byte[] bytes, int offset, int length) throws IOException {
063                    return inputStream.read(bytes, offset, length);
064            }
065    
066            @Override
067            public void reset() throws IOException {
068                    inputStream.reset();
069            }
070    
071            @Override
072            public long skip(long skip) throws IOException {
073                    return inputStream.skip(skip);
074            }
075    
076            protected InputStream inputStream;
077    
078    }