1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.shared.view; |
20 | |
|
21 | |
import java.io.IOException; |
22 | |
import java.io.Writer; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | 0 | class SwitchableWriter extends Writer |
29 | |
{ |
30 | |
|
31 | 0 | Writer _delegate = null; |
32 | 0 | ResponseSwitch _responseSwitch = null; |
33 | |
|
34 | |
public SwitchableWriter(Writer delegate, ResponseSwitch responseSwitch) |
35 | 0 | { |
36 | 0 | _delegate = delegate; |
37 | 0 | _responseSwitch = responseSwitch; |
38 | 0 | } |
39 | |
|
40 | |
public void write(String s, int start, int end) throws IOException |
41 | |
{ |
42 | 0 | if (_responseSwitch.isEnabled()) |
43 | |
{ |
44 | 0 | _delegate.write(s, start, end); |
45 | |
} |
46 | 0 | } |
47 | |
|
48 | |
public void write(String s) throws IOException |
49 | |
{ |
50 | 0 | if (_responseSwitch.isEnabled()) |
51 | |
{ |
52 | 0 | _delegate.write(s); |
53 | |
} |
54 | 0 | } |
55 | |
|
56 | |
public void write(char[] c, int start, int end) throws IOException |
57 | |
{ |
58 | 0 | if (_responseSwitch.isEnabled()) |
59 | |
{ |
60 | 0 | _delegate.write(c, start, end); |
61 | |
} |
62 | 0 | } |
63 | |
|
64 | |
public void write(char[] c) throws IOException |
65 | |
{ |
66 | 0 | if (_responseSwitch.isEnabled()) |
67 | |
{ |
68 | 0 | _delegate.write(c); |
69 | |
|
70 | |
} |
71 | 0 | } |
72 | |
|
73 | |
public void write(int i) throws IOException |
74 | |
{ |
75 | 0 | if (_responseSwitch.isEnabled()) |
76 | |
{ |
77 | 0 | _delegate.write(i); |
78 | |
} |
79 | 0 | } |
80 | |
|
81 | |
public void flush() throws IOException |
82 | |
{ |
83 | 0 | if (_responseSwitch.isEnabled()) |
84 | |
{ |
85 | 0 | _delegate.flush(); |
86 | |
} |
87 | 0 | } |
88 | |
|
89 | |
public void close() throws IOException |
90 | |
{ |
91 | 0 | if (_responseSwitch.isEnabled()) |
92 | |
{ |
93 | 0 | _delegate.close(); |
94 | |
} |
95 | 0 | } |
96 | |
|
97 | |
public Writer append(char c) throws IOException |
98 | |
{ |
99 | 0 | if (_responseSwitch.isEnabled()) |
100 | |
{ |
101 | 0 | return _delegate.append(c); |
102 | |
} |
103 | 0 | return this; |
104 | |
} |
105 | |
|
106 | |
public Writer append(CharSequence csq, int start, int end) |
107 | |
throws IOException |
108 | |
{ |
109 | 0 | if (_responseSwitch.isEnabled()) |
110 | |
{ |
111 | 0 | return _delegate.append(csq, start, end); |
112 | |
} |
113 | 0 | return this; |
114 | |
} |
115 | |
|
116 | |
public Writer append(CharSequence csq) throws IOException |
117 | |
{ |
118 | 0 | if (_responseSwitch.isEnabled()) |
119 | |
{ |
120 | 0 | return _delegate.append(csq); |
121 | |
} |
122 | 0 | return this; |
123 | |
} |
124 | |
} |