001: /*
002: * $Id: $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts2.portlet.servlet;
022:
023: import java.io.IOException;
024: import java.io.InputStream;
025:
026: import javax.servlet.ServletInputStream;
027:
028: /**
029: * Wrapper object exposing a {@link InputStream} from a portlet as a {@link ServletInputStream} instance.
030: * Clients accessing this stream object will in fact operate on the
031: * {@link InputStream} object wrapped by this stream object.
032: */
033: public class PortletServletInputStream extends ServletInputStream {
034:
035: private InputStream portletInputStream;
036:
037: public PortletServletInputStream(InputStream portletInputStream) {
038: this .portletInputStream = portletInputStream;
039: }
040:
041: /* (non-Javadoc)
042: * @see java.io.InputStream#read()
043: */
044: @Override
045: public int read() throws IOException {
046: return portletInputStream.read();
047: }
048:
049: /* (non-Javadoc)
050: * @see java.io.InputStream#available()
051: */
052: @Override
053: public int available() throws IOException {
054: return portletInputStream.available();
055: }
056:
057: /* (non-Javadoc)
058: * @see java.io.InputStream#close()
059: */
060: @Override
061: public void close() throws IOException {
062: portletInputStream.close();
063: }
064:
065: /* (non-Javadoc)
066: * @see java.io.InputStream#mark(int)
067: */
068: @Override
069: public synchronized void mark(int readlimit) {
070: portletInputStream.mark(readlimit);
071: }
072:
073: /* (non-Javadoc)
074: * @see java.io.InputStream#markSupported()
075: */
076: @Override
077: public boolean markSupported() {
078: return portletInputStream.markSupported();
079: }
080:
081: /* (non-Javadoc)
082: * @see java.io.InputStream#read(byte[], int, int)
083: */
084: @Override
085: public int read(byte[] b, int off, int len) throws IOException {
086: return portletInputStream.read(b, off, len);
087: }
088:
089: /* (non-Javadoc)
090: * @see java.io.InputStream#read(byte[])
091: */
092: @Override
093: public int read(byte[] b) throws IOException {
094: return portletInputStream.read(b);
095: }
096:
097: /* (non-Javadoc)
098: * @see java.io.InputStream#reset()
099: */
100: @Override
101: public synchronized void reset() throws IOException {
102: portletInputStream.reset();
103: }
104:
105: /* (non-Javadoc)
106: * @see java.io.InputStream#skip(long)
107: */
108: @Override
109: public long skip(long n) throws IOException {
110: return portletInputStream.skip(n);
111: }
112:
113: /**
114: * Get the wrapped {@link InputStream} instance.
115: * @return The wrapped {@link InputStream} instance.
116: */
117: public InputStream getInputStream() {
118: return portletInputStream;
119: }
120:
121: }
|