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.util.servlet;
016    
017    import java.io.ByteArrayInputStream;
018    import java.io.IOException;
019    
020    import javax.servlet.ServletInputStream;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class ByteArrayInputStreamWrapper extends ServletInputStream {
026    
027            public ByteArrayInputStreamWrapper(
028                    ByteArrayInputStream byteArrayInputStream) {
029    
030                    _byteArrayInputStream = byteArrayInputStream;
031            }
032    
033            @Override
034            public int available() {
035                    return _byteArrayInputStream.available();
036            }
037    
038            @Override
039            public void close() throws IOException {
040                    _byteArrayInputStream.close();
041            }
042    
043            @Override
044            public void mark(int readLimit) {
045                    _byteArrayInputStream.mark(readLimit);
046            }
047    
048            @Override
049            public boolean markSupported() {
050                    return _byteArrayInputStream.markSupported();
051            }
052    
053            @Override
054            public int read() {
055                    return _byteArrayInputStream.read();
056            }
057    
058            @Override
059            public int read(byte[] bytes) throws IOException {
060                    return _byteArrayInputStream.read(bytes);
061            }
062    
063            @Override
064            public int read(byte[] bytes, int offset, int length) {
065                    return _byteArrayInputStream.read(bytes, offset, length);
066            }
067    
068            @Override
069            public int readLine(byte[] bytes, int offset, int length) {
070                    return _byteArrayInputStream.read(bytes, offset, length);
071            }
072    
073            @Override
074            public void reset() {
075                    _byteArrayInputStream.reset();
076            }
077    
078            @Override
079            public long skip(long skip) {
080                    return _byteArrayInputStream.skip(skip);
081            }
082    
083            private ByteArrayInputStream _byteArrayInputStream;
084    
085    }