001 // Copyright 2004, 2005 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry.engine;
016
017 import org.apache.tapestry.IMarkupWriter;
018 import org.apache.tapestry.NestedMarkupWriter;
019 import org.apache.tapestry.markup.Attribute;
020
021 /**
022 * A {@link IMarkupWriter}that does absolutely <em>nothing</em>; this is used during the rewind
023 * phase of the request cycle when output is discarded anyway.
024 *
025 * @author Howard Lewis Ship, David Solis
026 * @since 0.2.9
027 */
028
029 public class NullWriter implements NestedMarkupWriter
030 {
031 private static IMarkupWriter shared;
032
033 public static IMarkupWriter getSharedInstance()
034 {
035 if (shared == null)
036 shared = new NullWriter();
037
038 return shared;
039 }
040
041 public String getBuffer()
042 {
043 return null;
044 }
045
046 public void printRaw(char[] buffer, int offset, int length)
047 {
048 }
049
050 public void printRaw(String value)
051 {
052 }
053
054 public void println()
055 {
056 }
057
058 public void print(char[] data, int offset, int length)
059 {
060 }
061
062 public void print(char value)
063 {
064 }
065
066 public void print(int value)
067 {
068 }
069
070 public void print(String value)
071 {
072 }
073
074 /**
075 * Returns <code>this</code>: since a NullWriter doesn't actually do anything, one is as good
076 * as another!.
077 */
078
079 public NestedMarkupWriter getNestedWriter()
080 {
081 return this;
082 }
083
084 public String getContentType()
085 {
086 return null;
087 }
088
089 public void flush()
090 {
091 }
092
093 public void end()
094 {
095 }
096
097 public void end(String name)
098 {
099 }
100
101 public void comment(String value)
102 {
103 }
104
105 public void closeTag()
106 {
107 }
108
109 public void close()
110 {
111 }
112
113 /**
114 * Always returns false.
115 */
116
117 public boolean checkError()
118 {
119 return false;
120 }
121
122 public void beginEmpty(String name)
123 {
124 }
125
126 public void begin(String name)
127 {
128 }
129
130 public void attribute(String name, int value)
131 {
132 }
133
134 public void attribute(String name, String value)
135 {
136 }
137
138 public void attribute(String name, boolean value)
139 {
140 }
141
142 public void attributeRaw(String name, String value)
143 {
144 }
145
146 public void attribute(String value)
147 {
148 }
149
150 public void appendAttribute(String name, boolean value)
151 {
152 }
153
154 public void appendAttribute(String name, int value)
155 {
156 }
157
158 public void appendAttribute(String name, String value)
159 {
160 }
161
162 public void appendAttributeRaw(String name, String value)
163 {
164 }
165
166 public Attribute getAttribute(String name)
167 {
168 return null;
169 }
170
171 public boolean hasAttribute(String name)
172 {
173 return false;
174 }
175
176 public Attribute removeAttribute(String name)
177 {
178 return null;
179 }
180
181 public void clearAttributes()
182 {
183 }
184
185 public void print(char[] data, int offset, int length, boolean raw)
186 {
187 }
188
189 public void print(String value, boolean raw)
190 {
191 }
192 }