Debian Codegraph @

src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadInputStream.java

raw
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
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 */
19 package org.apache.felix.gogo.runtime.threadio;
20
21 import java.io.IOException;
22 import java.io.InputStream;
23
24 public class ThreadInputStream extends InputStream
25 {
26 final InputStream dflt;
27 final ThreadIOImpl io;
28
29 public ThreadInputStream(ThreadIOImpl threadIO, InputStream in)
30 {
31 io = threadIO;
32 dflt = in;
33 }
34
35 private InputStream getCurrent()
36 {
37 Marker marker = io.current();
38 return marker.getIn();
39 }
40
41 /**
42 * Access to the root stream through reflection
43 *
44 * @return
45 */
46 public InputStream getRoot()
47 {
48 return dflt;
49 }
50
51 //
52 // Delegate methods
53 //
54
55 public int read() throws IOException
56 {
57 return getCurrent().read();
58 }
59
60 public int read(byte[] b) throws IOException
61 {
62 return getCurrent().read(b);
63 }
64
65 public int read(byte[] b, int off, int len) throws IOException
66 {
67 return getCurrent().read(b, off, len);
68 }
69
70 public long skip(long n) throws IOException
71 {
72 return getCurrent().skip(n);
73 }
74
75 public int available() throws IOException
76 {
77 return getCurrent().available();
78 }
79
80 public void close() throws IOException
81 {
82 getCurrent().close();
83 }
84
85 public void mark(int readlimit)
86 {
87 getCurrent().mark(readlimit);
88 }
89
90 public void reset() throws IOException
91 {
92 getCurrent().reset();
93 }
94
95 public boolean markSupported()
96 {
97 return getCurrent().markSupported();
98 }
99 }