001    /**
002     * Copyright (c) 2000-2010 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            public int available() {
034                    return _byteArrayInputStream.available();
035            }
036    
037            public void close() throws IOException {
038                    _byteArrayInputStream.close();
039            }
040    
041            public void mark(int readLimit) {
042                    _byteArrayInputStream.mark(readLimit);
043            }
044    
045            public boolean markSupported() {
046                    return _byteArrayInputStream.markSupported();
047            }
048    
049            public int read() {
050                    return _byteArrayInputStream.read();
051            }
052    
053            public int read(byte[] byteArray) throws IOException {
054                    return _byteArrayInputStream.read(byteArray);
055            }
056    
057            public int read(byte[] byteArray, int offset, int length) {
058                    return _byteArrayInputStream.read(byteArray, offset, length);
059            }
060    
061            public int readLine(byte[] byteArray, int offset, int length) {
062                    return _byteArrayInputStream.read(byteArray, offset, length);
063            }
064    
065            public void reset() {
066                    _byteArrayInputStream.reset();
067            }
068    
069            public long skip(long skip) {
070                    return _byteArrayInputStream.skip(skip);
071            }
072    
073            private ByteArrayInputStream _byteArrayInputStream;
074    
075    }