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
020 /**
021 * A {@link IMarkupWriter}that does absolutely <em>nothing</em>; this is used during the rewind
022 * phase of the request cycle when output is discarded anyway.
023 *
024 * @author Howard Lewis Ship, David Solis
025 * @since 0.2.9
026 */
027
028 public class NullWriter implements NestedMarkupWriter
029 {
030 private static IMarkupWriter shared;
031
032 public static IMarkupWriter getSharedInstance()
033 {
034 if (shared == null)
035 shared = new NullWriter();
036
037 return shared;
038 }
039
040 public String getBuffer()
041 {
042 return null;
043 }
044
045 public void printRaw(char[] buffer, int offset, int length)
046 {
047 }
048
049 public void printRaw(String value)
050 {
051 }
052
053 public void println()
054 {
055 }
056
057 public void print(char[] data, int offset, int length)
058 {
059 }
060
061 public void print(char value)
062 {
063 }
064
065 public void print(int value)
066 {
067 }
068
069 public void print(String value)
070 {
071 }
072
073 /**
074 * Returns <code>this</code>: since a NullWriter doesn't actually do anything, one is as good
075 * as another!.
076 */
077
078 public NestedMarkupWriter getNestedWriter()
079 {
080 return this;
081 }
082
083 public String getContentType()
084 {
085 return null;
086 }
087
088 public void flush()
089 {
090 }
091
092 public void end()
093 {
094 }
095
096 public void end(String name)
097 {
098 }
099
100 public void comment(String 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 name)
122 {
123 }
124
125 public void begin(String name)
126 {
127 }
128
129 public void attribute(String name, int value)
130 {
131 }
132
133 public void attribute(String name, String 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 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 name, String value)
152 {
153 }
154
155 public void print(char[] data, int offset, int length, boolean raw)
156 {
157 }
158
159 public void print(String value, boolean raw)
160 {
161 }
162 }