001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    }