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
29
30
31
32 class SwitchableWriter extends Writer
33 {
34
35 Writer _delegate = null;
36 ResponseSwitch _responseSwitch = null;
37
38 public SwitchableWriter(Writer delegate, ResponseSwitch responseSwitch)
39 {
40 _delegate = delegate;
41 _responseSwitch = responseSwitch;
42 }
43
44 public void write(String s, int start, int end) throws IOException
45 {
46 if (_responseSwitch.isEnabled())
47 {
48 _delegate.write(s, start, end);
49 }
50 }
51
52 public void write(String s) throws IOException
53 {
54 if (_responseSwitch.isEnabled())
55 {
56 _delegate.write(s);
57 }
58 }
59
60 public void write(char[] c, int start, int end) throws IOException
61 {
62 if (_responseSwitch.isEnabled())
63 {
64 _delegate.write(c, start, end);
65 }
66 }
67
68 public void write(char[] c) throws IOException
69 {
70 if (_responseSwitch.isEnabled())
71 {
72 _delegate.write(c);
73
74 }
75 }
76
77 public void write(int i) throws IOException
78 {
79 if (_responseSwitch.isEnabled())
80 {
81 _delegate.write(i);
82 }
83 }
84
85 public void flush() throws IOException
86 {
87 if (_responseSwitch.isEnabled())
88 {
89 _delegate.flush();
90 }
91 }
92
93 public void close() throws IOException
94 {
95 if (_responseSwitch.isEnabled())
96 {
97 _delegate.close();
98 }
99 }
100
101 public Writer append(char c) throws IOException
102 {
103 if (_responseSwitch.isEnabled())
104 {
105 return _delegate.append(c);
106 }
107 return this;
108 }
109
110 public Writer append(CharSequence csq, int start, int end)
111 throws IOException
112 {
113 if (_responseSwitch.isEnabled())
114 {
115 return _delegate.append(csq, start, end);
116 }
117 return this;
118 }
119
120 public Writer append(CharSequence csq) throws IOException
121 {
122 if (_responseSwitch.isEnabled())
123 {
124 return _delegate.append(csq);
125 }
126 return this;
127 }
128 }