01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.attachment;
19:
20: import java.io.IOException;
21: import java.io.InputStream;
22:
23: final class DelegatingInputStream extends InputStream {
24: private InputStream is;
25: private boolean isClosed;
26:
27: /**
28: * @param source
29: */
30: DelegatingInputStream(InputStream is) {
31: this .is = is;
32: }
33:
34: @Override
35: public void close() throws IOException {
36: is.close();
37: isClosed = true;
38: }
39:
40: public boolean isClosed() {
41: return isClosed;
42: }
43:
44: public void setClosed(boolean closed) {
45: this .isClosed = closed;
46: }
47:
48: public int read() throws IOException {
49: return this .is.read();
50: }
51:
52: @Override
53: public int available() throws IOException {
54: return this .is.available();
55: }
56:
57: @Override
58: public synchronized void mark(int arg0) {
59: this .is.mark(arg0);
60: }
61:
62: @Override
63: public boolean markSupported() {
64: return this .is.markSupported();
65: }
66:
67: @Override
68: public int read(byte[] bytes, int arg1, int arg2)
69: throws IOException {
70: return this .is.read(bytes, arg1, arg2);
71: }
72:
73: @Override
74: public int read(byte[] bytes) throws IOException {
75: return this .is.read(bytes);
76: }
77:
78: @Override
79: public synchronized void reset() throws IOException {
80: this .is.reset();
81: }
82:
83: @Override
84: public long skip(long n) throws IOException {
85: return this .is.skip(n);
86: }
87:
88: public void setInputStream(InputStream inputStream) {
89: this .is = inputStream;
90: }
91:
92: public InputStream getInputStream() {
93: return is;
94: }
95: }
|