org.apache.tapestry.engine
Class NullWriter

java.lang.Object
  extended by org.apache.tapestry.engine.NullWriter
All Implemented Interfaces:
IMarkupWriter, NestedMarkupWriter

public class NullWriter
extends Object
implements NestedMarkupWriter

A IMarkupWriterthat does absolutely nothing; this is used during the rewind phase of the request cycle when output is discarded anyway.

Since:
0.2.9
Author:
Howard Lewis Ship, David Solis

Constructor Summary
NullWriter()
           
 
Method Summary
 void appendAttribute(String name, boolean value)
          Appends a boolean attribute into the currently open tag.
 void appendAttribute(String name, int value)
          Appends an integer attribute to the current attribute with a matching name key, if one exists.
 void appendAttribute(String name, String value)
          Appends an attribute into the most recently opened tag.
 void appendAttributeRaw(String name, String value)
          Similar to IMarkupWriter.attribute(String, String) but no escaping of invalid elements is done for the value.
 void attribute(String value)
           
 void attribute(String name, boolean value)
          Writes a boolean attribute into the currently open tag.
 void attribute(String name, int value)
          Writes an integer attribute into the currently open tag.
 void attribute(String name, String value)
          Writes an attribute into the most recently opened tag.
 void attributeRaw(String name, String value)
          Similar to IMarkupWriter.attribute(String, String)but no escaping of invalid elements is done for the value.
 void begin(String name)
          Closes any existing tag then starts a new element.
 void beginEmpty(String name)
          Starts an element that will not later be matched with an end() call.
 boolean checkError()
          Always returns false.
 void clearAttributes()
          Removes all current attributes on the open tag, if any.
 void close()
          Closes this IMarkupWriter.
 void closeTag()
          Closes the most recently opened element by writing the '>' that ends it.
 void comment(String value)
          Writes an XML/HTML comment.
 void end()
          Ends the element most recently started by IMarkupWriter.begin(String).
 void end(String name)
          Ends the most recently started element with the given name.
 void flush()
          Forwards flush() to this IMarkupWriter's PrintWriter.
 Attribute getAttribute(String name)
          Gets the attribute matching name from the current open tag, if it exists.
 String getBuffer()
          Returns any makrup so far accumulated by the nested markup writer.
 String getContentType()
          Returns the type of content generated by this response writer, as a MIME type.
 NestedMarkupWriter getNestedWriter()
          Returns this: since a NullWriter doesn't actually do anything, one is as good as another!.
static IMarkupWriter getSharedInstance()
           
 boolean hasAttribute(String name)
          Checks if the current tag has an attribute keyed off of name.
 void print(char value)
          Prints a single character, or its equivalent entity.
 void print(char[] data, int offset, int length)
          Version of IMarkupWriter.print(char[], int, int, boolean) that assumes filter is enabled.
 void print(char[] data, int offset, int length, boolean raw)
          The primary print() method, used by most other methods.
 void print(int value)
          Prints an integer.
 void print(String value)
          As with IMarkupWriter.print(char[], int, int, boolean), but the data to print is defined by the String.
 void print(String value, boolean raw)
          As with IMarkupWriter.print(char[], int, int, boolean), but the data to print is defined by the String.
 void println()
          Closes the open tag (if any), then prints a line seperator to the output stream.
 void printRaw(char[] buffer, int offset, int length)
          Version of IMarkupWriter.print(char[], int, int, boolean)that assumes filter is enabled.
 void printRaw(String value)
          As with IMarkupWriter.print(char[], int, int, boolean), but the data to print is defined by the String.
 Attribute removeAttribute(String name)
          Removes the attribute specified with a matching name if one exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NullWriter

public NullWriter()
Method Detail

getSharedInstance

public static IMarkupWriter getSharedInstance()

getBuffer

public String getBuffer()
Description copied from interface: NestedMarkupWriter
Returns any makrup so far accumulated by the nested markup writer. When the nested markup writer is closed, it invokes IMarkupWriter.printRaw(String), with this content, on its parent markup writer.

Getting the buffer will close the writer.

Specified by:
getBuffer in interface NestedMarkupWriter

printRaw

public void printRaw(char[] buffer,
                     int offset,
                     int length)
Description copied from interface: IMarkupWriter
Version of IMarkupWriter.print(char[], int, int, boolean)that assumes filter is enabled.

Specified by:
printRaw in interface IMarkupWriter

printRaw

public void printRaw(String value)
Description copied from interface: IMarkupWriter
As with IMarkupWriter.print(char[], int, int, boolean), but the data to print is defined by the String. Assumes filtering is disabled.

Specified by:
printRaw in interface IMarkupWriter

println

public void println()
Description copied from interface: IMarkupWriter
Closes the open tag (if any), then prints a line seperator to the output stream.

Specified by:
println in interface IMarkupWriter

print

public void print(char[] data,
                  int offset,
                  int length)
Description copied from interface: IMarkupWriter
Version of IMarkupWriter.print(char[], int, int, boolean) that assumes filter is enabled.

Specified by:
print in interface IMarkupWriter

print

public void print(char value)
Description copied from interface: IMarkupWriter
Prints a single character, or its equivalent entity.

Closes any open tag.

Specified by:
print in interface IMarkupWriter

print

public void print(int value)
Description copied from interface: IMarkupWriter
Prints an integer.

Closes any open tag.

Specified by:
print in interface IMarkupWriter

print

public void print(String value)
Description copied from interface: IMarkupWriter
As with IMarkupWriter.print(char[], int, int, boolean), but the data to print is defined by the String. Assumes filtering is enabled.

Specified by:
print in interface IMarkupWriter

getNestedWriter

public NestedMarkupWriter getNestedWriter()
Returns this: since a NullWriter doesn't actually do anything, one is as good as another!.

Specified by:
getNestedWriter in interface IMarkupWriter

getContentType

public String getContentType()
Description copied from interface: IMarkupWriter
Returns the type of content generated by this response writer, as a MIME type.

Specified by:
getContentType in interface IMarkupWriter

flush

public void flush()
Description copied from interface: IMarkupWriter
Forwards flush() to this IMarkupWriter's PrintWriter.

Specified by:
flush in interface IMarkupWriter

end

public void end()
Description copied from interface: IMarkupWriter
Ends the element most recently started by IMarkupWriter.begin(String). The name of the tag is popped off of the active element stack and used to form an HTML close tag.

Specified by:
end in interface IMarkupWriter

end

public void end(String name)
Description copied from interface: IMarkupWriter
Ends the most recently started element with the given name. This will also end any other intermediate elements. This is very useful for easily ending a table or even an entire page.

Specified by:
end in interface IMarkupWriter

comment

public void comment(String value)
Description copied from interface: IMarkupWriter
Writes an XML/HTML comment. Any open tag is first closed. The method takes care of providing the <!-- and -->, and provides a blank line after the close of the comment.

Most characters are valid inside a comment, so no check of the contents is made (much like IMarkupWriter.printRaw(String).

Specified by:
comment in interface IMarkupWriter

closeTag

public void closeTag()
Description copied from interface: IMarkupWriter
Closes the most recently opened element by writing the '>' that ends it. Once this is invoked, the attribute() methods may not be used until a new element is opened with IMarkupWriter.begin(String)or or IMarkupWriter.beginEmpty(String).

Specified by:
closeTag in interface IMarkupWriter

close

public void close()
Description copied from interface: IMarkupWriter
Closes this IMarkupWriter. Close tags are written for any active elements. The PrintWriter is then sent close(). A nested writer will commit its buffer to its containing writer.

Specified by:
close in interface IMarkupWriter

checkError

public boolean checkError()
Always returns false.

Specified by:
checkError in interface IMarkupWriter

beginEmpty

public void beginEmpty(String name)
Description copied from interface: IMarkupWriter
Starts an element that will not later be matched with an end() call. This is useful for elements that do not need closing tags.

Specified by:
beginEmpty in interface IMarkupWriter

begin

public void begin(String name)
Description copied from interface: IMarkupWriter
Closes any existing tag then starts a new element. The new element is pushed onto the active element stack.

Specified by:
begin in interface IMarkupWriter

attribute

public void attribute(String name,
                      int value)
Description copied from interface: IMarkupWriter
Writes an integer attribute into the currently open tag.

Specified by:
attribute in interface IMarkupWriter

attribute

public void attribute(String name,
                      String value)
Description copied from interface: IMarkupWriter
Writes an attribute into the most recently opened tag. This must be called after IMarkupWriter.begin(String)and before any other kind of writing (which closes the tag).

The value may be null.

Specified by:
attribute in interface IMarkupWriter

attribute

public void attribute(String name,
                      boolean value)
Description copied from interface: IMarkupWriter
Writes a boolean attribute into the currently open tag.

Specified by:
attribute in interface IMarkupWriter

attributeRaw

public void attributeRaw(String name,
                         String value)
Description copied from interface: IMarkupWriter
Similar to IMarkupWriter.attribute(String, String)but no escaping of invalid elements is done for the value.

Specified by:
attributeRaw in interface IMarkupWriter

attribute

public void attribute(String value)

appendAttribute

public void appendAttribute(String name,
                            boolean value)
Description copied from interface: IMarkupWriter
Appends a boolean attribute into the currently open tag.

Specified by:
appendAttribute in interface IMarkupWriter

appendAttribute

public void appendAttribute(String name,
                            int value)
Description copied from interface: IMarkupWriter
Appends an integer attribute to the current attribute with a matching name key, if one exists.

Specified by:
appendAttribute in interface IMarkupWriter

appendAttribute

public void appendAttribute(String name,
                            String value)
Description copied from interface: IMarkupWriter
Appends an attribute into the most recently opened tag. This must be called after IMarkupWriter.begin(String) and before any other kind of writing (which closes the tag).

The value may be null.

Specified by:
appendAttribute in interface IMarkupWriter

appendAttributeRaw

public void appendAttributeRaw(String name,
                               String value)
Description copied from interface: IMarkupWriter
Similar to IMarkupWriter.attribute(String, String) but no escaping of invalid elements is done for the value.

Specified by:
appendAttributeRaw in interface IMarkupWriter

getAttribute

public Attribute getAttribute(String name)
Description copied from interface: IMarkupWriter
Gets the attribute matching name from the current open tag, if it exists.

Specified by:
getAttribute in interface IMarkupWriter
Parameters:
name - The attribute to get the value of by name.
Returns:
The attribute value, or null if it doesn't exist.

hasAttribute

public boolean hasAttribute(String name)
Description copied from interface: IMarkupWriter
Checks if the current tag has an attribute keyed off of name.

Specified by:
hasAttribute in interface IMarkupWriter
Parameters:
name - The name of the attribute to check for existance of.
Returns:
True if the attribute exists, false otherwise.

removeAttribute

public Attribute removeAttribute(String name)
Description copied from interface: IMarkupWriter
Removes the attribute specified with a matching name if one exists.

Specified by:
removeAttribute in interface IMarkupWriter
Parameters:
name - The attribute to remove.
Returns:
The removed attribute, null if one didn't exist.

clearAttributes

public void clearAttributes()
Description copied from interface: IMarkupWriter
Removes all current attributes on the open tag, if any.

Specified by:
clearAttributes in interface IMarkupWriter

print

public void print(char[] data,
                  int offset,
                  int length,
                  boolean raw)
Description copied from interface: IMarkupWriter
The primary print() method, used by most other methods.

Prints the character array, first closing any open tag. Problematic characters ('<', '>' and '&') are converted to appropriate entities.

Does nothing if data is null.

Closes any open tag.

Specified by:
print in interface IMarkupWriter
Parameters:
data - contains the characters to print, or null to not print anything
offset - offset into the array to start printing from
length - number of characters to print
raw - if true, filtering is disabled

print

public void print(String value,
                  boolean raw)
Description copied from interface: IMarkupWriter
As with IMarkupWriter.print(char[], int, int, boolean), but the data to print is defined by the String.

Specified by:
print in interface IMarkupWriter


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.