|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.tapestry.markup.MarkupWriterImpl
public class MarkupWriterImpl
Completely revised (for 4.0) implementation of IMarkupWriter
. No
longer does internal buffering (since the servlet/portlet APIs support that natively) and wraps
around a PrintWriter
(rather than an OutputStream
).
Constructor Summary | |
---|---|
MarkupWriterImpl(String contentType,
PrintWriter writer,
MarkupFilter filter)
|
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 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 |
attribute(String name,
String value,
boolean raw)
|
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()
Invokes checkError() on the PrintWriter used to format output. |
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 |
getContentType()
Returns the type of content generated by this response writer, as a MIME type. |
NestedMarkupWriter |
getNestedWriter()
Returns a nested writer, one that accumulates its changes in a buffer. |
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[] buffer,
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 |
---|
public MarkupWriterImpl(String contentType, PrintWriter writer, MarkupFilter filter)
Method Detail |
---|
public void attribute(String name, int value)
IMarkupWriter
attribute
in interface IMarkupWriter
public void attribute(String name, boolean value)
IMarkupWriter
attribute
in interface IMarkupWriter
public void attribute(String name, String value)
IMarkupWriter
IMarkupWriter.begin(String)
and before any other kind of writing (which closes the tag).
The value may be null.
attribute
in interface IMarkupWriter
public void attribute(String name, String value, boolean raw)
public void appendAttribute(String name, boolean value)
IMarkupWriter
appendAttribute
in interface IMarkupWriter
public void appendAttribute(String name, int value)
IMarkupWriter
name
key, if one exists.
appendAttribute
in interface IMarkupWriter
public void appendAttribute(String name, String value)
IMarkupWriter
IMarkupWriter.begin(String)
and before any other kind of writing (which closes the tag).
The value may be null.
appendAttribute
in interface IMarkupWriter
public void appendAttributeRaw(String name, String value)
IMarkupWriter
IMarkupWriter.attribute(String, String)
but no escaping of invalid elements is done for
the value.
appendAttributeRaw
in interface IMarkupWriter
public Attribute getAttribute(String name)
IMarkupWriter
name
from the current open
tag, if it exists.
getAttribute
in interface IMarkupWriter
name
- The attribute to get the value of by name.
public boolean hasAttribute(String name)
IMarkupWriter
name
.
hasAttribute
in interface IMarkupWriter
name
- The name of the attribute to check for existance of.
public void clearAttributes()
IMarkupWriter
clearAttributes
in interface IMarkupWriter
public Attribute removeAttribute(String name)
IMarkupWriter
name
if
one exists.
removeAttribute
in interface IMarkupWriter
name
- The attribute to remove.
public void attributeRaw(String name, String value)
IMarkupWriter
IMarkupWriter.attribute(String, String)
but no escaping of invalid elements is done for
the value.
attributeRaw
in interface IMarkupWriter
public void begin(String name)
IMarkupWriter
begin
in interface IMarkupWriter
public void beginEmpty(String name)
IMarkupWriter
end()
call. This is
useful for elements that do not need closing tags.
beginEmpty
in interface IMarkupWriter
public boolean checkError()
IMarkupWriter
PrintWriter
used to format output.
checkError
in interface IMarkupWriter
public void close()
IMarkupWriter
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.
close
in interface IMarkupWriter
public void closeTag()
IMarkupWriter
attribute()
methods may not be used until a new element is opened
with IMarkupWriter.begin(String)
or or IMarkupWriter.beginEmpty(String)
.
closeTag
in interface IMarkupWriter
public void comment(String value)
IMarkupWriter
<!--
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)
.
comment
in interface IMarkupWriter
public void end()
IMarkupWriter
IMarkupWriter.begin(String)
. The name of the tag is
popped off of the active element stack and used to form an HTML close tag.
end
in interface IMarkupWriter
public void end(String name)
IMarkupWriter
end
in interface IMarkupWriter
public void flush()
IMarkupWriter
flush()
to this IMarkupWriter
's
PrintWriter
.
flush
in interface IMarkupWriter
public NestedMarkupWriter getNestedWriter()
IMarkupWriter
IMarkupWriter
using IMarkupWriter.printRaw(String)
.
getNestedWriter
in interface IMarkupWriter
public void print(char[] data, int offset, int length)
IMarkupWriter
IMarkupWriter.print(char[], int, int, boolean)
that assumes filter is
enabled.
print
in interface IMarkupWriter
public void printRaw(char[] buffer, int offset, int length)
IMarkupWriter
IMarkupWriter.print(char[], int, int, boolean)
that assumes filter is enabled.
printRaw
in interface IMarkupWriter
public void print(char[] buffer, int offset, int length, boolean raw)
IMarkupWriter
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.
print
in interface IMarkupWriter
buffer
- contains the characters to print, or null to not print anythingoffset
- offset into the array to start printing fromlength
- number of characters to printraw
- if true, filtering is disabledpublic void print(String value)
IMarkupWriter
IMarkupWriter.print(char[], int, int, boolean)
, but the data to print is defined by the
String. Assumes filtering is enabled.
print
in interface IMarkupWriter
public void printRaw(String value)
IMarkupWriter
IMarkupWriter.print(char[], int, int, boolean)
, but the data to print is defined by the
String. Assumes filtering is disabled.
printRaw
in interface IMarkupWriter
public void print(String value, boolean raw)
IMarkupWriter
IMarkupWriter.print(char[], int, int, boolean)
, but the data to print is defined by the
String.
print
in interface IMarkupWriter
public void print(char value)
IMarkupWriter
Closes any open tag.
print
in interface IMarkupWriter
public void print(int value)
IMarkupWriter
Closes any open tag.
print
in interface IMarkupWriter
public void println()
IMarkupWriter
println
in interface IMarkupWriter
public String getContentType()
IMarkupWriter
getContentType
in interface IMarkupWriter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |