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