Debian Codegraph @

src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.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.PrintStream;
23 import java.util.Locale;
24
25 public class ThreadPrintStream extends PrintStream
26 {
27 final PrintStream dflt;
28 final ThreadIOImpl io;
29 final boolean errorStream;
30
31 public ThreadPrintStream(ThreadIOImpl threadIO, PrintStream out, boolean error)
32 {
33 super(out);
34 dflt = out;
35 io = threadIO;
36 errorStream = error;
37 }
38
39 public PrintStream getCurrent()
40 {
41 Marker marker = io.current();
42 return errorStream ? marker.getErr() : marker.getOut();
43 }
44
45 /**
46 * Access to the root stream through reflection
47 *
48 * @return
49 */
50 public PrintStream getRoot()
51 {
52 return dflt;
53 }
54
55 //
56 // Delegate methods
57 //
58
59 public void flush()
60 {
61 getCurrent().flush();
62 }
63
64 public void close()
65 {
66 getCurrent().close();
67 }
68
69 public boolean checkError()
70 {
71 return getCurrent().checkError();
72 }
73
74 public void setError()
75 {
76 // getCurrent().setError();
77 }
78
79 public void clearError()
80 {
81 // getCurrent().clearError();
82 }
83
84 public void write(int b)
85 {
86 getCurrent().write(b);
87 }
88
89 public void write(byte[] buf, int off, int len)
90 {
91 getCurrent().write(buf, off, len);
92 }
93
94 public void print(boolean b)
95 {
96 getCurrent().print(b);
97 }
98
99 public void print(char c)
100 {
101 getCurrent().print(c);
102 }
103
104 public void print(int i)
105 {
106 getCurrent().print(i);
107 }
108
109 public void print(long l)
110 {
111 getCurrent().print(l);
112 }
113
114 public void print(float f)
115 {
116 getCurrent().print(f);
117 }
118
119 public void print(double d)
120 {
121 getCurrent().print(d);
122 }
123
124 public void print(char[] s)
125 {
126 getCurrent().print(s);
127 }
128
129 public void print(String s)
130 {
131 getCurrent().print(s);
132 }
133
134 public void print(Object obj)
135 {
136 getCurrent().print(obj);
137 }
138
139 public void println()
140 {
141 getCurrent().println();
142 }
143
144 public void println(boolean x)
145 {
146 getCurrent().println(x);
147 }
148
149 public void println(char x)
150 {
151 getCurrent().println(x);
152 }
153
154 public void println(int x)
155 {
156 getCurrent().println(x);
157 }
158
159 public void println(long x)
160 {
161 getCurrent().println(x);
162 }
163
164 public void println(float x)
165 {
166 getCurrent().println(x);
167 }
168
169 public void println(double x)
170 {
171 getCurrent().println(x);
172 }
173
174 public void println(char[] x)
175 {
176 getCurrent().println(x);
177 }
178
179 public void println(String x)
180 {
181 getCurrent().println(x);
182 }
183
184 public void println(Object x)
185 {
186 getCurrent().println(x);
187 }
188
189 public PrintStream printf(String format, Object... args)
190 {
191 return getCurrent().printf(format, args);
192 }
193
194 public PrintStream printf(Locale l, String format, Object... args)
195 {
196 return getCurrent().printf(l, format, args);
197 }
198
199 public PrintStream format(String format, Object... args)
200 {
201 return getCurrent().format(format, args);
202 }
203
204 public PrintStream format(Locale l, String format, Object... args)
205 {
206 return getCurrent().format(l, format, args);
207 }
208
209 public PrintStream append(CharSequence csq)
210 {
211 return getCurrent().append(csq);
212 }
213
214 public PrintStream append(CharSequence csq, int start, int end)
215 {
216 return getCurrent().append(csq, start, end);
217 }
218
219 public PrintStream append(char c)
220 {
221 return getCurrent().append(c);
222 }
223
224 public void write(byte[] b) throws IOException
225 {
226 getCurrent().write(b);
227 }
228 }