KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > engine > NullWriter


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.engine;
16
17 import org.apache.tapestry.IMarkupWriter;
18 import org.apache.tapestry.NestedMarkupWriter;
19
20 /**
21  * A {@link IMarkupWriter}that does absolutely <em>nothing</em>; this is used during the rewind
22  * phase of the request cycle when output is discarded anyway.
23  *
24  * @author Howard Lewis Ship, David Solis
25  * @since 0.2.9
26  */

27
28 public class NullWriter implements NestedMarkupWriter
29 {
30     private static IMarkupWriter shared;
31
32     public static IMarkupWriter getSharedInstance()
33     {
34         if (shared == null)
35             shared = new NullWriter();
36
37         return shared;
38     }
39
40     public String JavaDoc getBuffer()
41     {
42         return null;
43     }
44
45     public void printRaw(char[] buffer, int offset, int length)
46     {
47     }
48
49     public void printRaw(String JavaDoc value)
50     {
51     }
52
53     public void println()
54     {
55     }
56
57     public void print(char[] data, int offset, int length)
58     {
59     }
60
61     public void print(char value)
62     {
63     }
64
65     public void print(int value)
66     {
67     }
68
69     public void print(String JavaDoc value)
70     {
71     }
72
73     /**
74      * Returns <code>this</code>: since a NullWriter doesn't actually do anything, one is as good
75      * as another!.
76      */

77
78     public NestedMarkupWriter getNestedWriter()
79     {
80         return this;
81     }
82
83     public String JavaDoc getContentType()
84     {
85         return null;
86     }
87
88     public void flush()
89     {
90     }
91
92     public void end()
93     {
94     }
95
96     public void end(String JavaDoc name)
97     {
98     }
99
100     public void comment(String JavaDoc value)
101     {
102     }
103
104     public void closeTag()
105     {
106     }
107
108     public void close()
109     {
110     }
111
112     /**
113      * Always returns false.
114      */

115
116     public boolean checkError()
117     {
118         return false;
119     }
120
121     public void beginEmpty(String JavaDoc name)
122     {
123     }
124
125     public void begin(String JavaDoc name)
126     {
127     }
128
129     public void attribute(String JavaDoc name, int value)
130     {
131     }
132
133     public void attribute(String JavaDoc name, String JavaDoc value)
134     {
135     }
136
137     /**
138      * @see org.apache.tapestry.IMarkupWriter#attribute(java.lang.String, boolean)
139      * @since 3.0
140      */

141
142     public void attribute(String JavaDoc name, boolean value)
143     {
144     }
145
146     /**
147      * @see org.apache.tapestry.IMarkupWriter#attributeRaw(java.lang.String, java.lang.String)
148      * @since 3.0
149      */

150
151     public void attributeRaw(String JavaDoc name, String JavaDoc value)
152     {
153     }
154
155     public void print(char[] data, int offset, int length, boolean raw)
156     {
157     }
158
159     public void print(String JavaDoc value, boolean raw)
160     {
161     }
162 }
Popular Tags